refactor: improve signer management in warp route deploy config creation

pull/4869/head
ljankovic-txfusion 8 hours ago
parent d7326a696f
commit 6561504641
  1. 31
      typescript/cli/src/config/warp.ts
  2. 6
      typescript/cli/src/context/context.ts
  3. 2
      typescript/cli/src/context/types.ts

@ -21,6 +21,8 @@ import {
promiseObjAll,
} from '@hyperlane-xyz/utils';
import { DEFAULT_STRATEGY_CONFIG_PATH } from '../commands/options.js';
import { MultiProtocolSignerManager } from '../context/strategies/signer/MultiProtocolSignerManager.js';
import { CommandContext } from '../context/types.js';
import { errorRed, log, logBlue, logGreen } from '../logger.js';
import { runMultiChainSelectionStep } from '../utils/chains.js';
@ -35,6 +37,7 @@ import {
} from '../utils/input.js';
import { createAdvancedIsmConfig } from './ism.js';
import { readChainSubmissionStrategyConfig } from './strategy.js';
const TYPE_DESCRIPTIONS: Record<TokenType, string> = {
[TokenType.synthetic]: 'A new ERC20 with remote transfer functionality',
@ -122,13 +125,6 @@ export async function createWarpRouteDeployConfig({
}) {
logBlue('Creating a new warp route deployment config...');
const owner = await detectAndConfirmOrPrompt(
async () => context.signer?.getAddress(),
'Enter the desired',
'owner address',
'signer',
);
const warpChains = await runMultiChainSelectionStep({
chainMetadata: context.chainMetadata,
message: 'Select chains to connect',
@ -138,11 +134,32 @@ export async function createWarpRouteDeployConfig({
requiresConfirmation: !context.skipConfirmation,
});
const strategyConfig = await readChainSubmissionStrategyConfig(
context.strategyPath ?? DEFAULT_STRATEGY_CONFIG_PATH,
);
const multiProtocolSigner = new MultiProtocolSignerManager(
strategyConfig,
warpChains,
context.multiProvider,
{ key: context.key },
);
const multiProviderWithSigners =
await multiProtocolSigner.setupMultiProvider();
const result: WarpRouteDeployConfig = {};
let typeChoices = TYPE_CHOICES;
for (const chain of warpChains) {
logBlue(`${chain}: Configuring warp route...`);
const owner = await detectAndConfirmOrPrompt(
async () => await multiProviderWithSigners.getSigner(chain).getAddress(),
'Enter the desired',
'owner address',
'signer',
);
// default to the mailbox from the registry and if not found ask to the user to submit one
const chainAddresses = await context.registry.getChainAddresses(chain);

@ -45,6 +45,7 @@ export async function contextMiddleware(argv: Record<string, any>) {
requiresKey,
disableProxy: argv.disableProxy,
skipConfirmation: argv.yes,
strategyPath: argv.strategy,
};
if (!isDryRun && settings.fromAddress)
throw new Error(
@ -57,13 +58,12 @@ export async function contextMiddleware(argv: Record<string, any>) {
}
export async function signerMiddleware(argv: Record<string, any>) {
const { key, context } = argv;
const { requiresKey, multiProvider } = context;
const { key, requiresKey, multiProvider, strategyPath } = argv.context;
if (!requiresKey) return argv;
const strategyConfig = await readChainSubmissionStrategyConfig(
argv.strategy ?? DEFAULT_STRATEGY_CONFIG_PATH,
strategyPath ?? DEFAULT_STRATEGY_CONFIG_PATH,
);
/**

@ -17,6 +17,7 @@ export interface ContextSettings {
requiresKey?: boolean;
disableProxy?: boolean;
skipConfirmation?: boolean;
strategyPath?: string;
}
export interface CommandContext {
@ -27,6 +28,7 @@ export interface CommandContext {
key?: string;
signer?: ethers.Signer;
warpCoreConfig?: WarpCoreConfig;
strategyPath?: string;
}
export interface WriteCommandContext extends CommandContext {

Loading…
Cancel
Save