Skip to content

Commit

Permalink
Fixes for CLI dry-runs (#3713)
Browse files Browse the repository at this point in the history
### Description

- Fixes type of dry-run arg in deploy command definitions
- Runs verifyAnvil during dry-run context setup
  • Loading branch information
jmrossy authored May 6, 2024
1 parent 8e5ef27 commit 78b77ee
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-papayas-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/cli': patch
---

Fixes for CLI dry-runs
10 changes: 3 additions & 7 deletions typescript/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '../context/types.js';
import { runKurtosisAgentDeploy } from '../deploy/agent.js';
import { runCoreDeploy } from '../deploy/core.js';
import { evaluateIfDryRunFailure, verifyAnvil } from '../deploy/dry-run.js';
import { evaluateIfDryRunFailure } from '../deploy/dry-run.js';
import { runWarpRouteDeploy } from '../deploy/warp.js';
import { log, logGray } from '../logger.js';

Expand Down Expand Up @@ -72,7 +72,7 @@ const coreCommand: CommandModuleWithWriteContext<{
targets: string;
ism?: string;
hook?: string;
'dry-run': boolean;
'dry-run': string;
agent: string;
}> = {
command: 'core',
Expand All @@ -90,8 +90,6 @@ const coreCommand: CommandModuleWithWriteContext<{
);
logGray('------------------------------------------------');

if (dryRun) await verifyAnvil();

try {
const chains = targets?.split(',').map((r: string) => r.trim());
await runCoreDeploy({
Expand All @@ -114,7 +112,7 @@ const coreCommand: CommandModuleWithWriteContext<{
*/
const warpCommand: CommandModuleWithWriteContext<{
config: string;
'dry-run': boolean;
'dry-run': string;
}> = {
command: 'warp',
describe: 'Deploy Warp Route contracts',
Expand All @@ -126,8 +124,6 @@ const warpCommand: CommandModuleWithWriteContext<{
logGray(`Hyperlane warp route deployment${dryRun ? ' dry-run' : ''}`);
logGray('------------------------------------------------');

if (dryRun) await verifyAnvil();

try {
await runWarpRouteDeploy({
context,
Expand Down
3 changes: 2 additions & 1 deletion typescript/cli/src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ChainName, MultiProvider } from '@hyperlane-xyz/sdk';
import { isNullish } from '@hyperlane-xyz/utils';

import { isSignCommand } from '../commands/signCommands.js';
import { forkNetworkToMultiProvider } from '../deploy/dry-run.js';
import { forkNetworkToMultiProvider, verifyAnvil } from '../deploy/dry-run.js';
import { logBlue } from '../logger.js';
import { MergedRegistry } from '../registry/MergedRegistry.js';
import { runSingleChainSelectionStep } from '../utils/chains.js';
Expand Down Expand Up @@ -82,6 +82,7 @@ export async function getDryRunContext(
}

logBlue(`Dry-running against chain: ${chain}`);
await verifyAnvil();

const multiProvider = await getMultiProvider(registry);
await forkNetworkToMultiProvider(multiProvider, chain);
Expand Down
2 changes: 1 addition & 1 deletion typescript/cli/src/deploy/dry-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function verifyAnvil() {
* @param error the thrown error
* @param dryRun the chain name to execute the dry-run on
*/
export function evaluateIfDryRunFailure(error: any, dryRun: boolean) {
export function evaluateIfDryRunFailure(error: any, dryRun: string) {
if (dryRun && error.message.includes('call revert exception'))
warnYellow(
'⛔️ [dry-run] The current RPC may not support forking. Please consider using a different RPC provider.',
Expand Down
2 changes: 1 addition & 1 deletion typescript/cli/src/deploy/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async function executeDeploy(params: DeployParams) {

logGreen('✅ Hyp token deployments complete');

log('Writing deployment artifacts');
if (!isDryRun) log('Writing deployment artifacts');
const warpCoreConfig = getWarpCoreConfig(params, deployedContracts);
await registry.addWarpRoute(warpCoreConfig);
log(JSON.stringify(warpCoreConfig, null, 2));
Expand Down

0 comments on commit 78b77ee

Please sign in to comment.