Skip to content

Commit

Permalink
Fixing problem with the gas price.
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-silva-funttastic committed Jan 6, 2024
1 parent 122c303 commit 17daa8f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/connectors/kujira/kujira.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 28 additions & 3 deletions src/connectors/kujira/kujira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import {
runWithRetryAndTimeout,
} from './kujira.helpers';
import {
CHAIN_INFO,
Denom,
fin,
KujiraQueryClient,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -288,6 +308,11 @@ export class Kujira {
this.network = network;

this.kujiraNetwork = convertNetworkToKujiraNetwork(this.network);
this.kujiraNetworkInfo = CHAIN_INFO[this.kujiraNetwork];
this.kujiraNetworkNativeFees = getNotNullOrThrowError<FeeCurrency>(
this.kujiraNetworkInfo['feeCurrencies'].find(it => it.coinDenom == config.nativeToken)
);
this.kujiraNetworkNativeGasPrice = config.gasPrice || BigNumber(getNotNullOrThrowError<number>(this.kujiraNetworkNativeFees.gasPriceStep?.low));

this.accounts = IMap<OwnerAddress, KujiraWalletArtifacts>().asMutable();
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/templates/kujira.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 17daa8f

Please sign in to comment.