1 | // Copyright 2017-2022 @polkadot/util authors & contributors
|
2 | // SPDX-License-Identifier: Apache-2.0
|
3 | import { BigInt } from '@polkadot/x-bigint';
|
4 | import { objectSpread } from "../object/spread.js";
|
5 | import { u8aToBigInt } from "../u8a/toBigInt.js";
|
6 | import { hexToU8a } from "./toU8a.js";
|
7 | /**
|
8 | * @name hexToBigInt
|
9 | * @summary Creates a BigInt instance object from a hex string.
|
10 | */
|
11 |
|
12 | export function hexToBigInt(value, options = {}) {
|
13 | return !value || value === '0x' ? BigInt(0) : u8aToBigInt(hexToU8a(value), objectSpread({
|
14 | isLe: false,
|
15 | isNegative: false
|
16 | }, options));
|
17 | } |
\ | No newline at end of file |