diff options
author | Florian Dold <florian@dold.me> | 2023-06-26 19:38:53 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-06-26 19:38:57 +0200 |
commit | 5af24c1e884140d986d1d32b60703b6c3ace524c (patch) | |
tree | ac2123f9fdbcc90a0ff6e436d860377de9561191 | |
parent | a844136489611525726c117cb28086b854bee5c0 (diff) | |
download | wallet-core-5af24c1e884140d986d1d32b60703b6c3ace524c.tar.xz |
wallet-core: fix some deposit transitions
-rw-r--r-- | packages/taler-wallet-core/src/operations/deposits.ts | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index b771fc009..601df4151 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -224,21 +224,30 @@ export async function suspendDepositGroup( return undefined; } const oldState = computeDepositTransactionStatus(dg); + let newOpStatus: DepositOperationStatus | undefined; switch (dg.operationStatus) { - case DepositOperationStatus.Finished: - return undefined; - case DepositOperationStatus.PendingDeposit: { - dg.operationStatus = DepositOperationStatus.SuspendedDeposit; - await tx.depositGroups.put(dg); - return { - oldTxState: oldState, - newTxState: computeDepositTransactionStatus(dg), - }; - } - case DepositOperationStatus.SuspendedDeposit: - return undefined; + case DepositOperationStatus.PendingDeposit: + newOpStatus = DepositOperationStatus.SuspendedDeposit; + break; + case DepositOperationStatus.PendingKyc: + newOpStatus = DepositOperationStatus.SuspendedKyc; + break; + case DepositOperationStatus.PendingTrack: + newOpStatus = DepositOperationStatus.SuspendedTrack; + break; + case DepositOperationStatus.Aborting: + newOpStatus = DepositOperationStatus.SuspendedAborting; + break; } - return undefined; + if (!newOpStatus) { + return undefined; + } + dg.operationStatus = newOpStatus; + await tx.depositGroups.put(dg); + return { + oldTxState: oldState, + newTxState: computeDepositTransactionStatus(dg), + }; }); stopLongpolling(ws, retryTag); notifyTransition(ws, transactionId, transitionInfo); @@ -263,21 +272,30 @@ export async function resumeDepositGroup( return; } const oldState = computeDepositTransactionStatus(dg); + let newOpStatus: DepositOperationStatus | undefined; switch (dg.operationStatus) { - case DepositOperationStatus.Finished: - return; - case DepositOperationStatus.PendingDeposit: { - return; - } case DepositOperationStatus.SuspendedDeposit: - dg.operationStatus = DepositOperationStatus.PendingDeposit; - await tx.depositGroups.put(dg); - return { - oldTxState: oldState, - newTxState: computeDepositTransactionStatus(dg), - }; + newOpStatus = DepositOperationStatus.PendingDeposit; + break; + case DepositOperationStatus.SuspendedAborting: + newOpStatus = DepositOperationStatus.Aborting; + break; + case DepositOperationStatus.SuspendedKyc: + newOpStatus = DepositOperationStatus.PendingKyc; + break; + case DepositOperationStatus.SuspendedTrack: + newOpStatus = DepositOperationStatus.PendingTrack; + break; } - return undefined; + if (!newOpStatus) { + return undefined; + } + dg.operationStatus = newOpStatus; + await tx.depositGroups.put(dg); + return { + oldTxState: oldState, + newTxState: computeDepositTransactionStatus(dg), + }; }); ws.workAvailable.trigger(); notifyTransition(ws, transactionId, transitionInfo); |