aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pending.ts
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-09-09 07:34:11 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-09-09 07:34:11 +0200
commit5495551071a3fdc36c38deb4c1cf6f4aa5b98bd4 (patch)
treeadf7730b190618a0499e50a2d43cf1b850cddd16 /packages/taler-wallet-core/src/operations/pending.ts
parent94cfcc875065f988815c31aaf8ebf36f75ac5983 (diff)
parent6c3cfa9be7a332c2cc8490f25ebd6c73c8244842 (diff)
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pending.ts93
1 files changed, 43 insertions, 50 deletions
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts
index e37e45c16..6115f848b 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -26,11 +26,10 @@ import {
WalletStoresV1,
BackupProviderStateTag,
RefreshCoinStatus,
- OperationStatusRange,
- PeerPushPaymentInitiationStatus,
+ PeerPushDebitStatus,
PeerPullDebitRecordStatus,
- PeerPushPaymentIncomingStatus,
- PeerPullPaymentInitiationStatus,
+ PeerPushCreditStatus,
+ PeerPullPaymentCreditStatus,
WithdrawalGroupStatus,
RewardRecordStatus,
DepositOperationStatus,
@@ -39,13 +38,15 @@ import {
DepositGroupRecord,
RewardRecord,
PurchaseRecord,
- PeerPullPaymentInitiationRecord,
+ PeerPullCreditRecord,
PeerPullPaymentIncomingRecord,
- PeerPushPaymentInitiationRecord,
+ PeerPushDebitRecord,
PeerPushPaymentIncomingRecord,
RefundGroupRecord,
RefundGroupStatus,
ExchangeEntryDbUpdateStatus,
+ RefreshOperationStatus,
+ DepositElementStatus,
} from "../db.js";
import {
PendingOperationsResponse,
@@ -136,8 +137,8 @@ export async function iterRecordsForRefresh(
let refreshGroups: RefreshGroupRecord[];
if (filter.onlyState === "nonfinal") {
const keyRange = GlobalIDB.KeyRange.bound(
- OperationStatusRange.ACTIVE_START,
- OperationStatusRange.ACTIVE_END,
+ RefreshOperationStatus.Pending,
+ RefreshOperationStatus.Suspended,
);
refreshGroups = await tx.refreshGroups.indexes.byStatus.getAll(keyRange);
} else {
@@ -277,8 +278,8 @@ async function gatherDepositPending(
): Promise<void> {
await iterRecordsForDeposit(tx, { onlyState: "nonfinal" }, async (dg) => {
let deposited = true;
- for (const d of dg.depositedPerCoin) {
- if (!d) {
+ for (const d of dg.statusPerCoin) {
+ if (d === DepositElementStatus.DepositPending) {
deposited = false;
}
}
@@ -470,28 +471,26 @@ async function gatherBackupPending(
export async function iterRecordsForPeerPullInitiation(
tx: GetReadOnlyAccess<{
- peerPullPaymentInitiations: typeof WalletStoresV1.peerPullPaymentInitiations;
+ peerPullCredit: typeof WalletStoresV1.peerPullCredit;
}>,
filter: TransactionRecordFilter,
- f: (r: PeerPullPaymentInitiationRecord) => Promise<void>,
+ f: (r: PeerPullCreditRecord) => Promise<void>,
): Promise<void> {
if (filter.onlyState === "nonfinal") {
const keyRange = GlobalIDB.KeyRange.bound(
- PeerPullPaymentInitiationStatus.PendingCreatePurse,
- PeerPullPaymentInitiationStatus.AbortingDeletePurse,
+ PeerPullPaymentCreditStatus.PendingCreatePurse,
+ PeerPullPaymentCreditStatus.AbortingDeletePurse,
);
- await tx.peerPullPaymentInitiations.indexes.byStatus
- .iter(keyRange)
- .forEachAsync(f);
+ await tx.peerPullCredit.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
- await tx.peerPullPaymentInitiations.indexes.byStatus.iter().forEachAsync(f);
+ await tx.peerPullCredit.indexes.byStatus.iter().forEachAsync(f);
}
}
async function gatherPeerPullInitiationPending(
ws: InternalWalletState,
tx: GetReadOnlyAccess<{
- peerPullPaymentInitiations: typeof WalletStoresV1.peerPullPaymentInitiations;
+ peerPullCredit: typeof WalletStoresV1.peerPullCredit;
operationRetries: typeof WalletStoresV1.operationRetries;
}>,
now: AbsoluteTime,
@@ -518,7 +517,7 @@ async function gatherPeerPullInitiationPending(
export async function iterRecordsForPeerPullDebit(
tx: GetReadOnlyAccess<{
- peerPullPaymentIncoming: typeof WalletStoresV1.peerPullPaymentIncoming;
+ peerPullDebit: typeof WalletStoresV1.peerPullDebit;
}>,
filter: TransactionRecordFilter,
f: (r: PeerPullPaymentIncomingRecord) => Promise<void>,
@@ -528,18 +527,16 @@ export async function iterRecordsForPeerPullDebit(
PeerPullDebitRecordStatus.PendingDeposit,
PeerPullDebitRecordStatus.AbortingRefresh,
);
- await tx.peerPullPaymentIncoming.indexes.byStatus
- .iter(keyRange)
- .forEachAsync(f);
+ await tx.peerPullDebit.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
- await tx.peerPullPaymentIncoming.indexes.byStatus.iter().forEachAsync(f);
+ await tx.peerPullDebit.indexes.byStatus.iter().forEachAsync(f);
}
}
async function gatherPeerPullDebitPending(
ws: InternalWalletState,
tx: GetReadOnlyAccess<{
- peerPullPaymentIncoming: typeof WalletStoresV1.peerPullPaymentIncoming;
+ peerPullDebit: typeof WalletStoresV1.peerPullDebit;
operationRetries: typeof WalletStoresV1.operationRetries;
}>,
now: AbsoluteTime,
@@ -558,7 +555,7 @@ async function gatherPeerPullDebitPending(
...getPendingCommon(ws, opId, timestampDue),
givesLifeness: true,
retryInfo: retryRecord?.retryInfo,
- peerPullPaymentIncomingId: pi.peerPullPaymentIncomingId,
+ peerPullDebitId: pi.peerPullDebitId,
});
},
);
@@ -566,28 +563,26 @@ async function gatherPeerPullDebitPending(
export async function iterRecordsForPeerPushInitiation(
tx: GetReadOnlyAccess<{
- peerPushPaymentInitiations: typeof WalletStoresV1.peerPushPaymentInitiations;
+ peerPushDebit: typeof WalletStoresV1.peerPushDebit;
}>,
filter: TransactionRecordFilter,
- f: (r: PeerPushPaymentInitiationRecord) => Promise<void>,
+ f: (r: PeerPushDebitRecord) => Promise<void>,
): Promise<void> {
if (filter.onlyState === "nonfinal") {
const keyRange = GlobalIDB.KeyRange.bound(
- PeerPushPaymentInitiationStatus.PendingCreatePurse,
- PeerPushPaymentInitiationStatus.AbortingRefresh,
+ PeerPushDebitStatus.PendingCreatePurse,
+ PeerPushDebitStatus.AbortingRefresh,
);
- await tx.peerPushPaymentInitiations.indexes.byStatus
- .iter(keyRange)
- .forEachAsync(f);
+ await tx.peerPushDebit.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
- await tx.peerPushPaymentInitiations.indexes.byStatus.iter().forEachAsync(f);
+ await tx.peerPushDebit.indexes.byStatus.iter().forEachAsync(f);
}
}
async function gatherPeerPushInitiationPending(
ws: InternalWalletState,
tx: GetReadOnlyAccess<{
- peerPushPaymentInitiations: typeof WalletStoresV1.peerPushPaymentInitiations;
+ peerPushDebit: typeof WalletStoresV1.peerPushDebit;
operationRetries: typeof WalletStoresV1.operationRetries;
}>,
now: AbsoluteTime,
@@ -614,36 +609,34 @@ async function gatherPeerPushInitiationPending(
export async function iterRecordsForPeerPushCredit(
tx: GetReadOnlyAccess<{
- peerPushPaymentIncoming: typeof WalletStoresV1.peerPushPaymentIncoming;
+ peerPushCredit: typeof WalletStoresV1.peerPushCredit;
}>,
filter: TransactionRecordFilter,
f: (r: PeerPushPaymentIncomingRecord) => Promise<void>,
): Promise<void> {
if (filter.onlyState === "nonfinal") {
const keyRange = GlobalIDB.KeyRange.bound(
- PeerPushPaymentIncomingStatus.PendingMerge,
- PeerPushPaymentIncomingStatus.PendingWithdrawing,
+ PeerPushCreditStatus.PendingMerge,
+ PeerPushCreditStatus.PendingWithdrawing,
);
- await tx.peerPushPaymentIncoming.indexes.byStatus
- .iter(keyRange)
- .forEachAsync(f);
+ await tx.peerPushCredit.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
- await tx.peerPushPaymentIncoming.indexes.byStatus.iter().forEachAsync(f);
+ await tx.peerPushCredit.indexes.byStatus.iter().forEachAsync(f);
}
}
async function gatherPeerPushCreditPending(
ws: InternalWalletState,
tx: GetReadOnlyAccess<{
- peerPushPaymentIncoming: typeof WalletStoresV1.peerPushPaymentIncoming;
+ peerPushCredit: typeof WalletStoresV1.peerPushCredit;
operationRetries: typeof WalletStoresV1.operationRetries;
}>,
now: AbsoluteTime,
resp: PendingOperationsResponse,
): Promise<void> {
const keyRange = GlobalIDB.KeyRange.bound(
- PeerPushPaymentIncomingStatus.PendingMerge,
- PeerPushPaymentIncomingStatus.PendingWithdrawing,
+ PeerPushCreditStatus.PendingMerge,
+ PeerPushCreditStatus.PendingWithdrawing,
);
await iterRecordsForPeerPushCredit(
tx,
@@ -658,7 +651,7 @@ async function gatherPeerPushCreditPending(
...getPendingCommon(ws, opId, timestampDue),
givesLifeness: true,
retryInfo: retryRecord?.retryInfo,
- peerPushPaymentIncomingId: pi.peerPushPaymentIncomingId,
+ peerPushCreditId: pi.peerPushCreditId,
});
},
);
@@ -682,10 +675,10 @@ export async function getPendingOperations(
x.depositGroups,
x.recoupGroups,
x.operationRetries,
- x.peerPullPaymentInitiations,
- x.peerPushPaymentInitiations,
- x.peerPullPaymentIncoming,
- x.peerPushPaymentIncoming,
+ x.peerPullCredit,
+ x.peerPushDebit,
+ x.peerPullDebit,
+ x.peerPushCredit,
])
.runReadWrite(async (tx) => {
const resp: PendingOperationsResponse = {