Skip to content

Commit 3a786c6

Browse files
authored
Merge pull request #2264 from oasisprotocol/pro-wh/bugfix/tsneg
ts-web/core: throw on quantity from negative bigint
2 parents 39703f7 + 65c7867 commit 3a786c6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

client-sdk/ts-web/core/src/quantity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function toBigInt(q: Uint8Array) {
77

88
export function fromBigInt(bi: bigint) {
99
if (bi === 0n) return new Uint8Array();
10+
if (bi < 0n) throw new RangeError(`Cannot convert ${bi} to quantity`);
1011
let hex = bi.toString(16);
1112
if (hex.length % 2) {
1213
hex = '0' + hex;

0 commit comments

Comments
 (0)