From fe4cdbeea478ca7bf19fbf3a2df1cadcf5d3bcea Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 2 Aug 2025 00:53:53 -0700 Subject: [PATCH] Fix wallet auto lock timing. Fix wallet verify method. --- src/lib/wallet.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) 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) } } } -- 2.47.3