diff --git a/typescript/cli/src/deploy/utils.ts b/typescript/cli/src/deploy/utils.ts index e5a9a7363f..088d031474 100644 --- a/typescript/cli/src/deploy/utils.ts +++ b/typescript/cli/src/deploy/utils.ts @@ -12,7 +12,7 @@ import { Address, ProtocolType } from '@hyperlane-xyz/utils'; import { parseIsmConfig } from '../config/ism.js'; import { WriteCommandContext } from '../context/types.js'; import { log, logGreen, logPink } from '../logger.js'; -import { assertGasBalances } from '../utils/balances.js'; +import { gasBalancesAreSufficient } from '../utils/balances.js'; import { ENV } from '../utils/env.js'; import { assertSigner } from '../utils/keys.js'; @@ -76,16 +76,16 @@ export async function runPreflightChecksForChains({ assertSigner(signer); logGreen('✅ Signer is valid'); - const lowBalanceExists = await assertGasBalances( + const sufficient = await gasBalancesAreSufficient( multiProvider, signer, chainsToGasCheck ?? chains, minGas, ); logGreen( - lowBalanceExists - ? '⚠️ Balances may not be sufficient' - : '✅ Balances are sufficient', + sufficient + ? '✅ Balances are sufficient' + : '⚠️ Balances may not be sufficient', ); } diff --git a/typescript/cli/src/utils/balances.ts b/typescript/cli/src/utils/balances.ts index 1708b2abe9..c58915de5b 100644 --- a/typescript/cli/src/utils/balances.ts +++ b/typescript/cli/src/utils/balances.ts @@ -3,7 +3,7 @@ import { ethers } from 'ethers'; import { ChainName, MultiProvider } from '@hyperlane-xyz/sdk'; -export async function assertNativeBalances( +export async function nativeBalancesAreSufficient( multiProvider: MultiProvider, signer: ethers.Signer, chains: ChainName[], @@ -11,7 +11,7 @@ export async function assertNativeBalances( ): Promise { const address = await signer.getAddress(); const minBalance = ethers.utils.formatEther(minBalanceWei.toString()); - let lowBalanceExists = false; + let sufficient = true; await Promise.all( chains.map(async (chain) => { const balanceWei = await multiProvider @@ -26,26 +26,26 @@ export async function assertNativeBalances( message: `WARNING: ${error} Continue?`, }); if (!isResume) throw new Error(error); - lowBalanceExists = true; + sufficient = false; } }), ); - return lowBalanceExists; + return sufficient; } -export async function assertGasBalances( +export async function gasBalancesAreSufficient( multiProvider: MultiProvider, signer: ethers.Signer, chains: ChainName[], minGas: string, ): Promise { - let lowBalanceExists = false; + let sufficient = true; await Promise.all( chains.map(async (chain) => { const provider = multiProvider.getProvider(chain); const gasPrice = await provider.getGasPrice(); const minBalanceWei = gasPrice.mul(minGas).toString(); - lowBalanceExists = await assertNativeBalances( + sufficient = await nativeBalancesAreSufficient( multiProvider, signer, [chain], @@ -53,5 +53,5 @@ export async function assertGasBalances( ); }), ); - return lowBalanceExists; + return sufficient; }