diff options
author | Florian Dold <florian@dold.me> | 2022-10-12 22:27:50 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-10-12 22:27:50 +0200 |
commit | ded00b680a776d03cd8c928354c87c0be8690f56 (patch) | |
tree | 2608e9c7ba1ce8bfb105a421c56cdc201a78f3c9 /packages/taler-wallet-core/src/operations/backup/state.ts | |
parent | 3da1e82a245851c384c22293c928fcef1c4c2f34 (diff) | |
download | wallet-core-ded00b680a776d03cd8c928354c87c0be8690f56.tar.xz |
wallet-core: implement enabling/disabling dev mode
Diffstat (limited to 'packages/taler-wallet-core/src/operations/backup/state.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/backup/state.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/packages/taler-wallet-core/src/operations/backup/state.ts b/packages/taler-wallet-core/src/operations/backup/state.ts index 2efd9be8e..b8dbb15c1 100644 --- a/packages/taler-wallet-core/src/operations/backup/state.ts +++ b/packages/taler-wallet-core/src/operations/backup/state.ts @@ -17,9 +17,9 @@ import { encodeCrock, getRandomBytes } from "@gnu-taler/taler-util"; import { ConfigRecord, + ConfigRecordKey, WalletBackupConfState, WalletStoresV1, - WALLET_BACKUP_STATE_KEY, } from "../../db.js"; import { checkDbInvariant } from "../../util/invariants.js"; import { GetReadOnlyAccess } from "../../util/query.js"; @@ -31,10 +31,10 @@ export async function provideBackupState( const bs: ConfigRecord | undefined = await ws.db .mktx((stores) => [stores.config]) .runReadOnly(async (tx) => { - return await tx.config.get(WALLET_BACKUP_STATE_KEY); + return await tx.config.get(ConfigRecordKey.WalletBackupState); }); if (bs) { - checkDbInvariant(bs.key === WALLET_BACKUP_STATE_KEY); + checkDbInvariant(bs.key === ConfigRecordKey.WalletBackupState); return bs.value; } // We need to generate the key outside of the transaction @@ -48,11 +48,11 @@ export async function provideBackupState( .mktx((x) => [x.config]) .runReadWrite(async (tx) => { let backupStateEntry: ConfigRecord | undefined = await tx.config.get( - WALLET_BACKUP_STATE_KEY, + ConfigRecordKey.WalletBackupState, ); if (!backupStateEntry) { backupStateEntry = { - key: WALLET_BACKUP_STATE_KEY, + key: ConfigRecordKey.WalletBackupState, value: { deviceId, walletRootPub: k.pub, @@ -62,7 +62,7 @@ export async function provideBackupState( }; await tx.config.put(backupStateEntry); } - checkDbInvariant(backupStateEntry.key === WALLET_BACKUP_STATE_KEY); + checkDbInvariant(backupStateEntry.key === ConfigRecordKey.WalletBackupState); return backupStateEntry.value; }); } @@ -71,9 +71,9 @@ export async function getWalletBackupState( ws: InternalWalletState, tx: GetReadOnlyAccess<{ config: typeof WalletStoresV1.config }>, ): Promise<WalletBackupConfState> { - const bs = await tx.config.get(WALLET_BACKUP_STATE_KEY); + const bs = await tx.config.get(ConfigRecordKey.WalletBackupState); checkDbInvariant(!!bs, "wallet backup state should be in DB"); - checkDbInvariant(bs.key === WALLET_BACKUP_STATE_KEY); + checkDbInvariant(bs.key === ConfigRecordKey.WalletBackupState); return bs.value; } @@ -86,11 +86,11 @@ export async function setWalletDeviceId( .mktx((x) => [x.config]) .runReadWrite(async (tx) => { let backupStateEntry: ConfigRecord | undefined = await tx.config.get( - WALLET_BACKUP_STATE_KEY, + ConfigRecordKey.WalletBackupState, ); if ( !backupStateEntry || - backupStateEntry.key !== WALLET_BACKUP_STATE_KEY + backupStateEntry.key !== ConfigRecordKey.WalletBackupState ) { return; } |