@bze/bze-ui-kit 0.2.1 → 0.2.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 +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +83 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2949,12 +2949,29 @@ function useBalance(denom) {
|
|
|
2949
2949
|
}
|
|
2950
2950
|
|
|
2951
2951
|
// src/hooks/useEpochs.ts
|
|
2952
|
-
import { useMemo as useMemo6 } from "react";
|
|
2952
|
+
import { useCallback as useCallback6, useMemo as useMemo6 } from "react";
|
|
2953
|
+
import BigNumber9 from "bignumber.js";
|
|
2953
2954
|
var EPOCH_HOUR2 = "hour";
|
|
2954
2955
|
var EPOCH_DAY2 = "day";
|
|
2955
2956
|
var EPOCH_WEEK2 = "week";
|
|
2957
|
+
function getEpochDurationByIdentifier2(identifier) {
|
|
2958
|
+
const hourMs = 60 * 60 * 1e3;
|
|
2959
|
+
switch (identifier) {
|
|
2960
|
+
case EPOCH_HOUR2:
|
|
2961
|
+
return hourMs;
|
|
2962
|
+
case EPOCH_DAY2:
|
|
2963
|
+
return hourMs * 24;
|
|
2964
|
+
case EPOCH_WEEK2:
|
|
2965
|
+
return hourMs * 24 * 7;
|
|
2966
|
+
default:
|
|
2967
|
+
return hourMs;
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2956
2970
|
function useEpochs() {
|
|
2957
2971
|
const { epochs, isLoading, updateEpochs } = useAssetsContext();
|
|
2972
|
+
const getCurrentEpoch2 = useCallback6((identifier) => {
|
|
2973
|
+
return epochs.get(identifier);
|
|
2974
|
+
}, [epochs]);
|
|
2958
2975
|
const hourEpochInfo = useMemo6(() => {
|
|
2959
2976
|
return epochs.get(EPOCH_HOUR2);
|
|
2960
2977
|
}, [epochs]);
|
|
@@ -2964,19 +2981,65 @@ function useEpochs() {
|
|
|
2964
2981
|
const weekEpochInfo = useMemo6(() => {
|
|
2965
2982
|
return epochs.get(EPOCH_WEEK2);
|
|
2966
2983
|
}, [epochs]);
|
|
2984
|
+
const getHourEpochInfo2 = useCallback6(() => {
|
|
2985
|
+
return epochs.get(EPOCH_HOUR2);
|
|
2986
|
+
}, [epochs]);
|
|
2987
|
+
const getDayEpochInfo = useCallback6(() => {
|
|
2988
|
+
return epochs.get(EPOCH_DAY2);
|
|
2989
|
+
}, [epochs]);
|
|
2990
|
+
const getWeekEpochInfo2 = useCallback6(() => {
|
|
2991
|
+
return epochs.get(EPOCH_WEEK2);
|
|
2992
|
+
}, [epochs]);
|
|
2993
|
+
const getPeriodicEpochEndTime2 = useCallback6((identifier, modWeek = 1) => {
|
|
2994
|
+
const epoch = epochs.get(identifier);
|
|
2995
|
+
if (!epoch || !epoch.current_epoch_start_time) {
|
|
2996
|
+
return void 0;
|
|
2997
|
+
}
|
|
2998
|
+
const current = new BigNumber9(epoch.current_epoch);
|
|
2999
|
+
let remainingEpochs = modWeek - current.toNumber() % modWeek;
|
|
3000
|
+
if (remainingEpochs === modWeek) {
|
|
3001
|
+
remainingEpochs = 0;
|
|
3002
|
+
}
|
|
3003
|
+
const startAt = new Date(epoch.current_epoch_start_time);
|
|
3004
|
+
const duration = getEpochDurationByIdentifier2(identifier);
|
|
3005
|
+
startAt.setTime(startAt.getTime() + duration + duration * remainingEpochs);
|
|
3006
|
+
return startAt;
|
|
3007
|
+
}, [epochs]);
|
|
3008
|
+
const getCurrentWeekEpochEndTime2 = useCallback6(() => {
|
|
3009
|
+
return getPeriodicEpochEndTime2(EPOCH_WEEK2);
|
|
3010
|
+
}, [getPeriodicEpochEndTime2]);
|
|
3011
|
+
const getPeriodicWeekEpochEndTime2 = useCallback6((modWeek = 1) => {
|
|
3012
|
+
return getPeriodicEpochEndTime2(EPOCH_WEEK2, modWeek);
|
|
3013
|
+
}, [getPeriodicEpochEndTime2]);
|
|
3014
|
+
const epochsList = useMemo6(() => Array.from(epochs.values()), [epochs]);
|
|
2967
3015
|
return {
|
|
2968
|
-
epochs,
|
|
3016
|
+
epochs: epochsList,
|
|
3017
|
+
epochsMap: epochs,
|
|
2969
3018
|
hourEpochInfo,
|
|
2970
3019
|
dayEpochInfo,
|
|
2971
3020
|
weekEpochInfo,
|
|
2972
3021
|
isLoading,
|
|
2973
|
-
updateEpochs
|
|
3022
|
+
updateEpochs,
|
|
3023
|
+
getCurrentEpoch: getCurrentEpoch2,
|
|
3024
|
+
getHourEpochInfo: getHourEpochInfo2,
|
|
3025
|
+
getDayEpochInfo,
|
|
3026
|
+
getWeekEpochInfo: getWeekEpochInfo2,
|
|
3027
|
+
getCurrentWeekEpochEndTime: getCurrentWeekEpochEndTime2,
|
|
3028
|
+
getPeriodicWeekEpochEndTime: getPeriodicWeekEpochEndTime2,
|
|
3029
|
+
getPeriodicEpochEndTime: getPeriodicEpochEndTime2
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
function useEpochsManager() {
|
|
3033
|
+
const { updateEpochs, isLoading } = useAssetsContext();
|
|
3034
|
+
return {
|
|
3035
|
+
updateEpochs,
|
|
3036
|
+
isLoading
|
|
2974
3037
|
};
|
|
2975
3038
|
}
|
|
2976
3039
|
|
|
2977
3040
|
// src/hooks/useLiquidityPools.ts
|
|
2978
|
-
import { useCallback as
|
|
2979
|
-
import
|
|
3041
|
+
import { useCallback as useCallback7, useMemo as useMemo7 } from "react";
|
|
3042
|
+
import BigNumber10 from "bignumber.js";
|
|
2980
3043
|
function useLiquidityPools() {
|
|
2981
3044
|
const { poolsMap, poolsDataMap, updateLiquidityPools, isLoading, assetsMap } = useAssetsContext();
|
|
2982
3045
|
const pools = useMemo7(() => {
|
|
@@ -2986,7 +3049,7 @@ function useLiquidityPools() {
|
|
|
2986
3049
|
const poolId = poolIdFromPoolDenom(lpDenom);
|
|
2987
3050
|
return poolsMap.get(poolId);
|
|
2988
3051
|
};
|
|
2989
|
-
const getDenomsPool =
|
|
3052
|
+
const getDenomsPool = useCallback7((denomA, denomB) => {
|
|
2990
3053
|
const poolId = createPoolId(denomA, denomB);
|
|
2991
3054
|
return poolsMap.get(poolId);
|
|
2992
3055
|
}, [poolsMap]);
|
|
@@ -3030,7 +3093,7 @@ function useAssetLiquidityPools(denom) {
|
|
|
3030
3093
|
return newMap;
|
|
3031
3094
|
}, [assetPools, poolsDataMap, isLoading, denom]);
|
|
3032
3095
|
const asset24HoursVolume = useMemo7(() => {
|
|
3033
|
-
let volume =
|
|
3096
|
+
let volume = BigNumber10(0);
|
|
3034
3097
|
if (isLoading || denom === "") return volume;
|
|
3035
3098
|
assetPoolsData.forEach((poolData) => {
|
|
3036
3099
|
if (poolData.base === denom) {
|
|
@@ -3085,13 +3148,13 @@ function useLiquidityPool(poolId) {
|
|
|
3085
3148
|
const reserveQuote = toBigNumber(pool.reserve_quote);
|
|
3086
3149
|
return userShares.dividedBy(totalShares).multipliedBy(reserveQuote);
|
|
3087
3150
|
}, [pool, userShares, totalShares]);
|
|
3088
|
-
const calculateOppositeAmount =
|
|
3151
|
+
const calculateOppositeAmount = useCallback7((amount, isBase) => {
|
|
3089
3152
|
if (!pool) {
|
|
3090
3153
|
return toBigNumber(0);
|
|
3091
3154
|
}
|
|
3092
3155
|
return calculatePoolOppositeAmount(pool, amount, isBase);
|
|
3093
3156
|
}, [pool]);
|
|
3094
|
-
const calculateSharesFromAmounts =
|
|
3157
|
+
const calculateSharesFromAmounts = useCallback7((baseAmount, quoteAmount) => {
|
|
3095
3158
|
if (!pool || !totalShares) {
|
|
3096
3159
|
return toBigNumber(0);
|
|
3097
3160
|
}
|
|
@@ -3107,9 +3170,9 @@ function useLiquidityPool(poolId) {
|
|
|
3107
3170
|
}
|
|
3108
3171
|
const baseRatio = baseAmountBN.dividedBy(reserveBase);
|
|
3109
3172
|
const quoteRatio = quoteAmountBN.dividedBy(reserveQuote);
|
|
3110
|
-
const mintRatio =
|
|
3173
|
+
const mintRatio = BigNumber10.minimum(baseRatio, quoteRatio);
|
|
3111
3174
|
const tokensToMint = mintRatio.multipliedBy(totalShares);
|
|
3112
|
-
return tokensToMint.integerValue(
|
|
3175
|
+
return tokensToMint.integerValue(BigNumber10.ROUND_DOWN);
|
|
3113
3176
|
}, [pool, totalShares]);
|
|
3114
3177
|
return {
|
|
3115
3178
|
isLoading,
|
|
@@ -3126,12 +3189,12 @@ function useLiquidityPool(poolId) {
|
|
|
3126
3189
|
}
|
|
3127
3190
|
|
|
3128
3191
|
// src/hooks/useAssetsValue.ts
|
|
3129
|
-
import { useCallback as
|
|
3130
|
-
import
|
|
3192
|
+
import { useCallback as useCallback8, useMemo as useMemo8 } from "react";
|
|
3193
|
+
import BigNumber11 from "bignumber.js";
|
|
3131
3194
|
function useAssetsValue() {
|
|
3132
3195
|
const { assetsMap, usdPricesMap, balancesMap, isLoading: isLoadingPrices } = useAssetsContext();
|
|
3133
|
-
const totalUsdValue =
|
|
3134
|
-
let usdValue =
|
|
3196
|
+
const totalUsdValue = useCallback8((prettyBalances) => {
|
|
3197
|
+
let usdValue = BigNumber11(0);
|
|
3135
3198
|
prettyBalances.map((denomBalance) => {
|
|
3136
3199
|
const assetPrice = usdPricesMap.get(denomBalance.denom);
|
|
3137
3200
|
if (assetPrice && assetPrice.gt(0)) {
|
|
@@ -3151,21 +3214,21 @@ function useAssetsValue() {
|
|
|
3151
3214
|
});
|
|
3152
3215
|
return total;
|
|
3153
3216
|
}, [balancesMap, usdPricesMap, assetsMap]);
|
|
3154
|
-
const denomUsdValue =
|
|
3217
|
+
const denomUsdValue = useCallback8((denom, uAmount) => {
|
|
3155
3218
|
const price = usdPricesMap.get(denom);
|
|
3156
3219
|
if (!price || !price.gt(0)) return toBigNumber(0);
|
|
3157
3220
|
const asset = assetsMap.get(denom);
|
|
3158
3221
|
if (!asset) return toBigNumber(0);
|
|
3159
3222
|
return price.multipliedBy(uAmountToBigNumberAmount(uAmount, asset.decimals));
|
|
3160
3223
|
}, [usdPricesMap, assetsMap]);
|
|
3161
|
-
const compareValues =
|
|
3224
|
+
const compareValues = useCallback8((a, b) => {
|
|
3162
3225
|
var _a2;
|
|
3163
|
-
let aValue =
|
|
3226
|
+
let aValue = BigNumber11(0);
|
|
3164
3227
|
const aPrice = usdPricesMap.get(a.denom);
|
|
3165
3228
|
if (aPrice) {
|
|
3166
3229
|
aValue = aPrice.multipliedBy(a.amount);
|
|
3167
3230
|
}
|
|
3168
|
-
let bValue =
|
|
3231
|
+
let bValue = BigNumber11(0);
|
|
3169
3232
|
const bPrice = usdPricesMap.get(b.denom);
|
|
3170
3233
|
if (bPrice) {
|
|
3171
3234
|
bValue = bPrice.multipliedBy(b.amount);
|
|
@@ -3218,17 +3281,17 @@ function useFeeTokens() {
|
|
|
3218
3281
|
}
|
|
3219
3282
|
|
|
3220
3283
|
// src/hooks/useMarkets.ts
|
|
3221
|
-
import { useCallback as
|
|
3222
|
-
import
|
|
3284
|
+
import { useCallback as useCallback9, useMemo as useMemo10 } from "react";
|
|
3285
|
+
import BigNumber12 from "bignumber.js";
|
|
3223
3286
|
function useMarkets() {
|
|
3224
3287
|
const { marketsMap, marketsDataMap, updateMarkets, isLoading } = useAssetsContext();
|
|
3225
3288
|
const markets = useMemo10(() => {
|
|
3226
3289
|
return Array.from(marketsMap.values());
|
|
3227
3290
|
}, [marketsMap]);
|
|
3228
3291
|
const marketsData = useMemo10(() => Array.from(marketsDataMap.values()), [marketsDataMap]);
|
|
3229
|
-
const marketExists =
|
|
3230
|
-
const getMarketData =
|
|
3231
|
-
const getMarket =
|
|
3292
|
+
const marketExists = useCallback9((marketId) => marketsMap.has(marketId), [marketsMap]);
|
|
3293
|
+
const getMarketData = useCallback9((marketId) => marketsDataMap.get(marketId), [marketsDataMap]);
|
|
3294
|
+
const getMarket = useCallback9((marketId) => marketsMap.get(marketId), [marketsMap]);
|
|
3232
3295
|
return {
|
|
3233
3296
|
markets,
|
|
3234
3297
|
marketsData,
|
|
@@ -3271,7 +3334,7 @@ function useAssetMarkets(denom) {
|
|
|
3271
3334
|
return acc.plus(market.quote_volume || 0);
|
|
3272
3335
|
}
|
|
3273
3336
|
return acc;
|
|
3274
|
-
}, new
|
|
3337
|
+
}, new BigNumber12(0));
|
|
3275
3338
|
}, [assetMarketsData, denom]);
|
|
3276
3339
|
return {
|
|
3277
3340
|
isLoading,
|
|
@@ -3324,7 +3387,7 @@ function useMarketsManager() {
|
|
|
3324
3387
|
}
|
|
3325
3388
|
|
|
3326
3389
|
// src/hooks/useToast.tsx
|
|
3327
|
-
import { useCallback as
|
|
3390
|
+
import { useCallback as useCallback10, useMemo as useMemo11 } from "react";
|
|
3328
3391
|
|
|
3329
3392
|
// src/components/toaster.tsx
|
|
3330
3393
|
import {
|
|
@@ -3354,7 +3417,7 @@ var Toaster = () => {
|
|
|
3354
3417
|
|
|
3355
3418
|
// src/hooks/useToast.tsx
|
|
3356
3419
|
var useToast = () => {
|
|
3357
|
-
const clickableSuccess =
|
|
3420
|
+
const clickableSuccess = useCallback10((title, actionFn, actionLabel, description, duration = 5e3) => {
|
|
3358
3421
|
toaster.create({
|
|
3359
3422
|
title,
|
|
3360
3423
|
description,
|
|
@@ -3367,7 +3430,7 @@ var useToast = () => {
|
|
|
3367
3430
|
}
|
|
3368
3431
|
});
|
|
3369
3432
|
}, []);
|
|
3370
|
-
const success =
|
|
3433
|
+
const success = useCallback10((title, description, duration = 5e3) => {
|
|
3371
3434
|
toaster.create({
|
|
3372
3435
|
title,
|
|
3373
3436
|
description,
|
|
@@ -3376,7 +3439,7 @@ var useToast = () => {
|
|
|
3376
3439
|
closable: true
|
|
3377
3440
|
});
|
|
3378
3441
|
}, []);
|
|
3379
|
-
const error =
|
|
3442
|
+
const error = useCallback10((title, description, duration = 8e3) => {
|
|
3380
3443
|
toaster.create({
|
|
3381
3444
|
title,
|
|
3382
3445
|
description,
|
|
@@ -3385,7 +3448,7 @@ var useToast = () => {
|
|
|
3385
3448
|
closable: true
|
|
3386
3449
|
});
|
|
3387
3450
|
}, []);
|
|
3388
|
-
const warning =
|
|
3451
|
+
const warning = useCallback10((title, description, duration = 6e3) => {
|
|
3389
3452
|
toaster.create({
|
|
3390
3453
|
title,
|
|
3391
3454
|
description,
|
|
@@ -3394,7 +3457,7 @@ var useToast = () => {
|
|
|
3394
3457
|
closable: true
|
|
3395
3458
|
});
|
|
3396
3459
|
}, []);
|
|
3397
|
-
const info =
|
|
3460
|
+
const info = useCallback10((title, description, duration = 5e3) => {
|
|
3398
3461
|
toaster.create({
|
|
3399
3462
|
title,
|
|
3400
3463
|
description,
|
|
@@ -3403,7 +3466,7 @@ var useToast = () => {
|
|
|
3403
3466
|
closable: true
|
|
3404
3467
|
});
|
|
3405
3468
|
}, []);
|
|
3406
|
-
const loading =
|
|
3469
|
+
const loading = useCallback10((title, description) => {
|
|
3407
3470
|
return toaster.create({
|
|
3408
3471
|
title,
|
|
3409
3472
|
description,
|
|
@@ -3411,7 +3474,7 @@ var useToast = () => {
|
|
|
3411
3474
|
closable: false
|
|
3412
3475
|
});
|
|
3413
3476
|
}, []);
|
|
3414
|
-
const dismiss =
|
|
3477
|
+
const dismiss = useCallback10((id) => {
|
|
3415
3478
|
toaster.dismiss(id);
|
|
3416
3479
|
}, []);
|
|
3417
3480
|
const toast = useMemo11(() => ({
|
|
@@ -3429,8 +3492,8 @@ var useToast = () => {
|
|
|
3429
3492
|
// src/hooks/useTx.tsx
|
|
3430
3493
|
import { coins, isDeliverTxSuccess } from "@cosmjs/stargate";
|
|
3431
3494
|
import { useChain as useChain2 } from "@interchain-kit/react";
|
|
3432
|
-
import
|
|
3433
|
-
import { useCallback as
|
|
3495
|
+
import BigNumber13 from "bignumber.js";
|
|
3496
|
+
import { useCallback as useCallback11, useMemo as useMemo12, useState as useState3 } from "react";
|
|
3434
3497
|
var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
3435
3498
|
TxStatus2["Failed"] = "Transaction Failed";
|
|
3436
3499
|
TxStatus2["Successful"] = "Transaction Successful";
|
|
@@ -3470,18 +3533,18 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
3470
3533
|
const { getDenomsPool } = useLiquidityPools();
|
|
3471
3534
|
const { feeDenom } = useSettings();
|
|
3472
3535
|
const defaultChainName = useMemo12(() => getChainName(), []);
|
|
3473
|
-
const canUseClient =
|
|
3536
|
+
const canUseClient = useCallback11(async () => {
|
|
3474
3537
|
if (!isSigningClientReady) {
|
|
3475
3538
|
console.error("waiting for signing client to be ready", signingClientError);
|
|
3476
3539
|
await sleep(1e3);
|
|
3477
3540
|
}
|
|
3478
3541
|
return isSigningClientReady;
|
|
3479
3542
|
}, [isSigningClientReady, signingClientError]);
|
|
3480
|
-
const simulateFee =
|
|
3543
|
+
const simulateFee = useCallback11(async (messages, memo) => {
|
|
3481
3544
|
const gasPrice = 0.02;
|
|
3482
3545
|
const nativeDenom = getChainNativeAssetDenom();
|
|
3483
3546
|
const gasEstimated = await signingClient.simulate(address, messages, memo);
|
|
3484
|
-
const gasAmount =
|
|
3547
|
+
const gasAmount = BigNumber13(gasEstimated).multipliedBy(1.5);
|
|
3485
3548
|
const gasPayment = gasAmount.multipliedBy(gasPrice);
|
|
3486
3549
|
const nativeFee = {
|
|
3487
3550
|
amount: coins(gasPayment.toFixed(0).toString(), nativeDenom),
|
|
@@ -3498,16 +3561,16 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
3498
3561
|
if (!expectedAmount.isPositive()) {
|
|
3499
3562
|
return nativeFee;
|
|
3500
3563
|
}
|
|
3501
|
-
expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(
|
|
3564
|
+
expectedAmount = expectedAmount.multipliedBy(1.5).integerValue(BigNumber13.ROUND_FLOOR);
|
|
3502
3565
|
if (expectedAmount.multipliedBy(pool.fee).lt(1)) {
|
|
3503
|
-
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(
|
|
3566
|
+
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(BigNumber13.ROUND_CEIL);
|
|
3504
3567
|
}
|
|
3505
3568
|
return {
|
|
3506
3569
|
amount: coins(expectedAmount.toFixed(0).toString(), feeDenom),
|
|
3507
3570
|
gas: gasAmount.multipliedBy(1.5).toFixed(0)
|
|
3508
3571
|
};
|
|
3509
3572
|
}, [signingClient, address, feeDenom, getDenomsPool]);
|
|
3510
|
-
const getFee =
|
|
3573
|
+
const getFee = useCallback11(async (messages, options) => {
|
|
3511
3574
|
try {
|
|
3512
3575
|
if (options == null ? void 0 : options.fee) {
|
|
3513
3576
|
return options.fee;
|
|
@@ -3524,7 +3587,7 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
3524
3587
|
}
|
|
3525
3588
|
}
|
|
3526
3589
|
}, [simulateFee]);
|
|
3527
|
-
const tx =
|
|
3590
|
+
const tx = useCallback11(async (msgs, options) => {
|
|
3528
3591
|
var _a2;
|
|
3529
3592
|
if (!address) {
|
|
3530
3593
|
toast.error("Transaction Failed" /* Failed */, "Please connect the wallet");
|
|
@@ -3777,7 +3840,7 @@ import {
|
|
|
3777
3840
|
} from "@chakra-ui/react";
|
|
3778
3841
|
import { Select, Portal as Portal3 } from "@chakra-ui/react";
|
|
3779
3842
|
import { useTheme } from "next-themes";
|
|
3780
|
-
import { useState as useState6, useEffect as useEffect4, useMemo as useMemo13, useCallback as
|
|
3843
|
+
import { useState as useState6, useEffect as useEffect4, useMemo as useMemo13, useCallback as useCallback12 } from "react";
|
|
3781
3844
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
3782
3845
|
var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
3783
3846
|
const { setTheme, resolvedTheme } = useTheme();
|
|
@@ -3797,7 +3860,7 @@ var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
3797
3860
|
setPreferredFeeDenom(settings.preferredFeeDenom || getChainNativeAssetDenom());
|
|
3798
3861
|
}
|
|
3799
3862
|
}, [isLoaded, settings]);
|
|
3800
|
-
const handleValidateEndpoints =
|
|
3863
|
+
const handleValidateEndpoints = useCallback12(async (rest, rpc) => {
|
|
3801
3864
|
setIsValidating(true);
|
|
3802
3865
|
setValidationResults({});
|
|
3803
3866
|
try {
|
|
@@ -3817,7 +3880,7 @@ var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
3817
3880
|
setTimeout(() => setValidationResults({}), 1e4);
|
|
3818
3881
|
}
|
|
3819
3882
|
}, []);
|
|
3820
|
-
const handleSaveSettings =
|
|
3883
|
+
const handleSaveSettings = useCallback12(async (rest, rpc, feeDenom) => {
|
|
3821
3884
|
setValidationResults({});
|
|
3822
3885
|
const results = await validateEndpoints(rest, rpc);
|
|
3823
3886
|
if (!results.isValid) {
|
|
@@ -3837,7 +3900,7 @@ var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
3837
3900
|
toast.success("Success!", "Settings have been saved.");
|
|
3838
3901
|
}
|
|
3839
3902
|
}, []);
|
|
3840
|
-
const handleResetToDefaults =
|
|
3903
|
+
const handleResetToDefaults = useCallback12(() => {
|
|
3841
3904
|
setRestEndpoint(defaultSettings.endpoints.restEndpoint);
|
|
3842
3905
|
setRpcEndpoint(defaultSettings.endpoints.rpcEndpoint);
|
|
3843
3906
|
setPreferredFeeDenom(defaultSettings.preferredFeeDenom);
|
|
@@ -3870,7 +3933,7 @@ var SettingsSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
3870
3933
|
name: token.ticker || token.name
|
|
3871
3934
|
}))
|
|
3872
3935
|
}), [feeTokens]);
|
|
3873
|
-
const handleFeeTokenChange =
|
|
3936
|
+
const handleFeeTokenChange = useCallback12((denom) => {
|
|
3874
3937
|
setPreferredFeeDenom(denom || void 0);
|
|
3875
3938
|
}, []);
|
|
3876
3939
|
const hasUnsavedChanges = restEndpoint !== settings.endpoints.restEndpoint || rpcEndpoint !== settings.endpoints.rpcEndpoint || preferredFeeDenom !== settings.preferredFeeDenom;
|
|
@@ -4046,15 +4109,15 @@ import {
|
|
|
4046
4109
|
VStack as VStack2
|
|
4047
4110
|
} from "@chakra-ui/react";
|
|
4048
4111
|
import { LuCopy, LuExternalLink, LuX as LuX2 } from "react-icons/lu";
|
|
4049
|
-
import { useCallback as
|
|
4112
|
+
import { useCallback as useCallback13, useEffect as useEffect5, useMemo as useMemo14, useRef as useRef3, useState as useState7 } from "react";
|
|
4050
4113
|
import { WalletState } from "@interchain-kit/core";
|
|
4051
|
-
import
|
|
4114
|
+
import BigNumber14 from "bignumber.js";
|
|
4052
4115
|
import { cosmos } from "@bze/bzejs";
|
|
4053
4116
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4054
4117
|
var validateAmount = (amount, coin, onError) => {
|
|
4055
4118
|
if (!coin) return;
|
|
4056
4119
|
if (amount === "") return;
|
|
4057
|
-
const amountNumber =
|
|
4120
|
+
const amountNumber = BigNumber14(amount);
|
|
4058
4121
|
if (amountNumber.isNaN()) {
|
|
4059
4122
|
onError("Invalid amount");
|
|
4060
4123
|
return;
|
|
@@ -4148,13 +4211,13 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4148
4211
|
const isValidForm = useMemo14(() => {
|
|
4149
4212
|
return selectedCoin && memoError === "" && recipientError === "" && sendAmountError === "" && sendAmount !== "" && recipient !== "";
|
|
4150
4213
|
}, [selectedCoin, memoError, recipientError, sendAmountError, sendAmount, recipient]);
|
|
4151
|
-
const resetSendForm =
|
|
4214
|
+
const resetSendForm = useCallback13(() => {
|
|
4152
4215
|
setSelectedCoin(void 0);
|
|
4153
4216
|
setSendAmount("");
|
|
4154
4217
|
setRecipient("");
|
|
4155
4218
|
setMemo("");
|
|
4156
4219
|
}, []);
|
|
4157
|
-
const handleSend =
|
|
4220
|
+
const handleSend = useCallback13(async () => {
|
|
4158
4221
|
var _a2, _b2;
|
|
4159
4222
|
if (!isValidForm) {
|
|
4160
4223
|
toast.error("Can not send coins!", "Please check the input data.");
|
|
@@ -4179,11 +4242,11 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4179
4242
|
setIsLoading(false);
|
|
4180
4243
|
onClose();
|
|
4181
4244
|
}, [address, memo, onClose, recipient, selectedCoin, sendAmount, status]);
|
|
4182
|
-
const handleCancel =
|
|
4245
|
+
const handleCancel = useCallback13(() => {
|
|
4183
4246
|
resetSendForm();
|
|
4184
4247
|
onClose();
|
|
4185
4248
|
}, [onClose, resetSendForm]);
|
|
4186
|
-
const onRecipientChange =
|
|
4249
|
+
const onRecipientChange = useCallback13((recipient2) => {
|
|
4187
4250
|
setRecipient(recipient2);
|
|
4188
4251
|
if (recipient2.length === 0) {
|
|
4189
4252
|
setRecipientError("");
|
|
@@ -4196,11 +4259,11 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4196
4259
|
setRecipientError(validate.message);
|
|
4197
4260
|
}
|
|
4198
4261
|
}, []);
|
|
4199
|
-
const onAmountChange =
|
|
4262
|
+
const onAmountChange = useCallback13((amount) => {
|
|
4200
4263
|
setSendAmount(sanitizeNumberInput(amount));
|
|
4201
4264
|
setSendAmountError("");
|
|
4202
4265
|
}, []);
|
|
4203
|
-
const onCoinSelectChange =
|
|
4266
|
+
const onCoinSelectChange = useCallback13((ticker) => {
|
|
4204
4267
|
if (ticker === "") return;
|
|
4205
4268
|
const selectedCoin2 = balances.find((item) => item.ticker === ticker);
|
|
4206
4269
|
if (selectedCoin2) {
|
|
@@ -4208,13 +4271,13 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4208
4271
|
validateAmount(sendAmount, selectedCoin2, setSendAmountError);
|
|
4209
4272
|
}
|
|
4210
4273
|
}, [sendAmount, balances]);
|
|
4211
|
-
const setMaxAmount =
|
|
4274
|
+
const setMaxAmount = useCallback13(() => {
|
|
4212
4275
|
if (!selectedCoin) return;
|
|
4213
4276
|
const maxAmount = uAmountToBigNumberAmount(selectedCoin.amount, selectedCoin.decimals);
|
|
4214
4277
|
onAmountChange(maxAmount.toString());
|
|
4215
4278
|
validateAmount(maxAmount.toString(), selectedCoin, setSendAmountError);
|
|
4216
4279
|
}, [selectedCoin, onAmountChange]);
|
|
4217
|
-
const onMemoChange =
|
|
4280
|
+
const onMemoChange = useCallback13((memo2) => {
|
|
4218
4281
|
setMemo(memo2);
|
|
4219
4282
|
if (memo2.length > 256) {
|
|
4220
4283
|
setMemoError("Memo must be less than or equal to 256 characters");
|
|
@@ -4425,15 +4488,15 @@ var WalletSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
4425
4488
|
setShowCopiedTooltip(true);
|
|
4426
4489
|
setTimeout(() => setShowCopiedTooltip(false), 2e3);
|
|
4427
4490
|
};
|
|
4428
|
-
const handleCancel =
|
|
4491
|
+
const handleCancel = useCallback13(() => {
|
|
4429
4492
|
setViewState("balances");
|
|
4430
4493
|
setClickedBalance("");
|
|
4431
4494
|
}, []);
|
|
4432
|
-
const onBalanceClick =
|
|
4495
|
+
const onBalanceClick = useCallback13((ticker) => {
|
|
4433
4496
|
setClickedBalance(ticker);
|
|
4434
4497
|
setViewState("send");
|
|
4435
4498
|
}, []);
|
|
4436
|
-
const handleDisconnectAll =
|
|
4499
|
+
const handleDisconnectAll = useCallback13(async () => {
|
|
4437
4500
|
setIsDisconnecting(true);
|
|
4438
4501
|
try {
|
|
4439
4502
|
console.log("Disconnected from all chains");
|
|
@@ -4829,6 +4892,7 @@ export {
|
|
|
4829
4892
|
useBalances,
|
|
4830
4893
|
useConnectionType,
|
|
4831
4894
|
useEpochs,
|
|
4895
|
+
useEpochsManager,
|
|
4832
4896
|
useFeeTokens,
|
|
4833
4897
|
useIBCChains,
|
|
4834
4898
|
useIBCTx,
|