From 000359a5e746d9b704b05f2f3eb8442e10a31f75 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 30 May 2023 12:28:21 +0200 Subject: finish implementation of abort / cancelAborting on all tx types --- .../src/operations/transactions.ts | 67 ++++++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/transactions.ts') diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index f1cfaed45..d424019ac 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -82,6 +82,7 @@ import { import { getExchangeDetails } from "./exchanges.js"; import { abortPayMerchant, + cancelAbortingPaymentTransaction, computePayMerchantTransactionState, computeRefundTransactionState, expectProposalDownload, @@ -90,6 +91,14 @@ import { suspendPayMerchant, } from "./pay-merchant.js"; import { + abortPeerPullCreditTransaction, + abortPeerPullDebitTransaction, + abortPeerPushCreditTransaction, + abortPeerPushDebitTransaction, + cancelAbortingPeerPullCreditTransaction, + cancelAbortingPeerPullDebitTransaction, + cancelAbortingPeerPushCreditTransaction, + cancelAbortingPeerPushDebitTransaction, computePeerPullCreditTransactionState, computePeerPullDebitTransactionState, computePeerPushCreditTransactionState, @@ -104,11 +113,15 @@ import { suspendPeerPushDebitTransaction, } from "./pay-peer.js"; import { + abortRefreshGroup, + cancelAbortingRefreshGroup, computeRefreshTransactionState, resumeRefreshGroup, suspendRefreshGroup, } from "./refresh.js"; import { + abortTipTransaction, + cancelAbortingTipTransaction, computeTipTransactionStatus, resumeTipTransaction, suspendTipTransaction, @@ -1492,11 +1505,35 @@ export async function cancelAbortingTransaction( case TransactionType.Deposit: await cancelAbortingDepositGroup(ws, tx.depositGroupId); return; + case TransactionType.InternalWithdrawal: case TransactionType.Withdrawal: await cancelAbortingWithdrawalTransaction(ws, tx.withdrawalGroupId); return; + case TransactionType.Payment: + await cancelAbortingPaymentTransaction(ws, tx.proposalId); + return; + case TransactionType.Refund: + throw Error("can't do cancel-aborting on refund transaction"); + case TransactionType.Tip: + await cancelAbortingTipTransaction(ws, tx.walletTipId); + return; + case TransactionType.Refresh: + await cancelAbortingRefreshGroup(ws, tx.refreshGroupId); + return; + case TransactionType.PeerPullCredit: + await cancelAbortingPeerPullCreditTransaction(ws, tx.pursePub); + return; + case TransactionType.PeerPullDebit: + await cancelAbortingPeerPullDebitTransaction(ws, tx.peerPullPaymentIncomingId); + return; + case TransactionType.PeerPushCredit: + await cancelAbortingPeerPushCreditTransaction(ws, tx.peerPushPaymentIncomingId); + return; + case TransactionType.PeerPushDebit: + await cancelAbortingPeerPushDebitTransaction(ws, tx.pursePub); + return; default: - logger.warn(`unable to suspend transaction of type '${tx.tag}'`); + assertUnreachable(tx); } } @@ -1774,18 +1811,36 @@ export async function abortTransaction( await abortPayMerchant(ws, txId.proposalId); break; } - case TransactionType.Withdrawal: { + case TransactionType.Withdrawal: + case TransactionType.InternalWithdrawal: { await abortWithdrawalTransaction(ws, txId.withdrawalGroupId); break; } case TransactionType.Deposit: await abortDepositGroup(ws, txId.depositGroupId); break; + case TransactionType.Tip: + await abortTipTransaction(ws, txId.walletTipId); + break; + case TransactionType.Refund: + throw Error("can't abort refund transactions"); + case TransactionType.Refresh: + await abortRefreshGroup(ws, txId.refreshGroupId); + break; + case TransactionType.PeerPullCredit: + await abortPeerPullCreditTransaction(ws, txId.pursePub); + break; + case TransactionType.PeerPullDebit: + await abortPeerPullDebitTransaction(ws, txId.peerPullPaymentIncomingId); + break; + case TransactionType.PeerPushCredit: + await abortPeerPushCreditTransaction(ws, txId.peerPushPaymentIncomingId); + break; + case TransactionType.PeerPushDebit: + await abortPeerPushDebitTransaction(ws, txId.pursePub); + break; default: { - const unknownTxType: any = txId.tag; - throw Error( - `can't abort a '${unknownTxType}' transaction: not yet implemented`, - ); + assertUnreachable(txId); } } } -- cgit v1.2.3