From 90db97116345dbe8b08c4dcf900b820dbb5e9b56 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 12 Oct 2024 20:21:18 -0700 Subject: [PATCH] Expose internal wallet hexadecimal ID through getter. --- 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 32d80c7..b139969 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -25,6 +25,9 @@ abstract class Wallet { #mnemonic: Bip39Mnemonic | null #safe: Safe #seed: string | null + get id () { + return this.#id.hex + } get mnemonic () { if (this.#mnemonic instanceof Bip39Mnemonic) { return this.#mnemonic.phrase @@ -150,7 +153,7 @@ abstract class Wallet { async lock (passkey: string | CryptoKey): Promise { let success = true try { - success &&= await this.#safe.overwrite(this.#id.hex, passkey as string, this.#id.hex) + success &&= await this.#safe.overwrite(this.id, passkey as string, this.id) if (!success) { throw null } @@ -190,8 +193,8 @@ abstract class Wallet { async unlock (key: CryptoKey): Promise async unlock (passkey: string | CryptoKey): Promise { try { - const id = await this.#safe.get(this.#id.hex, passkey as string) - if (id !== this.#id.hex) { + const id = await this.#safe.get(this.id, passkey as string) + if (id !== this.id) { throw null } const mnemonic = await this.#safe.get('mnemonic', passkey as string) -- 2.34.1