From 63fc107dd0e216bd987304dc0a46668885ddfd3d Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 6 Aug 2026 21:31:00 -0700 Subject: [PATCH] Extend Hex type to accomodate string expectations. --- src/index.ts | 2 +- src/lib/account/address.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 244c464..65b53e9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ declare global { type Bytes = Uint8Array | Buffer - type Hex = HexByte[] + type Hex = string & HexByte[] type HexByte = `${HexChar}${HexChar}` type HexChar = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' } diff --git a/src/lib/account/address.ts b/src/lib/account/address.ts index e531d38..b1de2d8 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 (typeof value === 'string') { - if (hex.is(value) && value.length === ACCOUNT_KEY_HEX_LENGTH) { + if (hex.is(value)) { + if (value.length === ACCOUNT_KEY_HEX_LENGTH) { this.#address = (this.constructor as typeof Address).fromPublicKey(hex.toBuffer(value)) } else { _validate(value) -- 2.52.0