aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pending.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pending.ts54
1 files changed, 25 insertions, 29 deletions
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts
index 560031ad1..8f9506331 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -24,7 +24,6 @@
import { GlobalIDB } from "@gnu-taler/idb-bridge";
import {
AbsoluteTime,
- TalerErrorDetail,
TalerPreciseTimestamp,
TransactionRecordFilter,
} from "@gnu-taler/taler-util";
@@ -38,11 +37,8 @@ import {
OPERATION_STATUS_ACTIVE_LAST,
PeerPullCreditRecord,
PeerPullDebitRecordStatus,
- PeerPullPaymentCreditStatus,
PeerPullPaymentIncomingRecord,
- PeerPushCreditStatus,
PeerPushDebitRecord,
- PeerPushDebitStatus,
PeerPushPaymentIncomingRecord,
PurchaseRecord,
PurchaseStatus,
@@ -50,17 +46,13 @@ import {
RefreshGroupRecord,
RefreshOperationStatus,
RefundGroupRecord,
- RefundGroupStatus,
RewardRecord,
- RewardRecordStatus,
WalletStoresV1,
WithdrawalGroupRecord,
- depositOperationNonfinalStatusRange,
timestampAbsoluteFromDb,
timestampOptionalAbsoluteFromDb,
timestampPreciseFromDb,
timestampPreciseToDb,
- withdrawalGroupNonfinalRange,
} from "../db.js";
import { InternalWalletState } from "../internal-wallet-state.js";
import {
@@ -224,9 +216,12 @@ export async function iterRecordsForWithdrawal(
): Promise<void> {
let withdrawalGroupRecords: WithdrawalGroupRecord[];
if (filter.onlyState === "nonfinal") {
- withdrawalGroupRecords = await tx.withdrawalGroups.indexes.byStatus.getAll(
- withdrawalGroupNonfinalRange,
+ const keyRange = GlobalIDB.KeyRange.bound(
+ OPERATION_STATUS_ACTIVE_FIRST,
+ OPERATION_STATUS_ACTIVE_LAST,
);
+ withdrawalGroupRecords =
+ await tx.withdrawalGroups.indexes.byStatus.getAll(keyRange);
} else {
withdrawalGroupRecords =
await tx.withdrawalGroups.indexes.byStatus.getAll();
@@ -290,9 +285,11 @@ export async function iterRecordsForDeposit(
): Promise<void> {
let dgs: DepositGroupRecord[];
if (filter.onlyState === "nonfinal") {
- dgs = await tx.depositGroups.indexes.byStatus.getAll(
- depositOperationNonfinalStatusRange,
+ const keyRange = GlobalIDB.KeyRange.bound(
+ OPERATION_STATUS_ACTIVE_FIRST,
+ OPERATION_STATUS_ACTIVE_LAST,
);
+ dgs = await tx.depositGroups.indexes.byStatus.getAll(keyRange);
} else {
dgs = await tx.depositGroups.indexes.byStatus.getAll();
}
@@ -350,11 +347,11 @@ export async function iterRecordsForReward(
f: (r: RewardRecord) => Promise<void>,
): Promise<void> {
if (filter.onlyState === "nonfinal") {
- const range = GlobalIDB.KeyRange.bound(
- RewardRecordStatus.PendingPickup,
- RewardRecordStatus.PendingPickup,
+ const keyRange = GlobalIDB.KeyRange.bound(
+ OPERATION_STATUS_ACTIVE_FIRST,
+ OPERATION_STATUS_ACTIVE_LAST,
);
- await tx.rewards.indexes.byStatus.iter(range).forEachAsync(f);
+ await tx.rewards.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
await tx.rewards.indexes.byStatus.iter().forEachAsync(f);
}
@@ -404,7 +401,10 @@ export async function iterRecordsForRefund(
f: (r: RefundGroupRecord) => Promise<void>,
): Promise<void> {
if (filter.onlyState === "nonfinal") {
- const keyRange = GlobalIDB.KeyRange.only(RefundGroupStatus.Pending);
+ const keyRange = GlobalIDB.KeyRange.bound(
+ OPERATION_STATUS_ACTIVE_FIRST,
+ OPERATION_STATUS_ACTIVE_LAST,
+ );
await tx.refundGroups.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
await tx.refundGroups.iter().forEachAsync(f);
@@ -534,8 +534,8 @@ export async function iterRecordsForPeerPullInitiation(
): Promise<void> {
if (filter.onlyState === "nonfinal") {
const keyRange = GlobalIDB.KeyRange.bound(
- PeerPullPaymentCreditStatus.PendingCreatePurse,
- PeerPullPaymentCreditStatus.AbortingDeletePurse,
+ OPERATION_STATUS_ACTIVE_FIRST,
+ OPERATION_STATUS_ACTIVE_LAST,
);
await tx.peerPullCredit.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
@@ -589,8 +589,8 @@ export async function iterRecordsForPeerPullDebit(
): Promise<void> {
if (filter.onlyState === "nonfinal") {
const keyRange = GlobalIDB.KeyRange.bound(
- PeerPullDebitRecordStatus.PendingDeposit,
- PeerPullDebitRecordStatus.AbortingRefresh,
+ OPERATION_STATUS_ACTIVE_FIRST,
+ OPERATION_STATUS_ACTIVE_LAST,
);
await tx.peerPullDebit.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
@@ -641,8 +641,8 @@ export async function iterRecordsForPeerPushInitiation(
): Promise<void> {
if (filter.onlyState === "nonfinal") {
const keyRange = GlobalIDB.KeyRange.bound(
- PeerPushDebitStatus.PendingCreatePurse,
- PeerPushDebitStatus.AbortingRefreshExpired,
+ OPERATION_STATUS_ACTIVE_FIRST,
+ OPERATION_STATUS_ACTIVE_LAST,
);
await tx.peerPushDebit.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
@@ -688,8 +688,8 @@ export async function iterRecordsForPeerPushCredit(
): Promise<void> {
if (filter.onlyState === "nonfinal") {
const keyRange = GlobalIDB.KeyRange.bound(
- PeerPushCreditStatus.PendingMerge,
- PeerPushCreditStatus.PendingWithdrawing,
+ OPERATION_STATUS_ACTIVE_FIRST,
+ OPERATION_STATUS_ACTIVE_LAST,
);
await tx.peerPushCredit.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
@@ -706,10 +706,6 @@ async function gatherPeerPushCreditPending(
now: AbsoluteTime,
resp: PendingOperationsResponse,
): Promise<void> {
- const keyRange = GlobalIDB.KeyRange.bound(
- PeerPushCreditStatus.PendingMerge,
- PeerPushCreditStatus.PendingWithdrawing,
- );
await iterRecordsForPeerPushCredit(
tx,
{ onlyState: "nonfinal" },