diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts index 05cf177b2d..9a25ef222b 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.spec.ts @@ -1035,7 +1035,7 @@ describe('EscrowCompletionService', () => { }); }); - it.each([EscrowStatus.Partial, EscrowStatus.Paid])( + it.each([EscrowStatus.Partial, EscrowStatus.Paid, EscrowStatus.Pending])( 'should properly complete escrow with status "%s"', async (escrowStatus) => { mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ @@ -1123,12 +1123,8 @@ describe('EscrowCompletionService', () => { }, ); - it.each([ - EscrowStatus.Cancelled, - EscrowStatus.Pending, - EscrowStatus.Complete, - ])( - 'should not comlete escrow if its status is not partial or paid [%#]', + it.each([EscrowStatus.Cancelled, EscrowStatus.Complete])( + 'should not complete escrow if its status is not completable [%#]', async (escrowStatus) => { mockedEscrowUtils.getEscrow.mockResolvedValueOnce({ launcher: launcherAddress, diff --git a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts index 51c281bceb..44f2ff212e 100644 --- a/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts +++ b/packages/apps/reputation-oracle/server/src/modules/escrow-completion/escrow-completion.service.ts @@ -122,6 +122,7 @@ export class EscrowCompletionService { const escrowStatus = await escrowClient.getStatus( escrowCompletionEntity.escrowAddress, ); + let toComplete = false; if ( escrowStatus === EscrowStatus.Pending || escrowStatus === EscrowStatus.ToCancel @@ -167,6 +168,7 @@ export class EscrowCompletionService { finalResultsUrl: escrowCompletionEntity.finalResultsUrl, }); + toComplete = calculatedPayouts.length === 0; /** * When creating payout batches we need to guarantee deterministic result, * so order it first. @@ -198,7 +200,7 @@ export class EscrowCompletionService { } escrowCompletionEntity.status = EscrowCompletionStatus.AWAITING_PAYOUTS; - if (escrowStatus === EscrowStatus.Cancelled) { + if (escrowStatus === EscrowStatus.Cancelled || toComplete) { escrowCompletionEntity.status = EscrowCompletionStatus.PAID; } await this.escrowCompletionRepository.updateOne(escrowCompletionEntity); @@ -241,6 +243,7 @@ export class EscrowCompletionService { EscrowStatus.Partial, EscrowStatus.Paid, EscrowStatus.ToCancel, + EscrowStatus.Pending, ].includes(escrowStatus) ) { const feeOverrides = await this.web3Service.calculateTxFees(chainId);