From 805078c3dbd6eff4b62b872ad7663156980312a6 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 11 Dec 2023 11:56:35 +0100 Subject: wallet-core: fix db import --- packages/taler-wallet-core/src/db.ts | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (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 4cc11d9eb..6b1fc2f5f 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -26,6 +26,7 @@ import { IDBRequest, IDBTransaction, structuredEncapsulate, + structuredRevive, } from "@gnu-taler/idb-bridge"; import { AbsoluteTime, @@ -577,11 +578,11 @@ export interface ExchangeDetailsRecord { * Information about ToS acceptance from the user. */ tosAccepted: - | { - etag: string; - timestamp: DbPreciseTimestamp; - } - | undefined; + | { + etag: string; + timestamp: DbPreciseTimestamp; + } + | undefined; wireInfo: WireInfo; @@ -1334,9 +1335,9 @@ export enum ConfigRecordKey { */ export type ConfigRecord = | { - key: ConfigRecordKey.WalletBackupState; - value: WalletBackupConfState; - } + key: ConfigRecordKey.WalletBackupState; + value: WalletBackupConfState; + } | { key: ConfigRecordKey.CurrencyDefaultsApplied; value: boolean } | { key: ConfigRecordKey.DevMode; value: boolean }; @@ -1603,15 +1604,15 @@ export enum BackupProviderStateTag { export type BackupProviderState = | { - tag: BackupProviderStateTag.Provisional; - } + tag: BackupProviderStateTag.Provisional; + } | { - tag: BackupProviderStateTag.Ready; - nextBackupTimestamp: DbPreciseTimestamp; - } + tag: BackupProviderStateTag.Ready; + nextBackupTimestamp: DbPreciseTimestamp; + } | { - tag: BackupProviderStateTag.Retrying; - }; + tag: BackupProviderStateTag.Retrying; + }; export interface BackupProviderTerms { supportedProtocolVersion: string; @@ -2840,7 +2841,7 @@ function checkDbDump(x: any): x is DbDump { } export async function importDb(db: IDBDatabase, dumpJson: any): Promise { - const d = dumpJson; + const d = structuredRevive(dumpJson); if (checkDbDump(d)) { const walletDb = d.databases[TALER_WALLET_MAIN_DB_NAME]; if (!walletDb) { @@ -3069,7 +3070,7 @@ export async function openStoredBackupsDatabase( idbFactory, TALER_WALLET_STORED_BACKUPS_DB_NAME, 1, - () => { }, + () => {}, onStoredBackupsDbUpgradeNeeded, ); @@ -3092,7 +3093,7 @@ export async function openTalerDatabase( idbFactory, TALER_WALLET_META_DB_NAME, 1, - () => { }, + () => {}, onMetaDbUpgradeNeeded, ); -- cgit v1.2.3