fix(cli): remove default for chain name (#3909)

### Description

- simply prompts if not a lowercase one-word chain name, instead of
sometimes returning incorrect chain name

### Drive-by changes

- none

### Related issues

- none

### Backward compatibility

- yes

### Testing

- manual w/ caldera: https://early-rabbits-throw.hub.caldera.xyz/
pull/3929/head
Noah Bayindirli 🥂 6 months ago committed by GitHub
parent 0e8374f361
commit 3283eefd6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/bright-emus-double.md
  2. 21
      typescript/cli/src/config/chain.ts
  3. 2
      typescript/sdk/src/index.ts

@ -0,0 +1,5 @@
---
'@hyperlane-xyz/cli': patch
---
Removes default pattern for chain name when creating a new chain.

@ -1,7 +1,11 @@
import { confirm, input } from '@inquirer/prompts'; import { confirm, input } from '@inquirer/prompts';
import { ethers } from 'ethers'; import { ethers } from 'ethers';
import { ChainMetadata, ChainMetadataSchema } from '@hyperlane-xyz/sdk'; import {
ChainMetadata,
ChainMetadataSchema,
ZChainName,
} from '@hyperlane-xyz/sdk';
import { ProtocolType } from '@hyperlane-xyz/utils'; import { ProtocolType } from '@hyperlane-xyz/utils';
import { CommandContext } from '../context/types.js'; import { CommandContext } from '../context/types.js';
@ -52,17 +56,10 @@ export async function createChainConfig({
); );
const provider = new ethers.providers.JsonRpcProvider(rpcUrl); const provider = new ethers.providers.JsonRpcProvider(rpcUrl);
const name = await detectAndConfirmOrPrompt( const name = await input({
async () => { message: 'Enter chain name (one word, lower case)',
const clientName = await provider.send('web3_clientVersion', []); validate: (chainName) => ZChainName.safeParse(chainName).success,
const port = rpcUrl.split(':').slice(-1); });
const client = clientName.split('/')[0];
return `${client}${port}`;
},
'Enter (one word, lower case)',
'chain name',
'JSON RPC provider',
);
const chainId = parseInt( const chainId = parseInt(
await detectAndConfirmOrPrompt( await detectAndConfirmOrPrompt(

@ -155,7 +155,7 @@ export {
} from './ism/multisig.js'; } from './ism/multisig.js';
export { EvmIsmReader } from './ism/EvmIsmReader.js'; export { EvmIsmReader } from './ism/EvmIsmReader.js';
export { collectValidators, moduleCanCertainlyVerify } from './ism/utils.js'; export { collectValidators, moduleCanCertainlyVerify } from './ism/utils.js';
export { ZHash } from './metadata/customZodTypes.js'; export { ZChainName, ZHash } from './metadata/customZodTypes.js';
export { export {
BlockExplorer, BlockExplorer,
ChainMetadata, ChainMetadata,

Loading…
Cancel
Save