UNPKG

iso-filecoin

Version:

Isomorphic filecoin abstractions for RPC, signatures, address, token and wallet

105 lines 2.58 kB
/** * @noImplicitAny: false * @typedef {number | string | BigNumber.Instance | bigint | Token} Value */ /** * Check if object is a {@link Token} instance * * @param {any} val * @returns {val is Token} */ export function isToken(val: any): val is Token; export const ATTO_DECIMALS: 18; export const FEMTO_DECIMALS: 15; export const PICO_DECIMALS: 12; export const NANO_DECIMALS: 9; export const MICRO_DECIMALS: 6; export const MILLI_DECIMALS: 3; export const WHOLE_DECIMALS: 0; /** * Class to work with different Filecoin denominations. * * @see https://docs.filecoin.io/basics/assets/the-fil-token/#denomonations */ export class Token { /** * @param {Value} val */ static fromAttoFIL(val: Value): Token; /** * @param {Value} val */ static fromFemtoFIL(val: Value): Token; /** * @param {Value} val */ static fromPicoFIL(val: Value): Token; /** * @param {Value} val */ static fromNanoFIL(val: Value): Token; /** * @param {Value} val */ static fromMicroFIL(val: Value): Token; /** * @param {Value} val */ static fromMilliFIL(val: Value): Token; /** * @param {Value} val */ static fromFIL(val: Value): Token; /** * @param {Value} val */ constructor(val: Value); /** @type {BigNumber} */ val: BigNumber; /** * @param {Value} val */ mul(val: Value): Token; /** * @param {Value} val */ div(val: Value): Token; abs(): Token; /** * @param {Value} val */ add(val: Value): Token; /** * @param {Value} val */ sub(val: Value): Token; /** * Serialize the number to a string using the given base. * * @param {number | undefined} [base] */ toString(base?: number | undefined): string; /** * Format the number using the given options. * * @param {import('./types.js').FormatOptions} [options] * @see https://mikemcl.github.io/bignumber.js/#toFor */ toFormat(options?: import("./types.js").FormatOptions): string; toAttoFIL(): this; toFemtoFIL(): Token; toPicoFIL(): Token; toNanoFIL(): Token; toMicroFIL(): Token; toMilliFIL(): Token; toFIL(): Token; toBigInt(): bigint; toBytes(): Uint8Array<ArrayBuffer>; /** @type {boolean} */ [symbol]: boolean; } export type Value = number | string | BigNumber.Instance | bigint | Token; import BigNumber from 'bignumber.js'; declare const symbol: unique symbol; export {}; //# sourceMappingURL=token.d.ts.map