import { BlockHash, Bytes, Hash, Metadata, Option, PrefixedStorageKey, RuntimeVersion, StorageData, StorageKey } from '@dedot/codecs'; import { Callback, GenericJsonRpcApis, Unsub } from '@dedot/types'; import { MigrationStatusResult, ReadProof, StorageChangeSet, TraceBlockResponse } from './types/index.js'; export interface StateJsonRpcApis extends GenericJsonRpcApis { /** * Call a method from the runtime API at a block's state. * * @rpcname state_call * @param {string} method * @param {Bytes} data * @param {BlockHash} at **/ state_call: (method: string, data: Bytes, at?: BlockHash) => Promise; /** * Returns proof of storage for child key entries at a specific block state. * * @rpcname state_getChildReadProof * @param {PrefixedStorageKey} childStorageKey * @param {Array} keys * @param {BlockHash} at **/ state_getChildReadProof: (childStorageKey: PrefixedStorageKey, keys: Array, at?: BlockHash) => Promise; /** * Returns the keys with prefix, leave empty to get all the keys. * * @rpcname state_getKeys * @deprecated: Please use `getKeysPaged` with proper paging support * @param {StorageKey} prefix * @param {BlockHash} at **/ state_getKeys: (prefix: StorageKey, at?: BlockHash) => Promise>; /** * Returns the keys with prefix with pagination support. Up to `count` keys will be returned. If `start_key` is passed, return next keys in storage in lexicographic order. * * @rpcname state_getKeysPaged * @param {Option} prefix * @param {number} count * @param {StorageKey} startKey * @param {BlockHash} at **/ state_getKeysPaged: (prefix: Option, count: number, startKey?: StorageKey, at?: BlockHash) => Promise>; /** * Returns the runtime metadata * * @rpcname state_getMetadata * @param {BlockHash} at **/ state_getMetadata: (at?: BlockHash) => Promise; /** * Returns the keys with prefix, leave empty to get all the keys * * @rpcname state_getPairs * @deprecated: Please use `getKeysPaged` with proper paging support * @param {StorageKey} prefix * @param {BlockHash} at **/ state_getPairs: (prefix: StorageKey, at?: BlockHash) => Promise>; /** * Returns proof of storage entries at a specific block's state. * * @rpcname state_getReadProof * @param {Array} keys * @param {BlockHash} at **/ state_getReadProof: (keys: Array, at?: BlockHash) => Promise; /** * Get the runtime version. * * @rpcname state_getRuntimeVersion **/ state_getRuntimeVersion: (at?: BlockHash) => Promise; /** * Returns a storage entry at a specific block's state. * * @rpcname state_getStorage * @param {StorageKey} key * @param {BlockHash} at **/ state_getStorage: (key: StorageKey, at?: BlockHash) => Promise>; /** * Returns the hash of a storage entry at a block's state. * * @rpcname state_getStorageHash * @param {StorageKey} key * @param {BlockHash} at **/ state_getStorageHash: (key: StorageKey, at?: BlockHash) => Promise>; /** * Returns the hash of a storage entry at a block's state. * * @rpcname state_getStorageSize * @param {StorageKey} key * @param {BlockHash} at **/ state_getStorageSize: (key: StorageKey, at?: BlockHash) => Promise>; /** * Query historical storage entries (by key) starting from a block given as the second parameter. NOTE: The first returned result contains the initial state of storage for all keys. Subsequent values in the vector represent changes to the previous state (diffs). WARNING: The time complexity of this query is O(|keys|*dist(block, hash)), and the memory complexity is O(dist(block, hash)) -- use with caution. * * @rpcname state_queryStorage * @param {Array} keys * @param {Hash} fromBlock * @param {BlockHash} at **/ state_queryStorage: (keys: Array, fromBlock: Hash, at?: BlockHash) => Promise>; /** * Query storage entries (by key) at a block hash given as the second parameter. NOTE: Each StorageChangeSet in the result corresponds to exactly one element -- the storage value under an input key at the input block hash. * * @rpcname state_queryStorageAt * @param {Array} keys * @param {BlockHash} at **/ state_queryStorageAt: (keys: Array, at?: BlockHash) => Promise>; /** * New runtime version subscription * * @subscription state_runtimeVersion, state_subscribeRuntimeVersion, state_unsubscribeRuntimeVersion **/ state_subscribeRuntimeVersion: (callback: Callback) => Promise; /** * Subscribes to storage changes for the provided keys * * @subscription state_storage, state_subscribeStorage, state_unsubscribeStorage * @param {Array} keys **/ state_subscribeStorage: (keys: Array, callback: Callback) => Promise; /** * The `traceBlock` RPC provides a way to trace the re-execution of a single block, collecting Spans and Events from both the client and the relevant WASM runtime. * * @rpcname state_traceBlock * @param {Hash} block * @param {Option} targets * @param {Option} storage_keys * @param {Option} methods **/ state_traceBlock: (block: Hash, targets: Option, storage_keys: Option, methods: Option) => Promise; /** * Check current migration state. This call is performed locally without submitting any transactions. Thus executing this won't change any state. Nonetheless it is a VERY costy call that should be only exposed to trusted peers. * * @rpcname state_trieMigrationStatus * @param {BlockHash} at **/ state_trieMigrationStatus: (at?: BlockHash) => Promise; }