diff options
author | Florian Dold <florian@dold.me> | 2023-05-26 14:12:11 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-05-26 14:12:11 +0200 |
commit | dad7d48ed2d7cd6f17466889395b49023e4b5097 (patch) | |
tree | dbaaa37c4df857f522486bb0fdd4df4327193e04 /packages/taler-wallet-core/src | |
parent | 96d9ea3840626f71efe38018b75748d8338565fa (diff) | |
download | wallet-core-dad7d48ed2d7cd6f17466889395b49023e4b5097.tar.xz |
wallet-core: fix withdrawal abort
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/operations/withdraw.ts | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 586aa50f5..ae170fa2c 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -290,37 +290,34 @@ export async function abortWithdrawalTransaction( } let newStatus: WithdrawalGroupStatus | undefined = undefined; switch (wg.status) { + case WithdrawalGroupStatus.SuspendedRegisteringBank: + case WithdrawalGroupStatus.SuspendedWaitConfirmBank: case WithdrawalGroupStatus.PendingWaitConfirmBank: case WithdrawalGroupStatus.PendingRegisteringBank: - case WithdrawalGroupStatus.AbortingBank: newStatus = WithdrawalGroupStatus.AbortingBank; break; + case WithdrawalGroupStatus.SuspendedAml: + case WithdrawalGroupStatus.SuspendedKyc: + case WithdrawalGroupStatus.SuspendedQueryingStatus: + case WithdrawalGroupStatus.SuspendedReady: case WithdrawalGroupStatus.PendingAml: - newStatus = WithdrawalGroupStatus.SuspendedAml; - break; case WithdrawalGroupStatus.PendingKyc: - newStatus = WithdrawalGroupStatus.SuspendedKyc; - break; case WithdrawalGroupStatus.PendingQueryingStatus: - newStatus = WithdrawalGroupStatus.SuspendedQueryingStatus; + newStatus = WithdrawalGroupStatus.AbortedExchange; break; case WithdrawalGroupStatus.PendingReady: newStatus = WithdrawalGroupStatus.SuspendedReady; break; case WithdrawalGroupStatus.SuspendedAbortingBank: - case WithdrawalGroupStatus.SuspendedQueryingStatus: - case WithdrawalGroupStatus.SuspendedAml: - case WithdrawalGroupStatus.SuspendedKyc: - case WithdrawalGroupStatus.SuspendedReady: - // No transition needed + case WithdrawalGroupStatus.AbortingBank: + // No transition needed, but not an error break; - case WithdrawalGroupStatus.SuspendedRegisteringBank: - case WithdrawalGroupStatus.SuspendedWaitConfirmBank: case WithdrawalGroupStatus.Finished: case WithdrawalGroupStatus.FailedBankAborted: case WithdrawalGroupStatus.AbortedExchange: case WithdrawalGroupStatus.FailedAbortingBank: // Not allowed + throw Error("abort not allowed in current state"); break; default: assertUnreachable(wg.status); @@ -1911,9 +1908,8 @@ async function registerReserveWithBank( if (r.wgInfo.withdrawalType !== WithdrawalRecordType.BankIntegrated) { throw Error("invariant failed"); } - r.wgInfo.bankInfo.timestampReserveInfoPosted = AbsoluteTime.toPreciseTimestamp( - AbsoluteTime.now(), - ); + r.wgInfo.bankInfo.timestampReserveInfoPosted = + AbsoluteTime.toPreciseTimestamp(AbsoluteTime.now()); const oldTxState = computeWithdrawalTransactionStatus(r); r.status = WithdrawalGroupStatus.PendingWaitConfirmBank; const newTxState = computeWithdrawalTransactionStatus(r); |