feat(cli): add 'source' to detectAndConfirmOrPrompt (#3906)

### Description

- adds `source` field to detect and confirm prompt so users know where
defaults are coming from

### Drive-by changes

- none

### Related issues

- none

### Backward compatibility

- yes

### Testing

- manual
pull/3908/head
Noah Bayindirli 🥂 5 months ago committed by GitHub
parent c38f799afa
commit 845ed5796e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      typescript/cli/src/commands/core.ts
  2. 3
      typescript/cli/src/config/chain.ts
  3. 1
      typescript/cli/src/config/ism.ts
  4. 2
      typescript/cli/src/config/warp.ts
  5. 5
      typescript/cli/src/utils/chains.ts

@ -60,6 +60,7 @@ export const configure: CommandModuleWithContext<{
async () => context.signer?.getAddress(), async () => context.signer?.getAddress(),
'Enter the desired', 'Enter the desired',
'owner address', 'owner address',
'signer',
); );
// Create default Ism config (advanced or trusted) // Create default Ism config (advanced or trusted)

@ -48,6 +48,7 @@ export async function createChainConfig({
}, },
'Enter http or https', 'Enter http or https',
'rpc url', 'rpc url',
'JSON RPC provider',
); );
const provider = new ethers.providers.JsonRpcProvider(rpcUrl); const provider = new ethers.providers.JsonRpcProvider(rpcUrl);
@ -60,6 +61,7 @@ export async function createChainConfig({
}, },
'Enter (one word, lower case)', 'Enter (one word, lower case)',
'chain name', 'chain name',
'JSON RPC provider',
); );
const chainId = parseInt( const chainId = parseInt(
@ -70,6 +72,7 @@ export async function createChainConfig({
}, },
'Enter a (number)', 'Enter a (number)',
'chain id', 'chain id',
'JSON RPC provider',
), ),
10, 10,
); );

@ -135,6 +135,7 @@ export async function createTrustedRelayerConfig(
async () => context.signer?.getAddress(), async () => context.signer?.getAddress(),
'For trusted relayer ISM, enter', 'For trusted relayer ISM, enter',
'relayer address', 'relayer address',
'signer',
); );
return { return {
type: IsmType.TRUSTED_RELAYER, type: IsmType.TRUSTED_RELAYER,

@ -114,6 +114,7 @@ export async function createWarpRouteDeployConfig({
async () => context.signer?.getAddress(), async () => context.signer?.getAddress(),
'Enter the desired', 'Enter the desired',
'owner address', 'owner address',
'signer',
); );
const warpChains = await runMultiChainSelectionStep( const warpChains = await runMultiChainSelectionStep(
@ -140,6 +141,7 @@ export async function createWarpRouteDeployConfig({
}, },
`For ${chain}, enter the`, `For ${chain}, enter the`,
'mailbox address', 'mailbox address',
'hyperlane-registry',
); );
const interchainSecurityModule = shouldUseDefault const interchainSecurityModule = shouldUseDefault

@ -78,13 +78,16 @@ export async function detectAndConfirmOrPrompt(
detect: () => Promise<string | undefined>, detect: () => Promise<string | undefined>,
prompt: string, prompt: string,
label: string, label: string,
source?: string,
): Promise<string> { ): Promise<string> {
let detectedValue: string | undefined; let detectedValue: string | undefined;
try { try {
detectedValue = await detect(); detectedValue = await detect();
if (detectedValue) { if (detectedValue) {
const confirmed = await confirm({ const confirmed = await confirm({
message: `Detected ${label} as ${detectedValue}, is this correct?`, message: `Detected ${label} as ${detectedValue}${
source ? ` from ${source}` : ''
}, is this correct?`,
}); });
if (confirmed) { if (confirmed) {
return detectedValue; return detectedValue;

Loading…
Cancel
Save