// Copyright 2017-2021 @axiasolar/types authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { SignOptions } from '@axiasolar/keyring/types'; import type { BN } from '@axiasolar/util'; import type { FunctionMetadataLatest, StorageEntryMetadataLatest } from '../interfaces/metadata'; import type { Hash } from '../interfaces/runtime'; import type { AnyTuple, ArgsDef, Codec } from './codec'; export interface ICompact extends Codec { toBigInt (): bigint; toBn (): BN; toNumber (): number; unwrap (): T; } export interface IEnum extends Codec { readonly defIndexes: number[]; readonly defKeys: string[]; readonly index: number; readonly isBasic: boolean readonly type: string; readonly value: Codec; toNumber (): number; } export interface IMap extends Map, Codec {} export interface INumber extends Codec { bitLength (): number; toBigInt (): bigint; toBn (): BN; toNumber (): number; } export interface IOption extends Codec { readonly isNone: boolean; readonly isSome: boolean; readonly value: Codec; unwrap (): T; unwrapOr (other: O): T | O; unwrapOrDefault (): T; } export interface IResult extends IEnum { readonly asErr: E; readonly asOk: O; readonly isErr: boolean; readonly isOk: boolean; } export interface ISet extends Set, Codec { readonly strings: string[]; } export interface IStruct extends Map, Codec { readonly defKeys: string[]; getAtIndex (index: number): Codec toArray (): Codec[]; } export type ITuple = T & Codec; export interface IU8a extends Uint8Array, Codec { readonly isAscii: boolean; bitLength (): number; toHuman (isExtended?: boolean): any; toJSON (): any; toUtf8 (): string; } export interface IVec extends Array, Codec { toArray (): T[]; } export interface IKeyringPair { readonly address: string; readonly addressRaw: Uint8Array; readonly publicKey: Uint8Array; sign: (data: Uint8Array, options?: SignOptions) => Uint8Array; } export interface IMethod extends Codec { readonly args: A; readonly argsDef: ArgsDef; readonly callIndex: Uint8Array; readonly data: Uint8Array; readonly hash: Hash; readonly meta: FunctionMetadataLatest; is: (tx: IMethod) => tx is IMethod; } export interface IRuntimeVersion { // eslint-disable-next-line @typescript-eslint/no-explicit-any readonly apis: any[]; readonly authoringVersion: BN; // eslint-disable-next-line @typescript-eslint/ban-types readonly implName: String; readonly implVersion: BN; // eslint-disable-next-line @typescript-eslint/ban-types readonly specName: String; readonly specVersion: BN; readonly transactionVersion: BN; } export interface IStorageKey { readonly args: A; readonly meta: StorageEntryMetadataLatest | undefined; readonly method: string | undefined; readonly outputType: string; readonly section: string | undefined; is: (key: IStorageKey) => key is IStorageKey; }