@bze/bze-ui-kit 1.0.14 → 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.d.mts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1081,18 +1081,19 @@ declare const useSigningClient: ({ chainName }: UseSigningClientProps) => {
|
|
|
1081
1081
|
|
|
1082
1082
|
/**
|
|
1083
1083
|
* Validates the wallet connection on mount and proactively disconnects if the
|
|
1084
|
-
* wallet state restored from localStorage is stale (
|
|
1085
|
-
*
|
|
1084
|
+
* wallet state restored from localStorage is stale (extension locked, or account
|
|
1085
|
+
* switched outside the UI between sessions).
|
|
1086
1086
|
*
|
|
1087
1087
|
* interchain-kit persists WalletState.Connected + the account address in
|
|
1088
|
-
* localStorage and restores it on every page load without verifying the
|
|
1089
|
-
* extension
|
|
1090
|
-
*
|
|
1091
|
-
* the
|
|
1092
|
-
* before the user tries a transaction.
|
|
1088
|
+
* localStorage and restores it on every page load without re-verifying the
|
|
1089
|
+
* extension. This hook catches that by calling refreshAccount() — interchain-kit's
|
|
1090
|
+
* own method for forcing a live fetch from the extension — and comparing the result
|
|
1091
|
+
* against the cached address. On mismatch or failure, shows a toast and disconnects.
|
|
1093
1092
|
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1093
|
+
* Runs on every status change (not just mount) because interchain-kit restores state
|
|
1094
|
+
* asynchronously, so status is Disconnected on the first render and only becomes
|
|
1095
|
+
* Connected after its own useEffect/init() completes. The hasValidated ref ensures
|
|
1096
|
+
* we only run the check once per page load.
|
|
1096
1097
|
*/
|
|
1097
1098
|
declare const useWalletHealthCheck: (chainName?: string) => void;
|
|
1098
1099
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1081,18 +1081,19 @@ declare const useSigningClient: ({ chainName }: UseSigningClientProps) => {
|
|
|
1081
1081
|
|
|
1082
1082
|
/**
|
|
1083
1083
|
* Validates the wallet connection on mount and proactively disconnects if the
|
|
1084
|
-
* wallet state restored from localStorage is stale (
|
|
1085
|
-
*
|
|
1084
|
+
* wallet state restored from localStorage is stale (extension locked, or account
|
|
1085
|
+
* switched outside the UI between sessions).
|
|
1086
1086
|
*
|
|
1087
1087
|
* interchain-kit persists WalletState.Connected + the account address in
|
|
1088
|
-
* localStorage and restores it on every page load without verifying the
|
|
1089
|
-
* extension
|
|
1090
|
-
*
|
|
1091
|
-
* the
|
|
1092
|
-
* before the user tries a transaction.
|
|
1088
|
+
* localStorage and restores it on every page load without re-verifying the
|
|
1089
|
+
* extension. This hook catches that by calling refreshAccount() — interchain-kit's
|
|
1090
|
+
* own method for forcing a live fetch from the extension — and comparing the result
|
|
1091
|
+
* against the cached address. On mismatch or failure, shows a toast and disconnects.
|
|
1093
1092
|
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1093
|
+
* Runs on every status change (not just mount) because interchain-kit restores state
|
|
1094
|
+
* asynchronously, so status is Disconnected on the first render and only becomes
|
|
1095
|
+
* Connected after its own useEffect/init() completes. The hasValidated ref ensures
|
|
1096
|
+
* we only run the check once per page load.
|
|
1096
1097
|
*/
|
|
1097
1098
|
declare const useWalletHealthCheck: (chainName?: string) => void;
|
|
1098
1099
|
|
package/dist/index.js
CHANGED
|
@@ -3678,21 +3678,23 @@ var Toaster = () => {
|
|
|
3678
3678
|
// src/hooks/useWalletHealthCheck.ts
|
|
3679
3679
|
var SIGNING_CLIENT_TIMEOUT_MS = 5e3;
|
|
3680
3680
|
var useWalletHealthCheck = (chainName) => {
|
|
3681
|
-
const { status,
|
|
3681
|
+
const { status, disconnect, address, wallet } = (0, import_react7.useChain)(chainName != null ? chainName : getChainName());
|
|
3682
|
+
const hasValidated = (0, import_react6.useRef)(false);
|
|
3682
3683
|
(0, import_react6.useEffect)(() => {
|
|
3683
3684
|
if (status !== import_core.WalletState.Connected) return;
|
|
3685
|
+
if (hasValidated.current) return;
|
|
3686
|
+
hasValidated.current = true;
|
|
3684
3687
|
const validate = async () => {
|
|
3685
|
-
var _a2;
|
|
3688
|
+
var _a2, _b2;
|
|
3686
3689
|
try {
|
|
3687
|
-
const
|
|
3688
|
-
|
|
3690
|
+
const refreshed = await Promise.race([
|
|
3691
|
+
(_a2 = wallet == null ? void 0 : wallet.refreshAccount) == null ? void 0 : _a2.call(wallet).then(() => true),
|
|
3689
3692
|
new Promise(
|
|
3690
|
-
(resolve) => setTimeout(() => resolve(
|
|
3693
|
+
(resolve) => setTimeout(() => resolve(false), SIGNING_CLIENT_TIMEOUT_MS)
|
|
3691
3694
|
)
|
|
3692
3695
|
]);
|
|
3693
|
-
if (!
|
|
3694
|
-
|
|
3695
|
-
console.error(msg);
|
|
3696
|
+
if (!refreshed) {
|
|
3697
|
+
console.error("[useWalletHealthCheck] refreshAccount timed out \u2014 wallet may be locked. Disconnecting.");
|
|
3696
3698
|
toaster.create({
|
|
3697
3699
|
title: "Wallet disconnected",
|
|
3698
3700
|
description: "Could not reach your wallet extension. Please reconnect.",
|
|
@@ -3703,10 +3705,10 @@ var useWalletHealthCheck = (chainName) => {
|
|
|
3703
3705
|
disconnect();
|
|
3704
3706
|
return;
|
|
3705
3707
|
}
|
|
3706
|
-
const
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
console.error(
|
|
3708
|
+
const freshAccount = await ((_b2 = wallet == null ? void 0 : wallet.getAccount) == null ? void 0 : _b2.call(wallet));
|
|
3709
|
+
const freshAddress = freshAccount == null ? void 0 : freshAccount.address;
|
|
3710
|
+
if (freshAddress && freshAddress !== address) {
|
|
3711
|
+
console.error(`[useWalletHealthCheck] Address mismatch \u2014 interchain-kit cached "${address}" but extension reports "${freshAddress}". Wallet was switched outside the UI. Disconnecting.`);
|
|
3710
3712
|
toaster.create({
|
|
3711
3713
|
title: "Wallet account changed",
|
|
3712
3714
|
description: "Your wallet account changed since your last visit. Please reconnect.",
|
|
@@ -3729,7 +3731,7 @@ var useWalletHealthCheck = (chainName) => {
|
|
|
3729
3731
|
}
|
|
3730
3732
|
};
|
|
3731
3733
|
validate();
|
|
3732
|
-
}, []);
|
|
3734
|
+
}, [status]);
|
|
3733
3735
|
};
|
|
3734
3736
|
|
|
3735
3737
|
// src/hooks/usePrices.ts
|