diff --git a/src/util/fees.ts b/src/util/fees.ts index 589810f..50e3afb 100644 --- a/src/util/fees.ts +++ b/src/util/fees.ts @@ -5,22 +5,23 @@ import { Arguments } from 'yargs'; import { StdFee, GasPrice, parseCoins } from '@cosmjs/stargate'; export const parseGasAndFees = (gas?: string, fees?: string): StdFee | number | undefined => { - const isFeesANumber = !isNaN(Number(fees)); - - // If fees is a number or not given, treat it as a gas estimation multiplier - if (fees == null) { + // If fees is not given or a number, treat it as a gas estimation multiplier + if (fees === null || fees === undefined) { return undefined; - } else if (isFeesANumber) { - return Number(fees); - } else { - // If fees is not a gas estimation multiplier, gas is required - assert(gas, 'Invalid gas.'); - - return { - amount: parseCoins(String(fees)), - gas: String(gas) - }; } + + const isFeesANumber = !isNaN(Number(fees)); + if (isFeesANumber) { + return Number(fees); + } + + // If fees is not a gas estimation multiplier, gas is required + assert(gas, 'Invalid gas.'); + + return { + amount: parseCoins(String(fees)), + gas: String(gas) + }; }; export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | number | undefined => { diff --git a/test/helpers.ts b/test/helpers.ts index b024e4e..84d8326 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -126,19 +126,19 @@ export function updateGasAndFeesConfig (gas?: string | null, fees?: string | nul const configFilePath = './config.yml'; const config = getConfig(path.resolve(configFilePath)); - if (gas != null) { + if (gas) { config.services.registry.gas = gas; } else if (gas === null) { delete config.services.registry.gas; } - if (fees != null) { + if (fees) { config.services.registry.fees = fees; } else if (fees === null) { delete config.services.registry.fees; } - if (gasPrice != null) { + if (gasPrice) { config.services.registry.gasPrice = gasPrice; } else if (gasPrice === null) { delete config.services.registry.gasPrice;