]> zoso.dev Git - libnemo.git/commitdiff
Add wallet properties to get locked or unlocked status.
authorChris Duncan <chris@zoso.dev>
Mon, 14 Oct 2024 10:51:49 +0000 (03:51 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 14 Oct 2024 10:51:49 +0000 (03:51 -0700)
src/lib/wallet.ts

index fafc6d1193306378daffd327cbca39c6b9d5ec36..2443aa91558b7cb726c7af31c14d9e0f1e9abbe7 100644 (file)
@@ -22,12 +22,13 @@ import type { Ledger } from './ledger.js'
 abstract class Wallet {\r
        #accounts: Account[]\r
        #id: Entropy\r
+       #locked: boolean = true\r
        #mnemonic: Bip39Mnemonic | null\r
        #safe: Safe\r
        #seed: string | null\r
-       get id () {\r
-               return this.#id.hex\r
-       }\r
+       get id () { return this.#id.hex }\r
+       get isLocked () { return this.#locked }\r
+       get isUnlocked () { return !this.#locked }\r
        get mnemonic () {\r
                if (this.#mnemonic instanceof Bip39Mnemonic) {\r
                        return this.#mnemonic.phrase\r
@@ -176,6 +177,7 @@ abstract class Wallet {
                } catch (err) {\r
                        throw new Error('Failed to lock wallet')\r
                }\r
+               this.#locked = true\r
                this.#mnemonic = null\r
                this.#seed = null\r
                return true\r
@@ -210,6 +212,7 @@ abstract class Wallet {
                        if (seed != null) {\r
                                this.#seed = seed\r
                        }\r
+                       this.#locked = false\r
                } catch (err) {\r
                        throw new Error('Failed to unlock wallet')\r
                }\r