aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/db.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-09-21 20:46:45 +0200
committerFlorian Dold <florian@dold.me>2022-09-21 22:50:42 +0200
commit7d6bcd42ea9efced6200cf94924aa38bed2dbb02 (patch)
tree54b2077512c7d098e558193392a7ac92a6d74d63 /packages/taler-wallet-core/src/db.ts
parent5d31803c92ac085d50ab0942a6cf657a6cd9cc4b (diff)
downloadwallet-core-7d6bcd42ea9efced6200cf94924aa38bed2dbb02.tar.xz
wallet-core: use numeric status field to allow range queries
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r--packages/taler-wallet-core/src/db.ts33
1 files changed, 17 insertions, 16 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 078060297..8ed4fe85e 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -62,6 +62,8 @@ import { Event, IDBDatabase } from "@gnu-taler/idb-bridge";
* will have an index.
* - Amounts are stored as strings, except when they are needed for
* indexing.
+ * - Every record that has a corresponding transaction item must have
+ * an index for a mandatory timestamp field.
* - Optional fields should be avoided, use "T | undefined" instead.
*
* @author Florian Dold <dold@taler.net>
@@ -94,38 +96,45 @@ export const CURRENT_DB_CONFIG_KEY = "currentMainDbName";
*/
export const WALLET_DB_MINOR_VERSION = 1;
+export namespace OperationStatusRange {
+ export const ACTIVE_START = 10;
+ export const ACTIVE_END = 29;
+ export const DORMANT_START = 40;
+ export const DORMANT_END = 59;
+}
+
/**
* Status of a withdrawal.
*/
-export enum ReserveRecordStatus {
+export enum WithdrawalGroupStatus {
/**
* Reserve must be registered with the bank.
*/
- RegisteringBank = "registering-bank",
+ RegisteringBank = OperationStatusRange.ACTIVE_START,
/**
* 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).
*/
- WaitConfirmBank = "wait-confirm-bank",
+ WaitConfirmBank = OperationStatusRange.ACTIVE_START + 1,
/**
* Querying reserve status with the exchange.
*/
- QueryingStatus = "querying-status",
+ QueryingStatus = OperationStatusRange.ACTIVE_START + 2,
/**
* The corresponding withdraw record has been created.
* No further processing is done, unless explicitly requested
* by the user.
*/
- Dormant = "dormant",
+ Finished = OperationStatusRange.DORMANT_START,
/**
* The bank aborted the withdrawal.
*/
- BankAborted = "bank-aborted",
+ BankAborted = OperationStatusRange.DORMANT_START + 1,
}
/**
@@ -1355,19 +1364,11 @@ export interface WithdrawalGroupRecord {
timestampFinish?: TalerProtocolTimestamp;
/**
- * Operation status of the withdrawal group.
- * Used for indexing in the database.
- *
- * FIXME: Redundant with reserveStatus
- */
- operationStatus: OperationStatus;
-
- /**
* Current status of the reserve.
*
* FIXME: Wrong name!
*/
- reserveStatus: ReserveRecordStatus;
+ status: WithdrawalGroupStatus;
/**
* Amount that was sent by the user to fund the reserve.
@@ -1947,7 +1948,7 @@ export const WalletStoresV1 = {
}),
{
byReservePub: describeIndex("byReservePub", "reservePub"),
- byStatus: describeIndex("byStatus", "operationStatus"),
+ byStatus: describeIndex("byStatus", "status"),
byTalerWithdrawUri: describeIndex(
"byTalerWithdrawUri",
"wgInfo.bankInfo.talerWithdrawUri",