From f45340eb11435f47a3a561c724cd356e5b4ba885 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 31 Mar 2024 16:50:34 +0200 Subject: wallet-core: implement denom-loss transaction --- packages/taler-wallet-core/src/db.ts | 38 +++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'packages/taler-wallet-core/src/db.ts') diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 98390805b..4ead3cf5c 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -39,6 +39,7 @@ import { CoinPublicKeyString, CoinRefreshRequest, CoinStatus, + DenomLossEventType, DenomSelectionState, DenominationInfo, DenominationPubKey, @@ -149,7 +150,7 @@ export const CURRENT_DB_CONFIG_KEY = "currentMainDbName"; * backwards-compatible way or object stores and indices * are added. */ -export const WALLET_DB_MINOR_VERSION = 8; +export const WALLET_DB_MINOR_VERSION = 9; declare const symDbProtocolTimestamp: unique symbol; @@ -2355,11 +2356,46 @@ export interface TransactionRecord { currency: string; } +export enum DenomLossStatus { + /** + * Done indicates that the loss happened. + */ + Done = 0x0500_0000, + + /** + * Aborted in the sense that the loss was reversed. + */ + Aborted = 0x0503_0001, +} + +export interface DenomLossEventRecord { + denomLossEventId: string; + currency: string; + denomPubHashes: string[]; + status: DenomLossStatus; + timestampCreated: DbPreciseTimestamp; + amount: string; + eventType: DenomLossEventType; + exchangeBaseUrl: string; +} + /** * Schema definition for the IndexedDB * wallet database. */ export const WalletStoresV1 = { + denomLossEvents: describeStoreV2({ + recordCodec: passthroughCodec(), + storeName: "denomLossEvents", + keyPath: "denomLossEventId", + versionAdded: 9, + indexes: { + byCurrency: describeIndex("byCurrency", "currency", { + versionAdded: 9, + }), + byStatus: describeIndex("byStatus", "status"), + }, + }), transactions: describeStoreV2({ recordCodec: passthroughCodec(), storeName: "transactions", -- cgit v1.2.3