aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-repair.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts2
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts2
-rw-r--r--packages/taler-util/src/wallet-types.ts12
-rw-r--r--packages/taler-wallet-cli/src/index.ts12
-rw-r--r--packages/taler-wallet-core/src/db.ts556
-rw-r--r--packages/taler-wallet-core/src/operations/balance.ts2
-rw-r--r--packages/taler-wallet-core/src/operations/common.ts28
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts10
-rw-r--r--packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts328
-rw-r--r--packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts178
-rw-r--r--packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts314
-rw-r--r--packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts294
-rw-r--r--packages/taler-wallet-core/src/operations/pending.ts80
-rw-r--r--packages/taler-wallet-core/src/operations/reward.ts14
-rw-r--r--packages/taler-wallet-core/src/operations/testing.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts122
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts12
-rw-r--r--packages/taler-wallet-core/src/pending-types.ts4
-rw-r--r--packages/taler-wallet-core/src/util/coinSelection.ts2
-rw-r--r--packages/taler-wallet-core/src/util/query.ts109
-rw-r--r--packages/taler-wallet-core/src/wallet.ts16
-rw-r--r--packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts4
-rw-r--r--packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts4
24 files changed, 990 insertions, 1121 deletions
diff --git a/packages/taler-harness/src/integrationtests/test-peer-repair.ts b/packages/taler-harness/src/integrationtests/test-peer-repair.ts
index b09bff2dc..d457ce1e5 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-repair.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-repair.ts
@@ -130,7 +130,7 @@ export async function runPeerRepairTest(t: GlobalTestState) {
);
await wallet2.client.call(WalletApiOperation.ConfirmPeerPushCredit, {
- peerPushPaymentIncomingId: resp2.peerPushPaymentIncomingId,
+ peerPushCreditId: resp2.peerPushCreditId,
});
await peerPushCreditDone1Cond;
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
index 5b55b1de1..25c000808 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
@@ -123,7 +123,7 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {
);
await wallet2.client.call(WalletApiOperation.ConfirmPeerPullDebit, {
- peerPullPaymentIncomingId: checkResp.peerPullPaymentIncomingId,
+ peerPullDebitId: checkResp.peerPullDebitId,
});
await peerPullCreditDoneCond;
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
index 26f70a5cc..018fa2020 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
@@ -126,7 +126,7 @@ export async function runPeerToPeerPushTest(t: GlobalTestState) {
const acceptResp = await w2.walletClient.call(
WalletApiOperation.ConfirmPeerPushCredit,
{
- peerPushPaymentIncomingId: checkResp.peerPushPaymentIncomingId,
+ peerPushCreditId: checkResp.peerPushCreditId,
},
);
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
index 0d78b405a..c6f19c73f 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -2438,7 +2438,7 @@ export interface PreparePeerPushCreditResponse {
amount: AmountString;
amountRaw: AmountString;
amountEffective: AmountString;
- peerPushPaymentIncomingId: string;
+ peerPushCreditId: string;
transactionId: string;
}
@@ -2453,7 +2453,7 @@ export interface PreparePeerPullDebitResponse {
amountRaw: AmountString;
amountEffective: AmountString;
- peerPullPaymentIncomingId: string;
+ peerPullDebitId: string;
transactionId: string;
}
@@ -2476,7 +2476,7 @@ export interface ConfirmPeerPushCreditRequest {
*
* @deprecated specify transactionId instead!
*/
- peerPushPaymentIncomingId?: string;
+ peerPushCreditId?: string;
transactionId?: string;
}
@@ -2491,7 +2491,7 @@ export interface AcceptPeerPullPaymentResponse {
export const codecForConfirmPeerPushPaymentRequest =
(): Codec<ConfirmPeerPushCreditRequest> =>
buildCodecForObject<ConfirmPeerPushCreditRequest>()
- .property("peerPushPaymentIncomingId", codecOptional(codecForString()))
+ .property("peerPushCreditId", codecOptional(codecForString()))
.property("transactionId", codecOptional(codecForString()))
.build("ConfirmPeerPushCreditRequest");
@@ -2501,7 +2501,7 @@ export interface ConfirmPeerPullDebitRequest {
*
* @deprecated use transactionId instead
*/
- peerPullPaymentIncomingId?: string;
+ peerPullDebitId?: string;
transactionId?: string;
}
@@ -2519,7 +2519,7 @@ export const codecForApplyDevExperiment =
export const codecForAcceptPeerPullPaymentRequest =
(): Codec<ConfirmPeerPullDebitRequest> =>
buildCodecForObject<ConfirmPeerPullDebitRequest>()
- .property("peerPullPaymentIncomingId", codecOptional(codecForString()))
+ .property("peerPullDebitId", codecOptional(codecForString()))
.property("transactionId", codecOptional(codecForString()))
.build("ConfirmPeerPullDebitRequest");
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts
index 943283a36..3fc86d0b5 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -1024,14 +1024,14 @@ peerCli
peerCli
.subcommand("confirmIncomingPayPull", "confirm-pull-debit")
- .requiredArgument("peerPullPaymentIncomingId", clk.STRING)
+ .requiredArgument("peerPullDebitId", clk.STRING)
.action(async (args) => {
await withWallet(args, async (wallet) => {
const resp = await wallet.client.call(
WalletApiOperation.ConfirmPeerPullDebit,
{
- peerPullPaymentIncomingId:
- args.confirmIncomingPayPull.peerPullPaymentIncomingId,
+ peerPullDebitId:
+ args.confirmIncomingPayPull.peerPullDebitId,
},
);
console.log(JSON.stringify(resp, undefined, 2));
@@ -1040,14 +1040,14 @@ peerCli
peerCli
.subcommand("confirmIncomingPayPush", "confirm-push-credit")
- .requiredArgument("peerPushPaymentIncomingId", clk.STRING)
+ .requiredArgument("peerPushCreditId", clk.STRING)
.action(async (args) => {
await withWallet(args, async (wallet) => {
const resp = await wallet.client.call(
WalletApiOperation.ConfirmPeerPushCredit,
{
- peerPushPaymentIncomingId:
- args.confirmIncomingPayPush.peerPushPaymentIncomingId,
+ peerPushCreditId:
+ args.confirmIncomingPayPush.peerPushCreditId,
},
);
console.log(JSON.stringify(resp, undefined, 2));
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 2c7673267..9aedb888b 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -60,7 +60,8 @@ import {
Logger,
CoinPublicKeyString,
TalerPreciseTimestamp,
- j2s,
+ codecForAny,
+ Codec,
} from "@gnu-taler/taler-util";
import {
DbAccess,
@@ -106,7 +107,7 @@ import { RetryInfo, TaskIdentifiers } from "./operations/common.js";
* for all previous versions must be written, which should be
* avoided.
*/
-export const TALER_WALLET_MAIN_DB_NAME = "taler-wallet-main-v9";
+export const TALER_WALLET_MAIN_DB_NAME = "taler-wallet-main-v10";
/**
* Name of the metadata database. This database is used
@@ -137,50 +138,26 @@ export const CURRENT_DB_CONFIG_KEY = "currentMainDbName";
* backwards-compatible way or object stores and indices
* are added.
*/
-export const WALLET_DB_MINOR_VERSION = 10;
+export const WALLET_DB_MINOR_VERSION = 1;
/**
- * Format of the operation status code: xyznnn
- *
- * x=1: active
- * yz=00: pending
- * yz=02: dialog
- * yz=03: aborting
- * yz=10: suspended
- * yz=13: suspended-aborting
- * x=2: final
- * yz=00: done
- * yz=01: failed
- * yz=02: expired
- * yz=03: aborted
- */
-// export const OperationStatusRange = {
-// ActiveStart: 10000,
-// ActiveEnd: 10999,
-// SuspendedStart: 10999,
-// SuspendedEnd: 10999,
-// FinalStart: 20000,
-// FinalEnd: 29999,
-//} as const;
-
-/**
- * Ranges for operation status fields.
- *
- * All individual enums should make sure that the values they
- * defined are in the right range.
+ * Format of the operation status code: 0x0abc_nnnn
+
+ * a=1: active
+ * 0x0100_nnnn: pending
+ * 0x0101_nnnn: dialog
+ * 0x0102_nnnn: (reserved)
+ * 0x0103_nnnn: aborting
+ * 0x0110_nnnn: suspended
+ * 0x0113_nnnn: suspended-aborting
+ * a=5: final
+ * 0x0500_nnnn: done
+ * 0x0501_nnnn: failed
+ * 0x0502_nnnn: expired
+ * 0x0503_nnnn: aborted
+ *
+ * nnnn=0000 should always be the most generic minor state for the major state
*/
-export enum OperationStatusRange {
- // Operations that need to be actively processed.
- ACTIVE_START = 10,
- ACTIVE_END = 29,
- // Operations that are suspended and might
- // expire, but nothing else can be done.
- SUSPENDED_START = 30,
- SUSPENDED_END = 49,
- // Operations that don't need any attention or processing.
- DORMANT_START = 50,
- DORMANT_END = 69,
-}
/**
* Status of a withdrawal.
@@ -189,71 +166,70 @@ export enum WithdrawalGroupStatus {
/**
* Reserve must be registered with the bank.
*/
- PendingRegisteringBank = 10,
+ PendingRegisteringBank = 0x0100_0000,
+ SuspendedRegisteringBank = 0x0110_0000,
/**
* We've registered reserve's information with the bank
* and are now waiting for the user to confirm the withdraw
* with the bank (typically 2nd factor auth).
*/
- PendingWaitConfirmBank = 11,
+ PendingWaitConfirmBank = 0x0100_0001,
+ SuspendedWaitConfirmBank = 0x0110_0001,
/**
* Querying reserve status with the exchange.
*/
- PendingQueryingStatus = 12,
+ PendingQueryingStatus = 0x0100_0002,
+ SuspendedQueryingStatus = 0x0110_0002,
/**
* Ready for withdrawal.
*/
- PendingReady = 13,
+ PendingReady = 0x0100_0003,
+ SuspendedReady = 0x0110_0003,
/**
* We are telling the bank that we don't want to complete
* the withdrawal!
*/
- AbortingBank = 14,
+ AbortingBank = 0x0103_0000,
+ SuspendedAbortingBank = 0x0113_0000,
/**
* Exchange wants KYC info from the user.
*/
- PendingKyc = 16,
+ PendingKyc = 0x0100_0004,
+ SuspendedKyc = 0x0110_004,
/**
* Exchange is doing AML checks.
*/
- PendingAml = 17,
-
- SuspendedRegisteringBank = 30,
- SuspendedWaitConfirmBank = 31,
- SuspendedQueryingStatus = 32,
- SuspendedReady = 33,
- SuspendedAbortingBank = 34,
- SuspendedKyc = 35,
- SuspendedAml = 36,
+ PendingAml = 0x0100_0005,
+ SuspendedAml = 0x0100_0005,
/**
* The corresponding withdraw record has been created.
* No further processing is done, unless explicitly requested
* by the user.
*/
- Finished = 50,
+ Done = 0x0500_0000,
/**
* The bank aborted the withdrawal.
*/
- FailedBankAborted = 51,
+ FailedBankAborted = 0x0501_0000,
- FailedAbortingBank = 59,
+ FailedAbortingBank = 0x0501_0001,
/**
* Aborted in a state where we were supposed to
* talk to the exchange. Money might have been
* wired or not.
*/
- AbortedExchange = 60,
+ AbortedExchange = 0x0503_0001,
- AbortedBank = 61,
+ AbortedBank = 0x0503_0002,
}
/**
@@ -298,17 +274,17 @@ export enum DenominationVerificationStatus {
/**
* Verification was delayed.
*/
- Unverified = OperationStatusRange.ACTIVE_START,
+ Unverified = 0x0500_0000,
/**
* Verified as valid.
*/
- VerifiedGood = OperationStatusRange.DORMANT_START,
+ VerifiedGood = 0x0500_0000,
/**
* Verified as invalid.
*/
- VerifiedBad = OperationStatusRange.DORMANT_START + 1,
+ VerifiedBad = 0x0501_0000,
}
export interface DenomFees {
@@ -904,50 +880,42 @@ export interface RewardRecord {
}
export enum RewardRecordStatus {
- PendingPickup = 10,
-
- SuspendidPickup = 20,
-
- DialogAccept = 30,
-
- Done = 50,
- Aborted = 51,
+ PendingPickup = 0x0100_0000,
+ SuspendedPickup = 0x0110_0000,
+ DialogAccept = 0x0101_0000,
+ Done = 0x0500_0000,
+ Aborted = 0x0500_0000,
}
export enum RefreshCoinStatus {
- Pending = OperationStatusRange.ACTIVE_START,
- Finished = OperationStatusRange.DORMANT_START,
+ Pending = 0x0100_0000,
+ Finished = 0x0500_0000,
/**
* The refresh for this coin has been frozen, because of a permanent error.
* More info in lastErrorPerCoin.
*/
- Failed = OperationStatusRange.DORMANT_START + 1,
-}
-
-export enum OperationStatus {
- Finished = OperationStatusRange.DORMANT_START,
- Pending = OperationStatusRange.ACTIVE_START,
+ Failed = 0x0501_000,
}
export enum RefreshOperationStatus {
- Pending = 10 /* ACTIVE_START */,
- Suspended = 20 /* DORMANT_START + 2 */,
+ Pending = 0x0100_0000,
+ Suspended = 0x0110_0000,
- Finished = 50 /* DORMANT_START */,
- Failed = 51 /* DORMANT_START + 1 */,
+ Finished = 0x0500_000,
+ Failed = 0x0501_000,
}
/**
* Status of a single element of a deposit group.
*/
export enum DepositElementStatus {
- Unknown = 10,
- Accepted = 20,
- KycRequired = 30,
- Wired = 40,
- RefundSuccess = 50,
- RefundFailed = 51,
+ Unknown = 0x0100_0000,
+ Accepted = 0x0100_0001,
+ KycRequired = 0x0100_0002,
+ Wired = 0x0500_0000,
+ RefundSuccess = 0x0503_0000,
+ RefundFailed = 0x0501_0000,
}
/**
@@ -962,9 +930,6 @@ export interface RefreshReasonDetails {
* Group of refresh operations. The refreshed coins do not
* have to belong to the same exchange, but must have the same
* currency.
- *
- * FIXME: Should include the currency as a top-level field,
- * but we need to write a migration for that.
*/
export interface RefreshGroupRecord {
operationStatus: RefreshOperationStatus;
@@ -980,8 +945,6 @@ export interface RefreshGroupRecord {
/**
* Currency of this refresh group.
- *
- * FIXME: Write a migration to add this to earlier DB versions.
*/
currency: string;
@@ -1116,81 +1079,84 @@ export enum PurchaseStatus {
/**
* Not downloaded yet.
*/
- PendingDownloadingProposal = 10,
+ PendingDownloadingProposal = 0x0100_0000,
+ SuspendedDownloadingProposal = 0x0110_0000,
/**
* The user has accepted the proposal.
*/
- PendingPaying = 11,
+ PendingPaying = 0x0100_0001,
+ SuspendedPaying = 0x0110_0001,
/**
* Currently in the process of aborting with a refund.
*/
- AbortingWithRefund = 12,
+ AbortingWithRefund = 0x0103_0000,
+ SuspendedAbortingWithRefund = 0x0113_0000,
/**
* Paying a second time, likely with different session ID
*/
- PendingPayingReplay = 13,
+ PendingPayingReplay = 0x0100_0002,
+ SuspendedPayingReplay = 0x0110_0002,
/**
* Query for refunds (until query succeeds).
*/
- PendingQueryingRefund = 14,
+ PendingQueryingRefund = 0x0100_0003,
+ SuspendedQueryingRefund = 0x0110_0003,
/**
* Query for refund (until auto-refund deadline is reached).
*/
- PendingQueryingAutoRefund = 15,
+ PendingQueryingAutoRefund = 0x0100_0004,
+ SuspendedQueryingAutoRefund = 0x0110_0004,
- PendingAcceptRefund = 16,
-
- SuspendedDownloadingProposal = 20,
- SuspendedPaying = 21,
- SuspendedAbortingWithRefund = 22,
- SuspendedPayingReplay = 23,
- SuspendedQueryingRefund = 24,
- SuspendedQueryingAutoRefund = 25,
- SuspendedPendingAcceptRefund = 26,
+ PendingAcceptRefund = 0x0100_0005,
+ SuspendedPendingAcceptRefund = 0x0100_0005,
/**
* Proposal downloaded, but the user needs to accept/reject it.
*/
- DialogProposed = 30,
+ DialogProposed = 0x0101_0000,
+
/**
* Proposal shared to other wallet or read from other wallet
* the user needs to accept/reject it.
*/
- DialogShared = 31,
+ DialogShared = 0x0101_0001,
/**
* The user has rejected the proposal.
*/
- AbortedProposalRefused = 50,
+ AbortedProposalRefused = 0x0503_0000,
/**
* Downloading or processing the proposal has failed permanently.
*/
- FailedClaim = 51,
+ FailedClaim = 0x0501_0000,
+
+ /**
+ * Payment was successful.
+ */
+ Done = 0x0500_0000,
/**
* Downloaded proposal was detected as a re-purchase.
*/
- RepurchaseDetected = 52,
+ DoneRepurchaseDetected = 0x0500_0001,
/**
* The payment has been aborted.
*/
- AbortedIncompletePayment = 53,
+ AbortedIncompletePayment = 0x0503_0000,
/**
- * Payment was successful.
+ * Tried to abort, but aborting failed or was cancelled.
*/
- Done = 54,
-
- FailedAbort = 55,
+ FailedAbort = 0x0501_0001,
- AbortedRefunded = 56,
+ AbortedRefunded = 0x0503_0000,
}
/**
@@ -1305,14 +1271,6 @@ export interface PurchaseRecord {
timestampAccept: TalerPreciseTimestamp | undefined;
/**
- * Pending refunds for the purchase. A refund is pending
- * when the merchant reports a transient error from the exchange.
- *
- * FIXME: Put this into a separate object store?
- */
- // refunds: { [refundKey: string]: WalletRefundItem };
-
- /**
* When was the last refund made?
* Set to 0 if no refund was made on the purchase.
*/
@@ -1375,6 +1333,7 @@ export interface WalletBackupConfState {
lastBackupNonce?: string;
}
+// FIXME: Should these be numeric codes?
export const enum WithdrawalRecordType {
BankManual = "bank-manual",
BankIntegrated = "bank-integrated",
@@ -1684,19 +1643,21 @@ export interface BackupProviderRecord {
}
export enum DepositOperationStatus {
- PendingDeposit = 10,
- Aborting = 11,
- PendingTrack = 12,
- PendingKyc = 13,
+ PendingDeposit = 0x0100_0000,
+ PendingTrack = 0x0100_0001,
+ PendingKyc = 0x0100_0002,
+
+ Aborting = 0x0103_0000,
- SuspendedDeposit = 20,
- SuspendedAborting = 21,
- SuspendedTrack = 22,
- SuspendedKyc = 23,
+ SuspendedDeposit = 0x0110_0000,
+ SuspendedTrack = 0x0110_0001,
+ SuspendedKyc = 0x0110_0002,
- Finished = 50,
- Failed = 51,
- Aborted = 52,
+ SuspendedAborting = 0x0113_0000,
+
+ Finished = 0x0500_0000,
+ Failed = 0x0501_0000,
+ Aborted = 0x0503_0000,
}
export interface DepositTrackingInfo {
@@ -1787,31 +1748,6 @@ export interface DepositKycInfo {
exchangeBaseUrl: string;
}
-/**
- * Record for a deposits that the wallet observed
- * as a result of double spending, but which is not
- * present in the wallet's own database otherwise.
- */
-export interface GhostDepositGroupRecord {
- /**
- * When multiple deposits for the same contract terms hash
- * have a different timestamp, we choose the earliest one.
- */
- timestamp: TalerPreciseTimestamp;
-
- contractTermsHash: string;
-
- deposits: {
- coinPub: string;
- amount: AmountString;
- timestamp: TalerProtocolTimestamp;
- depositFee: AmountString;
- merchantPub: string;
- coinSig: string;
- wireHash: string;
- }[];
-}
-
export interface TombstoneRecord {
/**
* Tombstone ID, with the syntax "tmb:<type>:<key>".
@@ -1819,24 +1755,24 @@ export interface TombstoneRecord {
id: string;
}
-export enum PeerPushPaymentInitiationStatus {
+export enum PeerPushDebitStatus {
/**
* Initiated, but no purse created yet.
*/
- PendingCreatePurse = 10 /* ACTIVE_START */,
- PendingReady = 11,
- AbortingDeletePurse = 12,
- AbortingRefresh = 13,
+ PendingCreatePurse = 0x0100_0000 /* ACTIVE_START */,
+ PendingReady = 0x0100_0001,
+ AbortingDeletePurse = 0x0103_0000,
+ AbortingRefresh = 0x0103_0001,
- SuspendedCreatePurse = 30,
- SuspendedReady = 31,
- SuspendedAbortingDeletePurse = 32,
- SuspendedAbortingRefresh = 33,
+ SuspendedCreatePurse = 0x0110_0000,
+ SuspendedReady = 0x0110_0001,
+ SuspendedAbortingDeletePurse = 0x0113_0000,
+ SuspendedAbortingRefresh = 0x0113_0001,
- Done = 50 /* DORMANT_START */,
- Aborted = 51,
- Failed = 52,
- Expired = 53,
+ Done = 0x0500_0000,
+ Aborted = 0x0503_0000,
+ Failed = 0x0501_0000,
+ Expired = 0x0502_0000,
}
export interface PeerPushPaymentCoinSelection {
@@ -1847,7 +1783,7 @@ export interface PeerPushPaymentCoinSelection {
/**
* Record for a push P2P payment that this wallet initiated.
*/
-export interface PeerPushPaymentInitiationRecord {
+export interface PeerPushDebitRecord {
/**
* What exchange are funds coming from?
*/
@@ -1907,32 +1843,34 @@ export interface PeerPushPaymentInitiationRecord {
/**
* Status of the peer push payment initiation.
*/
- status: PeerPushPaymentInitiationStatus;
+ status: PeerPushDebitStatus;
}
-export enum PeerPullPaymentInitiationStatus {
- PendingCreatePurse = 10 /* ACTIVE_START */,
+export enum PeerPullPaymentCreditStatus {
+ PendingCreatePurse = 0x0100_0000,
/**
* Purse created, waiting for the other party to accept the
* invoice and deposit money into it.
*/
- PendingReady = 11 /* ACTIVE_START + 1 */,
- PendingMergeKycRequired = 12 /* ACTIVE_START + 2 */,
- PendingWithdrawing = 13,
- AbortingDeletePurse = 14,
+ PendingReady = 0x0100_0001,
+ PendingMergeKycRequired = 0x0100_0002,
+ PendingWithdrawing = 0x0100_0003,
- SuspendedCreatePurse = 30,
- SuspendedReady = 31,
- SuspendedMergeKycRequired = 32,
- SuspendedWithdrawing = 33,
- SuspendedAbortingDeletePurse = 34,
+ AbortingDeletePurse = 0x0103_0000,
- Done = 50 /* DORMANT_START */,
- Failed = 51,
- Aborted = 52,
+ SuspendedCreatePurse = 0x0110_0000,
+ SuspendedReady = 0x0110_0001,
+ SuspendedMergeKycRequired = 0x0110_0002,
+ SuspendedWithdrawing = 0x0113_0000,
+
+ SuspendedAbortingDeletePurse = 0x0113_0000,
+
+ Done = 0x0500_0000,
+ Failed = 0x0501_0000,
+ Aborted = 0x0503_0000,
}
-export interface PeerPullPaymentInitiationRecord {
+export interface PeerPullCreditRecord {
/**
* What exchange are we using for the payment request?
*/
@@ -1982,7 +1920,7 @@ export interface PeerPullPaymentInitiationRecord {
/**
* Status of the peer pull payment initiation.
*/
- status: PeerPullPaymentInitiationStatus;
+ status: PeerPullPaymentCreditStatus;
kycInfo?: KycPendingInfo;
@@ -1991,24 +1929,24 @@ export interface PeerPullPaymentInitiationRecord {
withdrawalGroupId: string | undefined;
}
-export enum PeerPushPaymentIncomingStatus {
- PendingMerge = 10 /* ACTIVE_START */,
- PendingMergeKycRequired = 11 /* ACTIVE_START + 1 */,
+export enum PeerPushCreditStatus {
+ PendingMerge = 0x0100_0000,
+ PendingMergeKycRequired = 0x0100_0001,
/**
* Merge was successful and withdrawal group has been created, now
* everything is in the hand of the withdrawal group.
*/
- PendingWithdrawing = 12,
+ PendingWithdrawing = 0x0100_0002,
- SuspendedMerge = 20,
- SuspendedMergeKycRequired = 21,
- SuspendedWithdrawing = 22,
+ SuspendedMerge = 0x0110_0000,
+ SuspendedMergeKycRequired = 0x0110_0001,
+ SuspendedWithdrawing = 0x0110_0002,
- DialogProposed = 30 /* USER_ATTENTION_START */,
+ DialogProposed = 0x0101_0000,
- Done = 50 /* DORMANT_START */,
- Aborted = 51,
- Failed = 52,
+ Done = 0x0500_0000,
+ Aborted = 0x0503_0000,
+ Failed = 0x0501_0000,
}
/**
@@ -2017,7 +1955,7 @@ export enum PeerPushPaymentIncomingStatus {
* Unique: (exchangeBaseUrl, pursePub)
*/
export interface PeerPushPaymentIncomingRecord {
- peerPushPaymentIncomingId: string;
+ peerPushCreditId: string;
exchangeBaseUrl: string;
@@ -2040,7 +1978,7 @@ export interface PeerPushPaymentIncomingRecord {
/**
* Status of the peer push payment incoming initiation.
*/
- status: PeerPushPaymentIncomingStatus;
+ status: PeerPushCreditStatus;
/**
* Associated withdrawal group.
@@ -2061,17 +1999,17 @@ export interface PeerPushPaymentIncomingRecord {
}
export enum PeerPullDebitRecordStatus {
- PendingDeposit = 10 /* ACTIVE_START */,
- AbortingRefresh = 11,
+ PendingDeposit = 0x0100_0001,
+ AbortingRefresh = 0x0103_0001,
- SuspendedDeposit = 20,
- SuspendedAbortingRefresh = 21,
+ SuspendedDeposit = 0x0110_0001,
+ SuspendedAbortingRefresh = 0x0113_0001,
- DialogProposed = 30 /* USER_ATTENTION_START */,
+ DialogProposed = 0x0101_0001,
- DonePaid = 50 /* DORMANT_START */,
- Aborted = 51,
- Failed = 52,
+ Done = 0x0500_0000,
+ Aborted = 0x0503_0000,
+ Failed = 0x0501_0000,
}
export interface PeerPullPaymentCoinSelection {
@@ -2089,7 +2027,7 @@ export interface PeerPullPaymentCoinSelection {
* AKA PeerPullDebit.
*/
export interface PeerPullPaymentIncomingRecord {
- peerPullPaymentIncomingId: string;
+ peerPullDebitId: string;
pursePub: string;
@@ -2234,10 +2172,10 @@ export interface CurrencySettingsRecord {
}
export enum RefundGroupStatus {
- Pending = 10,
- Done = 50,
- Failed = 51,
- Aborted = 52,
+ Pending = 0x0100_0000,
+ Done = 0x0500_0000,
+ Failed = 0x0501_0000,
+ Aborted = 0x0503_0000,
}
/**
@@ -2273,16 +2211,16 @@ export enum RefundItemStatus {
*
* We'll try again!
*/
- Pending = 10,
+ Pending = 0x0100_0000,
/**
* Refund was obtained successfully.
*/
- Done = 50,
+ Done = 0x0500_0000,
/**
* Permanent error reported by the exchange
* for the refund.
*/
- Failed = 51,
+ Failed = 0x0501_0000,
}
/**
@@ -2298,7 +2236,9 @@ export interface RefundItemRecord {
refundGroupId: string;
- // Execution time as claimed by the merchant
+ /**
+ * Execution time as claimed by the merchant
+ */
executionTime: TalerProtocolTimestamp;
/**
@@ -2308,22 +2248,15 @@ export interface RefundItemRecord {
refundAmount: AmountString;
- //refundFee: AmountString;
-
- /**
- * Upper bound on the refresh cost incurred by
- * applying this refund.
- *
- * Might be lower in practice when two refunds on the same
- * coin are refreshed in the same refresh operation.
- */
- //totalRefreshCostBound: AmountString;
-
coinPub: string;
rtxid: number;
}
+export function passthroughCodec<T>(): Codec<T> {
+ return codecForAny();
+}
+
/**
* Schema definition for the IndexedDB
* wallet database.
@@ -2333,7 +2266,6 @@ export const WalletStoresV1 = {
"currencySettings",
describeContents<CurrencySettingsRecord>({
keyPath: ["currency"],
- versionAdded: 3,
}),
{},
),
@@ -2542,17 +2474,10 @@ export const WalletStoresV1 = {
}),
{},
),
- ghostDepositGroups: describeStore(
- "ghostDepositGroups",
- describeContents<GhostDepositGroupRecord>({
- keyPath: "contractTermsHash",
- }),
- {},
- ),
- peerPushPaymentIncoming: describeStore(
- "peerPushPaymentIncoming",
+ peerPushCredit: describeStore(
+ "peerPushCredit",
describeContents<PeerPushPaymentIncomingRecord>({
- keyPath: "peerPushPaymentIncomingId",
+ keyPath: "peerPushCreditId",
}),
{
byExchangeAndPurse: describeIndex("byExchangeAndPurse", [
@@ -2563,24 +2488,21 @@ export const WalletStoresV1 = {
"byExchangeAndContractPriv",
["exchangeBaseUrl", "contractPriv"],
{
- versionAdded: 5,
unique: true,
},
),
byWithdrawalGroupId: describeIndex(
"byWithdrawalGroupId",
"withdrawalGroupId",
- {
- versionAdded: 5,
- },
+ {},
),
byStatus: describeIndex("byStatus", "status"),
},
),
- peerPullPaymentIncoming: describeStore(
- "peerPullPaymentIncoming",
+ peerPullDebit: describeStore(
+ "peerPullDebit",
describeContents<PeerPullPaymentIncomingRecord>({
- keyPath: "peerPullPaymentIncomingId",
+ keyPath: "peerPullDebitId",
}),
{
byExchangeAndPurse: describeIndex("byExchangeAndPurse", [
@@ -2591,16 +2513,15 @@ export const WalletStoresV1 = {
"byExchangeAndContractPriv",
["exchangeBaseUrl", "contractPriv"],
{
- versionAdded: 5,
unique: true,
},
),
byStatus: describeIndex("byStatus", "status"),
},
),
- peerPullPaymentInitiations: describeStore(
- "peerPullPaymentInitiations",
- describeContents<PeerPullPaymentInitiationRecord>({
+ peerPullCredit: describeStore(
+ "peerPullCredit",
+ describeContents<PeerPullCreditRecord>({
keyPath: "pursePub",
}),
{
@@ -2609,14 +2530,13 @@ export const WalletStoresV1 = {
"byWithdrawalGroupId",
"withdrawalGroupId",
{
- versionAdded: 5,
},
),
},
),
- peerPushPaymentInitiations: describeStore(
- "peerPushPaymentInitiations",
- describeContents<PeerPushPaymentInitiationRecord>({
+ peerPushDebit: describeStore(
+ "peerPushDebit",
+ describeContents<PeerPushDebitRecord>({
keyPath: "pursePub",
}),
{
@@ -2641,7 +2561,6 @@ export const WalletStoresV1 = {
"userAttention",
describeContents<UserAttentionRecord>({
keyPath: ["entityId", "info.type"],
- versionAdded: 2,
}),
{},
),
@@ -2649,12 +2568,10 @@ export const WalletStoresV1 = {
"refundGroups",
describeContents<RefundGroupRecord>({
keyPath: "refundGroupId",
- versionAdded: 7,
}),
{
byProposalId: describeIndex("byProposalId", "proposalId"),
byStatus: describeIndex("byStatus", "status", {
- versionAdded: 10,
}),
},
),
@@ -2662,7 +2579,6 @@ export const WalletStoresV1 = {
"refundItems",
describeContents<RefundItemRecord>({
keyPath: "id",
- versionAdded: 7,
autoIncrement: true,
}),
{
@@ -2677,7 +2593,6 @@ export const WalletStoresV1 = {
"fixups",
describeContents<FixupRecord>({
keyPath: "fixupName",
- versionAdded: 2,
}),
{},
),
@@ -2905,106 +2820,7 @@ export interface FixupDescription {
/**
* Manual migrations between minor versions of the DB schema.
*/
-export const walletDbFixups: FixupDescription[] = [
- {
- name: "RefreshGroupRecord_currency",
- async fn(tx): Promise<void> {
- await tx.refreshGroups.iter().forEachAsync(async (rg) => {
- if (rg.currency) {
- return;
- }
- // Empty refresh group without input coin, delete it!
- if (rg.inputPerCoin.length === 0) {
- await tx.refreshGroups.delete(rg.refreshGroupId);
- return;
- }
- rg.currency = Amounts.parseOrThrow(rg.inputPerCoin[0]).currency;
- await tx.refreshGroups.put(rg);
- });
- },
- },
- {
- name: "DepositGroupRecord_transactionPerCoin",
- async fn(tx): Promise<void> {
- await tx.depositGroups.iter().forEachAsync(async (dg) => {
- if (dg.transactionPerCoin) {
- return;
- }
- dg.transactionPerCoin = dg.depositedPerCoin.map(
- (c) => DepositElementStatus.Unknown,
- );
- await tx.depositGroups.put(dg);
- });
- },
- },
- {
- name: "PeerPullPaymentIncomingRecord_totalCostEstimated_add",
- async fn(tx): Promise<void> {
- await tx.peerPullPaymentIncoming.iter().forEachAsync(async (pi) => {
- if (pi.totalCostEstimated) {
- return;
- }
- // Not really the cost, but a good substitute for older transactions
- // that don't sture the effective cost of the transaction.
- pi.totalCostEstimated = pi.contractTerms.amount;
- await tx.peerPullPaymentIncoming.put(pi);
- });
- },
- },
- {
- name: "PeerPushPaymentIncomingRecord_totalCostEstimated_add",
- async fn(tx): Promise<void> {
- await tx.peerPushPaymentIncoming.iter().forEachAsync(async (pi) => {
- if (pi.estimatedAmountEffective) {
- return;
- }
- const contractTerms = await tx.contractTerms.get(pi.contractTermsHash);
- if (!contractTerms) {
- // Not sure what we can do here!
- } else {
- // Not really the cost, but a good substitute for older transactions
- // that don't sture the effective cost of the transaction.
- pi.estimatedAmountEffective = contractTerms.contractTermsRaw.amount;
- await tx.peerPushPaymentIncoming.put(pi);
- }
- });
- },
- },
- {
- name: "PeerPullPaymentInitiationRecord_estimatedAmountEffective_add",
- async fn(tx): Promise<void> {
- await tx.peerPullPaymentInitiations.iter().forEachAsync(async (pi) => {
- if (pi.estimatedAmountEffective) {
- return;
- }
- pi.estimatedAmountEffective = pi.amount;
- await tx.peerPullPaymentInitiations.put(pi);
- });
- },
- },
- {
- name: "PeerPushPaymentInitiationRecord_ALL_removeLegacyTx",
- async fn(tx): Promise<void> {
- await tx.peerPushPaymentInitiations.iter().forEachAsync(async (pi) => {
- // Remove legacy transactions that don't have the totalCost field yet.
- if (!pi.totalCost) {
- await tx.peerPushPaymentInitiations.delete(pi.pursePub);
- }
- });
- },
- },
- {
- name: "CoinAvailabilityRecord_visibleCoinCount_add",
- async fn(tx): Promise<void> {
- await tx.coinAvailability.iter().forEachAsync(async (r) => {
- if (r.visibleCoinCount == null) {
- r.visibleCoinCount = r.freshCoinCount;
- await tx.coinAvailability.put(r);
- }
- });
- },
- },
-];
+export const walletDbFixups: FixupDescription[] = [];
const logger = new Logger("db.ts");
diff --git a/packages/taler-wallet-core/src/operations/balance.ts b/packages/taler-wallet-core/src/operations/balance.ts
index 9c08a57bf..287ac94fb 100644
--- a/packages/taler-wallet-core/src/operations/balance.ts
+++ b/packages/taler-wallet-core/src/operations/balance.ts
@@ -163,7 +163,7 @@ export async function getBalancesInsideTransaction(
case WithdrawalGroupStatus.AbortedExchange:
case WithdrawalGroupStatus.FailedAbortingBank:
case WithdrawalGroupStatus.FailedBankAborted:
- case WithdrawalGroupStatus.Finished:
+ case WithdrawalGroupStatus.Done:
// Does not count as pendingIncoming
return;
case WithdrawalGroupStatus.PendingReady:
diff --git a/packages/taler-wallet-core/src/operations/common.ts b/packages/taler-wallet-core/src/operations/common.ts
index e96beb5b2..680874dfa 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -52,9 +52,9 @@ import {
BackupProviderRecord,
DepositGroupRecord,
PeerPullPaymentIncomingRecord,
- PeerPullPaymentInitiationRecord,
+ PeerPullCreditRecord,
PeerPushPaymentIncomingRecord,
- PeerPushPaymentInitiationRecord,
+ PeerPushDebitRecord,
PurchaseRecord,
RecoupGroupRecord,
RefreshGroupRecord,
@@ -271,7 +271,7 @@ function convertTaskToTransactionId(
case PendingTaskType.PeerPullDebit:
return constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId: parsedTaskId.peerPullPaymentIncomingId,
+ peerPullDebitId: parsedTaskId.peerPullDebitId,
});
// FIXME: This doesn't distinguish internal-withdrawal.
// Maybe we should have a different task type for that as well?
@@ -284,7 +284,7 @@ function convertTaskToTransactionId(
case PendingTaskType.PeerPushCredit:
return constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId: parsedTaskId.peerPushPaymentIncomingId,
+ peerPushCreditId: parsedTaskId.peerPushCreditId,
});
case PendingTaskType.Deposit:
return constructTransactionIdentifier({
@@ -836,9 +836,9 @@ export type ParsedTaskIdentifier =
| { tag: PendingTaskType.Deposit; depositGroupId: string }
| { tag: PendingTaskType.ExchangeCheckRefresh; exchangeBaseUrl: string }
| { tag: PendingTaskType.ExchangeUpdate; exchangeBaseUrl: string }
- | { tag: PendingTaskType.PeerPullDebit; peerPullPaymentIncomingId: string }
+ | { tag: PendingTaskType.PeerPullDebit; peerPullDebitId: string }
| { tag: PendingTaskType.PeerPullCredit; pursePub: string }
- | { tag: PendingTaskType.PeerPushCredit; peerPushPaymentIncomingId: string }
+ | { tag: PendingTaskType.PeerPushCredit; peerPushCreditId: string }
| { tag: PendingTaskType.PeerPushDebit; pursePub: string }
| { tag: PendingTaskType.Purchase; proposalId: string }
| { tag: PendingTaskType.Recoup; recoupGroupId: string }
@@ -865,9 +865,9 @@ export function parseTaskIdentifier(x: string): ParsedTaskIdentifier {
case PendingTaskType.PeerPullCredit:
return { tag: type, pursePub: rest[0] };
case PendingTaskType.PeerPullDebit:
- return { tag: type, peerPullPaymentIncomingId: rest[0] };
+ return { tag: type, peerPullDebitId: rest[0] };
case PendingTaskType.PeerPushCredit:
- return { tag: type, peerPushPaymentIncomingId: rest[0] };
+ return { tag: type, peerPushCreditId: rest[0] };
case PendingTaskType.PeerPushDebit:
return { tag: type, pursePub: rest[0] };
case PendingTaskType.Purchase:
@@ -896,9 +896,9 @@ export function constructTaskIdentifier(p: ParsedTaskIdentifier): TaskId {
case PendingTaskType.ExchangeUpdate:
return `${p.tag}:${p.exchangeBaseUrl}` as TaskId;
case PendingTaskType.PeerPullDebit:
- return `${p.tag}:${p.peerPullPaymentIncomingId}` as TaskId;
+ return `${p.tag}:${p.peerPullDebitId}` as TaskId;
case PendingTaskType.PeerPushCredit:
- return `${p.tag}:${p.peerPushPaymentIncomingId}` as TaskId;
+ return `${p.tag}:${p.peerPushCreditId}` as TaskId;
case PendingTaskType.PeerPullCredit:
return `${p.tag}:${p.pursePub}` as TaskId;
case PendingTaskType.PeerPushDebit:
@@ -950,23 +950,23 @@ export namespace TaskIdentifiers {
return `${PendingTaskType.Backup}:${backupRecord.baseUrl}` as TaskId;
}
export function forPeerPushPaymentInitiation(
- ppi: PeerPushPaymentInitiationRecord,
+ ppi: PeerPushDebitRecord,
): TaskId {
return `${PendingTaskType.PeerPushDebit}:${ppi.pursePub}` as TaskId;
}
export function forPeerPullPaymentInitiation(
- ppi: PeerPullPaymentInitiationRecord,
+ ppi: PeerPullCreditRecord,
): TaskId {
return `${PendingTaskType.PeerPullCredit}:${ppi.pursePub}` as TaskId;
}
export function forPeerPullPaymentDebit(
ppi: PeerPullPaymentIncomingRecord,
): TaskId {
- return `${PendingTaskType.PeerPullDebit}:${ppi.peerPullPaymentIncomingId}` as TaskId;
+ return `${PendingTaskType.PeerPullDebit}:${ppi.peerPullDebitId}` as TaskId;
}
export function forPeerPushCredit(
ppi: PeerPushPaymentIncomingRecord,
): TaskId {
- return `${PendingTaskType.PeerPushCredit}:${ppi.peerPushPaymentIncomingId}` as TaskId;
+ return `${PendingTaskType.PeerPushCredit}:${ppi.peerPushCreditId}` as TaskId;
}
}
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index 2580c97f5..1b3248f49 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -541,7 +541,7 @@ async function processDownloadProposal(
// if original order is refunded.
if (otherPurchase && otherPurchase.refundAmountAwaiting === undefined) {
logger.warn("repurchase detected");
- p.purchaseStatus = PurchaseStatus.RepurchaseDetected;
+ p.purchaseStatus = PurchaseStatus.DoneRepurchaseDetected;
p.repurchaseProposalId = otherPurchase.proposalId;
await tx.purchases.put(p);
} else {
@@ -974,7 +974,7 @@ export async function checkPaymentByProposalId(
if (!proposal) {
throw Error(`could not get proposal ${proposalId}`);
}
- if (proposal.purchaseStatus === PurchaseStatus.RepurchaseDetected) {
+ if (proposal.purchaseStatus === PurchaseStatus.DoneRepurchaseDetected) {
const existingProposalId = proposal.repurchaseProposalId;
if (existingProposalId) {
logger.trace("using existing purchase for same product");
@@ -1527,7 +1527,7 @@ export async function processPurchase(
return processPurchaseDialogShared(ws, purchase);
case PurchaseStatus.FailedClaim:
case PurchaseStatus.Done:
- case PurchaseStatus.RepurchaseDetected:
+ case PurchaseStatus.DoneRepurchaseDetected:
case PurchaseStatus.DialogProposed:
case PurchaseStatus.AbortedProposalRefused:
case PurchaseStatus.AbortedIncompletePayment:
@@ -2099,7 +2099,7 @@ export function computePayMerchantTransactionState(
return {
major: TransactionMajorState.Done,
};
- case PurchaseStatus.RepurchaseDetected:
+ case PurchaseStatus.DoneRepurchaseDetected:
return {
major: TransactionMajorState.Failed,
minor: TransactionMinorState.Repurchase,
@@ -2176,7 +2176,7 @@ export function computePayMerchantTransactionActions(
return [TransactionAction.Delete];
case PurchaseStatus.Done:
return [TransactionAction.Delete];
- case PurchaseStatus.RepurchaseDetected:
+ case PurchaseStatus.DoneRepurchaseDetected:
return [TransactionAction.Delete];
case PurchaseStatus.AbortedIncompletePayment:
return [TransactionAction.Delete];
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
index 29c0fff9e..edadad1fc 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
@@ -55,8 +55,8 @@ import {
import {
KycPendingInfo,
KycUserType,
- PeerPullPaymentInitiationRecord,
- PeerPullPaymentInitiationStatus,
+ PeerPullCreditRecord,
+ PeerPullPaymentCreditStatus,
WithdrawalGroupStatus,
WithdrawalRecordType,
updateExchangeFromUrl,
@@ -90,7 +90,7 @@ const logger = new Logger("pay-peer-pull-credit.ts");
async function queryPurseForPeerPullCredit(
ws: InternalWalletState,
- pullIni: PeerPullPaymentInitiationRecord,
+ pullIni: PeerPullCreditRecord,
cancellationToken: CancellationToken,
): Promise<LongpollResult> {
const purseDepositUrl = new URL(
@@ -159,18 +159,18 @@ async function queryPurseForPeerPullCredit(
pursePub: pullIni.pursePub,
});
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadWrite(async (tx) => {
- const finPi = await tx.peerPullPaymentInitiations.get(pullIni.pursePub);
+ const finPi = await tx.peerPullCredit.get(pullIni.pursePub);
if (!finPi) {
- logger.warn("peerPullPaymentInitiation not found anymore");
+ logger.warn("peerPullCredit not found anymore");
return;
}
const oldTxState = computePeerPullCreditTransactionState(finPi);
- if (finPi.status === PeerPullPaymentInitiationStatus.PendingReady) {
- finPi.status = PeerPullPaymentInitiationStatus.PendingWithdrawing;
+ if (finPi.status === PeerPullPaymentCreditStatus.PendingReady) {
+ finPi.status = PeerPullPaymentCreditStatus.PendingWithdrawing;
}
- await tx.peerPullPaymentInitiations.put(finPi);
+ await tx.peerPullCredit.put(finPi);
const newTxState = computePeerPullCreditTransactionState(finPi);
return { oldTxState, newTxState };
});
@@ -214,22 +214,22 @@ async function longpollKycStatus(
kycStatusRes.status === HttpStatusCode.NoContent
) {
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadWrite(async (tx) => {
- const peerIni = await tx.peerPullPaymentInitiations.get(pursePub);
+ const peerIni = await tx.peerPullCredit.get(pursePub);
if (!peerIni) {
return;
}
if (
peerIni.status !==
- PeerPullPaymentInitiationStatus.PendingMergeKycRequired
+ PeerPullPaymentCreditStatus.PendingMergeKycRequired
) {
return;
}
const oldTxState = computePeerPullCreditTransactionState(peerIni);
- peerIni.status = PeerPullPaymentInitiationStatus.PendingCreatePurse;
+ peerIni.status = PeerPullPaymentCreditStatus.PendingCreatePurse;
const newTxState = computePeerPullCreditTransactionState(peerIni);
- await tx.peerPullPaymentInitiations.put(peerIni);
+ await tx.peerPullCredit.put(peerIni);
return { oldTxState, newTxState };
});
notifyTransition(ws, transactionId, transitionInfo);
@@ -250,7 +250,7 @@ async function longpollKycStatus(
async function processPeerPullCreditAbortingDeletePurse(
ws: InternalWalletState,
- peerPullIni: PeerPullPaymentInitiationRecord,
+ peerPullIni: PeerPullCreditRecord,
): Promise<TaskRunResult> {
const { pursePub, pursePriv } = peerPullIni;
const transactionId = constructTransactionIdentifier({
@@ -272,24 +272,24 @@ async function processPeerPullCreditAbortingDeletePurse(
const transitionInfo = await ws.db
.mktx((x) => [
- x.peerPullPaymentInitiations,
+ x.peerPullCredit,
x.refreshGroups,
x.denominations,
x.coinAvailability,
x.coins,
])
.runReadWrite(async (tx) => {
- const ppiRec = await tx.peerPullPaymentInitiations.get(pursePub);
+ const ppiRec = await tx.peerPullCredit.get(pursePub);
if (!ppiRec) {
return undefined;
}
if (
- ppiRec.status !== PeerPullPaymentInitiationStatus.AbortingDeletePurse
+ ppiRec.status !== PeerPullPaymentCreditStatus.AbortingDeletePurse
) {
return undefined;
}
const oldTxState = computePeerPullCreditTransactionState(ppiRec);
- ppiRec.status = PeerPullPaymentInitiationStatus.Aborted;
+ ppiRec.status = PeerPullPaymentCreditStatus.Aborted;
const newTxState = computePeerPullCreditTransactionState(ppiRec);
return {
oldTxState,
@@ -303,7 +303,7 @@ async function processPeerPullCreditAbortingDeletePurse(
async function handlePeerPullCreditWithdrawing(
ws: InternalWalletState,
- pullIni: PeerPullPaymentInitiationRecord,
+ pullIni: PeerPullCreditRecord,
): Promise<TaskRunResult> {
if (!pullIni.withdrawalGroupId) {
throw Error("invalid db state (withdrawing, but no withdrawal group ID");
@@ -315,14 +315,14 @@ async function handlePeerPullCreditWithdrawing(
const wgId = pullIni.withdrawalGroupId;
let finished: boolean = false;
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations, x.withdrawalGroups])
+ .mktx((x) => [x.peerPullCredit, x.withdrawalGroups])
.runReadWrite(async (tx) => {
- const ppi = await tx.peerPullPaymentInitiations.get(pullIni.pursePub);
+ const ppi = await tx.peerPullCredit.get(pullIni.pursePub);
if (!ppi) {
finished = true;
return;
}
- if (ppi.status !== PeerPullPaymentInitiationStatus.PendingWithdrawing) {
+ if (ppi.status !== PeerPullPaymentCreditStatus.PendingWithdrawing) {
finished = true;
return;
}
@@ -333,13 +333,13 @@ async function handlePeerPullCreditWithdrawing(
return undefined;
}
switch (wg.status) {
- case WithdrawalGroupStatus.Finished:
+ case WithdrawalGroupStatus.Done:
finished = true;
- ppi.status = PeerPullPaymentInitiationStatus.Done;
+ ppi.status = PeerPullPaymentCreditStatus.Done;
break;
// FIXME: Also handle other final states!
}
- await tx.peerPullPaymentInitiations.put(ppi);
+ await tx.peerPullCredit.put(ppi);
const newTxState = computePeerPullCreditTransactionState(ppi);
return {
oldTxState,
@@ -357,7 +357,7 @@ async function handlePeerPullCreditWithdrawing(
async function handlePeerPullCreditCreatePurse(
ws: InternalWalletState,
- pullIni: PeerPullPaymentInitiationRecord,
+ pullIni: PeerPullCreditRecord,
): Promise<TaskRunResult> {
const purseFee = Amounts.stringify(Amounts.zeroOfAmount(pullIni.amount));
const pursePub = pullIni.pursePub;
@@ -444,15 +444,15 @@ async function handlePeerPullCreditCreatePurse(
});
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadWrite(async (tx) => {
- const pi2 = await tx.peerPullPaymentInitiations.get(pursePub);
+ const pi2 = await tx.peerPullCredit.get(pursePub);
if (!pi2) {
return;
}
const oldTxState = computePeerPullCreditTransactionState(pi2);
- pi2.status = PeerPullPaymentInitiationStatus.PendingReady;
- await tx.peerPullPaymentInitiations.put(pi2);
+ pi2.status = PeerPullPaymentCreditStatus.PendingReady;
+ await tx.peerPullCredit.put(pi2);
const newTxState = computePeerPullCreditTransactionState(pi2);
return { oldTxState, newTxState };
});
@@ -466,9 +466,9 @@ export async function processPeerPullCredit(
pursePub: string,
): Promise<TaskRunResult> {
const pullIni = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadOnly(async (tx) => {
- return tx.peerPullPaymentInitiations.get(pursePub);
+ return tx.peerPullCredit.get(pursePub);
});
if (!pullIni) {
throw Error("peer pull payment initiation not found in database");
@@ -490,10 +490,10 @@ export async function processPeerPullCredit(
logger.trace(`processing ${retryTag}, status=${pullIni.status}`);
switch (pullIni.status) {
- case PeerPullPaymentInitiationStatus.Done: {
+ case PeerPullPaymentCreditStatus.Done: {
return TaskRunResult.finished();
}
- case PeerPullPaymentInitiationStatus.PendingReady:
+ case PeerPullPaymentCreditStatus.PendingReady:
runLongpollAsync(ws, retryTag, async (cancellationToken) =>
queryPurseForPeerPullCredit(ws, pullIni, cancellationToken),
);
@@ -503,7 +503,7 @@ export async function processPeerPullCredit(
return {
type: TaskRunResultType.Longpoll,
};
- case PeerPullPaymentInitiationStatus.PendingMergeKycRequired: {
+ case PeerPullPaymentCreditStatus.PendingMergeKycRequired: {
if (!pullIni.kycInfo) {
throw Error("invalid state, kycInfo required");
}
@@ -515,19 +515,19 @@ export async function processPeerPullCredit(
"individual",
);
}
- case PeerPullPaymentInitiationStatus.PendingCreatePurse:
+ case PeerPullPaymentCreditStatus.PendingCreatePurse:
return handlePeerPullCreditCreatePurse(ws, pullIni);
- case PeerPullPaymentInitiationStatus.AbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.AbortingDeletePurse:
return await processPeerPullCreditAbortingDeletePurse(ws, pullIni);
- case PeerPullPaymentInitiationStatus.PendingWithdrawing:
+ case PeerPullPaymentCreditStatus.PendingWithdrawing:
return handlePeerPullCreditWithdrawing(ws, pullIni);
- case PeerPullPaymentInitiationStatus.Aborted:
- case PeerPullPaymentInitiationStatus.Failed:
- case PeerPullPaymentInitiationStatus.SuspendedAbortingDeletePurse:
- case PeerPullPaymentInitiationStatus.SuspendedCreatePurse:
- case PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired:
- case PeerPullPaymentInitiationStatus.SuspendedReady:
- case PeerPullPaymentInitiationStatus.SuspendedWithdrawing:
+ case PeerPullPaymentCreditStatus.Aborted:
+ case PeerPullPaymentCreditStatus.Failed:
+ case PeerPullPaymentCreditStatus.SuspendedAbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.SuspendedCreatePurse:
+ case PeerPullPaymentCreditStatus.SuspendedMergeKycRequired:
+ case PeerPullPaymentCreditStatus.SuspendedReady:
+ case PeerPullPaymentCreditStatus.SuspendedWithdrawing:
break;
default:
assertUnreachable(pullIni.status);
@@ -538,7 +538,7 @@ export async function processPeerPullCredit(
async function processPeerPullCreditKycRequired(
ws: InternalWalletState,
- peerIni: PeerPullPaymentInitiationRecord,
+ peerIni: PeerPullCreditRecord,
kycPending: WalletKycUuid,
): Promise<TaskRunResult> {
const transactionId = constructTransactionIdentifier({
@@ -570,9 +570,9 @@ async function processPeerPullCreditKycRequired(
const kycStatus = await kycStatusRes.json();
logger.info(`kyc status: ${j2s(kycStatus)}`);
const { transitionInfo, result } = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadWrite(async (tx) => {
- const peerInc = await tx.peerPullPaymentInitiations.get(pursePub);
+ const peerInc = await tx.peerPullCredit.get(pursePub);
if (!peerInc) {
return {
transitionInfo: undefined,
@@ -586,9 +586,9 @@ async function processPeerPullCreditKycRequired(
};
peerInc.kycUrl = kycStatus.kyc_url;
peerInc.status =
- PeerPullPaymentInitiationStatus.PendingMergeKycRequired;
+ PeerPullPaymentCreditStatus.PendingMergeKycRequired;
const newTxState = computePeerPullCreditTransactionState(peerInc);
- await tx.peerPullPaymentInitiations.put(peerInc);
+ await tx.peerPullCredit.put(peerInc);
// We'll remove this eventually! New clients should rely on the
// kycUrl field of the transaction, not the error code.
const res: TaskRunResult = {
@@ -758,9 +758,9 @@ export async function initiatePeerPullPayment(
);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations, x.contractTerms])
+ .mktx((x) => [x.peerPullCredit, x.contractTerms])
.runReadWrite(async (tx) => {
- const ppi: PeerPullPaymentInitiationRecord = {
+ const ppi: PeerPullCreditRecord = {
amount: req.partialContractTerms.amount,
contractTermsHash: hContractTerms,
exchangeBaseUrl: exchangeBaseUrl,
@@ -768,7 +768,7 @@ export async function initiatePeerPullPayment(
pursePub: pursePair.pub,
mergePriv: mergePair.priv,
mergePub: mergePair.pub,
- status: PeerPullPaymentInitiationStatus.PendingCreatePurse,
+ status: PeerPullPaymentCreditStatus.PendingCreatePurse,
contractTerms: contractTerms,
mergeTimestamp,
contractEncNonce,
@@ -778,7 +778,7 @@ export async function initiatePeerPullPayment(
withdrawalGroupId,
estimatedAmountEffective: wi.withdrawalAmountEffective,
};
- await tx.peerPullPaymentInitiations.put(ppi);
+ await tx.peerPullCredit.put(ppi);
const oldTxState: TransactionState = {
major: TransactionMajorState.None,
};
@@ -826,39 +826,39 @@ export async function suspendPeerPullCreditTransaction(
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadWrite(async (tx) => {
- const pullCreditRec = await tx.peerPullPaymentInitiations.get(pursePub);
+ const pullCreditRec = await tx.peerPullCredit.get(pursePub);
if (!pullCreditRec) {
logger.warn(`peer pull credit ${pursePub} not found`);
return;
}
- let newStatus: PeerPullPaymentInitiationStatus | undefined = undefined;
+ let newStatus: PeerPullPaymentCreditStatus | undefined = undefined;
switch (pullCreditRec.status) {
- case PeerPullPaymentInitiationStatus.PendingCreatePurse:
- newStatus = PeerPullPaymentInitiationStatus.SuspendedCreatePurse;
+ case PeerPullPaymentCreditStatus.PendingCreatePurse:
+ newStatus = PeerPullPaymentCreditStatus.SuspendedCreatePurse;
break;
- case PeerPullPaymentInitiationStatus.PendingMergeKycRequired:
- newStatus = PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired;
+ case PeerPullPaymentCreditStatus.PendingMergeKycRequired:
+ newStatus = PeerPullPaymentCreditStatus.SuspendedMergeKycRequired;
break;
- case PeerPullPaymentInitiationStatus.PendingWithdrawing:
- newStatus = PeerPullPaymentInitiationStatus.SuspendedWithdrawing;
+ case PeerPullPaymentCreditStatus.PendingWithdrawing:
+ newStatus = PeerPullPaymentCreditStatus.SuspendedWithdrawing;
break;
- case PeerPullPaymentInitiationStatus.PendingReady:
- newStatus = PeerPullPaymentInitiationStatus.SuspendedReady;
+ case PeerPullPaymentCreditStatus.PendingReady:
+ newStatus = PeerPullPaymentCreditStatus.SuspendedReady;
break;
- case PeerPullPaymentInitiationStatus.AbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.AbortingDeletePurse:
newStatus =
- PeerPullPaymentInitiationStatus.SuspendedAbortingDeletePurse;
+ PeerPullPaymentCreditStatus.SuspendedAbortingDeletePurse;
break;
- case PeerPullPaymentInitiationStatus.Done:
- case PeerPullPaymentInitiationStatus.SuspendedCreatePurse:
- case PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired:
- case PeerPullPaymentInitiationStatus.SuspendedReady:
- case PeerPullPaymentInitiationStatus.SuspendedWithdrawing:
- case PeerPullPaymentInitiationStatus.Aborted:
- case PeerPullPaymentInitiationStatus.Failed:
- case PeerPullPaymentInitiationStatus.SuspendedAbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.Done:
+ case PeerPullPaymentCreditStatus.SuspendedCreatePurse:
+ case PeerPullPaymentCreditStatus.SuspendedMergeKycRequired:
+ case PeerPullPaymentCreditStatus.SuspendedReady:
+ case PeerPullPaymentCreditStatus.SuspendedWithdrawing:
+ case PeerPullPaymentCreditStatus.Aborted:
+ case PeerPullPaymentCreditStatus.Failed:
+ case PeerPullPaymentCreditStatus.SuspendedAbortingDeletePurse:
break;
default:
assertUnreachable(pullCreditRec.status);
@@ -867,7 +867,7 @@ export async function suspendPeerPullCreditTransaction(
const oldTxState = computePeerPullCreditTransactionState(pullCreditRec);
pullCreditRec.status = newStatus;
const newTxState = computePeerPullCreditTransactionState(pullCreditRec);
- await tx.peerPullPaymentInitiations.put(pullCreditRec);
+ await tx.peerPullCredit.put(pullCreditRec);
return {
oldTxState,
newTxState,
@@ -892,33 +892,33 @@ export async function abortPeerPullCreditTransaction(
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadWrite(async (tx) => {
- const pullCreditRec = await tx.peerPullPaymentInitiations.get(pursePub);
+ const pullCreditRec = await tx.peerPullCredit.get(pursePub);
if (!pullCreditRec) {
logger.warn(`peer pull credit ${pursePub} not found`);
return;
}
- let newStatus: PeerPullPaymentInitiationStatus | undefined = undefined;
+ let newStatus: PeerPullPaymentCreditStatus | undefined = undefined;
switch (pullCreditRec.status) {
- case PeerPullPaymentInitiationStatus.PendingCreatePurse:
- case PeerPullPaymentInitiationStatus.PendingMergeKycRequired:
- newStatus = PeerPullPaymentInitiationStatus.AbortingDeletePurse;
+ case PeerPullPaymentCreditStatus.PendingCreatePurse:
+ case PeerPullPaymentCreditStatus.PendingMergeKycRequired:
+ newStatus = PeerPullPaymentCreditStatus.AbortingDeletePurse;
break;
- case PeerPullPaymentInitiationStatus.PendingWithdrawing:
+ case PeerPullPaymentCreditStatus.PendingWithdrawing:
throw Error("can't abort anymore");
- case PeerPullPaymentInitiationStatus.PendingReady:
- newStatus = PeerPullPaymentInitiationStatus.AbortingDeletePurse;
+ case PeerPullPaymentCreditStatus.PendingReady:
+ newStatus = PeerPullPaymentCreditStatus.AbortingDeletePurse;
break;
- case PeerPullPaymentInitiationStatus.Done:
- case PeerPullPaymentInitiationStatus.SuspendedCreatePurse:
- case PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired:
- case PeerPullPaymentInitiationStatus.SuspendedReady:
- case PeerPullPaymentInitiationStatus.SuspendedWithdrawing:
- case PeerPullPaymentInitiationStatus.Aborted:
- case PeerPullPaymentInitiationStatus.AbortingDeletePurse:
- case PeerPullPaymentInitiationStatus.Failed:
- case PeerPullPaymentInitiationStatus.SuspendedAbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.Done:
+ case PeerPullPaymentCreditStatus.SuspendedCreatePurse:
+ case PeerPullPaymentCreditStatus.SuspendedMergeKycRequired:
+ case PeerPullPaymentCreditStatus.SuspendedReady:
+ case PeerPullPaymentCreditStatus.SuspendedWithdrawing:
+ case PeerPullPaymentCreditStatus.Aborted:
+ case PeerPullPaymentCreditStatus.AbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.Failed:
+ case PeerPullPaymentCreditStatus.SuspendedAbortingDeletePurse:
break;
default:
assertUnreachable(pullCreditRec.status);
@@ -927,7 +927,7 @@ export async function abortPeerPullCreditTransaction(
const oldTxState = computePeerPullCreditTransactionState(pullCreditRec);
pullCreditRec.status = newStatus;
const newTxState = computePeerPullCreditTransactionState(pullCreditRec);
- await tx.peerPullPaymentInitiations.put(pullCreditRec);
+ await tx.peerPullCredit.put(pullCreditRec);
return {
oldTxState,
newTxState,
@@ -952,30 +952,30 @@ export async function failPeerPullCreditTransaction(
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadWrite(async (tx) => {
- const pullCreditRec = await tx.peerPullPaymentInitiations.get(pursePub);
+ const pullCreditRec = await tx.peerPullCredit.get(pursePub);
if (!pullCreditRec) {
logger.warn(`peer pull credit ${pursePub} not found`);
return;
}
- let newStatus: PeerPullPaymentInitiationStatus | undefined = undefined;
+ let newStatus: PeerPullPaymentCreditStatus | undefined = undefined;
switch (pullCreditRec.status) {
- case PeerPullPaymentInitiationStatus.PendingCreatePurse:
- case PeerPullPaymentInitiationStatus.PendingMergeKycRequired:
- case PeerPullPaymentInitiationStatus.PendingWithdrawing:
- case PeerPullPaymentInitiationStatus.PendingReady:
- case PeerPullPaymentInitiationStatus.Done:
- case PeerPullPaymentInitiationStatus.SuspendedCreatePurse:
- case PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired:
- case PeerPullPaymentInitiationStatus.SuspendedReady:
- case PeerPullPaymentInitiationStatus.SuspendedWithdrawing:
- case PeerPullPaymentInitiationStatus.Aborted:
- case PeerPullPaymentInitiationStatus.Failed:
+ case PeerPullPaymentCreditStatus.PendingCreatePurse:
+ case PeerPullPaymentCreditStatus.PendingMergeKycRequired:
+ case PeerPullPaymentCreditStatus.PendingWithdrawing:
+ case PeerPullPaymentCreditStatus.PendingReady:
+ case PeerPullPaymentCreditStatus.Done:
+ case PeerPullPaymentCreditStatus.SuspendedCreatePurse:
+ case PeerPullPaymentCreditStatus.SuspendedMergeKycRequired:
+ case PeerPullPaymentCreditStatus.SuspendedReady:
+ case PeerPullPaymentCreditStatus.SuspendedWithdrawing:
+ case PeerPullPaymentCreditStatus.Aborted:
+ case PeerPullPaymentCreditStatus.Failed:
break;
- case PeerPullPaymentInitiationStatus.AbortingDeletePurse:
- case PeerPullPaymentInitiationStatus.SuspendedAbortingDeletePurse:
- newStatus = PeerPullPaymentInitiationStatus.Failed;
+ case PeerPullPaymentCreditStatus.AbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.SuspendedAbortingDeletePurse:
+ newStatus = PeerPullPaymentCreditStatus.Failed;
break;
default:
assertUnreachable(pullCreditRec.status);
@@ -984,7 +984,7 @@ export async function failPeerPullCreditTransaction(
const oldTxState = computePeerPullCreditTransactionState(pullCreditRec);
pullCreditRec.status = newStatus;
const newTxState = computePeerPullCreditTransactionState(pullCreditRec);
- await tx.peerPullPaymentInitiations.put(pullCreditRec);
+ await tx.peerPullCredit.put(pullCreditRec);
return {
oldTxState,
newTxState,
@@ -1009,38 +1009,38 @@ export async function resumePeerPullCreditTransaction(
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentInitiations])
+ .mktx((x) => [x.peerPullCredit])
.runReadWrite(async (tx) => {
- const pullCreditRec = await tx.peerPullPaymentInitiations.get(pursePub);
+ const pullCreditRec = await tx.peerPullCredit.get(pursePub);
if (!pullCreditRec) {
logger.warn(`peer pull credit ${pursePub} not found`);
return;
}
- let newStatus: PeerPullPaymentInitiationStatus | undefined = undefined;
+ let newStatus: PeerPullPaymentCreditStatus | undefined = undefined;
switch (pullCreditRec.status) {
- case PeerPullPaymentInitiationStatus.PendingCreatePurse:
- case PeerPullPaymentInitiationStatus.PendingMergeKycRequired:
- case PeerPullPaymentInitiationStatus.PendingWithdrawing:
- case PeerPullPaymentInitiationStatus.PendingReady:
- case PeerPullPaymentInitiationStatus.AbortingDeletePurse:
- case PeerPullPaymentInitiationStatus.Done:
- case PeerPullPaymentInitiationStatus.Failed:
- case PeerPullPaymentInitiationStatus.Aborted:
+ case PeerPullPaymentCreditStatus.PendingCreatePurse:
+ case PeerPullPaymentCreditStatus.PendingMergeKycRequired:
+ case PeerPullPaymentCreditStatus.PendingWithdrawing:
+ case PeerPullPaymentCreditStatus.PendingReady:
+ case PeerPullPaymentCreditStatus.AbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.Done:
+ case PeerPullPaymentCreditStatus.Failed:
+ case PeerPullPaymentCreditStatus.Aborted:
break;
- case PeerPullPaymentInitiationStatus.SuspendedCreatePurse:
- newStatus = PeerPullPaymentInitiationStatus.PendingCreatePurse;
+ case PeerPullPaymentCreditStatus.SuspendedCreatePurse:
+ newStatus = PeerPullPaymentCreditStatus.PendingCreatePurse;
break;
- case PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired:
- newStatus = PeerPullPaymentInitiationStatus.PendingMergeKycRequired;
+ case PeerPullPaymentCreditStatus.SuspendedMergeKycRequired:
+ newStatus = PeerPullPaymentCreditStatus.PendingMergeKycRequired;
break;
- case PeerPullPaymentInitiationStatus.SuspendedReady:
- newStatus = PeerPullPaymentInitiationStatus.PendingReady;
+ case PeerPullPaymentCreditStatus.SuspendedReady:
+ newStatus = PeerPullPaymentCreditStatus.PendingReady;
break;
- case PeerPullPaymentInitiationStatus.SuspendedWithdrawing:
- newStatus = PeerPullPaymentInitiationStatus.PendingWithdrawing;
+ case PeerPullPaymentCreditStatus.SuspendedWithdrawing:
+ newStatus = PeerPullPaymentCreditStatus.PendingWithdrawing;
break;
- case PeerPullPaymentInitiationStatus.SuspendedAbortingDeletePurse:
- newStatus = PeerPullPaymentInitiationStatus.AbortingDeletePurse;
+ case PeerPullPaymentCreditStatus.SuspendedAbortingDeletePurse:
+ newStatus = PeerPullPaymentCreditStatus.AbortingDeletePurse;
break;
default:
assertUnreachable(pullCreditRec.status);
@@ -1049,7 +1049,7 @@ export async function resumePeerPullCreditTransaction(
const oldTxState = computePeerPullCreditTransactionState(pullCreditRec);
pullCreditRec.status = newStatus;
const newTxState = computePeerPullCreditTransactionState(pullCreditRec);
- await tx.peerPullPaymentInitiations.put(pullCreditRec);
+ await tx.peerPullCredit.put(pullCreditRec);
return {
oldTxState,
newTxState,
@@ -1062,67 +1062,67 @@ export async function resumePeerPullCreditTransaction(
}
export function computePeerPullCreditTransactionState(
- pullCreditRecord: PeerPullPaymentInitiationRecord,
+ pullCreditRecord: PeerPullCreditRecord,
): TransactionState {
switch (pullCreditRecord.status) {
- case PeerPullPaymentInitiationStatus.PendingCreatePurse:
+ case PeerPullPaymentCreditStatus.PendingCreatePurse:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.CreatePurse,
};
- case PeerPullPaymentInitiationStatus.PendingMergeKycRequired:
+ case PeerPullPaymentCreditStatus.PendingMergeKycRequired:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.MergeKycRequired,
};
- case PeerPullPaymentInitiationStatus.PendingReady:
+ case PeerPullPaymentCreditStatus.PendingReady:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.Ready,
};
- case PeerPullPaymentInitiationStatus.Done:
+ case PeerPullPaymentCreditStatus.Done:
return {
major: TransactionMajorState.Done,
};
- case PeerPullPaymentInitiationStatus.PendingWithdrawing:
+ case PeerPullPaymentCreditStatus.PendingWithdrawing:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.Withdraw,
};
- case PeerPullPaymentInitiationStatus.SuspendedCreatePurse:
+ case PeerPullPaymentCreditStatus.SuspendedCreatePurse:
return {
major: TransactionMajorState.Suspended,
minor: TransactionMinorState.CreatePurse,
};
- case PeerPullPaymentInitiationStatus.SuspendedReady:
+ case PeerPullPaymentCreditStatus.SuspendedReady:
return {
major: TransactionMajorState.Suspended,
minor: TransactionMinorState.Ready,
};
- case PeerPullPaymentInitiationStatus.SuspendedWithdrawing:
+ case PeerPullPaymentCreditStatus.SuspendedWithdrawing:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.Withdraw,
};
- case PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired:
+ case PeerPullPaymentCreditStatus.SuspendedMergeKycRequired:
return {
major: TransactionMajorState.Suspended,
minor: TransactionMinorState.MergeKycRequired,
};
- case PeerPullPaymentInitiationStatus.Aborted:
+ case PeerPullPaymentCreditStatus.Aborted:
return {
major: TransactionMajorState.Aborted,
};
- case PeerPullPaymentInitiationStatus.AbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.AbortingDeletePurse:
return {
major: TransactionMajorState.Aborting,
minor: TransactionMinorState.DeletePurse,
};
- case PeerPullPaymentInitiationStatus.Failed:
+ case PeerPullPaymentCreditStatus.Failed:
return {
major: TransactionMajorState.Failed,
};
- case PeerPullPaymentInitiationStatus.SuspendedAbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.SuspendedAbortingDeletePurse:
return {
major: TransactionMajorState.Aborting,
minor: TransactionMinorState.DeletePurse,
@@ -1131,34 +1131,34 @@ export function computePeerPullCreditTransactionState(
}
export function computePeerPullCreditTransactionActions(
- pullCreditRecord: PeerPullPaymentInitiationRecord,
+ pullCreditRecord: PeerPullCreditRecord,
): TransactionAction[] {
switch (pullCreditRecord.status) {
- case PeerPullPaymentInitiationStatus.PendingCreatePurse:
+ case PeerPullPaymentCreditStatus.PendingCreatePurse:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPullPaymentInitiationStatus.PendingMergeKycRequired:
+ case PeerPullPaymentCreditStatus.PendingMergeKycRequired:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPullPaymentInitiationStatus.PendingReady:
+ case PeerPullPaymentCreditStatus.PendingReady:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPullPaymentInitiationStatus.Done:
+ case PeerPullPaymentCreditStatus.Done:
return [TransactionAction.Delete];
- case PeerPullPaymentInitiationStatus.PendingWithdrawing:
+ case PeerPullPaymentCreditStatus.PendingWithdrawing:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPullPaymentInitiationStatus.SuspendedCreatePurse:
+ case PeerPullPaymentCreditStatus.SuspendedCreatePurse:
return [TransactionAction.Resume, TransactionAction.Abort];
- case PeerPullPaymentInitiationStatus.SuspendedReady:
+ case PeerPullPaymentCreditStatus.SuspendedReady:
return [TransactionAction.Abort, TransactionAction.Resume];
- case PeerPullPaymentInitiationStatus.SuspendedWithdrawing:
+ case PeerPullPaymentCreditStatus.SuspendedWithdrawing:
return [TransactionAction.Resume, TransactionAction.Fail];
- case PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired:
+ case PeerPullPaymentCreditStatus.SuspendedMergeKycRequired:
return [TransactionAction.Resume, TransactionAction.Fail];
- case PeerPullPaymentInitiationStatus.Aborted:
+ case PeerPullPaymentCreditStatus.Aborted:
return [TransactionAction.Delete];
- case PeerPullPaymentInitiationStatus.AbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.AbortingDeletePurse:
return [TransactionAction.Suspend, TransactionAction.Fail];
- case PeerPullPaymentInitiationStatus.Failed:
+ case PeerPullPaymentCreditStatus.Failed:
return [TransactionAction.Delete];
- case PeerPullPaymentInitiationStatus.SuspendedAbortingDeletePurse:
+ case PeerPullPaymentCreditStatus.SuspendedAbortingDeletePurse:
return [TransactionAction.Resume, TransactionAction.Fail];
}
}
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
index 0de91bf97..f357c41d5 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
@@ -140,10 +140,10 @@ async function handlePurseCreationConflict(
);
await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- const myPpi = await tx.peerPullPaymentIncoming.get(
- peerPullInc.peerPullPaymentIncomingId,
+ const myPpi = await tx.peerPullDebit.get(
+ peerPullInc.peerPullDebitId,
);
if (!myPpi) {
return;
@@ -162,7 +162,7 @@ async function handlePurseCreationConflict(
default:
return;
}
- await tx.peerPullPaymentIncoming.put(myPpi);
+ await tx.peerPullDebit.put(myPpi);
});
return TaskRunResult.finished();
}
@@ -171,7 +171,7 @@ async function processPeerPullDebitPendingDeposit(
ws: InternalWalletState,
peerPullInc: PeerPullPaymentIncomingRecord,
): Promise<TaskRunResult> {
- const peerPullPaymentIncomingId = peerPullInc.peerPullPaymentIncomingId;
+ const peerPullDebitId = peerPullInc.peerPullDebitId;
const pursePub = peerPullInc.pursePub;
const coinSel = peerPullInc.coinSel;
@@ -202,7 +202,7 @@ async function processPeerPullDebitPendingDeposit(
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
const httpResp = await ws.http.fetch(purseDepositUrl.href, {
@@ -218,10 +218,10 @@ async function processPeerPullDebitPendingDeposit(
logger.trace(`purse deposit response: ${j2s(resp)}`);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- const pi = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const pi = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (!pi) {
throw Error("peer pull payment not found anymore");
@@ -230,9 +230,9 @@ async function processPeerPullDebitPendingDeposit(
return;
}
const oldTxState = computePeerPullDebitTransactionState(pi);
- pi.status = PeerPullDebitRecordStatus.DonePaid;
+ pi.status = PeerPullDebitRecordStatus.Done;
const newTxState = computePeerPullDebitTransactionState(pi);
- await tx.peerPullPaymentIncoming.put(pi);
+ await tx.peerPullDebit.put(pi);
return { oldTxState, newTxState };
});
notifyTransition(ws, transactionId, transitionInfo);
@@ -241,15 +241,15 @@ async function processPeerPullDebitPendingDeposit(
case HttpStatusCode.Gone: {
const transitionInfo = await ws.db
.mktx((x) => [
- x.peerPullPaymentIncoming,
+ x.peerPullDebit,
x.refreshGroups,
x.denominations,
x.coinAvailability,
x.coins,
])
.runReadWrite(async (tx) => {
- const pi = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const pi = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (!pi) {
throw Error("peer pull payment not found anymore");
@@ -284,7 +284,7 @@ async function processPeerPullDebitPendingDeposit(
pi.status = PeerPullDebitRecordStatus.AbortingRefresh;
pi.abortRefreshGroupId = refresh.refreshGroupId;
const newTxState = computePeerPullDebitTransactionState(pi);
- await tx.peerPullPaymentIncoming.put(pi);
+ await tx.peerPullDebit.put(pi);
return { oldTxState, newTxState };
});
notifyTransition(ws, transactionId, transitionInfo);
@@ -308,15 +308,15 @@ async function processPeerPullDebitAbortingRefresh(
ws: InternalWalletState,
peerPullInc: PeerPullPaymentIncomingRecord,
): Promise<TaskRunResult> {
- const peerPullPaymentIncomingId = peerPullInc.peerPullPaymentIncomingId;
+ const peerPullDebitId = peerPullInc.peerPullDebitId;
const abortRefreshGroupId = peerPullInc.abortRefreshGroupId;
checkLogicInvariant(!!abortRefreshGroupId);
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
const transitionInfo = await ws.db
- .mktx((x) => [x.refreshGroups, x.peerPullPaymentIncoming])
+ .mktx((x) => [x.refreshGroups, x.peerPullDebit])
.runReadWrite(async (tx) => {
const refreshGroup = await tx.refreshGroups.get(abortRefreshGroupId);
let newOpState: PeerPullDebitRecordStatus | undefined;
@@ -335,8 +335,8 @@ async function processPeerPullDebitAbortingRefresh(
}
}
if (newOpState) {
- const newDg = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const newDg = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (!newDg) {
return;
@@ -344,7 +344,7 @@ async function processPeerPullDebitAbortingRefresh(
const oldTxState = computePeerPullDebitTransactionState(newDg);
newDg.status = newOpState;
const newTxState = computePeerPullDebitTransactionState(newDg);
- await tx.peerPullPaymentIncoming.put(newDg);
+ await tx.peerPullDebit.put(newDg);
return { oldTxState, newTxState };
}
return undefined;
@@ -356,12 +356,12 @@ async function processPeerPullDebitAbortingRefresh(
export async function processPeerPullDebit(
ws: InternalWalletState,
- peerPullPaymentIncomingId: string,
+ peerPullDebitId: string,
): Promise<TaskRunResult> {
const peerPullInc = await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadOnly(async (tx) => {
- return tx.peerPullPaymentIncoming.get(peerPullPaymentIncomingId);
+ return tx.peerPullDebit.get(peerPullDebitId);
});
if (!peerPullInc) {
throw Error("peer pull debit not found");
@@ -380,31 +380,31 @@ export async function confirmPeerPullDebit(
ws: InternalWalletState,
req: ConfirmPeerPullDebitRequest,
): Promise<AcceptPeerPullPaymentResponse> {
- let peerPullPaymentIncomingId: string;
+ let peerPullDebitId: string;
if (req.transactionId) {
const parsedTx = parseTransactionIdentifier(req.transactionId);
if (!parsedTx || parsedTx.tag !== TransactionType.PeerPullDebit) {
throw Error("invalid peer-pull-debit transaction identifier");
}
- peerPullPaymentIncomingId = parsedTx.peerPullPaymentIncomingId;
- } else if (req.peerPullPaymentIncomingId) {
- peerPullPaymentIncomingId = req.peerPullPaymentIncomingId;
+ peerPullDebitId = parsedTx.peerPullDebitId;
+ } else if (req.peerPullDebitId) {
+ peerPullDebitId = req.peerPullDebitId;
} else {
throw Error(
- "invalid request, transactionId or peerPullPaymentIncomingId required",
+ "invalid request, transactionId or peerPullDebitId required",
);
}
const peerPullInc = await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadOnly(async (tx) => {
- return tx.peerPullPaymentIncoming.get(peerPullPaymentIncomingId);
+ return tx.peerPullDebit.get(peerPullDebitId);
});
if (!peerPullInc) {
throw Error(
- `can't accept unknown incoming p2p pull payment (${req.peerPullPaymentIncomingId})`,
+ `can't accept unknown incoming p2p pull payment (${req.peerPullDebitId})`,
);
}
@@ -437,15 +437,15 @@ export async function confirmPeerPullDebit(
x.coins,
x.denominations,
x.refreshGroups,
- x.peerPullPaymentIncoming,
+ x.peerPullDebit,
x.coinAvailability,
])
.runReadWrite(async (tx) => {
await spendCoins(ws, tx, {
- // allocationId: `txn:peer-pull-debit:${req.peerPullPaymentIncomingId}`,
+ // allocationId: `txn:peer-pull-debit:${req.peerPullDebitId}`,
allocationId: constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
}),
coinPubs: sel.coins.map((x) => x.coinPub),
contributions: sel.coins.map((x) =>
@@ -454,8 +454,8 @@ export async function confirmPeerPullDebit(
refreshReason: RefreshReason.PayPeerPull,
});
- const pi = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const pi = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (!pi) {
throw Error();
@@ -468,7 +468,7 @@ export async function confirmPeerPullDebit(
totalCost: Amounts.stringify(totalAmount),
};
}
- await tx.peerPullPaymentIncoming.put(pi);
+ await tx.peerPullDebit.put(pi);
return pi;
});
@@ -476,7 +476,7 @@ export async function confirmPeerPullDebit(
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
return {
@@ -499,9 +499,9 @@ export async function preparePeerPullDebit(
}
const existingPullIncomingRecord = await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadOnly(async (tx) => {
- return tx.peerPullPaymentIncoming.indexes.byExchangeAndContractPriv.get([
+ return tx.peerPullDebit.indexes.byExchangeAndContractPriv.get([
uri.exchangeBaseUrl,
uri.contractPriv,
]);
@@ -513,12 +513,12 @@ export async function preparePeerPullDebit(
amountRaw: existingPullIncomingRecord.contractTerms.amount,
amountEffective: existingPullIncomingRecord.totalCostEstimated,
contractTerms: existingPullIncomingRecord.contractTerms,
- peerPullPaymentIncomingId:
- existingPullIncomingRecord.peerPullPaymentIncomingId,
+ peerPullDebitId:
+ existingPullIncomingRecord.peerPullDebitId,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId:
- existingPullIncomingRecord.peerPullPaymentIncomingId,
+ peerPullDebitId:
+ existingPullIncomingRecord.peerPullDebitId,
}),
};
}
@@ -553,7 +553,7 @@ export async function preparePeerPullDebit(
codecForExchangePurseStatus(),
);
- const peerPullPaymentIncomingId = encodeCrock(getRandomBytes(32));
+ const peerPullDebitId = encodeCrock(getRandomBytes(32));
let contractTerms: PeerContractTerms;
@@ -588,10 +588,10 @@ export async function preparePeerPullDebit(
);
await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- await tx.peerPullPaymentIncoming.add({
- peerPullPaymentIncomingId,
+ await tx.peerPullDebit.add({
+ peerPullDebitId,
contractPriv: contractPriv,
exchangeBaseUrl: exchangeBaseUrl,
pursePub: pursePub,
@@ -607,42 +607,42 @@ export async function preparePeerPullDebit(
amountEffective: Amounts.stringify(totalAmount),
amountRaw: contractTerms.amount,
contractTerms: contractTerms,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId: peerPullPaymentIncomingId,
+ peerPullDebitId: peerPullDebitId,
}),
};
}
export async function suspendPeerPullDebitTransaction(
ws: InternalWalletState,
- peerPullPaymentIncomingId: string,
+ peerPullDebitId: string,
) {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- const pullDebitRec = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const pullDebitRec = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (!pullDebitRec) {
- logger.warn(`peer pull debit ${peerPullPaymentIncomingId} not found`);
+ logger.warn(`peer pull debit ${peerPullDebitId} not found`);
return;
}
let newStatus: PeerPullDebitRecordStatus | undefined = undefined;
switch (pullDebitRec.status) {
case PeerPullDebitRecordStatus.DialogProposed:
break;
- case PeerPullDebitRecordStatus.DonePaid:
+ case PeerPullDebitRecordStatus.Done:
break;
case PeerPullDebitRecordStatus.PendingDeposit:
newStatus = PeerPullDebitRecordStatus.SuspendedDeposit;
@@ -665,7 +665,7 @@ export async function suspendPeerPullDebitTransaction(
const oldTxState = computePeerPullDebitTransactionState(pullDebitRec);
pullDebitRec.status = newStatus;
const newTxState = computePeerPullDebitTransactionState(pullDebitRec);
- await tx.peerPullPaymentIncoming.put(pullDebitRec);
+ await tx.peerPullDebit.put(pullDebitRec);
return {
oldTxState,
newTxState,
@@ -678,25 +678,25 @@ export async function suspendPeerPullDebitTransaction(
export async function abortPeerPullDebitTransaction(
ws: InternalWalletState,
- peerPullPaymentIncomingId: string,
+ peerPullDebitId: string,
) {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- const pullDebitRec = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const pullDebitRec = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (!pullDebitRec) {
- logger.warn(`peer pull debit ${peerPullPaymentIncomingId} not found`);
+ logger.warn(`peer pull debit ${peerPullDebitId} not found`);
return;
}
let newStatus: PeerPullDebitRecordStatus | undefined = undefined;
@@ -704,7 +704,7 @@ export async function abortPeerPullDebitTransaction(
case PeerPullDebitRecordStatus.DialogProposed:
newStatus = PeerPullDebitRecordStatus.Aborted;
break;
- case PeerPullDebitRecordStatus.DonePaid:
+ case PeerPullDebitRecordStatus.Done:
break;
case PeerPullDebitRecordStatus.PendingDeposit:
newStatus = PeerPullDebitRecordStatus.AbortingRefresh;
@@ -726,7 +726,7 @@ export async function abortPeerPullDebitTransaction(
const oldTxState = computePeerPullDebitTransactionState(pullDebitRec);
pullDebitRec.status = newStatus;
const newTxState = computePeerPullDebitTransactionState(pullDebitRec);
- await tx.peerPullPaymentIncoming.put(pullDebitRec);
+ await tx.peerPullDebit.put(pullDebitRec);
return {
oldTxState,
newTxState,
@@ -739,25 +739,25 @@ export async function abortPeerPullDebitTransaction(
export async function failPeerPullDebitTransaction(
ws: InternalWalletState,
- peerPullPaymentIncomingId: string,
+ peerPullDebitId: string,
) {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- const pullDebitRec = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const pullDebitRec = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (!pullDebitRec) {
- logger.warn(`peer pull debit ${peerPullPaymentIncomingId} not found`);
+ logger.warn(`peer pull debit ${peerPullDebitId} not found`);
return;
}
let newStatus: PeerPullDebitRecordStatus | undefined = undefined;
@@ -765,7 +765,7 @@ export async function failPeerPullDebitTransaction(
case PeerPullDebitRecordStatus.DialogProposed:
newStatus = PeerPullDebitRecordStatus.Aborted;
break;
- case PeerPullDebitRecordStatus.DonePaid:
+ case PeerPullDebitRecordStatus.Done:
break;
case PeerPullDebitRecordStatus.PendingDeposit:
break;
@@ -787,7 +787,7 @@ export async function failPeerPullDebitTransaction(
const oldTxState = computePeerPullDebitTransactionState(pullDebitRec);
pullDebitRec.status = newStatus;
const newTxState = computePeerPullDebitTransactionState(pullDebitRec);
- await tx.peerPullPaymentIncoming.put(pullDebitRec);
+ await tx.peerPullDebit.put(pullDebitRec);
return {
oldTxState,
newTxState,
@@ -800,31 +800,31 @@ export async function failPeerPullDebitTransaction(
export async function resumePeerPullDebitTransaction(
ws: InternalWalletState,
- peerPullPaymentIncomingId: string,
+ peerPullDebitId: string,
) {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- const pullDebitRec = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const pullDebitRec = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (!pullDebitRec) {
- logger.warn(`peer pull debit ${peerPullPaymentIncomingId} not found`);
+ logger.warn(`peer pull debit ${peerPullDebitId} not found`);
return;
}
let newStatus: PeerPullDebitRecordStatus | undefined = undefined;
switch (pullDebitRec.status) {
case PeerPullDebitRecordStatus.DialogProposed:
- case PeerPullDebitRecordStatus.DonePaid:
+ case PeerPullDebitRecordStatus.Done:
case PeerPullDebitRecordStatus.PendingDeposit:
break;
case PeerPullDebitRecordStatus.SuspendedDeposit:
@@ -846,7 +846,7 @@ export async function resumePeerPullDebitTransaction(
const oldTxState = computePeerPullDebitTransactionState(pullDebitRec);
pullDebitRec.status = newStatus;
const newTxState = computePeerPullDebitTransactionState(pullDebitRec);
- await tx.peerPullPaymentIncoming.put(pullDebitRec);
+ await tx.peerPullDebit.put(pullDebitRec);
return {
oldTxState,
newTxState,
@@ -872,7 +872,7 @@ export function computePeerPullDebitTransactionState(
major: TransactionMajorState.Pending,
minor: TransactionMinorState.Deposit,
};
- case PeerPullDebitRecordStatus.DonePaid:
+ case PeerPullDebitRecordStatus.Done:
return {
major: TransactionMajorState.Done,
};
@@ -910,7 +910,7 @@ export function computePeerPullDebitTransactionActions(
return [];
case PeerPullDebitRecordStatus.PendingDeposit:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPullDebitRecordStatus.DonePaid:
+ case PeerPullDebitRecordStatus.Done:
return [TransactionAction.Delete];
case PeerPullDebitRecordStatus.SuspendedDeposit:
return [TransactionAction.Resume, TransactionAction.Abort];
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 afeeb2c6b..f0f659aa3 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
@@ -55,7 +55,7 @@ import {
KycPendingInfo,
KycUserType,
PeerPushPaymentIncomingRecord,
- PeerPushPaymentIncomingStatus,
+ PeerPushCreditStatus,
PendingTaskType,
WithdrawalGroupStatus,
WithdrawalRecordType,
@@ -99,10 +99,10 @@ export async function preparePeerPushCredit(
}
const existing = await ws.db
- .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming])
+ .mktx((x) => [x.contractTerms, x.peerPushCredit])
.runReadOnly(async (tx) => {
const existingPushInc =
- await tx.peerPushPaymentIncoming.indexes.byExchangeAndContractPriv.get([
+ await tx.peerPushCredit.indexes.byExchangeAndContractPriv.get([
uri.exchangeBaseUrl,
uri.contractPriv,
]);
@@ -129,12 +129,12 @@ export async function preparePeerPushCredit(
amountEffective: existing.existingPushInc.estimatedAmountEffective,
amountRaw: existing.existingContractTerms.amount,
contractTerms: existing.existingContractTerms,
- peerPushPaymentIncomingId:
- existing.existingPushInc.peerPushPaymentIncomingId,
+ peerPushCreditId:
+ existing.existingPushInc.peerPushCreditId,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId:
- existing.existingPushInc.peerPushPaymentIncomingId,
+ peerPushCreditId:
+ existing.existingPushInc.peerPushCreditId,
}),
};
}
@@ -172,7 +172,7 @@ export async function preparePeerPushCredit(
codecForExchangePurseStatus(),
);
- const peerPushPaymentIncomingId = encodeCrock(getRandomBytes(32));
+ const peerPushCreditId = encodeCrock(getRandomBytes(32));
const contractTermsHash = ContractTermsUtil.hashContractTerms(
dec.contractTerms,
@@ -188,17 +188,17 @@ export async function preparePeerPushCredit(
);
await ws.db
- .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming])
+ .mktx((x) => [x.contractTerms, x.peerPushCredit])
.runReadWrite(async (tx) => {
- await tx.peerPushPaymentIncoming.add({
- peerPushPaymentIncomingId,
+ await tx.peerPushCredit.add({
+ peerPushCreditId,
contractPriv: contractPriv,
exchangeBaseUrl: exchangeBaseUrl,
mergePriv: dec.mergePriv,
pursePub: pursePub,
timestamp: TalerPreciseTimestamp.now(),
contractTermsHash,
- status: PeerPushPaymentIncomingStatus.DialogProposed,
+ status: PeerPushCreditStatus.DialogProposed,
withdrawalGroupId,
currency: Amounts.currencyOf(purseStatus.balance),
estimatedAmountEffective: Amounts.stringify(
@@ -219,28 +219,28 @@ export async function preparePeerPushCredit(
amountEffective: wi.withdrawalAmountEffective,
amountRaw: purseStatus.balance,
contractTerms: dec.contractTerms,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
}),
};
}
async function longpollKycStatus(
ws: InternalWalletState,
- peerPushPaymentIncomingId: string,
+ peerPushCreditId: string,
exchangeUrl: string,
kycInfo: KycPendingInfo,
userType: KycUserType,
): Promise<TaskRunResult> {
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
const retryTag = constructTaskIdentifier({
tag: PendingTaskType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
runLongpollAsync(ws, retryTag, async (ct) => {
@@ -261,24 +261,24 @@ async function longpollKycStatus(
kycStatusRes.status === HttpStatusCode.NoContent
) {
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentIncoming])
+ .mktx((x) => [x.peerPushCredit])
.runReadWrite(async (tx) => {
- const peerInc = await tx.peerPushPaymentIncoming.get(
- peerPushPaymentIncomingId,
+ const peerInc = await tx.peerPushCredit.get(
+ peerPushCreditId,
);
if (!peerInc) {
return;
}
if (
peerInc.status !==
- PeerPushPaymentIncomingStatus.PendingMergeKycRequired
+ PeerPushCreditStatus.PendingMergeKycRequired
) {
return;
}
const oldTxState = computePeerPushCreditTransactionState(peerInc);
- peerInc.status = PeerPushPaymentIncomingStatus.PendingMerge;
+ peerInc.status = PeerPushCreditStatus.PendingMerge;
const newTxState = computePeerPushCreditTransactionState(peerInc);
- await tx.peerPushPaymentIncoming.put(peerInc);
+ await tx.peerPushCredit.put(peerInc);
return { oldTxState, newTxState };
});
notifyTransition(ws, transactionId, transitionInfo);
@@ -304,9 +304,9 @@ async function processPeerPushCreditKycRequired(
): Promise<TaskRunResult> {
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId: peerInc.peerPushPaymentIncomingId,
+ peerPushCreditId: peerInc.peerPushCreditId,
});
- const { peerPushPaymentIncomingId } = peerInc;
+ const { peerPushCreditId } = peerInc;
const userType = "individual";
const url = new URL(
@@ -331,10 +331,10 @@ async function processPeerPushCreditKycRequired(
const kycStatus = await kycStatusRes.json();
logger.info(`kyc status: ${j2s(kycStatus)}`);
const { transitionInfo, result } = await ws.db
- .mktx((x) => [x.peerPushPaymentIncoming])
+ .mktx((x) => [x.peerPushCredit])
.runReadWrite(async (tx) => {
- const peerInc = await tx.peerPushPaymentIncoming.get(
- peerPushPaymentIncomingId,
+ const peerInc = await tx.peerPushCredit.get(
+ peerPushCreditId,
);
if (!peerInc) {
return {
@@ -348,9 +348,9 @@ async function processPeerPushCreditKycRequired(
requirementRow: kycPending.requirement_row,
};
peerInc.kycUrl = kycStatus.kyc_url;
- peerInc.status = PeerPushPaymentIncomingStatus.PendingMergeKycRequired;
+ peerInc.status = PeerPushCreditStatus.PendingMergeKycRequired;
const newTxState = computePeerPushCreditTransactionState(peerInc);
- await tx.peerPushPaymentIncoming.put(peerInc);
+ await tx.peerPushCredit.put(peerInc);
// We'll remove this eventually! New clients should rely on the
// kycUrl field of the transaction, not the error code.
const res: TaskRunResult = {
@@ -379,10 +379,10 @@ async function handlePendingMerge(
peerInc: PeerPushPaymentIncomingRecord,
contractTerms: PeerContractTerms,
): Promise<TaskRunResult> {
- const { peerPushPaymentIncomingId } = peerInc;
+ const { peerPushCreditId } = peerInc;
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
const amount = Amounts.parseOrThrow(contractTerms.amount);
@@ -460,15 +460,15 @@ async function handlePendingMerge(
const txRes = await ws.db
.mktx((x) => [
x.contractTerms,
- x.peerPushPaymentIncoming,
+ x.peerPushCredit,
x.withdrawalGroups,
x.reserves,
x.exchanges,
x.exchangeDetails,
])
.runReadWrite(async (tx) => {
- const peerInc = await tx.peerPushPaymentIncoming.get(
- peerPushPaymentIncomingId,
+ const peerInc = await tx.peerPushCredit.get(
+ peerPushCreditId,
);
if (!peerInc) {
return undefined;
@@ -476,9 +476,9 @@ async function handlePendingMerge(
let withdrawalTransition: TransitionInfo | undefined;
const oldTxState = computePeerPushCreditTransactionState(peerInc);
switch (peerInc.status) {
- case PeerPushPaymentIncomingStatus.PendingMerge:
- case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: {
- peerInc.status = PeerPushPaymentIncomingStatus.PendingWithdrawing;
+ case PeerPushCreditStatus.PendingMerge:
+ case PeerPushCreditStatus.PendingMergeKycRequired: {
+ peerInc.status = PeerPushCreditStatus.PendingWithdrawing;
const wgRes = await internalPerformCreateWithdrawalGroup(
ws,
tx,
@@ -488,7 +488,7 @@ async function handlePendingMerge(
break;
}
}
- await tx.peerPushPaymentIncoming.put(peerInc);
+ await tx.peerPushCredit.put(peerInc);
const newTxState = computePeerPushCreditTransactionState(peerInc);
return {
peerPushCreditTransition: { oldTxState, newTxState },
@@ -514,21 +514,21 @@ async function handlePendingWithdrawing(
}
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId: peerInc.peerPushPaymentIncomingId,
+ peerPushCreditId: peerInc.peerPushCreditId,
});
const wgId = peerInc.withdrawalGroupId;
let finished: boolean = false;
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentIncoming, x.withdrawalGroups])
+ .mktx((x) => [x.peerPushCredit, x.withdrawalGroups])
.runReadWrite(async (tx) => {
- const ppi = await tx.peerPushPaymentIncoming.get(
- peerInc.peerPushPaymentIncomingId,
+ const ppi = await tx.peerPushCredit.get(
+ peerInc.peerPushCreditId,
);
if (!ppi) {
finished = true;
return;
}
- if (ppi.status !== PeerPushPaymentIncomingStatus.PendingWithdrawing) {
+ if (ppi.status !== PeerPushCreditStatus.PendingWithdrawing) {
finished = true;
return;
}
@@ -539,13 +539,13 @@ async function handlePendingWithdrawing(
return undefined;
}
switch (wg.status) {
- case WithdrawalGroupStatus.Finished:
+ case WithdrawalGroupStatus.Done:
finished = true;
- ppi.status = PeerPushPaymentIncomingStatus.Done;
+ ppi.status = PeerPushCreditStatus.Done;
break;
// FIXME: Also handle other final states!
}
- await tx.peerPushPaymentIncoming.put(ppi);
+ await tx.peerPushCredit.put(ppi);
const newTxState = computePeerPushCreditTransactionState(ppi);
return {
oldTxState,
@@ -563,14 +563,14 @@ async function handlePendingWithdrawing(
export async function processPeerPushCredit(
ws: InternalWalletState,
- peerPushPaymentIncomingId: string,
+ peerPushCreditId: string,
): Promise<TaskRunResult> {
let peerInc: PeerPushPaymentIncomingRecord | undefined;
let contractTerms: PeerContractTerms | undefined;
await ws.db
- .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming])
+ .mktx((x) => [x.contractTerms, x.peerPushCredit])
.runReadWrite(async (tx) => {
- peerInc = await tx.peerPushPaymentIncoming.get(peerPushPaymentIncomingId);
+ peerInc = await tx.peerPushCredit.get(peerPushCreditId);
if (!peerInc) {
return;
}
@@ -578,35 +578,35 @@ export async function processPeerPushCredit(
if (ctRec) {
contractTerms = ctRec.contractTermsRaw;
}
- await tx.peerPushPaymentIncoming.put(peerInc);
+ await tx.peerPushCredit.put(peerInc);
});
checkDbInvariant(!!contractTerms);
if (!peerInc) {
throw Error(
- `can't accept unknown incoming p2p push payment (${peerPushPaymentIncomingId})`,
+ `can't accept unknown incoming p2p push payment (${peerPushCreditId})`,
);
}
switch (peerInc.status) {
- case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: {
+ case PeerPushCreditStatus.PendingMergeKycRequired: {
if (!peerInc.kycInfo) {
throw Error("invalid state, kycInfo required");
}
return await longpollKycStatus(
ws,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
peerInc.exchangeBaseUrl,
peerInc.kycInfo,
"individual",
);
}
- case PeerPushPaymentIncomingStatus.PendingMerge:
+ case PeerPushCreditStatus.PendingMerge:
return handlePendingMerge(ws, peerInc, contractTerms);
- case PeerPushPaymentIncomingStatus.PendingWithdrawing:
+ case PeerPushCreditStatus.PendingWithdrawing:
return handlePendingWithdrawing(ws, peerInc);
default:
@@ -619,9 +619,9 @@ export async function confirmPeerPushCredit(
req: ConfirmPeerPushCreditRequest,
): Promise<AcceptPeerPushPaymentResponse> {
let peerInc: PeerPushPaymentIncomingRecord | undefined;
- let peerPushPaymentIncomingId: string;
- if (req.peerPushPaymentIncomingId) {
- peerPushPaymentIncomingId = req.peerPushPaymentIncomingId;
+ let peerPushCreditId: string;
+ if (req.peerPushCreditId) {
+ peerPushCreditId = req.peerPushCreditId;
} else if (req.transactionId) {
const parsedTx = parseTransactionIdentifier(req.transactionId);
if (!parsedTx) {
@@ -630,29 +630,29 @@ export async function confirmPeerPushCredit(
if (parsedTx.tag !== TransactionType.PeerPushCredit) {
throw Error("invalid transaction ID type");
}
- peerPushPaymentIncomingId = parsedTx.peerPushPaymentIncomingId;
+ peerPushCreditId = parsedTx.peerPushCreditId;
} else {
throw Error(
- "no transaction ID (or deprecated peerPushPaymentIncomingId) provided",
+ "no transaction ID (or deprecated peerPushCreditId) provided",
);
}
await ws.db
- .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming])
+ .mktx((x) => [x.contractTerms, x.peerPushCredit])
.runReadWrite(async (tx) => {
- peerInc = await tx.peerPushPaymentIncoming.get(peerPushPaymentIncomingId);
+ peerInc = await tx.peerPushCredit.get(peerPushCreditId);
if (!peerInc) {
return;
}
- if (peerInc.status === PeerPushPaymentIncomingStatus.DialogProposed) {
- peerInc.status = PeerPushPaymentIncomingStatus.PendingMerge;
+ if (peerInc.status === PeerPushCreditStatus.DialogProposed) {
+ peerInc.status = PeerPushCreditStatus.PendingMerge;
}
- await tx.peerPushPaymentIncoming.put(peerInc);
+ await tx.peerPushCredit.put(peerInc);
});
if (!peerInc) {
throw Error(
- `can't accept unknown incoming p2p push payment (${req.peerPushPaymentIncomingId})`,
+ `can't accept unknown incoming p2p push payment (${req.peerPushCreditId})`,
);
}
@@ -660,7 +660,7 @@ export async function confirmPeerPushCredit(
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
return {
@@ -670,48 +670,48 @@ export async function confirmPeerPushCredit(
export async function suspendPeerPushCreditTransaction(
ws: InternalWalletState,
- peerPushPaymentIncomingId: string,
+ peerPushCreditId: string,
) {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentIncoming])
+ .mktx((x) => [x.peerPushCredit])
.runReadWrite(async (tx) => {
- const pushCreditRec = await tx.peerPushPaymentIncoming.get(
- peerPushPaymentIncomingId,
+ const pushCreditRec = await tx.peerPushCredit.get(
+ peerPushCreditId,
);
if (!pushCreditRec) {
- logger.warn(`peer push credit ${peerPushPaymentIncomingId} not found`);
+ logger.warn(`peer push credit ${peerPushCreditId} not found`);
return;
}
- let newStatus: PeerPushPaymentIncomingStatus | undefined = undefined;
+ let newStatus: PeerPushCreditStatus | undefined = undefined;
switch (pushCreditRec.status) {
- case PeerPushPaymentIncomingStatus.DialogProposed:
- case PeerPushPaymentIncomingStatus.Done:
- case PeerPushPaymentIncomingStatus.SuspendedMerge:
- case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired:
- case PeerPushPaymentIncomingStatus.SuspendedWithdrawing:
+ case PeerPushCreditStatus.DialogProposed:
+ case PeerPushCreditStatus.Done:
+ case PeerPushCreditStatus.SuspendedMerge:
+ case PeerPushCreditStatus.SuspendedMergeKycRequired:
+ case PeerPushCreditStatus.SuspendedWithdrawing:
break;
- case PeerPushPaymentIncomingStatus.PendingMergeKycRequired:
- newStatus = PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired;
+ case PeerPushCreditStatus.PendingMergeKycRequired:
+ newStatus = PeerPushCreditStatus.SuspendedMergeKycRequired;
break;
- case PeerPushPaymentIncomingStatus.PendingMerge:
- newStatus = PeerPushPaymentIncomingStatus.SuspendedMerge;
+ case PeerPushCreditStatus.PendingMerge:
+ newStatus = PeerPushCreditStatus.SuspendedMerge;
break;
- case PeerPushPaymentIncomingStatus.PendingWithdrawing:
+ case PeerPushCreditStatus.PendingWithdrawing:
// FIXME: Suspend internal withdrawal transaction!
- newStatus = PeerPushPaymentIncomingStatus.SuspendedWithdrawing;
+ newStatus = PeerPushCreditStatus.SuspendedWithdrawing;
break;
- case PeerPushPaymentIncomingStatus.Aborted:
+ case PeerPushCreditStatus.Aborted:
break;
- case PeerPushPaymentIncomingStatus.Failed:
+ case PeerPushCreditStatus.Failed:
break;
default:
assertUnreachable(pushCreditRec.status);
@@ -720,7 +720,7 @@ export async function suspendPeerPushCreditTransaction(
const oldTxState = computePeerPushCreditTransactionState(pushCreditRec);
pushCreditRec.status = newStatus;
const newTxState = computePeerPushCreditTransactionState(pushCreditRec);
- await tx.peerPushPaymentIncoming.put(pushCreditRec);
+ await tx.peerPushCredit.put(pushCreditRec);
return {
oldTxState,
newTxState,
@@ -733,51 +733,51 @@ export async function suspendPeerPushCreditTransaction(
export async function abortPeerPushCreditTransaction(
ws: InternalWalletState,
- peerPushPaymentIncomingId: string,
+ peerPushCreditId: string,
) {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentIncoming])
+ .mktx((x) => [x.peerPushCredit])
.runReadWrite(async (tx) => {
- const pushCreditRec = await tx.peerPushPaymentIncoming.get(
- peerPushPaymentIncomingId,
+ const pushCreditRec = await tx.peerPushCredit.get(
+ peerPushCreditId,
);
if (!pushCreditRec) {
- logger.warn(`peer push credit ${peerPushPaymentIncomingId} not found`);
+ logger.warn(`peer push credit ${peerPushCreditId} not found`);
return;
}
- let newStatus: PeerPushPaymentIncomingStatus | undefined = undefined;
+ let newStatus: PeerPushCreditStatus | undefined = undefined;
switch (pushCreditRec.status) {
- case PeerPushPaymentIncomingStatus.DialogProposed:
- newStatus = PeerPushPaymentIncomingStatus.Aborted;
+ case PeerPushCreditStatus.DialogProposed:
+ newStatus = PeerPushCreditStatus.Aborted;
break;
- case PeerPushPaymentIncomingStatus.Done:
+ case PeerPushCreditStatus.Done:
break;
- case PeerPushPaymentIncomingStatus.SuspendedMerge:
- case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired:
- case PeerPushPaymentIncomingStatus.SuspendedWithdrawing:
- newStatus = PeerPushPaymentIncomingStatus.Aborted;
+ case PeerPushCreditStatus.SuspendedMerge:
+ case PeerPushCreditStatus.SuspendedMergeKycRequired:
+ case PeerPushCreditStatus.SuspendedWithdrawing:
+ newStatus = PeerPushCreditStatus.Aborted;
break;
- case PeerPushPaymentIncomingStatus.PendingMergeKycRequired:
- newStatus = PeerPushPaymentIncomingStatus.Aborted;
+ case PeerPushCreditStatus.PendingMergeKycRequired:
+ newStatus = PeerPushCreditStatus.Aborted;
break;
- case PeerPushPaymentIncomingStatus.PendingMerge:
- newStatus = PeerPushPaymentIncomingStatus.Aborted;
+ case PeerPushCreditStatus.PendingMerge:
+ newStatus = PeerPushCreditStatus.Aborted;
break;
- case PeerPushPaymentIncomingStatus.PendingWithdrawing:
- newStatus = PeerPushPaymentIncomingStatus.Aborted;
+ case PeerPushCreditStatus.PendingWithdrawing:
+ newStatus = PeerPushCreditStatus.Aborted;
break;
- case PeerPushPaymentIncomingStatus.Aborted:
+ case PeerPushCreditStatus.Aborted:
break;
- case PeerPushPaymentIncomingStatus.Failed:
+ case PeerPushCreditStatus.Failed:
break;
default:
assertUnreachable(pushCreditRec.status);
@@ -786,7 +786,7 @@ export async function abortPeerPushCreditTransaction(
const oldTxState = computePeerPushCreditTransactionState(pushCreditRec);
pushCreditRec.status = newStatus;
const newTxState = computePeerPushCreditTransactionState(pushCreditRec);
- await tx.peerPushPaymentIncoming.put(pushCreditRec);
+ await tx.peerPushCredit.put(pushCreditRec);
return {
oldTxState,
newTxState,
@@ -799,7 +799,7 @@ export async function abortPeerPushCreditTransaction(
export async function failPeerPushCreditTransaction(
ws: InternalWalletState,
- peerPushPaymentIncomingId: string,
+ peerPushCreditId: string,
) {
// We don't have any "aborting" states!
throw Error("can't run cancel-aborting on peer-push-credit transaction");
@@ -807,47 +807,47 @@ export async function failPeerPushCreditTransaction(
export async function resumePeerPushCreditTransaction(
ws: InternalWalletState,
- peerPushPaymentIncomingId: string,
+ peerPushCreditId: string,
) {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
const transactionId = constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentIncoming])
+ .mktx((x) => [x.peerPushCredit])
.runReadWrite(async (tx) => {
- const pushCreditRec = await tx.peerPushPaymentIncoming.get(
- peerPushPaymentIncomingId,
+ const pushCreditRec = await tx.peerPushCredit.get(
+ peerPushCreditId,
);
if (!pushCreditRec) {
- logger.warn(`peer push credit ${peerPushPaymentIncomingId} not found`);
+ logger.warn(`peer push credit ${peerPushCreditId} not found`);
return;
}
- let newStatus: PeerPushPaymentIncomingStatus | undefined = undefined;
+ let newStatus: PeerPushCreditStatus | undefined = undefined;
switch (pushCreditRec.status) {
- case PeerPushPaymentIncomingStatus.DialogProposed:
- case PeerPushPaymentIncomingStatus.Done:
- case PeerPushPaymentIncomingStatus.PendingMergeKycRequired:
- case PeerPushPaymentIncomingStatus.PendingMerge:
- case PeerPushPaymentIncomingStatus.PendingWithdrawing:
- case PeerPushPaymentIncomingStatus.SuspendedMerge:
- newStatus = PeerPushPaymentIncomingStatus.PendingMerge;
+ case PeerPushCreditStatus.DialogProposed:
+ case PeerPushCreditStatus.Done:
+ case PeerPushCreditStatus.PendingMergeKycRequired:
+ case PeerPushCreditStatus.PendingMerge:
+ case PeerPushCreditStatus.PendingWithdrawing:
+ case PeerPushCreditStatus.SuspendedMerge:
+ newStatus = PeerPushCreditStatus.PendingMerge;
break;
- case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired:
- newStatus = PeerPushPaymentIncomingStatus.PendingMergeKycRequired;
+ case PeerPushCreditStatus.SuspendedMergeKycRequired:
+ newStatus = PeerPushCreditStatus.PendingMergeKycRequired;
break;
- case PeerPushPaymentIncomingStatus.SuspendedWithdrawing:
+ case PeerPushCreditStatus.SuspendedWithdrawing:
// FIXME: resume underlying "internal-withdrawal" transaction.
- newStatus = PeerPushPaymentIncomingStatus.PendingWithdrawing;
+ newStatus = PeerPushCreditStatus.PendingWithdrawing;
break;
- case PeerPushPaymentIncomingStatus.Aborted:
+ case PeerPushCreditStatus.Aborted:
break;
- case PeerPushPaymentIncomingStatus.Failed:
+ case PeerPushCreditStatus.Failed:
break;
default:
assertUnreachable(pushCreditRec.status);
@@ -856,7 +856,7 @@ export async function resumePeerPushCreditTransaction(
const oldTxState = computePeerPushCreditTransactionState(pushCreditRec);
pushCreditRec.status = newStatus;
const newTxState = computePeerPushCreditTransactionState(pushCreditRec);
- await tx.peerPushPaymentIncoming.put(pushCreditRec);
+ await tx.peerPushCredit.put(pushCreditRec);
return {
oldTxState,
newTxState,
@@ -872,50 +872,50 @@ export function computePeerPushCreditTransactionState(
pushCreditRecord: PeerPushPaymentIncomingRecord,
): TransactionState {
switch (pushCreditRecord.status) {
- case PeerPushPaymentIncomingStatus.DialogProposed:
+ case PeerPushCreditStatus.DialogProposed:
return {
major: TransactionMajorState.Dialog,
minor: TransactionMinorState.Proposed,
};
- case PeerPushPaymentIncomingStatus.PendingMerge:
+ case PeerPushCreditStatus.PendingMerge:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.Merge,
};
- case PeerPushPaymentIncomingStatus.Done:
+ case PeerPushCreditStatus.Done:
return {
major: TransactionMajorState.Done,
};
- case PeerPushPaymentIncomingStatus.PendingMergeKycRequired:
+ case PeerPushCreditStatus.PendingMergeKycRequired:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.KycRequired,
};
- case PeerPushPaymentIncomingStatus.PendingWithdrawing:
+ case PeerPushCreditStatus.PendingWithdrawing:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.Withdraw,
};
- case PeerPushPaymentIncomingStatus.SuspendedMerge:
+ case PeerPushCreditStatus.SuspendedMerge:
return {
major: TransactionMajorState.Suspended,
minor: TransactionMinorState.Merge,
};
- case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired:
+ case PeerPushCreditStatus.SuspendedMergeKycRequired:
return {
major: TransactionMajorState.Suspended,
minor: TransactionMinorState.MergeKycRequired,
};
- case PeerPushPaymentIncomingStatus.SuspendedWithdrawing:
+ case PeerPushCreditStatus.SuspendedWithdrawing:
return {
major: TransactionMajorState.Suspended,
minor: TransactionMinorState.Withdraw,
};
- case PeerPushPaymentIncomingStatus.Aborted:
+ case PeerPushCreditStatus.Aborted:
return {
major: TransactionMajorState.Aborted,
};
- case PeerPushPaymentIncomingStatus.Failed:
+ case PeerPushCreditStatus.Failed:
return {
major: TransactionMajorState.Failed,
};
@@ -928,25 +928,25 @@ export function computePeerPushCreditTransactionActions(
pushCreditRecord: PeerPushPaymentIncomingRecord,
): TransactionAction[] {
switch (pushCreditRecord.status) {
- case PeerPushPaymentIncomingStatus.DialogProposed:
+ case PeerPushCreditStatus.DialogProposed:
return [TransactionAction.Delete];
- case PeerPushPaymentIncomingStatus.PendingMerge:
+ case PeerPushCreditStatus.PendingMerge:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPushPaymentIncomingStatus.Done:
+ case PeerPushCreditStatus.Done:
return [TransactionAction.Delete];
- case PeerPushPaymentIncomingStatus.PendingMergeKycRequired:
+ case PeerPushCreditStatus.PendingMergeKycRequired:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPushPaymentIncomingStatus.PendingWithdrawing:
+ case PeerPushCreditStatus.PendingWithdrawing:
return [TransactionAction.Suspend, TransactionAction.Fail];
- case PeerPushPaymentIncomingStatus.SuspendedMerge:
+ case PeerPushCreditStatus.SuspendedMerge:
return [TransactionAction.Resume, TransactionAction.Abort];
- case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired:
+ case PeerPushCreditStatus.SuspendedMergeKycRequired:
return [TransactionAction.Resume, TransactionAction.Abort];
- case PeerPushPaymentIncomingStatus.SuspendedWithdrawing:
+ case PeerPushCreditStatus.SuspendedWithdrawing:
return [TransactionAction.Resume, TransactionAction.Fail];
- case PeerPushPaymentIncomingStatus.Aborted:
+ case PeerPushCreditStatus.Aborted:
return [TransactionAction.Delete];
- case PeerPushPaymentIncomingStatus.Failed:
+ case PeerPushCreditStatus.Failed:
return [TransactionAction.Delete];
default:
assertUnreachable(pushCreditRecord.status);
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
index 2349e5c4a..a2e7a6891 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
@@ -51,8 +51,8 @@ import {
} from "@gnu-taler/taler-util/http";
import { EncryptContractRequest } from "../crypto/cryptoTypes.js";
import {
- PeerPushPaymentInitiationRecord,
- PeerPushPaymentInitiationStatus,
+ PeerPushDebitRecord,
+ PeerPushDebitStatus,
RefreshOperationStatus,
createRefreshGroup,
} from "../index.js";
@@ -107,7 +107,7 @@ export async function checkPeerPushDebit(
async function handlePurseCreationConflict(
ws: InternalWalletState,
- peerPushInitiation: PeerPushPaymentInitiationRecord,
+ peerPushInitiation: PeerPushDebitRecord,
resp: HttpResponse,
): Promise<TaskRunResult> {
const pursePub = peerPushInitiation.pursePub;
@@ -152,17 +152,17 @@ async function handlePurseCreationConflict(
}
await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations])
+ .mktx((x) => [x.peerPushDebit])
.runReadWrite(async (tx) => {
- const myPpi = await tx.peerPushPaymentInitiations.get(
+ const myPpi = await tx.peerPushDebit.get(
peerPushInitiation.pursePub,
);
if (!myPpi) {
return;
}
switch (myPpi.status) {
- case PeerPushPaymentInitiationStatus.PendingCreatePurse:
- case PeerPushPaymentInitiationStatus.SuspendedCreatePurse: {
+ case PeerPushDebitStatus.PendingCreatePurse:
+ case PeerPushDebitStatus.SuspendedCreatePurse: {
const sel = coinSelRes.result;
myPpi.coinSel = {
coinPubs: sel.coins.map((x) => x.coinPub),
@@ -173,14 +173,14 @@ async function handlePurseCreationConflict(
default:
return;
}
- await tx.peerPushPaymentInitiations.put(myPpi);
+ await tx.peerPushDebit.put(myPpi);
});
return TaskRunResult.finished();
}
async function processPeerPushDebitCreateReserve(
ws: InternalWalletState,
- peerPushInitiation: PeerPushPaymentInitiationRecord,
+ peerPushInitiation: PeerPushDebitRecord,
): Promise<TaskRunResult> {
logger.info("processing peer-push-debit pending(create-reserve)");
const pursePub = peerPushInitiation.pursePub;
@@ -284,8 +284,8 @@ async function processPeerPushDebitCreateReserve(
}
await transitionPeerPushDebitTransaction(ws, pursePub, {
- stFrom: PeerPushPaymentInitiationStatus.PendingCreatePurse,
- stTo: PeerPushPaymentInitiationStatus.PendingReady,
+ stFrom: PeerPushDebitStatus.PendingCreatePurse,
+ stTo: PeerPushDebitStatus.PendingReady,
});
return TaskRunResult.finished();
@@ -293,7 +293,7 @@ async function processPeerPushDebitCreateReserve(
async function processPeerPushDebitAbortingDeletePurse(
ws: InternalWalletState,
- peerPushInitiation: PeerPushPaymentInitiationRecord,
+ peerPushInitiation: PeerPushDebitRecord,
): Promise<TaskRunResult> {
const { pursePub, pursePriv } = peerPushInitiation;
const transactionId = constructTransactionIdentifier({
@@ -318,19 +318,19 @@ async function processPeerPushDebitAbortingDeletePurse(
const transitionInfo = await ws.db
.mktx((x) => [
- x.peerPushPaymentInitiations,
+ x.peerPushDebit,
x.refreshGroups,
x.denominations,
x.coinAvailability,
x.coins,
])
.runReadWrite(async (tx) => {
- const ppiRec = await tx.peerPushPaymentInitiations.get(pursePub);
+ const ppiRec = await tx.peerPushDebit.get(pursePub);
if (!ppiRec) {
return undefined;
}
if (
- ppiRec.status !== PeerPushPaymentInitiationStatus.AbortingDeletePurse
+ ppiRec.status !== PeerPushDebitStatus.AbortingDeletePurse
) {
return undefined;
}
@@ -352,9 +352,9 @@ async function processPeerPushDebitAbortingDeletePurse(
coinPubs,
RefreshReason.AbortPeerPushDebit,
);
- ppiRec.status = PeerPushPaymentInitiationStatus.AbortingRefresh;
+ ppiRec.status = PeerPushDebitStatus.AbortingRefresh;
ppiRec.abortRefreshGroupId = refresh.refreshGroupId;
- await tx.peerPushPaymentInitiations.put(ppiRec);
+ await tx.peerPushDebit.put(ppiRec);
const newTxState = computePeerPushDebitTransactionState(ppiRec);
return {
oldTxState,
@@ -367,8 +367,8 @@ async function processPeerPushDebitAbortingDeletePurse(
}
interface SimpleTransition {
- stFrom: PeerPushPaymentInitiationStatus;
- stTo: PeerPushPaymentInitiationStatus;
+ stFrom: PeerPushDebitStatus;
+ stTo: PeerPushDebitStatus;
}
async function transitionPeerPushDebitTransaction(
@@ -381,9 +381,9 @@ async function transitionPeerPushDebitTransaction(
pursePub,
});
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations])
+ .mktx((x) => [x.peerPushDebit])
.runReadWrite(async (tx) => {
- const ppiRec = await tx.peerPushPaymentInitiations.get(pursePub);
+ const ppiRec = await tx.peerPushDebit.get(pursePub);
if (!ppiRec) {
return undefined;
}
@@ -392,7 +392,7 @@ async function transitionPeerPushDebitTransaction(
}
const oldTxState = computePeerPushDebitTransactionState(ppiRec);
ppiRec.status = transitionSpec.stTo;
- await tx.peerPushPaymentInitiations.put(ppiRec);
+ await tx.peerPushDebit.put(ppiRec);
const newTxState = computePeerPushDebitTransactionState(ppiRec);
return {
oldTxState,
@@ -404,7 +404,7 @@ async function transitionPeerPushDebitTransaction(
async function processPeerPushDebitAbortingRefresh(
ws: InternalWalletState,
- peerPushInitiation: PeerPushPaymentInitiationRecord,
+ peerPushInitiation: PeerPushDebitRecord,
): Promise<TaskRunResult> {
const pursePub = peerPushInitiation.pursePub;
const abortRefreshGroupId = peerPushInitiation.abortRefreshGroupId;
@@ -414,33 +414,33 @@ async function processPeerPushDebitAbortingRefresh(
pursePub: peerPushInitiation.pursePub,
});
const transitionInfo = await ws.db
- .mktx((x) => [x.refreshGroups, x.peerPushPaymentInitiations])
+ .mktx((x) => [x.refreshGroups, x.peerPushDebit])
.runReadWrite(async (tx) => {
const refreshGroup = await tx.refreshGroups.get(abortRefreshGroupId);
- let newOpState: PeerPushPaymentInitiationStatus | undefined;
+ let newOpState: PeerPushDebitStatus | undefined;
if (!refreshGroup) {
// Maybe it got manually deleted? Means that we should
// just go into failed.
logger.warn("no aborting refresh group found for deposit group");
- newOpState = PeerPushPaymentInitiationStatus.Failed;
+ newOpState = PeerPushDebitStatus.Failed;
} else {
if (refreshGroup.operationStatus === RefreshOperationStatus.Finished) {
- newOpState = PeerPushPaymentInitiationStatus.Aborted;
+ newOpState = PeerPushDebitStatus.Aborted;
} else if (
refreshGroup.operationStatus === RefreshOperationStatus.Failed
) {
- newOpState = PeerPushPaymentInitiationStatus.Failed;
+ newOpState = PeerPushDebitStatus.Failed;
}
}
if (newOpState) {
- const newDg = await tx.peerPushPaymentInitiations.get(pursePub);
+ const newDg = await tx.peerPushDebit.get(pursePub);
if (!newDg) {
return;
}
const oldTxState = computePeerPushDebitTransactionState(newDg);
newDg.status = newOpState;
const newTxState = computePeerPushDebitTransactionState(newDg);
- await tx.peerPushPaymentInitiations.put(newDg);
+ await tx.peerPushDebit.put(newDg);
return { oldTxState, newTxState };
}
return undefined;
@@ -455,7 +455,7 @@ async function processPeerPushDebitAbortingRefresh(
*/
async function processPeerPushDebitReady(
ws: InternalWalletState,
- peerPushInitiation: PeerPushPaymentInitiationRecord,
+ peerPushInitiation: PeerPushDebitRecord,
): Promise<TaskRunResult> {
logger.info("processing peer-push-debit pending(ready)");
const pursePub = peerPushInitiation.pursePub;
@@ -488,8 +488,8 @@ async function processPeerPushDebitReady(
ws,
peerPushInitiation.pursePub,
{
- stFrom: PeerPushPaymentInitiationStatus.PendingReady,
- stTo: PeerPushPaymentInitiationStatus.Done,
+ stFrom: PeerPushDebitStatus.PendingReady,
+ stTo: PeerPushDebitStatus.Done,
},
);
return {
@@ -501,8 +501,8 @@ async function processPeerPushDebitReady(
ws,
peerPushInitiation.pursePub,
{
- stFrom: PeerPushPaymentInitiationStatus.PendingReady,
- stTo: PeerPushPaymentInitiationStatus.Expired,
+ stFrom: PeerPushDebitStatus.PendingReady,
+ stTo: PeerPushDebitStatus.Expired,
},
);
return {
@@ -528,9 +528,9 @@ export async function processPeerPushDebit(
pursePub: string,
): Promise<TaskRunResult> {
const peerPushInitiation = await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations])
+ .mktx((x) => [x.peerPushDebit])
.runReadOnly(async (tx) => {
- return tx.peerPushPaymentInitiations.get(pursePub);
+ return tx.peerPushDebit.get(pursePub);
});
if (!peerPushInitiation) {
throw Error("peer push payment not found");
@@ -550,13 +550,13 @@ export async function processPeerPushDebit(
}
switch (peerPushInitiation.status) {
- case PeerPushPaymentInitiationStatus.PendingCreatePurse:
+ case PeerPushDebitStatus.PendingCreatePurse:
return processPeerPushDebitCreateReserve(ws, peerPushInitiation);
- case PeerPushPaymentInitiationStatus.PendingReady:
+ case PeerPushDebitStatus.PendingReady:
return processPeerPushDebitReady(ws, peerPushInitiation);
- case PeerPushPaymentInitiationStatus.AbortingDeletePurse:
+ case PeerPushDebitStatus.AbortingDeletePurse:
return processPeerPushDebitAbortingDeletePurse(ws, peerPushInitiation);
- case PeerPushPaymentInitiationStatus.AbortingRefresh:
+ case PeerPushDebitStatus.AbortingRefresh:
return processPeerPushDebitAbortingRefresh(ws, peerPushInitiation);
default: {
const txState = computePeerPushDebitTransactionState(peerPushInitiation);
@@ -626,7 +626,7 @@ export async function initiatePeerPushDebit(
x.coinAvailability,
x.denominations,
x.refreshGroups,
- x.peerPushPaymentInitiations,
+ x.peerPushDebit,
])
.runReadWrite(async (tx) => {
// FIXME: Instead of directly doing a spendCoin here,
@@ -645,7 +645,7 @@ export async function initiatePeerPushDebit(
refreshReason: RefreshReason.PayPeerPush,
});
- const ppi: PeerPushPaymentInitiationRecord = {
+ const ppi: PeerPushDebitRecord = {
amount: Amounts.stringify(instructedAmount),
contractPriv: contractKeyPair.priv,
contractPub: contractKeyPair.pub,
@@ -657,7 +657,7 @@ export async function initiatePeerPushDebit(
pursePriv: pursePair.priv,
pursePub: pursePair.pub,
timestampCreated: TalerPreciseTimestamp.now(),
- status: PeerPushPaymentInitiationStatus.PendingCreatePurse,
+ status: PeerPushDebitStatus.PendingCreatePurse,
contractTerms: contractTerms,
contractEncNonce,
coinSel: {
@@ -667,7 +667,7 @@ export async function initiatePeerPushDebit(
totalCost: Amounts.stringify(totalAmount),
};
- await tx.peerPushPaymentInitiations.add(ppi);
+ await tx.peerPushDebit.add(ppi);
await tx.contractTerms.put({
h: hContractTerms,
@@ -701,32 +701,32 @@ export async function initiatePeerPushDebit(
}
export function computePeerPushDebitTransactionActions(
- ppiRecord: PeerPushPaymentInitiationRecord,
+ ppiRecord: PeerPushDebitRecord,
): TransactionAction[] {
switch (ppiRecord.status) {
- case PeerPushPaymentInitiationStatus.PendingCreatePurse:
+ case PeerPushDebitStatus.PendingCreatePurse:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPushPaymentInitiationStatus.PendingReady:
+ case PeerPushDebitStatus.PendingReady:
return [TransactionAction.Abort, TransactionAction.Suspend];
- case PeerPushPaymentInitiationStatus.Aborted:
+ case PeerPushDebitStatus.Aborted:
return [TransactionAction.Delete];
- case PeerPushPaymentInitiationStatus.AbortingDeletePurse:
+ case PeerPushDebitStatus.AbortingDeletePurse:
return [TransactionAction.Suspend, TransactionAction.Fail];
- case PeerPushPaymentInitiationStatus.AbortingRefresh:
+ case PeerPushDebitStatus.AbortingRefresh:
return [TransactionAction.Suspend, TransactionAction.Fail];
- case PeerPushPaymentInitiationStatus.SuspendedAbortingDeletePurse:
+ case PeerPushDebitStatus.SuspendedAbortingDeletePurse:
return [TransactionAction.Resume, TransactionAction.Fail];
- case PeerPushPaymentInitiationStatus.SuspendedAbortingRefresh:
+ case PeerPushDebitStatus.SuspendedAbortingRefresh:
return [TransactionAction.Resume, TransactionAction.Fail];
- case PeerPushPaymentInitiationStatus.SuspendedCreatePurse:
+ case PeerPushDebitStatus.SuspendedCreatePurse:
return [TransactionAction.Resume, TransactionAction.Abort];
- case PeerPushPaymentInitiationStatus.SuspendedReady:
+ case PeerPushDebitStatus.SuspendedReady:
return [TransactionAction.Suspend, TransactionAction.Abort];
- case PeerPushPaymentInitiationStatus.Done:
+ case PeerPushDebitStatus.Done:
return [TransactionAction.Delete];
- case PeerPushPaymentInitiationStatus.Expired:
+ case PeerPushDebitStatus.Expired:
return [TransactionAction.Delete];
- case PeerPushPaymentInitiationStatus.Failed:
+ case PeerPushDebitStatus.Failed:
return [TransactionAction.Delete];
}
}
@@ -745,32 +745,32 @@ export async function abortPeerPushDebitTransaction(
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations])
+ .mktx((x) => [x.peerPushDebit])
.runReadWrite(async (tx) => {
- const pushDebitRec = await tx.peerPushPaymentInitiations.get(pursePub);
+ const pushDebitRec = await tx.peerPushDebit.get(pursePub);
if (!pushDebitRec) {
logger.warn(`peer push debit ${pursePub} not found`);
return;
}
- let newStatus: PeerPushPaymentInitiationStatus | undefined = undefined;
+ let newStatus: PeerPushDebitStatus | undefined = undefined;
switch (pushDebitRec.status) {
- case PeerPushPaymentInitiationStatus.PendingReady:
- case PeerPushPaymentInitiationStatus.SuspendedReady:
- newStatus = PeerPushPaymentInitiationStatus.AbortingDeletePurse;
+ case PeerPushDebitStatus.PendingReady:
+ case PeerPushDebitStatus.SuspendedReady:
+ newStatus = PeerPushDebitStatus.AbortingDeletePurse;
break;
- case PeerPushPaymentInitiationStatus.SuspendedCreatePurse:
- case PeerPushPaymentInitiationStatus.PendingCreatePurse:
+ case PeerPushDebitStatus.SuspendedCreatePurse:
+ case PeerPushDebitStatus.PendingCreatePurse:
// Network request might already be in-flight!
- newStatus = PeerPushPaymentInitiationStatus.AbortingDeletePurse;
+ newStatus = PeerPushDebitStatus.AbortingDeletePurse;
break;
- case PeerPushPaymentInitiationStatus.SuspendedAbortingRefresh:
- case PeerPushPaymentInitiationStatus.SuspendedAbortingDeletePurse:
- case PeerPushPaymentInitiationStatus.AbortingRefresh:
- case PeerPushPaymentInitiationStatus.Done:
- case PeerPushPaymentInitiationStatus.AbortingDeletePurse:
- case PeerPushPaymentInitiationStatus.Aborted:
- case PeerPushPaymentInitiationStatus.Expired:
- case PeerPushPaymentInitiationStatus.Failed:
+ case PeerPushDebitStatus.SuspendedAbortingRefresh:
+ case PeerPushDebitStatus.SuspendedAbortingDeletePurse:
+ case PeerPushDebitStatus.AbortingRefresh:
+ case PeerPushDebitStatus.Done:
+ case PeerPushDebitStatus.AbortingDeletePurse:
+ case PeerPushDebitStatus.Aborted:
+ case PeerPushDebitStatus.Expired:
+ case PeerPushDebitStatus.Failed:
// Do nothing
break;
default:
@@ -780,7 +780,7 @@ export async function abortPeerPushDebitTransaction(
const oldTxState = computePeerPushDebitTransactionState(pushDebitRec);
pushDebitRec.status = newStatus;
const newTxState = computePeerPushDebitTransactionState(pushDebitRec);
- await tx.peerPushPaymentInitiations.put(pushDebitRec);
+ await tx.peerPushDebit.put(pushDebitRec);
return {
oldTxState,
newTxState,
@@ -805,32 +805,32 @@ export async function failPeerPushDebitTransaction(
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations])
+ .mktx((x) => [x.peerPushDebit])
.runReadWrite(async (tx) => {
- const pushDebitRec = await tx.peerPushPaymentInitiations.get(pursePub);
+ const pushDebitRec = await tx.peerPushDebit.get(pursePub);
if (!pushDebitRec) {
logger.warn(`peer push debit ${pursePub} not found`);
return;
}
- let newStatus: PeerPushPaymentInitiationStatus | undefined = undefined;
+ let newStatus: PeerPushDebitStatus | undefined = undefined;
switch (pushDebitRec.status) {
- case PeerPushPaymentInitiationStatus.AbortingRefresh:
- case PeerPushPaymentInitiationStatus.SuspendedAbortingRefresh:
+ case PeerPushDebitStatus.AbortingRefresh:
+ case PeerPushDebitStatus.SuspendedAbortingRefresh:
// FIXME: What to do about the refresh group?
- newStatus = PeerPushPaymentInitiationStatus.Failed;
+ newStatus = PeerPushDebitStatus.Failed;
break;
- case PeerPushPaymentInitiationStatus.AbortingDeletePurse:
- case PeerPushPaymentInitiationStatus.SuspendedAbortingDeletePurse:
- case PeerPushPaymentInitiationStatus.PendingReady:
- case PeerPushPaymentInitiationStatus.SuspendedReady:
- case PeerPushPaymentInitiationStatus.SuspendedCreatePurse:
- case PeerPushPaymentInitiationStatus.PendingCreatePurse:
- newStatus = PeerPushPaymentInitiationStatus.Failed;
+ case PeerPushDebitStatus.AbortingDeletePurse:
+ case PeerPushDebitStatus.SuspendedAbortingDeletePurse:
+ case PeerPushDebitStatus.PendingReady:
+ case PeerPushDebitStatus.SuspendedReady:
+ case PeerPushDebitStatus.SuspendedCreatePurse:
+ case PeerPushDebitStatus.PendingCreatePurse:
+ newStatus = PeerPushDebitStatus.Failed;
break;
- case PeerPushPaymentInitiationStatus.Done:
- case PeerPushPaymentInitiationStatus.Aborted:
- case PeerPushPaymentInitiationStatus.Failed:
- case PeerPushPaymentInitiationStatus.Expired:
+ case PeerPushDebitStatus.Done:
+ case PeerPushDebitStatus.Aborted:
+ case PeerPushDebitStatus.Failed:
+ case PeerPushDebitStatus.Expired:
// Do nothing
break;
default:
@@ -840,7 +840,7 @@ export async function failPeerPushDebitTransaction(
const oldTxState = computePeerPushDebitTransactionState(pushDebitRec);
pushDebitRec.status = newStatus;
const newTxState = computePeerPushDebitTransactionState(pushDebitRec);
- await tx.peerPushPaymentInitiations.put(pushDebitRec);
+ await tx.peerPushDebit.put(pushDebitRec);
return {
oldTxState,
newTxState,
@@ -865,36 +865,36 @@ export async function suspendPeerPushDebitTransaction(
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations])
+ .mktx((x) => [x.peerPushDebit])
.runReadWrite(async (tx) => {
- const pushDebitRec = await tx.peerPushPaymentInitiations.get(pursePub);
+ const pushDebitRec = await tx.peerPushDebit.get(pursePub);
if (!pushDebitRec) {
logger.warn(`peer push debit ${pursePub} not found`);
return;
}
- let newStatus: PeerPushPaymentInitiationStatus | undefined = undefined;
+ let newStatus: PeerPushDebitStatus | undefined = undefined;
switch (pushDebitRec.status) {
- case PeerPushPaymentInitiationStatus.PendingCreatePurse:
- newStatus = PeerPushPaymentInitiationStatus.SuspendedCreatePurse;
+ case PeerPushDebitStatus.PendingCreatePurse:
+ newStatus = PeerPushDebitStatus.SuspendedCreatePurse;
break;
- case PeerPushPaymentInitiationStatus.AbortingRefresh:
- newStatus = PeerPushPaymentInitiationStatus.SuspendedAbortingRefresh;
+ case PeerPushDebitStatus.AbortingRefresh:
+ newStatus = PeerPushDebitStatus.SuspendedAbortingRefresh;
break;
- case PeerPushPaymentInitiationStatus.AbortingDeletePurse:
+ case PeerPushDebitStatus.AbortingDeletePurse:
newStatus =
- PeerPushPaymentInitiationStatus.SuspendedAbortingDeletePurse;
+ PeerPushDebitStatus.SuspendedAbortingDeletePurse;
break;
- case PeerPushPaymentInitiationStatus.PendingReady:
- newStatus = PeerPushPaymentInitiationStatus.SuspendedReady;
+ case PeerPushDebitStatus.PendingReady:
+ newStatus = PeerPushDebitStatus.SuspendedReady;
break;
- case PeerPushPaymentInitiationStatus.SuspendedAbortingDeletePurse:
- case PeerPushPaymentInitiationStatus.SuspendedAbortingRefresh:
- case PeerPushPaymentInitiationStatus.SuspendedReady:
- case PeerPushPaymentInitiationStatus.SuspendedCreatePurse:
- case PeerPushPaymentInitiationStatus.Done:
- case PeerPushPaymentInitiationStatus.Aborted:
- case PeerPushPaymentInitiationStatus.Failed:
- case PeerPushPaymentInitiationStatus.Expired:
+ case PeerPushDebitStatus.SuspendedAbortingDeletePurse:
+ case PeerPushDebitStatus.SuspendedAbortingRefresh:
+ case PeerPushDebitStatus.SuspendedReady:
+ case PeerPushDebitStatus.SuspendedCreatePurse:
+ case PeerPushDebitStatus.Done:
+ case PeerPushDebitStatus.Aborted:
+ case PeerPushDebitStatus.Failed:
+ case PeerPushDebitStatus.Expired:
// Do nothing
break;
default:
@@ -904,7 +904,7 @@ export async function suspendPeerPushDebitTransaction(
const oldTxState = computePeerPushDebitTransactionState(pushDebitRec);
pushDebitRec.status = newStatus;
const newTxState = computePeerPushDebitTransactionState(pushDebitRec);
- await tx.peerPushPaymentInitiations.put(pushDebitRec);
+ await tx.peerPushDebit.put(pushDebitRec);
return {
oldTxState,
newTxState,
@@ -929,35 +929,35 @@ export async function resumePeerPushDebitTransaction(
});
stopLongpolling(ws, taskId);
const transitionInfo = await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations])
+ .mktx((x) => [x.peerPushDebit])
.runReadWrite(async (tx) => {
- const pushDebitRec = await tx.peerPushPaymentInitiations.get(pursePub);
+ const pushDebitRec = await tx.peerPushDebit.get(pursePub);
if (!pushDebitRec) {
logger.warn(`peer push debit ${pursePub} not found`);
return;
}
- let newStatus: PeerPushPaymentInitiationStatus | undefined = undefined;
+ let newStatus: PeerPushDebitStatus | undefined = undefined;
switch (pushDebitRec.status) {
- case PeerPushPaymentInitiationStatus.SuspendedAbortingDeletePurse:
- newStatus = PeerPushPaymentInitiationStatus.AbortingDeletePurse;
+ case PeerPushDebitStatus.SuspendedAbortingDeletePurse:
+ newStatus = PeerPushDebitStatus.AbortingDeletePurse;
break;
- case PeerPushPaymentInitiationStatus.SuspendedAbortingRefresh:
- newStatus = PeerPushPaymentInitiationStatus.AbortingRefresh;
+ case PeerPushDebitStatus.SuspendedAbortingRefresh:
+ newStatus = PeerPushDebitStatus.AbortingRefresh;
break;
- case PeerPushPaymentInitiationStatus.SuspendedReady:
- newStatus = PeerPushPaymentInitiationStatus.PendingReady;
+ case PeerPushDebitStatus.SuspendedReady:
+ newStatus = PeerPushDebitStatus.PendingReady;
break;
- case PeerPushPaymentInitiationStatus.SuspendedCreatePurse:
- newStatus = PeerPushPaymentInitiationStatus.PendingCreatePurse;
+ case PeerPushDebitStatus.SuspendedCreatePurse:
+ newStatus = PeerPushDebitStatus.PendingCreatePurse;
break;
- case PeerPushPaymentInitiationStatus.PendingCreatePurse:
- case PeerPushPaymentInitiationStatus.AbortingRefresh:
- case PeerPushPaymentInitiationStatus.AbortingDeletePurse:
- case PeerPushPaymentInitiationStatus.PendingReady:
- case PeerPushPaymentInitiationStatus.Done:
- case PeerPushPaymentInitiationStatus.Aborted:
- case PeerPushPaymentInitiationStatus.Failed:
- case PeerPushPaymentInitiationStatus.Expired:
+ case PeerPushDebitStatus.PendingCreatePurse:
+ case PeerPushDebitStatus.AbortingRefresh:
+ case PeerPushDebitStatus.AbortingDeletePurse:
+ case PeerPushDebitStatus.PendingReady:
+ case PeerPushDebitStatus.Done:
+ case PeerPushDebitStatus.Aborted:
+ case PeerPushDebitStatus.Failed:
+ case PeerPushDebitStatus.Expired:
// Do nothing
break;
default:
@@ -967,7 +967,7 @@ export async function resumePeerPushDebitTransaction(
const oldTxState = computePeerPushDebitTransactionState(pushDebitRec);
pushDebitRec.status = newStatus;
const newTxState = computePeerPushDebitTransactionState(pushDebitRec);
- await tx.peerPushPaymentInitiations.put(pushDebitRec);
+ await tx.peerPushDebit.put(pushDebitRec);
return {
oldTxState,
newTxState,
@@ -980,62 +980,62 @@ export async function resumePeerPushDebitTransaction(
}
export function computePeerPushDebitTransactionState(
- ppiRecord: PeerPushPaymentInitiationRecord,
+ ppiRecord: PeerPushDebitRecord,
): TransactionState {
switch (ppiRecord.status) {
- case PeerPushPaymentInitiationStatus.PendingCreatePurse:
+ case PeerPushDebitStatus.PendingCreatePurse:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.CreatePurse,
};
- case PeerPushPaymentInitiationStatus.PendingReady:
+ case PeerPushDebitStatus.PendingReady:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.Ready,
};
- case PeerPushPaymentInitiationStatus.Aborted:
+ case PeerPushDebitStatus.Aborted:
return {
major: TransactionMajorState.Aborted,
};
- case PeerPushPaymentInitiationStatus.AbortingDeletePurse:
+ case PeerPushDebitStatus.AbortingDeletePurse:
return {
major: TransactionMajorState.Aborting,
minor: TransactionMinorState.DeletePurse,
};
- case PeerPushPaymentInitiationStatus.AbortingRefresh:
+ case PeerPushDebitStatus.AbortingRefresh:
return {
major: TransactionMajorState.Aborting,
minor: TransactionMinorState.Refresh,
};
- case PeerPushPaymentInitiationStatus.SuspendedAbortingDeletePurse:
+ case PeerPushDebitStatus.SuspendedAbortingDeletePurse:
return {
major: TransactionMajorState.SuspendedAborting,
minor: TransactionMinorState.DeletePurse,
};
- case PeerPushPaymentInitiationStatus.SuspendedAbortingRefresh:
+ case PeerPushDebitStatus.SuspendedAbortingRefresh:
return {
major: TransactionMajorState.SuspendedAborting,
minor: TransactionMinorState.Refresh,
};
- case PeerPushPaymentInitiationStatus.SuspendedCreatePurse:
+ case PeerPushDebitStatus.SuspendedCreatePurse:
return {
major: TransactionMajorState.Suspended,
minor: TransactionMinorState.CreatePurse,
};
- case PeerPushPaymentInitiationStatus.SuspendedReady:
+ case PeerPushDebitStatus.SuspendedReady:
return {
major: TransactionMajorState.Suspended,
minor: TransactionMinorState.Ready,
};
- case PeerPushPaymentInitiationStatus.Done:
+ case PeerPushDebitStatus.Done:
return {
major: TransactionMajorState.Done,
};
- case PeerPushPaymentInitiationStatus.Failed:
+ case PeerPushDebitStatus.Failed:
return {
major: TransactionMajorState.Failed,
};
- case PeerPushPaymentInitiationStatus.Expired:
+ case PeerPushDebitStatus.Expired:
return {
major: TransactionMajorState.Expired,
};
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts
index e37e45c16..207e6ffda 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,14 @@ import {
DepositGroupRecord,
RewardRecord,
PurchaseRecord,
- PeerPullPaymentInitiationRecord,
+ PeerPullCreditRecord,
PeerPullPaymentIncomingRecord,
- PeerPushPaymentInitiationRecord,
+ PeerPushDebitRecord,
PeerPushPaymentIncomingRecord,
RefundGroupRecord,
RefundGroupStatus,
ExchangeEntryDbUpdateStatus,
+ RefreshOperationStatus,
} from "../db.js";
import {
PendingOperationsResponse,
@@ -136,8 +136,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 {
@@ -470,28 +470,28 @@ 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
+ 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 +518,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 +528,18 @@ export async function iterRecordsForPeerPullDebit(
PeerPullDebitRecordStatus.PendingDeposit,
PeerPullDebitRecordStatus.AbortingRefresh,
);
- await tx.peerPullPaymentIncoming.indexes.byStatus
+ 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 +558,7 @@ async function gatherPeerPullDebitPending(
...getPendingCommon(ws, opId, timestampDue),
givesLifeness: true,
retryInfo: retryRecord?.retryInfo,
- peerPullPaymentIncomingId: pi.peerPullPaymentIncomingId,
+ peerPullDebitId: pi.peerPullDebitId,
});
},
);
@@ -566,28 +566,28 @@ 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
+ 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 +614,36 @@ 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
+ 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 +658,7 @@ async function gatherPeerPushCreditPending(
...getPendingCommon(ws, opId, timestampDue),
givesLifeness: true,
retryInfo: retryRecord?.retryInfo,
- peerPushPaymentIncomingId: pi.peerPushPaymentIncomingId,
+ peerPushCreditId: pi.peerPushCreditId,
});
},
);
@@ -682,10 +682,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 = {
diff --git a/packages/taler-wallet-core/src/operations/reward.ts b/packages/taler-wallet-core/src/operations/reward.ts
index 6f9d3ce85..6ae021174 100644
--- a/packages/taler-wallet-core/src/operations/reward.ts
+++ b/packages/taler-wallet-core/src/operations/reward.ts
@@ -108,7 +108,7 @@ export function computeRewardTransactionStatus(
major: TransactionMajorState.Dialog,
minor: TransactionMinorState.Proposed,
};
- case RewardRecordStatus.SuspendidPickup:
+ case RewardRecordStatus.SuspendedPickup:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.Pickup,
@@ -128,7 +128,7 @@ export function computeTipTransactionActions(
return [TransactionAction.Delete];
case RewardRecordStatus.PendingPickup:
return [TransactionAction.Suspend, TransactionAction.Fail];
- case RewardRecordStatus.SuspendidPickup:
+ case RewardRecordStatus.SuspendedPickup:
return [TransactionAction.Resume, TransactionAction.Fail];
case RewardRecordStatus.DialogAccept:
return [TransactionAction.Abort];
@@ -255,7 +255,7 @@ export async function processTip(
case RewardRecordStatus.Aborted:
case RewardRecordStatus.DialogAccept:
case RewardRecordStatus.Done:
- case RewardRecordStatus.SuspendidPickup:
+ case RewardRecordStatus.SuspendedPickup:
return TaskRunResult.finished();
}
@@ -496,12 +496,12 @@ export async function suspendRewardTransaction(
let newStatus: RewardRecordStatus | undefined = undefined;
switch (tipRec.status) {
case RewardRecordStatus.Done:
- case RewardRecordStatus.SuspendidPickup:
+ case RewardRecordStatus.SuspendedPickup:
case RewardRecordStatus.Aborted:
case RewardRecordStatus.DialogAccept:
break;
case RewardRecordStatus.PendingPickup:
- newStatus = RewardRecordStatus.SuspendidPickup;
+ newStatus = RewardRecordStatus.SuspendedPickup;
break;
default:
@@ -551,7 +551,7 @@ export async function resumeTipTransaction(
case RewardRecordStatus.Aborted:
case RewardRecordStatus.DialogAccept:
break;
- case RewardRecordStatus.SuspendidPickup:
+ case RewardRecordStatus.SuspendedPickup:
newStatus = RewardRecordStatus.PendingPickup;
break;
default:
@@ -608,7 +608,7 @@ export async function abortTipTransaction(
case RewardRecordStatus.PendingPickup:
case RewardRecordStatus.DialogAccept:
break;
- case RewardRecordStatus.SuspendidPickup:
+ case RewardRecordStatus.SuspendedPickup:
newStatus = RewardRecordStatus.Aborted;
break;
default:
diff --git a/packages/taler-wallet-core/src/operations/testing.ts b/packages/taler-wallet-core/src/operations/testing.ts
index 1962c965c..f71d842c7 100644
--- a/packages/taler-wallet-core/src/operations/testing.ts
+++ b/packages/taler-wallet-core/src/operations/testing.ts
@@ -700,7 +700,7 @@ export async function runIntegrationTest2(
});
await confirmPeerPushCredit(ws, {
- peerPushPaymentIncomingId: peerPushCredit.peerPushPaymentIncomingId,
+ peerPushCreditId: peerPushCredit.peerPushCreditId,
});
const peerPullInit = await initiatePeerPullPayment(ws, {
@@ -723,7 +723,7 @@ export async function runIntegrationTest2(
});
await confirmPeerPullDebit(ws, {
- peerPullPaymentIncomingId: peerPullInc.peerPullPaymentIncomingId,
+ peerPullDebitId: peerPullInc.peerPullDebitId,
});
await waitUntilDone(ws);
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index 7f5302b25..5c57195c1 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -50,10 +50,10 @@ import {
OperationRetryRecord,
PeerPullPaymentIncomingRecord,
PeerPullDebitRecordStatus,
- PeerPullPaymentInitiationRecord,
+ PeerPullCreditRecord,
PeerPushPaymentIncomingRecord,
- PeerPushPaymentIncomingStatus,
- PeerPushPaymentInitiationRecord,
+ PeerPushCreditStatus,
+ PeerPushDebitRecord,
PurchaseRecord,
PurchaseStatus,
RefreshGroupRecord,
@@ -335,10 +335,10 @@ export async function getTransactionById(
}
case TransactionType.PeerPullDebit: {
return await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming])
+ .mktx((x) => [x.peerPullDebit])
.runReadWrite(async (tx) => {
- const debit = await tx.peerPullPaymentIncoming.get(
- parsedTx.peerPullPaymentIncomingId,
+ const debit = await tx.peerPullDebit.get(
+ parsedTx.peerPullDebitId,
);
if (!debit) throw Error("not found");
return buildTransactionForPullPaymentDebit(debit);
@@ -347,9 +347,9 @@ export async function getTransactionById(
case TransactionType.PeerPushDebit: {
return await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations, x.contractTerms])
+ .mktx((x) => [x.peerPushDebit, x.contractTerms])
.runReadWrite(async (tx) => {
- const debit = await tx.peerPushPaymentInitiations.get(
+ const debit = await tx.peerPushDebit.get(
parsedTx.pursePub,
);
if (!debit) throw Error("not found");
@@ -363,17 +363,17 @@ export async function getTransactionById(
}
case TransactionType.PeerPushCredit: {
- const peerPushPaymentIncomingId = parsedTx.peerPushPaymentIncomingId;
+ const peerPushCreditId = parsedTx.peerPushCreditId;
return await ws.db
.mktx((x) => [
- x.peerPushPaymentIncoming,
+ x.peerPushCredit,
x.contractTerms,
x.withdrawalGroups,
x.operationRetries,
])
.runReadWrite(async (tx) => {
- const pushInc = await tx.peerPushPaymentIncoming.get(
- peerPushPaymentIncomingId,
+ const pushInc = await tx.peerPushCredit.get(
+ peerPushCreditId,
);
if (!pushInc) throw Error("not found");
const ct = await tx.contractTerms.get(pushInc.contractTermsHash);
@@ -405,13 +405,13 @@ export async function getTransactionById(
const pursePub = parsedTx.pursePub;
return await ws.db
.mktx((x) => [
- x.peerPullPaymentInitiations,
+ x.peerPullCredit,
x.contractTerms,
x.withdrawalGroups,
x.operationRetries,
])
.runReadWrite(async (tx) => {
- const pushInc = await tx.peerPullPaymentInitiations.get(pursePub);
+ const pushInc = await tx.peerPullCredit.get(pursePub);
if (!pushInc) throw Error("not found");
const ct = await tx.contractTerms.get(pushInc.contractTermsHash);
checkDbInvariant(!!ct);
@@ -442,7 +442,7 @@ export async function getTransactionById(
}
function buildTransactionForPushPaymentDebit(
- pi: PeerPushPaymentInitiationRecord,
+ pi: PeerPushDebitRecord,
contractTerms: PeerContractTerms,
ort?: OperationRetryRecord,
): Transaction {
@@ -490,14 +490,14 @@ function buildTransactionForPullPaymentDebit(
timestamp: pi.timestampCreated,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId: pi.peerPullPaymentIncomingId,
+ peerPullDebitId: pi.peerPullDebitId,
}),
...(ort?.lastError ? { error: ort.lastError } : {}),
};
}
function buildTransactionForPeerPullCredit(
- pullCredit: PeerPullPaymentInitiationRecord,
+ pullCredit: PeerPullCreditRecord,
pullCreditOrt: OperationRetryRecord | undefined,
peerContractTerms: PeerContractTerms,
wsr: WithdrawalGroupRecord | undefined,
@@ -606,7 +606,7 @@ function buildTransactionForPeerPushCredit(
timestamp: wsr.timestampStart,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId: pushInc.peerPushPaymentIncomingId,
+ peerPushCreditId: pushInc.peerPushCreditId,
}),
kycUrl: pushInc.kycUrl,
...(wsrOrt?.lastError ? { error: wsrOrt.lastError } : {}),
@@ -629,7 +629,7 @@ function buildTransactionForPeerPushCredit(
timestamp: pushInc.timestamp,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId: pushInc.peerPushPaymentIncomingId,
+ peerPushCreditId: pushInc.peerPushCreditId,
}),
...(pushOrt?.lastError ? { error: pushOrt.lastError } : {}),
};
@@ -654,7 +654,7 @@ function buildTransactionForBankIntegratedWithdraw(
reservePub: wgRecord.reservePub,
bankConfirmationUrl: wgRecord.wgInfo.bankInfo.confirmUrl,
reserveIsReady:
- wgRecord.status === WithdrawalGroupStatus.Finished ||
+ wgRecord.status === WithdrawalGroupStatus.Done ||
wgRecord.status === WithdrawalGroupStatus.PendingReady,
},
kycUrl: wgRecord.kycUrl,
@@ -698,7 +698,7 @@ function buildTransactionForManualWithdraw(
reservePub: withdrawalGroup.reservePub,
exchangePaytoUris,
reserveIsReady:
- withdrawalGroup.status === WithdrawalGroupStatus.Finished ||
+ withdrawalGroup.status === WithdrawalGroupStatus.Done ||
withdrawalGroup.status === WithdrawalGroupStatus.PendingReady,
},
kycUrl: withdrawalGroup.kycUrl,
@@ -944,10 +944,10 @@ export async function getTransactions(
x.exchangeDetails,
x.exchanges,
x.operationRetries,
- x.peerPullPaymentIncoming,
- x.peerPushPaymentInitiations,
- x.peerPushPaymentIncoming,
- x.peerPullPaymentInitiations,
+ x.peerPullDebit,
+ x.peerPushDebit,
+ x.peerPushCredit,
+ x.peerPullCredit,
x.planchets,
x.purchases,
x.contractTerms,
@@ -985,7 +985,7 @@ export async function getTransactions(
}
if (
pi.status !== PeerPullDebitRecordStatus.PendingDeposit &&
- pi.status !== PeerPullDebitRecordStatus.DonePaid
+ pi.status !== PeerPullDebitRecordStatus.Done
) {
return;
}
@@ -1004,7 +1004,7 @@ export async function getTransactions(
if (shouldSkipSearch(transactionsRequest, [])) {
return;
}
- if (pi.status === PeerPushPaymentIncomingStatus.DialogProposed) {
+ if (pi.status === PeerPushCreditStatus.DialogProposed) {
// We don't report proposed push credit transactions, user needs
// to scan URI again and confirm to see it.
return;
@@ -1268,9 +1268,9 @@ export async function getTransactions(
export type ParsedTransactionIdentifier =
| { tag: TransactionType.Deposit; depositGroupId: string }
| { tag: TransactionType.Payment; proposalId: string }
- | { tag: TransactionType.PeerPullDebit; peerPullPaymentIncomingId: string }
+ | { tag: TransactionType.PeerPullDebit; peerPullDebitId: string }
| { tag: TransactionType.PeerPullCredit; pursePub: string }
- | { tag: TransactionType.PeerPushCredit; peerPushPaymentIncomingId: string }
+ | { tag: TransactionType.PeerPushCredit; peerPushCreditId: string }
| { tag: TransactionType.PeerPushDebit; pursePub: string }
| { tag: TransactionType.Refresh; refreshGroupId: string }
| { tag: TransactionType.Refund; refundGroupId: string }
@@ -1289,9 +1289,9 @@ export function constructTransactionIdentifier(
case TransactionType.PeerPullCredit:
return `txn:${pTxId.tag}:${pTxId.pursePub}` as TransactionIdStr;
case TransactionType.PeerPullDebit:
- return `txn:${pTxId.tag}:${pTxId.peerPullPaymentIncomingId}` as TransactionIdStr;
+ return `txn:${pTxId.tag}:${pTxId.peerPullDebitId}` as TransactionIdStr;
case TransactionType.PeerPushCredit:
- return `txn:${pTxId.tag}:${pTxId.peerPushPaymentIncomingId}` as TransactionIdStr;
+ return `txn:${pTxId.tag}:${pTxId.peerPushCreditId}` as TransactionIdStr;
case TransactionType.PeerPushDebit:
return `txn:${pTxId.tag}:${pTxId.pursePub}` as TransactionIdStr;
case TransactionType.Refresh:
@@ -1337,12 +1337,12 @@ export function parseTransactionIdentifier(
case TransactionType.PeerPullDebit:
return {
tag: TransactionType.PeerPullDebit,
- peerPullPaymentIncomingId: rest[0],
+ peerPullDebitId: rest[0],
};
case TransactionType.PeerPushCredit:
return {
tag: TransactionType.PeerPushCredit,
- peerPushPaymentIncomingId: rest[0],
+ peerPushCreditId: rest[0],
};
case TransactionType.PeerPushDebit:
return { tag: TransactionType.PeerPushDebit, pursePub: rest[0] };
@@ -1455,7 +1455,7 @@ export async function retryTransaction(
case TransactionType.PeerPullDebit: {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPullDebit,
- peerPullPaymentIncomingId: parsedTx.peerPullPaymentIncomingId,
+ peerPullDebitId: parsedTx.peerPullDebitId,
});
await resetPendingTaskTimeout(ws, taskId);
stopLongpolling(ws, taskId);
@@ -1464,7 +1464,7 @@ export async function retryTransaction(
case TransactionType.PeerPushCredit: {
const taskId = constructTaskIdentifier({
tag: PendingTaskType.PeerPushCredit,
- peerPushPaymentIncomingId: parsedTx.peerPushPaymentIncomingId,
+ peerPushCreditId: parsedTx.peerPushCreditId,
});
await resetPendingTaskTimeout(ws, taskId);
stopLongpolling(ws, taskId);
@@ -1522,10 +1522,10 @@ export async function suspendTransaction(
await suspendPeerPushDebitTransaction(ws, tx.pursePub);
break;
case TransactionType.PeerPullDebit:
- await suspendPeerPullDebitTransaction(ws, tx.peerPullPaymentIncomingId);
+ await suspendPeerPullDebitTransaction(ws, tx.peerPullDebitId);
break;
case TransactionType.PeerPushCredit:
- await suspendPeerPushCreditTransaction(ws, tx.peerPushPaymentIncomingId);
+ await suspendPeerPushCreditTransaction(ws, tx.peerPushCreditId);
break;
case TransactionType.Refund:
throw Error("refund transactions can't be suspended or resumed");
@@ -1568,10 +1568,10 @@ export async function failTransaction(
await failPeerPullCreditTransaction(ws, tx.pursePub);
return;
case TransactionType.PeerPullDebit:
- await failPeerPullDebitTransaction(ws, tx.peerPullPaymentIncomingId);
+ await failPeerPullDebitTransaction(ws, tx.peerPullDebitId);
return;
case TransactionType.PeerPushCredit:
- await failPeerPushCreditTransaction(ws, tx.peerPushPaymentIncomingId);
+ await failPeerPushCreditTransaction(ws, tx.peerPushCreditId);
return;
case TransactionType.PeerPushDebit:
await failPeerPushDebitTransaction(ws, tx.pursePub);
@@ -1613,10 +1613,10 @@ export async function resumeTransaction(
await resumePeerPushDebitTransaction(ws, tx.pursePub);
break;
case TransactionType.PeerPullDebit:
- await resumePeerPullDebitTransaction(ws, tx.peerPullPaymentIncomingId);
+ await resumePeerPullDebitTransaction(ws, tx.peerPullDebitId);
break;
case TransactionType.PeerPushCredit:
- await resumePeerPushCreditTransaction(ws, tx.peerPushPaymentIncomingId);
+ await resumePeerPushCreditTransaction(ws, tx.peerPushCreditId);
break;
case TransactionType.Refund:
throw Error("refund transactions can't be suspended or resumed");
@@ -1641,16 +1641,16 @@ export async function deleteTransaction(
switch (parsedTx.tag) {
case TransactionType.PeerPushCredit: {
- const peerPushPaymentIncomingId = parsedTx.peerPushPaymentIncomingId;
+ const peerPushCreditId = parsedTx.peerPushCreditId;
await ws.db
.mktx((x) => [
x.withdrawalGroups,
- x.peerPushPaymentIncoming,
+ x.peerPushCredit,
x.tombstones,
])
.runReadWrite(async (tx) => {
- const pushInc = await tx.peerPushPaymentIncoming.get(
- peerPushPaymentIncomingId,
+ const pushInc = await tx.peerPushCredit.get(
+ peerPushCreditId,
);
if (!pushInc) {
return;
@@ -1668,12 +1668,12 @@ export async function deleteTransaction(
});
}
}
- await tx.peerPushPaymentIncoming.delete(peerPushPaymentIncomingId);
+ await tx.peerPushCredit.delete(peerPushCreditId);
await tx.tombstones.put({
id:
TombstoneTag.DeletePeerPushCredit +
":" +
- peerPushPaymentIncomingId,
+ peerPushCreditId,
});
});
return;
@@ -1684,11 +1684,11 @@ export async function deleteTransaction(
await ws.db
.mktx((x) => [
x.withdrawalGroups,
- x.peerPullPaymentInitiations,
+ x.peerPullCredit,
x.tombstones,
])
.runReadWrite(async (tx) => {
- const pullIni = await tx.peerPullPaymentInitiations.get(pursePub);
+ const pullIni = await tx.peerPullCredit.get(pursePub);
if (!pullIni) {
return;
}
@@ -1705,7 +1705,7 @@ export async function deleteTransaction(
});
}
}
- await tx.peerPullPaymentInitiations.delete(pursePub);
+ await tx.peerPullCredit.delete(pursePub);
await tx.tombstones.put({
id: TombstoneTag.DeletePeerPullCredit + ":" + pursePub,
});
@@ -1795,7 +1795,7 @@ export async function deleteTransaction(
case TransactionType.Refund: {
const refundGroupId = parsedTx.refundGroupId;
await ws.db
- .mktx((x) => [x.refundGroups, x.tombstones, x.refundItems])
+ .mktx((x) => [x.refundGroups, x.tombstones])
.runReadWrite(async (tx) => {
const refundRecord = await tx.refundGroups.get(refundGroupId);
if (!refundRecord) {
@@ -1809,15 +1809,15 @@ export async function deleteTransaction(
}
case TransactionType.PeerPullDebit: {
- const peerPullPaymentIncomingId = parsedTx.peerPullPaymentIncomingId;
+ const peerPullDebitId = parsedTx.peerPullDebitId;
await ws.db
- .mktx((x) => [x.peerPullPaymentIncoming, x.tombstones])
+ .mktx((x) => [x.peerPullDebit, x.tombstones])
.runReadWrite(async (tx) => {
- const debit = await tx.peerPullPaymentIncoming.get(
- peerPullPaymentIncomingId,
+ const debit = await tx.peerPullDebit.get(
+ peerPullDebitId,
);
if (debit) {
- await tx.peerPullPaymentIncoming.delete(peerPullPaymentIncomingId);
+ await tx.peerPullDebit.delete(peerPullDebitId);
await tx.tombstones.put({ id: transactionId });
}
});
@@ -1828,11 +1828,11 @@ export async function deleteTransaction(
case TransactionType.PeerPushDebit: {
const pursePub = parsedTx.pursePub;
await ws.db
- .mktx((x) => [x.peerPushPaymentInitiations, x.tombstones])
+ .mktx((x) => [x.peerPushDebit, x.tombstones])
.runReadWrite(async (tx) => {
- const debit = await tx.peerPushPaymentInitiations.get(pursePub);
+ const debit = await tx.peerPushDebit.get(pursePub);
if (debit) {
- await tx.peerPushPaymentInitiations.delete(pursePub);
+ await tx.peerPushDebit.delete(pursePub);
await tx.tombstones.put({ id: transactionId });
}
});
@@ -1875,10 +1875,10 @@ export async function abortTransaction(
await abortPeerPullCreditTransaction(ws, txId.pursePub);
break;
case TransactionType.PeerPullDebit:
- await abortPeerPullDebitTransaction(ws, txId.peerPullPaymentIncomingId);
+ await abortPeerPullDebitTransaction(ws, txId.peerPullDebitId);
break;
case TransactionType.PeerPushCredit:
- await abortPeerPushCreditTransaction(ws, txId.peerPushPaymentIncomingId);
+ await abortPeerPushCreditTransaction(ws, txId.peerPushCreditId);
break;
case TransactionType.PeerPushDebit:
await abortPeerPushDebitTransaction(ws, txId.pursePub);
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index b2b25144d..32e63f4f6 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -315,7 +315,7 @@ export async function abortWithdrawalTransaction(
case WithdrawalGroupStatus.AbortingBank:
// No transition needed, but not an error
break;
- case WithdrawalGroupStatus.Finished:
+ case WithdrawalGroupStatus.Done:
case WithdrawalGroupStatus.FailedBankAborted:
case WithdrawalGroupStatus.AbortedExchange:
case WithdrawalGroupStatus.AbortedBank:
@@ -395,7 +395,7 @@ export function computeWithdrawalTransactionStatus(
return {
major: TransactionMajorState.Aborted,
};
- case WithdrawalGroupStatus.Finished:
+ case WithdrawalGroupStatus.Done:
return {
major: TransactionMajorState.Done,
};
@@ -499,7 +499,7 @@ export function computeWithdrawalTransactionActions(
switch (wgRecord.status) {
case WithdrawalGroupStatus.FailedBankAborted:
return [TransactionAction.Delete];
- case WithdrawalGroupStatus.Finished:
+ case WithdrawalGroupStatus.Done:
return [TransactionAction.Delete];
case WithdrawalGroupStatus.PendingRegisteringBank:
return [TransactionAction.Suspend, TransactionAction.Abort];
@@ -1457,7 +1457,7 @@ async function processWithdrawalGroupPendingReady(
return undefined;
}
const txStatusOld = computeWithdrawalTransactionStatus(wg);
- wg.status = WithdrawalGroupStatus.Finished;
+ wg.status = WithdrawalGroupStatus.Done;
wg.timestampFinish = TalerPreciseTimestamp.now();
const txStatusNew = computeWithdrawalTransactionStatus(wg);
await tx.withdrawalGroups.put(wg);
@@ -1555,7 +1555,7 @@ async function processWithdrawalGroupPendingReady(
logger.info(`now withdrawn ${numFinished} of ${numTotalCoins} coins`);
if (wg.timestampFinish === undefined && numFinished === numTotalCoins) {
wg.timestampFinish = TalerPreciseTimestamp.now();
- wg.status = WithdrawalGroupStatus.Finished;
+ wg.status = WithdrawalGroupStatus.Done;
await makeCoinsVisible(ws, tx, transactionId);
}
@@ -1647,7 +1647,7 @@ export async function processWithdrawalGroup(
}
break;
}
- case WithdrawalGroupStatus.Finished:
+ case WithdrawalGroupStatus.Done:
case WithdrawalGroupStatus.FailedBankAborted: {
// FIXME
return TaskRunResult.pending();
diff --git a/packages/taler-wallet-core/src/pending-types.ts b/packages/taler-wallet-core/src/pending-types.ts
index 82eb542a7..627888b4d 100644
--- a/packages/taler-wallet-core/src/pending-types.ts
+++ b/packages/taler-wallet-core/src/pending-types.ts
@@ -99,14 +99,14 @@ export interface PendingPeerPullInitiationTask {
*/
export interface PendingPeerPullDebitTask {
type: PendingTaskType.PeerPullDebit;
- peerPullPaymentIncomingId: string;
+ peerPullDebitId: string;
}
/**
*/
export interface PendingPeerPushCreditTask {
type: PendingTaskType.PeerPushCredit;
- peerPushPaymentIncomingId: string;
+ peerPushCreditId: string;
}
/**
diff --git a/packages/taler-wallet-core/src/util/coinSelection.ts b/packages/taler-wallet-core/src/util/coinSelection.ts
index abf0bbc02..ce9fec186 100644
--- a/packages/taler-wallet-core/src/util/coinSelection.ts
+++ b/packages/taler-wallet-core/src/util/coinSelection.ts
@@ -1002,7 +1002,7 @@ export async function selectPeerCoins(
x.coinAvailability,
x.denominations,
x.refreshGroups,
- x.peerPushPaymentInitiations,
+ x.peerPushDebit,
])
.runReadWrite(async (tx) => {
const exchanges = await tx.exchanges.iter().toArray();
diff --git a/packages/taler-wallet-core/src/util/query.ts b/packages/taler-wallet-core/src/util/query.ts
index 1c3ff6a2a..309c17a43 100644
--- a/packages/taler-wallet-core/src/util/query.ts
+++ b/packages/taler-wallet-core/src/util/query.ts
@@ -35,7 +35,7 @@ import {
IDBKeyPath,
IDBKeyRange,
} from "@gnu-taler/idb-bridge";
-import { Logger, j2s } from "@gnu-taler/taler-util";
+import { Codec, Logger, j2s } from "@gnu-taler/taler-util";
const logger = new Logger("query.ts");
@@ -387,11 +387,11 @@ export interface StoreReadWriteAccessor<RecordType, IndexMap> {
export interface StoreWithIndexes<
StoreName extends string,
- SD extends StoreDescriptor<unknown>,
+ RecordType,
IndexMap,
> {
storeName: StoreName;
- store: SD;
+ store: StoreDescriptor<RecordType>;
indexMap: IndexMap;
/**
@@ -401,19 +401,13 @@ export interface StoreWithIndexes<
mark: Symbol;
}
-export type GetRecordType<T> = T extends StoreDescriptor<infer X> ? X : unknown;
-
const storeWithIndexesSymbol = Symbol("StoreWithIndexesMark");
-export function describeStore<
- StoreName extends string,
- SD extends StoreDescriptor<unknown>,
- IndexMap,
->(
+export function describeStore<StoreName extends string, RecordType, IndexMap>(
name: StoreName,
- s: SD,
+ s: StoreDescriptor<RecordType>,
m: IndexMap,
-): StoreWithIndexes<StoreName, SD, IndexMap> {
+): StoreWithIndexes<StoreName, RecordType, IndexMap> {
return {
storeName: name,
store: s,
@@ -422,13 +416,72 @@ export function describeStore<
};
}
+export function describeStoreV2<
+ StoreName extends string,
+ RecordType,
+ IndexMap extends { [x: string]: IndexDescriptor } = {},
+>(args: {
+ storeName: StoreName;
+ recordCodec: Codec<RecordType>;
+ keyPath?: IDBKeyPath | IDBKeyPath[];
+ autoIncrement?: boolean;
+ /**
+ * Database version that this store was added in, or
+ * undefined if added in the first version.
+ */
+ versionAdded?: number;
+ indexes?: IndexMap;
+}): StoreWithIndexes<StoreName, RecordType, IndexMap> {
+ return {
+ storeName: args.storeName,
+ store: {
+ _dummy: undefined as any,
+ autoIncrement: args.autoIncrement,
+ keyPath: args.keyPath,
+ versionAdded: args.versionAdded,
+ },
+ indexMap: args.indexes ?? ({} as IndexMap),
+ mark: storeWithIndexesSymbol,
+ };
+}
+
+type KeyPathComponents = string | number;
+
+/**
+ * Follow a key path (dot-separated) in an object.
+ */
+type DerefKeyPath<T, P> = P extends `${infer PX extends keyof T &
+ KeyPathComponents}`
+ ? T[PX]
+ : P extends `${infer P0 extends keyof T & KeyPathComponents}.${infer Rest}`
+ ? DerefKeyPath<T[P0], Rest>
+ : unknown;
+
+/**
+ * Return a path if it is a valid dot-separate path to an object.
+ * Otherwise, return "never".
+ */
+type ValidateKeyPath<T, P> = P extends `${infer PX extends keyof T &
+ KeyPathComponents}`
+ ? PX
+ : P extends `${infer P0 extends keyof T & KeyPathComponents}.${infer Rest}`
+ ? `${P0}.${ValidateKeyPath<T[P0], Rest>}`
+ : never;
+
+// function foo<T, P>(
+// x: T,
+// p: P extends ValidateKeyPath<T, P> ? P : never,
+// ): void {}
+
+// foo({x: [0,1,2]}, "x.0");
+
export type GetReadOnlyAccess<BoundStores> = {
[P in keyof BoundStores]: BoundStores[P] extends StoreWithIndexes<
- infer SN,
- infer SD,
- infer IM
+ infer StoreName,
+ infer RecordType,
+ infer IndexMap
>
- ? StoreReadOnlyAccessor<GetRecordType<SD>, IM>
+ ? StoreReadOnlyAccessor<RecordType, IndexMap>
: unknown;
};
@@ -446,11 +499,11 @@ export type DbReadOnlyTransaction<
}
? {
[P in Stores]: StoreMap[P] extends StoreWithIndexes<
- infer SN,
- infer SD,
- infer IM
+ infer StoreName,
+ infer RecordType,
+ infer IndexMap
>
- ? StoreReadOnlyAccessor<GetRecordType<SD>, IM>
+ ? StoreReadOnlyAccessor<RecordType, IndexMap>
: unknown;
}
: unknown;
@@ -463,22 +516,22 @@ export type DbReadWriteTransaction<
}
? {
[P in Stores]: StoreMap[P] extends StoreWithIndexes<
- infer SN,
- infer SD,
- infer IM
+ infer StoreName,
+ infer RecordType,
+ infer IndexMap
>
- ? StoreReadWriteAccessor<GetRecordType<SD>, IM>
+ ? StoreReadWriteAccessor<RecordType, IndexMap>
: unknown;
}
: unknown;
export type GetReadWriteAccess<BoundStores> = {
[P in keyof BoundStores]: BoundStores[P] extends StoreWithIndexes<
- infer SN,
- infer SD,
- infer IM
+ infer StoreName,
+ infer RecordType,
+ infer IndexMap
>
- ? StoreReadWriteAccessor<GetRecordType<SD>, IM>
+ ? StoreReadWriteAccessor<RecordType, IndexMap>
: unknown;
};
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index cb82a3a43..11fb3f739 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -354,9 +354,9 @@ async function callOperationHandler(
case PendingTaskType.PeerPullCredit:
return await processPeerPullCredit(ws, pending.pursePub);
case PendingTaskType.PeerPullDebit:
- return await processPeerPullDebit(ws, pending.peerPullPaymentIncomingId);
+ return await processPeerPullDebit(ws, pending.peerPullDebitId);
case PendingTaskType.PeerPushCredit:
- return await processPeerPushCredit(ws, pending.peerPushPaymentIncomingId);
+ return await processPeerPushCredit(ws, pending.peerPushCreditId);
default:
return assertUnreachable(pending);
}
@@ -1876,7 +1876,7 @@ class InternalWalletStateImpl implements InternalWalletState {
return computeRefundTransactionState(rec);
}
case TransactionType.PeerPullCredit:
- const rec = await tx.peerPullPaymentInitiations.get(
+ const rec = await tx.peerPullCredit.get(
parsedTxId.pursePub,
);
if (!rec) {
@@ -1884,8 +1884,8 @@ class InternalWalletStateImpl implements InternalWalletState {
}
return computePeerPullCreditTransactionState(rec);
case TransactionType.PeerPullDebit: {
- const rec = await tx.peerPullPaymentIncoming.get(
- parsedTxId.peerPullPaymentIncomingId,
+ const rec = await tx.peerPullDebit.get(
+ parsedTxId.peerPullDebitId,
);
if (!rec) {
return undefined;
@@ -1893,8 +1893,8 @@ class InternalWalletStateImpl implements InternalWalletState {
return computePeerPullDebitTransactionState(rec);
}
case TransactionType.PeerPushCredit: {
- const rec = await tx.peerPushPaymentIncoming.get(
- parsedTxId.peerPushPaymentIncomingId,
+ const rec = await tx.peerPushCredit.get(
+ parsedTxId.peerPushCreditId,
);
if (!rec) {
return undefined;
@@ -1902,7 +1902,7 @@ class InternalWalletStateImpl implements InternalWalletState {
return computePeerPushCreditTransactionState(rec);
}
case TransactionType.PeerPushDebit: {
- const rec = await tx.peerPushPaymentInitiations.get(
+ const rec = await tx.peerPushDebit.get(
parsedTxId.pursePub,
);
if (!rec) {
diff --git a/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts b/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts
index 098f18921..8bae9470f 100644
--- a/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts
@@ -78,7 +78,7 @@ export function useComponentState({
const {
contractTerms,
- peerPullPaymentIncomingId,
+ peerPullDebitId,
amountEffective,
amountRaw,
} = hook.response.p2p;
@@ -155,7 +155,7 @@ export function useComponentState({
const resp = await api.wallet.call(
WalletApiOperation.ConfirmPeerPullDebit,
{
- peerPullPaymentIncomingId,
+ peerPullDebitId,
},
);
onSuccess(resp.transactionId);
diff --git a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
index fb9acbe83..47c644736 100644
--- a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts
@@ -58,7 +58,7 @@ export function useComponentState({
const {
contractTerms,
- peerPushPaymentIncomingId,
+ peerPushCreditId,
amountEffective,
amountRaw,
} = hook.response;
@@ -72,7 +72,7 @@ export function useComponentState({
const resp = await api.wallet.call(
WalletApiOperation.ConfirmPeerPushCredit,
{
- peerPushPaymentIncomingId,
+ peerPushCreditId,
},
);
onSuccess(resp.transactionId);