Update fees parsing
This commit is contained in:
parent
b7fde03bd4
commit
5dcbdf505d
@ -5,14 +5,16 @@ 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) {
|
||||
}
|
||||
|
||||
const isFeesANumber = !isNaN(Number(fees));
|
||||
if (isFeesANumber) {
|
||||
return Number(fees);
|
||||
} else {
|
||||
}
|
||||
|
||||
// If fees is not a gas estimation multiplier, gas is required
|
||||
assert(gas, 'Invalid gas.');
|
||||
|
||||
@ -20,7 +22,6 @@ export const parseGasAndFees = (gas?: string, fees?: string): StdFee | number |
|
||||
amount: parseCoins(String(fees)),
|
||||
gas: String(gas)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | number | undefined => {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user