@bze/bze-ui-kit 1.0.4 → 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;
@@ -3975,10 +3979,14 @@ var useTx = (chainName) => {
3975
3979
  return { typeUrl, value: encodedValue };
3976
3980
  });
3977
3981
  const txBody = TxBody.fromPartial({ messages: encodedMessages, memo: memo != null ? memo : "" });
3978
- const signerInfo = SignerInfo.fromPartial({ modeInfo: { single: { mode: 1 } }, sequence: BigInt(0) });
3982
+ const sequence = await signer.getSequence(address);
3983
+ const signerInfo = SignerInfo.fromPartial({ modeInfo: { single: { mode: 1 } }, sequence });
3979
3984
  const { gasInfo } = await signer.simulateByTxBody(txBody, [signerInfo]);
3980
3985
  const gasEstimated = Number((_a2 = gasInfo == null ? void 0 : gasInfo.gasUsed) != null ? _a2 : BigInt(0));
3981
- const gasAmount = BigNumber13(gasEstimated).multipliedBy(1.5);
3986
+ if (gasEstimated === 0) {
3987
+ throw new Error("Gas simulation returned 0");
3988
+ }
3989
+ const gasAmount = BigNumber13(gasEstimated).multipliedBy(getGasMultiplier());
3982
3990
  const gasPayment = gasAmount.multipliedBy(gasPrice);
3983
3991
  const nativeFee = {
3984
3992
  amount: coins(gasPayment.toFixed(0).toString(), nativeDenom),
@@ -4013,12 +4021,8 @@ var useTx = (chainName) => {
4013
4021
  return await simulateFee(messages, options == null ? void 0 : options.memo);
4014
4022
  }
4015
4023
  } catch (e) {
4016
- console.error("could not get fee: ", e);
4017
- if (options == null ? void 0 : options.fallbackOnSimulate) {
4018
- return defaultFee;
4019
- } else {
4020
- throw e;
4021
- }
4024
+ console.error("could not get fee, using default fee: ", e);
4025
+ return defaultFee;
4022
4026
  }
4023
4027
  }, [simulateFee]);
4024
4028
  const tx = useCallback11(async (msgs, options) => {