@bze/bze-ui-kit 1.0.13 → 1.0.15

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.mjs CHANGED
@@ -3388,31 +3388,93 @@ 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
+
3395
+ // src/components/toaster.tsx
3396
+ import {
3397
+ Toaster as ChakraToaster,
3398
+ Portal,
3399
+ Spinner,
3400
+ Stack,
3401
+ Toast,
3402
+ createToaster
3403
+ } from "@chakra-ui/react";
3404
+ import { jsx, jsxs } from "react/jsx-runtime";
3405
+ var toaster = createToaster({
3406
+ placement: "top-end",
3407
+ pauseOnPageIdle: true
3408
+ });
3409
+ var Toaster = () => {
3410
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(ChakraToaster, { toaster, insetInline: { mdDown: "4" }, children: (toast) => /* @__PURE__ */ jsxs(Toast.Root, { width: { md: "sm" }, children: [
3411
+ toast.type === "loading" ? /* @__PURE__ */ jsx(Spinner, { size: "sm", color: "blue.solid" }) : /* @__PURE__ */ jsx(Toast.Indicator, {}),
3412
+ /* @__PURE__ */ jsxs(Stack, { gap: "1", flex: "1", maxWidth: "100%", children: [
3413
+ toast.title && /* @__PURE__ */ jsx(Toast.Title, { children: toast.title }),
3414
+ toast.description && /* @__PURE__ */ jsx(Toast.Description, { children: toast.description })
3415
+ ] }),
3416
+ toast.action && /* @__PURE__ */ jsx(Toast.ActionTrigger, { children: toast.action.label }),
3417
+ toast.closable && /* @__PURE__ */ jsx(Toast.CloseTrigger, {})
3418
+ ] }) }) });
3419
+ };
3420
+
3421
+ // src/hooks/useWalletHealthCheck.ts
3394
3422
  var SIGNING_CLIENT_TIMEOUT_MS = 5e3;
