diff options
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); |