import { BigNumber, ContractFactory, ContractReceipt, ContractTransaction, PopulatedTransaction, Signer, providers } from 'ethers'; import { Logger } from 'pino'; import { ContractFactory as ZKSyncContractFactory, Provider as ZKSyncProvider } from 'zksync-ethers'; import { ZKSyncArtifact } from '@hyperlane-xyz/core'; import { Address } from '@hyperlane-xyz/utils'; import { ChainMetadataManager } from '../metadata/ChainMetadataManager.js'; import { ChainMetadata, EthJsonRpcBlockParameterTag } from '../metadata/chainMetadataTypes.js'; import { ChainMap, ChainName, ChainNameOrId } from '../types.js'; import { AnnotatedEV5Transaction } from './ProviderType.js'; import { ProviderBuilderFn } from './providerBuilders.js'; type Provider = providers.Provider | ZKSyncProvider; export interface MultiProviderOptions { logger?: Logger; providers?: ChainMap; providerBuilder?: ProviderBuilderFn; signers?: ChainMap; } export interface SendTransactionOptions { /** * Number of confirmations to wait for, or a block tag like "finalized" or "safe". * If not provided, uses chain metadata's blocks.confirmations (default: 1). */ waitConfirmations?: number | EthJsonRpcBlockParameterTag; /** * Timeout in ms when waiting for confirmations. * Default: max(2 × confirmations × estimateBlockTime, 30s) when available, otherwise 300000 (5 min). */ timeoutMs?: number; } /** * A utility class to create and manage providers and signers for multiple chains * @typeParam MetaExt - Extra metadata fields for chains (such as contract addresses) */ export declare class MultiProvider extends ChainMetadataManager { readonly options: MultiProviderOptions; readonly providers: ChainMap; readonly providerBuilder: ProviderBuilderFn; signers: ChainMap; useSharedSigner: boolean; readonly logger: Logger; /** * Create a new MultiProvider with the given chainMetadata, * or the SDK's default metadata if not provided */ constructor(chainMetadata: ChainMap>, options?: MultiProviderOptions); addChain(metadata: ChainMetadata): void; extendChainMetadata(additionalMetadata: ChainMap): MultiProvider; /** * Get an Ethers provider for a given chain name or domain id */ tryGetProvider(chainNameOrId: ChainNameOrId): Provider | null; /** * Get an Ethers provider for a given chain name or domain id * @throws if chain's metadata has not been set */ getProvider(chainNameOrId: ChainNameOrId): Provider; /** * Sets an Ethers provider for a given chain name or domain id * @throws if chain's metadata has not been set */ setProvider(chainNameOrId: ChainNameOrId, provider: Provider): Provider; /** * Sets Ethers providers for a set of chains * @throws if chain's metadata has not been set */ setProviders(providers: ChainMap): void; /** * Get an Ethers signer for a given chain name or domain id * If signer is not yet connected, it will be connected */ tryGetSigner(chainNameOrId: ChainNameOrId): Signer | null; /** * Get an Ethers signer for a given chain name or domain id * If signer is not yet connected, it will be connected * @throws if chain's metadata or signer has not been set */ getSigner(chainNameOrId: ChainNameOrId): Signer; /** * Get an Ethers signer for a given chain name or domain id * @throws if chain's metadata or signer has not been set */ getSignerAddress(chainNameOrId: ChainNameOrId): Promise
; /** * Sets an Ethers Signer for a given chain name or domain id * @throws if chain's metadata has not been set or shared signer has already been set */ setSigner(chainNameOrId: ChainNameOrId, signer: Signer): Signer; /** * Sets Ethers Signers for a set of chains * @throws if chain's metadata has not been set or shared signer has already been set */ setSigners(signers: ChainMap): void; /** * Gets the Signer if it's been set, otherwise the provider */ tryGetSignerOrProvider(chainNameOrId: ChainNameOrId): Signer | Provider | null; /** * Gets the Signer if it's been set, otherwise the provider * @throws if chain metadata has not been set */ getSignerOrProvider(chainNameOrId: ChainNameOrId): Signer | Provider; /** * Sets Ethers Signers to be used for all chains * Any subsequent calls to getSigner will return given signer * Setting sharedSigner to null clears all signers */ setSharedSigner(sharedSigner: Signer | null): Signer | null; /** * Create a new MultiProvider from the intersection * of current's chains and the provided chain list */ intersect(chains: ChainName[], throwIfNotSubset?: boolean): { intersection: ChainName[]; result: MultiProvider; }; /** * Get a block explorer URL for given chain's address */ tryGetExplorerAddressUrl(chainNameOrId: ChainNameOrId, address?: string): Promise; /** * Get the latest block range for a given chain's RPC provider */ getLatestBlockRange(chainNameOrId: ChainNameOrId, rangeSize?: number): Promise<{ fromBlock: number; toBlock: number; }>; /** * Get the transaction overrides for a given chain name or domain id * @throws if chain's metadata has not been set */ getTransactionOverrides(chainNameOrId: ChainNameOrId): Partial; /** * Wait for deploy tx to be confirmed * @throws if chain's metadata or signer has not been set or tx fails */ handleDeploy(chainNameOrId: ChainNameOrId, factory: F, params: Parameters, artifact?: ZKSyncArtifact): Promise>>; /** * Resolve a core typechain factory to its Tron-compiled equivalent * wrapped with TronContractFactory for deployment. * * @hyperlane-xyz/tron-sdk exports typechain factories with class names identical to * @hyperlane-xyz/core (e.g. Mailbox__factory), generated from the same Solidity source. * They share the same ABIs and deploy signatures, differing only in TVM bytecode. * * Looks up the tron factory by factory.constructor.name and wraps it * with TronContractFactory to handle Tron's deployment flow. * @throws if no matching Tron factory is found */ resolveTronFactory(factory: F): Promise; /** * Wait for given tx to be confirmed * @param options - Optional configuration including waitConfirmations and timeoutMs * @throws if chain's metadata or signer has not been set, tx fails, block tag unsupported, or timeout exceeded */ handleTx(chainNameOrId: ChainNameOrId, tx: ContractTransaction | Promise, options?: SendTransactionOptions): Promise; /** * Wait for a transaction to be included in a block with the given tag (e.g., "finalized", "safe"). * Polls until the tagged block number >= transaction block number. * @param timeoutMs - Timeout in ms (default: 300000 = 5 min) * @throws if block tag is unsupported by the RPC provider or timeout exceeded * @internal - Prefer using handleTx with waitConfirmations parameter. */ waitForBlockTag(chainNameOrId: ChainNameOrId, response: ContractTransaction, blockTag: EthJsonRpcBlockParameterTag, timeoutMs?: number): Promise; /** * Populate a transaction's fields using signer address and overrides * @throws if chain's metadata has not been set or tx fails */ prepareTx(chainNameOrId: ChainNameOrId, tx: PopulatedTransaction, from?: string): Promise; /** * Estimate gas for given tx * @throws if chain's metadata has not been set or tx fails */ estimateGas(chainNameOrId: ChainNameOrId, tx: PopulatedTransaction, from?: string): Promise; /** * Send a transaction and wait for confirmation * @param options - Optional configuration including waitConfirmations * @throws if chain's metadata or signer has not been set or tx fails */ sendTransaction(chainNameOrId: ChainNameOrId, txProm: AnnotatedEV5Transaction | Promise, options?: SendTransactionOptions): Promise; /** * Creates a MultiProvider using the given signer for all test networks */ static createTestMultiProvider(params?: { signer?: Signer; provider?: Provider; }, chains?: ChainName[]): MultiProvider; } export {}; //# sourceMappingURL=MultiProvider.d.ts.map