@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.js CHANGED
@@ -594,6 +594,10 @@ var getChainExplorerURL = (chainName) => {
594
594
  var getLockerAddress = () => {
595
595
  return process.env.NEXT_PUBLIC_LOCKER_ADDRESS || "bze1pc5zjcvhx3e8l305zjl72grytfa30r5mdypmw4";
596
596
  };
597
+ var getGasMultiplier = () => {
598
+ const val = parseFloat(process.env.NEXT_PUBLIC_GAS_MULTIPLIER || "");
599
+ return isNaN(val) || val <= 0 ? 1.5 : val;
600
+ };
597
601
 
598
602
  // src/storage/storage.ts
599
603
  var TTL_NO_EXPIRY = 0;
@@ -4159,7 +4163,6 @@ var useToast = () => {
4159
4163
 
4160
4164
  // src/hooks/useTx.tsx
4161
4165
  var import_tx13 = require("@bze/bzejs/cosmos/tx/v1beta1/tx");
4162
- var import_encoding2 = require("@interchainjs/encoding");
4163
4166
  var import_react15 = require("@interchain-kit/react");
4164
4167
  var import_bignumber13 = __toESM(require("bignumber.js"));
4165
4168
  var import_react16 = require("react");
@@ -4210,7 +4213,7 @@ var useTx = (chainName) => {
4210
4213
  return isSigningClientReady;
4211
4214
  }, [isSigningClientReady, signingClientError]);
4212
4215
  const simulateFee = (0, import_react16.useCallback)(async (messages, memo) => {
4213
- var _a2, _b2;
4216
+ var _a2;
4214
4217
  const gasPrice = 0.02;
4215
4218
  const nativeDenom = getChainNativeAssetDenom();
4216
4219
  const signer = signingClient;
@@ -4221,27 +4224,14 @@ var useTx = (chainName) => {
4221
4224
  return { typeUrl, value: encodedValue };
4222
4225
  });
4223
4226
  const txBody = import_tx13.TxBody.fromPartial({ messages: encodedMessages, memo: memo != null ? memo : "" });
4224
- const authInfo = import_tx13.AuthInfo.fromPartial({
4225
- signerInfos: [import_tx13.SignerInfo.fromPartial({ modeInfo: { single: { mode: 1 } }, sequence: BigInt(0) })],
4226
- fee: { amount: [], gasLimit: BigInt(0), payer: "", granter: "" }
4227
- });
4228
- const tx2 = import_tx13.Tx.fromPartial({ body: txBody, authInfo, signatures: [new Uint8Array(0)] });
4229
- const txBytes = import_tx13.Tx.encode(tx2).finish();
4230
- const restEndpoint = getSettings().endpoints.restEndpoint.replace(/\/$/, "");
4231
- const simResponse = await fetch(`${restEndpoint}/cosmos/tx/v1beta1/simulate`, {
4232
- method: "POST",
4233
- headers: { "Content-Type": "application/json" },
4234
- body: JSON.stringify({ tx_bytes: (0, import_encoding2.toBase64)(txBytes) })
4235
- });
4236
- if (!simResponse.ok) {
4237
- throw new Error(`Simulation request failed with status ${simResponse.status}`);
4238
- }
4239
- const simData = await simResponse.json();
4240
- const gasEstimated = Number((_b2 = (_a2 = simData == null ? void 0 : simData.gas_info) == null ? void 0 : _a2.gas_used) != null ? _b2 : 0);
4227
+ const sequence = await signer.getSequence(address);
4228
+ const signerInfo = import_tx13.SignerInfo.fromPartial({ modeInfo: { single: { mode: 1 } }, sequence });
4229
+ const { gasInfo } = await signer.simulateByTxBody(txBody, [signerInfo]);
4230
+ const gasEstimated = Number((_a2 = gasInfo == null ? void 0 : gasInfo.gasUsed) != null ? _a2 : BigInt(0));
4241
4231
  if (gasEstimated === 0) {
4242
4232
  throw new Error("Gas simulation returned 0");
4243
4233
  }
4244
- const gasAmount = (0, import_bignumber13.default)(gasEstimated).multipliedBy(1.5);
4234
+ const gasAmount = (0, import_bignumber13.default)(gasEstimated).multipliedBy(getGasMultiplier());
4245
4235
  const gasPayment = gasAmount.multipliedBy(gasPrice);
4246
4236
  const nativeFee = {
4247
4237
  amount: coins(gasPayment.toFixed(0).toString(), nativeDenom),