From ffbc13cc58dfe87145dcb153314082c6b4232a29 Mon Sep 17 00:00:00 2001 From: Daniel Savu <23065004+daniel-savu@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:50:09 +0000 Subject: [PATCH] chore: instantiate router config in warp generators (#4807) ### Description Uncomments generator code to actually instantiate a `routerConfig`, as recommended in https://github.com/hyperlane-xyz/hyperlane-monorepo/pull/4799#discussion_r1826157666 ### Drive-by changes ### Related issues ### Backward compatibility ### Testing --------- Co-authored-by: Trevor Porter --- ...generate-eclipse-usdt-warp-route-config.ts | 8 +++-- ...generate-eclipse-wbtc-warp-route-config.ts | 8 +++-- typescript/infra/scripts/warp-routes/utils.ts | 30 +++++++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 typescript/infra/scripts/warp-routes/utils.ts diff --git a/typescript/infra/scripts/generate-eclipse-usdt-warp-route-config.ts b/typescript/infra/scripts/generate-eclipse-usdt-warp-route-config.ts index 38507084cd..8b2be8eef7 100644 --- a/typescript/infra/scripts/generate-eclipse-usdt-warp-route-config.ts +++ b/typescript/infra/scripts/generate-eclipse-usdt-warp-route-config.ts @@ -5,10 +5,12 @@ import { WarpRouteDeployConfigSchema } from '@hyperlane-xyz/sdk'; import { getEclipseEthereumUSDTWarpConfig } from '../config/environments/mainnet3/warp/configGetters/getEclipseEthereumUSDTWarpConfig.js'; +import { getRouterConfig } from './warp-routes/utils.js'; + async function main() { - // remove the argument in the function definition to call - // const tokenConfig = await getEclipseEthereumUSDTWarpConfig(); - const parsed = WarpRouteDeployConfigSchema.safeParse(''); + const routerConfig = await getRouterConfig(); + const tokenConfig = await getEclipseEthereumUSDTWarpConfig(routerConfig); + const parsed = WarpRouteDeployConfigSchema.safeParse(tokenConfig); if (!parsed.success) { console.dir(parsed.error.format(), { depth: null }); diff --git a/typescript/infra/scripts/generate-eclipse-wbtc-warp-route-config.ts b/typescript/infra/scripts/generate-eclipse-wbtc-warp-route-config.ts index 9dbc424d3a..dce156b235 100644 --- a/typescript/infra/scripts/generate-eclipse-wbtc-warp-route-config.ts +++ b/typescript/infra/scripts/generate-eclipse-wbtc-warp-route-config.ts @@ -5,10 +5,12 @@ import { WarpRouteDeployConfigSchema } from '@hyperlane-xyz/sdk'; import { getEclipseEthereumWBTCWarpConfig } from '../config/environments/mainnet3/warp/configGetters/getEclipseEthereumWBTCWarpConfig.js'; +import { getRouterConfig } from './warp-routes/utils.js'; + async function main() { - // remove the argument in the function definition to call - // const tokenConfig = await getEclipseEthereumWBTCWarpConfig(); - const parsed = WarpRouteDeployConfigSchema.safeParse(''); + const routerConfig = await getRouterConfig(); + const tokenConfig = await getEclipseEthereumWBTCWarpConfig(routerConfig); + const parsed = WarpRouteDeployConfigSchema.safeParse(tokenConfig); if (!parsed.success) { console.dir(parsed.error.format(), { depth: null }); diff --git a/typescript/infra/scripts/warp-routes/utils.ts b/typescript/infra/scripts/warp-routes/utils.ts new file mode 100644 index 0000000000..2e0fdc40b9 --- /dev/null +++ b/typescript/infra/scripts/warp-routes/utils.ts @@ -0,0 +1,30 @@ +import { Contexts } from '../../config/contexts.js'; +import { Role } from '../../src/roles.js'; +import { + getArgs, + withBuildArtifactPath, + withChains, + withConcurrentDeploy, + withContext, +} from '../agent-utils.js'; +import { getEnvironmentConfig, getHyperlaneCore } from '../core-utils.js'; + +export async function getRouterConfig() { + const { + context = Contexts.Hyperlane, + environment, + chains, + } = await withContext( + withConcurrentDeploy(withChains(withBuildArtifactPath(getArgs()))), + ).argv; + const envConfig = getEnvironmentConfig(environment); + + let multiProvider = await envConfig.getMultiProvider( + context, + Role.Deployer, + true, + chains, + ); + const { core } = await getHyperlaneCore(environment, multiProvider); + return core.getRouterConfig(envConfig.owners); +}