From: Chris Duncan Date: Sat, 30 Aug 2025 08:04:22 +0000 (-0700) Subject: Set default vault timer and simplify promise chain. X-Git-Tag: v0.10.5~38^2~3 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=29e0a5b9e3ffefcadb0b6349fdd2bb25c535ec65;p=libnemo.git Set default vault timer and simplify promise chain. --- diff --git a/src/lib/vault/vault-worker.ts b/src/lib/vault/vault-worker.ts index f7ba724..9be024a 100644 --- a/src/lib/vault/vault-worker.ts +++ b/src/lib/vault/vault-worker.ts @@ -13,7 +13,7 @@ import { VaultTimer } from './vault-timer' */ export class VaultWorker { static locked: boolean = true - static timeout: VaultTimer + static timeout: VaultTimer = new VaultTimer(() => { }, 0) static type?: 'BIP-44' | 'BLAKE2b' static seed?: ArrayBuffer static mnemonic?: ArrayBuffer @@ -118,14 +118,12 @@ export class VaultWorker { try { const entropy = crypto.getRandomValues(new Uint8Array(32)) return Bip39.fromEntropy(entropy) - .then(bip39 => { - return this._load(type, key, keySalt, bip39.phrase, mnemonicSalt) - .then(record => { - if (this.seed == null || this.mnemonic == null) { - throw new Error('Failed to generate seed and mnemonic') - } - return { ...record, seed: this.seed.slice(), mnemonic: this.mnemonic.slice() } - }) + .then(bip39 => this._load(type, key, keySalt, bip39.phrase, mnemonicSalt)) + .then(record => { + if (this.seed == null || this.mnemonic == null) { + throw new Error('Failed to generate seed and mnemonic') + } + return { ...record, seed: this.seed.slice(), mnemonic: this.mnemonic.slice() } }) } catch (err) { console.error(err)