From: Chris Duncan Date: Mon, 14 Oct 2024 10:51:49 +0000 (-0700) Subject: Add wallet properties to get locked or unlocked status. X-Git-Tag: v0.0.11~1 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=190e624dcf88ddda547f88a72f25877bfd9cae2c;p=libnemo.git Add wallet properties to get locked or unlocked status. --- 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') }