assert cleanups (#957)

This commit is contained in:
Jaco
2021-04-22 13:13:41 +02:00
committed by GitHub
parent a52a6253b5
commit bbadfbebfa
15 changed files with 27 additions and 29 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ export function decodeAddress (encoded?: string | Uint8Array | null, ignoreCheck
const [isValid, endPos, ss58Length, ss58Decoded] = checkAddressChecksum(decoded);
assert(ignoreChecksum || isValid, 'Invalid decoded address checksum');
assert([-1, ss58Decoded].includes(ss58Format), `Expected ss58Format ${ss58Format}, received ${ss58Decoded}`);
assert([-1, ss58Decoded].includes(ss58Format), () => `Expected ss58Format ${ss58Format}, received ${ss58Decoded}`);
return decoded.slice(ss58Length, endPos);
} catch (error) {
+1 -1
View File
@@ -16,7 +16,7 @@ export function encodeAddress (key: Uint8Array | string, ss58Format: Prefix = de
const u8a = decodeAddress(key);
assert(ss58Format >= 0 && ss58Format <= 16383 && ![46, 47].includes(ss58Format), 'Out of range ss58Format specified');
assert(defaults.allowedDecodedLengths.includes(u8a.length), `Expected a valid key to convert, with length ${defaults.allowedDecodedLengths.join(', ')}`);
assert(defaults.allowedDecodedLengths.includes(u8a.length), () => `Expected a valid key to convert, with length ${defaults.allowedDecodedLengths.join(', ')}`);
const input = u8aConcat(
ss58Format < 64