From 5f27035e1314f0aa13d833ab07a7ab4b76903915 Mon Sep 17 00:00:00 2001 From: Karim Dalaize Date: Tue, 27 Feb 2024 16:59:25 +0100 Subject: [PATCH] =?UTF-8?q?[Updated]=C2=A0Gas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/constant/wallet.ts | 2 ++ src/utils/lumClient.ts | 17 +++++++++-------- src/utils/walletClient.ts | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/constant/wallet.ts b/src/constant/wallet.ts index fff04c72..bf8ba17b 100644 --- a/src/constant/wallet.ts +++ b/src/constant/wallet.ts @@ -5,3 +5,5 @@ export enum WalletProvider { } export const AUTOCONNECT_STORAGE_KEY = 'autoconnect_storage_key'; + +export const GAS_MULTIPLIER = 2; diff --git a/src/utils/lumClient.ts b/src/utils/lumClient.ts index 56bde405..9a587f5e 100644 --- a/src/utils/lumClient.ts +++ b/src/utils/lumClient.ts @@ -10,6 +10,7 @@ import { EncodeObject, OfflineSigner } from '@cosmjs/proto-signing'; import { Dec, IntPretty } from '@keplr-wallet/unit'; import { LumApi } from 'api'; +import { GAS_MULTIPLIER } from 'constant'; import { AggregatedDepositModel, DepositModel, LumWalletModel, PoolModel, PrizeModel } from 'models'; import { PoolsUtils } from 'utils'; @@ -365,7 +366,7 @@ class LumClient { const gasEstimated = await this.signingClient.simulate(wallet.address, [message], ''); const fee = { amount: coins('25000', MICRO_LUM_DENOM), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const broadcastResult = await this.signingClient.signAndBroadcast(wallet.address, [message], fee); @@ -390,7 +391,7 @@ class LumClient { const gasEstimated = await this.signingClient.simulate(wallet.address, [message], ''); const fee = { amount: coins('25000', MICRO_LUM_DENOM), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const broadcastResult = await this.signingClient.signAndBroadcast(wallet.address, [message], fee); @@ -430,7 +431,7 @@ class LumClient { const gasEstimated = await this.signingClient.simulate(wallet.address, messages, ''); const fee = { amount: coins('25000', MICRO_LUM_DENOM), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const broadcastResult = await this.signingClient.signAndBroadcast(wallet.address, messages, fee); @@ -455,7 +456,7 @@ class LumClient { const gasEstimated = await this.signingClient.simulate(wallet.address, [message], ''); const fee = { amount: coins('25000', MICRO_LUM_DENOM), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const broadcastResult = await this.signingClient.signAndBroadcast(wallet.address, [message], fee); @@ -480,7 +481,7 @@ class LumClient { const gasEstimated = await this.signingClient.simulate(wallet.address, [message], ''); const fee = { amount: coins('25000', MICRO_LUM_DENOM), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const broadcastResult = await this.signingClient.signAndBroadcast(wallet.address, [message], fee); @@ -509,7 +510,7 @@ class LumClient { const gasEstimated = await this.signingClient.simulate(wallet.address, messages, ''); const fee = { amount: coins('25000', MICRO_LUM_DENOM), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const broadcastResult = await this.signingClient.signAndBroadcast(wallet.address, messages, fee); @@ -583,7 +584,7 @@ class LumClient { const gasEstimated = await this.signingClient.simulate(wallet.address, messages, ''); const fee = { amount: coins('25000', MICRO_LUM_DENOM), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const broadcastResult = await this.signingClient.signAndBroadcast(wallet.address, messages, fee); @@ -614,7 +615,7 @@ class LumClient { const gasEstimated = await this.signingClient.simulate(wallet.address, [message], ''); const fee = { amount: coins('25000', MICRO_LUM_DENOM), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const broadcastResult = await this.signingClient.signAndBroadcast(wallet.address, [message], fee); diff --git a/src/utils/walletClient.ts b/src/utils/walletClient.ts index 4c510a5e..df2f4e67 100644 --- a/src/utils/walletClient.ts +++ b/src/utils/walletClient.ts @@ -5,7 +5,7 @@ import { Coin } from '@keplr-wallet/types'; import { Dec, IntPretty } from '@keplr-wallet/unit'; import { cosmos, fromAscii, getSigningIbcClient, ibc } from '@lum-network/sdk-javascript'; -import { ApiConstants } from 'constant'; +import { ApiConstants, GAS_MULTIPLIER } from 'constant'; import { I18n, NumbersUtils } from 'utils'; import { showErrorToast } from './toast'; @@ -147,7 +147,7 @@ class WalletClient { const gasEstimated = await this.walletClient.simulate(fromWallet, [msg], ''); const fee = { amount: coins('25000', feesDenom), - gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(1.3))).maxDecimals(0).locale(false).toString(), + gas: new IntPretty(new Dec(gasEstimated).mul(new Dec(GAS_MULTIPLIER))).maxDecimals(0).locale(false).toString(), }; const res = await this.walletClient.signAndBroadcast(fromWallet, [msg], fee);