import { ILogger } from "../onchain/types/logger.js"; import { ChainId } from "../model/primitives.js"; import { DataResponse } from "../model/response.js"; import "../model/index.js"; import { EntityMerger, ListMerger } from "./utils/types.js"; import "./utils/index.js"; import { EnsureFreshChains, NamespaceOptions } from "./types.js"; //#region src/sdk/AbstractNamespace.d.ts /** * One read of a combined namespace: the same query against each source, plus * the policy that turns the two answers into one. * * @typeParam Onchain - On-chain source namespace. * @typeParam Offchain - Backend source namespace. * @typeParam T - Payload type of the read. **/ export interface MergedQuery { fromChain: (source: Onchain) => Promise>; fromBackend: (source: Offchain) => Promise>; merge: ListMerger | EntityMerger; /** * Chains the on-chain leg touches, so only they are revalidated before it; * omitted when the read fans out to every chain. **/ chainIds?: readonly ChainId[]; } /** * Base class of every {@link GearboxSDK} namespace: holds the two source * namespaces, exposes each on its own, and runs merged reads over both. * * @typeParam Onchain - On-chain source namespace, e.g. * `MultichainOpportunitiesService`. * @typeParam Offchain - Backend source namespace, e.g. `OffchainOpportunities`. **/ export declare abstract class AbstractNamespace { #private; /** * How far the backend may lag the chain and still serve a chain. **/ protected readonly maxOffchainLagSeconds: number; protected readonly logger?: ILogger; /** * The SDK's loading policy, awaited before every on-chain leg: attached, and * the touched chains no older than the SDK allows. **/ protected readonly ensureFresh?: EnsureFreshChains; protected constructor(name: string, onchain: Onchain | undefined, offchain: Offchain | undefined, options: NamespaceOptions); /** * The on-chain source namespace on its own — every read of it attaches and * revalidates like a merged read does, so a consumer showing the two sources * separately still gets the SDK's loading policy. Throws * {@link SourceUnavailableError} in `offchain` mode. **/ get onchain(): Onchain; /** * The backend source namespace on its own. Throws * {@link SourceUnavailableError} in `onchain` mode. **/ get offchain(): Offchain; /** * Asks both sources at once and merges what came back, failing only when no * chain was served at all. **/ protected merged(action: string, query: MergedQuery): Promise>; } //#endregion