From 4c20be38607e14a172551ce5519f233c59b75a54 Mon Sep 17 00:00:00 2001 From: F-OBrien Date: Thu, 5 Dec 2024 17:08:29 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20handle=20`tradeDate`?= =?UTF-8?q?=20and=20`valueDate`=20of=20`null`=20in=20instruction=20details?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/entities/Instruction/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/entities/Instruction/index.ts b/src/api/entities/Instruction/index.ts index 235aa916a3..673d3290cf 100644 --- a/src/api/entities/Instruction/index.ts +++ b/src/api/entities/Instruction/index.ts @@ -474,8 +474,8 @@ export class Instruction extends Entity { return { status: middlewareInstructionStatusToInstructionStatus(status), createdAt: new Date(createdBlock!.datetime), - tradeDate: new Date(tradeDate), - valueDate: new Date(valueDate), + tradeDate: tradeDate ? new Date(tradeDate) : null, + valueDate: valueDate ? new Date(valueDate) : null, venue: venueId ? new Venue({ id: new BigNumber(venueId) }, context) : null, memo: memo ?? null, ...endCondition, From 8a915866913ccfbaceca8e1f4e7c56f3989be168 Mon Sep 17 00:00:00 2001 From: Eric Richardson Date: Thu, 5 Dec 2024 12:35:05 -0500 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20cases=20for=20?= =?UTF-8?q?null=20trade/value=20dates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entities/Instruction/__tests__/index.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/api/entities/Instruction/__tests__/index.ts b/src/api/entities/Instruction/__tests__/index.ts index e690117296..b31f4acf3d 100644 --- a/src/api/entities/Instruction/__tests__/index.ts +++ b/src/api/entities/Instruction/__tests__/index.ts @@ -521,6 +521,27 @@ describe('Instruction class', () => { expect(result.venue).toBeNull(); expect(result.memo).toBeNull(); + + dsMockUtils.createApolloQueryMock( + instructionsQuery(false, { + id: id.toString(), + }), + { + instructions: { + nodes: [ + { + ...middlewareInstruction, + valueDate: undefined, + tradeDate: undefined, + }, + ], + }, + } + ); + result = await instruction.details(); + + expect(result.tradeDate).toBeNull(); + expect(result.valueDate).toBeNull(); }); it('should throw an error if an Instruction is not yet processed by middleware', () => {