Skip to content

Commit

Permalink
feat(backend):Check quote expiry in outgoing payment worker (interled…
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinsMunene committed Dec 11, 2024
1 parent 5de6208 commit e449c22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,9 @@ export enum LifecycleError {
MissingBalance = 'MissingBalance',
MissingQuote = 'MissingQuote',
MissingExpiration = 'MissingExpiration',
Unauthorized = 'Unauthorized'
Unauthorized = 'Unauthorized',

// To be thrown when a Quote has expired
QuoteExpired = 'QuoteExpired'

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LifecycleError } from './errors'
import { LifecycleError, OutgoingPaymentError } from './errors'
import {
OutgoingPayment,
OutgoingPaymentState,
Expand All @@ -17,6 +17,11 @@ export async function handleSending(
): Promise<void> {
if (!payment.quote) throw LifecycleError.MissingQuote

// Check if the current time is greater than or equal to when the Quote should be expiring
if (Date.now() >= payment.quote.expiresAt.getTime()) {
throw LifecycleError.QuoteExpired
}

const receiver = await deps.receiverService.get(payment.receiver)

// TODO: Query TigerBeetle transfers by code to distinguish sending debits from withdrawals
Expand Down

0 comments on commit e449c22

Please sign in to comment.