From: Chris Duncan Date: Sun, 13 Oct 2024 03:21:18 +0000 (-0700) Subject: Expose internal wallet hexadecimal ID through getter. X-Git-Tag: v0.0.8~3 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=90db97116345dbe8b08c4dcf900b820dbb5e9b56;p=libnemo.git Expose internal wallet hexadecimal ID through getter. --- 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)