Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: run when finished #267

Merged
merged 2 commits into from
Jan 11, 2023
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 @@ -105,12 +105,13 @@ export class OrderFulfilledHandler
this.substrateService.api as any,
this.substrateService.pair,
requestId,
);

await this.callbackSendReward(
order,
amountToForward / currencyUnit[order.currency],
blockNumber,
async () => {
await this.callbackSendReward(
order,
amountToForward / currencyUnit[order.currency],
blockNumber,
);
},
);
}

Expand Down Expand Up @@ -176,12 +177,21 @@ export class OrderFulfilledHandler
BigInt(fixedRewardLab) * BigInt(currencyUnit.DBIO)
).toString();

// Send reward to customer
// Send reward to Customer
await sendRewards(
this.substrateService.api as any,
this.substrateService.pair,
order.customerId,
dbioRewardCustomer,
async () => {
// Send reward to Lab
await sendRewards(
this.substrateService.api as any,
this.substrateService.pair,
order.sellerId,
dbioRewardLab,
);
},
);

// Write Logging Notification Customer Reward From Request Service
Expand Down Expand Up @@ -215,14 +225,6 @@ export class OrderFulfilledHandler
};
await this.loggingService.create(dataCustomerLoggingInput);

// Send reward to lab
await sendRewards(
this.substrateService.api as any,
this.substrateService.pair,
order.sellerId,
dbioRewardLab,
);

// Write Logging Notification Lab Reward From Request Service
const labNotificationInput: NotificationDto = {
role: 'Lab',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ describe('Order Fulfilled Handler Event', () => {

expect(sendRewardsSpy).toHaveBeenCalled();
expect(transactionLoggingServiceMock.create).toHaveBeenCalled();
expect(sendRewardsSpy).toHaveBeenCalledTimes(2);
expect(transactionLoggingServiceMock.create).toHaveBeenCalledTimes(2);
}, 12000);
});