aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/db.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-09-07 20:35:46 +0200
committerFlorian Dold <florian@dold.me>2023-09-08 00:12:52 +0200
commitc660db82c12e08020661828f1d8383baa7ef0e02 (patch)
tree655b3aa9cf91fae4a4b4052356b97a9b3b119376 /packages/taler-wallet-core/src/db.ts
parent33f2798004b1235eeb33a66d08bf22243f5ae566 (diff)
downloadwallet-core-c660db82c12e08020661828f1d8383baa7ef0e02.tar.xz
wallet-core: address DB FIXMEs, systematic state numbering
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r--packages/taler-wallet-core/src/db.ts556
1 files changed, 186 insertions, 370 deletions
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");