feat: `warp init` simplified config (#4504)

### Description

This PR updates the ISM configuration prompting for the `warp init`
command allowing the user to choose if a trusted ISM should be used by
default or a configured one.

Before:

![image](https://github.com/user-attachments/assets/7be4e5af-d664-4481-ac31-b87caf609b91)


![image](https://github.com/user-attachments/assets/030aa59c-82ad-4349-a973-273b0eb15403)

After:

![image](https://github.com/user-attachments/assets/c19ca765-c771-4d04-8041-c5c19f44f645)


![image](https://github.com/user-attachments/assets/5e875beb-c86e-464d-bcf9-0c705a9f43ce)


### Drive-by changes

- No

### Related issues

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

### Backward compatibility

- Yes

### Testing

- Manual

---------

Co-authored-by: Lee <6251863+ltyu@users.noreply.github.com>
pull/4686/head
xeno097 2 weeks ago committed by GitHub
parent c08d842adf
commit 3662297fc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/long-swans-drive.md
  2. 49
      typescript/cli/src/config/warp.ts

@ -0,0 +1,5 @@
---
'@hyperlane-xyz/cli': minor
---
Add prompt in `warp init` command to choose if a trusted relayer should be used instead of making the choice by default for the user and enable the `--yes` flag to default to a trusted ISM

@ -1,4 +1,4 @@
import { input, select } from '@inquirer/prompts';
import { confirm, input, select } from '@inquirer/prompts';
import { stringify as yamlStringify } from 'yaml';
import {
@ -142,6 +142,29 @@ export async function createWarpRouteDeployConfig({
message: `Could not retrieve mailbox address from the registry for chain "${chain}". Please enter a valid mailbox address:`,
}));
/**
* The logic from the cli is as follows:
* --advanced flag is provided: the user will have to build their own configuration using the available ISM types
* --yes flag is provided: the default ISM config will be used (Trusted ISM + Default fallback ISM)
* -- no flag is provided: the user must choose if the default ISM config should be used:
* - yes: the default ISM config will be used (Trusted ISM + Default fallback ISM)
* - no: the default fallback ISM will be used
*/
let interchainSecurityModule: IsmConfig;
if (advanced) {
interchainSecurityModule = await createAdvancedIsmConfig(context);
} else if (context.skipConfirmation) {
interchainSecurityModule = createDefaultWarpIsmConfig(owner);
} else if (
await confirm({
message: 'Do you want to use a trusted ISM for warp route?',
})
) {
interchainSecurityModule = createDefaultWarpIsmConfig(owner);
} else {
interchainSecurityModule = createFallbackRoutingConfig(owner);
}
const type = await select({
message: `Select ${chain}'s token type`,
choices: TYPE_CHOICES,
@ -151,10 +174,6 @@ export async function createWarpRouteDeployConfig({
const isNft =
type === TokenType.syntheticUri || type === TokenType.collateralUri;
const interchainSecurityModule = advanced
? await createAdvancedIsmConfig(context)
: createDefaultWarpIsmConfig(owner);
switch (type) {
case TokenType.collateral:
case TokenType.XERC20:
@ -234,12 +253,22 @@ function createDefaultWarpIsmConfig(owner: Address): IsmConfig {
type: IsmType.TRUSTED_RELAYER,
relayer: owner,
},
{
type: IsmType.FALLBACK_ROUTING,
domains: {},
owner,
},
createFallbackRoutingConfig(owner),
],
threshold: 1,
};
}
/**
* Creates a fallback configuration for an ISM with a FALLBACK_ROUTING and the provided `owner`.
*
* @param owner - The address of the owner of the ISM.
* @returns The Fallback Routing ISM configuration.
*/
function createFallbackRoutingConfig(owner: Address): IsmConfig {
return {
type: IsmType.FALLBACK_ROUTING,
domains: {},
owner,
};
}

Loading…
Cancel
Save