import { UserImporterOptions, ImportCandidate } from 'ipfs-unixfs-importer';
import * as ipfs_unixfs_importer_types_src_types from 'ipfs-unixfs-importer/types/src/types';
import * as Web3 from 'web3';
import * as bn_js from 'bn.js';
import { AxiosResponse } from 'axios';

declare type Content = ReadableStream | Buffer | string;
interface ImageHasher {
    options: UserImporterOptions;
    content: ImportCandidate;
}
interface NonImageHasher {
    options: UserImporterOptions;
    content: Uint8Array;
}
interface HashedImage {
    path: string | undefined;
    cid: string;
    size: number;
}

declare class Utils {
    static importDataContractABI(pathStr: string): Record<string, unknown>;
    static importEthContractABI(pathStr: string): Record<string, unknown>;
    static utf8ToHex(utf8Str: string): string;
    static padRight(hexStr: string, size: number): string;
    static hexToUtf8(hexStr: string): string;
    static keccak256(utf8Str: string): string;
    static isBN(number: number): boolean;
    static toBN(number: number, base: number): bn_js;
    static BN(): typeof bn_js;
    static checkStrLen(str: string, maxLen: number, minLen?: number): void;
    static wait(milliseconds: number): Promise<void>;
    static isFQDN(url: string): boolean;
    static isHttps(url: string): boolean;
    static isHealthy(url: string): Promise<any>;
    static formatOptionalMultihash(multihash: string): string;
    static decodeMultihash(multihash: string): {
        digest: string;
        hashFn: number;
        size: number;
    };
    /**
     * Given a digest value (written on chain, obtained through AudiusABIDecoder.decodeMethod),
     * convert back to a IFPS CIDv0
     * @param multihashDigest digest value from decodeMultihash
     * @returns String CID value
     */
    static encodeMultihash(multihashDigest: string): string;
    static parseDataFromResponse(response: AxiosResponse): any;
    static configureWeb3(web3Provider: string, chainNetworkId: string, requiresAccount?: boolean): Promise<false | Web3.default>;
    static get zeroAddress(): string;
    static isZeroAddress(address: string): boolean;
    static makeUuid(): string;
    /**
     * Decodes a string id into an int. Returns null if an invalid ID.
     */
    static decodeHashId(id: string): number | null;
    /**
     * Encodes an int to a string based hashid
     */
    static encodeHashId(id: number | null): string | null;
    /**
     * If `promise` responds before `timeoutMs`,
     * this function returns its response; else rejects with `timeoutMessage`
     */
    static racePromiseWithTimeout(promise: Promise<void>, timeoutMs: number, timeoutMessage: string): Promise<unknown>;
    static fileHasher: {
        convertNanosToMillis(nanoSeconds: bigint): bigint;
        initImageHasher(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, options: ipfs_unixfs_importer_types_src_types.UserImporterOptions): ImageHasher;
        initNonImageHasher(content: Uint8Array, options: ipfs_unixfs_importer_types_src_types.UserImporterOptions): NonImageHasher;
        convertToBuffer(content: Content, logger: any): Promise<Buffer>;
        hashNonImages(content: Uint8Array, options?: ipfs_unixfs_importer_types_src_types.UserImporterOptions): Promise<string>;
        hashImages(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, options?: ipfs_unixfs_importer_types_src_types.UserImporterOptions): Promise<HashedImage[]>;
        generateNonImageCid(content: Content, logger?: any): Promise<string>;
        generateImageCids(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, logger?: any): Promise<HashedImage[]>;
    };
}

declare global {
    interface Window {
        grecaptcha: {
            ready: (callback: () => void) => Promise<void>;
            execute: (siteKey: string, config: {
                action: string;
            }) => Promise<string>;
        };
    }
}

export { Utils };
