aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/transactions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/transactions.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts32
1 files changed, 20 insertions, 12 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index a16809b36..7f5302b25 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -36,6 +36,7 @@ import {
TransactionByIdRequest,
TransactionIdStr,
TransactionMajorState,
+ TransactionRecordFilter,
TransactionsRequest,
TransactionsResponse,
TransactionState,
@@ -153,6 +154,7 @@ import {
resumePeerPushDebitTransaction,
abortPeerPushDebitTransaction,
} from "./pay-peer-push-debit.js";
+import { iterRecordsForDeposit, iterRecordsForPeerPullDebit, iterRecordsForPeerPullInitiation, iterRecordsForPeerPushCredit, iterRecordsForPeerPushInitiation, iterRecordsForPurchase, iterRecordsForRefresh, iterRecordsForRefund, iterRecordsForReward, iterRecordsForWithdrawal } from "./pending.js";
const logger = new Logger("taler-wallet-core:transactions.ts");
@@ -929,6 +931,11 @@ export async function getTransactions(
): Promise<TransactionsResponse> {
const transactions: Transaction[] = [];
+ const filter: TransactionRecordFilter = {};
+ if (transactionsRequest?.filterByState) {
+ filter.onlyState = transactionsRequest.filterByState;
+ }
+
await ws.db
.mktx((x) => [
x.coins,
@@ -952,7 +959,7 @@ export async function getTransactions(
x.refundGroups,
])
.runReadOnly(async (tx) => {
- tx.peerPushPaymentInitiations.iter().forEachAsync(async (pi) => {
+ await iterRecordsForPeerPushInitiation(tx, filter, async (pi) => {
const amount = Amounts.parseOrThrow(pi.amount);
if (shouldSkipCurrency(transactionsRequest, amount.currency)) {
@@ -968,7 +975,7 @@ export async function getTransactions(
);
});
- tx.peerPullPaymentIncoming.iter().forEachAsync(async (pi) => {
+ await iterRecordsForPeerPullDebit(tx, filter, async (pi) => {
const amount = Amounts.parseOrThrow(pi.contractTerms.amount);
if (shouldSkipCurrency(transactionsRequest, amount.currency)) {
return;
@@ -986,7 +993,7 @@ export async function getTransactions(
transactions.push(buildTransactionForPullPaymentDebit(pi));
});
- tx.peerPushPaymentIncoming.iter().forEachAsync(async (pi) => {
+ await iterRecordsForPeerPushCredit(tx, filter, async (pi) => {
if (!pi.currency) {
// Legacy transaction
return;
@@ -1026,8 +1033,8 @@ export async function getTransactions(
),
);
});
-
- tx.peerPullPaymentInitiations.iter().forEachAsync(async (pi) => {
+
+ await iterRecordsForPeerPullInitiation(tx, filter, async (pi) => {
const currency = Amounts.currencyOf(pi.amount);
if (shouldSkipCurrency(transactionsRequest, currency)) {
return;
@@ -1060,7 +1067,7 @@ export async function getTransactions(
);
});
- tx.refundGroups.iter().forEachAsync(async (refundGroup) => {
+ await iterRecordsForRefund(tx, filter, async (refundGroup) => {
const currency = Amounts.currencyOf(refundGroup.amountRaw);
if (shouldSkipCurrency(transactionsRequest, currency)) {
return;
@@ -1071,8 +1078,8 @@ export async function getTransactions(
);
transactions.push(buildTransactionForRefund(refundGroup, contractData));
});
-
- tx.refreshGroups.iter().forEachAsync(async (rg) => {
+
+ await iterRecordsForRefresh(tx, filter, async (rg) => {
if (shouldSkipCurrency(transactionsRequest, rg.currency)) {
return;
}
@@ -1092,7 +1099,7 @@ export async function getTransactions(
}
});
- tx.withdrawalGroups.iter().forEachAsync(async (wsr) => {
+ await iterRecordsForWithdrawal(tx, filter ,async (wsr) => {
if (
shouldSkipCurrency(
transactionsRequest,
@@ -1146,7 +1153,7 @@ export async function getTransactions(
}
});
- tx.depositGroups.iter().forEachAsync(async (dg) => {
+ await iterRecordsForDeposit(tx, filter, async (dg) => {
const amount = Amounts.parseOrThrow(dg.contractTermsRaw.amount);
if (shouldSkipCurrency(transactionsRequest, amount.currency)) {
return;
@@ -1157,7 +1164,7 @@ export async function getTransactions(
transactions.push(buildTransactionForDeposit(dg, retryRecord));
});
- tx.purchases.iter().forEachAsync(async (purchase) => {
+ await iterRecordsForPurchase(tx, filter, async (purchase) => {
const download = purchase.download;
if (!download) {
return;
@@ -1200,7 +1207,7 @@ export async function getTransactions(
);
});
- tx.rewards.iter().forEachAsync(async (tipRecord) => {
+ await iterRecordsForReward(tx, filter, async (tipRecord) => {
if (
shouldSkipCurrency(
transactionsRequest,
@@ -1909,4 +1916,5 @@ export function notifyTransition(
transactionId,
});
}
+ ws.workAvailable.trigger();
}