@bze/bze-ui-kit 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -303,6 +303,10 @@ var getChainExplorerURL = (chainName) => {
303
303
  var getLockerAddress = () => {
304
304
  return process.env.NEXT_PUBLIC_LOCKER_ADDRESS || "bze1pc5zjcvhx3e8l305zjl72grytfa30r5mdypmw4";
305
305
  };
306
+ var getGasMultiplier = () => {
307
+ const val = parseFloat(process.env.NEXT_PUBLIC_GAS_MULTIPLIER || "");
308
+ return isNaN(val) || val <= 0 ? 1.5 : val;
309
+ };
306
310
 
307
311
  // src/storage/storage.ts
308
312
  var TTL_NO_EXPIRY = 0;
@@ -3913,8 +3917,7 @@ var useToast = () => {
3913
3917
  };
3914
3918
 
3915
3919
  // src/hooks/useTx.tsx
3916
- import { Tx, TxBody, AuthInfo, SignerInfo } from "@bze/bzejs/cosmos/tx/v1beta1/tx";
3917
- import { toBase64 } from "@interchainjs/encoding";
3920
+ import { TxBody, SignerInfo } from "@bze/bzejs/cosmos/tx/v1beta1/tx";
3918
3921
  import { useChain as useChain2 } from "@interchain-kit/react";
3919
3922
  import BigNumber13 from "bignumber.js";
3920
3923
  import { useCallback as useCallback11, useMemo as useMemo11, useState as useState3 } from "react";
@@ -3965,7 +3968,7 @@ var useTx = (chainName) => {
3965
3968
  return isSigningClientReady;
3966
3969
  }, [isSigningClientReady, signingClientError]);
3967
3970
  const simulateFee = useCallback11(async (messages, memo) => {
3968
- var _a2, _b2;
3971
+ var _a2;
3969
3972
  const gasPrice = 0.02;
3970
3973
  const nativeDenom = getChainNativeAssetDenom();
3971
3974
  const signer = signingClient;
@@ -3976,27 +3979,14 @@ var useTx = (chainName) => {
3976
3979
  return { typeUrl, value: encodedValue };
3977
3980
  });
3978
3981
  const txBody = TxBody.fromPartial({ messages: encodedMessages, memo: memo != null ? memo : "" });
3979
- const authInfo = AuthInfo.fromPartial({
3980
- signerInfos: [SignerInfo.fromPartial({ modeInfo: { single: { mode: 1 } }, sequence: BigInt(0) })],
3981
- fee: { amount: [], gasLimit: BigInt(0), payer: "", granter: "" }
3982
- });
3983
- const tx2 = Tx.fromPartial({ body: txBody, authInfo, signatures: [new Uint8Array(0)] });
3984
- const txBytes = Tx.encode(tx2).finish();
3985
- const restEndpoint = getSettings().endpoints.restEndpoint.replace(/\/$/, "");
3986
- const simResponse = await fetch(`${restEndpoint}/cosmos/tx/v1beta1/simulate`, {
3987
- method: "POST",
3988
- headers: { "Content-Type": "application/json" },
3989
- body: JSON.stringify({ tx_bytes: toBase64(txBytes) })
3990
- });
3991
- if (!simResponse.ok) {
3992
- throw new Error(`Simulation request failed with status ${simResponse.status}`);
3993
- }
3994
- const simData = await simResponse.json();
3995
- const gasEstimated = Number((_b2 = (_a2 = simData == null ? void 0 : simData.gas_info) == null ? void 0 : _a2.gas_used) != null ? _b2 : 0);
3982
+ const sequence = await signer.getSequence(address);
3983
+ const signerInfo = SignerInfo.fromPartial({ modeInfo: { single: { mode: 1 } }, sequence });
3984
+ const { gasInfo } = await signer.simulateByTxBody(txBody, [signerInfo]);
3985
+ const gasEstimated = Number((_a2 = gasInfo == null ? void 0 : gasInfo.gasUsed) != null ? _a2 : BigInt(0));
3996
3986
  if (gasEstimated === 0) {
3997
3987
  throw new Error("Gas simulation returned 0");
3998
3988
  }
3999
- const gasAmount = BigNumber13(gasEstimated).multipliedBy(1.5);
3989
+ const gasAmount = BigNumber13(gasEstimated).multipliedBy(getGasMultiplier());
4000
3990
  const gasPayment = gasAmount.multipliedBy(gasPrice);
4001
3991
  const nativeFee = {
4002
3992
  amount: coins(gasPayment.toFixed(0).toString(), nativeDenom),