]> git.codecow.com Git - libnemo.git/commitdiff
Fix address construction and error logging.
authorChris Duncan <chris@codecow.com>
Fri, 7 Aug 2026 19:43:33 +0000 (12:43 -0700)
committerChris Duncan <chris@codecow.com>
Fri, 7 Aug 2026 19:43:33 +0000 (12:43 -0700)
src/lib/account/address.ts
src/lib/account/index.ts

index b1de2d8fcb94a9545e392b765c9c489288f56790..e531d38ce3aff391706a98ae1462b7f31fd3da2f 100644 (file)
@@ -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)
index adcd9013256ac572fd816212b2e25951a179c63d..05d2e6835ae83c89e77a7c63732629d30fc30493 100644 (file)
@@ -206,7 +206,7 @@ export class Account {
                                this.#publicKey = this.#address.toPublicKey()\r
                        } catch (err) {\r
                                console.error(err)\r
-                               throw new TypeError('Failed to import Account from public data', { cause: { err } })\r
+                               throw new TypeError('Failed to import Account from public data', { cause: err })\r
                        }\r
                }\r
        }\r