Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: balance check skip confirmation #5012

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/five-bats-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/cli': patch
---

fix: balance check skip confirmation
3 changes: 2 additions & 1 deletion typescript/cli/src/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function runPreflightChecksForChains({
chainsToGasCheck?: ChainName[];
}) {
log('Running pre-flight checks for chains...');
const { multiProvider } = context;
const { multiProvider, skipConfirmation } = context;

if (!chains?.length) throw new Error('Empty chain selection');
for (const chain of chains) {
Expand All @@ -59,6 +59,7 @@ export async function runPreflightChecksForChains({
multiProvider,
chainsToGasCheck ?? chains,
minGas,
skipConfirmation,
);
}

Expand Down
12 changes: 7 additions & 5 deletions typescript/cli/src/utils/balances.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { confirm } from '@inquirer/prompts';
import { ethers } from 'ethers';

import { ChainName, MultiProvider } from '@hyperlane-xyz/sdk';
import { ProtocolType } from '@hyperlane-xyz/utils';

import { logGray, logGreen, logRed } from '../logger.js';
import { autoConfirm } from '../config/prompts.js';
import { logBlue, logGray, logGreen, logRed, warnYellow } from '../logger.js';

export async function nativeBalancesAreSufficient(
multiProvider: MultiProvider,
chains: ChainName[],
minGas: string,
skipConfirmation: boolean,
) {
const sufficientBalances: boolean[] = [];
for (const chain of chains) {
Expand Down Expand Up @@ -42,9 +43,10 @@ export async function nativeBalancesAreSufficient(
if (allSufficient) {
logGreen('✅ Balances are sufficient');
} else {
const isResume = await confirm({
message: 'Deployment may fail due to insufficient balance(s). Continue?',
});
warnYellow(`Deployment may fail due to insufficient balance(s)`);
const isResume = await autoConfirm('Continue?', skipConfirmation, () =>
logBlue('Continuing deployment with insufficient balances'),
);
if (!isResume) throw new Error('Canceled deployment due to low balance');
}
}
Loading