@bze/bze-ui-kit 1.0.12 → 1.0.14

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
@@ -3352,34 +3352,34 @@ var registerBzeEncoders = (client) => {
3352
3352
 
3353
3353
  // src/hooks/useSigningClient.ts
3354
3354
  var useSigningClient = ({ chainName }) => {
3355
- const { getSigningClient, signingClientError, wallet, chain } = useChain(chainName != null ? chainName : getChainName());
3355
+ const { getSigningClient, signingClientError, wallet, chain, address } = useChain(chainName != null ? chainName : getChainName());
3356
3356
  const [signingClient, setSigningClient] = useState(null);
3357
3357
  const [isSigningClientReady, setIsSigningClientReady] = useState(false);
3358
- const initializedForWallet = useRef(null);
3358
+ const initializedForAddress = useRef(null);
3359
3359
  const createSigningClient = useCallback2(async () => {
3360
3360
  return getSigningClient();
3361
3361
  }, [getSigningClient]);
3362
3362
  useEffect(() => {
3363
- if (!wallet || !chain) {
3364
- if (initializedForWallet.current !== null) {
3363
+ if (!wallet || !chain || !address) {
3364
+ if (initializedForAddress.current !== null) {
3365
3365
  setSigningClient(null);
3366
3366
  setIsSigningClientReady(false);
3367
- initializedForWallet.current = null;
3367
+ initializedForAddress.current = null;
3368
3368
  }
3369
3369
  return;
3370
3370
  }
3371
- if (initializedForWallet.current === wallet) return;
3371
+ if (initializedForAddress.current === address) return;
3372
3372
  const load = async () => {
3373
3373
  const client = await createSigningClient();
3374
3374
  if (client) {
3375
3375
  registerBzeEncoders(client);
3376
3376
  setSigningClient(client);
3377
3377
  setIsSigningClientReady(true);
3378
- initializedForWallet.current = wallet;
3378
+ initializedForAddress.current = address;
3379
3379
  }
3380
3380
  };
3381
3381
  load();
3382
- }, [wallet, chain, createSigningClient]);
3382
+ }, [wallet, chain, address, createSigningClient]);
3383
3383
  return {
3384
3384
  signingClientError,
3385
3385
  signingClient,
@@ -3391,12 +3391,41 @@ var useSigningClient = ({ chainName }) => {
3391
3391
  import { useEffect as useEffect2 } 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, getSigningClient, disconnect, address } = useChain2(chainName != null ? chainName : getChainName());
3397
3425
  useEffect2(() => {
3398
3426
  if (status !== WalletState.Connected) return;
3399
3427
  const validate = async () => {
3428
+ var _a2;
3400
3429
  try {
3401
3430
  const client = await Promise.race([
3402
3431
  getSigningClient(),
@@ -3405,9 +3434,40 @@ var useWalletHealthCheck = (chainName) => {
3405
3434
  )
3406
3435
  ]);
3407
3436
  if (!client) {
3437
+ const msg = "[useWalletHealthCheck] Signing client unavailable or timed out \u2014 wallet may be locked. Disconnecting.";
3438
+ console.error(msg);
3439
+ toaster.create({
3440
+ title: "Wallet disconnected",
3441
+ description: "Could not reach your wallet extension. Please reconnect.",
3442
+ type: "error",
3443
+ duration: 8e3,
3444
+ closable: true
3445
+ });
3408
3446
  disconnect();
3447
+ return;
3409
3448
  }
3410
- } catch (e) {
3449
+ const accounts = await ((_a2 = client.getAccounts) == null ? void 0 : _a2.call(client));
3450
+ if ((accounts == null ? void 0 : accounts.length) > 0 && accounts[0].address !== address) {
3451
+ const msg = `[useWalletHealthCheck] Address mismatch \u2014 interchain-kit cached "${address}" but signing client reports "${accounts[0].address}". Wallet was likely switched outside the UI. Disconnecting.`;
3452
+ console.error(msg);
3453
+ toaster.create({
3454
+ title: "Wallet account changed",
3455
+ description: "Your wallet account changed since your last visit. Please reconnect.",
3456
+ type: "warning",
3457
+ duration: 8e3,
3458
+ closable: true
3459
+ });
3460
+ disconnect();
3461
+ }
3462
+ } catch (err) {
3463
+ console.error("[useWalletHealthCheck] Error validating wallet connection:", err);
3464
+ toaster.create({
3465
+ title: "Wallet connection error",
3466
+ description: "Could not verify your wallet connection. Please reconnect.",
3467
+ type: "error",
3468
+ duration: 8e3,
3469
+ closable: true
3470
+ });
3411
3471
  disconnect();
3412
3472
  }
3413
3473
  };
@@ -3997,34 +4057,6 @@ function useMarketsManager() {
3997
4057
 
3998
4058
  // src/hooks/useToast.tsx
3999
4059
  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
4060
  var useToast = () => {
4029
4061
  const clickableSuccess = useCallback10((title, actionFn, actionLabel, description, duration = 5e3) => {
4030
4062
  toaster.create({