declare global {
type Bytes = Uint8Array<ArrayBuffer> | Buffer<ArrayBuffer>
- 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'
}
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)