@embarkai/ui-kit 0.4.36 → 0.4.38

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
@@ -15691,38 +15691,33 @@ var init_MainMenu2 = __esm({
15691
15691
  // src/modules/linkedProfiles.ts
15692
15692
  import { useQuery as useQuery11, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
15693
15693
  import { useCallback as useCallback16 } from "react";
15694
- async function getLinkProfilesData() {
15695
- const list = await getLinkedProviders();
15696
- const loadedProfiles = list.map((p) => {
15697
- const info = getProviderDisplayInfo(p.provider);
15698
- return { ...p, displayName: info.name, icon: info.icon };
15699
- });
15700
- let avatar = null;
15701
- try {
15702
- avatar = jwtTokenManager2.getAvatar() || null;
15703
- } catch {
15704
- avatar = null;
15705
- }
15706
- return { profiles: loadedProfiles, avatar };
15707
- }
15708
15694
  function useLinkedProfiles() {
15709
15695
  const qc = useQueryClient11();
15710
15696
  const address = useSession((st) => st.address);
15711
- const {
15712
- data,
15713
- isFetching: isLoading,
15714
- error
15715
- } = useQuery11({
15697
+ const { data, isFetching, isLoading, error } = useQuery11({
15716
15698
  retry: false,
15717
15699
  enabled: !!address,
15718
15700
  queryKey: [LINKED_PROFILES_QUERY_KEY, address],
15719
- queryFn: getLinkProfilesData
15701
+ queryFn: async () => {
15702
+ const list = await getLinkedProviders();
15703
+ const loadedProfiles = list.map((p) => {
15704
+ const info = getProviderDisplayInfo(p.provider);
15705
+ return { ...p, displayName: info.name, icon: info.icon };
15706
+ });
15707
+ let avatar2 = null;
15708
+ try {
15709
+ avatar2 = jwtTokenManager2.getAvatar() || null;
15710
+ } catch {
15711
+ avatar2 = null;
15712
+ }
15713
+ return { profiles: loadedProfiles, avatar: avatar2 };
15714
+ }
15720
15715
  });
15721
15716
  const { profiles = [], avatar = null } = data || {};
15722
15717
  const refresh = useCallback16(async () => {
15723
15718
  await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
15724
15719
  }, [qc, address]);
15725
- return { profiles, avatar, isLoading, error, refresh };
15720
+ return { profiles, avatar, isLoading, isFetching, error, refresh };
15726
15721
  }
15727
15722
  var LINKED_PROFILES_QUERY_KEY;
15728
15723
  var init_linkedProfiles = __esm({
@@ -16732,15 +16727,49 @@ var init_ManageWallet = __esm({
16732
16727
  }
16733
16728
  });
16734
16729
 
16730
+ // src/internal/stores/useExternalWalletStore.ts
16731
+ import { create as create8 } from "zustand";
16732
+ var useExternalWalletStore;
16733
+ var init_useExternalWalletStore = __esm({
16734
+ "src/internal/stores/useExternalWalletStore.ts"() {
16735
+ useExternalWalletStore = create8((set) => ({
16736
+ configMode: "linked",
16737
+ activeMode: "linked",
16738
+ externalAddress: null,
16739
+ externalChainId: null,
16740
+ isExternalConnected: false,
16741
+ connectorName: null,
16742
+ setConfigMode: (mode) => set({ configMode: mode }),
16743
+ setActiveMode: (mode) => set({ activeMode: mode }),
16744
+ setExternalWallet: ({ address, chainId, connectorName }) => set({
16745
+ externalAddress: address,
16746
+ externalChainId: chainId,
16747
+ isExternalConnected: true,
16748
+ connectorName
16749
+ }),
16750
+ clearExternalWallet: () => set({
16751
+ externalAddress: null,
16752
+ externalChainId: null,
16753
+ isExternalConnected: false,
16754
+ connectorName: null
16755
+ }),
16756
+ setExternalChainId: (chainId) => set({ externalChainId: chainId })
16757
+ }));
16758
+ }
16759
+ });
16760
+
16735
16761
  // src/internal/components/ManageWalletMenu/UnlinkProviderMenu.tsx
16736
16762
  import { useMutation as useMutation15, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
16737
16763
  import { Key as Key6, Loader as Loader16 } from "lucide-react";
16738
16764
  import { useState as useState17 } from "react";
16765
+ import { useDisconnect } from "wagmi";
16739
16766
  import { jsx as jsx74, jsxs as jsxs68 } from "react/jsx-runtime";
16740
16767
  function UnlinkProviderMenu() {
16741
16768
  const qc = useQueryClient16();
16742
16769
  const address = useSession((st) => st.address);
16743
16770
  const { callbacksRef } = useProviderConfig();
16771
+ const { disconnect: disconnectExternalWallet } = useDisconnect();
16772
+ const isExternalConnected = useExternalWalletStore((st) => st.isExternalConnected);
16744
16773
  const { t } = useT();
16745
16774
  const setPage = useLayoutDataStore((st) => st.setPage);
16746
16775
  const { confirmUnlink, setConfirmUnlink, setAlert } = useManageWalletStore();
@@ -16751,6 +16780,13 @@ function UnlinkProviderMenu() {
16751
16780
  throw new Error("No provider to unlink");
16752
16781
  }
16753
16782
  const { provider, externalId } = confirmUnlink;
16783
+ if (provider === "wallet" && isExternalConnected) {
16784
+ await new Promise((resolve) => {
16785
+ disconnectExternalWallet();
16786
+ useExternalWalletStore.getState().clearExternalWallet();
16787
+ setTimeout(() => resolve(null), 1e3);
16788
+ });
16789
+ }
16754
16790
  await unlinkProvider(provider, externalId);
16755
16791
  },
16756
16792
  onSuccess: async () => {
@@ -16827,6 +16863,7 @@ var init_UnlinkProviderMenu = __esm({
16827
16863
  init_useT();
16828
16864
  init_linkedProfiles();
16829
16865
  init_auth();
16866
+ init_useExternalWalletStore();
16830
16867
  init_button();
16831
16868
  init_input();
16832
16869
  init_useProvidersList();
@@ -18972,37 +19009,6 @@ var init_wallet = __esm({
18972
19009
  }
18973
19010
  });
18974
19011
 
18975
- // src/internal/stores/useExternalWalletStore.ts
18976
- import { create as create8 } from "zustand";
18977
- var useExternalWalletStore;
18978
- var init_useExternalWalletStore = __esm({
18979
- "src/internal/stores/useExternalWalletStore.ts"() {
18980
- useExternalWalletStore = create8((set) => ({
18981
- configMode: "linked",
18982
- activeMode: "linked",
18983
- externalAddress: null,
18984
- externalChainId: null,
18985
- isExternalConnected: false,
18986
- connectorName: null,
18987
- setConfigMode: (mode) => set({ configMode: mode }),
18988
- setActiveMode: (mode) => set({ activeMode: mode }),
18989
- setExternalWallet: ({ address, chainId, connectorName }) => set({
18990
- externalAddress: address,
18991
- externalChainId: chainId,
18992
- isExternalConnected: true,
18993
- connectorName
18994
- }),
18995
- clearExternalWallet: () => set({
18996
- externalAddress: null,
18997
- externalChainId: null,
18998
- isExternalConnected: false,
18999
- connectorName: null
19000
- }),
19001
- setExternalChainId: (chainId) => set({ externalChainId: chainId })
19002
- }));
19003
- }
19004
- });
19005
-
19006
19012
  // src/internal/components/SendMenu/useFlowSelector.ts
19007
19013
  import { create as create9 } from "zustand";
19008
19014
  import { persist as persist2 } from "zustand/middleware";
@@ -19087,7 +19093,6 @@ var init_useBridgeStore = __esm({
19087
19093
  bridgeStep: "select",
19088
19094
  bridgeType: "hyper",
19089
19095
  bridgeSender: "embarkai-wallet",
19090
- bridgeSenders: [],
19091
19096
  amount: "",
19092
19097
  quote: null,
19093
19098
  isQuoteEstimating: false,
@@ -19096,6 +19101,7 @@ var init_useBridgeStore = __esm({
19096
19101
  useBridgeStore = create10()(
19097
19102
  persist3(
19098
19103
  (set, get) => ({
19104
+ bridgeSenders: [],
19099
19105
  hyperRoute: null,
19100
19106
  recipient: null,
19101
19107
  originChain: null,
@@ -19154,7 +19160,7 @@ import { useEffect as useEffect33, useRef as useRef17, useState as useState24 }
19154
19160
  import { useSignMessage } from "wagmi";
19155
19161
  import { jsx as jsx89, jsxs as jsxs83 } from "react/jsx-runtime";
19156
19162
  function SenderSelector(props) {
19157
- const { profiles } = props;
19163
+ const { directWalletProfile } = props;
19158
19164
  const { t } = useT();
19159
19165
  const config = useProviderConfig().config;
19160
19166
  const { signMessageAsync } = useSignMessage();
@@ -19169,22 +19175,15 @@ function SenderSelector(props) {
19169
19175
  useEffect33(() => {
19170
19176
  useFlowSelectorStore.getState().setRenderKey(`sender-selected-${Date.now()}`);
19171
19177
  }, [walletMessage]);
19172
- useEffect33(() => {
19173
- const pending = pendingWalletRef.current;
19174
- if (!pending || !directWalletIsConnected || !directWalletAddress) return;
19175
- if (directWalletAddress.toLowerCase() !== pending.externalId?.toLowerCase()) return;
19176
- pendingWalletRef.current = null;
19177
- directWalletFlow(pending);
19178
- }, [directWalletIsConnected, directWalletAddress]);
19179
- const { mutate: directWalletFlow, isPending: isDirectWalletLogin } = useMutation18({
19180
- mutationFn: async (walletProfile2) => {
19181
- if (!walletProfile2?.meta?.walletName || !walletProfile2?.externalId || !walletProfile2?.meta?.walletType) {
19182
- console.error("[SENDER SELECTOR] Invalid wallet profile:", walletProfile2);
19178
+ const { mutate: loginDirectWallet, isPending: isDirectWalletLoggingIn } = useMutation18({
19179
+ mutationFn: async (walletProfile) => {
19180
+ if (!walletProfile?.meta?.walletName || !walletProfile?.externalId || !walletProfile?.meta?.walletType) {
19181
+ console.error("[SENDER SELECTOR] Invalid wallet profile:", walletProfile);
19183
19182
  setWalletMessage("Invalid wallet profile. Please try connecting your wallet again.");
19184
19183
  return;
19185
19184
  }
19186
19185
  const projectName = config.current?.projectId ? await fetchProjectName(config.current.projectId) : "EmbarkAI";
19187
- const signingWalletAddress = walletProfile2?.externalId;
19186
+ const signingWalletAddress = walletProfile?.externalId;
19188
19187
  const message = createLoginMessage(signingWalletAddress, projectName);
19189
19188
  const signature = await Promise.race([
19190
19189
  signMessageAsync({ message, account: signingWalletAddress }),
@@ -19208,19 +19207,17 @@ function SenderSelector(props) {
19208
19207
  address: signingWalletAddress,
19209
19208
  signature,
19210
19209
  message,
19211
- walletName: walletProfile2.meta.walletName,
19212
- walletType: walletProfile2.meta.walletType
19210
+ walletName: walletProfile.meta.walletName,
19211
+ walletType: walletProfile.meta.walletType
19213
19212
  };
19214
- console.log("[SENDER SELECTOR] Wallet login data prepared:", walletData);
19215
19213
  const loginData = await walletLogin(walletData);
19216
- return { fromChainId, loginData, walletProfile: walletProfile2 };
19214
+ return { fromChainId, loginData, walletProfile };
19217
19215
  },
19218
- onSuccess: ({ fromChainId, loginData, walletProfile: walletProfile2 }) => {
19219
- console.log("[SENDER SELECTOR] Wallet login successful:", loginData);
19216
+ onSuccess: ({ fromChainId, loginData, walletProfile }) => {
19220
19217
  useExternalWalletStore.getState().setExternalWallet({
19221
- address: walletProfile2?.externalId,
19218
+ address: walletProfile?.externalId,
19222
19219
  chainId: fromChainId,
19223
- connectorName: walletProfile2?.meta?.walletName || "Unknown Wallet"
19220
+ connectorName: walletProfile?.meta?.walletName || "Unknown Wallet"
19224
19221
  });
19225
19222
  setWalletMessage(null);
19226
19223
  useBridgeStore.getState().setBridgeSender("direct-wallet");
@@ -19231,7 +19228,13 @@ function SenderSelector(props) {
19231
19228
  setWalletMessage(error instanceof Error ? error.message : "Wallet login failed. Please try again.");
19232
19229
  }
19233
19230
  });
19234
- const walletProfile = profiles.filter((p) => p.provider === "wallet")[0] || null;
19231
+ useEffect33(() => {
19232
+ const pendingProfile = pendingWalletRef.current;
19233
+ if (!pendingProfile || !directWalletIsConnected || !directWalletAddress) return;
19234
+ if (directWalletAddress.toLowerCase() !== pendingProfile.externalId?.toLowerCase()) return;
19235
+ pendingWalletRef.current = null;
19236
+ loginDirectWallet(pendingProfile);
19237
+ }, [directWalletIsConnected, directWalletAddress]);
19235
19238
  return /* @__PURE__ */ jsxs83("div", { className: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: [
19236
19239
  bridgeSenders.map((sender) => /* @__PURE__ */ jsxs83(
19237
19240
  Button,
@@ -19283,14 +19286,14 @@ function SenderSelector(props) {
19283
19286
  variant: "default",
19284
19287
  size: "large",
19285
19288
  className: "w-full",
19286
- disabled: !walletProfile || isDirectWalletLogin,
19289
+ disabled: !directWalletProfile || isDirectWalletLoggingIn,
19287
19290
  onClick: () => {
19288
- const isConnectedToRightWallet = directWalletIsConnected && directWalletAddress?.toLowerCase() === walletProfile?.externalId?.toLowerCase();
19291
+ const isConnectedToRightWallet = directWalletIsConnected && directWalletAddress?.toLowerCase() === directWalletProfile?.externalId?.toLowerCase();
19289
19292
  if (isConnectedToRightWallet) {
19290
- directWalletFlow(walletProfile);
19293
+ loginDirectWallet(directWalletProfile);
19291
19294
  } else {
19292
19295
  useLayoutDataStore.getState().setPage(null);
19293
- pendingWalletRef.current = walletProfile;
19296
+ pendingWalletRef.current = directWalletProfile;
19294
19297
  openConnectModal?.();
19295
19298
  }
19296
19299
  },
@@ -19413,39 +19416,39 @@ var init_wallets = __esm({
19413
19416
  import { useEffect as useEffect34, useRef as useRef18 } from "react";
19414
19417
  function useAvailableSenders() {
19415
19418
  const address = useSession((st) => st.address);
19416
- const activeChainId = useSession((st) => st.activeChainId);
19417
19419
  const { profiles } = useLinkedProfiles();
19418
- const walletProfiles = profiles.filter((p) => p.provider === "wallet");
19419
19420
  const lastCalcedSenders = useRef18([]);
19420
19421
  useEffect34(() => {
19421
19422
  const sendersAccumulator = [
19422
19423
  {
19423
19424
  type: "embarkai-wallet",
19424
19425
  name: "embarkAI",
19425
- chainId: activeChainId,
19426
+ chainId: null,
19426
19427
  address,
19427
19428
  Icon: TOKENS_ICONS["EMBARKAI"]
19428
19429
  }
19429
19430
  ];
19430
- if (!!walletProfiles.length) {
19431
- walletProfiles.forEach((wProfile) => {
19432
- sendersAccumulator.push({
19433
- type: "direct-wallet",
19434
- name: wProfile?.meta?.walletName || "External wallet",
19435
- chainId: null,
19436
- address: wProfile?.externalId,
19437
- Icon: WALLET_ICONS[wProfile?.meta?.walletName?.toLowerCase()] || WALLET_ICONS["default"]
19438
- });
19431
+ const walletProfile = profiles.filter((p) => p.provider === "wallet")[0] || null;
19432
+ if (!!walletProfile) {
19433
+ sendersAccumulator.push({
19434
+ type: "direct-wallet",
19435
+ name: walletProfile?.meta?.walletName || "External wallet",
19436
+ chainId: null,
19437
+ address: walletProfile?.externalId,
19438
+ Icon: WALLET_ICONS[walletProfile?.meta?.walletName?.toLowerCase()] || WALLET_ICONS["default"]
19439
19439
  });
19440
19440
  }
19441
19441
  if (sendersAccumulator.map((s) => `${s.name}-${s.address}`).join(",") === lastCalcedSenders.current.join(",")) {
19442
19442
  return;
19443
19443
  }
19444
19444
  lastCalcedSenders.current = sendersAccumulator.map((s) => `${s.name}-${s.address}`);
19445
+ console.info("[SENDER SELECTOR] setting bridge senders", sendersAccumulator);
19445
19446
  useBridgeStore.getState().setBridgeSenders(sendersAccumulator);
19446
19447
  useFlowSelectorStore.getState().setRenderKey(`sender-selected-${Date.now()}`);
19447
- }, [address, walletProfiles, activeChainId]);
19448
- return { profiles: walletProfiles };
19448
+ }, [address, profiles]);
19449
+ return {
19450
+ directWalletProfile: profiles.filter((p) => p.provider === "wallet")[0] || null
19451
+ };
19449
19452
  }
19450
19453
  var init_useAvailableSenders = __esm({
19451
19454
  "src/internal/components/SendMenu/hyperbridge/hooks/useAvailableSenders.ts"() {
@@ -20104,18 +20107,16 @@ function SelectStep(props) {
20104
20107
  const { swapChains, hyperlaneWarpRoutes, isLoadingWarpRoutes, handleQuoteEstimation } = props;
20105
20108
  const { t } = useT();
20106
20109
  const {
20110
+ bridgeSenders,
20111
+ bridgeSender,
20107
20112
  originChain,
20108
20113
  destinationChain,
20109
20114
  hyperRoute,
20110
20115
  amount,
20111
- // bridgeSenders,
20112
20116
  isQuoteEstimating,
20113
- recipient,
20114
- setBridgeStep,
20115
- setAmount,
20116
- setRecipient
20117
+ recipient
20117
20118
  } = useBridgeStore();
20118
- const selectedSender = useBridgeStore((st) => st.bridgeSenders.find((s) => s.type === st.bridgeSender));
20119
+ const selectedSender = bridgeSenders?.find((s) => s.type === bridgeSender) || null;
20119
20120
  const { routeTokenBalance, isRouteTokenBalanceLoading } = useBridgeBalance(hyperlaneWarpRoutes);
20120
20121
  const selectedWarpRoute = hyperlaneWarpRoutes.find((route) => {
20121
20122
  const { routeId, chainPair } = route;
@@ -20147,7 +20148,7 @@ function SelectStep(props) {
20147
20148
  className: "w-full justify-between",
20148
20149
  onClick: () => {
20149
20150
  useFlowSelectorStore.getState().setError(null);
20150
- setBridgeStep("sender-selector");
20151
+ useBridgeStore.getState().setBridgeStep("sender-selector");
20151
20152
  },
20152
20153
  children: [
20153
20154
  /* @__PURE__ */ jsxs85("div", { className: "flex items-center gap-[var(--ui-kit-gap)]", children: [
@@ -20186,7 +20187,7 @@ function SelectStep(props) {
20186
20187
  className: "w-full justify-between",
20187
20188
  onClick: () => {
20188
20189
  useFlowSelectorStore.getState().setError(null);
20189
- setBridgeStep("select-token");
20190
+ useBridgeStore.getState().setBridgeStep("select-token");
20190
20191
  },
20191
20192
  children: [
20192
20193
  selectedWarpRoute ? /* @__PURE__ */ jsxs85("div", { className: "flex items-center gap-[var(--ui-kit-gap)]", children: [
@@ -20270,9 +20271,9 @@ function SelectStep(props) {
20270
20271
  }
20271
20272
  if (regex.test(value) || value === "") {
20272
20273
  if (value === "") {
20273
- setAmount("0");
20274
+ useBridgeStore.getState().setAmount("0");
20274
20275
  } else {
20275
- setAmount(value);
20276
+ useBridgeStore.getState().setAmount(value);
20276
20277
  }
20277
20278
  }
20278
20279
  },
@@ -20303,7 +20304,7 @@ function SelectStep(props) {
20303
20304
  Icon: Wallet2Icon2,
20304
20305
  onChange: (e) => {
20305
20306
  useFlowSelectorStore.getState().setError(null);
20306
- setRecipient(e.target.value);
20307
+ useBridgeStore.getState().setRecipient(e.target.value);
20307
20308
  },
20308
20309
  element: /* @__PURE__ */ jsx93(
20309
20310
  Button,
@@ -20313,7 +20314,7 @@ function SelectStep(props) {
20313
20314
  variant: "ghost",
20314
20315
  onClick: (e) => {
20315
20316
  e.stopPropagation();
20316
- setRecipient(null);
20317
+ useBridgeStore.getState().setRecipient(null);
20317
20318
  },
20318
20319
  children: /* @__PURE__ */ jsx93(XIcon, { className: "w-4 h-4" })
20319
20320
  }
@@ -20610,7 +20611,8 @@ var init_SuccessStep = __esm({
20610
20611
 
20611
20612
  // src/internal/components/SendMenu/hyperbridge/hooks/useHyperlaneHistory.ts
20612
20613
  import { useQuery as useQuery21 } from "@tanstack/react-query";
20613
- import { useEffect as useEffect38, useState as useState26 } from "react";
20614
+ import { debounce as debounce3 } from "lodash-es";
20615
+ import { useCallback as useCallback24, useEffect as useEffect38, useState as useState26 } from "react";
20614
20616
  function useHyperlaneHistory() {
20615
20617
  const address = useSession((st) => st.address);
20616
20618
  const page = useLayoutDataStore((st) => st.page);
@@ -20624,11 +20626,17 @@ function useHyperlaneHistory() {
20624
20626
  queryKey: [HYPERLANE_HISTORY_QUERY_KEY, address, currentPage],
20625
20627
  queryFn: async () => await getHyperlaneBridgeHistory({ page: currentPage, pageSize: TX_HISTORY_PAGE_SIZE })
20626
20628
  });
20629
+ const updateExpandable = useCallback24(
20630
+ debounce3(() => {
20631
+ useFlowSelectorStore.getState().setRenderKey(`hyperlane-history-loaded-${Date.now()}`);
20632
+ }, 500),
20633
+ []
20634
+ );
20627
20635
  useEffect38(() => {
20628
20636
  const { data, isLoading } = query;
20629
- if (isLoading || data.data.length === 0 || currentPage > 1) return;
20630
- useFlowSelectorStore.getState().setRenderKey(`hyperlane-history-loaded-${Date.now()}`);
20631
- }, [query, currentPage]);
20637
+ if (isLoading || data.data?.length === 0) return;
20638
+ updateExpandable();
20639
+ }, [query]);
20632
20640
  return {
20633
20641
  ...query,
20634
20642
  currentPage,
@@ -21035,7 +21043,7 @@ function HyperlaneBridge() {
21035
21043
  const bridgeStep = useBridgeStore((st) => st.bridgeStep);
21036
21044
  const { swapDirection, handleQuoteEstimation, bridgeAsset, isAssetBridging } = useBridge();
21037
21045
  const { hyperlaneWarpRoutes, isLoadingWarpRoutes } = useHyperlaneRoutes();
21038
- const { profiles } = useAvailableSenders();
21046
+ const { directWalletProfile } = useAvailableSenders();
21039
21047
  useMenuTitle(hyperlaneWarpRoutes);
21040
21048
  useEffect39(
21041
21049
  () => () => {
@@ -21044,7 +21052,7 @@ function HyperlaneBridge() {
21044
21052
  []
21045
21053
  );
21046
21054
  return /* @__PURE__ */ jsxs90(Fragment38, { children: [
21047
- bridgeStep === "sender-selector" && /* @__PURE__ */ jsx99(SenderSelector, { profiles }),
21055
+ bridgeStep === "sender-selector" && /* @__PURE__ */ jsx99(SenderSelector, { directWalletProfile }),
21048
21056
  bridgeStep === "select" && /* @__PURE__ */ jsx99(
21049
21057
  SelectStep,
21050
21058
  {
@@ -21266,7 +21274,7 @@ var init_useNicknameResolve = __esm({
21266
21274
  });
21267
21275
 
21268
21276
  // src/hooks/useSendTransaction.ts
21269
- import { useCallback as useCallback24, useState as useState29 } from "react";
21277
+ import { useCallback as useCallback25, useState as useState29 } from "react";
21270
21278
  import { encodeFunctionData as encodeFunctionData2, isAddress, parseEther as parseEther2, parseUnits } from "viem";
21271
21279
  function useSendTransaction() {
21272
21280
  const session = useSession((st) => st.session);
@@ -21274,7 +21282,7 @@ function useSendTransaction() {
21274
21282
  const [isLoading, setIsLoading] = useState29(false);
21275
21283
  const [error, setError] = useState29(null);
21276
21284
  const [userOpHash, setUserOpHash] = useState29(null);
21277
- const sendTransaction = useCallback24(
21285
+ const sendTransaction = useCallback25(
21278
21286
  async (params) => {
21279
21287
  if (!session || !address) {
21280
21288
  setError("No active session");
@@ -21371,7 +21379,7 @@ function useSendTransaction() {
21371
21379
  },
21372
21380
  [session, address]
21373
21381
  );
21374
- const reset = useCallback24(() => {
21382
+ const reset = useCallback25(() => {
21375
21383
  setError(null);
21376
21384
  setUserOpHash(null);
21377
21385
  setIsLoading(false);
@@ -23636,7 +23644,7 @@ var init_TransactionsGroup = __esm({
23636
23644
  // src/internal/components/TransactionsMenu/TransactionsMenu.tsx
23637
23645
  import { useQuery as useQuery24, useQueryClient as useQueryClient23 } from "@tanstack/react-query";
23638
23646
  import { ArrowLeft as ArrowLeft22, Loader as Loader33, RefreshCw as RefreshCw3, XCircle } from "lucide-react";
23639
- import { useCallback as useCallback25, useState as useState31 } from "react";
23647
+ import { useCallback as useCallback26, useState as useState31 } from "react";
23640
23648
  import { jsx as jsx114, jsxs as jsxs103 } from "react/jsx-runtime";
23641
23649
  function TransactionsMenu() {
23642
23650
  const qc = useQueryClient23();
@@ -23658,7 +23666,7 @@ function TransactionsMenu() {
23658
23666
  queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address],
23659
23667
  queryFn: () => getTransactionsListQuery({ address, chainConfig })
23660
23668
  });
23661
- const refreshTxHistory = useCallback25(
23669
+ const refreshTxHistory = useCallback26(
23662
23670
  () => qc.invalidateQueries({ queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address] }),
23663
23671
  [qc, chainConfig.id, address]
23664
23672
  );
@@ -23897,7 +23905,7 @@ var init_PageMap = __esm({
23897
23905
  });
23898
23906
 
23899
23907
  // src/internal/hooks/usePageMapper.tsx
23900
- import { useCallback as useCallback26, useEffect as useEffect44 } from "react";
23908
+ import { useCallback as useCallback27, useEffect as useEffect44 } from "react";
23901
23909
  import { jsx as jsx115 } from "react/jsx-runtime";
23902
23910
  function usePageMapper() {
23903
23911
  const page = useLayoutDataStore((st) => st.page);
@@ -23909,7 +23917,7 @@ function usePageMapper() {
23909
23917
  setIsDialogOpen,
23910
23918
  setIsDialogClosing
23911
23919
  } = useLayoutStore();
23912
- const closeDialog = useCallback26(() => {
23920
+ const closeDialog = useCallback27(() => {
23913
23921
  setIsDialogClosing(true);
23914
23922
  setTimeout(() => {
23915
23923
  setDialogContent(null);
@@ -23920,7 +23928,7 @@ function usePageMapper() {
23920
23928
  setIsDialogOpen(false);
23921
23929
  }, CLEAR_DIALOG_TIMEOUT);
23922
23930
  }, [setDialogContent, setDialogDescription, setDialogTitle, setIsDialogForced, setIsDialogOpen, setIsDialogClosing]);
23923
- const openDialog = useCallback26(
23931
+ const openDialog = useCallback27(
23924
23932
  (pageItem) => {
23925
23933
  const PageContentComponent = pageItem.component;
23926
23934
  setDialogTitle(pageItem.title);
@@ -24006,7 +24014,7 @@ var init_package = __esm({
24006
24014
  "package.json"() {
24007
24015
  package_default = {
24008
24016
  name: "@embarkai/ui-kit",
24009
- version: "0.4.36",
24017
+ version: "0.4.38",
24010
24018
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
24011
24019
  type: "module",
24012
24020
  main: "./dist/index.cjs",
@@ -24224,7 +24232,7 @@ var init_Footer2 = __esm({
24224
24232
  // src/internal/components/Header/Header.tsx
24225
24233
  import { useQuery as useQuery26 } from "@tanstack/react-query";
24226
24234
  import { Copy as Copy5, Loader as Loader35 } from "lucide-react";
24227
- import { useCallback as useCallback27, useRef as useRef20, useState as useState32 } from "react";
24235
+ import { useCallback as useCallback28, useRef as useRef20, useState as useState32 } from "react";
24228
24236
  import { Fragment as Fragment44, jsx as jsx117, jsxs as jsxs105 } from "react/jsx-runtime";
24229
24237
  function formatAddress2(addr) {
24230
24238
  if (!addr) return "";
@@ -24240,7 +24248,7 @@ function Header() {
24240
24248
  const [copied, setCopied] = useState32(false);
24241
24249
  const clickCountRef = useRef20(0);
24242
24250
  const clickTimerRef = useRef20(null);
24243
- const handleAvatarClick = useCallback27(() => {
24251
+ const handleAvatarClick = useCallback28(() => {
24244
24252
  clickCountRef.current += 1;
24245
24253
  if (clickTimerRef.current) {
24246
24254
  clearTimeout(clickTimerRef.current);
@@ -24620,7 +24628,7 @@ var init_Dialog2 = __esm({
24620
24628
  });
24621
24629
 
24622
24630
  // src/internal/components/TssManager.tsx
24623
- import React8, { useCallback as useCallback28 } from "react";
24631
+ import React8, { useCallback as useCallback29 } from "react";
24624
24632
  var TssManagerWithRef;
24625
24633
  var init_TssManager = __esm({
24626
24634
  "src/internal/components/TssManager.tsx"() {
@@ -24635,7 +24643,7 @@ var init_TssManager = __esm({
24635
24643
  const setStatus = useSession((st) => st.setStatus);
24636
24644
  const setSession = useSession((st) => st.setSession);
24637
24645
  const setAddress = useSession((st) => st.setAddress);
24638
- const onSessionCreated = useCallback28(
24646
+ const onSessionCreated = useCallback29(
24639
24647
  (session, address) => {
24640
24648
  setSession(session);
24641
24649
  setAddress(address);
@@ -24676,15 +24684,15 @@ var init_TssManager = __esm({
24676
24684
  // src/internal/components/WalletConnectHandler.tsx
24677
24685
  import { useConnectModal as useConnectModal2 } from "@rainbow-me/rainbowkit";
24678
24686
  import { useMutation as useMutation21, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
24679
- import React9, { useCallback as useCallback29, useEffect as useEffect47 } from "react";
24680
- import { useAccount, useDisconnect, useSignMessage as useSignMessage2 } from "wagmi";
24687
+ import React9, { useCallback as useCallback30, useEffect as useEffect47 } from "react";
24688
+ import { useAccount, useDisconnect as useDisconnect2, useSignMessage as useSignMessage2 } from "wagmi";
24681
24689
  function WalletConnectHandler() {
24682
24690
  const qc = useQueryClient25();
24683
24691
  const { callbacksRef } = useProviderConfig();
24684
24692
  const passportWalletAddress = useSession((st) => st.address);
24685
24693
  const { address: walletAddress, isConnected, chain, connector } = useAccount();
24686
24694
  const { openConnectModal, connectModalOpen } = useConnectModal2();
24687
- const { disconnect } = useDisconnect();
24695
+ const { disconnect } = useDisconnect2();
24688
24696
  const { signMessageAsync } = useSignMessage2();
24689
24697
  const isWalletLinking = useLayoutDataStore((st) => st.isWalletLinking);
24690
24698
  const setPage = useLayoutDataStore((st) => st.setPage);
@@ -24699,7 +24707,7 @@ function WalletConnectHandler() {
24699
24707
  const projectId = providerConfig?.projectId;
24700
24708
  const setExternalWallet = useExternalWalletStore((st) => st.setExternalWallet);
24701
24709
  const setPendingWalletLogin = useLayoutDataStore((st) => st.setPendingWalletLogin);
24702
- const onLinkingComplete = useCallback29(
24710
+ const onLinkingComplete = useCallback30(
24703
24711
  async (success) => {
24704
24712
  setIsWalletLinking(false);
24705
24713
  if (!success && !passportWalletAddress) {
@@ -27849,7 +27857,7 @@ import { initSdkErrorTracking } from "@embarkai/core/internal/error-tracking";
27849
27857
  import { merge as merge3 } from "lodash-es";
27850
27858
  import {
27851
27859
  createContext,
27852
- useCallback as useCallback30,
27860
+ useCallback as useCallback31,
27853
27861
  useContext,
27854
27862
  useEffect as useEffect49,
27855
27863
  useMemo as useMemo12,
@@ -27876,7 +27884,7 @@ function Provider(props) {
27876
27884
  const callbacksRef = useRef21(callbacks);
27877
27885
  useEffect49(() => notifyNoProjetctId(projectId), [projectId]);
27878
27886
  const config = useRef21(merge3({}, DEFAULT_PROVIDER_CONFIG, { projectId }, initialConfig));
27879
- const updateConfig = useCallback30((updates) => {
27887
+ const updateConfig = useCallback31((updates) => {
27880
27888
  const prev = config.current;
27881
27889
  const next = { ...prev };
27882
27890
  if (updates.projectId !== void 0) next.projectId = updates.projectId;
@@ -27910,7 +27918,7 @@ function Provider(props) {
27910
27918
  if (updates.translations) next.translations = { ...next.translations, ...updates.translations };
27911
27919
  config.current = next;
27912
27920
  }, []);
27913
- const updateCallbacks = useCallback30((updates) => {
27921
+ const updateCallbacks = useCallback31((updates) => {
27914
27922
  const prev = callbacksRef.current;
27915
27923
  const next = updates ? { ...prev, ...updates } : void 0;
27916
27924
  callbacksRef.current = next;
@@ -28325,13 +28333,13 @@ var useHydrated = () => useSession((st) => st.hasHydrated);
28325
28333
  // src/hooks/useOpenPage.ts
28326
28334
  init_SessionContext();
28327
28335
  init_useLayoutDataStore();
28328
- import { useCallback as useCallback31 } from "react";
28336
+ import { useCallback as useCallback32 } from "react";
28329
28337
  function useOpenPage() {
28330
28338
  const page = useLayoutDataStore((st) => st.page);
28331
28339
  const setPage = useLayoutDataStore((st) => st.setPage);
28332
28340
  const setPageParams = useLayoutDataStore((st) => st.setPageParams);
28333
28341
  const address = useSession((st) => st.address);
28334
- const open = useCallback31(
28342
+ const open = useCallback32(
28335
28343
  (passportPage, params) => {
28336
28344
  if (!address) return setPage("auth" /* AUTH */);
28337
28345
  if (!!address && passportPage === "auth" /* AUTH */) return setPage("manage-wallet" /* MANAGE_WALLET */);
@@ -28340,7 +28348,7 @@ function useOpenPage() {
28340
28348
  },
28341
28349
  [setPage, setPageParams, address]
28342
28350
  );
28343
- const close = useCallback31(() => setPage(null), [setPage]);
28351
+ const close = useCallback32(() => setPage(null), [setPage]);
28344
28352
  return { open, close, isOpen: page !== null };
28345
28353
  }
28346
28354
 
@@ -29206,12 +29214,12 @@ init_useErc3643Compliance();
29206
29214
 
29207
29215
  // src/hooks/useWalletMode.ts
29208
29216
  init_useExternalWalletStore();
29209
- import { useCallback as useCallback34 } from "react";
29217
+ import { useCallback as useCallback35 } from "react";
29210
29218
  function useWalletMode() {
29211
29219
  const configMode = useExternalWalletStore((st) => st.configMode);
29212
29220
  const activeMode = useExternalWalletStore((st) => st.activeMode);
29213
29221
  const setActiveMode = useExternalWalletStore((st) => st.setActiveMode);
29214
- const switchMode = useCallback34(
29222
+ const switchMode = useCallback35(
29215
29223
  (mode) => {
29216
29224
  if (configMode !== "both") return;
29217
29225
  setActiveMode(mode);
@@ -29229,25 +29237,25 @@ function useWalletMode() {
29229
29237
  // src/hooks/useDirectWallet.ts
29230
29238
  init_useExternalWalletStore();
29231
29239
  init_useLayoutDataStore();
29232
- import { useCallback as useCallback35 } from "react";
29240
+ import { useCallback as useCallback36 } from "react";
29233
29241
  import { useConnectModal as useConnectModal3 } from "@rainbow-me/rainbowkit";
29234
- import { useDisconnect as useDisconnect2 } from "wagmi";
29242
+ import { useDisconnect as useDisconnect3 } from "wagmi";
29235
29243
  function useDirectWallet() {
29236
29244
  const address = useExternalWalletStore((st) => st.externalAddress);
29237
29245
  const chainId = useExternalWalletStore((st) => st.externalChainId);
29238
29246
  const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
29239
29247
  const connectorName = useExternalWalletStore((st) => st.connectorName);
29240
29248
  const clearExternalWallet = useExternalWalletStore((st) => st.clearExternalWallet);
29241
- const { disconnect: wagmiDisconnect } = useDisconnect2();
29249
+ const { disconnect: wagmiDisconnect } = useDisconnect3();
29242
29250
  const { openConnectModal } = useConnectModal3();
29243
29251
  const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
29244
- const connect = useCallback35(() => {
29252
+ const connect = useCallback36(() => {
29245
29253
  setIsWalletLinking(true);
29246
29254
  }, [setIsWalletLinking]);
29247
- const reconnect = useCallback35(() => {
29255
+ const reconnect = useCallback36(() => {
29248
29256
  if (openConnectModal) openConnectModal();
29249
29257
  }, [openConnectModal]);
29250
- const disconnect = useCallback35(() => {
29258
+ const disconnect = useCallback36(() => {
29251
29259
  wagmiDisconnect();
29252
29260
  clearExternalWallet();
29253
29261
  }, [wagmiDisconnect, clearExternalWallet]);
@@ -29264,7 +29272,7 @@ function useDirectWallet() {
29264
29272
 
29265
29273
  // src/hooks/useSendDirectTransaction.ts
29266
29274
  init_useExternalWalletStore();
29267
- import { useCallback as useCallback36, useState as useState38 } from "react";
29275
+ import { useCallback as useCallback37, useState as useState38 } from "react";
29268
29276
  import { isAddress as isAddress3, parseEther as parseEther3 } from "viem";
29269
29277
  import { useSendTransaction as useWagmiSendTransaction, useSwitchChain as useSwitchChain3 } from "wagmi";
29270
29278
  function useSendDirectTransaction() {
@@ -29275,7 +29283,7 @@ function useSendDirectTransaction() {
29275
29283
  const [isPending, setIsPending] = useState38(false);
29276
29284
  const [error, setError] = useState38(null);
29277
29285
  const [txHash, setTxHash] = useState38(null);
29278
- const sendTransaction = useCallback36(
29286
+ const sendTransaction = useCallback37(
29279
29287
  async (params) => {
29280
29288
  if (!isConnected) {
29281
29289
  setError("No external wallet connected");
@@ -29309,7 +29317,7 @@ function useSendDirectTransaction() {
29309
29317
  },
29310
29318
  [isConnected, externalChainId, sendTransactionAsync, switchChainAsync]
29311
29319
  );
29312
- const reset = useCallback36(() => {
29320
+ const reset = useCallback37(() => {
29313
29321
  setError(null);
29314
29322
  setTxHash(null);
29315
29323
  setIsPending(false);
@@ -29321,7 +29329,7 @@ function useSendDirectTransaction() {
29321
29329
  init_SessionContext();
29322
29330
  init_account2();
29323
29331
  init_linkedProfiles();
29324
- import { useCallback as useCallback37, useMemo as useMemo14, useState as useState39 } from "react";
29332
+ import { useCallback as useCallback38, useMemo as useMemo14, useState as useState39 } from "react";
29325
29333
  import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress4, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
29326
29334
  var ERC20_TRANSFER_ABI2 = [
29327
29335
  {
@@ -29344,7 +29352,7 @@ function useTransferToLinkedWallet() {
29344
29352
  () => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
29345
29353
  [profiles]
29346
29354
  );
29347
- const transfer = useCallback37(
29355
+ const transfer = useCallback38(
29348
29356
  async (params) => {
29349
29357
  if (!session) {
29350
29358
  setError("No active session");
@@ -29395,7 +29403,7 @@ function useTransferToLinkedWallet() {
29395
29403
  },
29396
29404
  [session, linkedWallets]
29397
29405
  );
29398
- const reset = useCallback37(() => {
29406
+ const reset = useCallback38(() => {
29399
29407
  setError(null);
29400
29408
  setUserOpHash(null);
29401
29409
  setIsPending(false);
@@ -29421,11 +29429,11 @@ function useNativeWalletSignature() {
29421
29429
  init_ProviderContext();
29422
29430
  init_SessionContext();
29423
29431
  import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
29424
- import { useCallback as useCallback38 } from "react";
29432
+ import { useCallback as useCallback39 } from "react";
29425
29433
  function useLogout() {
29426
29434
  const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
29427
29435
  const { callbacksRef } = useProviderConfig();
29428
- const logout2 = useCallback38(async () => {
29436
+ const logout2 = useCallback39(async () => {
29429
29437
  const prevAddress = address;
29430
29438
  let userId = null;
29431
29439
  setIsLoading(true);