From 17daa8fc11b02dba1b7aec0bfee2eafdbefa5073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danilo=20Ara=C3=BAjo=20Silva?= Date: Sat, 6 Jan 2024 00:26:00 +0000 Subject: [PATCH] Fixing problem with the gas price. --- src/connectors/kujira/kujira.config.ts | 2 +- src/connectors/kujira/kujira.ts | 31 +++++++++++++++++++++++--- src/templates/kujira.yml | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/connectors/kujira/kujira.config.ts b/src/connectors/kujira/kujira.config.ts index fdc3f9bdef..ace4fedf41 100644 --- a/src/connectors/kujira/kujira.config.ts +++ b/src/connectors/kujira/kujira.config.ts @@ -27,7 +27,7 @@ export namespace KujiraConfig { prefix: configManager.get('kujira.prefix') || 'kujira', accountNumber: configManager.get('kujira.accountNumber') || 0, nativeToken: 'KUJI', - gasPrice: BigNumber(configManager.get('kujira.gasPrice') || 0.00125), + gasPrice: configManager.get('kujira.gasPrice') ? BigNumber(configManager.get('kujira.gasPrice')) : null, gasPriceSuffix: 'ukuji', gasLimitEstimate: BigNumber( configManager.get('kujira.gasLimitEstimate') || 0.009147 diff --git a/src/connectors/kujira/kujira.ts b/src/connectors/kujira/kujira.ts index 1baa31c7b5..068ba59ffa 100644 --- a/src/connectors/kujira/kujira.ts +++ b/src/connectors/kujira/kujira.ts @@ -117,6 +117,7 @@ import { runWithRetryAndTimeout, } from './kujira.helpers'; import { + CHAIN_INFO, Denom, fin, KujiraQueryClient, @@ -167,6 +168,7 @@ import fse from 'fs-extra'; import { ConfigManagerCertPassphrase } from '../../services/config-manager-cert-passphrase'; import * as crypto from 'crypto'; import util from 'util'; +import {ChainInfo, FeeCurrency} from "@keplr-wallet/types"; const pbkdf2 = util.promisify(crypto.pbkdf2); @@ -206,6 +208,24 @@ export class Kujira { */ private readonly kujiraNetwork: keyof typeof contracts; + /** + * + * @private + */ + private readonly kujiraNetworkInfo: ChainInfo; + + /** + * + * @private + */ + private readonly kujiraNetworkNativeFees: FeeCurrency; + + /** + * + * @private + */ + private readonly kujiraNetworkNativeGasPrice: BigNumber; + /** * * @private @@ -288,6 +308,11 @@ export class Kujira { this.network = network; this.kujiraNetwork = convertNetworkToKujiraNetwork(this.network); + this.kujiraNetworkInfo = CHAIN_INFO[this.kujiraNetwork]; + this.kujiraNetworkNativeFees = getNotNullOrThrowError( + this.kujiraNetworkInfo['feeCurrencies'].find(it => it.coinDenom == config.nativeToken) + ); + this.kujiraNetworkNativeGasPrice = config.gasPrice || BigNumber(getNotNullOrThrowError(this.kujiraNetworkNativeFees.gasPriceStep?.low)); this.accounts = IMap().asMutable(); } @@ -499,7 +524,7 @@ export class Kujira { const prefix: string = config.prefix; - const gasPrice: string = `${config.gasPrice}${config.gasPriceSuffix}`; + const gasPrice: string = `${this.kujiraNetworkNativeGasPrice.toString()}${config.gasPriceSuffix}`; const mnemonic: string = basicWallet.mnemonic; @@ -1996,9 +2021,9 @@ export class Kujira { ): GetEstimatedFeesResponse { return { token: config.nativeToken, - price: config.gasPrice, + price: this.kujiraNetworkNativeGasPrice, limit: config.gasLimitEstimate, - cost: config.gasPrice.multipliedBy(config.gasLimitEstimate), + cost: this.kujiraNetworkNativeGasPrice.multipliedBy(config.gasLimitEstimate), } as EstimatedFees; } diff --git a/src/templates/kujira.yml b/src/templates/kujira.yml index 9966cda9ca..3198776a82 100644 --- a/src/templates/kujira.yml +++ b/src/templates/kujira.yml @@ -31,7 +31,7 @@ networks: nodeURL: null # Empty or null means choosing the RPC automatically prefix: 'kujira' accountNumber: 0 -gasPrice: 0.00125 +gasPrice: null # Empty or null means automatically gasPriceSuffix: 'ukuji' gasLimitEstimate: 0.009147 orderBook: