From 190e624dcf88ddda547f88a72f25877bfd9cae2c Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 14 Oct 2024 03:51:49 -0700 Subject: [PATCH] Add wallet properties to get locked or unlocked status. --- src/lib/wallet.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/wallet.ts b/src/lib/wallet.ts index fafc6d1..2443aa9 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -22,12 +22,13 @@ import type { Ledger } from './ledger.js' abstract class Wallet { #accounts: Account[] #id: Entropy + #locked: boolean = true #mnemonic: Bip39Mnemonic | null #safe: Safe #seed: string | null - get id () { - return this.#id.hex - } + get id () { return this.#id.hex } + get isLocked () { return this.#locked } + get isUnlocked () { return !this.#locked } get mnemonic () { if (this.#mnemonic instanceof Bip39Mnemonic) { return this.#mnemonic.phrase @@ -176,6 +177,7 @@ abstract class Wallet { } catch (err) { throw new Error('Failed to lock wallet') } + this.#locked = true this.#mnemonic = null this.#seed = null return true @@ -210,6 +212,7 @@ abstract class Wallet { if (seed != null) { this.#seed = seed } + this.#locked = false } catch (err) { throw new Error('Failed to unlock wallet') } -- 2.34.1