diff --git a/packages/util-crypto/src/address/encodeDerived.ts b/packages/util-crypto/src/address/encodeDerived.ts index 086ccfa58..33a00cf5f 100644 --- a/packages/util-crypto/src/address/encodeDerived.ts +++ b/packages/util-crypto/src/address/encodeDerived.ts @@ -14,6 +14,6 @@ import { createKeyDerived } from './keyDerived'; * @description * Creates a Substrate derived address based on the input address/publicKey and the index supplied. */ -export function encodeDerivedAddress (who: Uint8Array | string, index: BigInt | BN | number, ss58Format?: Prefix): string { +export function encodeDerivedAddress (who: Uint8Array | string, index: bigint | BN | number, ss58Format?: Prefix): string { return encodeAddress(createKeyDerived(decodeAddress(who), index), ss58Format); } diff --git a/packages/util-crypto/src/address/encodeMulti.ts b/packages/util-crypto/src/address/encodeMulti.ts index 334e8b6c7..5d3998fd0 100644 --- a/packages/util-crypto/src/address/encodeMulti.ts +++ b/packages/util-crypto/src/address/encodeMulti.ts @@ -13,6 +13,6 @@ import { createKeyMulti } from './keyMulti'; * @description * Creates a Substrate multisig address based on the input address and the required threshold. */ -export function encodeMultiAddress (who: (Uint8Array | string)[], threshold: BigInt | BN | number, ss58Format?: Prefix): string { +export function encodeMultiAddress (who: (Uint8Array | string)[], threshold: bigint | BN | number, ss58Format?: Prefix): string { return encodeAddress(createKeyMulti(who, threshold), ss58Format); } diff --git a/packages/util-crypto/src/address/keyDerived.ts b/packages/util-crypto/src/address/keyDerived.ts index da514371f..dc219e931 100644 --- a/packages/util-crypto/src/address/keyDerived.ts +++ b/packages/util-crypto/src/address/keyDerived.ts @@ -10,7 +10,7 @@ import { decodeAddress } from './decode'; const PREFIX = stringToU8a('modlpy/utilisuba'); -export function createKeyDerived (who: Uint8Array | string, index: BigInt | BN | number): Uint8Array { +export function createKeyDerived (who: Uint8Array | string, index: bigint | BN | number): Uint8Array { return blake2AsU8a( u8aConcat( PREFIX, diff --git a/packages/util-crypto/src/address/keyMulti.ts b/packages/util-crypto/src/address/keyMulti.ts index b352c26c4..860dd172f 100644 --- a/packages/util-crypto/src/address/keyMulti.ts +++ b/packages/util-crypto/src/address/keyMulti.ts @@ -10,7 +10,7 @@ import { decodeAddress } from './decode'; const PREFIX = stringToU8a('modlpy/utilisuba'); -export function createKeyMulti (who: (Uint8Array | string)[], threshold: BigInt | BN | number): Uint8Array { +export function createKeyMulti (who: (Uint8Array | string)[], threshold: bigint | BN | number): Uint8Array { return blake2AsU8a( u8aConcat( PREFIX, diff --git a/packages/util-crypto/src/key/DeriveJunction.ts b/packages/util-crypto/src/key/DeriveJunction.ts index 7a71e2699..eef445dd8 100644 --- a/packages/util-crypto/src/key/DeriveJunction.ts +++ b/packages/util-crypto/src/key/DeriveJunction.ts @@ -47,7 +47,7 @@ export class DeriveJunction { return !this.#isHard; } - public hard (value: number | string | BigInt | BN | Uint8Array): DeriveJunction { + public hard (value: number | string | bigint | BN | Uint8Array): DeriveJunction { return this.soft(value).harden(); } @@ -57,7 +57,7 @@ export class DeriveJunction { return this; } - public soft (value: number | string | BigInt | BN | Uint8Array): DeriveJunction { + public soft (value: number | string | bigint | BN | Uint8Array): DeriveJunction { if (isNumber(value) || isBn(value) || isBigInt(value)) { return this.soft(bnToHex(value, BN_OPTIONS)); } else if (isHex(value)) { diff --git a/packages/util/src/bn/sqrt.spec.ts b/packages/util/src/bn/sqrt.spec.ts index 3ed5f84f8..40d2aa177 100644 --- a/packages/util/src/bn/sqrt.spec.ts +++ b/packages/util/src/bn/sqrt.spec.ts @@ -3,7 +3,7 @@ import { BN, bnSqrt } from '.'; -const TESTS: [string | number | BN | BigInt, string | number][] = [ +const TESTS: [string | number | BN | bigint, string | number][] = [ [0, 0], [1, 1], [4, 2], diff --git a/packages/util/src/bn/sqrt.ts b/packages/util/src/bn/sqrt.ts index 6c4dc8cf6..b916fbf0c 100644 --- a/packages/util/src/bn/sqrt.ts +++ b/packages/util/src/bn/sqrt.ts @@ -23,7 +23,7 @@ const SQRT_MAX_SAFE_INTEGER = new BN(94906265); * bnSqrt(new BN(16)).toString(); // => '4' * ``` */ -export function bnSqrt (value: ExtToBn | BN | BigInt | string | number | null): BN { +export function bnSqrt (value: ExtToBn | BN | bigint | string | number | null): BN { const n = bnToBn(value); assert(n.gte(BN_ZERO), 'square root of negative numbers is not supported'); diff --git a/packages/util/src/bn/toBn.ts b/packages/util/src/bn/toBn.ts index b3cab1147..c4da4166a 100644 --- a/packages/util/src/bn/toBn.ts +++ b/packages/util/src/bn/toBn.ts @@ -11,7 +11,7 @@ import { BN } from './bn'; /** * @name bnToBn - * @summary Creates a BN value from a BN, BigInt, string (base 10 or hex) or number input. + * @summary Creates a BN value from a BN, bigint, string (base 10 or hex) or number input. * @description * `null` inputs returns a `0x0` result, BN values returns the value, numbers returns a BN representation. * @example @@ -25,7 +25,7 @@ import { BN } from './bn'; * bnToBn(new BN(0x1234)); // => BN(0x1234) * ``` */ -export function bnToBn (value?: ExtToBn | BN | BigInt | string | number | null): BN { +export function bnToBn (value?: ExtToBn | BN | bigint | string | number | null): BN { if (!value) { return new BN(0); } else if (isHex(value)) { diff --git a/packages/util/src/bn/toHex.ts b/packages/util/src/bn/toHex.ts index 3c574f5c8..1af0ebebc 100644 --- a/packages/util/src/bn/toHex.ts +++ b/packages/util/src/bn/toHex.ts @@ -29,9 +29,9 @@ interface Options extends ToBnOptions { * bnToHex(new BN(0x123456)); // => '0x123456' * ``` */ -function bnToHex (value?: ExtToBn | BN | BigInt | number | null, options?: Options): string; -function bnToHex (value?: ExtToBn | BN | BigInt | number | null, bitLength?: number, isLe?: boolean): string; -function bnToHex (value?: ExtToBn | BN | BigInt | number | null, arg1: number | Options = { bitLength: -1, isLe: false, isNegative: false }, arg2?: boolean): string { +function bnToHex (value?: ExtToBn | BN | bigint | number | null, options?: Options): string; +function bnToHex (value?: ExtToBn | BN | bigint | number | null, bitLength?: number, isLe?: boolean): string; +function bnToHex (value?: ExtToBn | BN | bigint | number | null, arg1: number | Options = { bitLength: -1, isLe: false, isNegative: false }, arg2?: boolean): string { if (!value) { return ZERO_STR; } diff --git a/packages/util/src/bn/toU8a.ts b/packages/util/src/bn/toU8a.ts index 57f142157..db4521472 100644 --- a/packages/util/src/bn/toU8a.ts +++ b/packages/util/src/bn/toU8a.ts @@ -40,9 +40,9 @@ function createValue (valueBn: BN, byteLength: number, { isLe, isNegative }: Opt * bnToU8a(new BN(0x1234)); // => [0x12, 0x34] * ``` */ -function bnToU8a (value?: ExtToBn | BN | BigInt | number | null, options?: Options): Uint8Array; -function bnToU8a (value?: ExtToBn | BN | BigInt | number | null, bitLength?: number, isLe?: boolean): Uint8Array; -function bnToU8a (value?: ExtToBn | BN | BigInt | number | null, arg1: number | Options = { bitLength: -1, isLe: true, isNegative: false }, arg2?: boolean): Uint8Array { +function bnToU8a (value?: ExtToBn | BN | bigint | number | null, options?: Options): Uint8Array; +function bnToU8a (value?: ExtToBn | BN | bigint | number | null, bitLength?: number, isLe?: boolean): Uint8Array; +function bnToU8a (value?: ExtToBn | BN | bigint | number | null, arg1: number | Options = { bitLength: -1, isLe: true, isNegative: false }, arg2?: boolean): Uint8Array { const options: Options = { bitLength: -1, isLe: true, diff --git a/packages/util/src/compact/toU8a.ts b/packages/util/src/compact/toU8a.ts index 08fa20aef..cd73c7279 100644 --- a/packages/util/src/compact/toU8a.ts +++ b/packages/util/src/compact/toU8a.ts @@ -21,7 +21,7 @@ const MAX_U32 = new BN(2).pow(new BN(32 - 2)).subn(1); * console.log(compactToU8a(511, 32)); // Uint8Array([0b11111101, 0b00000111]) * ``` */ -export function compactToU8a (_value: BN | BigInt | number): Uint8Array { +export function compactToU8a (_value: BN | bigint | number): Uint8Array { const value = bnToBn(_value); if (value.lte(MAX_U8)) { diff --git a/packages/util/src/format/formatBalance.ts b/packages/util/src/format/formatBalance.ts index 6ae7a5bac..3c29c24bc 100644 --- a/packages/util/src/format/formatBalance.ts +++ b/packages/util/src/format/formatBalance.ts @@ -29,7 +29,7 @@ interface Options { } interface BalanceFormatter { - (input?: number | string | BN | BigInt | ExtToBn, options?: Options, decimals?: number): string; + (input?: number | string | BN | bigint | ExtToBn, options?: Options, decimals?: number): string; calcSi (text: string, decimals?: number): SiDef; findSi (type: string): SiDef; getDefaults (): Defaults; @@ -44,7 +44,7 @@ let defaultDecimals = DEFAULT_DECIMALS; let defaultUnit = DEFAULT_UNIT; // Formats a string/number with . notation -function _formatBalance (input?: number | string | BN | BigInt | ExtToBn, options: Options | boolean = true, optDecimals: number = defaultDecimals): string { +function _formatBalance (input?: number | string | BN | bigint | ExtToBn, options: Options | boolean = true, optDecimals: number = defaultDecimals): string { let text = bnToBn(input).toString(); if (text.length === 0 || text === '0') { diff --git a/packages/util/src/format/formatElapsed.ts b/packages/util/src/format/formatElapsed.ts index fc99fccf7..2c39dd761 100644 --- a/packages/util/src/format/formatElapsed.ts +++ b/packages/util/src/format/formatElapsed.ts @@ -18,7 +18,7 @@ function formatValue (elapsed: number): string { return `${elapsed / 3600 | 0}h`; } -export function formatElapsed (now?: Date | null, value?: BigInt | BN | ExtToBn | Date | number | null): string { +export function formatElapsed (now?: Date | null, value?: bigint | BN | ExtToBn | Date | number | null): string { const tsNow = (now && now.getTime()) || 0; const tsValue = value instanceof Date ? value.getTime() diff --git a/packages/util/src/format/formatNumber.ts b/packages/util/src/format/formatNumber.ts index 6af75443e..f1a4f0f85 100644 --- a/packages/util/src/format/formatNumber.ts +++ b/packages/util/src/format/formatNumber.ts @@ -7,6 +7,6 @@ import type { ToBn } from '../types'; import { bnToBn } from '../bn/toBn'; import { formatDecimal } from './formatDecimal'; -export function formatNumber (value?: ExtToBn | BN | BigInt | number | null): string { +export function formatNumber (value?: ExtToBn | BN | bigint | number | null): string { return formatDecimal(bnToBn(value).toString()); } diff --git a/packages/util/src/is/bigInt.ts b/packages/util/src/is/bigInt.ts index c09b291f8..4820a4676 100644 --- a/packages/util/src/is/bigInt.ts +++ b/packages/util/src/is/bigInt.ts @@ -15,6 +15,6 @@ * console.log('isBigInt', isBigInt(123_456n)); // => true * ``` */ -export function isBigInt (value: unknown): value is BigInt { +export function isBigInt (value: unknown): value is bigint { return typeof value === 'bigint'; }