]> zoso.dev Git - libnemo.git/commitdiff
Expose internal wallet hexadecimal ID through getter.
authorChris Duncan <chris@zoso.dev>
Sun, 13 Oct 2024 03:21:18 +0000 (20:21 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 13 Oct 2024 03:21:18 +0000 (20:21 -0700)
src/lib/wallet.ts

index 32d80c734f29fb9f32ce8b1b1aaa47b55dd738e9..b139969cc5a007d18bfc4f7b70c8882efe93aa0d 100644 (file)
@@ -25,6 +25,9 @@ abstract class Wallet {
        #mnemonic: Bip39Mnemonic | null\r
        #safe: Safe\r
        #seed: string | null\r
+       get id () {\r
+               return this.#id.hex\r
+       }\r
        get mnemonic () {\r
                if (this.#mnemonic instanceof Bip39Mnemonic) {\r
                        return this.#mnemonic.phrase\r
@@ -150,7 +153,7 @@ abstract class Wallet {
        async lock (passkey: string | CryptoKey): Promise<boolean> {\r
                let success = true\r
                try {\r
-                       success &&= await this.#safe.overwrite(this.#id.hex, passkey as string, this.#id.hex)\r
+                       success &&= await this.#safe.overwrite(this.id, passkey as string, this.id)\r
                        if (!success) {\r
                                throw null\r
                        }\r
@@ -190,8 +193,8 @@ abstract class Wallet {
        async unlock (key: CryptoKey): Promise<boolean>\r
        async unlock (passkey: string | CryptoKey): Promise<boolean> {\r
                try {\r
-                       const id = await this.#safe.get(this.#id.hex, passkey as string)\r
-                       if (id !== this.#id.hex) {\r
+                       const id = await this.#safe.get(this.id, passkey as string)\r
+                       if (id !== this.id) {\r
                                throw null\r
                        }\r
                        const mnemonic = await this.#safe.get('mnemonic', passkey as string)\r