From: Chris Duncan Date: Sat, 2 Aug 2025 07:53:53 +0000 (-0700) Subject: Fix wallet auto lock timing. Fix wallet verify method. X-Git-Tag: v0.10.5~47^2~19 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=fe4cdbeea478ca7bf19fbf3a2df1cadcf5d3bcea;p=libnemo.git Fix wallet auto lock timing. Fix wallet verify method. --- diff --git a/src/lib/wallet.ts b/src/lib/wallet.ts index 1543c86..a85a02e 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -396,7 +396,7 @@ export class Wallet { throw new Error('Unlock request to Safe failed') } clearTimeout(this.#lockTimer) - this.#lockTimer = setTimeout(() => this.lock(), 120000) + this.#lockTimer = setTimeout(() => this.lock(), 300000) return isUnlocked } catch (err) { throw new Error('Failed to unlock wallet', { cause: err }) @@ -453,24 +453,22 @@ export class Wallet { async verify (mnemonic: string): Promise async verify (secret: string): Promise { try { - const data: NamedData = { + clearTimeout(this.#lockTimer) + const data: NamedData = { action: 'verify' } if (/^[A-Fa-f0-9]+$/.test(secret)) { - data.seed = secret + data.seed = hex.toBuffer(secret) } else { data.mnemonicPhrase = secret } const result = await this.#safe.request(data) - const { isUnlocked } = result - if (!isUnlocked) { - throw new Error('Unlock request to Safe failed') - } - clearTimeout(this.#lockTimer) - this.#lockTimer = setTimeout(() => this.lock(), 120) - return isUnlocked + const { isVerified } = result + return isVerified } catch (err) { - throw new Error('Failed to unlock wallet', { cause: err }) + throw new Error('Failed to verify wallet', { cause: err }) + } finally { + this.#lockTimer = setTimeout(() => this.lock(), 300000) } } }