UNPKG

624 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.hexToBigInt = void 0;
4const x_bigint_1 = require("@polkadot/x-bigint");
5const toBigInt_js_1 = require("../u8a/toBigInt.js");
6const toU8a_js_1 = require("./toU8a.js");
7/**
8 * @name hexToBigInt
9 * @summary Creates a BigInt instance object from a hex string.
10 */
11function hexToBigInt(value, { isLe = false, isNegative = false } = {}) {
12 return !value || value === '0x'
13 ? (0, x_bigint_1.BigInt)(0)
14 : (0, toBigInt_js_1.u8aToBigInt)((0, toU8a_js_1.hexToU8a)(value), { isLe, isNegative });
15}
16exports.hexToBigInt = hexToBigInt;