From f1d1769d5303d804716f2596139d945873e52811 Mon Sep 17 00:00:00 2001 From: xeno097 Date: Mon, 16 Sep 2024 17:46:51 -0400 Subject: [PATCH 1/8] refactor(cli): deprecated the --advanced flag and updated the warp init command to promt for default ism option --- typescript/cli/src/commands/warp.ts | 5 +++-- typescript/cli/src/config/warp.ts | 16 ++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/typescript/cli/src/commands/warp.ts b/typescript/cli/src/commands/warp.ts index da15e62a26..1670d34a70 100644 --- a/typescript/cli/src/commands/warp.ts +++ b/typescript/cli/src/commands/warp.ts @@ -147,17 +147,18 @@ export const init: CommandModuleWithContext<{ type: 'boolean', describe: 'Create an advanced ISM', default: false, + deprecated: + 'Please use the --yes flag to skip advanced configuration. The CLI will ask the user to configure an ISM.', }, out: outputFileCommandOption('./configs/warp-route-deployment.yaml'), }, - handler: async ({ context, advanced, out }) => { + handler: async ({ context, out }) => { logGray('Hyperlane Warp Configure'); logGray('------------------------'); await createWarpRouteDeployConfig({ context, outPath: out, - advanced, }); process.exit(0); }, diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index 240e0e39d1..0b13c6d144 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -1,4 +1,4 @@ -import { input, select } from '@inquirer/prompts'; +import { confirm, input, select } from '@inquirer/prompts'; import { stringify as yamlStringify } from 'yaml'; import { @@ -101,11 +101,9 @@ export function isValidWarpRouteDeployConfig(config: any) { export async function createWarpRouteDeployConfig({ context, outPath, - advanced = false, }: { context: CommandContext; outPath: string; - advanced: boolean; }) { logBlue('Creating a new warp route deployment config...'); @@ -144,9 +142,15 @@ export async function createWarpRouteDeployConfig({ 'hyperlane-registry', ); - const interchainSecurityModule = advanced - ? await createAdvancedIsmConfig(context) - : createDefaultWarpIsmConfig(owner); + const createDefaultIsm = + context.skipConfirmation || + (await confirm({ + message: 'Use a trusted ISM for warp route', + })); + + const interchainSecurityModule = createDefaultIsm + ? createDefaultWarpIsmConfig(owner) + : await createAdvancedIsmConfig(context); switch (type) { case TokenType.collateral: From 8f8d7299f1feee0322173f3513ce0a7c3356fc21 Mon Sep 17 00:00:00 2001 From: xeno097 Date: Tue, 17 Sep 2024 10:49:21 -0400 Subject: [PATCH 2/8] feat(cli): readded the advanced flag in the warp init command --- typescript/cli/src/commands/warp.ts | 5 ++--- typescript/cli/src/config/warp.ts | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/typescript/cli/src/commands/warp.ts b/typescript/cli/src/commands/warp.ts index 1670d34a70..da15e62a26 100644 --- a/typescript/cli/src/commands/warp.ts +++ b/typescript/cli/src/commands/warp.ts @@ -147,18 +147,17 @@ export const init: CommandModuleWithContext<{ type: 'boolean', describe: 'Create an advanced ISM', default: false, - deprecated: - 'Please use the --yes flag to skip advanced configuration. The CLI will ask the user to configure an ISM.', }, out: outputFileCommandOption('./configs/warp-route-deployment.yaml'), }, - handler: async ({ context, out }) => { + handler: async ({ context, advanced, out }) => { logGray('Hyperlane Warp Configure'); logGray('------------------------'); await createWarpRouteDeployConfig({ context, outPath: out, + advanced, }); process.exit(0); }, diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index 0b13c6d144..ce1655a61f 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -101,10 +101,19 @@ export function isValidWarpRouteDeployConfig(config: any) { export async function createWarpRouteDeployConfig({ context, outPath, + advanced = false, }: { context: CommandContext; outPath: string; + advanced: boolean; }) { + // Providing the global --yes flag will trigger the usage of a trusted ISM while the + // --advanced flag will force the user to manually configure an ISM. Both flags should + // not be set to true at the same time. + if (context.skipConfirmation && advanced) { + throw new Error('Arguments advanced and yes are mutually exclusive'); + } + logBlue('Creating a new warp route deployment config...'); const owner = await detectAndConfirmOrPrompt( @@ -142,11 +151,16 @@ export async function createWarpRouteDeployConfig({ 'hyperlane-registry', ); - const createDefaultIsm = - context.skipConfirmation || - (await confirm({ + let createDefaultIsm: boolean; + if (context.skipConfirmation) { + createDefaultIsm = true; + } else if (advanced) { + createDefaultIsm = false; + } else { + createDefaultIsm = await confirm({ message: 'Use a trusted ISM for warp route', - })); + }); + } const interchainSecurityModule = createDefaultIsm ? createDefaultWarpIsmConfig(owner) From f2456eb34c48d378dd60661e64f3fb59338f1f3b Mon Sep 17 00:00:00 2001 From: xeno097 Date: Tue, 17 Sep 2024 11:09:01 -0400 Subject: [PATCH 3/8] chore: yarn changeset --- .changeset/long-swans-drive.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/long-swans-drive.md diff --git a/.changeset/long-swans-drive.md b/.changeset/long-swans-drive.md new file mode 100644 index 0000000000..3d6b98c0a5 --- /dev/null +++ b/.changeset/long-swans-drive.md @@ -0,0 +1,5 @@ +--- +'@hyperlane-xyz/cli': major +--- + +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 From 66d3d44e521e7cff8a52e3d1ec7489e5bdaceb0d Mon Sep 17 00:00:00 2001 From: xeno097 Date: Tue, 17 Sep 2024 14:08:29 -0400 Subject: [PATCH 4/8] feat(cli): removed error in case both --yes and --advanced flag were provided --- .changeset/long-swans-drive.md | 4 ++-- typescript/cli/src/config/warp.ts | 13 +++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.changeset/long-swans-drive.md b/.changeset/long-swans-drive.md index 3d6b98c0a5..84c5ed780d 100644 --- a/.changeset/long-swans-drive.md +++ b/.changeset/long-swans-drive.md @@ -1,5 +1,5 @@ --- -'@hyperlane-xyz/cli': major +'@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 +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 adn enable the `--yes` flag to default to a trusted ISM diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index ce1655a61f..faa7f99cc9 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -107,13 +107,6 @@ export async function createWarpRouteDeployConfig({ outPath: string; advanced: boolean; }) { - // Providing the global --yes flag will trigger the usage of a trusted ISM while the - // --advanced flag will force the user to manually configure an ISM. Both flags should - // not be set to true at the same time. - if (context.skipConfirmation && advanced) { - throw new Error('Arguments advanced and yes are mutually exclusive'); - } - logBlue('Creating a new warp route deployment config...'); const owner = await detectAndConfirmOrPrompt( @@ -152,10 +145,10 @@ export async function createWarpRouteDeployConfig({ ); let createDefaultIsm: boolean; - if (context.skipConfirmation) { - createDefaultIsm = true; - } else if (advanced) { + if (advanced) { createDefaultIsm = false; + } else if (context.skipConfirmation) { + createDefaultIsm = true; } else { createDefaultIsm = await confirm({ message: 'Use a trusted ISM for warp route', From 564fa86b70263bdc65f448fa600f5f037dd9fe5f Mon Sep 17 00:00:00 2001 From: xeno097 Date: Thu, 19 Sep 2024 14:15:24 -0400 Subject: [PATCH 5/8] fixed typo in .changeset/long-swans-drive.md Co-authored-by: Lee <6251863+ltyu@users.noreply.github.com> --- .changeset/long-swans-drive.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/long-swans-drive.md b/.changeset/long-swans-drive.md index 84c5ed780d..3f21e56c41 100644 --- a/.changeset/long-swans-drive.md +++ b/.changeset/long-swans-drive.md @@ -2,4 +2,4 @@ '@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 adn enable the `--yes` flag to default to a trusted ISM +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 From 4d23bda78dcbfa9e8877a216837bd463020f7020 Mon Sep 17 00:00:00 2001 From: xeno097 Date: Thu, 19 Sep 2024 14:16:00 -0400 Subject: [PATCH 6/8] feat(cli): improved prompt message for default ISM in typescript/cli/src/config/warp.ts Co-authored-by: Lee <6251863+ltyu@users.noreply.github.com> --- typescript/cli/src/config/warp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index faa7f99cc9..90d32302f7 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -151,7 +151,7 @@ export async function createWarpRouteDeployConfig({ createDefaultIsm = true; } else { createDefaultIsm = await confirm({ - message: 'Use a trusted ISM for warp route', + message: 'Do you want to use a trusted ISM for warp route?', }); } From 75efc37208eca075ac84aa84b8647aafc33a68a9 Mon Sep 17 00:00:00 2001 From: xeno097 Date: Mon, 23 Sep 2024 12:26:27 -0400 Subject: [PATCH 7/8] chore(cli): pr changes part 2 --- typescript/cli/src/config/warp.ts | 48 +++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index a9695fe5e8..5ee6acd987 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -151,21 +151,29 @@ export async function createWarpRouteDeployConfig({ const isNft = type === TokenType.syntheticUri || type === TokenType.collateralUri; - let createDefaultIsm: boolean; + /** + * 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) { - createDefaultIsm = false; + interchainSecurityModule = await createAdvancedIsmConfig(context); } else if (context.skipConfirmation) { - createDefaultIsm = true; - } else { - createDefaultIsm = await confirm({ + 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 interchainSecurityModule = createDefaultIsm - ? createDefaultWarpIsmConfig(owner) - : await createAdvancedIsmConfig(context); - switch (type) { case TokenType.collateral: case TokenType.XERC20: @@ -245,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, + }; +} From 09329541da1dc904441cb67dd991df958ea2186d Mon Sep 17 00:00:00 2001 From: xeno097 Date: Thu, 26 Sep 2024 17:12:21 -0400 Subject: [PATCH 8/8] feat(cli): group token config prompts in warp init command --- typescript/cli/src/config/warp.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/typescript/cli/src/config/warp.ts b/typescript/cli/src/config/warp.ts index 5ee6acd987..6ce1f6665a 100644 --- a/typescript/cli/src/config/warp.ts +++ b/typescript/cli/src/config/warp.ts @@ -142,15 +142,6 @@ export async function createWarpRouteDeployConfig({ 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, - }); - - // TODO: restore NFT prompting - const isNft = - type === TokenType.syntheticUri || type === TokenType.collateralUri; - /** * 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 @@ -174,6 +165,15 @@ export async function createWarpRouteDeployConfig({ interchainSecurityModule = createFallbackRoutingConfig(owner); } + const type = await select({ + message: `Select ${chain}'s token type`, + choices: TYPE_CHOICES, + }); + + // TODO: restore NFT prompting + const isNft = + type === TokenType.syntheticUri || type === TokenType.collateralUri; + switch (type) { case TokenType.collateral: case TokenType.XERC20: