From: Chris Duncan Date: Fri, 7 Aug 2026 19:43:33 +0000 (-0700) Subject: Fix address construction and error logging. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=94cf6b7889ae647b0c9aba7229728aaceb431b69;p=libnemo.git Fix address construction and error logging. --- diff --git a/src/lib/account/address.ts b/src/lib/account/address.ts index b1de2d8..e531d38 100644 --- a/src/lib/account/address.ts +++ b/src/lib/account/address.ts @@ -28,8 +28,8 @@ export class Address { if (typeof value !== 'string' && !(value instanceof ArrayBuffer) && !(value instanceof Uint8Array)) { throw new TypeError('Invalid address input', { cause: value }) } - if (hex.is(value)) { - if (value.length === ACCOUNT_KEY_HEX_LENGTH) { + if (typeof value === 'string') { + if (hex.is(value) && value.length === ACCOUNT_KEY_HEX_LENGTH) { this.#address = (this.constructor as typeof Address).fromPublicKey(hex.toBuffer(value)) } else { _validate(value) diff --git a/src/lib/account/index.ts b/src/lib/account/index.ts index adcd901..05d2e68 100644 --- a/src/lib/account/index.ts +++ b/src/lib/account/index.ts @@ -206,7 +206,7 @@ export class Account { this.#publicKey = this.#address.toPublicKey() } catch (err) { console.error(err) - throw new TypeError('Failed to import Account from public data', { cause: { err } }) + throw new TypeError('Failed to import Account from public data', { cause: err }) } } }