import { SignOptions } from '@polkadot/keyring/types';
import { FunctionMetadataLatest } from './interfaces/metadata';
import { Address, Balance, Call, EcdsaSignature, Ed25519Signature, Index, Sr25519Signature } from './interfaces/runtime';
import BN from 'bn.js';
import { InterfaceRegistry } from './interfaceRegistry';
import { Signer } from "../api/types";
export * from './codec/types';
export declare type ArrayElementType<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer ElementType> ? ElementType : never;
export declare type BareOpts = boolean | Record<string, boolean>;
export declare type InterfaceTypes = keyof InterfaceRegistry;
export interface CallBase {
    callIndex: Uint8Array;
    meta: FunctionMetadataLatest;
    method: string;
    section: string;
    toJSON: () => any;
}
export interface CallFunction extends CallBase {
    (...args: any[]): Call;
}
export declare type Calls = Record<string, CallFunction>;
export declare type ModulesWithCalls = Record<string, Calls>;
export interface IKeyringPair {
    address: string;
    publicKey: Uint8Array;
    sign: (data: Uint8Array, options?: SignOptions) => Uint8Array;
}
interface CodecArgArray extends Array<CodecArg> {
}
export declare type CodecArg = Codec | BN | boolean | string | Uint8Array | boolean | number | string | undefined | CodecArgArray | CodecArgObject;
export declare type Callback<T> = (result: T) => void | Promise<void>;
interface CodecArgObject {
    [index: string]: CodecArg;
}
export declare type AnyFunction = (...args: any[]) => any;
export declare type AnyNumber = BN | Uint8Array | number | string;
export declare type AnyString = string | string;
export declare type AnyU8a = Uint8Array | number[] | string;
export interface AnyJsonObject extends Record<string, AnyJson> {
}
export interface AnyJsonArray extends Array<AnyJson> {
}
export declare type AnyJson = string | number | boolean | null | undefined | AnyJsonObject | AnyJsonArray;
/**
 * @name Codec
 * @description
 * The base Codec interface. All types implement the interface provided here. Additionally
 * implementors can add their own specific interfaces and helpers with getters and functions.
 * The Codec Base is however required for operating as an encoding/decoding layer
 */
