aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-12-13 08:28:06 +0100
committerFlorian Dold <florian@dold.me>2023-12-13 08:28:06 +0100
commitdd7cc6f886122eb5cec8428e2edf28ddb95aa520 (patch)
tree874ddb0630ed7dcc2af8e6a339561981ef792f29 /packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts
parent00b98cb79d1a99d42fbbf6a09eada615b45e8bf6 (diff)
downloadwallet-core-dd7cc6f886122eb5cec8428e2edf28ddb95aa520.tar.gz
wallet-core-dd7cc6f886122eb5cec8428e2edf28ddb95aa520.tar.bz2
wallet-core-dd7cc6f886122eb5cec8428e2edf28ddb95aa520.zip
-comment
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.ts30
1 files changed, 22 insertions, 8 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 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;
}