Skip to content

Commit

Permalink
sorting escrow events in getBalance
Browse files Browse the repository at this point in the history
  • Loading branch information
KolevDarko committed Mar 10, 2022
1 parent 2b9ef15 commit a4afa0f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/payment-detection/src/payment-detector-base.ts
Expand Up @@ -33,7 +33,7 @@ export abstract class PaymentDetectorBase<
const events = this.sortEvents(rawPaymentEvents);

const balance = this.computeBalance(events).toString();
const escrowEvents = allNetworkEvents.escrowEvents;
const escrowEvents = this.sortEscrowEvents(allNetworkEvents.escrowEvents || []);
return {
balance,
events,
Expand Down Expand Up @@ -82,6 +82,12 @@ export abstract class PaymentDetectorBase<
return events.sort((a, b) => (a.timestamp || 0) - (b.timestamp || 0));
}

protected sortEscrowEvents(
events: PaymentTypes.EscrowNetworkEvent[],
): PaymentTypes.EscrowNetworkEvent[] {
return events.sort((a, b) => (a.timestamp || 0) - (b.timestamp || 0));
}

protected checkRequiredParameter<T>(value: T | undefined, name: string): asserts value is T {
if (!value) {
throw new ExtensionMissingRequiredValue(this.paymentNetworkId, name);
Expand Down

0 comments on commit a4afa0f

Please sign in to comment.