@bze/bze-ui-kit 1.0.2 → 1.0.3
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 +16 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4059,10 +4059,10 @@ var useToast = () => {
|
|
|
4059
4059
|
};
|
|
4060
4060
|
|
|
4061
4061
|
// src/hooks/useTx.tsx
|
|
4062
|
+
var import_tx = require("@bze/bzejs/cosmos/tx/v1beta1/tx");
|
|
4062
4063
|
var import_react15 = require("@interchain-kit/react");
|
|
4063
4064
|
var import_bignumber13 = __toESM(require("bignumber.js"));
|
|
4064
4065
|
var import_react16 = require("react");
|
|
4065
|
-
var coins2 = (amount, denom) => [{ amount: String(amount), denom }];
|
|
4066
4066
|
var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
4067
4067
|
TxStatus2["Failed"] = "Transaction Failed";
|
|
4068
4068
|
TxStatus2["Successful"] = "Transaction Successful";
|
|
@@ -4070,7 +4070,7 @@ var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
|
4070
4070
|
return TxStatus2;
|
|
4071
4071
|
})(TxStatus || {});
|
|
4072
4072
|
var defaultFee = {
|
|
4073
|
-
amount:
|
|
4073
|
+
amount: coins(2e4, getChainNativeAssetDenom()),
|
|
4074
4074
|
gas: "500000"
|
|
4075
4075
|
};
|
|
4076
4076
|
var useSDKTx = (chainName) => {
|
|
@@ -4110,13 +4110,24 @@ var useTx = (chainName) => {
|
|
|
4110
4110
|
return isSigningClientReady;
|
|
4111
4111
|
}, [isSigningClientReady, signingClientError]);
|
|
4112
4112
|
const simulateFee = (0, import_react16.useCallback)(async (messages, memo) => {
|
|
4113
|
+
var _a2;
|
|
4113
4114
|
const gasPrice = 0.02;
|
|
4114
4115
|
const nativeDenom = getChainNativeAssetDenom();
|
|
4115
|
-
const
|
|
4116
|
+
const signer = signingClient;
|
|
4117
|
+
const encodedMessages = messages.map(({ typeUrl, value }) => {
|
|
4118
|
+
const encoder = signer.getEncoder(typeUrl);
|
|
4119
|
+
const encodedWriter = encoder.encode(value);
|
|
4120
|
+
const encodedValue = typeof (encodedWriter == null ? void 0 : encodedWriter.finish) === "function" ? encodedWriter.finish() : encodedWriter;
|
|
4121
|
+
return { typeUrl, value: encodedValue };
|
|
4122
|
+
});
|
|
4123
|
+
const txBody = import_tx.TxBody.fromPartial({ messages: encodedMessages, memo: memo != null ? memo : "" });
|
|
4124
|
+
const signerInfo = import_tx.SignerInfo.fromPartial({ modeInfo: { single: { mode: 1 } }, sequence: BigInt(0) });
|
|
4125
|
+
const { gasInfo } = await signer.simulateByTxBody(txBody, [signerInfo]);
|
|
4126
|
+
const gasEstimated = Number((_a2 = gasInfo == null ? void 0 : gasInfo.gasUsed) != null ? _a2 : BigInt(0));
|
|
4116
4127
|
const gasAmount = (0, import_bignumber13.default)(gasEstimated).multipliedBy(1.5);
|
|
4117
4128
|
const gasPayment = gasAmount.multipliedBy(gasPrice);
|
|
4118
4129
|
const nativeFee = {
|
|
4119
|
-
amount:
|
|
4130
|
+
amount: coins(gasPayment.toFixed(0).toString(), nativeDenom),
|
|
4120
4131
|
gas: gasAmount.toFixed(0)
|
|
4121
4132
|
};
|
|
4122
4133
|
if (feeDenom === nativeDenom) {
|
|
@@ -4135,7 +4146,7 @@ var useTx = (chainName) => {
|
|
|
4135
4146
|
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(import_bignumber13.default.ROUND_CEIL);
|
|
4136
4147
|
}
|
|
4137
4148
|
return {
|
|
4138
|
-
amount:
|
|
4149
|
+
amount: coins(expectedAmount.toFixed(0).toString(), feeDenom),
|
|
4139
4150
|
gas: gasAmount.multipliedBy(1.5).toFixed(0)
|
|
4140
4151
|
};
|
|
4141
4152
|
}, [signingClient, address, feeDenom, getDenomsPool]);
|