///
import type { Observable } from 'rxjs';
import type { AugmentedCall, QueryableCalls } from '@polkadot/api-base/types';
import type { RpcInterface } from '@polkadot/rpc-core/types';
import type { Metadata, Text } from '@polkadot/types';
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
import type { AnyFunction, Codec, DefinitionCallNamed, DefinitionRpc, DefinitionRpcSub, DefinitionsCall, DefinitionsCallEntry, DetectCodec, Registry, RegistryTypes } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types';
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecorateMethod, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types/index.js';
import type { AllDerives } from '../util/decorate.js';
import type { VersionedRegistry } from './types.js';
import { BehaviorSubject } from 'rxjs';
import { RpcCore } from '@polkadot/rpc-core';
import { BN } from '@polkadot/util';
import { Events } from './Events.js';
interface FullDecoration {
createdAt?: Uint8Array | undefined;
decoratedApi: ApiDecoration;
decoratedMeta: DecoratedMeta;
}
export declare abstract class Decorate extends Events {
#private;
protected __phantom: BN;
protected _type: ApiTypes;
protected _call: QueryableCalls;
protected _consts: QueryableConsts;
protected _derive?: ReturnType['_decorateDerive']>;
protected _errors: DecoratedErrors;
protected _events: DecoratedEvents;
protected _extrinsics?: SubmittableExtrinsics;
protected _extrinsicType: number;
protected _genesisHash?: Hash;
protected _isConnected: BehaviorSubject;
protected _isReady: boolean;
protected _query: QueryableStorage;
protected _queryMulti?: QueryableStorageMulti;
protected _rpc?: DecoratedRpc;
protected _rpcCore: RpcCore & RpcInterface;
protected _runtimeMap: Record;
protected _runtimeChain?: Text;
protected _runtimeMetadata?: Metadata;
protected _runtimeVersion?: RuntimeVersion;
protected _rx: ApiInterfaceRx;
protected readonly _options: ApiOptions;
/**
* This is the one and only method concrete children classes need to implement.
* It's a higher-order function, which takes one argument
* `method: Method extends (...args: any[]) => Observable`
* (and one optional `options`), and should return the user facing method.
* For example:
* - For ApiRx, `decorateMethod` should just be identity, because the input
* function is already an Observable
* - For ApiPromise, `decorateMethod` should return a function that takes all
* the parameters from `method`, adds an optional `callback` argument, and
* returns a Promise.
*
* We could easily imagine other user-facing interfaces, which are simply
* implemented by transforming the Observable to Stream/Iterator/Kefir/Bacon
* via `decorateMethod`.
*/
protected _decorateMethod: DecorateMethod;
/**
* @description Create an instance of the class
*
* @param options Options object to create API instance or a Provider instance
*
* @example
*
*
* ```javascript
* import Api from '@polkadot/api/promise';
*
* const api = new Api().isReady();
*
* api.rpc.subscribeNewHeads((header) => {
* console.log(`new block #${header.number.toNumber()}`);
* });
* ```
*/
constructor(options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod);
abstract at(blockHash: Uint8Array | string, knownVersion?: RuntimeVersion): Promise>;
/**
* @description Return the current used registry
*/
get registry(): Registry;
/**
* @description Creates an instance of a type as registered
*/
createType(type: K, ...params: unknown[]): DetectCodec;
/**
* @description Register additional user-defined of chain-specific types in the type registry
*/
registerTypes(types?: RegistryTypes): void;
/**
* @returns `true` if the API operates with subscriptions
*/
get hasSubscriptions(): boolean;
/**
* @returns `true` if the API decorate multi-key queries
*/
get supportMulti(): boolean;
protected _emptyDecorated(registry: Registry, blockHash?: Uint8Array): ApiDecoration;
protected _createDecorated(registry: VersionedRegistry, fromEmpty: boolean, decoratedApi: ApiDecoration | null, blockHash?: Uint8Array): FullDecoration;
protected _injectMetadata(registry: VersionedRegistry, fromEmpty?: boolean): void;
/**
* @deprecated
* backwards compatible endpoint for metadata injection, may be removed in the future (However, it is still useful for testing injection)
*/
injectMetadata(metadata: Metadata, fromEmpty?: boolean, registry?: Registry): void;
private _decorateFunctionMeta;
protected _filterRpc(methods: string[], additional: Record>): void;
protected _filterRpcMethods(exposed: string[]): void;
private _rpcSubmitter;
protected _decorateRpc(rpc: RpcCore & RpcInterface, decorateMethod: DecorateMethod, input?: Partial>): DecoratedRpc;
protected _addRuntimeDef(result: DefinitionsCall, additional?: DefinitionsCall): void;
protected _getRuntimeDefs(registry: Registry, specName: Text, chain?: Text | string): [string, DefinitionsCallEntry[]][];
protected _decorateCalls({ registry, runtimeVersion: { apis, specName, specVersion } }: VersionedRegistry, decorateMethod: DecorateMethod, blockHash?: Uint8Array | string | null): QueryableCalls;
protected _decorateCall(registry: Registry, def: DefinitionCallNamed, stateCall: (method: string, bytes: Uint8Array) => Observable, decorateMethod: DecorateMethod): AugmentedCall;
protected _decorateMulti(decorateMethod: DecorateMethod): QueryableStorageMulti;
protected _decorateMultiAt(atApi: ApiDecoration, decorateMethod: DecorateMethod, blockHash: Uint8Array | string): QueryableStorageMulti;
protected _decorateExtrinsics({ tx }: DecoratedMeta, decorateMethod: DecorateMethod): SubmittableExtrinsics;
private _decorateExtrinsicEntry;
protected _decorateStorage({ query, registry }: DecoratedMeta, decorateMethod: DecorateMethod, blockHash?: Uint8Array): QueryableStorage;
private _decorateStorageEntry;
private _decorateStorageEntryAt;
private _queueStorage;
private _decorateStorageCall;
private _retrieveMulti;
private _retrieveMapKeys;
private _retrieveMapKeysPaged;
private _retrieveMapEntries;
private _retrieveMapEntriesPaged;
protected _decorateDeriveRx(decorateMethod: DecorateMethod): AllDerives<'rxjs'>;
protected _decorateDerive(decorateMethod: DecorateMethod): AllDerives;
/**
* Put the `this.onCall` function of ApiRx here, because it is needed by
* `api._rx`.
*/
protected _rxDecorateMethod: (method: Method) => Method;
}
export {};