UNPKG

@hyperlane-xyz/cli

Version:

A command-line utility for common Hyperlane operations

32 lines 1.77 kB
import { CommandType } from '../../../commands/signCommands.js'; import { MultiChainResolver } from './MultiChainResolver.js'; /** * @class ChainResolverFactory * @description Intercepts commands to determine the appropriate chain resolver strategy based on command type. */ export class ChainResolverFactory { static strategyMap = new Map([ [CommandType.WARP_DEPLOY, () => MultiChainResolver.forWarpRouteConfig()], // Using the forRelayer resolver because warp send allows the user to self relay the tx [CommandType.WARP_SEND, () => MultiChainResolver.forRelayer()], [CommandType.WARP_APPLY, () => MultiChainResolver.forWarpRouteConfig()], // Using the forRelayer resolver because send allows the user to self relay the tx [CommandType.SEND_MESSAGE, () => MultiChainResolver.forRelayer()], [CommandType.AGENT_KURTOSIS, () => MultiChainResolver.forAgentKurtosis()], // Using the forRelayer resolver because status allows the user to self relay the tx [CommandType.STATUS, () => MultiChainResolver.forRelayer()], [CommandType.SUBMIT, () => MultiChainResolver.forStrategyConfig()], [CommandType.RELAYER, () => MultiChainResolver.forRelayer()], [CommandType.CORE_APPLY, () => MultiChainResolver.forCoreApply()], ]); /** * @param argv - Command line arguments. * @returns ChainResolver - The appropriate chain resolver strategy based on the command type. */ static getStrategy(argv) { const commandKey = `${argv._[0]}:${argv._[1] || ''}`.trim(); const createStrategy = this.strategyMap.get(commandKey) || (() => MultiChainResolver.default()); return createStrategy(); } } //# sourceMappingURL=ChainResolverFactory.js.map