Skip to content

Commit 739a505

Browse files
committed
ts-web/core: throw on quantity from negative bigint
1 parent d7d8dea commit 739a505

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

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)