fix: require multiple chains in warp init (#4256)

### Description

Block on user selecting multiple chains in `hyperlane warp init`

### Drive-by

Adjust incorrect requirement of multiple chain selection in routing ISM
builder

### Related issues

- Fixes https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/4255

### Backward compatibility

Yes

### Testing

Manual

---------

Co-authored-by: Lee <6251863+ltyu@users.noreply.github.com>
pull/4263/head
Yorke Rhodes 4 months ago committed by GitHub
parent d396e2c553
commit 3d4e6436d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/fast-schools-battle.md
  2. 8
      typescript/cli/src/config/hooks.ts
  3. 5
      typescript/cli/src/config/ism.ts
  4. 1
      typescript/cli/src/config/warp.ts
  5. 2
      typescript/cli/src/deploy/agent.ts
  6. 10
      typescript/cli/src/utils/chains.ts

@ -0,0 +1,5 @@
---
"@hyperlane-xyz/cli": patch
---
Require at least 1 chain selection in warp init

@ -262,10 +262,14 @@ export const createRoutingConfig = callWithConfigCreationLogs(
advanced: boolean = false,
): Promise<HookConfig> => {
const owner = await input({
message: 'Enter owner address for routing ISM',
message: 'Enter owner address for routing Hook',
});
const ownerAddress = owner;
const chains = await runMultiChainSelectionStep(context.chainMetadata);
const chains = await runMultiChainSelectionStep(
context.chainMetadata,
'Select chains for routing Hook',
1,
);
const domainsMap: ChainMap<HookConfig> = {};
for (const chain of chains) {

@ -226,11 +226,10 @@ export const createRoutingConfig = callWithConfigCreationLogs(
message: 'Enter owner address for routing ISM',
});
const ownerAddress = owner;
const requireMultiple = true;
const chains = await runMultiChainSelectionStep(
context.chainMetadata,
'Select chains to configure routing ISM for',
requireMultiple,
1,
);
const domainsMap: ChainMap<IsmConfig> = {};
@ -253,7 +252,7 @@ export const createFallbackRoutingConfig = callWithConfigCreationLogs(
const chains = await runMultiChainSelectionStep(
context.chainMetadata,
'Select chains to configure fallback routing ISM for',
true,
1,
);
const domainsMap: ChainMap<IsmConfig> = {};

@ -119,6 +119,7 @@ export async function createWarpRouteDeployConfig({
const warpChains = await runMultiChainSelectionStep(
context.chainMetadata,
'Select chains to connect',
1,
);
const result: WarpRouteDeployConfig = {};

@ -31,7 +31,7 @@ export async function runKurtosisAgentDeploy({
const selectedRelayChains = await runMultiChainSelectionStep(
context.chainMetadata,
'Select chains to relay between',
true,
2,
);
relayChains = selectedRelayChains.join(',');
}

@ -31,20 +31,22 @@ export async function runSingleChainSelectionStep(
export async function runMultiChainSelectionStep(
chainMetadata: ChainMap<ChainMetadata>,
message = 'Select chains',
requireMultiple = false,
requireNumber = 0,
) {
const networkType = await selectNetworkType();
const choices = getChainChoices(chainMetadata, networkType);
while (true) {
logTip('Use SPACE key to select chains, then press ENTER');
logTip(
`Use SPACE key to select at least ${requireNumber} chains, then press ENTER`,
);
const chains = (await checkbox({
message,
choices,
pageSize: calculatePageSize(2),
})) as string[];
handleNewChain(chains);
if (requireMultiple && chains?.length < 2) {
logRed('Please select at least 2 chains');
if (chains?.length < requireNumber) {
logRed(`Please select at least ${requireNumber} chains`);
continue;
}
return chains;

Loading…
Cancel
Save