From dd7cc6f886122eb5cec8428e2edf28ddb95aa520 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 13 Dec 2023 08:28:06 +0100 Subject: -comment --- .../src/operations/pay-peer-push-credit.ts | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'packages/taler-wallet-core') 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 575780ba4..1174ccc8e 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 @@ -193,10 +193,10 @@ export async function preparePeerPushCredit( undefined, ); - await ws.db + const transitionInfo = await ws.db .mktx((x) => [x.contractTerms, x.peerPushCredit]) .runReadWrite(async (tx) => { - await tx.peerPushCredit.add({ + const rec: PeerPushPaymentIncomingRecord = { peerPushCreditId, contractPriv: contractPriv, exchangeBaseUrl: exchangeBaseUrl, @@ -210,14 +210,30 @@ export async function preparePeerPushCredit( estimatedAmountEffective: Amounts.stringify( wi.withdrawalAmountEffective, ), - }); - + }; + await tx.peerPushCredit.add(rec); await tx.contractTerms.put({ h: contractTermsHash, contractTermsRaw: dec.contractTerms, }); + + const newTxState = computePeerPushCreditTransactionState(rec); + + return { + oldTxState: { + major: TransactionMajorState.None, + }, + newTxState, + } satisfies TransitionInfo; }); + const transactionId = constructTransactionIdentifier({ + tag: TransactionType.PeerPushCredit, + peerPushCreditId, + }); + + notifyTransition(ws, transactionId, transitionInfo); + ws.notify({ type: NotificationType.BalanceChange }); return { @@ -226,10 +242,7 @@ export async function preparePeerPushCredit( amountRaw: purseStatus.balance, contractTerms: dec.contractTerms, peerPushCreditId, - transactionId: constructTransactionIdentifier({ - tag: TransactionType.PeerPushCredit, - peerPushCreditId, - }), + transactionId, exchangeBaseUrl, }; } @@ -481,6 +494,7 @@ async function handlePendingMerge( tx, withdrawalGroupPrep, ); + withdrawalTransition = wgRes.transitionInfo; peerInc.withdrawalGroupId = wgRes.withdrawalGroup.withdrawalGroupId; break; } -- cgit v1.2.3