diff options
author | Florian Dold <florian@dold.me> | 2024-01-08 21:17:00 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-01-08 21:17:08 +0100 |
commit | 6f2b03021d7946a61d6b8e53dbba7fc10e5f9a4d (patch) | |
tree | 82a3985ab7267e6f4a57c0b275f1929558b5e572 /packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts | |
parent | c019f4c040e82baebdbbda8208f10be2fbc19566 (diff) | |
download | wallet-core-6f2b03021d7946a61d6b8e53dbba7fc10e5f9a4d.tar.xz |
wallet-core: exchange management cleanup
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts index 78263c4c3..6b7b62393 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts @@ -69,7 +69,7 @@ import { constructTaskIdentifier, runLongpollAsync, } from "./common.js"; -import { fetchFreshExchange } from "./exchanges.js"; +import { fetchFreshExchange, markExchangeUsed } from "./exchanges.js"; import { codecForExchangePurseStatus, getMergeReserveInfo, @@ -82,6 +82,7 @@ import { stopLongpolling, } from "./transactions.js"; import { + PerformCreateWithdrawalGroupResult, getExchangeWithdrawalInfo, internalPerformCreateWithdrawalGroup, internalPrepareCreateWithdrawalGroup, @@ -486,19 +487,20 @@ async function handlePendingMerge( if (!peerInc) { return undefined; } - let withdrawalTransition: TransitionInfo | undefined; const oldTxState = computePeerPushCreditTransactionState(peerInc); + let wgCreateRes: PerformCreateWithdrawalGroupResult | undefined = + undefined; switch (peerInc.status) { case PeerPushCreditStatus.PendingMerge: case PeerPushCreditStatus.PendingMergeKycRequired: { peerInc.status = PeerPushCreditStatus.PendingWithdrawing; - const wgRes = await internalPerformCreateWithdrawalGroup( + wgCreateRes = await internalPerformCreateWithdrawalGroup( ws, tx, withdrawalGroupPrep, ); - withdrawalTransition = wgRes.transitionInfo; - peerInc.withdrawalGroupId = wgRes.withdrawalGroup.withdrawalGroupId; + peerInc.withdrawalGroupId = + wgCreateRes.withdrawalGroup.withdrawalGroupId; break; } } @@ -506,13 +508,17 @@ async function handlePendingMerge( const newTxState = computePeerPushCreditTransactionState(peerInc); return { peerPushCreditTransition: { oldTxState, newTxState }, - withdrawalTransition, + wgCreateRes, }; }); + // Transaction was commited, now we can emit notifications. + if (txRes?.wgCreateRes?.exchangeNotif) { + ws.notify(txRes.wgCreateRes.exchangeNotif); + } notifyTransition( ws, withdrawalGroupPrep.transactionId, - txRes?.withdrawalTransition, + txRes?.wgCreateRes?.transitionInfo, ); notifyTransition(ws, transactionId, txRes?.peerPushCreditTransition); |