Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class EscrowCompletionService {
const escrowStatus = await escrowClient.getStatus(
escrowCompletionEntity.escrowAddress,
);
let toComplete = false;
if (
escrowStatus === EscrowStatus.Pending ||
escrowStatus === EscrowStatus.ToCancel
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -241,6 +243,7 @@ export class EscrowCompletionService {
EscrowStatus.Partial,
EscrowStatus.Paid,
EscrowStatus.ToCancel,
EscrowStatus.Pending,
].includes(escrowStatus)
) {
const feeOverrides = await this.web3Service.calculateTxFees(chainId);
Expand Down
Loading