@polkadot/util#u8aToBn TypeScript Examples
The following examples show how to use
@polkadot/util#u8aToBn.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From bodhi.js with Apache License 2.0 | 7 votes |
export function toBN(bigNumberis: BigNumberish = 0): BN {
if (isU8a(bigNumberis)) {
return u8aToBn(bigNumberis);
}
if (isHex(bigNumberis)) {
return hexToBn(bigNumberis);
}
if (BigNumber.isBigNumber(bigNumberis)) {
const hex = bigNumberis.toHexString();
if (hex[0] === '-') {
return new BN('-' + hex.substring(3), 16);
}
return new BN(hex.substring(2), 16);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new BN(bigNumberis as any);
}
Example #2
Source File: utils.ts From evm-provider.js with Apache License 2.0 | 7 votes |
export function toBN(bigNumberis: BigNumberish = 0): BN {
if (isU8a(bigNumberis)) {
return u8aToBn(bigNumberis);
}
if (isHex(bigNumberis)) {
return hexToBn(bigNumberis);
}
if (BigNumber.isBigNumber(bigNumberis)) {
const hex = bigNumberis.toHexString();
if (hex[0] === '-') {
return new BN('-' + hex.substring(3), 16);
}
return new BN(hex.substring(2), 16);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new BN(bigNumberis as any);
}