From 7b87ccf1f981c79ec1f9a3305db84865b32292e7 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 3 Oct 2024 16:20:22 +0530 Subject: [PATCH 1/2] Use registry-sdk method to parse gas and fees --- src/util/fees.ts | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/util/fees.ts b/src/util/fees.ts index 50e3afb..1ad5ad4 100644 --- a/src/util/fees.ts +++ b/src/util/fees.ts @@ -1,28 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import assert from 'assert'; import { Arguments } from 'yargs'; -import { StdFee, GasPrice, parseCoins } from '@cosmjs/stargate'; - -export const parseGasAndFees = (gas?: string, fees?: string): StdFee | number | undefined => { - // If fees is not given or a number, treat it as a gas estimation multiplier - if (fees === null || fees === undefined) { - return undefined; - } - - 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) - }; -}; +import { parseGasAndFees, getGasPrice as registryGetGasPrice } from '@cerc-io/registry-sdk'; +import { StdFee, GasPrice } from '@cosmjs/stargate'; export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | number | undefined => { return parseGasAndFees( @@ -33,5 +13,5 @@ export const getGasAndFees = (argv: Arguments, config: any = {}): StdFee | numbe export const getGasPrice = (argv: Arguments, config: any = {}): GasPrice | undefined => { const gasPriceString = argv.gasPrice || config.gasPrice; - return gasPriceString != null ? GasPrice.fromString(String(gasPriceString)) : undefined; + return registryGetGasPrice(gasPriceString); }; -- 2.45.2 From f2ec183965c540c79b20705cdc0efee2993017fa Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 7 Oct 2024 16:48:32 +0530 Subject: [PATCH 2/2] Update registry-sdk version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8c4b64..b2d24a5 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "typescript": "^4.6.3" }, "dependencies": { - "@cerc-io/registry-sdk": "^0.2.10", + "@cerc-io/registry-sdk": "^0.2.11", "@cosmjs/stargate": "^0.32.2", "fs-extra": "^10.1.0", "js-yaml": "^3.14.1", -- 2.45.2