Update fees parsing
Some checks failed
Lint / lint (18.x) (pull_request) Successful in 1m13s
Tests / cli_tests (18.x) (pull_request) Failing after 1m14s

This commit is contained in:
Prathamesh Musale 2024-09-05 11:43:46 +05:30
parent d441c04443
commit 8d49de05f2
2 changed files with 18 additions and 17 deletions

View File

@ -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 => {

View File

@ -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;