User template string type for isHex (#1020)
* User template string type for isHex * isHex/isString combo checks
This commit is contained in:
@@ -29,6 +29,6 @@ export function decodeAddress (encoded?: string | Uint8Array | null, ignoreCheck
|
||||
|
||||
return decoded.slice(ss58Length, endPos);
|
||||
} catch (error) {
|
||||
throw new Error(`Decoding ${encoded as string}: ${(error as Error).message}`);
|
||||
throw new Error(`Decoding ${encoded}: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,13 +60,11 @@ export class DeriveJunction {
|
||||
public soft (value: number | string | BigInt | BN | Uint8Array): DeriveJunction {
|
||||
if (isNumber(value) || isBn(value) || isBigInt(value)) {
|
||||
return this.soft(bnToHex(value, BN_OPTIONS));
|
||||
} else if (isHex(value)) {
|
||||
return this.soft(hexToU8a(value));
|
||||
} else if (isString(value)) {
|
||||
return isHex(value)
|
||||
? this.soft(hexToU8a(value))
|
||||
: this.soft(compactAddLength(stringToU8a(value)));
|
||||
}
|
||||
|
||||
if (value.length > JUNCTION_ID_LEN) {
|
||||
return this.soft(compactAddLength(stringToU8a(value)));
|
||||
} else if (value.length > JUNCTION_ID_LEN) {
|
||||
return this.soft(blake2AsU8a(value));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user