Adjust AbstractInt asserts (#4898)

* Adjust AbstractInt asserts

* Adjust

* Number.isInteger
This commit is contained in:
Jaco
2022-06-07 14:43:39 +03:00
committed by GitHub
parent ea36b6d486
commit df74330b67
2 changed files with 23 additions and 13 deletions
@@ -31,7 +31,7 @@ function decodeAbstractInt (value: Exclude<AnyNumber, Uint8Array>, isNegative: b
} else if (isHex(value, -1, true)) {
return hexToBn(value, { isLe: false, isNegative }).toString();
} else if (isNumber(value)) {
assert(value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER && Math.floor(value) === value, 'Number needs to be an integer <= Number.MAX_SAFE_INTEGER, i.e. 2 ^ 53 - 1');
assert(value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER && Number.isInteger(value), 'Number needs to be an integer <= Number.MAX_SAFE_INTEGER, i.e. 2 ^ 53 - 1');
} else if (isString(value)) {
assert(!(value.includes('.') || value.includes(',') || value.includes('e')), 'String should not contain decimal points or scientific notation');
}