///
import { BigNumber } from 'ethers';
import BN from 'bn.js';
import { ChainState } from './interfaces/chainState';
import { ChainJsPlugin, ChainJsPluginOptions } from './interfaces/plugin';
import { ChainEntityName, IndexedObject, ChainEndpoint } from './models';
export declare function isAString(value: any): boolean;
export declare function isADate(value: any): boolean;
export declare function isABoolean(value: any): boolean;
export declare function isANumber(value: any): boolean;
export declare function isAUint8Array(obj: any): boolean;
export declare function isABuffer(value: any): boolean;
export declare function isNullOrEmpty(obj: any): boolean;
export declare function isAnObject(obj: any): boolean;
/**
* The reviver function passed into JSON.parse to implement custom type conversions.
* If the value is a previously stringified buffer we convert it to a Buffer,
* If its an object of numbers, we convert to UInt8Array {"0":2,"1":209,"2":8 ...}
* otherwise return the value
*/
export declare function jsonParseComplexObjectReviver(key: string, value: any): any;
/** restore object from JSON serialization (i.e. recrete Buffer properties) */
export declare function jsonParseAndRevive(value: any): any;
export declare function getArrayIndexOrNull(array: any[], index: number): any;
export declare function stringifySafe(obj: any): any;
export declare function parseSafe(string: string): any;
/** Checks that string starts with 0x - removes it if it does */
export declare function removeHexPrefix(value: string): string;
export declare function toBuffer(data: any, encoding?: BufferEncoding): Buffer;
export declare function bufferToString(buffer: Buffer, encoding?: BufferEncoding): string;
export declare function bufferToUint8Array(buffer: Buffer): Uint8Array;
export declare function uint8ArraysAreEqual(array1: Uint8Array, array2: Uint8Array): boolean;
/** filter values in array down to an array of a single, uniques value
* e.g. if array = [{value:'A', other}, {value:'B'}, {value:'A', other}]
* distinct(array, uniqueKey:'value') => ['A','B']
*/
export declare function distinctValues(values: Array, uniqueKey: string): any[];
/** combine one array into another but only include unique values */
export declare function addUniqueToArray(array: T[], values: T[]): T[];
/** Typescript Typeguard to verify that the value is in the enumType specified */
export declare function isInEnum(enumType: T, value: any): value is T[keyof T];
export declare function isBase64Encoded(value: any): boolean;
export declare function isBase64EncodedAndNotUtf(value: any): boolean;
export declare function getUniqueValues(array: T[]): any[];
export declare function trimTrailingChars(value: string, charToTrim: string): string;
export declare const removeEmptyValuesInJsonObject: (obj: {
[x: string]: any;
}) => void;
export declare const notImplemented: () => never;
export declare const notSupported: (description: string) => never;
/**
* Returns an the first value from the array if only 1 exists, otherwise returns null
*/
export declare function getFirstValueIfOnlyOneExists(array: any[]): any;
/** Always returns true (unless empty */
export declare function isValidChainEntityName(str: ChainEntityName | string): str is ChainEntityName;
/** Coerce string into ChainEntityName */
export declare function toChainEntityName(name: string): ChainEntityName;
export declare function fetchWrapper(fetchService: any, globalOptions?: {}): (url: any, options?: {}) => Promise;
/** Conver an array to a JSON object e.g. [{'key1':value1}, {'key2':value2}] => {{'key1':value1}, {'key2':value2}} */
export declare function arrayToObject(array: IndexedObject[]): any;
/** returns the required header from the headers attached to chain endpoint. For ex: headers: [{'x-api-key': '...'}] */
export declare function getHeaderValueFromEndpoint(endpoint: ChainEndpoint, headerName: string): any;
/** returns the number of decimal places in a number (expressed as a string) - supports exponential notiation
* e.g. '.05' = 2, '25e-100'= 100. '2.5e-99' = 100 */
export declare function getDecimalPlacesFromString(num?: string): number;
/** Checks if string is a valid hex string
*
*/
export declare function isHexString(value: any): Boolean;
/** If input is an object of numbers {'0',123, '1',456}, converts to UInt8Array
* Otherwise, input value is just returned
*/
export declare function ensureJsonArrayOfIntsConvertedToUInt8Array(value: any | Uint8Array): any;
/** Converts a hex string to a unit8 byte array */
export declare function hexStringToByteArray(value: string): Uint8Array;
/** Convert a byte array to hex string */
export declare function byteArrayToHexString(value: Uint8Array): string;
/** Convert a byte array array to hex string array */
export declare function byteArrayArrayToHexStringArray(value: Uint8Array[]): string[];
/** Checks that string starts with 0x - appends if not
* Also converts hex chars to lowercase for consistency
*/
export declare function ensureHexPrefix(value: string): string;
/** Convert a byte array to hex string */
export declare function bufferToHexString(value: Buffer): string;
/** Convert a byte array to hex string */
export declare function bufferToPrefixedHexString(value: Buffer): string;
/**
* Converts a `Buffer` to a `Number`.
* @param buf `Buffer` object to convert
* @throws If the input number exceeds 53 bits.
*/
export declare function bufferToInt(buf: Buffer): number;
export declare function utf8StringToHexString(value: string): string;
/** convert a decimal number string to a hex string - supports long decimals (uses BN)
* e.g. '16' => '0xA' */
export declare function decimalToHexString(value: string): string;
/** Return true if value is a hexidecimal encoded string (is prefixed by 0x) */
export declare function hasHexPrefix(value: any): boolean;
/** makes sure that the public key has a 0x prefix - but drops '04' at front of public key if exists */
export declare function ensureHexPrefixForPublicKey(value: string): string;
/** Converts a decimal string to a hex string
* If already hex string, returns same value */
export declare function toHexStringIfNeeded(value: any): any;
/** Accepts string or Buffer
* If string - converts (Utf8 OR Hex string) into Buffer
* If buffer - just returns it */
export declare function convertUtf8OrHexStringToBuffer(data: string | Buffer): Buffer;
/** Whether array is exactly length of 1 */
export declare function isArrayLengthOne(array: any[]): boolean;
export declare function objectHasProperty(obj: object, propertyName: string): boolean;
/** if value is empty (e.g. empty buffer), returns null, otherwise return the value passed-in */
export declare function nullifyIfEmpty(value: any): any;
/** convert to Buffer if needed from hex, base64, or other encoded value */
export declare function toBufferIfNeededFromAny(value: any): any;
/** Attempts to infer the precision of a token (eg ERC20) by counting digits after the decimal places in a number value string
* e.g. '0.120' = 3 - If no decimal places in the string, then returns default precision for token i.e. 0
*/
export declare function inferTokenPrecisionFromValue(value?: string): number;
/** Convert a value with decimal places to a large integer string
* shift decimal places left by precision specified - e.g. (precision=18) ‘200.3333’ -> '200333300000000000000'
* base: default is base 10 (string value is a decimal number)
* if no precision is provided, infers precision by number of digits after decimal e.g. ‘200.3300’ = 4
*/
export declare function toTokenValueString(value: string, base: number, precision: number): string;
/** Convert a value shifted to have no decimal places back to include decimal places
* shift decimal places right by precision specified - e.g. (precision=18) '200333300000000000000' -> ‘200.3333’
* base: default is base 10 (string value is a decimal number)
* if no precision is provided, it CANT be infered from the value - so we use DEFAULT_TOKEN_PRECISION (i.e. 0)
*/
export declare function fromTokenValueString(value: string, base: number, precision: number): string;
/** object is of type BN (big number) */
export declare function isABN(value: any): boolean;
/** convert a balance and decimals into a long value string
* e.g. BN('200333300000000000000'), precision=18 -> '200.333' */
export declare function bigNumberToString(value: BN | BigNumber, precision: number): string;
/** Convert a string with decimal places, or number or BN to a large integer string
* default is base 10 (string value is a decimal number) */
export declare function toBigIntegerString(value: string | number | BN, base?: number): string;
/** Call the callback once for each item in the array and await for each to finish in turn */
export declare function asyncForEach(array: any[], callback: (item: any, index: number, array: any[]) => Promise): Promise;
/** Generates a SHA256 hash from a string value
* Returns a hex-encoded result */
export declare function createSha256Hash(value: string): string;
export declare function bigIntToUint8Array(bn: number): Uint8Array;
export declare function uInt8ArrayToInteger(value: Uint8Array): number;
/** Installs a plugin. If options provided, also runs plugIn.init(options) */
export declare function initializePlugin(chainState: ChainState, plugin: ChainJsPlugin, options?: ChainJsPluginOptions): Promise;
/** Throws if a plugin of the same type has already been installed */
export declare function assertPluginTypeNotAlreadyInstalled(plugin: ChainJsPlugin, installedPlugins: ChainJsPlugin[]): void;
/** Pause exectuion for nn miliseconds */
export declare function sleep(ms: number): Promise;
/** Parses a stringified string into a JSON object
* Returns Null if parse fails */
export declare function tryParseJSON(value: any): any;
export declare function convertStringifiedOrObjectToObject(value: object | string): object;