diff --git a/.changeset/lazy-flies-sin.md b/.changeset/lazy-flies-sin.md new file mode 100644 index 000000000..33b439809 --- /dev/null +++ b/.changeset/lazy-flies-sin.md @@ -0,0 +1,5 @@ +--- +'@hyperlane-xyz/cli': minor +--- + +Remove mailbox choice prompt if it can be automatically detected from the registry diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index 240e0e39d..8e15ccc3c 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -12,7 +12,13 @@ import { WarpRouteDeployConfig, WarpRouteDeployConfigSchema, } from '@hyperlane-xyz/sdk'; -import { Address, assert, objMap, promiseObjAll } from '@hyperlane-xyz/utils'; +import { + Address, + assert, + isAddress, + objMap, + promiseObjAll, +} from '@hyperlane-xyz/utils'; import { CommandContext } from '../context/types.js'; import { errorRed, log, logBlue, logGreen } from '../logger.js'; @@ -125,6 +131,17 @@ export async function createWarpRouteDeployConfig({ const result: WarpRouteDeployConfig = {}; for (const chain of warpChains) { logBlue(`${chain}: Configuring warp route...`); + + // default to the mailbox from the registry and if not found ask to the user to submit one + const chainAddresses = await context.registry.getChainAddresses(chain); + + const mailbox = + chainAddresses?.mailbox ?? + (await input({ + validate: isAddress, + message: `Could not retrieve mailbox address from the registry for chain "${chain}". Please enter a valid mailbox address:`, + })); + const type = await select({ message: `Select ${chain}'s token type`, choices: TYPE_CHOICES, @@ -134,16 +151,6 @@ export async function createWarpRouteDeployConfig({ const isNft = type === TokenType.syntheticUri || type === TokenType.collateralUri; - const mailbox = await detectAndConfirmOrPrompt( - async () => { - const addresses = await context.registry.getChainAddresses(chain); - return addresses?.mailbox; - }, - `For ${chain}, enter the`, - 'mailbox address', - 'hyperlane-registry', - ); - const interchainSecurityModule = advanced ? await createAdvancedIsmConfig(context) : createDefaultWarpIsmConfig(owner);