Skip to content

Commit

Permalink
feat(2981): make use of cache for outgoing payment.
Browse files Browse the repository at this point in the history
  • Loading branch information
koekiebox committed Nov 22, 2024
1 parent d55d93e commit cbc2ee3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ export function initIocContainer(
peerService: await deps.use('peerService'),
walletAddressService: await deps.use('walletAddressService'),
quoteService: await deps.use('quoteService'),
assetService: await deps.use('assetService'),
telemetry: await deps.use('telemetry')
})
})
Expand Down
23 changes: 13 additions & 10 deletions packages/backend/src/open_payments/payment/outgoing/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { isQuoteError } from '../../quote/errors'
import { Pagination, SortOrder } from '../../../shared/baseModel'
import { FilterString } from '../../../shared/filters'
import { IAppConfig } from '../../../config/app'
import { AssetService } from '../../../asset/service'

export interface OutgoingPaymentService
extends WalletAddressSubresourceService<OutgoingPayment> {
Expand All @@ -68,6 +69,7 @@ export interface ServiceDependencies extends BaseService {
paymentMethodHandlerService: PaymentMethodHandlerService
walletAddressService: WalletAddressService
quoteService: QuoteService
assetService: AssetService
telemetry: TelemetryService
}

Expand Down Expand Up @@ -294,16 +296,17 @@ async function createOutgoingPayment(
description: 'Time to insert payment in outgoing payment'
}
)
const payment = await OutgoingPayment.query(trx)
.insertAndFetch({
id: quoteId,
walletAddressId: walletAddressId,
client: options.client,
metadata: options.metadata,
state: OutgoingPaymentState.Funding,
grantId
})
.withGraphFetched('[quote.asset, walletAddress]')
const payment = await OutgoingPayment.query(trx).insertAndFetch({
id: quoteId,
walletAddressId: walletAddressId,
client: options.client,
metadata: options.metadata,
state: OutgoingPaymentState.Funding,
grantId
})
await deps.assetService.setOn(payment.quote)
await deps.walletAddressService.setOn(payment)

stopTimerInsertPayment()

if (
Expand Down

0 comments on commit cbc2ee3

Please sign in to comment.