diff options
author | Florian Dold <florian@dold.me> | 2022-09-20 21:44:21 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-09-20 23:17:42 +0200 |
commit | 16a5bb40834c01e50e84144bb644517e67a66187 (patch) | |
tree | f6e7167aca608316ad03cf1e0debdb65eabe02cc /packages/taler-wallet-core/src/wallet.ts | |
parent | 52ec740c825d4e94fd59ef0a5cd8e8b73f4dfc06 (diff) | |
download | wallet-core-16a5bb40834c01e50e84144bb644517e67a66187.tar.xz |
wallet-core: make basic backup work again
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 1b74f2025..2e362da6e 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -99,6 +99,7 @@ import { CryptoDispatcher, CryptoWorkerFactory, } from "./crypto/workers/cryptoDispatcher.js"; +import { clearDatabase } from "./db-utils.js"; import { AuditorTrustRecord, CoinRecord, @@ -114,7 +115,6 @@ import { makeErrorDetail, TalerError, } from "./errors.js"; -import { createDenominationTimeline } from "./index.browser.js"; import { ExchangeOperations, InternalWalletState, @@ -131,6 +131,7 @@ import { codecForRunBackupCycle, getBackupInfo, getBackupRecovery, + importBackupPlain, loadBackupRecovery, processBackupForProvider, removeBackupProvider, @@ -215,6 +216,7 @@ import { } from "./pending-types.js"; import { assertUnreachable } from "./util/assertUnreachable.js"; import { AsyncOpMemoMap, AsyncOpMemoSingle } from "./util/asyncMemo.js"; +import { createDenominationTimeline } from "./util/denominations.js"; import { HttpRequestLibrary, readSuccessResponseJsonOrThrow, @@ -1060,8 +1062,11 @@ async function dispatchRequestInternal( `wallet must be initialized before running operation ${operation}`, ); } + // FIXME: Can we make this more type-safe by using the request/response type + // definitions we already have? switch (operation) { case "initWallet": { + logger.info("initializing wallet"); ws.initCalled = true; if (typeof payload === "object" && (payload as any).skipDefaults) { logger.info("skipping defaults"); @@ -1371,6 +1376,15 @@ async function dispatchRequestInternal( logger.info(`started fakebank withdrawal: ${j2s(fbResp)}`); return {}; } + case "clearDb": + await clearDatabase(ws.db.idbHandle()); + return {}; + case "recycle": { + const backup = await exportBackup(ws); + await clearDatabase(ws.db.idbHandle()); + await importBackupPlain(ws, backup); + return {}; + } case "exportDb": { const dbDump = await exportDb(ws.db.idbHandle()); return dbDump; |