@bze/bze-ui-kit 1.0.4 → 1.0.5
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.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4159,6 +4159,7 @@ var useToast = () => {
|
|
|
4159
4159
|
|
|
4160
4160
|
// src/hooks/useTx.tsx
|
|
4161
4161
|
var import_tx13 = require("@bze/bzejs/cosmos/tx/v1beta1/tx");
|
|
4162
|
+
var import_encoding2 = require("@interchainjs/encoding");
|
|
4162
4163
|
var import_react15 = require("@interchain-kit/react");
|
|
4163
4164
|
var import_bignumber13 = __toESM(require("bignumber.js"));
|
|
4164
4165
|
var import_react16 = require("react");
|
|
@@ -4209,7 +4210,7 @@ var useTx = (chainName) => {
|
|
|
4209
4210
|
return isSigningClientReady;
|
|
4210
4211
|
}, [isSigningClientReady, signingClientError]);
|
|
4211
4212
|
const simulateFee = (0, import_react16.useCallback)(async (messages, memo) => {
|
|
4212
|
-
var _a2;
|
|
4213
|
+
var _a2, _b2;
|
|
4213
4214
|
const gasPrice = 0.02;
|
|
4214
4215
|
const nativeDenom = getChainNativeAssetDenom();
|
|
4215
4216
|
const signer = signingClient;
|
|
@@ -4220,9 +4221,26 @@ var useTx = (chainName) => {
|
|
|
4220
4221
|
return { typeUrl, value: encodedValue };
|
|
4221
4222
|
});
|
|
4222
4223
|
const txBody = import_tx13.TxBody.fromPartial({ messages: encodedMessages, memo: memo != null ? memo : "" });
|
|
4223
|
-
const
|
|
4224
|
-
|
|
4225
|
-
|
|
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);
|
|
4241
|
+
if (gasEstimated === 0) {
|
|
4242
|
+
throw new Error("Gas simulation returned 0");
|
|
4243
|
+
}
|
|
4226
4244
|
const gasAmount = (0, import_bignumber13.default)(gasEstimated).multipliedBy(1.5);
|
|
4227
4245
|
const gasPayment = gasAmount.multipliedBy(gasPrice);
|
|
4228
4246
|
const nativeFee = {
|
|
@@ -4258,12 +4276,8 @@ var useTx = (chainName) => {
|
|
|
4258
4276
|
return await simulateFee(messages, options == null ? void 0 : options.memo);
|
|
4259
4277
|
}
|
|
4260
4278
|
} catch (e) {
|
|
4261
|
-
console.error("could not get fee: ", e);
|
|
4262
|
-
|
|
4263
|
-
return defaultFee;
|
|
4264
|
-
} else {
|
|
4265
|
-
throw e;
|
|
4266
|
-
}
|
|
4279
|
+
console.error("could not get fee, using default fee: ", e);
|
|
4280
|
+
return defaultFee;
|
|
4267
4281
|
}
|
|
4268
4282
|
}, [simulateFee]);
|
|
4269
4283
|
const tx = (0, import_react16.useCallback)(async (msgs, options) => {
|