import { ChainId } from "../../model/primitives.js"; import { DataResponse } from "../../model/response.js"; import "../../model/index.js"; import { NetworkType } from "../chain/chains.js"; import { PluginsMap } from "../plugins/types.js"; import "../plugins/index.js"; import { OnchainSDK } from "../OnchainSDK.js"; import { MultichainSDK } from "../MultichainSDK.js"; //#region src/onchain/base/MultichainConstruct.d.ts /** * Block one chain's data was read at, and is reported at. **/ export interface ChainBlock { blockNumber: bigint; /** * Unix seconds of {@link blockNumber}. **/ timestamp: bigint; } /** * Where the block a request is read at comes from: the SDK's loaded snapshot, * or a freshly fetched head. **/ export type ChainBlockSource = "state" | "latest"; /** * {@link ChainBlockSource}, or an explicit height. Only single-chain requests * accept a height. **/ export type ChainBlockPin = ChainBlockSource | bigint; /** * Describes a request that is sent to every queried chain. * * @typeParam T - Payload returned by a single chain. * @typeParam Plugins - Map of attached plugin types. **/ export interface ChainQueryProps { /** * Chains to query. All configured chains when omitted. **/ chainIds?: ChainId[]; /** * Action description used in warnings, e.g. `"get liquidatable accounts"`. **/ label: string; /** * @defaultValue `"state"` **/ block?: ChainBlockSource; /** * Request sent to a single chain, at the resolved block of that chain. **/ run: (sdk: OnchainSDK, block: ChainBlock) => Promise; } /** * Describes a request that is sent to exactly one chain. * * @typeParam T - Payload returned by the chain. * @typeParam Plugins - Map of attached plugin types. **/ export interface ChainQueryOneProps { /** * Chain to query, as a network label or a chain id. **/ network: NetworkType | ChainId; /** * @defaultValue `"state"` **/ block?: ChainBlockPin; /** * Request sent to the chain, at its resolved block. **/ run: (sdk: OnchainSDK, block: ChainBlock) => Promise; } /** * @internal * Base class for services that fan out over the chains of a * {@link MultichainSDK}, the cross-chain counterpart of {@link SDKConstruct}. * * A fan-out soft-fails: a chain that rejects is logged as a warning and * contributes no payload, while the remaining chains still return their rows. * A single-chain request throws instead. * * @typeParam Plugins - Map of attached plugin types. **/ export declare abstract class MultichainConstruct { #private; protected readonly sdk: MultichainSDK; constructor(sdk: MultichainSDK); /** * Fans out a request that returns a list, concatenating the lists of all * chains that responded successfully. **/ protected queryChains(props: ChainQueryProps): Promise>; /** * Fans out a request with no payload, reporting the outcome of every queried * chain in `meta.chains`. **/ protected runChains(props: ChainQueryProps): Promise>; /** * Runs a request against one chain and reports the block it was read at. * Throws when the chain is not configured, not attached, or rejects the read. **/ protected queryChain({ network, block, run }: ChainQueryOneProps): Promise>; } //#endregion