import { BlockHash, Option } from '@dedot/codecs'; import { ArchiveStorageResult, PaginatedStorageQuery } from '@dedot/types/json-rpc'; import { HexString } from '@dedot/utils'; import { IJsonRpcClient } from '../../types.js'; import { JsonRpcGroup, JsonRpcGroupOptions } from './JsonRpcGroup.js'; /** * @name Archive * Archive JSON-RPC methods for accessing historical blockchain data. * Functions with the `archive` prefix allow obtaining the state of the chain * at any point in the present or in the past. * * JSON-RPC V2: https://paritytech.github.io/json-rpc-interface-spec/api/archive.html */ export declare class Archive extends JsonRpcGroup { #private; constructor(client: IJsonRpcClient, options?: Partial); /** * Retrieves the body (list of transactions) of a given block. * Returns an array of strings containing the hexadecimal-encoded SCALE-codec-encoded * transactions in that block. If no block with that hash is found, null. * * @param hash - The block hash (optional, defaults to current finalized block) * @returns Array of transaction hashes or null if block not found * * @example * ```typescript * // Get transactions from current finalized block * const transactions = await archive.body(); * * // Get transactions from specific block * const transactions = await archive.body('0x1234...'); * ``` */ body(hash?: BlockHash): Promise>>; /** * Get the chain's genesis hash. * Returns a string containing the hexadecimal-encoded hash of the genesis block of the chain. * This value is cached after the first call. * * @returns The genesis block hash */ genesisHash(): Promise; /** * Get the block's header. * Returns a string containing the hexadecimal-encoded SCALE-codec encoding header of the block. * * @param hash - The block hash (optional, defaults to current finalized block) * @returns The encoded block header or null if block not found * * @example * ```typescript * // Get header of current finalized block * const header = await archive.header(); * * // Get header of specific block * const header = await archive.header('0x1234...'); * ``` */ header(hash?: BlockHash): Promise>; /** * Get the height of the current finalized block. * Returns an integer height of the current finalized block of the chain. * * @returns The height of the finalized block */ finalizedHeight(): Promise; /** * Get the hash of the current finalized block. * Returns a string containing the hexadecimal-encoded hash of the current finalized block. * This is a convenience method that combines finalizedHeight() and hashByHeight(). * * @returns The hash of the current finalized block */ finalizedHash(): Promise; /** * Get the hashes of blocks from the given height. * Returns an array (possibly empty) of strings containing hexadecimal-encoded hashes of block headers. * * Note: For heights <= finalized height, there is guaranteed to be one block. * For heights > finalized height, there may be zero, one or multiple blocks depending on forks. * * @param height - The block height * @returns Array of block hashes at the given height */ hashByHeight(height: number): Promise>; /** * Call into the Runtime API at a specified block's state. * * @param func - The runtime API function to call * @param params - The parameters for the function call (SCALE-encoded) * @param hash - The block hash (optional, defaults to current finalized block) * @returns The result of the runtime call * * @example * ```typescript * // Call Core_version on current finalized block * const version = await archive.call('Core_version', '0x'); * * // Call Core_version on specific block * const version = await archive.call('Core_version', '0x', '0x1234...'); * ``` */ call(func: string, params: HexString, hash?: BlockHash): Promise; /** * Returns storage entries at a specific block's state. * This method collects all storage events and returns them as a single result. * * @param items - Array of storage queries with optional pagination * @param childTrie - Optional child trie key * @param hash - The block hash (optional, defaults to current finalized block) * @returns Storage results array * * @example * ```typescript * // Query storage from current finalized block * const results = await archive.storage([{ key: '0x1234', type: 'value' }]); * * // Query storage from specific block * const results = await archive.storage([{ key: '0x1234', type: 'value' }], null, '0xabcd...'); * ``` */ storage(items: Array, childTrie?: HexString | null, hash?: BlockHash): Promise; /** * Clears the internal cache used for storing archive query results. * This can be useful for memory management or when you want to force fresh data retrieval. * * @example * ```typescript * // Clear all cached results * archive.clearCache(); * ``` */ clearCache(): void; }