@bze/bze-ui-kit 1.0.1 → 1.0.2
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 +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +41 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -719,6 +719,36 @@ var openExternalLink = (url) => {
|
|
|
719
719
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
720
720
|
};
|
|
721
721
|
|
|
722
|
+
// src/utils/coins.ts
|
|
723
|
+
var coin = (amount, denom) => {
|
|
724
|
+
let outAmount;
|
|
725
|
+
if (typeof amount === "number") {
|
|
726
|
+
if (!Number.isInteger(amount) || amount < 0 || amount > Number.MAX_SAFE_INTEGER) {
|
|
727
|
+
throw new Error("Given amount is not a safe integer. Consider using a string instead to overcome the limitations of JS numbers.");
|
|
728
|
+
}
|
|
729
|
+
outAmount = String(amount);
|
|
730
|
+
} else {
|
|
731
|
+
if (!amount.match(/^[0-9]+$/)) {
|
|
732
|
+
throw new Error("Invalid unsigned integer string format");
|
|
733
|
+
}
|
|
734
|
+
outAmount = amount.replace(/^0*/, "") || "0";
|
|
735
|
+
}
|
|
736
|
+
return { amount: outAmount, denom };
|
|
737
|
+
};
|
|
738
|
+
var coins = (amount, denom) => {
|
|
739
|
+
return [coin(amount, denom)];
|
|
740
|
+
};
|
|
741
|
+
var parseCoins = (input) => {
|
|
742
|
+
return input.replace(/\s/g, "").split(",").filter(Boolean).map((part) => {
|
|
743
|
+
const match = part.match(/^([0-9]+)([a-zA-Z][a-zA-Z0-9/:._-]{2,127})$/);
|
|
744
|
+
if (!match) throw new Error("Got an invalid coin string");
|
|
745
|
+
return {
|
|
746
|
+
amount: match[1].replace(/^0+/, "") || "0",
|
|
747
|
+
denom: match[2]
|
|
748
|
+
};
|
|
749
|
+
});
|
|
750
|
+
};
|
|
751
|
+
|
|
722
752
|
// src/utils/ibc.ts
|
|
723
753
|
import BigNumber3 from "bignumber.js";
|
|
724
754
|
var canDepositFromIBC = (ibcData2) => {
|
|
@@ -3754,7 +3784,7 @@ var useToast = () => {
|
|
|
3754
3784
|
import { useChain as useChain2 } from "@interchain-kit/react";
|
|
3755
3785
|
import BigNumber13 from "bignumber.js";
|
|
3756
3786
|
import { useCallback as useCallback11, useMemo as useMemo11, useState as useState3 } from "react";
|
|
3757
|
-
var
|
|
3787
|
+
var coins2 = (amount, denom) => [{ amount: String(amount), denom }];
|
|
3758
3788
|
var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
3759
3789
|
TxStatus2["Failed"] = "Transaction Failed";
|
|
3760
3790
|
TxStatus2["Successful"] = "Transaction Successful";
|
|
@@ -3762,7 +3792,7 @@ var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
|
3762
3792
|
return TxStatus2;
|
|
3763
3793
|
})(TxStatus || {});
|
|
3764
3794
|
var defaultFee = {
|
|
3765
|
-
amount:
|
|
3795
|
+
amount: coins2(2e4, getChainNativeAssetDenom()),
|
|
3766
3796
|
gas: "500000"
|
|
3767
3797
|
};
|
|
3768
3798
|
var useSDKTx = (chainName) => {
|
|
@@ -3808,7 +3838,7 @@ var useTx = (chainName) => {
|
|
|
3808
3838
|
const gasAmount = BigNumber13(gasEstimated).multipliedBy(1.5);
|
|
3809
3839
|
const gasPayment = gasAmount.multipliedBy(gasPrice);
|
|
3810
3840
|
const nativeFee = {
|
|
3811
|
-
amount:
|
|
3841
|
+
amount: coins2(gasPayment.toFixed(0).toString(), nativeDenom),
|
|
3812
3842
|
gas: gasAmount.toFixed(0)
|
|
3813
3843
|
};
|
|
3814
3844
|
if (feeDenom === nativeDenom) {
|
|
@@ -3827,7 +3857,7 @@ var useTx = (chainName) => {
|
|
|
3827
3857
|
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(BigNumber13.ROUND_CEIL);
|
|
3828
3858
|
}
|
|
3829
3859
|
return {
|
|
3830
|
-
amount:
|
|
3860
|
+
amount: coins2(expectedAmount.toFixed(0).toString(), feeDenom),
|
|
3831
3861
|
gas: gasAmount.multipliedBy(1.5).toFixed(0)
|
|
3832
3862
|
};
|
|
3833
3863
|
}, [signingClient, address, feeDenom, getDenomsPool]);
|
|
@@ -4470,15 +4500,15 @@ import { WalletState } from "@interchain-kit/core";
|
|
|
4470
4500
|
import BigNumber14 from "bignumber.js";
|
|
4471
4501
|
import { cosmos } from "@bze/bzejs";
|
|
4472
4502
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4473
|
-
var validateAmount = (amount,
|
|
4474
|
-
if (!
|
|
4503
|
+
var validateAmount = (amount, coin2, onError) => {
|
|
4504
|
+
if (!coin2) return;
|
|
4475
4505
|
if (amount === "") return;
|
|
4476
4506
|
const amountNumber = BigNumber14(amount);
|
|
4477
4507
|
if (amountNumber.isNaN()) {
|
|
4478
4508
|
onError("Invalid amount");
|
|
4479
4509
|
return;
|
|
4480
4510
|
}
|
|
4481
|
-
const coinBalance = uAmountToBigNumberAmount(
|
|
4511
|
+
const coinBalance = uAmountToBigNumberAmount(coin2.amount, coin2.decimals);
|
|
4482
4512
|
if (coinBalance.isLessThan(amount)) {
|
|
4483
4513
|
onError("Insufficient balance");
|
|
4484
4514
|
} else {
|
|
@@ -5121,6 +5151,7 @@ export {
|
|
|
5121
5151
|
canSendToIBC,
|
|
5122
5152
|
cancelDebounce,
|
|
5123
5153
|
checkAddressWonRaffle,
|
|
5154
|
+
coins,
|
|
5124
5155
|
convertToWebSocketUrl,
|
|
5125
5156
|
counterpartyChainForChannel,
|
|
5126
5157
|
createMarketId,
|
|
@@ -5252,6 +5283,7 @@ export {
|
|
|
5252
5283
|
keplrSuggestChain,
|
|
5253
5284
|
mapEventAttributes,
|
|
5254
5285
|
openExternalLink,
|
|
5286
|
+
parseCoins,
|
|
5255
5287
|
parseUnbondingDays,
|
|
5256
5288
|
poolIdFromPoolDenom,
|
|
5257
5289
|
prettyAmount,
|