@bze/bze-ui-kit 1.0.14 → 1.0.16
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 +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +31 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3388,7 +3388,7 @@ var useSigningClient = ({ chainName }) => {
|
|
|
3388
3388
|
};
|
|
3389
3389
|
|
|
3390
3390
|
// src/hooks/useWalletHealthCheck.ts
|
|
3391
|
-
import { useEffect as useEffect2 } from "react";
|
|
3391
|
+
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
3392
3392
|
import { useChain as useChain2 } from "@interchain-kit/react";
|
|
3393
3393
|
import { WalletState } from "@interchain-kit/core";
|
|
3394
3394
|
|
|
@@ -3421,21 +3421,23 @@ var Toaster = () => {
|
|
|
3421
3421
|
// src/hooks/useWalletHealthCheck.ts
|
|
3422
3422
|
var SIGNING_CLIENT_TIMEOUT_MS = 5e3;
|
|
3423
3423
|
var useWalletHealthCheck = (chainName) => {
|
|
3424
|
-
const { status,
|
|
3424
|
+
const { status, disconnect, address, wallet } = useChain2(chainName != null ? chainName : getChainName());
|
|
3425
|
+
const hasValidated = useRef2(false);
|
|
3425
3426
|
useEffect2(() => {
|
|
3426
3427
|
if (status !== WalletState.Connected) return;
|
|
3428
|
+
if (hasValidated.current) return;
|
|
3429
|
+
hasValidated.current = true;
|
|
3427
3430
|
const validate = async () => {
|
|
3428
|
-
var _a2;
|
|
3431
|
+
var _a2, _b2;
|
|
3429
3432
|
try {
|
|
3430
|
-
const
|
|
3431
|
-
|
|
3433
|
+
const refreshed = await Promise.race([
|
|
3434
|
+
(_a2 = wallet == null ? void 0 : wallet.refreshAccount) == null ? void 0 : _a2.call(wallet).then(() => true),
|
|
3432
3435
|
new Promise(
|
|
3433
|
-
(resolve) => setTimeout(() => resolve(
|
|
3436
|
+
(resolve) => setTimeout(() => resolve(false), SIGNING_CLIENT_TIMEOUT_MS)
|
|
3434
3437
|
)
|
|
3435
3438
|
]);
|
|
3436
|
-
if (!
|
|
3437
|
-
|
|
3438
|
-
console.error(msg);
|
|
3439
|
+
if (!refreshed) {
|
|
3440
|
+
console.error("[useWalletHealthCheck] refreshAccount timed out \u2014 wallet may be locked. Disconnecting.");
|
|
3439
3441
|
toaster.create({
|
|
3440
3442
|
title: "Wallet disconnected",
|
|
3441
3443
|
description: "Could not reach your wallet extension. Please reconnect.",
|
|
@@ -3446,10 +3448,10 @@ var useWalletHealthCheck = (chainName) => {
|
|
|
3446
3448
|
disconnect();
|
|
3447
3449
|
return;
|
|
3448
3450
|
}
|
|
3449
|
-
const
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
console.error(
|
|
3451
|
+
const freshAccount = await ((_b2 = wallet == null ? void 0 : wallet.getAccount) == null ? void 0 : _b2.call(wallet));
|
|
3452
|
+
const freshAddress = freshAccount == null ? void 0 : freshAccount.address;
|
|
3453
|
+
if (freshAddress && freshAddress !== address) {
|
|
3454
|
+
console.error(`[useWalletHealthCheck] Address mismatch \u2014 interchain-kit cached "${address}" but extension reports "${freshAddress}". Wallet was switched outside the UI. Disconnecting.`);
|
|
3453
3455
|
toaster.create({
|
|
3454
3456
|
title: "Wallet account changed",
|
|
3455
3457
|
description: "Your wallet account changed since your last visit. Please reconnect.",
|
|
@@ -3472,7 +3474,7 @@ var useWalletHealthCheck = (chainName) => {
|
|
|
3472
3474
|
}
|
|
3473
3475
|
};
|
|
3474
3476
|
validate();
|
|
3475
|
-
}, []);
|
|
3477
|
+
}, [status]);
|
|
3476
3478
|
};
|
|
3477
3479
|
|
|
3478
3480
|
// src/hooks/usePrices.ts
|
|
@@ -4240,18 +4242,19 @@ var useTx = (chainName) => {
|
|
|
4240
4242
|
}
|
|
4241
4243
|
}, [simulateFee]);
|
|
4242
4244
|
const tx = useCallback11(async (msgs, options) => {
|
|
4243
|
-
var _a2;
|
|
4245
|
+
var _a2, _b2;
|
|
4244
4246
|
if (!address) {
|
|
4245
4247
|
toast.error("Transaction Failed" /* Failed */, "Please connect the wallet");
|
|
4246
|
-
return;
|
|
4248
|
+
return false;
|
|
4247
4249
|
}
|
|
4248
4250
|
if (!await canUseClient()) {
|
|
4249
4251
|
toast.error("Transaction Failed" /* Failed */, "Can not find suitable signing client. Make sure your wallet is installed, connected and unlocked.");
|
|
4250
4252
|
disconnect();
|
|
4251
|
-
return;
|
|
4253
|
+
return false;
|
|
4252
4254
|
}
|
|
4253
4255
|
setProgressTrack("Getting fee");
|
|
4254
4256
|
const broadcastToastId = toast.loading("Transaction Pending" /* Broadcasting */, "Waiting for transaction to be signed and included in block");
|
|
4257
|
+
let success = false;
|
|
4255
4258
|
if (signingClient) {
|
|
4256
4259
|
try {
|
|
4257
4260
|
const fee = await getFee(msgs, options);
|
|
@@ -4261,6 +4264,7 @@ var useTx = (chainName) => {
|
|
|
4261
4264
|
const resp = await broadcastResult.wait();
|
|
4262
4265
|
const txHash = (resp == null ? void 0 : resp.txhash) || broadcastResult.transactionHash;
|
|
4263
4266
|
if ((resp == null ? void 0 : resp.code) === 0) {
|
|
4267
|
+
success = true;
|
|
4264
4268
|
setProgressTrack("Transaction sent");
|
|
4265
4269
|
toast.clickableSuccess("Transaction Successful" /* Successful */, () => {
|
|
4266
4270
|
openExternalLink(`${getChainExplorerURL(chainName != null ? chainName : defaultChainName)}/tx/${txHash}`);
|
|
@@ -4277,12 +4281,19 @@ var useTx = (chainName) => {
|
|
|
4277
4281
|
}
|
|
4278
4282
|
} catch (e) {
|
|
4279
4283
|
console.error(e);
|
|
4280
|
-
|
|
4284
|
+
const errMsg = (_b2 = e == null ? void 0 : e.message) != null ? _b2 : "";
|
|
4285
|
+
const isSignerError = [
|
|
4286
|
+
"Failed to retrieve account from signer",
|
|
4287
|
+
"Signer address does not match",
|
|
4288
|
+
"signers mismatch",
|
|
4289
|
+
"Signer mismatched"
|
|
4290
|
+
].some((pattern) => errMsg.includes(pattern));
|
|
4291
|
+
if (isSignerError) {
|
|
4281
4292
|
disconnect();
|
|
4282
4293
|
}
|
|
4283
|
-
toast.error("Transaction Failed" /* Failed */, prettyError(
|
|
4294
|
+
toast.error("Transaction Failed" /* Failed */, prettyError(errMsg));
|
|
4284
4295
|
if (options == null ? void 0 : options.onFailure) {
|
|
4285
|
-
options.onFailure(prettyError(
|
|
4296
|
+
options.onFailure(prettyError(errMsg) || "Unknown error");
|
|
4286
4297
|
}
|
|
4287
4298
|
}
|
|
4288
4299
|
}
|
|
@@ -4290,6 +4301,7 @@ var useTx = (chainName) => {
|
|
|
4290
4301
|
setTimeout(() => {
|
|
4291
4302
|
setProgressTrack("");
|
|
4292
4303
|
}, (options == null ? void 0 : options.progressTrackerTimeout) || 5e3);
|
|
4304
|
+
return success;
|
|
4293
4305
|
}, [address, canUseClient, toast, signingClient, disconnect, getFee, chainName, defaultChainName]);
|
|
4294
4306
|
return {
|
|
4295
4307
|
tx,
|
|
@@ -4298,15 +4310,15 @@ var useTx = (chainName) => {
|
|
|
4298
4310
|
};
|
|
4299
4311
|
|
|
4300
4312
|
// src/hooks/useValidatorLogos.ts
|
|
4301
|
-
import { useCallback as useCallback12, useEffect as useEffect4, useRef as
|
|
4313
|
+
import { useCallback as useCallback12, useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
|
|
4302
4314
|
var KEYBASE_API_URL = "https://keybase.io/_/api/1.0/user/lookup.json";
|
|
4303
4315
|
var LOGOS_STORAGE_KEY = "validator_logos";
|
|
4304
4316
|
var LOGOS_TTL = 24 * 60 * 60 * 1e3;
|
|
4305
4317
|
var useValidatorLogos = (validators) => {
|
|
4306
4318
|
const [logos, setLogos] = useState4({});
|
|
4307
4319
|
const [isLoading, setIsLoading] = useState4(false);
|
|
4308
|
-
const fetchedRef =
|
|
4309
|
-
const validatorCountRef =
|
|
4320
|
+
const fetchedRef = useRef3(false);
|
|
4321
|
+
const validatorCountRef = useRef3(0);
|
|
4310
4322
|
const fetchLogos = useCallback12(async (identities) => {
|
|
4311
4323
|
if (identities.length === 0) return {};
|
|
4312
4324
|
let cached = null;
|
|
@@ -4394,7 +4406,7 @@ var useValidatorLogos = (validators) => {
|
|
|
4394
4406
|
|
|
4395
4407
|
// src/components/highlight.tsx
|
|
4396
4408
|
import { Text } from "@chakra-ui/react";
|
|
4397
|
-
import { useEffect as useEffect5, useRef as
|
|
4409
|
+
import { useEffect as useEffect5, useRef as useRef4, useState as useState5 } from "react";
|
|
4398
4410
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
4399
4411
|
var HighlightText = (_a2) => {
|
|
4400
4412
|
var _b2 = _a2, {
|
|
@@ -4411,10 +4423,10 @@ var HighlightText = (_a2) => {
|
|
|
4411
4423
|
"children"
|
|
4412
4424
|
]);
|
|
4413
4425
|
const [isHighlighted, setIsHighlighted] = useState5(false);
|
|
4414
|
-
const isMountedRef =
|
|
4415
|
-
const timeoutRef =
|
|
4426
|
+
const isMountedRef = useRef4(false);
|
|
4427
|
+
const timeoutRef = useRef4(void 0);
|
|
4416
4428
|
const childrenString = String(children);
|
|
4417
|
-
const previousValueRef =
|
|
4429
|
+
const previousValueRef = useRef4(childrenString);
|
|
4418
4430
|
const highlightOpacity = highlightIntensity === "subtle" ? "15" : "50";
|
|
4419
4431
|
const boxShadowStrength = highlightIntensity === "subtle" ? "10" : "25";
|
|
4420
4432
|
useEffect5(() => {
|
|
@@ -4859,7 +4871,7 @@ import {
|
|
|
4859
4871
|
VStack as VStack2
|
|
4860
4872
|
} from "@chakra-ui/react";
|
|
4861
4873
|
import { LuCopy, LuExternalLink, LuX as LuX2 } from "react-icons/lu";
|
|
4862
|
-
import { useCallback as useCallback14, useEffect as useEffect7, useMemo as useMemo13, useRef as
|
|
4874
|
+
import { useCallback as useCallback14, useEffect as useEffect7, useMemo as useMemo13, useRef as useRef5, useState as useState8 } from "react";
|
|
4863
4875
|
import { WalletState as WalletState2 } from "@interchain-kit/core";
|
|
4864
4876
|
import BigNumber14 from "bignumber.js";
|
|
4865
4877
|
import { cosmos } from "@bze/bzejs";
|
|
@@ -5202,7 +5214,7 @@ var WalletSidebarContent = ({ accentColor = "blue" }) => {
|
|
|
5202
5214
|
const [isDisconnecting, setIsDisconnecting] = useState8(false);
|
|
5203
5215
|
const [showCopiedTooltip, setShowCopiedTooltip] = useState8(false);
|
|
5204
5216
|
const [clickedBalance, setClickedBalance] = useState8("");
|
|
5205
|
-
const copyButtonRef =
|
|
5217
|
+
const copyButtonRef = useRef5(null);
|
|
5206
5218
|
const {
|
|
5207
5219
|
status,
|
|
5208
5220
|
username,
|