@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.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
|
|
|
@@ -1266,15 +1267,15 @@ declare enum TxStatus {
|
|
|
1266
1267
|
Broadcasting = "Transaction Pending"
|
|
1267
1268
|
}
|
|
1268
1269
|
declare const useSDKTx: (chainName?: string) => {
|
|
1269
|
-
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<
|
|
1270
|
+
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<boolean>;
|
|
1270
1271
|
progressTrack: string;
|
|
1271
1272
|
};
|
|
1272
1273
|
declare const useBZETx: () => {
|
|
1273
|
-
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<
|
|
1274
|
+
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<boolean>;
|
|
1274
1275
|
progressTrack: string;
|
|
1275
1276
|
};
|
|
1276
1277
|
declare const useIBCTx: (chainName?: string) => {
|
|
1277
|
-
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<
|
|
1278
|
+
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<boolean>;
|
|
1278
1279
|
progressTrack: string;
|
|
1279
1280
|
};
|
|
1280
1281
|
|
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
|
|
|
@@ -1266,15 +1267,15 @@ declare enum TxStatus {
|
|
|
1266
1267
|
Broadcasting = "Transaction Pending"
|
|
1267
1268
|
}
|
|
1268
1269
|
declare const useSDKTx: (chainName?: string) => {
|
|
1269
|
-
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<
|
|
1270
|
+
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<boolean>;
|
|
1270
1271
|
progressTrack: string;
|
|
1271
1272
|
};
|
|
1272
1273
|
declare const useBZETx: () => {
|
|
1273
|
-
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<
|
|
1274
|
+
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<boolean>;
|
|
1274
1275
|
progressTrack: string;
|
|
1275
1276
|
};
|
|
1276
1277
|
declare const useIBCTx: (chainName?: string) => {
|
|
1277
|
-
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<
|
|
1278
|
+
tx: (msgs: EncodeObject[], options?: TxOptions | undefined) => Promise<boolean>;
|
|
1278
1279
|
progressTrack: string;
|
|
1279
1280
|
};
|
|
1280
1281
|
|
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
|
|
@@ -4497,18 +4499,19 @@ var useTx = (chainName) => {
|
|
|
4497
4499
|
}
|
|
4498
4500
|
}, [simulateFee]);
|
|
4499
4501
|
const tx = (0, import_react18.useCallback)(async (msgs, options) => {
|
|
4500
|
-
var _a2;
|
|
4502
|
+
var _a2, _b2;
|
|
4501
4503
|
if (!address) {
|
|
4502
4504
|
toast.error("Transaction Failed" /* Failed */, "Please connect the wallet");
|
|
4503
|
-
return;
|
|
4505
|
+
return false;
|
|
4504
4506
|
}
|
|
4505
4507
|
if (!await canUseClient()) {
|
|
4506
4508
|
toast.error("Transaction Failed" /* Failed */, "Can not find suitable signing client. Make sure your wallet is installed, connected and unlocked.");
|
|
4507
4509
|
disconnect();
|
|
4508
|
-
return;
|
|
4510
|
+
return false;
|
|
4509
4511
|
}
|
|
4510
4512
|
setProgressTrack("Getting fee");
|
|
4511
4513
|
const broadcastToastId = toast.loading("Transaction Pending" /* Broadcasting */, "Waiting for transaction to be signed and included in block");
|
|
4514
|
+
let success = false;
|
|
4512
4515
|
if (signingClient) {
|
|
4513
4516
|
try {
|
|
4514
4517
|
const fee = await getFee(msgs, options);
|
|
@@ -4518,6 +4521,7 @@ var useTx = (chainName) => {
|
|
|
4518
4521
|
const resp = await broadcastResult.wait();
|
|
4519
4522
|
const txHash = (resp == null ? void 0 : resp.txhash) || broadcastResult.transactionHash;
|
|
4520
4523
|
if ((resp == null ? void 0 : resp.code) === 0) {
|
|
4524
|
+
success = true;
|
|
4521
4525
|
setProgressTrack("Transaction sent");
|
|
4522
4526
|
toast.clickableSuccess("Transaction Successful" /* Successful */, () => {
|
|
4523
4527
|
openExternalLink(`${getChainExplorerURL(chainName != null ? chainName : defaultChainName)}/tx/${txHash}`);
|
|
@@ -4534,12 +4538,19 @@ var useTx = (chainName) => {
|
|
|
4534
4538
|
}
|
|
4535
4539
|
} catch (e) {
|
|
4536
4540
|
console.error(e);
|
|
4537
|
-
|
|
4541
|
+
const errMsg = (_b2 = e == null ? void 0 : e.message) != null ? _b2 : "";
|
|
4542
|
+
const isSignerError = [
|
|
4543
|
+
"Failed to retrieve account from signer",
|
|
4544
|
+
"Signer address does not match",
|
|
4545
|
+
"signers mismatch",
|
|
4546
|
+
"Signer mismatched"
|
|
4547
|
+
].some((pattern) => errMsg.includes(pattern));
|
|
4548
|
+
if (isSignerError) {
|
|
4538
4549
|
disconnect();
|
|
4539
4550
|
}
|
|
4540
|
-
toast.error("Transaction Failed" /* Failed */, prettyError(
|
|
4551
|
+
toast.error("Transaction Failed" /* Failed */, prettyError(errMsg));
|
|
4541
4552
|
if (options == null ? void 0 : options.onFailure) {
|
|
4542
|
-
options.onFailure(prettyError(
|
|
4553
|
+
options.onFailure(prettyError(errMsg) || "Unknown error");
|
|
4543
4554
|
}
|
|
4544
4555
|
}
|
|
4545
4556
|
}
|
|
@@ -4547,6 +4558,7 @@ var useTx = (chainName) => {
|
|
|
4547
4558
|
setTimeout(() => {
|
|
4548
4559
|
setProgressTrack("");
|
|
4549
4560
|
}, (options == null ? void 0 : options.progressTrackerTimeout) || 5e3);
|
|
4561
|
+
return success;
|
|
4550
4562
|
}, [address, canUseClient, toast, signingClient, disconnect, getFee, chainName, defaultChainName]);
|
|
4551
4563
|
return {
|
|
4552
4564
|
tx,
|