UNPKG

@hiero-ledger/sdk

Version:
211 lines (210 loc) 7.25 kB
/** * Takes any param and returns false if null or undefined. * * @param {any | null | undefined} variable * @returns {boolean} */ export function isNonNull(variable: any | null | undefined): boolean; /** * Takes any param and returns true if param variable and type are the same. * * @param {any | null | undefined} variable * @param {any | null | undefined} type * @returns {boolean} */ export function isType(variable: any | null | undefined, type: any | null | undefined): boolean; /** * Takes any param and returns true if param is not null and of type Uint8Array. * * @param {any | null | undefined} variable * @returns {boolean} */ export function isUint8Array(variable: any | null | undefined): boolean; /** * Takes any param and returns true if param is not null and of type Number. * * @param {any | null | undefined} variable * @returns {boolean} */ export function isNumber(variable: any | null | undefined): boolean; /** * Takes any param and returns true if param is not null and of type BigNumber. * * @param {any | null | undefined} variable * @returns {boolean} */ export function isBigNumber(variable: any | null | undefined): boolean; /** * Takes any param and returns true if param is not null and of type BigNumber. * * @param {any | null | undefined} variable * @returns {boolean} */ export function isLong(variable: any | null | undefined): boolean; /** * Takes any param and returns true if param is not null and of type string. * * @param {any | null | undefined} variable * @returns {boolean} */ export function isString(variable: any | null | undefined): boolean; /** * Takes any param and returns true if param is not null and type string or Uint8Array. * * @param {any | null | undefined} variable * @returns {boolean} */ export function isStringOrUint8Array(variable: any | null | undefined): boolean; /** * Takes an address as `Uint8Array` and returns whether or not this is a long-zero address * * @param {Uint8Array} address * @returns {boolean} */ export function isLongZeroAddress(address: Uint8Array): boolean; /** * Takes any param and returns false if null or undefined. * * @template {Long | Hbar} T * @param {T} variable * @returns {T} */ export function requireNotNegative<T extends Long | Hbar>(variable: T): T; /** * Takes any param and throws custom error if null or undefined. * * @param {any} variable * @returns {object} */ export function requireNonNull(variable: any): object; /** * Takes any param and throws custom error if params are not same type. * * @param {any | null | undefined} variable * @param {any | null | undefined} type * @returns {object} */ export function requireType(variable: any | null | undefined, type: any | null | undefined): object; /** * Takes any param and throws custom error if non BigNumber. * * @param {any | null | undefined} variable * @returns {BigNumber} */ export function requireBigNumber(variable: any | null | undefined): BigNumber; /** * Takes any param and throws custom error if non BigNumber. * * @param {any | null | undefined} variable * @returns {Long} */ export function requireLong(variable: any | null | undefined): Long; /** * Takes any param and throws custom error if non string. * * @param {any | null | undefined} variable * @returns {string} */ export function requireString(variable: any | null | undefined): string; /** * Takes any param and throws custom error if non Uint8Array. * * @param {any | null | undefined} variable * @returns {Uint8Array} */ export function requireUint8Array(variable: any | null | undefined): Uint8Array; /** * Takes any param and throws custom error if non Uint8Array. * * @param {any | null | undefined} variable * @returns {number} */ export function requireNumber(variable: any | null | undefined): number; /** * Takes any param and throws custom error if null or undefined and not a string or Uint8Array. * * @param {any | null | undefined} variable * @returns {string | Uint8Array} */ export function requireStringOrUint8Array(variable: any | null | undefined): string | Uint8Array; /** * Converts number or string to BigNumber. * * @param {any | null | undefined} variable * @returns {BigNumber} */ export function convertToBigNumber(variable: any | null | undefined): BigNumber; /** * Converts Array of Numbers or Strings to Array of BigNumbers. * * @param {any | null | undefined} variable * @returns {Array<BigNumber>} */ export function convertToBigNumberArray(variable: any | null | undefined): Array<BigNumber>; /** * @param {*} variable * @returns {number} */ export function convertToNumber(variable: any): number; /** * Creates a DataView on top of an Uint8Array that could be or not be pooled, ensuring that we don't get out of bounds. * * @param {Uint8Array | Int8Array} arr * @param {number | undefined} offset * @param {number | undefined} length * @returns {DataView} */ export function safeView(arr: Uint8Array | Int8Array, offset?: number | undefined, length?: number | undefined): DataView; /** * @param {any} a * @param {any} b * @param {Set<string>=} ignore * @returns {boolean} */ export function compare(a: any, b: any, ignore?: Set<string> | undefined): boolean; /** * https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array * * @template T * @param {Array<T>} array */ export function shuffle<T>(array: Array<T>): void; /** * @param {Uint8Array} array1 * @param {Uint8Array} array2 * @returns {boolean} */ export function arrayEqual(array1: Uint8Array, array2: Uint8Array): boolean; /** * @description Function that delays an execution for a given time (in milliseconds) * @param {number} ms * @returns {Promise<void>} */ export function wait(ms: number): Promise<void>; /** * Converts a SCREAMING_SNAKE_CASE string to PascalCase * @param {string} name - The string to convert * @returns {string} The converted PascalCase string */ export function screamingSnakeToPascalCase(name: string): string; /** * @typedef {import("./Hbar.js").default} Hbar */ /** * Utility Error Messages */ export const REQUIRE_NON_NULL_ERROR: "This value cannot be null | undefined."; export const REQUIRE_STRING_ERROR: "This value must be a string."; export const REQUIRE_UINT8ARRAY_ERROR: "This value must be a Uint8Array."; export const REQUIRE_STRING_OR_UINT8ARRAY_ERROR: "This value must be a string or Uint8Array."; export const REQUIRE_NUMBER_ERROR: "This value must be a Number."; export const REQUIRE_BIGNUMBER_ERROR: "This value must be a BigNumber."; export const REQUIRE_ARRAY_ERROR: "The provided variable must be an Array."; export const REQUIRE_LONG_ERROR: "This value must be a Long."; export const REQUIRE_TYPE_ERROR: "The provided variables are not matching types."; export const FUNCTION_CONVERT_TO_BIGNUMBER_ERROR: "This value must be a String, Number, or BigNumber to be converted."; export const FUNCTION_CONVERT_TO_NUMBER_ERROR: "This value must be a String, Number, or BigNumber to be converted."; export const FUNCTION_CONVERT_TO_NUMBER_PARSE_ERROR: "Unable to parse given variable. Returns NaN."; export type Hbar = import("./Hbar.js").default; import Long from "long"; import BigNumber from "bignumber.js";