@embarkai/ui-kit 0.4.45 → 0.4.47

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.js CHANGED
@@ -2432,15 +2432,11 @@ function useBackupStatusChanges() {
2432
2432
  onSuccess: ({ stats, detail }) => {
2433
2433
  const hasRecoveryData = stats && (!!stats.created || !!stats?.devices?.length);
2434
2434
  if (!!hasRecoveryData) {
2435
- console.log(
2436
- "[BACKUP STATUS] Recovery data found after backup status change.\n Redirect to main menu:",
2437
- detail?.navigateToMainMenu
2438
- );
2439
2435
  setHasServerVault(true);
2440
- if (!!detail?.navigateToMainMenu) {
2441
- setTimeout(() => setPage(null), 1e3);
2436
+ if (!!detail?.navigateToNicknameMenu) {
2437
+ console.log("[BACKUP STATUS] New user backup created, navigating to nickname settings");
2438
+ setTimeout(() => setPage("nickname-settings" /* NICKNAME_SETTINGS */), 1e3);
2442
2439
  }
2443
- console.info("[BACKUP STATUS] Recovery data found in vault, marking as has-server-vault");
2444
2440
  } else {
2445
2441
  setHasServerVault(false);
2446
2442
  setPage("keysare-backup" /* KEYSARE_BACKUP */);
@@ -7586,25 +7582,15 @@ function useAuthMenuHandlers() {
7586
7582
  const { config, callbacksRef } = useProviderConfig();
7587
7583
  const qc = useQueryClient2();
7588
7584
  const pendingLoginResponseRef = useRef6(null);
7589
- const setPage = useLayoutDataStore((st) => st.setPage);
7590
- const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
7591
7585
  const [telegramCleanup, setTelegramCleanup] = useState2(null);
7592
- const {
7593
- usePaymaster,
7594
- publicClient,
7595
- activeChainId,
7596
- setError,
7597
- setStatus,
7598
- setSession,
7599
- setAddress,
7600
- setRecoveryUserId,
7601
- setHasServerVault,
7602
- setIsLoading
7603
- } = useSession();
7586
+ const usePaymaster = useSession((st) => st.usePaymaster);
7587
+ const publicClient = useSession((st) => st.publicClient);
7588
+ const activeChainId = useSession((st) => st.activeChainId);
7604
7589
  const setStep = useAuthStore((st) => st.setStep);
7605
7590
  const setAlert = useAuthStore((st) => st.setAlert);
7606
7591
  const createSessionWithKeyshare = useCallback8(
7607
7592
  async (userId, hasServerKeyshare, isNewUser) => {
7593
+ const { setStatus } = useSession.getState();
7608
7594
  try {
7609
7595
  try {
7610
7596
  callbacksRef.current?.onConnecting?.({ method: "wallet" });
@@ -7642,9 +7628,19 @@ function useAuthMenuHandlers() {
7642
7628
  throw error;
7643
7629
  }
7644
7630
  },
7645
- [setStatus, usePaymaster, activeChainId]
7631
+ [usePaymaster, activeChainId]
7646
7632
  );
7647
7633
  const onAuthSuccess = useCallback8(async () => {
7634
+ const {
7635
+ //
7636
+ setSession,
7637
+ setAddress,
7638
+ setStatus,
7639
+ setIsLoading,
7640
+ setError,
7641
+ setHasServerVault,
7642
+ setRecoveryUserId
7643
+ } = useSession.getState();
7648
7644
  setIsLoading(true);
7649
7645
  setStep("loading");
7650
7646
  const loginResponse = pendingLoginResponseRef.current;
@@ -7708,11 +7704,11 @@ function useAuthMenuHandlers() {
7708
7704
  if (!!jwt?.isNewUser || !hasKeyshareVaultBackup) {
7709
7705
  if (!!jwt?.isNewUser) console.log("[AuthMenu] New user detected - forcing backup flow");
7710
7706
  if (!hasKeyshareVaultBackup) console.log("[AuthMenu] No recovery data found - forcing backup flow");
7711
- setIsDialogForced(true);
7712
- setPage("keysare-backup" /* KEYSARE_BACKUP */);
7707
+ useLayoutStore.getState().setIsDialogForced(true);
7708
+ useLayoutDataStore.getState().setPage("keysare-backup" /* KEYSARE_BACKUP */);
7713
7709
  } else {
7714
- setIsDialogForced(false);
7715
- setPage(null);
7710
+ useLayoutStore.getState().setIsDialogForced(false);
7711
+ useLayoutDataStore.getState().setPage(null);
7716
7712
  }
7717
7713
  }, 100);
7718
7714
  } catch (error) {
@@ -7724,9 +7720,7 @@ function useAuthMenuHandlers() {
7724
7720
  setAddress(null);
7725
7721
  setRecoveryUserId(userId);
7726
7722
  setStatus("recovery_needed");
7727
- setTimeout(() => {
7728
- setPage("keyshare-restore" /* KEYSHARE_RESTORE */);
7729
- }, 100);
7723
+ setTimeout(() => useLayoutDataStore.getState().setPage("keyshare-restore" /* KEYSHARE_RESTORE */), 100);
7730
7724
  } else {
7731
7725
  pendingLoginResponseRef.current = null;
7732
7726
  await jwtTokenManager2.clearTokens();
@@ -7742,20 +7736,7 @@ function useAuthMenuHandlers() {
7742
7736
  setIsLoading(false);
7743
7737
  setStep("signin");
7744
7738
  }
7745
- }, [
7746
- qc,
7747
- setStep,
7748
- setPage,
7749
- setError,
7750
- setStatus,
7751
- setSession,
7752
- setAlert,
7753
- setAddress,
7754
- setRecoveryUserId,
7755
- setHasServerVault,
7756
- setIsDialogForced,
7757
- createSessionWithKeyshare
7758
- ]);
7739
+ }, [qc, setStep, setAlert, createSessionWithKeyshare]);
7759
7740
  const goBackToSignIn = useCallback8(() => {
7760
7741
  setStep("signin");
7761
7742
  setAlert(null);
@@ -9545,11 +9526,12 @@ var init_networks = __esm({
9545
9526
  });
9546
9527
 
9547
9528
  // src/internal/components/BuyMenu/binance/BinanceSummary.tsx
9548
- import { useMutation as useMutation5 } from "@tanstack/react-query";
9529
+ import { useMutation as useMutation5, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
9549
9530
  import { InfoIcon as InfoIcon3, LoaderIcon } from "lucide-react";
9550
9531
  import { jsx as jsx33, jsxs as jsxs29 } from "react/jsx-runtime";
9551
9532
  function BinanceSummary(props) {
9552
9533
  const { payment } = props;
9534
+ const qc = useQueryClient3();
9553
9535
  const { t } = useT();
9554
9536
  const walletAddress = useSession((st) => st.address);
9555
9537
  const chainConfig = useSession((st) => st.chainConfig);
@@ -9568,10 +9550,10 @@ function BinanceSummary(props) {
9568
9550
  network: CHAIN_ID_TO_BINANCE_NETWORK_NAMES[chainConfig.id],
9569
9551
  payMethodCode: payment?.payMethodCode || void 0,
9570
9552
  payMethodSubCode: payment?.payMethodSubCode || void 0,
9571
- // redirectUrl: returnUrl,
9572
- // failRedirectUrl: returnUrl,
9573
9553
  // TODO: pass quote response to backend to create order with exact quote details (amount, fees, etc.)
9574
9554
  quote: quoteData
9555
+ // redirectUrl: returnUrl,
9556
+ // failRedirectUrl: returnUrl,
9575
9557
  });
9576
9558
  },
9577
9559
  onSuccess: (response) => {
@@ -9582,6 +9564,7 @@ function BinanceSummary(props) {
9582
9564
  } else {
9583
9565
  setTimeout(() => {
9584
9566
  setRedirecting(false);
9567
+ qc.invalidateQueries({ queryKey: [QUERY_KEYS2.binanceTransactions] });
9585
9568
  window.open(link, "_blank", "noopener,noreferrer");
9586
9569
  useBuyMenuStore.getState().setError(null);
9587
9570
  useBuyMenuStore.getState().setIsTransactionHistory(true);
@@ -9591,6 +9574,7 @@ function BinanceSummary(props) {
9591
9574
  onError: (err) => {
9592
9575
  setRedirecting(false);
9593
9576
  console.error("[BINANCE] Create Checkout Order failed", err);
9577
+ qc.invalidateQueries({ queryKey: [QUERY_KEYS2.binanceTransactions] });
9594
9578
  }
9595
9579
  });
9596
9580
  const isContinueDisabled = !!redirecting || !!isFundWalletOrderCheckouting || !quoteData;
@@ -9669,6 +9653,7 @@ var init_BinanceSummary = __esm({
9669
9653
  init_button();
9670
9654
  init_highlight();
9671
9655
  init_contants();
9656
+ init_queryKeys();
9672
9657
  init_useBuyMenuStore();
9673
9658
  init_api();
9674
9659
  init_networks();
@@ -9917,31 +9902,40 @@ function BinanceTxHistoryItem(props) {
9917
9902
  /* @__PURE__ */ jsxs30("div", { className: "w-full flex items-start gap-[var(--ui-kit-gap)] mb-1", children: [
9918
9903
  /* @__PURE__ */ jsx35(TokenIcon, { className: "w-8 h-8" }),
9919
9904
  /* @__PURE__ */ jsxs30("div", { className: "w-full", children: [
9905
+ Number(fiatAmount || "0") > 0 && /* @__PURE__ */ jsxs30("p", { className: "text-[10px] leading-3", children: [
9906
+ formatPrice(Number(fiatAmount)),
9907
+ " ",
9908
+ fiatCurrency
9909
+ ] }),
9920
9910
  /* @__PURE__ */ jsxs30("p", { className: "text-lg leading-5", children: [
9921
9911
  /* @__PURE__ */ jsx35("strong", { children: formatPrice(Number(cryptoAmount)) }),
9922
9912
  " ",
9923
9913
  cryptoCurrency
9924
- ] }),
9925
- Number(fiatAmount || "0") > 0 && /* @__PURE__ */ jsxs30("p", { className: "text-[10px] leading-4", children: [
9926
- formatPrice(Number(fiatAmount)),
9927
- " ",
9928
- fiatCurrency
9929
9914
  ] })
9930
9915
  ] })
9931
9916
  ] }),
9932
- /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-[var(--ui-kit-gap)] justify-between mb-1", children: [
9933
- /* @__PURE__ */ jsxs30("span", { className: cn("text-[10px] leading-5 text-[var(--ui-kit-fg-muted)]"), children: [
9917
+ /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-[var(--ui-kit-gap)] justify-between leading-4", children: [
9918
+ /* @__PURE__ */ jsxs30("span", { className: "flex-none whitespace-nowrap text-[10px] text-[var(--ui-kit-fg-muted)]", children: [
9934
9919
  "ID: ",
9935
9920
  id
9936
9921
  ] }),
9937
- /* @__PURE__ */ jsx35("span", { className: "text-[10px] leading-5 text-[var(--ui-kit-fg-muted)]", children: dayjs(updatedAt || createdAt).format("MMM D YYYY [at] HH:mm") })
9922
+ /* @__PURE__ */ jsx35(
9923
+ "span",
9924
+ {
9925
+ className: cn(
9926
+ "whitespace-nowrap overflow-hidden text-ellipsis",
9927
+ "block flex-1 text-[10px] text-right text-[var(--ui-kit-fg-muted)]"
9928
+ ),
9929
+ children: dayjs(updatedAt || createdAt).format("MMM D YYYY [at] HH:mm")
9930
+ }
9931
+ )
9938
9932
  ] }),
9939
9933
  orderDetailLink && /* @__PURE__ */ jsxs30(
9940
9934
  Button,
9941
9935
  {
9942
9936
  variant: "outline",
9943
9937
  size: "medium",
9944
- className: "w-full",
9938
+ className: "w-full mt-1",
9945
9939
  onClick: () => window.open(orderDetailLink, "_blank", "noopener,noreferrer"),
9946
9940
  children: [
9947
9941
  /* @__PURE__ */ jsx35(ExternalLinkIcon, { className: "w-4 h-4" }),
@@ -9991,7 +9985,7 @@ function BinanceTxHistory() {
9991
9985
  return /* @__PURE__ */ jsx35(Highlight, { children: t("passport:buyMenu.noItems.noTransactions") });
9992
9986
  }
9993
9987
  return /* @__PURE__ */ jsxs30("div", { className: "flex flex-col gap-[var(--ui-kit-gap)]", children: [
9994
- txList.map((tx) => /* @__PURE__ */ jsx35(BinanceTxHistoryItem, { ...tx }, tx.id)),
9988
+ isTxDataLoading ? /* @__PURE__ */ jsx35("div", { className: "w-full flex items-center justify-center p-[var(--ui-kit-pd)]", children: /* @__PURE__ */ jsx35(LoaderIcon2, { className: "w-4 h-4 animate-spin" }) }) : txList.map((tx) => /* @__PURE__ */ jsx35(BinanceTxHistoryItem, { ...tx }, tx.id)),
9995
9989
  hasNextPage && /* @__PURE__ */ jsxs30(
9996
9990
  Button,
9997
9991
  {
@@ -10029,10 +10023,10 @@ var init_BinanceTxHistory = __esm({
10029
10023
  });
10030
10024
 
10031
10025
  // src/internal/components/BuyMenu/binance/useBinanceSseTracing.ts
10032
- import { useQueryClient as useQueryClient3 } from "@tanstack/react-query";
10026
+ import { useQueryClient as useQueryClient4 } from "@tanstack/react-query";
10033
10027
  import { useEffect as useEffect12, useRef as useRef8 } from "react";
10034
10028
  function useBinanceSseTxTracing(walletAddress) {
10035
- const qc = useQueryClient3();
10029
+ const qc = useQueryClient4();
10036
10030
  const debounceRef = useRef8(null);
10037
10031
  useEffect12(() => {
10038
10032
  if (!walletAddress) return;
@@ -10042,7 +10036,7 @@ function useBinanceSseTxTracing(walletAddress) {
10042
10036
  if (data?.type !== "ORDER_UPDATED") return;
10043
10037
  if (debounceRef.current) clearTimeout(debounceRef.current);
10044
10038
  debounceRef.current = setTimeout(() => {
10045
- qc.invalidateQueries({ queryKey: [QUERY_KEYS2.binanceTransactions, walletAddress] });
10039
+ qc.invalidateQueries({ queryKey: [QUERY_KEYS2.binanceTransactions] });
10046
10040
  }, 500);
10047
10041
  }) || null;
10048
10042
  connectTxTracing({ walletAddress }).catch(
@@ -10074,7 +10068,7 @@ var init_utils6 = __esm({
10074
10068
  });
10075
10069
 
10076
10070
  // src/internal/components/BuyMenu/binance/Binance.tsx
10077
- import { useMutation as useMutation6, useQuery as useQuery2, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
10071
+ import { useMutation as useMutation6, useQuery as useQuery2, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
10078
10072
  import { LoaderIcon as LoaderIcon3 } from "lucide-react";
10079
10073
  import { useEffect as useEffect13 } from "react";
10080
10074
  import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs31 } from "react/jsx-runtime";
@@ -10084,7 +10078,7 @@ function normalizeChainName(chainName) {
10084
10078
  return chainName.toUpperCase();
10085
10079
  }
10086
10080
  function Binance() {
10087
- const qc = useQueryClient4();
10081
+ const qc = useQueryClient5();
10088
10082
  const { t, i18n } = useT();
10089
10083
  const resolvedLanguage = i18n.resolvedLanguage || "en";
10090
10084
  const chainConfig = useSession((st) => st.chainConfig);
@@ -10700,10 +10694,10 @@ var init_networks2 = __esm({
10700
10694
  });
10701
10695
 
10702
10696
  // src/internal/components/BuyMenu/finchpay/useFinchpaySseTxTracing.ts
10703
- import { useQueryClient as useQueryClient5 } from "@tanstack/react-query";
10697
+ import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
10704
10698
  import { useEffect as useEffect14, useRef as useRef9 } from "react";
10705
10699
  function useFinchpaySseTxTracing(walletAddress) {
10706
- const qc = useQueryClient5();
10700
+ const qc = useQueryClient6();
10707
10701
  const debounceRef = useRef9(null);
10708
10702
  useEffect14(() => {
10709
10703
  if (!walletAddress) return;
@@ -10752,12 +10746,12 @@ var init_utils7 = __esm({
10752
10746
  });
10753
10747
 
10754
10748
  // src/internal/components/BuyMenu/finchpay/FinchPay.tsx
10755
- import { useQuery as useQuery3, useQueryClient as useQueryClient6 } from "@tanstack/react-query";
10749
+ import { useQuery as useQuery3, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
10756
10750
  import { DollarSign, LoaderIcon as LoaderIcon5 } from "lucide-react";
10757
10751
  import { useEffect as useEffect15 } from "react";
10758
10752
  import { Fragment as Fragment12, jsx as jsx39, jsxs as jsxs34 } from "react/jsx-runtime";
10759
10753
  function FinchPay() {
10760
- const qc = useQueryClient6();
10754
+ const qc = useQueryClient7();
10761
10755
  const { t, i18n } = useT();
10762
10756
  const resolvedLanguage = i18n.resolvedLanguage || "en";
10763
10757
  const chainConfig = useSession((st) => st.chainConfig);
@@ -11577,75 +11571,51 @@ var init_LumiaIcon2 = __esm({
11577
11571
  }
11578
11572
  });
11579
11573
 
11580
- // src/config/networks.ts
11574
+ // src/internal/assets/networks/index.ts
11581
11575
  import {
11582
11576
  ARBITRUM_SEPOLIA_CHAIN_ID,
11583
11577
  BASE_SEPOLIA_CHAIN_ID,
11578
+ BSC_MAINNET_CHAIN_ID,
11584
11579
  BSC_TESTNET_CHAIN_ID as BSC_TESTNET_CHAIN_ID3,
11585
- LUMIA_PULSAR_TESTNET_CHAIN_ID,
11586
11580
  LUMIA_MAINNET_CHAIN_ID as LUMIA_MAINNET_CHAIN_ID3,
11587
- LUMIA_TESTNET_CHAIN_ID as LUMIA_TESTNET_CHAIN_ID3,
11588
- SEPOLIA_CHAIN_ID
11581
+ LUMIA_PULSAR_TESTNET_CHAIN_ID,
11582
+ LUMIA_TESTNET_CHAIN_ID as LUMIA_TESTNET_CHAIN_ID3
11589
11583
  } from "@embarkai/core/read";
11590
- var NETWORK_OPTIONS;
11584
+ var NETWORKS_ICONS;
11591
11585
  var init_networks3 = __esm({
11592
- "src/config/networks.ts"() {
11586
+ "src/internal/assets/networks/index.ts"() {
11593
11587
  init_ArbitrumIcon();
11594
11588
  init_BaseIcon();
11595
11589
  init_BscIcon();
11596
11590
  init_EthereumIcon();
11597
11591
  init_LumiaIcon2();
11598
- NETWORK_OPTIONS = [
11599
- {
11600
- chainId: LUMIA_TESTNET_CHAIN_ID3,
11601
- name: "Lumia Beam",
11602
- badge: "TESTNET",
11603
- Icon: LumiaIcon2,
11604
- isActive: true
11605
- },
11606
- {
11607
- chainId: LUMIA_MAINNET_CHAIN_ID3,
11608
- name: "Lumia Prism",
11609
- badge: "MAINNET",
11610
- Icon: LumiaIcon2,
11611
- isActive: true
11612
- },
11613
- {
11614
- chainId: SEPOLIA_CHAIN_ID,
11615
- name: "Sepolia",
11616
- badge: "TESTNET",
11617
- Icon: EthereumIcon,
11618
- isActive: true
11619
- },
11620
- {
11621
- chainId: BSC_TESTNET_CHAIN_ID3,
11622
- name: "BSC Testnet",
11623
- badge: "TESTNET",
11624
- Icon: BSCIcon,
11625
- isActive: true
11626
- },
11627
- {
11628
- chainId: ARBITRUM_SEPOLIA_CHAIN_ID,
11629
- name: "Arbitrum Sepolia",
11630
- badge: "TESTNET",
11631
- Icon: ArbitrumIcon,
11632
- isActive: true
11633
- },
11634
- {
11635
- chainId: BASE_SEPOLIA_CHAIN_ID,
11636
- name: "Base Sepolia",
11637
- badge: "TESTNET",
11638
- Icon: BaseIcon,
11639
- isActive: true
11640
- },
11641
- {
11642
- chainId: LUMIA_PULSAR_TESTNET_CHAIN_ID,
11643
- name: "Lumia Pulsar Testnet",
11644
- badge: "TESTNET",
11645
- Icon: LumiaIcon2,
11646
- isActive: true
11647
- }
11648
- ];
11592
+ NETWORKS_ICONS = {
11593
+ [LUMIA_MAINNET_CHAIN_ID3]: LumiaIcon2,
11594
+ [LUMIA_TESTNET_CHAIN_ID3]: LumiaIcon2,
11595
+ [LUMIA_PULSAR_TESTNET_CHAIN_ID]: LumiaIcon2,
11596
+ [BASE_SEPOLIA_CHAIN_ID]: BaseIcon,
11597
+ [BSC_MAINNET_CHAIN_ID]: BSCIcon,
11598
+ [BSC_TESTNET_CHAIN_ID3]: BSCIcon,
11599
+ 1: EthereumIcon,
11600
+ [ARBITRUM_SEPOLIA_CHAIN_ID]: ArbitrumIcon
11601
+ };
11602
+ }
11603
+ });
11604
+
11605
+ // src/config/networks.ts
11606
+ import { SUPPORTED_CHAINS, SUPPORTED_MAINNETS } from "@embarkai/core/read";
11607
+ var NETWORK_OPTIONS;
11608
+ var init_networks4 = __esm({
11609
+ "src/config/networks.ts"() {
11610
+ init_networks3();
11611
+ init_EmbarkIcon();
11612
+ NETWORK_OPTIONS = [...SUPPORTED_CHAINS].map(([chainId, chain]) => ({
11613
+ chainId,
11614
+ name: chain.name,
11615
+ badge: SUPPORTED_MAINNETS.includes(chainId) ? "MAINNET" : "TESTNET",
11616
+ Icon: NETWORKS_ICONS[chainId] || EmbarkIcon,
11617
+ isActive: true
11618
+ }));
11649
11619
  }
11650
11620
  });
11651
11621
 
@@ -11842,7 +11812,7 @@ function ChainsMenu() {
11842
11812
  }
11843
11813
  var init_ChainsMenu = __esm({
11844
11814
  "src/internal/components/ChainsMenu/ChainsMenu.tsx"() {
11845
- init_networks3();
11815
+ init_networks4();
11846
11816
  init_ProviderContext();
11847
11817
  init_SessionContext();
11848
11818
  init_useT();
@@ -11946,7 +11916,7 @@ function ChainSwitchRequest() {
11946
11916
  }
11947
11917
  var init_ChainSwitchRequest = __esm({
11948
11918
  "src/internal/components/ChainsMenu/ChainSwitchRequest.tsx"() {
11949
- init_networks3();
11919
+ init_networks4();
11950
11920
  init_ProviderContext();
11951
11921
  init_SessionContext();
11952
11922
  init_useT();
@@ -11967,7 +11937,7 @@ var init_ChainsMenu2 = __esm({
11967
11937
  });
11968
11938
 
11969
11939
  // src/internal/clients/devices.ts
11970
- import { useMutation as useMutation8, useQuery as useQuery5, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
11940
+ import { useMutation as useMutation8, useQuery as useQuery5, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
11971
11941
  async function getDevices() {
11972
11942
  const response = await tssClient.get("/api/auth/devices", true);
11973
11943
  if (!response.success || !response.data) {
@@ -11999,7 +11969,7 @@ function useDevices() {
11999
11969
  });
12000
11970
  }
12001
11971
  function useLinkDevice() {
12002
- const qc = useQueryClient7();
11972
+ const qc = useQueryClient8();
12003
11973
  return useMutation8({
12004
11974
  mutationFn: (code) => linkDevice(code),
12005
11975
  onSuccess: () => {
@@ -12008,7 +11978,7 @@ function useLinkDevice() {
12008
11978
  });
12009
11979
  }
12010
11980
  function useUnlinkDevice() {
12011
- const qc = useQueryClient7();
11981
+ const qc = useQueryClient8();
12012
11982
  return useMutation8({
12013
11983
  mutationFn: (deviceId) => unlinkDevice(deviceId),
12014
11984
  onSuccess: () => {
@@ -13751,43 +13721,46 @@ var init_cloudStorage = __esm({
13751
13721
  });
13752
13722
 
13753
13723
  // src/internal/components/KeyshareRestoreMenu/hooks/useCreateBackup.ts
13754
- import { useMutation as useMutation9, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
13755
- import { useEffect as useEffect20 } from "react";
13724
+ import { useMutation as useMutation9, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
13725
+ import { useCallback as useCallback17, useEffect as useEffect20 } from "react";
13756
13726
  function useCreateBackup() {
13757
- const qc = useQueryClient8();
13727
+ const qc = useQueryClient9();
13758
13728
  const session = useSession((st) => st.session);
13759
13729
  const address = useSession((st) => st.address);
13760
13730
  const hasServerVault = useSession((st) => st.hasServerVault);
13761
- const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
13762
- const { usePasskey, restorePassword, selectedCloudProvider, setSuccess, setError, setMethod, setIsCreatingPasskey } = useRestoreStore();
13731
+ const usePasskey = useRestoreStore((st) => st.usePasskey);
13732
+ const restorePassword = useRestoreStore((st) => st.restorePassword);
13733
+ const selectedCloudProvider = useRestoreStore((st) => st.selectedCloudProvider);
13763
13734
  useEffect20(() => {
13764
13735
  if (!hasServerVault) {
13765
- setMethod("server");
13766
- setIsDialogForced(true);
13736
+ useRestoreStore.getState().setMethod("server");
13737
+ useLayoutStore.getState().setIsDialogForced(true);
13767
13738
  }
13768
- }, [hasServerVault, setIsDialogForced, setMethod]);
13739
+ }, [hasServerVault]);
13769
13740
  const recoveryUserId = useSession((st) => st.recoveryUserId);
13770
13741
  const passportUserId = session?.mpcUserId || recoveryUserId || "";
13771
- const onBackupSuccess = () => console.log("[ConnectWalletButton] Backup created successfully");
13742
+ const onBackupSuccess = useCallback17(() => {
13743
+ console.log("[EMBARKAI BACKUP] Backup created successfully");
13744
+ }, [hasServerVault]);
13772
13745
  const { mutate: createPasswordBackup, isPending: isPasswordBackupCreating } = useMutation9({
13773
13746
  mutationFn: async () => {
13774
13747
  const iframeManager = getIframeManager();
13775
13748
  if (!iframeManager) {
13776
13749
  throw new Error("Iframe manager not initialized");
13777
13750
  }
13778
- const jwt = await Promise.resolve().then(() => (init_auth(), auth_exports)).then((m) => m.jwtTokenManager.getTokens());
13751
+ const jwt = jwtTokenManager2.getTokens();
13779
13752
  if (!usePasskey && !restorePassword) {
13780
13753
  throw new Error("Please provide a password for the backup");
13781
13754
  }
13782
13755
  const password = !usePasskey ? restorePassword : void 0;
13783
- const navigateToMainMenu = jwt.isNewUser || !hasServerVault;
13784
- console.log("[BACKUP STATUS] is new user:", jwt.isNewUser, !hasServerVault, "usePasskey:", usePasskey);
13756
+ console.log("[BACKUP STATUS] is new user:", jwt.isNewUser);
13785
13757
  return {
13786
13758
  response: await iframeManager.createBackup(passportUserId, { method: "server", password }, jwt.accessToken),
13787
- navigateToMainMenu
13759
+ isNewUser: jwt.isNewUser
13788
13760
  };
13789
13761
  },
13790
- onSuccess: async ({ response, navigateToMainMenu }) => {
13762
+ onSuccess: async ({ response, isNewUser }) => {
13763
+ const { setError, setSuccess } = useRestoreStore.getState();
13791
13764
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13792
13765
  if (response.success) {
13793
13766
  setError("");
@@ -13795,7 +13768,11 @@ function useCreateBackup() {
13795
13768
  if (typeof window !== "undefined") {
13796
13769
  window.dispatchEvent(
13797
13770
  new CustomEvent("lumia-passport-backup-status-changed", {
13798
- detail: { method: "server", success: true, navigateToMainMenu }
13771
+ detail: {
13772
+ method: "server",
13773
+ success: true,
13774
+ navigateToNicknameMenu: !!isNewUser
13775
+ }
13799
13776
  })
13800
13777
  );
13801
13778
  }
@@ -13803,9 +13780,10 @@ function useCreateBackup() {
13803
13780
  } else {
13804
13781
  setError(response.error || "Server backup failed");
13805
13782
  }
13806
- setIsDialogForced(false);
13783
+ useLayoutStore.getState().setIsDialogForced(false);
13807
13784
  },
13808
13785
  onError: async (error) => {
13786
+ const { setError, setSuccess } = useRestoreStore.getState();
13809
13787
  setSuccess("");
13810
13788
  if (error?.name === "NotAllowedError" || error?.message?.includes("timed out or was not allowed")) {
13811
13789
  setError("Passkey selection was cancelled. Please try again or create a new passkey.");
@@ -13834,7 +13812,7 @@ function useCreateBackup() {
13834
13812
  },
13835
13813
  onSuccess: async () => {
13836
13814
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13837
- setSuccess("Backup file downloaded successfully");
13815
+ useRestoreStore.getState().setSuccess("Backup file downloaded successfully");
13838
13816
  if (typeof window !== "undefined") {
13839
13817
  window.dispatchEvent(
13840
13818
  new CustomEvent("lumia-passport-backup-status-changed", {
@@ -13845,13 +13823,13 @@ function useCreateBackup() {
13845
13823
  onBackupSuccess();
13846
13824
  },
13847
13825
  onError: async (error) => {
13848
- setError(error?.message || "Backup creation failed");
13826
+ useRestoreStore.getState().setError(error?.message || "Backup creation failed");
13849
13827
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13850
13828
  }
13851
13829
  });
13852
13830
  const { mutate: createPasskey, isPending: isPasskeyCreating } = useMutation9({
13853
13831
  mutationFn: async () => {
13854
- setIsCreatingPasskey(true);
13832
+ useRestoreStore.getState().setIsCreatingPasskey(true);
13855
13833
  const { linkPasskeyWithWebAuthn: linkPasskeyWithWebAuthn2 } = await Promise.resolve().then(() => (init_passkey2(), passkey_exports2));
13856
13834
  const { createPasskeyHelpers: createPasskeyHelpers2 } = await Promise.resolve().then(() => (init_passkey(), passkey_exports));
13857
13835
  const { credentialId, rawId } = await linkPasskeyWithWebAuthn2();
@@ -13861,11 +13839,13 @@ function useCreateBackup() {
13861
13839
  return { credentialId, rawId };
13862
13840
  },
13863
13841
  onSuccess: async () => {
13842
+ const { setError, setSuccess, setIsCreatingPasskey } = useRestoreStore.getState();
13864
13843
  setIsCreatingPasskey(false);
13865
13844
  setError(null);
13866
13845
  setSuccess("Passkey created successfully. You can now create a backup.");
13867
13846
  },
13868
13847
  onError: async (error) => {
13848
+ const { setError, setIsCreatingPasskey } = useRestoreStore.getState();
13869
13849
  setIsCreatingPasskey(false);
13870
13850
  if (error.name === "NotAllowedError") {
13871
13851
  setError("Passkey creation cancelled. Please try again.");
@@ -13898,7 +13878,7 @@ function useCreateBackup() {
13898
13878
  },
13899
13879
  onSuccess: async ({ provider, uploadResult }) => {
13900
13880
  console.log("[KeyshareBackup] Cloud backup upload result:", uploadResult);
13901
- setSuccess(`Successfully created cloud backup on ${provider.name}`);
13881
+ useRestoreStore.getState().setSuccess(`Successfully created cloud backup on ${provider.name}`);
13902
13882
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13903
13883
  if (typeof window !== "undefined") {
13904
13884
  window.dispatchEvent(
@@ -13910,7 +13890,7 @@ function useCreateBackup() {
13910
13890
  onBackupSuccess();
13911
13891
  },
13912
13892
  onError: async (error) => {
13913
- setError(error?.message || "Backup creation failed");
13893
+ useRestoreStore.getState().setError(error?.message || "Backup creation failed");
13914
13894
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
13915
13895
  }
13916
13896
  });
@@ -13928,6 +13908,7 @@ function useCreateBackup() {
13928
13908
  var init_useCreateBackup = __esm({
13929
13909
  "src/internal/components/KeyshareRestoreMenu/hooks/useCreateBackup.ts"() {
13930
13910
  init_SessionContext();
13911
+ init_auth();
13931
13912
  init_useLayoutStore();
13932
13913
  init_iframe_manager();
13933
13914
  init_constants4();
@@ -14541,7 +14522,7 @@ var init_File = __esm({
14541
14522
  });
14542
14523
 
14543
14524
  // src/internal/components/KeyshareRestoreMenu/methods/Server.tsx
14544
- import { useQueryClient as useQueryClient9 } from "@tanstack/react-query";
14525
+ import { useQueryClient as useQueryClient10 } from "@tanstack/react-query";
14545
14526
  import dayjs3 from "dayjs";
14546
14527
  import { Download as Download3, Key as Key5, Upload as Upload3 } from "lucide-react";
14547
14528
  import { useEffect as useEffect23 } from "react";
@@ -14549,7 +14530,7 @@ import { Fragment as Fragment21, jsx as jsx58, jsxs as jsxs53 } from "react/jsx-
14549
14530
  function Server(props) {
14550
14531
  const { isLoading, mode = "restore", serverHandler, createPasskeyHandler } = props;
14551
14532
  const address = useSession((st) => st.address);
14552
- const qc = useQueryClient9();
14533
+ const qc = useQueryClient10();
14553
14534
  const { t } = useT();
14554
14535
  const usePasskey = useRestoreStore((st) => st.usePasskey);
14555
14536
  const setUsePasskey = useRestoreStore((st) => st.setUsePasskey);
@@ -14996,7 +14977,7 @@ var init_methods = __esm({
14996
14977
  });
14997
14978
 
14998
14979
  // src/internal/components/KeyshareRestoreMenu/KeyshareRestoreMenu.tsx
14999
- import { useMutation as useMutation11, useQuery as useQuery7, useQueryClient as useQueryClient10 } from "@tanstack/react-query";
14980
+ import { useMutation as useMutation11, useQuery as useQuery7, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
15000
14981
  import { AlertCircle as AlertCircle2, CheckCircle2, CloudDownload as CloudDownload2, Loader as Loader10, UserCircle as UserCircle2 } from "lucide-react";
15001
14982
  import { useEffect as useEffect25 } from "react";
15002
14983
  import { Fragment as Fragment24, jsx as jsx62, jsxs as jsxs57 } from "react/jsx-runtime";
@@ -15025,26 +15006,17 @@ var init_KeyshareRestoreMenu = __esm({
15025
15006
  guardian: Guardian
15026
15007
  };
15027
15008
  KeyshareRestoreMenu = () => {
15028
- const qc = useQueryClient10();
15009
+ const qc = useQueryClient11();
15029
15010
  const { callbacksRef } = useProviderConfig();
15030
15011
  const { t } = useT();
15031
- const { address, setSession, setAddress, setStatus, setIsLoading } = useSession();
15012
+ const address = useSession((st) => st.address);
15032
15013
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
15033
- const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
15034
- const setPage = useLayoutDataStore((st) => st.setPage);
15035
- const {
15036
- method: currentRestoreMethod,
15037
- error,
15038
- success,
15039
- setError,
15040
- setShowPassword,
15041
- setUsePasskey,
15042
- setRestoreFile,
15043
- setRestorePassword,
15044
- setSuccess,
15045
- setMethod
15046
- } = useRestoreStore();
15014
+ const error = useRestoreStore((st) => st.error);
15015
+ const success = useRestoreStore((st) => st.success);
15016
+ const currentRestoreMethod = useRestoreStore((st) => st.method);
15047
15017
  useEffect25(() => {
15018
+ const { setIsDialogForced } = useLayoutStore.getState();
15019
+ const { setRestorePassword, setRestoreFile, setShowPassword, setUsePasskey, setMethod } = useRestoreStore.getState();
15048
15020
  setIsDialogForced(true);
15049
15021
  return () => {
15050
15022
  setRestorePassword("");
@@ -15071,14 +15043,17 @@ var init_KeyshareRestoreMenu = __esm({
15071
15043
  });
15072
15044
  const hasServerBackup = serverRecoveryStatus?.created || serverRecoveryStatus?.devices?.length > 0;
15073
15045
  useEffect25(() => {
15074
- if (!!hasServerBackup) setMethod("server");
15046
+ if (!!hasServerBackup) useRestoreStore.getState().setMethod("server");
15075
15047
  }, [hasServerBackup]);
15076
15048
  const { mutate: disconnect, isPending: isDisconnecting } = useMutation11({
15077
15049
  mutationFn: async () => {
15050
+ const { setStatus, setIsLoading } = useSession.getState();
15051
+ const { setError, setMethod } = useRestoreStore.getState();
15078
15052
  setError(null);
15079
15053
  setMethod(null);
15080
15054
  setStatus("disconnecting");
15081
15055
  setIsLoading(true);
15056
+ useLayoutStore.getState().setIsDialogForced(true);
15082
15057
  const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
15083
15058
  const userId = jwtTokenManager4.getUserId() || null;
15084
15059
  const { logout: logout2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
@@ -15087,20 +15062,22 @@ var init_KeyshareRestoreMenu = __esm({
15087
15062
  },
15088
15063
  onSuccess: async ({ disconnectedUserId }) => {
15089
15064
  await qc.resetQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY] });
15065
+ const { setStatus, setIsLoading, setSession, setAddress } = useSession.getState();
15090
15066
  setSession(null);
15091
15067
  setAddress(null);
15092
- setError(null);
15093
15068
  setStatus("idle");
15094
15069
  setIsLoading(false);
15095
- setIsDialogForced(false);
15070
+ useRestoreStore.getState().setError(null);
15071
+ useLayoutStore.getState().setIsDialogForced(false);
15096
15072
  callbacksRef.current?.onDisconnect?.({ address: "0x", userId: disconnectedUserId });
15097
- setTimeout(() => setPage("auth" /* AUTH */), 50);
15073
+ setTimeout(() => useLayoutDataStore.getState().setPage("auth" /* AUTH */), 50);
15098
15074
  },
15099
15075
  onError: (err) => {
15100
- setError(err.message || "An unknown error occurred during sign out");
15076
+ const { setStatus, setIsLoading } = useSession.getState();
15101
15077
  setStatus("idle");
15102
15078
  setIsLoading(false);
15103
- setIsDialogForced(false);
15079
+ useRestoreStore.getState().setError(err.message || "An unknown error occurred during sign out");
15080
+ useLayoutStore.getState().setIsDialogForced(false);
15104
15081
  }
15105
15082
  });
15106
15083
  const RestoreComponent = currentRestoreMethod ? RESTORE_COMPONENTS[currentRestoreMethod] : null;
@@ -15134,6 +15111,7 @@ var init_KeyshareRestoreMenu = __esm({
15134
15111
  labels: { checked: t("passport:common.standard"), unchecked: t("passport:common.advanced") },
15135
15112
  checked: currentRestoreMethod !== "server",
15136
15113
  onChange: () => {
15114
+ const { setError, setRestorePassword, setRestoreFile, setMethod } = useRestoreStore.getState();
15137
15115
  if (!!error) setError(null);
15138
15116
  if (currentRestoreMethod === "server") {
15139
15117
  setRestorePassword("");
@@ -15163,6 +15141,15 @@ var init_KeyshareRestoreMenu = __esm({
15163
15141
  size: "large",
15164
15142
  variant: "ghost",
15165
15143
  onClick: () => {
15144
+ const {
15145
+ setError,
15146
+ setShowPassword,
15147
+ setUsePasskey,
15148
+ setRestoreFile,
15149
+ setRestorePassword,
15150
+ setSuccess,
15151
+ setMethod
15152
+ } = useRestoreStore.getState();
15166
15153
  setError(null);
15167
15154
  setShowPassword(false);
15168
15155
  setUsePasskey(false);
@@ -15209,20 +15196,11 @@ function KeyshareBackupMenu() {
15209
15196
  const { t } = useT();
15210
15197
  const setPage = useLayoutDataStore((st) => st.setPage);
15211
15198
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
15212
- const {
15213
- method: currentBackupMethod,
15214
- error,
15215
- success,
15216
- setSelectedCloudProvider,
15217
- setSuccess,
15218
- setError,
15219
- setRestorePassword,
15220
- setRestoreFile,
15221
- setShowPassword,
15222
- setUsePasskey,
15223
- setMethod
15224
- } = useRestoreStore();
15199
+ const currentBackupMethod = useRestoreStore((st) => st.method);
15200
+ const error = useRestoreStore((st) => st.error);
15201
+ const success = useRestoreStore((st) => st.success);
15225
15202
  useEffect26(() => {
15203
+ const { setSuccess, setError, setRestorePassword, setRestoreFile, setShowPassword, setUsePasskey, setMethod } = useRestoreStore.getState();
15226
15204
  return () => {
15227
15205
  setSuccess(null);
15228
15206
  setError(null);
@@ -15236,13 +15214,12 @@ function KeyshareBackupMenu() {
15236
15214
  const { data: serverRecoveryStatus, isLoading: isRecoveryLoading } = useQuery8({
15237
15215
  retry: false,
15238
15216
  enabled: !!address,
15239
- // Prevent query from running with undefined address
15240
15217
  queryKey: [CHECK_BACKUP_QUERY_KEY, address],
15241
15218
  queryFn: async () => await getShareRecoveryStats()
15242
15219
  });
15243
15220
  const hasRecoveryData = serverRecoveryStatus?.created || serverRecoveryStatus?.devices?.length > 0;
15244
15221
  useEffect26(() => {
15245
- if (!!hasRecoveryData) setMethod("server");
15222
+ if (!!hasRecoveryData) useRestoreStore.getState().setMethod("server");
15246
15223
  }, [hasRecoveryData]);
15247
15224
  const {
15248
15225
  isPasswordBackupCreating,
@@ -15275,6 +15252,16 @@ function KeyshareBackupMenu() {
15275
15252
  size: "icon",
15276
15253
  title: "Back",
15277
15254
  onClick: () => {
15255
+ const {
15256
+ setSuccess,
15257
+ setError,
15258
+ setRestorePassword,
15259
+ setRestoreFile,
15260
+ setShowPassword,
15261
+ setUsePasskey,
15262
+ setMethod,
15263
+ setSelectedCloudProvider
15264
+ } = useRestoreStore.getState();
15278
15265
  setRestorePassword("");
15279
15266
  setRestoreFile(null);
15280
15267
  setShowPassword(false);
@@ -15297,6 +15284,7 @@ function KeyshareBackupMenu() {
15297
15284
  labels: { checked: t("passport:common.standard"), unchecked: t("passport:common.advanced") },
15298
15285
  checked: currentBackupMethod !== "server",
15299
15286
  onChange: () => {
15287
+ const { setError, setRestorePassword, setRestoreFile, setMethod } = useRestoreStore.getState();
15300
15288
  if (!!error) setError(null);
15301
15289
  if (currentBackupMethod === "server") {
15302
15290
  setRestorePassword("");
@@ -15329,21 +15317,12 @@ function KeyshareBackupMenu() {
15329
15317
  /* @__PURE__ */ jsx63(AlertCircle3, { className: "h-4 w-4 flex-shrink-0" }),
15330
15318
  /* @__PURE__ */ jsx63("span", { className: "block w-full flex-1", children: error })
15331
15319
  ] }),
15332
- success && /* @__PURE__ */ jsxs58(Fragment25, { children: [
15333
- /* @__PURE__ */ jsxs58(Highlight, { type: "success", className: "flex gap-[var(--ui-kit-gap)]", children: [
15320
+ success && /* @__PURE__ */ jsxs58(Highlight, { type: "success", className: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: [
15321
+ /* @__PURE__ */ jsxs58("div", { className: "w-full flex gap-[var(--ui-kit-gap)]", children: [
15334
15322
  /* @__PURE__ */ jsx63(CheckCircle22, { className: "h-4 w-4 flex-shrink-0" }),
15335
15323
  /* @__PURE__ */ jsx63("span", { className: "block w-full flex-1", children: success })
15336
15324
  ] }),
15337
- /* @__PURE__ */ jsx63(
15338
- Button,
15339
- {
15340
- variant: "default",
15341
- size: "large",
15342
- className: "w-full",
15343
- onClick: () => setPage("settings" /* SETTINGS */),
15344
- children: "Done"
15345
- }
15346
- )
15325
+ /* @__PURE__ */ jsx63(Button, { variant: "default", size: "large", className: "w-full", onClick: () => setPage("settings" /* SETTINGS */), children: t("passport:common.continue") })
15347
15326
  ] })
15348
15327
  ] })
15349
15328
  }
@@ -15383,7 +15362,7 @@ var init_KeyshareRestoreMenu2 = __esm({
15383
15362
  });
15384
15363
 
15385
15364
  // src/hooks/useColorMode.ts
15386
- import { useCallback as useCallback17, useEffect as useEffect27 } from "react";
15365
+ import { useCallback as useCallback18, useEffect as useEffect27 } from "react";
15387
15366
  function useColorMode() {
15388
15367
  const {
15389
15368
  config: { current: config }
@@ -15391,7 +15370,7 @@ function useColorMode() {
15391
15370
  const preferedColorMode = config?.preferedColorMode;
15392
15371
  const colorMode = useLayoutStore((st) => st.colorMode);
15393
15372
  const handleStoreColorMode = useLayoutStore((st) => st.setColorMode);
15394
- const setColorMode = useCallback17(
15373
+ const setColorMode = useCallback18(
15395
15374
  (mode) => {
15396
15375
  localStorage.setItem(LOCAL_COLOR_MODE_KEY, mode);
15397
15376
  handleStoreColorMode(mode);
@@ -15886,10 +15865,10 @@ var init_MainMenu2 = __esm({
15886
15865
  });
15887
15866
 
15888
15867
  // src/modules/linkedProfiles.ts
15889
- import { useQuery as useQuery11, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
15890
- import { useCallback as useCallback18 } from "react";
15868
+ import { useQuery as useQuery11, useQueryClient as useQueryClient12 } from "@tanstack/react-query";
15869
+ import { useCallback as useCallback19 } from "react";
15891
15870
  function useLinkedProfiles() {
15892
- const qc = useQueryClient11();
15871
+ const qc = useQueryClient12();
15893
15872
  const address = useSession((st) => st.address);
15894
15873
  const { data, isFetching, isLoading, error } = useQuery11({
15895
15874
  retry: false,
@@ -15911,7 +15890,7 @@ function useLinkedProfiles() {
15911
15890
  }
15912
15891
  });
15913
15892
  const { profiles = [], avatar = null } = data || {};
15914
- const refresh = useCallback18(async () => {
15893
+ const refresh = useCallback19(async () => {
15915
15894
  await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
15916
15895
  }, [qc, address]);
15917
15896
  return { profiles, avatar, isLoading, isFetching, error, refresh };
@@ -16131,10 +16110,10 @@ var init_useSendVerificationCode = __esm({
16131
16110
  });
16132
16111
 
16133
16112
  // src/internal/components/ManageWalletMenu/hooks/useVerifyCode.ts
16134
- import { useMutation as useMutation14, useQueryClient as useQueryClient12 } from "@tanstack/react-query";
16113
+ import { useMutation as useMutation14, useQueryClient as useQueryClient13 } from "@tanstack/react-query";
16135
16114
  function useVerifyCode() {
16136
16115
  const { callbacksRef } = useProviderConfig();
16137
- const qc = useQueryClient12();
16116
+ const qc = useQueryClient13();
16138
16117
  const address = useSession((st) => st.address);
16139
16118
  const setIsLoading = useSession((st) => st.setIsLoading);
16140
16119
  const {
@@ -16198,7 +16177,7 @@ var init_useVerifyCode = __esm({
16198
16177
  });
16199
16178
 
16200
16179
  // src/internal/components/ManageWalletMenu/AddProvider.tsx
16201
- import { useQueryClient as useQueryClient13 } from "@tanstack/react-query";
16180
+ import { useQueryClient as useQueryClient14 } from "@tanstack/react-query";
16202
16181
  import { Fragment as Fragment27, jsx as jsx70, jsxs as jsxs65 } from "react/jsx-runtime";
16203
16182
  function normalizePasskeyLinkError(msg) {
16204
16183
  const lower = msg.toLowerCase();
@@ -16211,7 +16190,7 @@ function normalizePasskeyLinkError(msg) {
16211
16190
  return msg;
16212
16191
  }
16213
16192
  function AddProvider() {
16214
- const qc = useQueryClient13();
16193
+ const qc = useQueryClient14();
16215
16194
  const { callbacksRef } = useProviderConfig();
16216
16195
  const address = useSession((st) => st.address);
16217
16196
  const { t } = useT();
@@ -16388,7 +16367,7 @@ var init_EmailNotConnectedWarning = __esm({
16388
16367
  });
16389
16368
 
16390
16369
  // src/internal/components/ManageWalletMenu/hooks/useLinkSocial.ts
16391
- import { useQueryClient as useQueryClient14 } from "@tanstack/react-query";
16370
+ import { useQueryClient as useQueryClient15 } from "@tanstack/react-query";
16392
16371
  import React5, { useEffect as useEffect30 } from "react";
16393
16372
  function normalizeSocialLinkError(message) {
16394
16373
  if (message === "X_ALREADY_LINKED") {
@@ -16397,7 +16376,7 @@ function normalizeSocialLinkError(message) {
16397
16376
  return message;
16398
16377
  }
16399
16378
  function useLinkSocial() {
16400
- const qc = useQueryClient14();
16379
+ const qc = useQueryClient15();
16401
16380
  const address = useSession((st) => st.address);
16402
16381
  const {
16403
16382
  config: { current: config },
@@ -16547,19 +16526,19 @@ var init_telegram2 = __esm({
16547
16526
  });
16548
16527
 
16549
16528
  // src/internal/components/ManageWalletMenu/hooks/useLinkTelegram.ts
16550
- import { useQueryClient as useQueryClient15 } from "@tanstack/react-query";
16551
- import { useCallback as useCallback19, useEffect as useEffect31, useState as useState17 } from "react";
16529
+ import { useQueryClient as useQueryClient16 } from "@tanstack/react-query";
16530
+ import { useCallback as useCallback20, useEffect as useEffect31, useState as useState17 } from "react";
16552
16531
  function useLinkTelegram() {
16553
16532
  const {
16554
16533
  config: { current: config },
16555
16534
  callbacksRef
16556
16535
  } = useProviderConfig();
16557
- const qc = useQueryClient15();
16536
+ const qc = useQueryClient16();
16558
16537
  const address = useSession((st) => st.address);
16559
16538
  const isWalletLinking = useLayoutDataStore((st) => st.isWalletLinking);
16560
16539
  const { providerType, linkIsLoading, setLinkIsLoading, setProviderType, setAlert } = useManageWalletStore();
16561
16540
  const setPage = useLayoutDataStore((st) => st.setPage);
16562
- const handleLinkTelegram = useCallback19(async () => {
16541
+ const handleLinkTelegram = useCallback20(async () => {
16563
16542
  try {
16564
16543
  if (shouldBlockSocialAuthInTelegram("telegram")) {
16565
16544
  setAlert(buildTelegramBrowserRestriction("Telegram", "linking"));
@@ -16956,13 +16935,13 @@ var init_useExternalWalletStore = __esm({
16956
16935
  });
16957
16936
 
16958
16937
  // src/internal/components/ManageWalletMenu/UnlinkProviderMenu.tsx
16959
- import { useMutation as useMutation15, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
16938
+ import { useMutation as useMutation15, useQueryClient as useQueryClient17 } from "@tanstack/react-query";
16960
16939
  import { Key as Key6, Loader as Loader15 } from "lucide-react";
16961
16940
  import { useState as useState18 } from "react";
16962
16941
  import { useDisconnect } from "wagmi";
16963
16942
  import { jsx as jsx74, jsxs as jsxs69 } from "react/jsx-runtime";
16964
16943
  function UnlinkProviderMenu() {
16965
- const qc = useQueryClient16();
16944
+ const qc = useQueryClient17();
16966
16945
  const address = useSession((st) => st.address);
16967
16946
  const { callbacksRef } = useProviderConfig();
16968
16947
  const { disconnect: disconnectExternalWallet } = useDisconnect();
@@ -17197,9 +17176,9 @@ var init_nickname_validation = __esm({
17197
17176
  });
17198
17177
 
17199
17178
  // src/internal/components/NicknameMenu/NicknameEditForm.tsx
17200
- import { useMutation as useMutation16, useQueryClient as useQueryClient17 } from "@tanstack/react-query";
17179
+ import { useMutation as useMutation16, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
17201
17180
  import { AtSign, Check as Check2, ChevronRight as ChevronRight5, Copy as Copy2, Loader as Loader17 } from "lucide-react";
17202
- import { useCallback as useCallback20, useState as useState19 } from "react";
17181
+ import { useCallback as useCallback21, useState as useState19 } from "react";
17203
17182
  import { Fragment as Fragment29, jsx as jsx76, jsxs as jsxs71 } from "react/jsx-runtime";
17204
17183
  function NicknameEditForm(props) {
17205
17184
  const {
@@ -17214,7 +17193,7 @@ function NicknameEditForm(props) {
17214
17193
  info
17215
17194
  } = props;
17216
17195
  const { handle: currentNickname, canChange } = info || { handle: "", canChange: false };
17217
- const qc = useQueryClient17();
17196
+ const qc = useQueryClient18();
17218
17197
  const { t } = useT();
17219
17198
  const passportWalletAddress = useSession((st) => st.address);
17220
17199
  const { callbacksRef } = useProviderConfig();
@@ -17250,7 +17229,7 @@ function NicknameEditForm(props) {
17250
17229
  );
17251
17230
  }
17252
17231
  });
17253
- const handleInputChange = useCallback20(
17232
+ const handleInputChange = useCallback21(
17254
17233
  (e) => {
17255
17234
  const value = e.target.value;
17256
17235
  setInputValue(value);
@@ -17264,7 +17243,7 @@ function NicknameEditForm(props) {
17264
17243
  },
17265
17244
  [clientError, isNicknameChangeError, isNicknameChangeSuccess, reset, t]
17266
17245
  );
17267
- const handleSubmit = useCallback20(
17246
+ const handleSubmit = useCallback21(
17268
17247
  (e) => {
17269
17248
  if (!canChange) return;
17270
17249
  e.preventDefault();
@@ -17666,7 +17645,7 @@ var init_useWatchTokens = __esm({
17666
17645
  // src/internal/hooks/useBlockscoutAssets.ts
17667
17646
  import { createBlockscoutClient } from "@embarkai/core/clients";
17668
17647
  import { useQuery as useQuery15 } from "@tanstack/react-query";
17669
- import { useCallback as useCallback21, useMemo as useMemo9, useRef as useRef16 } from "react";
17648
+ import { useCallback as useCallback22, useMemo as useMemo9, useRef as useRef16 } from "react";
17670
17649
  import { formatEther, formatUnits as formatUnits3 } from "viem";
17671
17650
  function resolveIpfsUri(uri) {
17672
17651
  if (!uri) return "";
@@ -17973,7 +17952,7 @@ function useBlockscoutAssets(options) {
17973
17952
  if (!tokensError) return null;
17974
17953
  return createError(tokensError);
17975
17954
  }, [tokensError]);
17976
- const refreshBalances = useCallback21(async () => {
17955
+ const refreshBalances = useCallback22(async () => {
17977
17956
  const now = Date.now();
17978
17957
  if (now - lastRefreshRef.current < BLOCKSCOUT_REFRESH_DEBOUNCE) {
17979
17958
  return;
@@ -17981,7 +17960,7 @@ function useBlockscoutAssets(options) {
17981
17960
  lastRefreshRef.current = now;
17982
17961
  await Promise.all([refetchNative(), refetchTokens(), refetchNfts(), refetchWatchTokens()]);
17983
17962
  }, [refetchNative, refetchTokens, refetchNfts, refetchWatchTokens]);
17984
- const getTokenBalance = useCallback21(
17963
+ const getTokenBalance = useCallback22(
17985
17964
  (tokenAddress) => {
17986
17965
  return assets.find((a) => a.address?.toLowerCase() === tokenAddress.toLowerCase()) || null;
17987
17966
  },
@@ -18068,7 +18047,7 @@ var init_BalanceView2 = __esm({
18068
18047
  });
18069
18048
 
18070
18049
  // src/internal/components/PortfolioMenu/PortfolioItem.tsx
18071
- import { useQuery as useQuery16, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
18050
+ import { useQuery as useQuery16, useQueryClient as useQueryClient19 } from "@tanstack/react-query";
18072
18051
  import { Image as ImageIcon, Loader as Loader19, ShieldAlert, Sparkles } from "lucide-react";
18073
18052
  import { useState as useState22 } from "react";
18074
18053
  import { formatUnits as formatUnits5 } from "viem";
@@ -18161,7 +18140,7 @@ function PortfolioItem(props) {
18161
18140
  const { assets: projectAssets, showBalanceAs: showBalanceAsSymbol } = providerConfig.projectAssets || {};
18162
18141
  const customAssetRateQuery = providerConfig.portfolio?.assetRateQuery;
18163
18142
  const customAssetRateQueryKey = providerConfig.portfolio?.assetRateQueryKey;
18164
- const qc = useQueryClient18();
18143
+ const qc = useQueryClient19();
18165
18144
  const { balanceQueryKey } = projectAssets?.find((a) => a.symbol === showBalanceAsSymbol) || {};
18166
18145
  const projectAssetBalance = !!balanceQueryKey ? qc.getQueryData(balanceQueryKey) : null;
18167
18146
  const isNft = isNftAsset(asset);
@@ -18255,14 +18234,14 @@ var init_PortfolioItem = __esm({
18255
18234
  });
18256
18235
 
18257
18236
  // src/internal/components/PortfolioMenu/PortfolioMenu.tsx
18258
- import { useQueryClient as useQueryClient19 } from "@tanstack/react-query";
18237
+ import { useQueryClient as useQueryClient20 } from "@tanstack/react-query";
18259
18238
  import { AlertCircle as AlertCircle4, ArrowLeft as ArrowLeft16, Gem, Loader as Loader20, RefreshCw as RefreshCw2 } from "lucide-react";
18260
- import { useCallback as useCallback22 } from "react";
18239
+ import { useCallback as useCallback23 } from "react";
18261
18240
  import { jsx as jsx80, jsxs as jsxs75 } from "react/jsx-runtime";
18262
18241
  function PortfolioMenu() {
18263
18242
  const { assets: projectAssets = [] } = useProviderConfig().config.current?.projectAssets || {};
18264
18243
  const { t } = useT();
18265
- const qc = useQueryClient19();
18244
+ const qc = useQueryClient20();
18266
18245
  const address = useSession((st) => st.address);
18267
18246
  const setPage = useLayoutDataStore((st) => st.setPage);
18268
18247
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
@@ -18277,7 +18256,7 @@ function PortfolioMenu() {
18277
18256
  enabled: !!address
18278
18257
  });
18279
18258
  const shownProjectAssests = projectAssets.filter((asset) => !asset.hideInPortfolio);
18280
- const refreshAllAssetsBalances = useCallback22(() => {
18259
+ const refreshAllAssetsBalances = useCallback23(() => {
18281
18260
  Promise.all(shownProjectAssests.map((asset) => qc.invalidateQueries({ queryKey: asset.balanceQueryKey })));
18282
18261
  refreshBlockscoutBalances();
18283
18262
  }, [qc, shownProjectAssests, refreshBlockscoutBalances]);
@@ -18432,7 +18411,7 @@ var init_nickname_fingerprint = __esm({
18432
18411
  // src/internal/components/ReceiveMenu/ReceiveMenu.tsx
18433
18412
  import { ArrowLeft as ArrowLeft17, CheckCircle2 as CheckCircle23, Copy as Copy3, Info as Info5, Loader as Loader21, Shield } from "lucide-react";
18434
18413
  import QRCode from "qrcode";
18435
- import { useCallback as useCallback23, useEffect as useEffect33, useMemo as useMemo10, useState as useState23 } from "react";
18414
+ import { useCallback as useCallback24, useEffect as useEffect33, useMemo as useMemo10, useState as useState23 } from "react";
18436
18415
  import { Fragment as Fragment31, jsx as jsx81, jsxs as jsxs76 } from "react/jsx-runtime";
18437
18416
  function ReceiveMenu() {
18438
18417
  const session = useSession((st) => st.session);
@@ -18467,7 +18446,7 @@ function ReceiveMenu() {
18467
18446
  });
18468
18447
  }
18469
18448
  }, [open, address]);
18470
- const handleCopy = useCallback23(async () => {
18449
+ const handleCopy = useCallback24(async () => {
18471
18450
  if (!address) return;
18472
18451
  try {
18473
18452
  await navigator.clipboard.writeText(address);
@@ -18477,7 +18456,7 @@ function ReceiveMenu() {
18477
18456
  console.error("Failed to copy address:", error);
18478
18457
  }
18479
18458
  }, [address]);
18480
- const handleCopyFingerprint = useCallback23(async () => {
18459
+ const handleCopyFingerprint = useCallback24(async () => {
18481
18460
  if (!fingerprint) return;
18482
18461
  try {
18483
18462
  await navigator.clipboard.writeText(fingerprint);
@@ -19000,12 +18979,12 @@ var init_UntrustApplication = __esm({
19000
18979
  });
19001
18980
 
19002
18981
  // src/internal/components/SecurityMenu/SecurityMenu.tsx
19003
- import { useMutation as useMutation17, useQueryClient as useQueryClient20 } from "@tanstack/react-query";
18982
+ import { useMutation as useMutation17, useQueryClient as useQueryClient21 } from "@tanstack/react-query";
19004
18983
  import { ArrowLeft as ArrowLeft18 } from "lucide-react";
19005
18984
  import { useState as useState24 } from "react";
19006
18985
  import { jsx as jsx88, jsxs as jsxs83 } from "react/jsx-runtime";
19007
18986
  function SecurityMenu() {
19008
- const qc = useQueryClient20();
18987
+ const qc = useQueryClient21();
19009
18988
  const { t } = useT();
19010
18989
  const maxScrollHeight = useLayoutStore((st) => st.maxScrollHeight);
19011
18990
  const setPage = useLayoutDataStore((st) => st.setPage);
@@ -19966,7 +19945,7 @@ function isOririnChainEmbarkSupported(originChain) {
19966
19945
  }
19967
19946
  var init_utils8 = __esm({
19968
19947
  "src/internal/components/SendMenu/hyperbridge/utils.ts"() {
19969
- init_networks3();
19948
+ init_networks4();
19970
19949
  init_chains();
19971
19950
  }
19972
19951
  });
@@ -19974,7 +19953,7 @@ var init_utils8 = __esm({
19974
19953
  // src/internal/components/SendMenu/hyperbridge/hooks/useHyperlaneHistory.ts
19975
19954
  import { useInfiniteQuery as useInfiniteQuery3 } from "@tanstack/react-query";
19976
19955
  import { debounce as debounce6 } from "lodash-es";
19977
- import { useCallback as useCallback24, useEffect as useEffect36, useMemo as useMemo11 } from "react";
19956
+ import { useCallback as useCallback25, useEffect as useEffect36, useMemo as useMemo11 } from "react";
19978
19957
  function useHyperlaneHistory() {
19979
19958
  const address = useSession((st) => st.address);
19980
19959
  const page = useLayoutDataStore((st) => st.page);
@@ -19994,7 +19973,7 @@ function useHyperlaneHistory() {
19994
19973
  () => txHistoryData?.pages?.map((p) => p.data).flat(Infinity) || [],
19995
19974
  [txHistoryData]
19996
19975
  );
19997
- const updateExpandable = useCallback24(
19976
+ const updateExpandable = useCallback25(
19998
19977
  debounce6(() => {
19999
19978
  useFlowSelectorStore.getState().setRenderKey(`hyperlane-history-loaded-${Date.now()}`);
20000
19979
  }, 250),
@@ -20035,16 +20014,16 @@ var init_useOperationHashesStore = __esm({
20035
20014
  });
20036
20015
 
20037
20016
  // src/internal/components/SendMenu/hyperbridge/hooks/useBridge.ts
20038
- import { useMutation as useMutation19, useQueryClient as useQueryClient21 } from "@tanstack/react-query";
20039
- import { useCallback as useCallback25 } from "react";
20017
+ import { useMutation as useMutation19, useQueryClient as useQueryClient22 } from "@tanstack/react-query";
20018
+ import { useCallback as useCallback26 } from "react";
20040
20019
  import { useSwitchChain, useWalletClient } from "wagmi";
20041
20020
  function useBridge() {
20042
- const qc = useQueryClient21();
20021
+ const qc = useQueryClient22();
20043
20022
  const { t } = useT();
20044
20023
  const address = useSession((st) => st.address);
20045
20024
  const { data: walletClient } = useWalletClient();
20046
20025
  const { switchChainAsync } = useSwitchChain();
20047
- const swapDirection = useCallback25(() => {
20026
+ const swapDirection = useCallback26(() => {
20048
20027
  const {
20049
20028
  bridgeStep,
20050
20029
  originChain,
@@ -20096,7 +20075,7 @@ function useBridge() {
20096
20075
  useFlowSelectorStore.getState().setError(error instanceof Error ? error.message : String(error));
20097
20076
  }
20098
20077
  });
20099
- const handleQuoteEstimation = useCallback25((amnt) => {
20078
+ const handleQuoteEstimation = useCallback26((amnt) => {
20100
20079
  const { originChain, destinationChain, bridgeSender } = useBridgeStore.getState();
20101
20080
  if (!amnt || !Number(amnt)) {
20102
20081
  useBridgeStore.getState().setQuote(null);
@@ -20192,6 +20171,7 @@ function useBridge() {
20192
20171
  },
20193
20172
  onSuccess: (operationHashes) => {
20194
20173
  const { setBridgeStep, setBridgeTxStatus } = useBridgeStore.getState();
20174
+ qc.invalidateQueries({ queryKey: [HYPERLANE_HISTORY_QUERY_KEY] });
20195
20175
  useOperationHashesStore.getState().setOperationHashes(operationHashes);
20196
20176
  useLayoutStore.getState().setIsDialogForced(false);
20197
20177
  useFlowSelectorStore.getState().setIsUiLocked(false);
@@ -20204,7 +20184,7 @@ function useBridge() {
20204
20184
  if (hyperlaneDbTx?.id) {
20205
20185
  patchInitiatedBridgeTxStatus({ txId: hyperlaneDbTx.id, txStatus: "REJECTED" }).then(({ ok }) => {
20206
20186
  console.log("[HYPERLANE SDK] initiated tx patched as REJECTED: ", hyperlaneDbTx.id, "ok: ", ok);
20207
- if (ok) qc.invalidateQueries({ queryKey: [HYPERLANE_HISTORY_QUERY_KEY, address, 1] });
20187
+ if (ok) qc.invalidateQueries({ queryKey: [HYPERLANE_HISTORY_QUERY_KEY] });
20208
20188
  });
20209
20189
  }
20210
20190
  useLayoutStore.getState().setIsDialogForced(false);
@@ -20354,12 +20334,12 @@ var init_ResolveChainIcon = __esm({
20354
20334
 
20355
20335
  // src/internal/components/SendMenu/hyperbridge/hooks/useBridgeBalance.ts
20356
20336
  import { CHAINS_BROWSERS_TRANSPORTS as CHAINS_BROWSERS_TRANSPORTS2 } from "@embarkai/core";
20357
- import { useQuery as useQuery20, useQueryClient as useQueryClient22 } from "@tanstack/react-query";
20358
- import { useCallback as useCallback26, useEffect as useEffect39 } from "react";
20337
+ import { useQuery as useQuery20, useQueryClient as useQueryClient23 } from "@tanstack/react-query";
20338
+ import { useCallback as useCallback27, useEffect as useEffect39 } from "react";
20359
20339
  import { createPublicClient as createPublicClient2, erc20Abi as erc20Abi2, formatUnits as formatUnits7, http as http3 } from "viem";
20360
20340
  import { useSwitchChain as useSwitchChain2 } from "wagmi";
20361
20341
  function useBridgeBalance(hyperlaneWarpRoutes) {
20362
- const qc = useQueryClient22();
20342
+ const qc = useQueryClient23();
20363
20343
  const { t } = useT();
20364
20344
  const address = useSession((st) => st.address);
20365
20345
  const directWalletAddress = useExternalWalletStore((st) => st.externalAddress);
@@ -20444,7 +20424,7 @@ function useBridgeBalance(hyperlaneWarpRoutes) {
20444
20424
  };
20445
20425
  }
20446
20426
  });
20447
- const refreshRouteTokenBalance = useCallback26(
20427
+ const refreshRouteTokenBalance = useCallback27(
20448
20428
  (senderWallet) => {
20449
20429
  switch (true) {
20450
20430
  case senderWallet === "embarkai-wallet":
@@ -21019,7 +20999,7 @@ var init_SuccessStep = __esm({
21019
20999
  });
21020
21000
 
21021
21001
  // src/internal/components/SendMenu/hyperbridge/steps/HistoryStep.tsx
21022
- import { useQueryClient as useQueryClient23 } from "@tanstack/react-query";
21002
+ import { useQueryClient as useQueryClient24 } from "@tanstack/react-query";
21023
21003
  import dayjs7 from "dayjs";
21024
21004
  import { ArrowRightIcon, DownloadIcon as DownloadIcon2, ExternalLinkIcon as ExternalLinkIcon3, InfoIcon as InfoIcon4, LoaderIcon as LoaderIcon10 } from "lucide-react";
21025
21005
  import { jsx as jsx97, jsxs as jsxs89 } from "react/jsx-runtime";
@@ -21140,7 +21120,7 @@ function HistoryItem(props) {
21140
21120
  txStatus
21141
21121
  } = props;
21142
21122
  const { t } = useT();
21143
- const qc = useQueryClient23();
21123
+ const qc = useQueryClient24();
21144
21124
  const address = useSession((st) => st.address);
21145
21125
  const warpRoutes = qc.getQueryData([HYPERLANE_WARP_ROUTES_QUERY_KEY, address]);
21146
21126
  const assetWarpRoute = warpRoutes?.find((route) => {
@@ -21490,6 +21470,7 @@ function BridgeHistorySwitch(props) {
21490
21470
  onChange: () => {
21491
21471
  const { bridgeStep: bridgeStep2, setBridgeStep } = useBridgeStore.getState();
21492
21472
  if (bridgeStep2 !== "tx-history") lastBridgeStepRef.current = bridgeStep2;
21473
+ useFlowSelectorStore.getState().setError(null);
21493
21474
  setBridgeStep(bridgeStep2 === "tx-history" ? lastBridgeStepRef.current || "select" : "tx-history");
21494
21475
  }
21495
21476
  }
@@ -21652,7 +21633,7 @@ var init_useNicknameResolve = __esm({
21652
21633
  });
21653
21634
 
21654
21635
  // src/hooks/useSendTransaction.ts
21655
- import { useCallback as useCallback27, useState as useState29 } from "react";
21636
+ import { useCallback as useCallback28, useState as useState29 } from "react";
21656
21637
  import { encodeFunctionData as encodeFunctionData2, isAddress, parseEther as parseEther2, parseUnits } from "viem";
21657
21638
  function useSendTransaction() {
21658
21639
  const session = useSession((st) => st.session);
@@ -21660,7 +21641,7 @@ function useSendTransaction() {
21660
21641
  const [isLoading, setIsLoading] = useState29(false);
21661
21642
  const [error, setError] = useState29(null);
21662
21643
  const [userOpHash, setUserOpHash] = useState29(null);
21663
- const sendTransaction = useCallback27(
21644
+ const sendTransaction = useCallback28(
21664
21645
  async (params) => {
21665
21646
  if (!session || !address) {
21666
21647
  setError("No active session");
@@ -21757,7 +21738,7 @@ function useSendTransaction() {
21757
21738
  },
21758
21739
  [session, address]
21759
21740
  );
21760
- const reset = useCallback27(() => {
21741
+ const reset = useCallback28(() => {
21761
21742
  setError(null);
21762
21743
  setUserOpHash(null);
21763
21744
  setIsLoading(false);
@@ -23144,7 +23125,7 @@ import {
23144
23125
  BSC_TESTNET_CHAIN_ID as BSC_TESTNET_CHAIN_ID4,
23145
23126
  LUMIA_MAINNET_CHAIN_ID as LUMIA_MAINNET_CHAIN_ID4,
23146
23127
  LUMIA_TESTNET_CHAIN_ID as LUMIA_TESTNET_CHAIN_ID4,
23147
- SEPOLIA_CHAIN_ID as SEPOLIA_CHAIN_ID2
23128
+ SEPOLIA_CHAIN_ID
23148
23129
  } from "@embarkai/core/read";
23149
23130
  function isTransactionHistorySupported(chainId) {
23150
23131
  return !UNSUPPORTED_HISTORY_CHAINS.has(chainId);
@@ -23214,7 +23195,7 @@ var init_txUrls = __esm({
23214
23195
  };
23215
23196
  CHAIN_SPECIFIC_API_URLS = {};
23216
23197
  ETHERSCAN_CHAINS = /* @__PURE__ */ new Set([
23217
- SEPOLIA_CHAIN_ID2,
23198
+ SEPOLIA_CHAIN_ID,
23218
23199
  ARBITRUM_SEPOLIA_CHAIN_ID2,
23219
23200
  BASE_SEPOLIA_CHAIN_ID2
23220
23201
  ]);
@@ -24020,12 +24001,12 @@ var init_TransactionsGroup = __esm({
24020
24001
  });
24021
24002
 
24022
24003
  // src/internal/components/TransactionsMenu/TransactionsMenu.tsx
24023
- import { useQuery as useQuery23, useQueryClient as useQueryClient24 } from "@tanstack/react-query";
24004
+ import { useQuery as useQuery23, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
24024
24005
  import { ArrowLeft as ArrowLeft22, Loader as Loader32, RefreshCw as RefreshCw3, XCircle } from "lucide-react";
24025
- import { useCallback as useCallback28, useState as useState31 } from "react";
24006
+ import { useCallback as useCallback29, useState as useState31 } from "react";
24026
24007
  import { jsx as jsx114, jsxs as jsxs104 } from "react/jsx-runtime";
24027
24008
  function TransactionsMenu() {
24028
- const qc = useQueryClient24();
24009
+ const qc = useQueryClient25();
24029
24010
  const address = useSession((st) => st.address);
24030
24011
  const chainConfig = useSession((st) => st.chainConfig);
24031
24012
  const { t } = useT();
@@ -24044,7 +24025,7 @@ function TransactionsMenu() {
24044
24025
  queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address],
24045
24026
  queryFn: () => getTransactionsListQuery({ address, chainConfig })
24046
24027
  });
24047
- const refreshTxHistory = useCallback28(
24028
+ const refreshTxHistory = useCallback29(
24048
24029
  () => qc.invalidateQueries({ queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address] }),
24049
24030
  [qc, chainConfig.id, address]
24050
24031
  );
@@ -24283,7 +24264,7 @@ var init_PageMap = __esm({
24283
24264
  });
24284
24265
 
24285
24266
  // src/internal/hooks/usePageMapper.tsx
24286
- import { useCallback as useCallback29, useEffect as useEffect45 } from "react";
24267
+ import { useCallback as useCallback30, useEffect as useEffect45 } from "react";
24287
24268
  import { jsx as jsx115 } from "react/jsx-runtime";
24288
24269
  function usePageMapper() {
24289
24270
  const page = useLayoutDataStore((st) => st.page);
@@ -24295,7 +24276,7 @@ function usePageMapper() {
24295
24276
  setIsDialogOpen,
24296
24277
  setIsDialogClosing
24297
24278
  } = useLayoutStore();
24298
- const closeDialog = useCallback29(() => {
24279
+ const closeDialog = useCallback30(() => {
24299
24280
  setIsDialogClosing(true);
24300
24281
  setTimeout(() => {
24301
24282
  setDialogContent(null);
@@ -24306,7 +24287,7 @@ function usePageMapper() {
24306
24287
  setIsDialogOpen(false);
24307
24288
  }, CLEAR_DIALOG_TIMEOUT);
24308
24289
  }, [setDialogContent, setDialogDescription, setDialogTitle, setIsDialogForced, setIsDialogOpen, setIsDialogClosing]);
24309
- const openDialog = useCallback29(
24290
+ const openDialog = useCallback30(
24310
24291
  (pageItem) => {
24311
24292
  const PageContentComponent = pageItem.component;
24312
24293
  setDialogTitle(pageItem.title);
@@ -24392,7 +24373,7 @@ var init_package = __esm({
24392
24373
  "package.json"() {
24393
24374
  package_default = {
24394
24375
  name: "@embarkai/ui-kit",
24395
- version: "0.4.45",
24376
+ version: "0.4.47",
24396
24377
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
24397
24378
  type: "module",
24398
24379
  main: "./dist/index.cjs",
@@ -24490,21 +24471,34 @@ var init_package = __esm({
24490
24471
  });
24491
24472
 
24492
24473
  // src/internal/components/Footer/Footer.tsx
24493
- import { useMutation as useMutation20, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
24474
+ import { useMutation as useMutation20, useQueryClient as useQueryClient26 } from "@tanstack/react-query";
24494
24475
  import { Loader as Loader33, LogOut } from "lucide-react";
24476
+ import { useDisconnect as useDisconnect2 } from "wagmi";
24495
24477
  import { jsx as jsx116, jsxs as jsxs105 } from "react/jsx-runtime";
24496
24478
  function Footer() {
24497
- const qc = useQueryClient25();
24479
+ const qc = useQueryClient26();
24498
24480
  const { callbacksRef } = useProviderConfig();
24499
- const { address, setSession, setAddress, setStatus, setError, setIsLoading } = useSession();
24500
- const chainConfig = useSession((st) => st.chainConfig);
24501
24481
  const { t } = useT();
24502
- const setPage = useLayoutDataStore((st) => st.setPage);
24503
- const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
24482
+ const address = useSession((st) => st.address);
24483
+ const chainConfig = useSession((st) => st.chainConfig);
24484
+ const directWalletAddress = useExternalWalletStore((st) => st.externalAddress);
24485
+ const { disconnect: wagmiDisconnect } = useDisconnect2({
24486
+ mutation: {
24487
+ onSuccess: () => {
24488
+ useExternalWalletStore.getState().clearExternalWallet();
24489
+ useExternalWalletStore.getState().setExternalChainId(null);
24490
+ console.log("[ExternalWalletStore] Disconnected from external wallet");
24491
+ },
24492
+ onError: (err) => {
24493
+ console.error("[ExternalWalletStore] Error disconnecting from external wallet:", err);
24494
+ }
24495
+ }
24496
+ });
24504
24497
  const { mutate: disconnect, isPending: isDisconnecting } = useMutation20({
24505
24498
  mutationFn: async (disconnectAddress) => {
24506
24499
  if (!disconnectAddress) throw new Error("No address to disconnect");
24507
- setIsDialogForced(true);
24500
+ const { setError, setStatus, setIsLoading } = useSession.getState();
24501
+ useLayoutStore.getState().setIsDialogForced(true);
24508
24502
  setError(null);
24509
24503
  setStatus("disconnecting");
24510
24504
  setIsLoading(true);
@@ -24515,6 +24509,8 @@ function Footer() {
24515
24509
  },
24516
24510
  onSuccess: async ({ disconnectAddress, disconnectedUserId }) => {
24517
24511
  await qc.resetQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY] });
24512
+ if (!!directWalletAddress) wagmiDisconnect();
24513
+ const { setError, setStatus, setIsLoading, setSession, setAddress } = useSession.getState();
24518
24514
  setSession(null);
24519
24515
  setAddress(null);
24520
24516
  setError(null);
@@ -24522,15 +24518,16 @@ function Footer() {
24522
24518
  setIsLoading(false);
24523
24519
  callbacksRef.current?.onDisconnect?.({ address: disconnectAddress, userId: disconnectedUserId });
24524
24520
  setTimeout(() => {
24525
- setPage("auth" /* AUTH */);
24526
- setIsDialogForced(false);
24521
+ useLayoutDataStore.getState().setPage("auth" /* AUTH */);
24522
+ useLayoutStore.getState().setIsDialogForced(false);
24527
24523
  }, 200);
24528
24524
  },
24529
24525
  onError: (err) => {
24526
+ const { setError, setStatus, setIsLoading } = useSession.getState();
24530
24527
  setError(err.message || "An unknown error occurred during sign out");
24531
24528
  setStatus("idle");
24532
24529
  setIsLoading(false);
24533
- setIsDialogForced(false);
24530
+ useLayoutStore.getState().setIsDialogForced(false);
24534
24531
  }
24535
24532
  });
24536
24533
  const ChainIcon = NETWORK_OPTIONS.find((net) => net.chainId === chainConfig.id)?.Icon || (() => /* @__PURE__ */ jsx116("div", { className: "flex-none w-4 h-4 rounded-full flex items-center justify-center bg-[var(--ui-kit-primary)]", children: /* @__PURE__ */ jsx116("span", { className: "text-[var(--ui-kit-fg-inverted)] text-xs font-bold", children: chainConfig.name.charAt(0) }) }));
@@ -24586,7 +24583,7 @@ function Footer() {
24586
24583
  var init_Footer = __esm({
24587
24584
  "src/internal/components/Footer/Footer.tsx"() {
24588
24585
  init_package();
24589
- init_networks3();
24586
+ init_networks4();
24590
24587
  init_ProviderContext();
24591
24588
  init_SessionContext();
24592
24589
  init_i18n();
@@ -24595,6 +24592,7 @@ var init_Footer = __esm({
24595
24592
  init_useLayoutDataStore();
24596
24593
  init_useLayoutStore();
24597
24594
  init_utils2();
24595
+ init_useExternalWalletStore();
24598
24596
  init_constants4();
24599
24597
  init_button();
24600
24598
  }
@@ -24610,7 +24608,7 @@ var init_Footer2 = __esm({
24610
24608
  // src/internal/components/Header/Header.tsx
24611
24609
  import { useQuery as useQuery25 } from "@tanstack/react-query";
24612
24610
  import { Copy as Copy5, Loader as Loader34 } from "lucide-react";
24613
- import { useCallback as useCallback30, useRef as useRef20, useState as useState32 } from "react";
24611
+ import { useCallback as useCallback31, useRef as useRef20, useState as useState32 } from "react";
24614
24612
  import { Fragment as Fragment44, jsx as jsx117, jsxs as jsxs106 } from "react/jsx-runtime";
24615
24613
  function formatAddress2(addr) {
24616
24614
  if (!addr) return "";
@@ -24626,7 +24624,7 @@ function Header() {
24626
24624
  const [copied, setCopied] = useState32(false);
24627
24625
  const clickCountRef = useRef20(0);
24628
24626
  const clickTimerRef = useRef20(null);
24629
- const handleAvatarClick = useCallback30(() => {
24627
+ const handleAvatarClick = useCallback31(() => {
24630
24628
  clickCountRef.current += 1;
24631
24629
  if (clickTimerRef.current) {
24632
24630
  clearTimeout(clickTimerRef.current);
@@ -24729,7 +24727,7 @@ function Header() {
24729
24727
  var init_Header = __esm({
24730
24728
  "src/internal/components/Header/Header.tsx"() {
24731
24729
  init_LumiaIcon3();
24732
- init_networks3();
24730
+ init_networks4();
24733
24731
  init_ProviderContext();
24734
24732
  init_SessionContext();
24735
24733
  init_useT();
@@ -25006,7 +25004,7 @@ var init_Dialog2 = __esm({
25006
25004
  });
25007
25005
 
25008
25006
  // src/internal/components/TssManager.tsx
25009
- import React8, { useCallback as useCallback31 } from "react";
25007
+ import React8, { useCallback as useCallback32 } from "react";
25010
25008
  var TssManagerWithRef;
25011
25009
  var init_TssManager = __esm({
25012
25010
  "src/internal/components/TssManager.tsx"() {
@@ -25021,7 +25019,7 @@ var init_TssManager = __esm({
25021
25019
  const setStatus = useSession((st) => st.setStatus);
25022
25020
  const setSession = useSession((st) => st.setSession);
25023
25021
  const setAddress = useSession((st) => st.setAddress);
25024
- const onSessionCreated = useCallback31(
25022
+ const onSessionCreated = useCallback32(
25025
25023
  (session, address) => {
25026
25024
  setSession(session);
25027
25025
  setAddress(address);
@@ -25061,16 +25059,16 @@ var init_TssManager = __esm({
25061
25059
 
25062
25060
  // src/internal/components/WalletConnectHandler.tsx
25063
25061
  import { useConnectModal as useConnectModal2 } from "@rainbow-me/rainbowkit";
25064
- import { useMutation as useMutation21, useQueryClient as useQueryClient26 } from "@tanstack/react-query";
25065
- import React9, { useCallback as useCallback32, useEffect as useEffect48 } from "react";
25066
- import { useAccount, useDisconnect as useDisconnect2, useSignMessage as useSignMessage2 } from "wagmi";
25062
+ import { useMutation as useMutation21, useQueryClient as useQueryClient27 } from "@tanstack/react-query";
25063
+ import React9, { useCallback as useCallback33, useEffect as useEffect48 } from "react";
25064
+ import { useAccount, useDisconnect as useDisconnect3, useSignMessage as useSignMessage2 } from "wagmi";
25067
25065
  function WalletConnectHandler() {
25068
- const qc = useQueryClient26();
25066
+ const qc = useQueryClient27();
25069
25067
  const { callbacksRef } = useProviderConfig();
25070
25068
  const passportWalletAddress = useSession((st) => st.address);
25071
25069
  const { address: walletAddress, isConnected, chain, connector } = useAccount();
25072
25070
  const { openConnectModal, connectModalOpen } = useConnectModal2();
25073
- const { disconnect } = useDisconnect2();
25071
+ const { disconnect } = useDisconnect3();
25074
25072
  const { signMessageAsync } = useSignMessage2();
25075
25073
  const isWalletLinking = useLayoutDataStore((st) => st.isWalletLinking);
25076
25074
  const setPage = useLayoutDataStore((st) => st.setPage);
@@ -25085,7 +25083,7 @@ function WalletConnectHandler() {
25085
25083
  const projectId = providerConfig?.projectId;
25086
25084
  const setExternalWallet = useExternalWalletStore((st) => st.setExternalWallet);
25087
25085
  const setPendingWalletLogin = useLayoutDataStore((st) => st.setPendingWalletLogin);
25088
- const onLinkingComplete = useCallback32(
25086
+ const onLinkingComplete = useCallback33(
25089
25087
  async (success) => {
25090
25088
  setIsWalletLinking(false);
25091
25089
  if (!success && !passportWalletAddress) {
@@ -28204,7 +28202,7 @@ import { initSdkErrorTracking } from "@embarkai/core/internal/error-tracking";
28204
28202
  import { merge as merge3 } from "lodash-es";
28205
28203
  import {
28206
28204
  createContext,
28207
- useCallback as useCallback33,
28205
+ useCallback as useCallback34,
28208
28206
  useContext,
28209
28207
  useEffect as useEffect50,
28210
28208
  useMemo as useMemo16,
@@ -28231,7 +28229,7 @@ function Provider(props) {
28231
28229
  const callbacksRef = useRef21(callbacks);
28232
28230
  useEffect50(() => notifyNoProjetctId(projectId), [projectId]);
28233
28231
  const config = useRef21(merge3({}, DEFAULT_PROVIDER_CONFIG, { projectId }, initialConfig));
28234
- const updateConfig = useCallback33((updates) => {
28232
+ const updateConfig = useCallback34((updates) => {
28235
28233
  const prev = config.current;
28236
28234
  const next = { ...prev };
28237
28235
  if (updates.projectId !== void 0) next.projectId = updates.projectId;
@@ -28265,7 +28263,7 @@ function Provider(props) {
28265
28263
  if (updates.translations) next.translations = { ...next.translations, ...updates.translations };
28266
28264
  config.current = next;
28267
28265
  }, []);
28268
- const updateCallbacks = useCallback33((updates) => {
28266
+ const updateCallbacks = useCallback34((updates) => {
28269
28267
  const prev = callbacksRef.current;
28270
28268
  const next = updates ? { ...prev, ...updates } : void 0;
28271
28269
  callbacksRef.current = next;
@@ -28687,13 +28685,13 @@ var useHydrated = () => useSession((st) => st.hasHydrated);
28687
28685
  // src/hooks/useOpenPage.ts
28688
28686
  init_SessionContext();
28689
28687
  init_useLayoutDataStore();
28690
- import { useCallback as useCallback34 } from "react";
28688
+ import { useCallback as useCallback35 } from "react";
28691
28689
  function useOpenPage() {
28692
28690
  const page = useLayoutDataStore((st) => st.page);
28693
28691
  const setPage = useLayoutDataStore((st) => st.setPage);
28694
28692
  const setPageParams = useLayoutDataStore((st) => st.setPageParams);
28695
28693
  const address = useSession((st) => st.address);
28696
- const open = useCallback34(
28694
+ const open = useCallback35(
28697
28695
  (passportPage, params) => {
28698
28696
  if (!address) return setPage("auth" /* AUTH */);
28699
28697
  if (!!address && passportPage === "auth" /* AUTH */) return setPage("manage-wallet" /* MANAGE_WALLET */);
@@ -28702,7 +28700,7 @@ function useOpenPage() {
28702
28700
  },
28703
28701
  [setPage, setPageParams, address]
28704
28702
  );
28705
- const close = useCallback34(() => setPage(null), [setPage]);
28703
+ const close = useCallback35(() => setPage(null), [setPage]);
28706
28704
  return { open, close, isOpen: page !== null };
28707
28705
  }
28708
28706
 
@@ -29462,12 +29460,12 @@ init_useErc3643Compliance();
29462
29460
 
29463
29461
  // src/hooks/useWalletMode.ts
29464
29462
  init_useExternalWalletStore();
29465
- import { useCallback as useCallback37 } from "react";
29463
+ import { useCallback as useCallback38 } from "react";
29466
29464
  function useWalletMode() {
29467
29465
  const configMode = useExternalWalletStore((st) => st.configMode);
29468
29466
  const activeMode = useExternalWalletStore((st) => st.activeMode);
29469
29467
  const setActiveMode = useExternalWalletStore((st) => st.setActiveMode);
29470
- const switchMode = useCallback37(
29468
+ const switchMode = useCallback38(
29471
29469
  (mode) => {
29472
29470
  if (configMode !== "both") return;
29473
29471
  setActiveMode(mode);
@@ -29485,25 +29483,25 @@ function useWalletMode() {
29485
29483
  // src/hooks/useDirectWallet.ts
29486
29484
  init_useExternalWalletStore();
29487
29485
  init_useLayoutDataStore();
29488
- import { useCallback as useCallback38 } from "react";
29486
+ import { useCallback as useCallback39 } from "react";
29489
29487
  import { useConnectModal as useConnectModal3 } from "@rainbow-me/rainbowkit";
29490
- import { useDisconnect as useDisconnect3 } from "wagmi";
29488
+ import { useDisconnect as useDisconnect4 } from "wagmi";
29491
29489
  function useDirectWallet() {
29492
29490
  const address = useExternalWalletStore((st) => st.externalAddress);
29493
29491
  const chainId = useExternalWalletStore((st) => st.externalChainId);
29494
29492
  const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
29495
29493
  const connectorName = useExternalWalletStore((st) => st.connectorName);
29496
29494
  const clearExternalWallet = useExternalWalletStore((st) => st.clearExternalWallet);
29497
- const { disconnect: wagmiDisconnect } = useDisconnect3();
29495
+ const { disconnect: wagmiDisconnect } = useDisconnect4();
29498
29496
  const { openConnectModal } = useConnectModal3();
29499
29497
  const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
29500
- const connect = useCallback38(() => {
29498
+ const connect = useCallback39(() => {
29501
29499
  setIsWalletLinking(true);
29502
29500
  }, [setIsWalletLinking]);
29503
- const reconnect = useCallback38(() => {
29501
+ const reconnect = useCallback39(() => {
29504
29502
  if (openConnectModal) openConnectModal();
29505
29503
  }, [openConnectModal]);
29506
- const disconnect = useCallback38(() => {
29504
+ const disconnect = useCallback39(() => {
29507
29505
  wagmiDisconnect();
29508
29506
  clearExternalWallet();
29509
29507
  }, [wagmiDisconnect, clearExternalWallet]);
@@ -29520,7 +29518,7 @@ function useDirectWallet() {
29520
29518
 
29521
29519
  // src/hooks/useSendDirectTransaction.ts
29522
29520
  init_useExternalWalletStore();
29523
- import { useCallback as useCallback39, useState as useState38 } from "react";
29521
+ import { useCallback as useCallback40, useState as useState38 } from "react";
29524
29522
  import { isAddress as isAddress3, parseEther as parseEther3 } from "viem";
29525
29523
  import { useSendTransaction as useWagmiSendTransaction, useSwitchChain as useSwitchChain3 } from "wagmi";
29526
29524
  function useSendDirectTransaction() {
@@ -29531,7 +29529,7 @@ function useSendDirectTransaction() {
29531
29529
  const [isPending, setIsPending] = useState38(false);
29532
29530
  const [error, setError] = useState38(null);
29533
29531
  const [txHash, setTxHash] = useState38(null);
29534
- const sendTransaction = useCallback39(
29532
+ const sendTransaction = useCallback40(
29535
29533
  async (params) => {
29536
29534
  if (!isConnected) {
29537
29535
  setError("No external wallet connected");
@@ -29565,7 +29563,7 @@ function useSendDirectTransaction() {
29565
29563
  },
29566
29564
  [isConnected, externalChainId, sendTransactionAsync, switchChainAsync]
29567
29565
  );
29568
- const reset = useCallback39(() => {
29566
+ const reset = useCallback40(() => {
29569
29567
  setError(null);
29570
29568
  setTxHash(null);
29571
29569
  setIsPending(false);
@@ -29577,7 +29575,7 @@ function useSendDirectTransaction() {
29577
29575
  init_SessionContext();
29578
29576
  init_account2();
29579
29577
  init_linkedProfiles();
29580
- import { useCallback as useCallback40, useMemo as useMemo18, useState as useState39 } from "react";
29578
+ import { useCallback as useCallback41, useMemo as useMemo18, useState as useState39 } from "react";
29581
29579
  import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress4, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
29582
29580
  var ERC20_TRANSFER_ABI2 = [
29583
29581
  {
@@ -29600,7 +29598,7 @@ function useTransferToLinkedWallet() {
29600
29598
  () => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
29601
29599
  [profiles]
29602
29600
  );
29603
- const transfer = useCallback40(
29601
+ const transfer = useCallback41(
29604
29602
  async (params) => {
29605
29603
  if (!session) {
29606
29604
  setError("No active session");
@@ -29651,7 +29649,7 @@ function useTransferToLinkedWallet() {
29651
29649
  },
29652
29650
  [session, linkedWallets]
29653
29651
  );
29654
- const reset = useCallback40(() => {
29652
+ const reset = useCallback41(() => {
29655
29653
  setError(null);
29656
29654
  setUserOpHash(null);
29657
29655
  setIsPending(false);
@@ -29676,12 +29674,27 @@ function useNativeWalletSignature() {
29676
29674
  // src/hooks/useLogout.ts
29677
29675
  init_ProviderContext();
29678
29676
  init_SessionContext();
29677
+ init_useExternalWalletStore();
29679
29678
  import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
29680
- import { useCallback as useCallback41 } from "react";
29679
+ import { useCallback as useCallback42 } from "react";
29680
+ import { useDisconnect as useDisconnect5 } from "wagmi";
29681
29681
  function useLogout() {
29682
- const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
29683
29682
  const { callbacksRef } = useProviderConfig();
29684
- const logout2 = useCallback41(async () => {
29683
+ const address = useSession((st) => st.address);
29684
+ const { disconnect: wagmiDisconnect } = useDisconnect5({
29685
+ mutation: {
29686
+ onSuccess: () => {
29687
+ useExternalWalletStore.getState().clearExternalWallet();
29688
+ useExternalWalletStore.getState().setExternalChainId(null);
29689
+ console.log("[ExternalWalletStore] Disconnected from external wallet");
29690
+ },
29691
+ onError: (err) => {
29692
+ console.error("[ExternalWalletStore] Error disconnecting from external wallet:", err);
29693
+ }
29694
+ }
29695
+ });
29696
+ const logout2 = useCallback42(async () => {
29697
+ const { setSession, setIsLoading, setAddress, setStatus, setError } = useSession.getState();
29685
29698
  const prevAddress = address;
29686
29699
  let userId = null;
29687
29700
  setIsLoading(true);
@@ -29695,6 +29708,7 @@ function useLogout() {
29695
29708
  } catch (error) {
29696
29709
  console.warn("[useLogout] Core logout failed:", error);
29697
29710
  }
29711
+ if (!!useExternalWalletStore.getState().externalAddress) wagmiDisconnect();
29698
29712
  setSession(null);
29699
29713
  setAddress(null);
29700
29714
  setStatus("idle");
@@ -29708,7 +29722,7 @@ function useLogout() {
29708
29722
  } catch (error) {
29709
29723
  console.warn("[useLogout] Callback error:", error);
29710
29724
  }
29711
- }, [address, setAddress, setError, setSession, setStatus]);
29725
+ }, [address]);
29712
29726
  return { logout: logout2 };
29713
29727
  }
29714
29728