3395
3423
  var useWalletHealthCheck = (chainName) => {
3396
- const { status, getSigningClient, disconnect } = useChain2(chainName != null ? chainName : getChainName());
3424
+ const { status, disconnect, address, wallet } = useChain2(chainName != null ? chainName : getChainName());
3425
+ const hasValidated = useRef2(false);
3397
3426
  useEffect2(() => {
3398
3427
  if (status !== WalletState.Connected) return;
3428
+ if (hasValidated.current) return;
3429
+ hasValidated.current = true;
3399
3430
  const validate = async () => {
3431
+ var _a2, _b2;
3400
3432
  try {
3401
- const client = await Promise.race([
3402
- getSigningClient(),
3433
+ const refreshed = await Promise.race([
3434
+ (_a2 = wallet == null ? void 0 : wallet.refreshAccount) == null ? void 0 : _a2.call(wallet).then(() => true),
3403
3435
  new Promise(
3404
- (resolve) => setTimeout(() => resolve(null), SIGNING_CLIENT_TIMEOUT_MS)
3436
+ (resolve) => setTimeout(() => resolve(false), SIGNING_CLIENT_TIMEOUT_MS)
3405
3437
  )
3406
3438
  ]);
3407
- if (!client) {
3439
+ if (!refreshed) {
3440
+ console.error("[useWalletHealthCheck] refreshAccount timed out \u2014 wallet may be locked. Disconnecting.");
3441
+ toaster.create({
3442
+ title: "Wallet disconnected",
3443
+ description: "Could not reach your wallet extension. Please reconnect.",
3444
+ type: "error",
3445
+ duration: 8e3,
3446
+ closable: true
3447
+ });
3408
3448
  disconnect();
3449
+ return;
3409
3450
  }
3410
- } catch (e) {
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.`);
3455
+ toaster.create({
3456
+ title: "Wallet account changed",
3457
+ description: "Your wallet account changed since your last visit. Please reconnect.",
3458
+ type: "warning",
3459
+ duration: 8e3,
3460
+ closable: true
3461
+ });
3462
+ disconnect();
3463
+ }
3464
+ } catch (err) {
3465
+ console.error("[useWalletHealthCheck] Error validating wallet connection:", err);
3466
+ toaster.create({
3467
+ title: "Wallet connection error",
3468
+ description: "Could not verify your wallet connection. Please reconnect.",
3469
+ type: "error",
3470
+ duration: 8e3,
3471
+ closable: true
3472
+ });
3411
3473
  disconnect();
3412
3474
  }
3413
3475
  };
3414
3476
  validate();
3415
- }, []);
3477
+ }, [status]);
3416
3478
  };
3417
3479
 
3418
3480
  // src/hooks/usePrices.ts
@@ -3997,34 +4059,6 @@ function useMarketsManager() {
3997
4059
 
3998
4060
  // src/hooks/useToast.tsx
3999
4061
  import { useCallback as useCallback10, useMemo as useMemo10 } from "react";
4000
-
4001
- // src/components/toaster.tsx
4002
- import {
4003
- Toaster as ChakraToaster,
4004
- Portal,
4005
- Spinner,
4006
- Stack,
4007
- Toast,
4008
- createToaster
4009
- } from "@chakra-ui/react";
4010
- import { jsx, jsxs } from "react/jsx-runtime";
4011
- var toaster = createToaster({
4012
- placement: "top-end",
4013
- pauseOnPageIdle: true
4014
- });
4015
- var Toaster = () => {
4016
- return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(ChakraToaster, { toaster, insetInline: { mdDown: "4" }, children: (toast) => /* @__PURE__ */ jsxs(Toast.Root, { width: { md: "sm" }, children: [
4017
- toast.type === "loading" ? /* @__PURE__ */ jsx(Spinner, { size: "sm", color: "blue.solid" }) : /* @__PURE__ */ jsx(Toast.Indicator, {}),
4018
- /* @__PURE__ */ jsxs(Stack, { gap: "1", flex: "1", maxWidth: "100%", children: [
4019
- toast.title && /* @__PURE__ */ jsx(Toast.Title, { children: toast.title }),
4020
- toast.description && /* @__PURE__ */ jsx(Toast.Description, { children: toast.description })
4021
- ] }),
4022
- toast.action && /* @__PURE__ */ jsx(Toast.ActionTrigger, { children: toast.action.label }),
4023
- toast.closable && /* @__PURE__ */ jsx(Toast.CloseTrigger, {})
4024
- ] }) }) });
4025
- };
4026
-
4027
- // src/hooks/useToast.tsx
4028
4062
  var useToast = () => {
4029
4063
  const clickableSuccess = useCallback10((title, actionFn, actionLabel, description, duration = 5e3) => {
4030
4064
  toaster.create({
@@ -4266,15 +4300,15 @@ var useTx = (chainName) => {
4266
4300
  };
4267
4301
 
4268
4302
  // src/hooks/useValidatorLogos.ts
4269
- import { useCallback as useCallback12, useEffect as useEffect4, useRef as useRef2, useState as useState4 } from "react";
4303
+ import { useCallback as useCallback12, useEffect as useEffect4, useRef as useRef3, useState as useState4 } from "react";
4270
4304
  var KEYBASE_API_URL = "https://keybase.io/_/api/1.0/user/lookup.json";
4271
4305
  var LOGOS_STORAGE_KEY = "validator_logos";
4272
4306
  var LOGOS_TTL = 24 * 60 * 60 * 1e3;
4273
4307
  var useValidatorLogos = (validators) => {
4274
4308
  const [logos, setLogos] = useState4({});
4275
4309
  const [isLoading, setIsLoading] = useState4(false);
4276
- const fetchedRef = useRef2(false);
4277
- const validatorCountRef = useRef2(0);
4310
+ const fetchedRef = useRef3(false);
4311
+ const validatorCountRef = useRef3(0);
4278
4312
  const fetchLogos = useCallback12(async (identities) => {
4279
4313
  if (identities.length === 0) return {};
4280
4314
  let cached = null;
@@ -4362,7 +4396,7 @@ var useValidatorLogos = (validators) => {
4362
4396
 
4363
4397
  // src/components/highlight.tsx
4364
4398
  import { Text } from "@chakra-ui/react";
4365
- import { useEffect as useEffect5, useRef as useRef3, useState as useState5 } from "react";
4399
+ import { useEffect as useEffect5, useRef as useRef4, useState as useState5 } from "react";
4366
4400
  import { jsx as jsx2 } from "react/jsx-runtime";
4367
4401
  var HighlightText = (_a2) => {
4368
4402
  var _b2 = _a2, {
@@ -4379,10 +4413,10 @@ var HighlightText = (_a2) => {
4379
4413
  "children"
4380
4414
  ]);
4381
4415
  const [isHighlighted, setIsHighlighted] = useState5(false);
4382
- const isMountedRef = useRef3(false);
4383
- const timeoutRef = useRef3(void 0);
4416
+ const isMountedRef = useRef4(false);
4417
+ const timeoutRef = useRef4(void 0);
4384
4418
  const childrenString = String(children);
4385
- const previousValueRef = useRef3(childrenString);
4419
+ const previousValueRef = useRef4(childrenString);
4386
4420
  const highlightOpacity = highlightIntensity === "subtle" ? "15" : "50";
4387
4421
  const boxShadowStrength = highlightIntensity === "subtle" ? "10" : "25";
4388
4422
  useEffect5(() => {
@@ -4827,7 +4861,7 @@ import {
4827
4861
  VStack as VStack2
4828
4862
  } from "@chakra-ui/react";
4829
4863
  import { LuCopy, LuExternalLink, LuX as LuX2 } from "react-icons/lu";
4830
- import { useCallback as useCallback14, useEffect as useEffect7, useMemo as useMemo13, useRef as useRef4, useState as useState8 } from "react";
4864
+ import { useCallback as useCallback14, useEffect as useEffect7, useMemo as useMemo13, useRef as useRef5, useState as useState8 } from "react";
4831
4865
  import { WalletState as WalletState2 } from "@interchain-kit/core";
4832
4866
  import BigNumber14 from "bignumber.js";
4833
4867
  import { cosmos } from "@bze/bzejs";
@@ -5170,7 +5204,7 @@ var WalletSidebarContent = ({ accentColor = "blue" }) => {
5170
5204
  const [isDisconnecting, setIsDisconnecting] = useState8(false);
5171
5205
  const [showCopiedTooltip, setShowCopiedTooltip] = useState8(false);
5172
5206
  const [clickedBalance, setClickedBalance] = useState8("");
5173
- const copyButtonRef = useRef4(null);
5207
+ const copyButtonRef = useRef5(null);
5174
5208
  const {
5175
5209
  status,
5176
5210
  username,