import { BlockHash, type Extrinsic, Metadata } from '@dedot/codecs'; import type { JsonRpcProvider } from '@dedot/providers'; import { Callback, ChainSubmittableExtrinsic, GenericSubstrateApi, IRuntimeTxCall, ISubmittableResult, TxUnsub } from '@dedot/types'; import { HexString } from '@dedot/utils'; import type { SubstrateApi } from '../chaintypes/index.js'; import { Archive, ChainHead, ChainSpec, PinnedBlock } from '../json-rpc/index.js'; import { BaseStorageQuery } from '../storage/index.js'; import type { ApiOptions, BlockExplorer, DedotClientEvent, ISubstrateClientAt, TxBroadcaster } from '../types.js'; import { BaseSubstrateClient } from './BaseSubstrateClient.js'; /** * @name V2Client * @description New promised-based API Client for Polkadot & Substrate based on JSON-RPC V2 * * __Unstable, use with caution.__ */ export declare class V2Client// prettier-end-here extends BaseSubstrateClient { #private; protected _chainHead?: ChainHead; protected _chainSpec?: ChainSpec; protected _archive?: Archive; protected _txBroadcaster?: TxBroadcaster; protected _blockExplorer?: BlockExplorer; /** * Use factory methods (`create`, `new`) to create `V2Client` instances. * * @param options */ constructor(options: ApiOptions | JsonRpcProvider); /** * Factory method to create a new V2Client instance * * @param options */ static create(options: ApiOptions | JsonRpcProvider): Promise>; /** * Alias for __V2Client.create__ * * @param options */ static new(options: ApiOptions | JsonRpcProvider): Promise>; get chainSpec(): ChainSpec; get chainHead(): ChainHead; get archive(): Archive | undefined; get txBroadcaster(): TxBroadcaster; /** * Initialize APIs before usage */ protected doInitialize(): Promise; protected subscribeRuntimeUpgrades(): void; protected onRuntimeUpgrade: (block: PinnedBlock) => Promise; protected setMetadata(metadata: Metadata): Promise; protected beforeDisconnect(): Promise; protected cleanUp(): void; /** * @description Clear local cache, API at-block cache, and ChainHead cache * @param keepMetadataCache Keep the metadata cache, only clear other caches. */ clearCache(keepMetadataCache?: boolean): Promise; get query(): ChainApi['query']; get view(): ChainApi['view']; get call(): ChainApi['call']; protected callAt(blockHash?: BlockHash): ChainApi['call']; get tx(): ChainApi['tx']; get block(): BlockExplorer; /** * Get a new API instance at a specific block hash * Supports both pinned blocks (via ChainHead) and historical blocks (via Archive fallback) * * @param hash */ at(hash: BlockHash): Promise>; protected getStorageQuery(): BaseStorageQuery; sendTx(tx: HexString | Extrinsic, callback?: Callback>): TxUnsub; toTx(tx: HexString | Uint8Array | Extrinsic | IRuntimeTxCall): ChainSubmittableExtrinsic; }