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 { BaseStorageQuery } from '../storage/index.js'; import type { ApiOptions, BlockExplorer, IChainSpec, ISubstrateClientAt } from '../types.js'; import { BaseSubstrateClient } from './BaseSubstrateClient.js'; /** * @name LegacyClient * @description Promised-based API Client for Polkadot & Substrate * * Initialize API instance and interact with substrate-based network * ```typescript * import { Dedot } from 'dedot'; * import type { PolkadotApi } from '@dedot/chaintypes/polkadot'; * * const run = async () => { * const api = await LegacyClient.new('wss://rpc.polkadot.io'); * * // Call rpc `state_getMetadata` to fetch raw scale-encoded metadata and decode it. * const metadata = await api.rpc.state.getMetadata(); * console.log('Metadata:', metadata); * * // Query on-chain storage * const address = '14...'; * const balance = await api.query.system.account(address); * console.log('Balance:', balance); * * * // Subscribe to on-chain storage changes * const unsub = await api.query.system.number((blockNumber) => { * console.log(`Current block number: ${blockNumber}`); * }); * * // Get pallet constants * const ss58Prefix = api.consts.system.ss58Prefix; * console.log('Polkadot ss58Prefix:', ss58Prefix) * * // await unsub(); * // await api.disconnect(); * } * * run().catch(console.error); * ``` */ export declare class LegacyClient// prettier-end-here extends BaseSubstrateClient { #private; protected _blockExplorer?: BlockExplorer; /** * Use factory methods (`create`, `new`) to create `Dedot` instances. * * @param options */ constructor(options: ApiOptions | JsonRpcProvider); /** * Factory method to create a new Dedot instance * * @param options */ static create(options: ApiOptions | JsonRpcProvider): Promise>; /** * Alias for __LegacyClient.create__ * * @param options */ static new(options: ApiOptions | JsonRpcProvider): Promise>; protected beforeDisconnect(): Promise; /** * Initialize APIs before usage */ protected doInitialize(): Promise; protected cleanUp(): void; protected setMetadata(metadata: Metadata): Promise; /** * @description Entry-point for inspecting constants (parameter types) for all pallets (modules). * * ```typescript * const ss58Prefix = api.consts.system.ss58Prefix; * console.log('ss58Prefix:', ss58Prefix) * ``` */ get consts(): ChainApi['consts']; /** * @description Entry-point for executing query to on-chain storage. * * ```typescript * const balance = await api.query.system.account(
); * console.log('Balance:', balance); * ``` */ get query(): ChainApi['query']; /** * @description Entry-point for inspecting errors from metadata */ get errors(): ChainApi['errors']; /** * @description Entry-point for inspecting events from metadata */ get events(): ChainApi['events']; /** * @description Entry-point for executing runtime api * * ```typescript * // Get account nonce * const nonce = await api.call.accountNonceApi.accountNonce(
); * * // Query transaction payment info * const tx = api.tx.balances.transferKeepAlive(
, 2_000_000_000_000n); * const queryInfo = await api.call.transactionPaymentApi.queryInfo(tx.toU8a(), tx.length); * ``` */ get call(): ChainApi['call']; protected callAt(hash?: BlockHash): ChainApi['call']; get view(): ChainApi['view']; /** * @description Entry-point for executing on-chain transactions * * ```typescript * // Make a transfer balance transaction * api.tx.balances.transferKeepAlive(
, ) * .signAndSend(, { signer }, ({ status }) => { * console.log('Transaction status', status.type); * }); * ``` */ get tx(): ChainApi['tx']; get block(): BlockExplorer; get chainSpec(): IChainSpec; /** * Create a new API instance at a specific block hash * This is useful when we want to inspect the state of the chain at a specific block hash * * @param hash */ at(hash: BlockHash): Promise>; protected getStorageQuery(): BaseStorageQuery; sendTx(tx: HexString | Extrinsic, callback?: Callback>): TxUnsub; toTx(tx: HexString | Uint8Array | Extrinsic | IRuntimeTxCall): ChainSubmittableExtrinsic; }