diff options
Diffstat (limited to 'packages/taler-wallet-core/src/pay-peer-push-credit.ts')
-rw-r--r-- | packages/taler-wallet-core/src/pay-peer-push-credit.ts | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/packages/taler-wallet-core/src/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/pay-peer-push-credit.ts index 42a5b19df..e629bffe4 100644 --- a/packages/taler-wallet-core/src/pay-peer-push-credit.ts +++ b/packages/taler-wallet-core/src/pay-peer-push-credit.ts @@ -31,6 +31,7 @@ import { TalerPreciseTimestamp, TalerProtocolTimestamp, TransactionAction, + TransactionIdStr, TransactionMajorState, TransactionMinorState, TransactionState, @@ -55,7 +56,7 @@ import { import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http"; import { PendingTaskType, - TaskId, + TaskIdStr, TaskRunResult, TaskRunResultType, TombstoneTag, @@ -93,8 +94,8 @@ import { const logger = new Logger("pay-peer-push-credit.ts"); export class PeerPushCreditTransactionContext implements TransactionContext { - readonly transactionId: string; - readonly retryTag: TaskId; + readonly transactionId: TransactionIdStr; + readonly taskId: TaskIdStr; constructor( public ws: InternalWalletState, @@ -104,7 +105,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { tag: TransactionType.PeerPushCredit, peerPushCreditId, }); - this.retryTag = constructTaskIdentifier({ + this.taskId = constructTaskIdentifier({ tag: PendingTaskType.PeerPushCredit, peerPushCreditId, }); @@ -140,7 +141,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { } async suspendTransaction(): Promise<void> { - const { ws, peerPushCreditId, retryTag, transactionId } = this; + const { ws, peerPushCreditId, taskId: retryTag, transactionId } = this; const transitionInfo = await ws.db.runReadWriteTx( ["peerPushCredit"], async (tx) => { @@ -194,7 +195,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { } async abortTransaction(): Promise<void> { - const { ws, peerPushCreditId, retryTag, transactionId } = this; + const { ws, peerPushCreditId, taskId: retryTag, transactionId } = this; const transitionInfo = await ws.db.runReadWriteTx( ["peerPushCredit"], async (tx) => { @@ -251,7 +252,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { } async resumeTransaction(): Promise<void> { - const { ws, peerPushCreditId, retryTag, transactionId } = this; + const { ws, peerPushCreditId, taskId: retryTag, transactionId } = this; const transitionInfo = await ws.db.runReadWriteTx( ["peerPushCredit"], async (tx) => { @@ -304,7 +305,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { } async failTransaction(): Promise<void> { - const { ws, peerPushCreditId, retryTag, transactionId } = this; + const { ws, peerPushCreditId, taskId: retryTag, transactionId } = this; const transitionInfo = await ws.db.runReadWriteTx( ["peerPushCredit"], async (tx) => { @@ -575,6 +576,7 @@ async function processPeerPushCreditKycRequired( ws: InternalWalletState, peerInc: PeerPushPaymentIncomingRecord, kycPending: WalletKycUuid, + cancellationToken: CancellationToken, ): Promise<TaskRunResult> { const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, @@ -591,6 +593,7 @@ async function processPeerPushCreditKycRequired( logger.info(`kyc url ${url.href}`); const kycStatusRes = await ws.http.fetch(url.href, { method: "GET", + cancellationToken, }); if ( @@ -651,6 +654,7 @@ async function handlePendingMerge( ws: InternalWalletState, peerInc: PeerPushPaymentIncomingRecord, contractTerms: PeerContractTerms, + cancellationToken: CancellationToken, ): Promise<TaskRunResult> { const { peerPushCreditId } = peerInc; const transactionId = constructTransactionIdentifier({ @@ -705,7 +709,12 @@ async function handlePendingMerge( const respJson = await mergeHttpResp.json(); const kycPending = codecForWalletKycUuid().decode(respJson); logger.info(`kyc uuid response: ${j2s(kycPending)}`); - return processPeerPushCreditKycRequired(ws, peerInc, kycPending); + return processPeerPushCreditKycRequired( + ws, + peerInc, + kycPending, + cancellationToken, + ); } logger.trace(`merge request: ${j2s(mergeReq)}`); @@ -887,7 +896,7 @@ export async function processPeerPushCredit( } case PeerPushCreditStatus.PendingMerge: - return handlePendingMerge(ws, peerInc, contractTerms); + return handlePendingMerge(ws, peerInc, contractTerms, cancellationToken); case PeerPushCreditStatus.PendingWithdrawing: return handlePendingWithdrawing(ws, peerInc); @@ -940,7 +949,7 @@ export async function confirmPeerPushCredit( const ctx = new PeerPushCreditTransactionContext(ws, peerPushCreditId); - ws.taskScheduler.startShepherdTask(ctx.retryTag); + ws.taskScheduler.startShepherdTask(ctx.taskId); const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, |