Skip to content

Commit

Permalink
Merge pull request #112 from lum-network/improvement/lum-893
Browse files Browse the repository at this point in the history
[LUM-893] Adjust gas
  • Loading branch information
greedyboi committed Feb 28, 2024
2 parents 2341fee + d3b255f commit 86c3418
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/frontend-elements
20 changes: 11 additions & 9 deletions src/utils/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ const { delegate, beginRedelegate, undelegate } = cosmos.staking.v1beta1.Message
const { withdrawDelegatorReward, setWithdrawAddress } = cosmos.distribution.v1beta1.MessageComposer.withTypeUrl;
const { vote } = cosmos.gov.v1beta1.MessageComposer.withTypeUrl;

const rpcUrl = new URL(process.env.REACT_APP_RPC_URL ?? 'rpc.cosmos.directory/lumnetwork');

class WalletClient {
private lumInfos: LumInfo | null = null;
private node: string = new URL(process.env.REACT_APP_RPC_URL).hostname;
private node: string = rpcUrl.hostname + rpcUrl.pathname;
private chainId: string | null = null;
private queryClient: Awaited<ReturnType<typeof lum.ClientFactory.createRPCQueryClient>> | null = null;
private cosmosSigningClient: SigningStargateClient | null = null;
Expand Down Expand Up @@ -471,7 +473,7 @@ class WalletClient {
const gasEstimated = await this.cosmosSigningClient.simulate(fromWallet.address, [sendMsg], memo);
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(2))).maxDecimals(0).locale(false).toString(),
};

// Fetch chain id
Expand Down Expand Up @@ -518,7 +520,7 @@ class WalletClient {
const gasEstimated = await this.cosmosSigningClient.simulate(fromWallet.address, [delegateMsg], memo);
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(2))).maxDecimals(0).locale(false).toString(),
};

// Fetch chain id
Expand Down Expand Up @@ -565,7 +567,7 @@ class WalletClient {
const gasEstimated = await this.cosmosSigningClient.simulate(fromWallet.address, [undelegateMsg], memo);
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(2))).maxDecimals(0).locale(false).toString(),
};

// Fetch chain id
Expand Down Expand Up @@ -602,7 +604,7 @@ class WalletClient {
const gasEstimated = await this.cosmosSigningClient.simulate(fromWallet.address, [getRewardMsg], memo);
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(2))).maxDecimals(0).locale(false).toString(),
};

// Fetch chain id
Expand Down Expand Up @@ -645,7 +647,7 @@ class WalletClient {
const gasEstimated = await this.cosmosSigningClient.simulate(fromWallet.address, messages, memo);
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(2))).maxDecimals(0).locale(false).toString(),
};

// Fetch chain id
Expand Down Expand Up @@ -699,7 +701,7 @@ class WalletClient {
const gasEstimated = await this.cosmosSigningClient.simulate(fromWallet.address, [redelegateMsg], memo);
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(2))).maxDecimals(0).locale(false).toString(),
};

// Fetch chain id
Expand Down Expand Up @@ -740,7 +742,7 @@ class WalletClient {
const gasEstimated = await this.cosmosSigningClient.simulate(fromWallet.address, [voteMsg], undefined);
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(2))).maxDecimals(0).locale(false).toString(),
};

// Fetch chain id
Expand Down Expand Up @@ -777,7 +779,7 @@ class WalletClient {
const gasEstimated = await this.cosmosSigningClient.simulate(fromWallet.address, [setWithdrawAddressMsg], memo);
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(2))).maxDecimals(0).locale(false).toString(),
};

// Fetch chain id
Expand Down

0 comments on commit 86c3418

Please sign in to comment.