aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/db.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-01-22 13:49:11 +0100
committerFlorian Dold <florian@dold.me>2024-01-22 13:49:11 +0100
commit88851f45403c1995c973bcae7ad2976db3c430c7 (patch)
tree8a7bbd228b7b647a4ddc22bff732b71e0c6be276 /packages/taler-wallet-core/src/db.ts
parentd32731fc7526df18361aae6aa5541e10cf6b41aa (diff)
downloadwallet-core-88851f45403c1995c973bcae7ad2976db3c430c7.tar.xz
wallet-core: implement DD45 global currency management requests
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r--packages/taler-wallet-core/src/db.ts69
1 files changed, 46 insertions, 23 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index f16600f5d..ceca24c82 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -74,6 +74,7 @@ import {
describeContents,
describeIndex,
describeStore,
+ describeStoreV2,
openDatabase,
} from "./util/query.js";
@@ -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 = 2;
+export const WALLET_DB_MINOR_VERSION = 3;
declare const symDbProtocolTimestamp: unique symbol;
@@ -2197,21 +2198,6 @@ export interface DbAuditorHandle {
auditorPub: string;
}
-// Work in progress for regional currencies
-export interface CurrencySettingsRecord {
- currency: string;
-
- globalScopeExchanges: DbExchangeHandle[];
-
- globalScopeAuditors: DbAuditorHandle[];
-
- // Used to decide which auditor to show the currency under
- // when multiple auditors apply.
- auditorPriority: string[];
-
- // Later, we might add stuff related to how the currency is rendered.
-}
-
export enum RefundGroupStatus {
Pending = 0x0100_0000,
Done = 0x0500_0000,
@@ -2299,18 +2285,55 @@ export function passthroughCodec<T>(): Codec<T> {
return codecForAny();
}
+export interface GlobalCurrencyAuditorRecord {
+ id?: number;
+ currency: string;
+ auditorBaseUrl: string;
+ auditorPub: string;
+}
+
+export interface GlobalCurrencyExchangeRecord {
+ id?: number;
+ currency: string;
+ exchangeBaseUrl: string;
+ exchangeMasterPub: string;
+}
+
/**
* Schema definition for the IndexedDB
* wallet database.
*/
export const WalletStoresV1 = {
- currencySettings: describeStore(
- "currencySettings",
- describeContents<CurrencySettingsRecord>({
- keyPath: ["currency"],
- }),
- {},
- ),
+ globalCurrencyAuditors: describeStoreV2({
+ recordCodec: passthroughCodec<GlobalCurrencyAuditorRecord>(),
+ storeName: "globalCurrencyAuditors",
+ keyPath: "id",
+ autoIncrement: true,
+ versionAdded: 3,
+ indexes: {
+ byCurrencyAndUrlAndPub: describeIndex("byCurrencyAndUrlAndPub", [
+ "currency",
+ "auditorBaseUrl",
+ "auditorPub",
+ ]),
+ },
+ }),
+ globalCurrencyExchanges: describeStoreV2({
+ recordCodec: passthroughCodec<GlobalCurrencyExchangeRecord>(),
+ storeName: "globalCurrencyExchanges",
+ keyPath: "id",
+ autoIncrement: true,
+ versionAdded: 3,
+ indexes: {
+ byCurrencyAndUrlAndPub: describeIndex(
+ "byCurrencyAndUrlAndPub",
+ ["currency", "exchangeBaseUrl", "exchangeMasterPub"],
+ {
+ unique: true,
+ },
+ ),
+ },
+ }),
coinAvailability: describeStore(
"coinAvailability",
describeContents<CoinAvailabilityRecord>({