aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/transactions.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-09-08 11:45:31 +0200
committerFlorian Dold <florian@dold.me>2023-09-08 11:45:31 +0200
commit132ece8e53d2c7d69c943a2898ed07411c63f12f (patch)
treedbe97c498c5853efd844aab4502ae97d8dec7b4a /packages/taler-wallet-core/src/operations/transactions.ts
parentc660db82c12e08020661828f1d8383baa7ef0e02 (diff)
downloadwallet-core-132ece8e53d2c7d69c943a2898ed07411c63f12f.tar.xz
wallet-core: store contract terms in separate object store only
Diffstat (limited to 'packages/taler-wallet-core/src/operations/transactions.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts64
1 files changed, 27 insertions, 37 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index 5c57195c1..ff9fbf57a 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -154,7 +154,18 @@ import {
resumePeerPushDebitTransaction,
abortPeerPushDebitTransaction,
} from "./pay-peer-push-debit.js";
-import { iterRecordsForDeposit, iterRecordsForPeerPullDebit, iterRecordsForPeerPullInitiation, iterRecordsForPeerPushCredit, iterRecordsForPeerPushInitiation, iterRecordsForPurchase, iterRecordsForRefresh, iterRecordsForRefund, iterRecordsForReward, iterRecordsForWithdrawal } from "./pending.js";
+import {
+ iterRecordsForDeposit,
+ iterRecordsForPeerPullDebit,
+ iterRecordsForPeerPullInitiation,
+ iterRecordsForPeerPushCredit,
+ iterRecordsForPeerPushInitiation,
+ iterRecordsForPurchase,
+ iterRecordsForRefresh,
+ iterRecordsForRefund,
+ iterRecordsForReward,
+ iterRecordsForWithdrawal,
+} from "./pending.js";
const logger = new Logger("taler-wallet-core:transactions.ts");
@@ -337,9 +348,7 @@ export async function getTransactionById(
return await ws.db
.mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- const debit = await tx.peerPullDebit.get(
- parsedTx.peerPullDebitId,
- );
+ const debit = await tx.peerPullDebit.get(parsedTx.peerPullDebitId);
if (!debit) throw Error("not found");
return buildTransactionForPullPaymentDebit(debit);
});
@@ -349,9 +358,7 @@ export async function getTransactionById(
return await ws.db
.mktx((x) => [x.peerPushDebit, x.contractTerms])
.runReadWrite(async (tx) => {
- const debit = await tx.peerPushDebit.get(
- parsedTx.pursePub,
- );
+ const debit = await tx.peerPushDebit.get(parsedTx.pursePub);
if (!debit) throw Error("not found");
const ct = await tx.contractTerms.get(debit.contractTermsHash);
checkDbInvariant(!!ct);
@@ -372,9 +379,7 @@ export async function getTransactionById(
x.operationRetries,
])
.runReadWrite(async (tx) => {
- const pushInc = await tx.peerPushCredit.get(
- peerPushCreditId,
- );
+ const pushInc = await tx.peerPushCredit.get(peerPushCreditId);
if (!pushInc) throw Error("not found");
const ct = await tx.contractTerms.get(pushInc.contractTermsHash);
checkDbInvariant(!!ct);
@@ -532,8 +537,8 @@ function buildTransactionForPeerPullCredit(
// Old transactions don't have it!
timestamp: pullCredit.mergeTimestamp ?? TalerPreciseTimestamp.now(),
info: {
- expiration: wsr.wgInfo.contractTerms.purse_expiration,
- summary: wsr.wgInfo.contractTerms.summary,
+ expiration: peerContractTerms.purse_expiration,
+ summary: peerContractTerms.summary,
},
talerUri: stringifyPayPullUri({
exchangeBaseUrl: wsr.exchangeBaseUrl,
@@ -600,8 +605,8 @@ function buildTransactionForPeerPushCredit(
amountRaw: Amounts.stringify(wsr.instructedAmount),
exchangeBaseUrl: wsr.exchangeBaseUrl,
info: {
- expiration: wsr.wgInfo.contractTerms.purse_expiration,
- summary: wsr.wgInfo.contractTerms.summary,
+ expiration: peerContractTerms.purse_expiration,
+ summary: peerContractTerms.summary,
},
timestamp: wsr.timestampStart,
transactionId: constructTransactionIdentifier({
@@ -1033,7 +1038,7 @@ export async function getTransactions(
),
);
});
-
+
await iterRecordsForPeerPullInitiation(tx, filter, async (pi) => {
const currency = Amounts.currencyOf(pi.amount);
if (shouldSkipCurrency(transactionsRequest, currency)) {
@@ -1078,7 +1083,7 @@ export async function getTransactions(
);
transactions.push(buildTransactionForRefund(refundGroup, contractData));
});
-
+
await iterRecordsForRefresh(tx, filter, async (rg) => {
if (shouldSkipCurrency(transactionsRequest, rg.currency)) {
return;
@@ -1099,7 +1104,7 @@ export async function getTransactions(
}
});
- await iterRecordsForWithdrawal(tx, filter ,async (wsr) => {
+ await iterRecordsForWithdrawal(tx, filter, async (wsr) => {
if (
shouldSkipCurrency(
transactionsRequest,
@@ -1643,15 +1648,9 @@ export async function deleteTransaction(
case TransactionType.PeerPushCredit: {
const peerPushCreditId = parsedTx.peerPushCreditId;
await ws.db
- .mktx((x) => [
- x.withdrawalGroups,
- x.peerPushCredit,
- x.tombstones,
- ])
+ .mktx((x) => [x.withdrawalGroups, x.peerPushCredit, x.tombstones])
.runReadWrite(async (tx) => {
- const pushInc = await tx.peerPushCredit.get(
- peerPushCreditId,
- );
+ const pushInc = await tx.peerPushCredit.get(peerPushCreditId);
if (!pushInc) {
return;
}
@@ -1670,10 +1669,7 @@ export async function deleteTransaction(
}
await tx.peerPushCredit.delete(peerPushCreditId);
await tx.tombstones.put({
- id:
- TombstoneTag.DeletePeerPushCredit +
- ":" +
- peerPushCreditId,
+ id: TombstoneTag.DeletePeerPushCredit + ":" + peerPushCreditId,
});
});
return;
@@ -1682,11 +1678,7 @@ export async function deleteTransaction(
case TransactionType.PeerPullCredit: {
const pursePub = parsedTx.pursePub;
await ws.db
- .mktx((x) => [
- x.withdrawalGroups,
- x.peerPullCredit,
- x.tombstones,
- ])
+ .mktx((x) => [x.withdrawalGroups, x.peerPullCredit, x.tombstones])
.runReadWrite(async (tx) => {
const pullIni = await tx.peerPullCredit.get(pursePub);
if (!pullIni) {
@@ -1813,9 +1805,7 @@ export async function deleteTransaction(
await ws.db
.mktx((x) => [x.peerPullDebit, x.tombstones])
.runReadWrite(async (tx) => {
- const debit = await tx.peerPullDebit.get(
- peerPullDebitId,
- );
+ const debit = await tx.peerPullDebit.get(peerPullDebitId);
if (debit) {
await tx.peerPullDebit.delete(peerPullDebitId);
await tx.tombstones.put({ id: transactionId });