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)
+ } else if (_validate(value)) {
this.#address = value
- }
+ } else {
+ throw new Error('Invalid address')
+ }
} else if (value instanceof ArrayBuffer || value instanceof Uint8Array) {
const v = new Uint8Array(value)
this.#address = (this.constructor as typeof Address).fromPublicKey(v)