diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-merchant.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-merchant.ts | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index 19eb40f3a..25153f9fb 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -95,7 +95,7 @@ import { TalerError, TalerProtocolViolationError, } from "@gnu-taler/taler-util"; -import { GetReadWriteAccess } from "../index.js"; +import { GetReadWriteAccess, PendingTaskType } from "../index.js"; import { EXCHANGE_COINS_LOCK, InternalWalletState, @@ -119,8 +119,9 @@ import { OperationAttemptResult, OperationAttemptResultType, RetryInfo, - RetryTags, + TaskIdentifiers, scheduleRetry, + constructTaskIdentifier, } from "../util/retries.js"; import { makeTransactionId, @@ -360,7 +361,7 @@ export async function processDownloadProposal( requestBody.token = proposal.claimToken; } - const opId = RetryTags.forPay(proposal); + const opId = TaskIdentifiers.forPay(proposal); const retryRecord = await ws.db .mktx((x) => [x.operationRetries]) .runReadOnly(async (tx) => { @@ -1598,8 +1599,11 @@ export async function runPayForConfirmPay( proposalId: string, ): Promise<ConfirmPayResult> { logger.trace("processing proposal for confirmPay"); - const opId = RetryTags.byPaymentProposalId(proposalId); - const res = await runOperationWithErrorReporting(ws, opId, async () => { + const taskId = constructTaskIdentifier({ + tag: PendingTaskType.Purchase, + proposalId, + }); + const res = await runOperationWithErrorReporting(ws, taskId, async () => { return await processPurchasePay(ws, proposalId, { forceNow: true }); }); logger.trace(`processPurchasePay response type ${res.type}`); @@ -1624,9 +1628,7 @@ export async function runPayForConfirmPay( // We hide transient errors from the caller. const opRetry = await ws.db .mktx((x) => [x.operationRetries]) - .runReadOnly(async (tx) => - tx.operationRetries.get(RetryTags.byPaymentProposalId(proposalId)), - ); + .runReadOnly(async (tx) => tx.operationRetries.get(taskId)); return { type: ConfirmPayResultType.Pending, lastError: opRetry?.lastError, @@ -1792,9 +1794,7 @@ export async function confirmPay( export async function processPurchase( ws: InternalWalletState, proposalId: string, - options: { - forceNow?: boolean; - } = {}, + options: Record<any, never> = {}, ): Promise<OperationAttemptResult> { const purchase = await ws.db .mktx((x) => [x.purchases]) @@ -1843,9 +1843,7 @@ export async function processPurchase( export async function processPurchasePay( ws: InternalWalletState, proposalId: string, - options: { - forceNow?: boolean; - } = {}, + options: unknown = {}, ): Promise<OperationAttemptResult> { const purchase = await ws.db .mktx((x) => [x.purchases]) @@ -1935,7 +1933,7 @@ export async function processPurchasePay( handleInsufficientFunds(ws, proposalId, err).catch(async (e) => { console.log("handling insufficient funds failed"); - await scheduleRetry(ws, RetryTags.forPay(purchase), { + await scheduleRetry(ws, TaskIdentifiers.forPay(purchase), { code: TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION, when: AbsoluteTime.now(), message: "unexpected exception", @@ -2830,7 +2828,10 @@ export async function abortPay( proposalId: string, cancelImmediately?: boolean, ): Promise<void> { - const opId = RetryTags.byPaymentProposalId(proposalId); + const opId = constructTaskIdentifier({ + tag: PendingTaskType.Purchase, + proposalId, + }); await ws.db .mktx((x) => [ x.purchases, |