From a7bd03be68c7a02719d00a624b54e127001bd625 Mon Sep 17 00:00:00 2001 From: Eric Richardson Date: Tue, 7 Nov 2023 12:07:12 -0500 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20fix=20leg-validations=20?= =?UTF-8?q?test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/settlements/dto/leg-validation-params.dto.ts | 6 +++--- src/settlements/settlements.service.spec.ts | 2 +- src/settlements/settlements.service.ts | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/settlements/dto/leg-validation-params.dto.ts b/src/settlements/dto/leg-validation-params.dto.ts index e307e169..e7e4f2c4 100644 --- a/src/settlements/dto/leg-validation-params.dto.ts +++ b/src/settlements/dto/leg-validation-params.dto.ts @@ -16,18 +16,18 @@ export class LegValidationParamsDto { @ValidateIf(({ nfts }) => !nfts) @IsBigNumber() @ToBigNumber() - readonly amount: BigNumber; + readonly amount?: BigNumber; @ApiPropertyOptional({ description: 'The NFT IDs to be transferred for the collection', type: 'string', isArray: true, - example: ['1000'], + example: ['1'], }) @ValidateIf(({ amount }) => !amount) @IsBigNumber() @ToBigNumber() - readonly nfts: BigNumber[]; + readonly nfts?: BigNumber[]; @ApiProperty({ description: 'DID of the sender', diff --git a/src/settlements/settlements.service.spec.ts b/src/settlements/settlements.service.spec.ts index 07a98e11..e54cf591 100644 --- a/src/settlements/settlements.service.spec.ts +++ b/src/settlements/settlements.service.spec.ts @@ -410,7 +410,7 @@ describe('SettlementsService', () => { const mockAsset = new MockAsset(); mockAsset.settlements.canTransfer.mockResolvedValue(mockTransferBreakdown); - mockAssetsService.findFungible.mockResolvedValue(mockAsset); + mockAssetsService.findOne.mockResolvedValue(mockAsset); const result = await service.canTransfer( new PortfolioDto({ did: 'fromDid', id: new BigNumber(1) }).toPortfolioLike(), diff --git a/src/settlements/settlements.service.ts b/src/settlements/settlements.service.ts index e750aa9e..b118bc92 100644 --- a/src/settlements/settlements.service.ts +++ b/src/settlements/settlements.service.ts @@ -142,10 +142,12 @@ export class SettlementsService { from: PortfolioLike, to: PortfolioLike, ticker: string, - amount: BigNumber, - nfts: BigNumber[] + transferAmount?: BigNumber, + transferNfts?: BigNumber[] ): Promise { const assetDetails = await this.assetsService.findOne(ticker); + const amount = transferAmount ?? new BigNumber(0); + const nfts = transferNfts ?? []; return assetDetails.settlements.canTransfer({ from, to, amount, nfts }); }