UNPKG

@hyperlane-xyz/sdk

Version:

The official SDK for the Hyperlane Network

600 lines 21.4 kB
import { ethers, providers } from 'ethers'; import { Logger } from 'pino'; import { z } from 'zod'; import { Address, ParsedMessage } from '@hyperlane-xyz/utils'; import { DerivedHookConfig } from '../hook/types.js'; import { BaseMetadataBuilder } from '../ism/metadata/builder.js'; import { DerivedIsmConfig } from '../ism/types.js'; import { MultiProvider } from '../providers/MultiProvider.js'; import { ChainMap, ChainName } from '../types.js'; import { HyperlaneCore } from './HyperlaneCore.js'; import { DispatchedMessage } from './types.js'; export declare const RelayerCacheSchema: z.ZodObject<{ hook: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodIntersection<z.ZodUnion<[z.ZodString, z.ZodObject<{ owner: z.ZodString; ownerOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; } & { type: z.ZodLiteral<"protocolFee">; beneficiary: z.ZodString; maxProtocolFee: z.ZodString; protocolFee: z.ZodString; }, "strip", z.ZodTypeAny, { type: "protocolFee"; owner: string; protocolFee: string; beneficiary: string; maxProtocolFee: string; ownerOverrides?: Record<string, string> | undefined; }, { type: "protocolFee"; owner: string; protocolFee: string; beneficiary: string; maxProtocolFee: string; ownerOverrides?: Record<string, string> | undefined; }>, z.ZodObject<{ owner: z.ZodString; ownerOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; } & { paused: z.ZodBoolean; } & { type: z.ZodLiteral<"pausableHook">; }, "strip", z.ZodTypeAny, { type: "pausableHook"; owner: string; paused: boolean; ownerOverrides?: Record<string, string> | undefined; }, { type: "pausableHook"; owner: string; paused: boolean; ownerOverrides?: Record<string, string> | undefined; }>, z.ZodObject<{ owner: z.ZodString; ownerOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; } & { type: z.ZodLiteral<"opStackHook">; nativeBridge: z.ZodString; destinationChain: z.ZodString; }, "strip", z.ZodTypeAny, { type: "opStackHook"; owner: string; nativeBridge: string; destinationChain: string; ownerOverrides?: Record<string, string> | undefined; }, { type: "opStackHook"; owner: string; nativeBridge: string; destinationChain: string; ownerOverrides?: Record<string, string> | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"merkleTreeHook">; }, "strip", z.ZodTypeAny, { type: "merkleTreeHook"; }, { type: "merkleTreeHook"; }>, z.ZodObject<{ owner: z.ZodString; ownerOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; } & { type: z.ZodLiteral<"interchainGasPaymaster">; beneficiary: z.ZodString; oracleKey: z.ZodString; overhead: z.ZodRecord<z.ZodString, z.ZodNumber>; oracleConfig: z.ZodRecord<z.ZodString, z.ZodObject<{ gasPrice: z.ZodString; tokenExchangeRate: z.ZodString; } & { tokenDecimals: z.ZodOptional<z.ZodNumber>; } & { typicalCost: z.ZodOptional<z.ZodObject<{ handleGasAmount: z.ZodNumber; totalGasAmount: z.ZodNumber; totalUsdCost: z.ZodNumber; }, "strip", z.ZodTypeAny, { handleGasAmount: number; totalGasAmount: number; totalUsdCost: number; }, { handleGasAmount: number; totalGasAmount: number; totalUsdCost: number; }>>; }, "strip", z.ZodTypeAny, { gasPrice: string; tokenExchangeRate: string; tokenDecimals?: number | undefined; typicalCost?: { handleGasAmount: number; totalGasAmount: number; totalUsdCost: number; } | undefined; }, { gasPrice: string; tokenExchangeRate: string; tokenDecimals?: number | undefined; typicalCost?: { handleGasAmount: number; totalGasAmount: number; totalUsdCost: number; } | undefined; }>>; }, "strip", z.ZodTypeAny, { type: "interchainGasPaymaster"; owner: string; beneficiary: string; oracleKey: string; overhead: Record<string, number>; oracleConfig: Record<string, { gasPrice: string; tokenExchangeRate: string; tokenDecimals?: number | undefined; typicalCost?: { handleGasAmount: number; totalGasAmount: number; totalUsdCost: number; } | undefined; }>; ownerOverrides?: Record<string, string> | undefined; }, { type: "interchainGasPaymaster"; owner: string; beneficiary: string; oracleKey: string; overhead: Record<string, number>; oracleConfig: Record<string, { gasPrice: string; tokenExchangeRate: string; tokenDecimals?: number | undefined; typicalCost?: { handleGasAmount: number; totalGasAmount: number; totalUsdCost: number; } | undefined; }>; ownerOverrides?: Record<string, string> | undefined; }>, z.ZodType<import("../hook/types.js").DomainRoutingHookConfig, z.ZodTypeDef, import("../hook/types.js").DomainRoutingHookConfig>, z.ZodType<import("../hook/types.js").FallbackRoutingHookConfig, z.ZodTypeDef, import("../hook/types.js").FallbackRoutingHookConfig>, z.ZodType<import("../hook/types.js").AmountRoutingHookConfig, z.ZodTypeDef, import("../hook/types.js").AmountRoutingHookConfig>, z.ZodType<import("../hook/types.js").AggregationHookConfig, z.ZodTypeDef, import("../hook/types.js").AggregationHookConfig>, z.ZodObject<{ type: z.ZodLiteral<"arbL2ToL1Hook">; arbSys: z.ZodString; bridge: z.ZodOptional<z.ZodString>; destinationChain: z.ZodString; childHook: z.ZodLazy<z.ZodType<any, z.ZodTypeDef, any>>; }, "strip", z.ZodTypeAny, { type: "arbL2ToL1Hook"; destinationChain: string; arbSys: string; bridge?: string | undefined; childHook?: any; }, { type: "arbL2ToL1Hook"; destinationChain: string; arbSys: string; bridge?: string | undefined; childHook?: any; }>, z.ZodObject<{ type: z.ZodLiteral<"defaultHook">; }, "strip", z.ZodTypeAny, { type: "defaultHook"; }, { type: "defaultHook"; }>, z.ZodObject<{ type: z.ZodLiteral<"ccipHook">; destinationChain: z.ZodString; }, "strip", z.ZodTypeAny, { type: "ccipHook"; destinationChain: string; }, { type: "ccipHook"; destinationChain: string; }>]>, z.ZodObject<{ address: z.ZodString; }, "strip", z.ZodTypeAny, { address: string; }, { address: string; }>>>>; ism: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodIntersection<z.ZodUnion<[z.ZodString, z.ZodObject<{ type: z.ZodLiteral<"testIsm">; }, "strip", z.ZodTypeAny, { type: "testIsm"; }, { type: "testIsm"; }>, z.ZodObject<{ type: z.ZodLiteral<"opStackIsm">; origin: z.ZodString; nativeBridge: z.ZodString; }, "strip", z.ZodTypeAny, { type: "opStackIsm"; nativeBridge: string; origin: string; }, { type: "opStackIsm"; nativeBridge: string; origin: string; }>, z.ZodIntersection<z.ZodObject<{ owner: z.ZodString; ownerOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; } & { paused: z.ZodBoolean; }, "strip", z.ZodTypeAny, { owner: string; paused: boolean; ownerOverrides?: Record<string, string> | undefined; }, { owner: string; paused: boolean; ownerOverrides?: Record<string, string> | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"pausableIsm">; }, "strip", z.ZodTypeAny, { type: "pausableIsm"; }, { type: "pausableIsm"; }>>, z.ZodObject<{ type: z.ZodLiteral<"trustedRelayerIsm">; relayer: z.ZodString; }, "strip", z.ZodTypeAny, { type: "trustedRelayerIsm"; relayer: string; }, { type: "trustedRelayerIsm"; relayer: string; }>, z.ZodObject<{ type: z.ZodLiteral<"ccipIsm">; originChain: z.ZodString; }, "strip", z.ZodTypeAny, { type: "ccipIsm"; originChain: string; }, { type: "ccipIsm"; originChain: string; }>, z.ZodIntersection<z.ZodObject<{ validators: z.ZodArray<z.ZodString, "many">; threshold: z.ZodNumber; }, "strip", z.ZodTypeAny, { threshold: number; validators: string[]; }, { threshold: number; validators: string[]; }>, z.ZodObject<{ type: z.ZodUnion<[z.ZodLiteral<"merkleRootMultisigIsm">, z.ZodLiteral<"messageIdMultisigIsm">, z.ZodLiteral<"storageMerkleRootMultisigIsm">, z.ZodLiteral<"storageMessageIdMultisigIsm">]>; }, "strip", z.ZodTypeAny, { type: "merkleRootMultisigIsm" | "messageIdMultisigIsm" | "storageMerkleRootMultisigIsm" | "storageMessageIdMultisigIsm"; }, { type: "merkleRootMultisigIsm" | "messageIdMultisigIsm" | "storageMerkleRootMultisigIsm" | "storageMessageIdMultisigIsm"; }>>, z.ZodIntersection<z.ZodObject<{ validators: z.ZodArray<z.ZodObject<{ signingAddress: z.ZodString; weight: z.ZodNumber; }, "strip", z.ZodTypeAny, { signingAddress: string; weight: number; }, { signingAddress: string; weight: number; }>, "many">; thresholdWeight: z.ZodNumber; }, "strip", z.ZodTypeAny, { validators: { signingAddress: string; weight: number; }[]; thresholdWeight: number; }, { validators: { signingAddress: string; weight: number; }[]; thresholdWeight: number; }>, z.ZodObject<{ type: z.ZodUnion<[z.ZodLiteral<"weightedMerkleRootMultisigIsm">, z.ZodLiteral<"weightedMessageIdMultisigIsm">]>; }, "strip", z.ZodTypeAny, { type: "weightedMerkleRootMultisigIsm" | "weightedMessageIdMultisigIsm"; }, { type: "weightedMerkleRootMultisigIsm" | "weightedMessageIdMultisigIsm"; }>>, z.ZodType<import("../ism/types.js").RoutingIsmConfig, z.ZodTypeDef, import("../ism/types.js").RoutingIsmConfig>, z.ZodType<import("../ism/types.js").AggregationIsmConfig, z.ZodTypeDef, import("../ism/types.js").AggregationIsmConfig>, z.ZodObject<{ type: z.ZodLiteral<"arbL2ToL1Ism">; bridge: z.ZodString; }, "strip", z.ZodTypeAny, { type: "arbL2ToL1Ism"; bridge: string; }, { type: "arbL2ToL1Ism"; bridge: string; }>, z.ZodObject<{ owner: z.ZodString; ownerOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; } & { type: z.ZodLiteral<"offchainLookupIsm">; urls: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { type: "offchainLookupIsm"; owner: string; urls: string[]; ownerOverrides?: Record<string, string> | undefined; }, { type: "offchainLookupIsm"; owner: string; urls: string[]; ownerOverrides?: Record<string, string> | undefined; }>, z.ZodObject<{ owner: z.ZodString; ownerOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; } & { type: z.ZodLiteral<"interchainAccountRouting">; isms: z.ZodRecord<z.ZodString, z.ZodString>; }, "strip", z.ZodTypeAny, { type: "interchainAccountRouting"; owner: string; isms: Record<string, string>; ownerOverrides?: Record<string, string> | undefined; }, { type: "interchainAccountRouting"; owner: string; isms: Record<string, string>; ownerOverrides?: Record<string, string> | undefined; }>]>, z.ZodObject<{ address: z.ZodString; }, "strip", z.ZodTypeAny, { address: string; }, { address: string; }>>>>; backlog: z.ZodArray<z.ZodObject<{ attempts: z.ZodNumber; lastAttempt: z.ZodNumber; message: z.ZodString; dispatchTx: z.ZodString; }, "strip", z.ZodTypeAny, { message: string; dispatchTx: string; attempts: number; lastAttempt: number; }, { message: string; dispatchTx: string; attempts: number; lastAttempt: number; }>, "many">; }, "strip", z.ZodTypeAny, { hook: Record<string, Record<string, (string | { type: "merkleTreeHook"; } | { type: "interchainGasPaymaster"; owner: string; beneficiary: string; oracleKey: string; overhead: Record<string, number>; oracleConfig: Record<string, { gasPrice: string; tokenExchangeRate: string; tokenDecimals?: number | undefined; typicalCost?: { handleGasAmount: number; totalGasAmount: number; totalUsdCost: number; } | undefined; }>; ownerOverrides?: Record<string, string> | undefined; } | { type: "protocolFee"; owner: string; protocolFee: string; beneficiary: string; maxProtocolFee: string; ownerOverrides?: Record<string, string> | undefined; } | { type: "pausableHook"; owner: string; paused: boolean; ownerOverrides?: Record<string, string> | undefined; } | { type: "opStackHook"; owner: string; nativeBridge: string; destinationChain: string; ownerOverrides?: Record<string, string> | undefined; } | { type: "arbL2ToL1Hook"; destinationChain: string; arbSys: string; bridge?: string | undefined; childHook?: any; } | { type: "defaultHook"; } | { type: "ccipHook"; destinationChain: string; } | import("../hook/types.js").DomainRoutingHookConfig | import("../hook/types.js").FallbackRoutingHookConfig | import("../hook/types.js").AmountRoutingHookConfig | import("../hook/types.js").AggregationHookConfig) & { address: string; }>>; ism: Record<string, Record<string, (string | ({ threshold: number; validators: string[]; } & { type: "merkleRootMultisigIsm" | "messageIdMultisigIsm" | "storageMerkleRootMultisigIsm" | "storageMessageIdMultisigIsm"; }) | ({ validators: { signingAddress: string; weight: number; }[]; thresholdWeight: number; } & { type: "weightedMerkleRootMultisigIsm" | "weightedMessageIdMultisigIsm"; }) | { type: "testIsm"; } | ({ owner: string; paused: boolean; ownerOverrides?: Record<string, string> | undefined; } & { type: "pausableIsm"; }) | { type: "opStackIsm"; nativeBridge: string; origin: string; } | { type: "trustedRelayerIsm"; relayer: string; } | { type: "ccipIsm"; originChain: string; } | { type: "arbL2ToL1Ism"; bridge: string; } | { type: "offchainLookupIsm"; owner: string; urls: string[]; ownerOverrides?: Record<string, string> | undefined; } | import("../ism/types.js").RoutingIsmConfig | import("../ism/types.js").AggregationIsmConfig) & { address: string; }>>; backlog: { message: string; dispatchTx: string; attempts: number; lastAttempt: number; }[]; }, { hook: Record<string, Record<string, (string | { type: "merkleTreeHook"; } | { type: "interchainGasPaymaster"; owner: string; beneficiary: string; oracleKey: string; overhead: Record<string, number>; oracleConfig: Record<string, { gasPrice: string; tokenExchangeRate: string; tokenDecimals?: number | undefined; typicalCost?: { handleGasAmount: number; totalGasAmount: number; totalUsdCost: number; } | undefined; }>; ownerOverrides?: Record<string, string> | undefined; } | { type: "protocolFee"; owner: string; protocolFee: string; beneficiary: string; maxProtocolFee: string; ownerOverrides?: Record<string, string> | undefined; } | { type: "pausableHook"; owner: string; paused: boolean; ownerOverrides?: Record<string, string> | undefined; } | { type: "opStackHook"; owner: string; nativeBridge: string; destinationChain: string; ownerOverrides?: Record<string, string> | undefined; } | { type: "arbL2ToL1Hook"; destinationChain: string; arbSys: string; bridge?: string | undefined; childHook?: any; } | { type: "defaultHook"; } | { type: "ccipHook"; destinationChain: string; } | import("../hook/types.js").DomainRoutingHookConfig | import("../hook/types.js").FallbackRoutingHookConfig | import("../hook/types.js").AmountRoutingHookConfig | import("../hook/types.js").AggregationHookConfig) & { address: string; }>>; ism: Record<string, Record<string, (string | ({ threshold: number; validators: string[]; } & { type: "merkleRootMultisigIsm" | "messageIdMultisigIsm" | "storageMerkleRootMultisigIsm" | "storageMessageIdMultisigIsm"; }) | ({ validators: { signingAddress: string; weight: number; }[]; thresholdWeight: number; } & { type: "weightedMerkleRootMultisigIsm" | "weightedMessageIdMultisigIsm"; }) | { type: "testIsm"; } | ({ owner: string; paused: boolean; ownerOverrides?: Record<string, string> | undefined; } & { type: "pausableIsm"; }) | { type: "opStackIsm"; nativeBridge: string; origin: string; } | { type: "trustedRelayerIsm"; relayer: string; } | { type: "ccipIsm"; originChain: string; } | { type: "arbL2ToL1Ism"; bridge: string; } | { type: "offchainLookupIsm"; owner: string; urls: string[]; ownerOverrides?: Record<string, string> | undefined; } | { type: "interchainAccountRouting"; owner: string; isms: Record<string, string>; ownerOverrides?: Record<string, string> | undefined; } | import("../ism/types.js").RoutingIsmConfig | import("../ism/types.js").AggregationIsmConfig) & { address: string; }>>; backlog: { message: string; dispatchTx: string; attempts: number; lastAttempt: number; }[]; }>; type RelayerCache = z.infer<typeof RelayerCacheSchema>; type MessageWhitelist = ChainMap<Set<Address>>; export declare function messageMatchesWhitelist(whitelist: MessageWhitelist, message: ParsedMessage): boolean; export declare class HyperlaneRelayer { protected multiProvider: MultiProvider; protected metadataBuilder: BaseMetadataBuilder; protected readonly core: HyperlaneCore; protected readonly retryTimeout: number; protected readonly whitelist: ChainMap<Set<Address>> | undefined; backlog: RelayerCache['backlog']; cache: RelayerCache | undefined; protected stopRelayingHandler: ((chains?: ChainName[]) => void) | undefined; readonly logger: Logger; constructor({ core, caching, retryTimeout, whitelist, }: { core: HyperlaneCore; caching?: boolean; retryTimeout?: number; whitelist?: ChainMap<Address[]>; }); getHookConfig(chain: ChainName, hook: Address, messageContext?: DispatchedMessage): Promise<DerivedHookConfig>; getIsmConfig(chain: ChainName, ism: Address, messageContext?: DispatchedMessage): Promise<DerivedIsmConfig>; getSenderHookConfig(message: DispatchedMessage): Promise<DerivedHookConfig>; getRecipientIsmConfig(message: DispatchedMessage): Promise<DerivedIsmConfig>; relayAll(dispatchTx: providers.TransactionReceipt, messages?: DispatchedMessage[]): Promise<ChainMap<ethers.ContractReceipt[]>>; relayMessage(dispatchTx: providers.TransactionReceipt, messageIndex?: number, message?: DispatchedMessage): Promise<ethers.ContractReceipt>; hydrate(cache: RelayerCache): void; hydrateDefaults(): Promise<void>; protected flushBacklog(): Promise<void>; protected whitelistChains(): string[] | undefined; start(): void; stop(): void; } export {}; //# sourceMappingURL=HyperlaneRelayer.d.ts.map