From cf5f0aa71ec2b44bed194ca2e94048d551094c0d Mon Sep 17 00:00:00 2001 From: xeno097 Date: Wed, 23 Oct 2024 12:57:20 -0400 Subject: [PATCH] feat(cli): added proxy admin and ica router ownership configurability to core init command --- typescript/cli/src/config/core.ts | 39 +++++++++++++++++++++++++++--- typescript/cli/src/deploy/core.ts | 1 + typescript/sdk/src/core/schemas.ts | 9 ++++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/typescript/cli/src/config/core.ts b/typescript/cli/src/config/core.ts index 8be42113d..73f2649c4 100644 --- a/typescript/cli/src/config/core.ts +++ b/typescript/cli/src/config/core.ts @@ -1,6 +1,11 @@ import { stringify as yamlStringify } from 'yaml'; -import { CoreConfigSchema, HookConfig, IsmConfig } from '@hyperlane-xyz/sdk'; +import { + CoreConfigSchema, + HookConfig, + IsmConfig, + OwnableConfig, +} from '@hyperlane-xyz/sdk'; import { CommandContext } from '../context/types.js'; import { errorRed, log, logBlue, logGreen } from '../logger.js'; @@ -18,6 +23,9 @@ import { } from './hooks.js'; import { createAdvancedIsmConfig, createTrustedRelayerConfig } from './ism.js'; +const ENTER_DESIRED_VALUE_MSG = 'Enter the desired'; +const SIGNER_PROMPT_LABEL = 'signer'; + export async function createCoreDeployConfig({ context, configFilePath, @@ -31,9 +39,9 @@ export async function createCoreDeployConfig({ const owner = await detectAndConfirmOrPrompt( async () => context.signer?.getAddress(), - 'Enter the desired', + ENTER_DESIRED_VALUE_MSG, 'owner address', - 'signer', + SIGNER_PROMPT_LABEL, ); const defaultIsm: IsmConfig = advanced @@ -41,6 +49,7 @@ export async function createCoreDeployConfig({ : await createTrustedRelayerConfig(context, advanced); let defaultHook: HookConfig, requiredHook: HookConfig; + let proxyAdmin: OwnableConfig, interchainAccountRouter: OwnableConfig; if (advanced) { defaultHook = await createHookConfig({ context, @@ -52,9 +61,31 @@ export async function createCoreDeployConfig({ selectMessage: 'Select required hook type', advanced, }); + proxyAdmin = { + owner: await detectAndConfirmOrPrompt( + async () => context.signer?.getAddress(), + ENTER_DESIRED_VALUE_MSG, + 'ProxyAdmin owner address', + SIGNER_PROMPT_LABEL, + ), + }; + interchainAccountRouter = { + owner: await detectAndConfirmOrPrompt( + async () => context.signer?.getAddress(), + ENTER_DESIRED_VALUE_MSG, + 'ICA Router owner address', + SIGNER_PROMPT_LABEL, + ), + }; } else { defaultHook = await createMerkleTreeConfig(); requiredHook = await createProtocolFeeConfig(context, advanced); + proxyAdmin = { + owner, + }; + interchainAccountRouter = { + owner, + }; } try { @@ -63,6 +94,8 @@ export async function createCoreDeployConfig({ defaultIsm, defaultHook, requiredHook, + proxyAdmin, + interchainAccountRouter, }); logBlue(`Core config is valid, writing to file ${configFilePath}:\n`); log(indentYamlOrJson(yamlStringify(coreConfig, null, 2), 4)); diff --git a/typescript/cli/src/deploy/core.ts b/typescript/cli/src/deploy/core.ts index f0848458f..a05cef5d4 100644 --- a/typescript/cli/src/deploy/core.ts +++ b/typescript/cli/src/deploy/core.ts @@ -34,6 +34,7 @@ interface DeployParams { interface ApplyParams extends DeployParams { deployedCoreAddresses: DeployedCoreAddresses; } + /** * Executes the core deploy command. */ diff --git a/typescript/sdk/src/core/schemas.ts b/typescript/sdk/src/core/schemas.ts index 569bb2ee0..e25a4ee30 100644 --- a/typescript/sdk/src/core/schemas.ts +++ b/typescript/sdk/src/core/schemas.ts @@ -1,6 +1,9 @@ import { z } from 'zod'; -import { ProxyFactoryFactoriesSchema } from '../deploy/schemas.js'; +import { + OwnableConfigSchema, + ProxyFactoryFactoriesSchema, +} from '../deploy/schemas.js'; import { HookConfigSchema } from '../hook/schemas.js'; import { IsmConfigSchema } from '../ism/schemas.js'; import { OwnableSchema } from '../schemas.js'; @@ -9,6 +12,10 @@ export const CoreConfigSchema = OwnableSchema.extend({ defaultIsm: IsmConfigSchema, defaultHook: HookConfigSchema, requiredHook: HookConfigSchema, + // These fields are set as optional because the old core config + // did not have them and we want to maintain backward compatibility + proxyAdmin: OwnableConfigSchema.optional(), + interchainAccountRouter: OwnableConfigSchema.optional(), }); export const DeployedCoreAddressesSchema = ProxyFactoryFactoriesSchema.extend({