import { DotNetwork, DotNetworkId, EthNetwork, EthNetworkId, IChaindataNetworkProvider, IChaindataTokenProvider, SolNetwork, SolNetworkId } from "@talismn/chaindata-provider"; import { Account, PublicClient, WalletClient } from "viem"; import { Rpc, RpcTransport, SolanaRpcApi } from "@solana/kit"; //#region src/dot/IChainConnectorDot.d.ts /** Callback signature for RPC subscriptions (error-first, matches the legacy polkadot-js ProviderInterfaceCallback) */ export type SubscriptionCallback = (error: Error | null, result: any) => void; export interface IChainConnectorDot { send(chainId: DotNetworkId, method: string, params: unknown[], isCacheable?: boolean, extraOptions?: { expectErrors?: boolean; }): Promise; subscribe(chainId: DotNetworkId, subscribeMethod: string, responseMethod: string, params: unknown[], callback: SubscriptionCallback, timeout?: number | false): Promise<(unsubscribeMethod: string) => void>; reset(chainId: DotNetworkId): Promise; } //#endregion //#region src/dot/ChainConnectorDot.d.ts export declare class ChainConnectionError extends Error { type: "CHAIN_CONNECTION_ERROR"; chainId: string; constructor(chainId: string, options?: ErrorOptions); } export declare class StaleRpcError extends Error { type: "STALE_RPC_ERROR"; chainId: string; constructor(chainId: string, options?: ErrorOptions); } /** * ChainConnector provides an interface similar to a websocket JSON-RPC provider, but with three points of difference: * * 1. ChainConnector methods all accept a `chainId` instead of an array of RPCs. RPCs are then fetched internally from chaindata. * 2. ChainConnector creates only one socket connection per chain (via polkadot-api's ws-provider, which handles * endpoint rotation, reconnection and stale-socket detection) and ensures that all downstream requests to a chain * share that connection. * 3. Subscriptions return a callable `unsubscribe` method instead of an id, and are automatically re-established * when the provider reconnects (possibly to another endpoint). * * Additionally, when run on the clientside of a dapp where `window.talismanSub` is available, instead of spinning up new websocket * connections this class will forward all requests through to the wallet backend - where another instance of this class will * handle the websocket connections. */ export declare class ChainConnectorDot implements IChainConnectorDot { #private; constructor(chaindataChainProvider: IChaindataNetworkProvider); send(chainId: DotNetworkId, method: string, params: unknown[], _isCacheable?: boolean | undefined, extraOptions?: { /** * Set to `true` if this query is speculative, i.e. if on some chains it's expected that it will raise a wasm unreachable error of the form: * * 4003: Client error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed * * By setting expectErrors to true, this method won't pollute the logs with errors we intend to have happen. * An example use case of this is when you plan to catch the wasm unreachable error on chains that don't support the query, and then fall back * to another query or perhaps an empty result. */ expectErrors?: boolean; }): Promise; subscribe(chainId: DotNetworkId, subscribeMethod: string, responseMethod: string, params: unknown[], callback: SubscriptionCallback, timeout?: number | false): Promise<(unsubscribeMethod: string) => void>; /** * Kills and recreates the connection for a chain, if any. * Useful after changing a network's rpcs to make sure the new list is applied for further requests. * Active subscriptions are automatically re-established on the new connection. */ reset(chainId: DotNetworkId): Promise; /** Sends a request over a connection, throwing `Error("TIMEOUT")` if no response arrives in time */ private request; /** Issues the subscribe request and routes notifications to the subscription callback */ private startSubscription; /** * Get (or create) the shared connection for a chain. * * The caller must call releaseConnection with the returned SocketUserId once they are finished with it. */ private acquireConnection; private createConnection; private handleStatusChange; private releaseConnection; private destroyConnection; private getGenesisHash; /** continues to generate a random number until it finds one which is not present in the exclude list */ private getExclusiveRandomId; /** generates a random number */ private getRandomId; private getTalismanSub; } //#endregion //#region src/dot/ChainConnectorDotStub.d.ts export declare class ChainConnectorDotStub implements IChainConnectorDot { #private; constructor(network: DotNetwork); send(_chainId: DotNetworkId, method: string, params: unknown[], _isCacheable?: boolean): Promise; subscribe(_chainId: DotNetworkId, subscribeMethod: string, _responseMethod: string, params: unknown[], callback: SubscriptionCallback, timeout?: number | false): Promise<(unsubscribeMethod: string) => void>; reset(): Promise; destroy(): void; } //#endregion //#region src/eth/IChainConnectorEth.d.ts export interface IChainConnectorEth { getPublicClientForEvmNetwork: (evmNetworkId: EthNetworkId) => Promise; getWalletClientForEvmNetwork: (evmNetworkId: EthNetworkId, account?: `0x${string}` | Account) => Promise; clearRpcProvidersCache: (evmNetworkId?: EthNetworkId) => void; } //#endregion //#region src/eth/ChainConnectorEth.d.ts export declare class ChainConnectorEth implements IChainConnectorEth { #private; constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider); getPublicClientForEvmNetwork(evmNetworkId: EthNetworkId): Promise; getWalletClientForEvmNetwork(evmNetworkId: EthNetworkId, account?: `0x${string}` | Account): Promise; clearRpcProvidersCache(evmNetworkId?: EthNetworkId): void; } //#endregion //#region src/eth/ChainConnectorEthStub.d.ts export declare class ChainConnectorEthStub implements IChainConnectorEth { #private; constructor(network: EthNetwork); getPublicClientForEvmNetwork(): Promise; getWalletClientForEvmNetwork(_networkId: EthNetworkId, account?: `0x${string}` | Account): Promise; clearRpcProvidersCache(): void; } //#endregion //#region src/sol/getSolRpc.d.ts export type SolRpc = Rpc; export declare const getSolTransport: (_networkId: SolNetworkId, rpcs: string[]) => RpcTransport; export declare const getSolRpc: (networkId: SolNetworkId, rpcs: string[]) => SolRpc; //#endregion //#region src/sol/IChainConnectorSol.d.ts export interface IChainConnectorSol { getRpc: (networkId: SolNetworkId) => Promise; /** Raw JSON-RPC transport, used by the background script to relay frontend RPC requests */ getTransport: (networkId: SolNetworkId) => Promise; } //#endregion //#region src/sol/ChainConnectorSol.d.ts export declare class ChainConnectorSol implements IChainConnectorSol { #private; constructor(chaindataProvider: IChaindataNetworkProvider & IChaindataTokenProvider); getTransport(networkId: SolNetworkId): Promise; getRpc(networkId: SolNetworkId): Promise; /** Drops cached transports/rpcs so the next call re-reads the network's rpcs from chaindata */ clearRpcProvidersCache(networkId?: SolNetworkId): void; } //#endregion //#region src/sol/ChainConnectorSolStub.d.ts export declare class ChainConnectorSolStub implements IChainConnectorSol { #private; constructor(network: Pick); getRpc(): Promise; getTransport(): Promise; } //#endregion //# sourceMappingURL=index.d.ts.map