1 | import { u8aToHex } from '../u8a/index.js';
|
2 | import { bnToU8a } from './toU8a.js';
|
3 | /**
|
4 | * @name bnToHex
|
5 | * @summary Creates a hex value from a BN.js bignumber object.
|
6 | * @description
|
7 | * `null` inputs returns a `0x` result, BN values return the actual value as a `0x` prefixed hex value. Anything that is not a BN object throws an error. With `bitLength` set, it fixes the number to the specified length.
|
8 | * @example
|
9 | * <BR>
|
10 | *
|
11 | * ```javascript
|
12 | * import BN from 'bn.js';
|
13 | * import { bnToHex } from '@polkadot/util';
|
14 | *
|
15 | * bnToHex(new BN(0x123456)); // => '0x123456'
|
16 | * ```
|
17 | */
|
18 | export function bnToHex(value, { bitLength = -1, isLe = false, isNegative = false } = {}) {
|
19 | return u8aToHex(bnToU8a(value, { bitLength, isLe, isNegative }));
|
20 | } |
\ | No newline at end of file |