export interface Codec {
    /**
     * @description The length of the value when encoded as a Uint8Array
     */
    readonly encodedLength: number;
    /**
     * @description Returns a hash of the value
     */
    readonly hash: IHash;
    /**
     * @description Checks if the value is an empty value
     */
    readonly isEmpty: boolean;
    /**
     * @description The registry associated with this object
     */
    readonly registry: Registry;
    /**
     * @description Compares the value of the input to see if there is a match
     */
    eq(other?: any): boolean;
    /**
     * @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
     */
    toHex(isLe?: boolean): string;
    /**
     * @description Converts the Object to JSON, typically used for RPC transfers
     */
    toJSON(): AnyJson;
    /**
     * @description Returns the base runtime type name for this instance
     */
    toRawType(): string;
    /**
     * @description Returns the string representation of the value
     */
    toString(): string;
    /**
     * @description Encodes the value as a Uint8Array as per the SCALE specifications
     * @param isBare true when the value has none of the type-specific prefixes (internal)
     */
    toU8a(isBare?: BareOpts): Uint8Array;
}
export interface IU8a extends Uint8Array, Codec {
    bitLength(): number;
    toJSON(): any;
}
export interface IHash extends IU8a {
}
export interface ICompact<T> extends Codec {
    toBn(): BN;
    toNumber(): number;
    unwrap(): T;
}
export declare type CodecTo = 'toHex' | 'toJSON' | 'toString' | 'toU8a';
export interface Constructor<T = Codec> {
    new (registry: Registry, ...value: any[]): T;
}
export declare type ConstructorDef<T = Codec> = Record<string, Constructor<T>>;
export declare type RegistryTypes = Record<string, Constructor | string | Record<string, string> | {
    _enum: string[] | Record<string, string | null>;
} | {
    _set: Record<string, number>;
}>;
export interface RuntimeVersionInterface {
    readonly apis: any[];
    readonly authoringVersion: BN;
    readonly implName: String;
    readonly implVersion: BN;
    readonly specName: String;
    readonly specVersion: BN;
}
export interface SignatureOptions {
    blockHash: AnyU8a;
    era?: IExtrinsicEra;
    genesisHash: AnyU8a;
    nonce: AnyNumber;
    runtimeVersion: RuntimeVersionInterface;
    signer?: Signer;
    tip?: AnyNumber;
}
export declare type ArgsDef = Record<string, Constructor>;
export declare type ITuple<Sub extends Codec[]> = Sub & Codec;
export interface IMethod extends Codec {
    readonly args: Codec[];
    readonly argsDef: ArgsDef;
    readonly callIndex: Uint8Array;
    readonly data: Uint8Array;
    readonly hash: IHash;
    readonly hasOrigin: boolean;
    readonly meta: FunctionMetadataLatest;
}
interface ExtrinsicSignatureBase {
    readonly isSigned: boolean;
    readonly era: IExtrinsicEra;
    readonly nonce: ICompact<Index>;
    readonly signature: EcdsaSignature | Ed25519Signature | Sr25519Signature;
    readonly signer: Address;
    readonly tip: ICompact<Balance>;
}
export interface ExtrinsicPayloadValue {
    blockHash: AnyU8a;
    era: AnyU8a | IExtrinsicEra;
    genesisHash: AnyU8a;
    method: AnyU8a | IMethod;
    nonce: AnyNumber;
    specVersion: AnyNumber;
    tip: AnyNumber;
}
export interface IExtrinsicSignature extends ExtrinsicSignatureBase, Codec {
    addSignature(signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: Uint8Array | string): IExtrinsicSignature;
    sign(method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature;
    signFake(method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature;
}
export interface IExtrinsicEra extends Codec {
    asImmortalEra: Codec;
    asMortalEra: Codec;
}
interface IExtrinsicSignable<T> {
    addSignature(signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): T;
    sign(account: IKeyringPair, options: SignatureOptions): T;
    signFake(address: Address | Uint8Array | string, options: SignatureOptions): T;
}
export interface IExtrinsicImpl extends IExtrinsicSignable<IExtrinsicImpl>, Codec {
    readonly method: Call;
    readonly signature: IExtrinsicSignature;
    readonly version: number;
}
export interface IExtrinsic extends IExtrinsicSignable<IExtrinsic>, ExtrinsicSignatureBase, IMethod {
    readonly length: number;
    readonly method: Call;
    readonly type: number;
    readonly version: number;
}
export interface SignerPayloadJSON {
    /**
     * @description The ss-58 encoded address
     */
    address: string;
    /**
     * @description The checkpoint hash of the block, in hex
     */
    blockHash: string;
    /**
     * @description The checkpoint block number, in hex
     */
    blockNumber: string;
    /**
     * @description The era for this transaction, in hex
     */
    era: string;
    /**
     * @description The genesis hash of the chain, in hex
     */
    genesisHash: string;
    /**
     * @description The encoded method (with arguments) in hex
     */
    method: string;
    /**
     * @description The nonce for this transaction, in hex
     */
    nonce: string;
    /**
     * @description The current spec version for  the runtime
     */
    specVersion: string;
    /**
     * @description The tip for this transaction, in hex
     */
    tip: string;
    /**
     * @description The version of the extrinsic we are dealing with
     */
    version: number;
}
export interface SignerPayloadRawBase {
    /**
     * @description The hex-encoded data for this request
     */
    data: string;
    /**
     * @description The type of the contained data
     */
    type?: 'bytes' | 'payload';
}
export interface SignerPayloadRaw extends SignerPayloadRawBase {
    /**
     * @description The ss-58 encoded address
     */
    address: string;
    /**
     * @description The type of the contained data
     */
    type: 'bytes' | 'payload';
}
export interface ISignerPayload {
    toPayload(): SignerPayloadJSON;
    toRaw(): SignerPayloadRaw;
}
export interface RegistryMetadataText extends String, Codec {
    setOverride(override: string): void;
}
export interface RegistryMetadataCallArg {
    name: RegistryMetadataText;
    type: RegistryMetadataText;
}
export interface RegistryMetadataCall {
    args: RegistryMetadataCallArg[];
    name: RegistryMetadataText;
    toJSON(): string | AnyJsonObject;
}
export interface RegistryMetadataCalls {
    isSome: boolean;
    unwrap(): RegistryMetadataCall[];
}
export interface RegistryError {
    documentation: string[];
    index: number;
    name: string;
    section: string;
}
export interface RegistryMetadataError {
    name: String;
    documentation: String[];
}
export declare type RegistryMetadataErrors = RegistryMetadataError[];
export interface RegistryMetadataEvent {
    args: any[];
    name: RegistryMetadataText;
}
export interface RegistryMetadataEvents {
    isSome: boolean;
    unwrap(): RegistryMetadataEvent[];
}
export interface RegistryMetadataExtrinsic {
    version: BN;
    signedExtensions: String[];
}
export interface RegistryMetadataModule {
    calls: RegistryMetadataCalls;
    errors: RegistryMetadataErrors;
    events: RegistryMetadataEvents;
    name: RegistryMetadataText;
}
export interface RegistryMetadataLatest {
    modules: RegistryMetadataModule[];
    extrinsic: RegistryMetadataExtrinsic;
}
export interface RegistryMetadata {
    asLatest: RegistryMetadataLatest;
}
export interface Registry {
    findMetaCall(callIndex: Uint8Array): CallFunction;
    findMetaError(errorIndex: Uint8Array): any;
    findMetaEvent(eventIndex: Uint8Array): Constructor<any>;
    get<T extends Codec = Codec>(name: string): Constructor<T> | undefined;
    getOrThrow<T extends Codec = Codec>(name: string, msg?: string): Constructor<T>;
    getSignedExtensionExtra(): Record<string, InterfaceTypes>;
    getSignedExtensionTypes(): Record<string, InterfaceTypes>;
    hasClass(name: string): boolean;
    hasDef(name: string): boolean;
    hasType(name: string): boolean;
    register(type: Constructor | RegistryTypes): void;
    register(name: string, type: Constructor): void;
    register(arg1: string | Constructor | RegistryTypes, arg2?: Constructor): void;
    setMetadata(metadata: RegistryMetadata): void;
}
