@embarkai/ui-kit 0.4.103 → 0.4.104

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.
@@ -15,7 +15,7 @@
15
15
  <meta http-equiv="X-Content-Type-Options" content="nosniff" />
16
16
  <meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
17
17
 
18
- <title>EmbarkAI Secure Wallet - iframe version 0.4.103</title>
18
+ <title>EmbarkAI Secure Wallet - iframe version 0.4.104</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -6342,7 +6342,7 @@ var SigningManager = class extends TokenRefreshApiClient {
6342
6342
  };
6343
6343
 
6344
6344
  // src/iframe/main.ts
6345
- var IFRAME_VERSION = "0.4.103";
6345
+ var IFRAME_VERSION = "0.4.104";
6346
6346
  var IframeWallet = class {
6347
6347
  // private finchpay: FinchPayRampAPI
6348
6348
  // private rampnow: RampnowOnrampAPI
package/dist/index.cjs CHANGED
@@ -11661,7 +11661,6 @@ var init_AuthMenu = __esm({
11661
11661
  var init_AuthMenu2 = __esm({
11662
11662
  "src/internal/components/AuthMenu/index.ts"() {
11663
11663
  init_AuthMenu();
11664
- init_useAuthStore();
11665
11664
  }
11666
11665
  });
11667
11666
 
@@ -16812,7 +16811,8 @@ function ProviderCard(props) {
16812
16811
  mutate: connectExternalWallet,
16813
16812
  disconnect: disconnectExternalWallet,
16814
16813
  isPending: isConnectingExternalWallet,
16815
- variables: pendingConnectVariables
16814
+ variables: pendingConnectVariables,
16815
+ isAvailable: isConnectExternalWalletAvailable
16816
16816
  } = useExternalWalletConnnect();
16817
16817
  const setPage = useLayoutDataStore((st) => st.setPage);
16818
16818
  const setConfirmUnlink = useManageWalletStore((st) => st.setConfirmUnlink);
@@ -16878,7 +16878,7 @@ function ProviderCard(props) {
16878
16878
  variant: "ghost",
16879
16879
  size: "small",
16880
16880
  className: "px-0 w-8 h-8",
16881
- disabled: disabled || isConnectingExternalWallet,
16881
+ disabled: disabled || isConnectingExternalWallet || !isConnectExternalWalletAvailable,
16882
16882
  title: isWalletProviderConnected ? t("passport:common.disconnect") : t("passport:common.connect"),
16883
16883
  onClick: () => {
16884
16884
  if (isWalletProviderConnected) {
@@ -17334,7 +17334,6 @@ function ConnectExternalWalletMenu() {
17334
17334
  const menuParams = useConnectExternalWalletMenuParams();
17335
17335
  const connectors = (0, import_wagmi2.useConnectors)();
17336
17336
  const hasInjectedWallet2 = useHasInjectedWallet();
17337
- const { isConnected: isExternalWalletConnected } = (0, import_wagmi2.useConnection)();
17338
17337
  const { mutate: disconnect } = (0, import_wagmi2.useDisconnect)();
17339
17338
  const { mutateAsync: signMessageAsync } = (0, import_wagmi2.useSignMessage)();
17340
17339
  const walletMenuOpenedFrom = useLayoutDataStore((st) => st.walletMenuOpenedFrom);
@@ -17344,6 +17343,7 @@ function ConnectExternalWalletMenu() {
17344
17343
  queryKey: [PROVIDERS_QUERY_KEY, embarkAiAddress],
17345
17344
  queryFn: async () => getLinkedProviders()
17346
17345
  });
17346
+ const [connectError, setConnectError] = (0, import_react46.useState)(null);
17347
17347
  const { mutateAsync: onLinkingComplete } = (0, import_react_query25.useMutation)({
17348
17348
  mutationFn: async (success) => {
17349
17349
  useManageWalletStore.getState().setProviderType(null);
@@ -17358,28 +17358,42 @@ function ConnectExternalWalletMenu() {
17358
17358
  const { mutateAsync: loginOrLinkOrConnectWallet, isPending: isLoginOrLinkOrConnectWallet } = (0, import_react_query25.useMutation)({
17359
17359
  mutationFn: async (payload) => {
17360
17360
  const { walletData, connectFlowType } = payload;
17361
- const { walletMenuOpenedFrom: walletMenuOpenedFrom2, setPage, setPendingWalletLogin } = useLayoutDataStore.getState();
17362
17361
  switch (connectFlowType) {
17363
17362
  // Auth flow: call wallet, default
17364
17363
  case "auth":
17365
- const loginResponse = await walletLogin(walletData);
17366
- setPendingWalletLogin(loginResponse);
17367
- setPage("auth" /* AUTH */);
17368
- break;
17364
+ return await walletLogin(walletData);
17369
17365
  // Link wallet profile flow, only if embarkAI is connected
17370
17366
  case "link":
17371
17367
  const skipLinkWalletProfile = providers.findIndex((p) => p.externalId === walletData.address) !== -1;
17372
- if (skipLinkWalletProfile) throw new Error(`Address ${walletData.address} already linked`);
17373
- await linkWallet(walletData).then(() => onLinkingComplete(true));
17374
- break;
17368
+ if (skipLinkWalletProfile)
17369
+ return { linked: false, message: `Address ${walletData.address} already linked` };
17370
+ return await linkWallet(walletData).then(async () => await onLinkingComplete(true)).catch((err) => {
17371
+ throw err;
17372
+ });
17375
17373
  // Connect external wallet flow, only if embarkAI is connected
17376
17374
  case "connect":
17377
- setPage(walletMenuOpenedFrom2 || "main-menu" /* MAIN_MENU */);
17378
- break;
17375
+ return null;
17379
17376
  }
17380
17377
  },
17381
- onSuccess: async (_, { walletData, connector }) => {
17382
- const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
17378
+ onSuccess: async (response, { walletData, connector, connectFlowType }) => {
17379
+ let shouldKeepConnected = walletMode === "direct" || walletMode === "both";
17380
+ switch (connectFlowType) {
17381
+ case "auth":
17382
+ useLayoutDataStore.getState().setPendingWalletLogin(response);
17383
+ useLayoutDataStore.getState().setPage("auth" /* AUTH */);
17384
+ break;
17385
+ case "link":
17386
+ const { linked, message } = response || {};
17387
+ if (!linked && message.includes("already linked")) {
17388
+ console.warn("[LINK STATUS] already linked", response);
17389
+ useManageWalletStore.getState().setProviderType(null);
17390
+ useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "manage-wallet" /* MANAGE_WALLET */);
17391
+ }
17392
+ break;
17393
+ case "connect":
17394
+ useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
17395
+ break;
17396
+ }
17383
17397
  if (shouldKeepConnected && walletData.chainId && connector) {
17384
17398
  useExternalWalletStore.getState().setExternalWallet({
17385
17399
  address: walletData.address,
@@ -17391,54 +17405,17 @@ function ConnectExternalWalletMenu() {
17391
17405
  }
17392
17406
  useLayoutStore.getState().setIsDialogForced(false);
17393
17407
  },
17394
- onError: (err, { walletData, connectFlowType }) => {
17395
- disconnect();
17408
+ onError: async (err, { walletData, connectFlowType }) => {
17409
+ setTimeout(() => disconnect(), 1e3);
17396
17410
  useLayoutStore.getState().setIsDialogForced(false);
17397
17411
  const errorMsg = err?.message || "Failed to connect wallet";
17398
- const setAuthError = useAuthStore.getState().setAlert;
17399
- const setManageWalletLinkError = useManageWalletStore.getState().setAlert;
17400
- if (errorMsg.includes("User rejected") || errorMsg.includes("User denied")) {
17401
- switch (connectFlowType) {
17402
- case "auth":
17403
- setAuthError({ title: "Signature error", message: "Signature request was cancelled" });
17404
- break;
17405
- case "link":
17406
- setManageWalletLinkError({ title: "Signature error", message: "Signature request was cancelled" });
17407
- break;
17408
- case "connect":
17409
- break;
17410
- }
17411
- } else if (errorMsg.includes("already linked")) {
17412
- switch (connectFlowType) {
17413
- case "auth":
17414
- setAuthError({ title: "Wallet error", message: "This wallet is already linked to another account" });
17415
- break;
17416
- case "link":
17417
- setManageWalletLinkError({
17418
- title: "Wallet error",
17419
- message: "This wallet is already linked to another account"
17420
- });
17421
- break;
17422
- case "connect":
17423
- break;
17424
- }
17425
- } else {
17426
- switch (connectFlowType) {
17427
- case "auth":
17428
- setAuthError({ title: "Error", message: errorMsg });
17429
- break;
17430
- case "link":
17431
- setManageWalletLinkError({ title: "Error", message: errorMsg });
17432
- break;
17433
- case "connect":
17434
- break;
17435
- }
17436
- }
17437
17412
  switch (connectFlowType) {
17438
17413
  case "auth":
17414
+ setConnectError(errorMsg);
17439
17415
  break;
17440
17416
  case "link":
17441
- onLinkingComplete(false);
17417
+ useManageWalletStore.getState().setAlert({ title: "Error", message: errorMsg });
17418
+ await onLinkingComplete(false);
17442
17419
  break;
17443
17420
  case "connect":
17444
17421
  openEmbarkAI(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
@@ -17449,7 +17426,6 @@ function ConnectExternalWalletMenu() {
17449
17426
  const {
17450
17427
  mutateAsync: connect,
17451
17428
  isPending: isConnectingExternalWallet,
17452
- error,
17453
17429
  variables: pendingConnectVariables
17454
17430
  } = (0, import_wagmi2.useConnect)({
17455
17431
  mutation: {
@@ -17495,7 +17471,7 @@ function ConnectExternalWalletMenu() {
17495
17471
  }
17496
17472
  });
17497
17473
  },
17498
- onError: (error2, { connector }) => {
17474
+ onError: (error, { connector }) => {
17499
17475
  const connectFlowType = getConnectFlowType({
17500
17476
  isEmbarkAI: !!embarkAiAddress,
17501
17477
  connectFlow: menuParams.current?.connectFlowType || "auth"
@@ -17504,20 +17480,17 @@ function ConnectExternalWalletMenu() {
17504
17480
  setTimeout(() => {
17505
17481
  switch (connectFlowType) {
17506
17482
  case "auth":
17507
- useAuthStore.getState().setAlert({
17508
- title: `Failed to connect: ${connector.name}`,
17509
- message: error2?.message || "Failed to connect wallet"
17510
- });
17483
+ setConnectError(error?.message || "Failed to connect wallet");
17511
17484
  break;
17512
17485
  case "link":
17486
+ setPage("manage-wallet" /* MANAGE_WALLET */);
17513
17487
  useManageWalletStore.getState().setAlert({
17514
17488
  title: `Failed to connect: ${connector.name}`,
17515
- message: error2?.message || "Failed to connect wallet before linking"
17489
+ message: error?.message || "Failed to connect wallet before linking"
17516
17490
  });
17517
- setPage("manage-wallet" /* MANAGE_WALLET */);
17518
17491
  break;
17519
17492
  case "connect":
17520
- openEmbarkAI(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
17493
+ setConnectError(error?.message || "Failed to connect wallet");
17521
17494
  break;
17522
17495
  }
17523
17496
  useLayoutStore.getState().setIsDialogForced(false);
@@ -17583,17 +17556,16 @@ function ConnectExternalWalletMenu() {
17583
17556
  className: "w-full justify-center",
17584
17557
  disabled: isConnectingExternalWallet,
17585
17558
  onClick: async () => {
17586
- if (isExternalWalletConnected) {
17559
+ if (connectError) setConnectError(null);
17560
+ try {
17587
17561
  disconnect();
17588
- await new Promise((resolve) => setTimeout(resolve, 500));
17562
+ } catch {
17589
17563
  }
17564
+ await new Promise((resolve) => setTimeout(resolve, 500));
17590
17565
  switch (true) {
17591
17566
  case (connector.id === "metaMaskSDK" && !hasInjectedWallet2):
17592
17567
  closeEmbarkAI();
17593
17568
  break;
17594
- // case connector.id === 'walletConnect':
17595
- // closeEmbarkAI() // close embarkAI since WalletConnect has dedicated UI
17596
- // break
17597
17569
  default:
17598
17570
  useLayoutStore.getState().setIsDialogForced(true);
17599
17571
  break;
@@ -17620,7 +17592,25 @@ function ConnectExternalWalletMenu() {
17620
17592
  })
17621
17593
  }),
17622
17594
  visibleConnectors.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Highlight, { type: "info", children: t("passport:connectMenu.noWallets") }),
17623
- error && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Highlight, { type: "error", children: error.message })
17595
+ connectError && /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(Highlight, { type: "error", className: "flex flex-col gap-[var(--ui-kit-gap)]", children: [
17596
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("p", { children: connectError }),
17597
+ /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
17598
+ Button,
17599
+ {
17600
+ variant: "default",
17601
+ size: "medium",
17602
+ className: "w-full",
17603
+ onClick: () => {
17604
+ try {
17605
+ disconnect();
17606
+ } catch {
17607
+ }
17608
+ setConnectError(null);
17609
+ },
17610
+ children: t("passport:common.hide")
17611
+ }
17612
+ )
17613
+ ] })
17624
17614
  ] });
17625
17615
  }
17626
17616
  var import_react_query25, import_lucide_react33, import_react46, import_wagmi2, import_jsx_runtime74;
@@ -17641,7 +17631,6 @@ var init_ConnectExternalWalletMenu = __esm({
17641
17631
  init_useLayoutDataStore();
17642
17632
  init_useLayoutStore();
17643
17633
  init_useExternalWalletStore();
17644
- init_AuthMenu2();
17645
17634
  init_Expandable2();
17646
17635
  init_ManageWalletMenu();
17647
17636
  init_button();
@@ -17655,24 +17644,19 @@ var init_ConnectExternalWalletMenu = __esm({
17655
17644
  // src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts
17656
17645
  function useExternalWalletConnnect() {
17657
17646
  const { config } = useProviderConfig();
17658
- const walletMode = config.current?.wallet?.mode || "both";
17647
+ const walletMode = config.current?.wallet?.mode;
17659
17648
  const connectors = (0, import_wagmi3.useConnectors)();
17660
17649
  const { mutate: disconnect } = (0, import_wagmi3.useDisconnect)();
17661
17650
  const { mutate: connect, ...restUseConnect } = (0, import_wagmi3.useConnect)({
17662
17651
  mutation: {
17663
17652
  onSuccess: (connectionData, { connector }) => {
17664
17653
  const { chainId, accounts } = connectionData;
17665
- const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
17666
- if (shouldKeepConnected && connector) {
17667
- const signingWalletAddress = accounts[0];
17668
- useExternalWalletStore.getState().setExternalWallet({
17669
- address: signingWalletAddress,
17670
- chainId,
17671
- connectorName: connector.name || "Unknown Wallet"
17672
- });
17673
- } else {
17674
- disconnect();
17675
- }
17654
+ const signingWalletAddress = accounts[0];
17655
+ useExternalWalletStore.getState().setExternalWallet({
17656
+ address: signingWalletAddress,
17657
+ chainId,
17658
+ connectorName: connector.name || "Unknown Wallet"
17659
+ });
17676
17660
  useLayoutStore.getState().setIsDialogForced(false);
17677
17661
  },
17678
17662
  onError: (error, variables) => {
@@ -17681,27 +17665,31 @@ function useExternalWalletConnnect() {
17681
17665
  }
17682
17666
  });
17683
17667
  const disconnectExternalWallet = (0, import_react47.useCallback)(() => {
17684
- disconnect();
17668
+ try {
17669
+ disconnect();
17670
+ } catch {
17671
+ return;
17672
+ }
17685
17673
  useExternalWalletStore.getState().clearExternalWallet();
17686
17674
  }, [disconnect]);
17687
17675
  const connectExternalWallet = (0, import_react47.useCallback)(
17688
17676
  async (walletConnectorType) => {
17689
- const externalAddress = useExternalWalletStore.getState().externalAddress;
17690
- if (externalAddress) {
17691
- disconnectExternalWallet();
17692
- await new Promise((resolve) => setTimeout(resolve, 500));
17693
- }
17677
+ disconnectExternalWallet();
17694
17678
  const connector = connectors.find((c) => c.id === walletConnectorType);
17695
17679
  if (!connector) {
17696
17680
  console.error("[ExternalWalletConnnect] Connector not found for:", walletConnectorType);
17697
17681
  return;
17698
17682
  }
17699
17683
  useLayoutStore.getState().setIsDialogForced(true);
17700
- connect({ connector });
17684
+ try {
17685
+ await connect({ connector });
17686
+ } catch {
17687
+ }
17701
17688
  },
17702
17689
  [connectors]
17703
17690
  );
17704
17691
  return {
17692
+ isAvailable: walletMode === "direct" || walletMode === "both",
17705
17693
  mutate: connectExternalWallet,
17706
17694
  disconnect: disconnectExternalWallet,
17707
17695
  ...restUseConnect
@@ -24847,7 +24835,8 @@ function SenderSelector(props) {
24847
24835
  const {
24848
24836
  mutate: connectExternalWallet,
24849
24837
  isPending: isConnectingExternalWallet,
24850
- variables: pendingConnectVariables
24838
+ variables: pendingConnectVariables,
24839
+ isAvailable: isConnectExternalWalletAvailable
24851
24840
  } = useExternalWalletConnnect();
24852
24841
  const directWalletAddress = useExternalWalletStore((st) => st.externalAddress);
24853
24842
  const directWalletIsConnected = useExternalWalletStore((st) => st.isExternalConnected);
@@ -24860,7 +24849,7 @@ function SenderSelector(props) {
24860
24849
  variant: "secondary",
24861
24850
  size: "large",
24862
24851
  className: "justify-between",
24863
- disabled: isConnectingExternalWallet,
24852
+ disabled: !isConnectExternalWalletAvailable || isConnectingExternalWallet,
24864
24853
  onClick: async () => {
24865
24854
  switch (sender.type) {
24866
24855
  case "embarkai-wallet":
@@ -29967,7 +29956,7 @@ var init_package = __esm({
29967
29956
  "package.json"() {
29968
29957
  package_default = {
29969
29958
  name: "@embarkai/ui-kit",
29970
- version: "0.4.103",
29959
+ version: "0.4.104",
29971
29960
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
29972
29961
  type: "module",
29973
29962
  main: "./dist/index.cjs",
package/dist/index.js CHANGED
@@ -11626,7 +11626,6 @@ var init_AuthMenu = __esm({
11626
11626
  var init_AuthMenu2 = __esm({
11627
11627
  "src/internal/components/AuthMenu/index.ts"() {
11628
11628
  init_AuthMenu();
11629
- init_useAuthStore();
11630
11629
  }
11631
11630
  });
11632
11631
 
@@ -16765,7 +16764,8 @@ function ProviderCard(props) {
16765
16764
  mutate: connectExternalWallet,
16766
16765
  disconnect: disconnectExternalWallet,
16767
16766
  isPending: isConnectingExternalWallet,
16768
- variables: pendingConnectVariables
16767
+ variables: pendingConnectVariables,
16768
+ isAvailable: isConnectExternalWalletAvailable
16769
16769
  } = useExternalWalletConnnect();
16770
16770
  const setPage = useLayoutDataStore((st) => st.setPage);
16771
16771
  const setConfirmUnlink = useManageWalletStore((st) => st.setConfirmUnlink);
@@ -16831,7 +16831,7 @@ function ProviderCard(props) {
16831
16831
  variant: "ghost",
16832
16832
  size: "small",
16833
16833
  className: "px-0 w-8 h-8",
16834
- disabled: disabled || isConnectingExternalWallet,
16834
+ disabled: disabled || isConnectingExternalWallet || !isConnectExternalWalletAvailable,
16835
16835
  title: isWalletProviderConnected ? t("passport:common.disconnect") : t("passport:common.connect"),
16836
16836
  onClick: () => {
16837
16837
  if (isWalletProviderConnected) {
@@ -17268,8 +17268,8 @@ var init_useHasInjectedWallet = __esm({
17268
17268
  // src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx
17269
17269
  import { useMutation as useMutation10, useQuery as useQuery9, useQueryClient as useQueryClient14 } from "@tanstack/react-query";
17270
17270
  import { ArrowLeft as ArrowLeft8, Loader as Loader11, Wallet2Icon as Wallet2Icon2 } from "lucide-react";
17271
- import { useCallback as useCallback17, useMemo as useMemo9 } from "react";
17272
- import { useConnect, useConnection, useConnectors, useDisconnect as useDisconnect2, useSignMessage } from "wagmi";
17271
+ import { useCallback as useCallback17, useMemo as useMemo9, useState as useState14 } from "react";
17272
+ import { useConnect, useConnectors, useDisconnect as useDisconnect2, useSignMessage } from "wagmi";
17273
17273
  import { jsx as jsx74, jsxs as jsxs65 } from "react/jsx-runtime";
17274
17274
  function getConnectFlowType(params) {
17275
17275
  const { isEmbarkAI, connectFlow } = params;
@@ -17287,7 +17287,6 @@ function ConnectExternalWalletMenu() {
17287
17287
  const menuParams = useConnectExternalWalletMenuParams();
17288
17288
  const connectors = useConnectors();
17289
17289
  const hasInjectedWallet2 = useHasInjectedWallet();
17290
- const { isConnected: isExternalWalletConnected } = useConnection();
17291
17290
  const { mutate: disconnect } = useDisconnect2();
17292
17291
  const { mutateAsync: signMessageAsync } = useSignMessage();
17293
17292
  const walletMenuOpenedFrom = useLayoutDataStore((st) => st.walletMenuOpenedFrom);
@@ -17297,6 +17296,7 @@ function ConnectExternalWalletMenu() {
17297
17296
  queryKey: [PROVIDERS_QUERY_KEY, embarkAiAddress],
17298
17297
  queryFn: async () => getLinkedProviders()
17299
17298
  });
17299
+ const [connectError, setConnectError] = useState14(null);
17300
17300
  const { mutateAsync: onLinkingComplete } = useMutation10({
17301
17301
  mutationFn: async (success) => {
17302
17302
  useManageWalletStore.getState().setProviderType(null);
@@ -17311,28 +17311,42 @@ function ConnectExternalWalletMenu() {
17311
17311
  const { mutateAsync: loginOrLinkOrConnectWallet, isPending: isLoginOrLinkOrConnectWallet } = useMutation10({
17312
17312
  mutationFn: async (payload) => {
17313
17313
  const { walletData, connectFlowType } = payload;
17314
- const { walletMenuOpenedFrom: walletMenuOpenedFrom2, setPage, setPendingWalletLogin } = useLayoutDataStore.getState();
17315
17314
  switch (connectFlowType) {
17316
17315
  // Auth flow: call wallet, default
17317
17316
  case "auth":
17318
- const loginResponse = await walletLogin(walletData);
17319
- setPendingWalletLogin(loginResponse);
17320
- setPage("auth" /* AUTH */);
17321
- break;
17317
+ return await walletLogin(walletData);
17322
17318
  // Link wallet profile flow, only if embarkAI is connected
17323
17319
  case "link":
17324
17320
  const skipLinkWalletProfile = providers.findIndex((p) => p.externalId === walletData.address) !== -1;
17325
- if (skipLinkWalletProfile) throw new Error(`Address ${walletData.address} already linked`);
17326
- await linkWallet(walletData).then(() => onLinkingComplete(true));
17327
- break;
17321
+ if (skipLinkWalletProfile)
17322
+ return { linked: false, message: `Address ${walletData.address} already linked` };
17323
+ return await linkWallet(walletData).then(async () => await onLinkingComplete(true)).catch((err) => {
17324
+ throw err;
17325
+ });
17328
17326
  // Connect external wallet flow, only if embarkAI is connected
17329
17327
  case "connect":
17330
- setPage(walletMenuOpenedFrom2 || "main-menu" /* MAIN_MENU */);
17331
- break;
17328
+ return null;
17332
17329
  }
17333
17330
  },
17334
- onSuccess: async (_, { walletData, connector }) => {
17335
- const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
17331
+ onSuccess: async (response, { walletData, connector, connectFlowType }) => {
17332
+ let shouldKeepConnected = walletMode === "direct" || walletMode === "both";
17333
+ switch (connectFlowType) {
17334
+ case "auth":
17335
+ useLayoutDataStore.getState().setPendingWalletLogin(response);
17336
+ useLayoutDataStore.getState().setPage("auth" /* AUTH */);
17337
+ break;
17338
+ case "link":
17339
+ const { linked, message } = response || {};
17340
+ if (!linked && message.includes("already linked")) {
17341
+ console.warn("[LINK STATUS] already linked", response);
17342
+ useManageWalletStore.getState().setProviderType(null);
17343
+ useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "manage-wallet" /* MANAGE_WALLET */);
17344
+ }
17345
+ break;
17346
+ case "connect":
17347
+ useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
17348
+ break;
17349
+ }
17336
17350
  if (shouldKeepConnected && walletData.chainId && connector) {
17337
17351
  useExternalWalletStore.getState().setExternalWallet({
17338
17352
  address: walletData.address,
@@ -17344,54 +17358,17 @@ function ConnectExternalWalletMenu() {
17344
17358
  }
17345
17359
  useLayoutStore.getState().setIsDialogForced(false);
17346
17360
  },
17347
- onError: (err, { walletData, connectFlowType }) => {
17348
- disconnect();
17361
+ onError: async (err, { walletData, connectFlowType }) => {
17362
+ setTimeout(() => disconnect(), 1e3);
17349
17363
  useLayoutStore.getState().setIsDialogForced(false);
17350
17364
  const errorMsg = err?.message || "Failed to connect wallet";
17351
- const setAuthError = useAuthStore.getState().setAlert;
17352
- const setManageWalletLinkError = useManageWalletStore.getState().setAlert;
17353
- if (errorMsg.includes("User rejected") || errorMsg.includes("User denied")) {
17354
- switch (connectFlowType) {
17355
- case "auth":
17356
- setAuthError({ title: "Signature error", message: "Signature request was cancelled" });
17357
- break;
17358
- case "link":
17359
- setManageWalletLinkError({ title: "Signature error", message: "Signature request was cancelled" });
17360
- break;
17361
- case "connect":
17362
- break;
17363
- }
17364
- } else if (errorMsg.includes("already linked")) {
17365
- switch (connectFlowType) {
17366
- case "auth":
17367
- setAuthError({ title: "Wallet error", message: "This wallet is already linked to another account" });
17368
- break;
17369
- case "link":
17370
- setManageWalletLinkError({
17371
- title: "Wallet error",
17372
- message: "This wallet is already linked to another account"
17373
- });
17374
- break;
17375
- case "connect":
17376
- break;
17377
- }
17378
- } else {
17379
- switch (connectFlowType) {
17380
- case "auth":
17381
- setAuthError({ title: "Error", message: errorMsg });
17382
- break;
17383
- case "link":
17384
- setManageWalletLinkError({ title: "Error", message: errorMsg });
17385
- break;
17386
- case "connect":
17387
- break;
17388
- }
17389
- }
17390
17365
  switch (connectFlowType) {
17391
17366
  case "auth":
17367
+ setConnectError(errorMsg);
17392
17368
  break;
17393
17369
  case "link":
17394
- onLinkingComplete(false);
17370
+ useManageWalletStore.getState().setAlert({ title: "Error", message: errorMsg });
17371
+ await onLinkingComplete(false);
17395
17372
  break;
17396
17373
  case "connect":
17397
17374
  openEmbarkAI(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
@@ -17402,7 +17379,6 @@ function ConnectExternalWalletMenu() {
17402
17379
  const {
17403
17380
  mutateAsync: connect,
17404
17381
  isPending: isConnectingExternalWallet,
17405
- error,
17406
17382
  variables: pendingConnectVariables
17407
17383
  } = useConnect({
17408
17384
  mutation: {
@@ -17448,7 +17424,7 @@ function ConnectExternalWalletMenu() {
17448
17424
  }
17449
17425
  });
17450
17426
  },
17451
- onError: (error2, { connector }) => {
17427
+ onError: (error, { connector }) => {
17452
17428
  const connectFlowType = getConnectFlowType({
17453
17429
  isEmbarkAI: !!embarkAiAddress,
17454
17430
  connectFlow: menuParams.current?.connectFlowType || "auth"
@@ -17457,20 +17433,17 @@ function ConnectExternalWalletMenu() {
17457
17433
  setTimeout(() => {
17458
17434
  switch (connectFlowType) {
17459
17435
  case "auth":
17460
- useAuthStore.getState().setAlert({
17461
- title: `Failed to connect: ${connector.name}`,
17462
- message: error2?.message || "Failed to connect wallet"
17463
- });
17436
+ setConnectError(error?.message || "Failed to connect wallet");
17464
17437
  break;
17465
17438
  case "link":
17439
+ setPage("manage-wallet" /* MANAGE_WALLET */);
17466
17440
  useManageWalletStore.getState().setAlert({
17467
17441
  title: `Failed to connect: ${connector.name}`,
17468
- message: error2?.message || "Failed to connect wallet before linking"
17442
+ message: error?.message || "Failed to connect wallet before linking"
17469
17443
  });
17470
- setPage("manage-wallet" /* MANAGE_WALLET */);
17471
17444
  break;
17472
17445
  case "connect":
17473
- openEmbarkAI(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
17446
+ setConnectError(error?.message || "Failed to connect wallet");
17474
17447
  break;
17475
17448
  }
17476
17449
  useLayoutStore.getState().setIsDialogForced(false);
@@ -17536,17 +17509,16 @@ function ConnectExternalWalletMenu() {
17536
17509
  className: "w-full justify-center",
17537
17510
  disabled: isConnectingExternalWallet,
17538
17511
  onClick: async () => {
17539
- if (isExternalWalletConnected) {
17512
+ if (connectError) setConnectError(null);
17513
+ try {
17540
17514
  disconnect();
17541
- await new Promise((resolve) => setTimeout(resolve, 500));
17515
+ } catch {
17542
17516
  }
17517
+ await new Promise((resolve) => setTimeout(resolve, 500));
17543
17518
  switch (true) {
17544
17519
  case (connector.id === "metaMaskSDK" && !hasInjectedWallet2):
17545
17520
  closeEmbarkAI();
17546
17521
  break;
17547
- // case connector.id === 'walletConnect':
17548
- // closeEmbarkAI() // close embarkAI since WalletConnect has dedicated UI
17549
- // break
17550
17522
  default:
17551
17523
  useLayoutStore.getState().setIsDialogForced(true);
17552
17524
  break;
@@ -17573,7 +17545,25 @@ function ConnectExternalWalletMenu() {
17573
17545
  })
17574
17546
  }),
17575
17547
  visibleConnectors.length === 0 && /* @__PURE__ */ jsx74(Highlight, { type: "info", children: t("passport:connectMenu.noWallets") }),
17576
- error && /* @__PURE__ */ jsx74(Highlight, { type: "error", children: error.message })
17548
+ connectError && /* @__PURE__ */ jsxs65(Highlight, { type: "error", className: "flex flex-col gap-[var(--ui-kit-gap)]", children: [
17549
+ /* @__PURE__ */ jsx74("p", { children: connectError }),
17550
+ /* @__PURE__ */ jsx74(
17551
+ Button,
17552
+ {
17553
+ variant: "default",
17554
+ size: "medium",
17555
+ className: "w-full",
17556
+ onClick: () => {
17557
+ try {
17558
+ disconnect();
17559
+ } catch {
17560
+ }
17561
+ setConnectError(null);
17562
+ },
17563
+ children: t("passport:common.hide")
17564
+ }
17565
+ )
17566
+ ] })
17577
17567
  ] });
17578
17568
  }
17579
17569
  var init_ConnectExternalWalletMenu = __esm({
@@ -17589,7 +17579,6 @@ var init_ConnectExternalWalletMenu = __esm({
17589
17579
  init_useLayoutDataStore();
17590
17580
  init_useLayoutStore();
17591
17581
  init_useExternalWalletStore();
17592
- init_AuthMenu2();
17593
17582
  init_Expandable2();
17594
17583
  init_ManageWalletMenu();
17595
17584
  init_button();
@@ -17604,24 +17593,19 @@ import { useCallback as useCallback18 } from "react";
17604
17593
  import { useConnect as useConnect2, useConnectors as useConnectors2, useDisconnect as useDisconnect3 } from "wagmi";
17605
17594
  function useExternalWalletConnnect() {
17606
17595
  const { config } = useProviderConfig();
17607
- const walletMode = config.current?.wallet?.mode || "both";
17596
+ const walletMode = config.current?.wallet?.mode;
17608
17597
  const connectors = useConnectors2();
17609
17598
  const { mutate: disconnect } = useDisconnect3();
17610
17599
  const { mutate: connect, ...restUseConnect } = useConnect2({
17611
17600
  mutation: {
17612
17601
  onSuccess: (connectionData, { connector }) => {
17613
17602
  const { chainId, accounts } = connectionData;
17614
- const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
17615
- if (shouldKeepConnected && connector) {
17616
- const signingWalletAddress = accounts[0];
17617
- useExternalWalletStore.getState().setExternalWallet({
17618
- address: signingWalletAddress,
17619
- chainId,
17620
- connectorName: connector.name || "Unknown Wallet"
17621
- });
17622
- } else {
17623
- disconnect();
17624
- }
17603
+ const signingWalletAddress = accounts[0];
17604
+ useExternalWalletStore.getState().setExternalWallet({
17605
+ address: signingWalletAddress,
17606
+ chainId,
17607
+ connectorName: connector.name || "Unknown Wallet"
17608
+ });
17625
17609
  useLayoutStore.getState().setIsDialogForced(false);
17626
17610
  },
17627
17611
  onError: (error, variables) => {
@@ -17630,27 +17614,31 @@ function useExternalWalletConnnect() {
17630
17614
  }
17631
17615
  });
17632
17616
  const disconnectExternalWallet = useCallback18(() => {
17633
- disconnect();
17617
+ try {
17618
+ disconnect();
17619
+ } catch {
17620
+ return;
17621
+ }
17634
17622
  useExternalWalletStore.getState().clearExternalWallet();
17635
17623
  }, [disconnect]);
17636
17624
  const connectExternalWallet = useCallback18(
17637
17625
  async (walletConnectorType) => {
17638
- const externalAddress = useExternalWalletStore.getState().externalAddress;
17639
- if (externalAddress) {
17640
- disconnectExternalWallet();
17641
- await new Promise((resolve) => setTimeout(resolve, 500));
17642
- }
17626
+ disconnectExternalWallet();
17643
17627
  const connector = connectors.find((c) => c.id === walletConnectorType);
17644
17628
  if (!connector) {
17645
17629
  console.error("[ExternalWalletConnnect] Connector not found for:", walletConnectorType);
17646
17630
  return;
17647
17631
  }
17648
17632
  useLayoutStore.getState().setIsDialogForced(true);
17649
- connect({ connector });
17633
+ try {
17634
+ await connect({ connector });
17635
+ } catch {
17636
+ }
17650
17637
  },
17651
17638
  [connectors]
17652
17639
  );
17653
17640
  return {
17641
+ isAvailable: walletMode === "direct" || walletMode === "both",
17654
17642
  mutate: connectExternalWallet,
17655
17643
  disconnect: disconnectExternalWallet,
17656
17644
  ...restUseConnect
@@ -17732,7 +17720,7 @@ var init_devices = __esm({
17732
17720
 
17733
17721
  // src/internal/components/DevicesMenu/DeviceLinkScreen.tsx
17734
17722
  import { ArrowLeft as ArrowLeft9, Loader2 as Loader22 } from "lucide-react";
17735
- import { useState as useState14 } from "react";
17723
+ import { useState as useState15 } from "react";
17736
17724
  import { jsx as jsx75, jsxs as jsxs66 } from "react/jsx-runtime";
17737
17725
  function getErrorMessage(err) {
17738
17726
  const code = err?.code;
@@ -17752,8 +17740,8 @@ function getErrorMessage(err) {
17752
17740
  function DeviceLinkScreen() {
17753
17741
  const setPage = useLayoutDataStore((s) => s.setPage);
17754
17742
  const { mutate: link, isPending } = useLinkDevice();
17755
- const [code, setCode] = useState14("");
17756
- const [error, setError] = useState14(null);
17743
+ const [code, setCode] = useState15("");
17744
+ const [error, setError] = useState15(null);
17757
17745
  const isValid = code.length === 6 && VALID_CHARS.test(code);
17758
17746
  function handleCodeChange(value) {
17759
17747
  const upper = value.toUpperCase().slice(0, 6);
@@ -18325,7 +18313,7 @@ var init_guardian_backup = __esm({
18325
18313
 
18326
18314
  // src/internal/components/DevicesMenu/DeviceManageScreen.tsx
18327
18315
  import { ArrowLeft as ArrowLeft10, Cpu, Download, HardDrive, Loader2 as Loader23, Trash2, Upload } from "lucide-react";
18328
- import { useCallback as useCallback19, useEffect as useEffect26, useRef as useRef14, useState as useState15 } from "react";
18316
+ import { useCallback as useCallback19, useEffect as useEffect26, useRef as useRef14, useState as useState16 } from "react";
18329
18317
  import { Fragment as Fragment20, jsx as jsx76, jsxs as jsxs67 } from "react/jsx-runtime";
18330
18318
  function formatSize(bytes) {
18331
18319
  if (bytes < 1024) return `${bytes} B`;
@@ -18339,12 +18327,12 @@ function DeviceManageScreen() {
18339
18327
  const deviceId = pageParams?.deviceId;
18340
18328
  const deviceName = pageParams?.deviceName;
18341
18329
  const guardianRef = useRef14(null);
18342
- const [screen, setScreen] = useState15({ step: "connecting" });
18343
- const [actionState, setActionState] = useState15(null);
18344
- const [password, setPassword] = useState15("");
18345
- const [statusMessage, setStatusMessage] = useState15(null);
18346
- const [errorMessage, setErrorMessage] = useState15(null);
18347
- const [waitingConfirm, setWaitingConfirm] = useState15(false);
18330
+ const [screen, setScreen] = useState16({ step: "connecting" });
18331
+ const [actionState, setActionState] = useState16(null);
18332
+ const [password, setPassword] = useState16("");
18333
+ const [statusMessage, setStatusMessage] = useState16(null);
18334
+ const [errorMessage, setErrorMessage] = useState16(null);
18335
+ const [waitingConfirm, setWaitingConfirm] = useState16(false);
18348
18336
  useEffect26(() => {
18349
18337
  if (!statusMessage) return;
18350
18338
  const t = setTimeout(() => setStatusMessage(null), 3e3);
@@ -18635,7 +18623,7 @@ var init_DeviceManageScreen = __esm({
18635
18623
 
18636
18624
  // src/internal/components/DevicesMenu/DeviceRestoreScreen.tsx
18637
18625
  import { AlertTriangle as AlertTriangle2, ArrowLeft as ArrowLeft11, Download as Download2, Loader2 as Loader24 } from "lucide-react";
18638
- import { useCallback as useCallback20, useState as useState16 } from "react";
18626
+ import { useCallback as useCallback20, useState as useState17 } from "react";
18639
18627
  import { Fragment as Fragment21, jsx as jsx77, jsxs as jsxs68 } from "react/jsx-runtime";
18640
18628
  function DeviceRestoreScreen() {
18641
18629
  const setPage = useLayoutDataStore((s) => s.setPage);
@@ -18645,10 +18633,10 @@ function DeviceRestoreScreen() {
18645
18633
  const keyshareId = pageParams?.keyshareId;
18646
18634
  const deviceId = pageParams?.deviceId;
18647
18635
  const deviceName = pageParams?.deviceName;
18648
- const [password, setPassword] = useState16("");
18649
- const [isWorking, setIsWorking] = useState16(false);
18650
- const [statusMessage, setStatusMessage] = useState16(null);
18651
- const [errorMessage, setErrorMessage] = useState16(null);
18636
+ const [password, setPassword] = useState17("");
18637
+ const [isWorking, setIsWorking] = useState17(false);
18638
+ const [statusMessage, setStatusMessage] = useState17(null);
18639
+ const [errorMessage, setErrorMessage] = useState17(null);
18652
18640
  const handleRestore = useCallback20(async () => {
18653
18641
  if (!password || !keyshareId || !userId) return;
18654
18642
  const iframe6 = getIframeManager();
@@ -18742,7 +18730,7 @@ var init_DeviceRestoreScreen = __esm({
18742
18730
 
18743
18731
  // src/internal/components/DevicesMenu/DevicesMenu.tsx
18744
18732
  import { ArrowLeft as ArrowLeft12, CheckCircle, Cpu as Cpu2, HardDrive as HardDrive2, Loader2 as Loader25, Monitor, RefreshCw, Trash2 as Trash22 } from "lucide-react";
18745
- import { useState as useState17 } from "react";
18733
+ import { useState as useState18 } from "react";
18746
18734
  import { jsx as jsx78, jsxs as jsxs69 } from "react/jsx-runtime";
18747
18735
  function DeviceIcon({ deviceType }) {
18748
18736
  const Icon2 = deviceType === "iot" ? Cpu2 : Monitor;
@@ -18753,8 +18741,8 @@ function truncateAddress(address) {
18753
18741
  return `${address.slice(0, 6)}...${address.slice(-4)}`;
18754
18742
  }
18755
18743
  function DeviceRow({ device }) {
18756
- const [confirmingUnlink, setConfirmingUnlink] = useState17(false);
18757
- const [unlinkError, setUnlinkError] = useState17(null);
18744
+ const [confirmingUnlink, setConfirmingUnlink] = useState18(false);
18745
+ const [unlinkError, setUnlinkError] = useState18(null);
18758
18746
  const { mutate: unlink, isPending } = useUnlinkDevice();
18759
18747
  if (confirmingUnlink) {
18760
18748
  return /* @__PURE__ */ jsxs69("div", { className: "flex flex-col gap-2 p-3 rounded-lg bg-[var(--ui-kit-bg)]", children: [
@@ -20505,7 +20493,7 @@ var init_Cloud = __esm({
20505
20493
  });
20506
20494
 
20507
20495
  // src/internal/components/KeyshareRestoreMenu/methods/Guardian.tsx
20508
- import { useState as useState19 } from "react";
20496
+ import { useState as useState20 } from "react";
20509
20497
  import { Cpu as Cpu4, Loader2 as Loader26 } from "lucide-react";
20510
20498
  import { Fragment as Fragment28, jsx as jsx86, jsxs as jsxs77 } from "react/jsx-runtime";
20511
20499
  function Guardian(props) {
@@ -20514,8 +20502,8 @@ function Guardian(props) {
20514
20502
  const session = useSession((st) => st.session);
20515
20503
  const recoveryUserId = useSession((st) => st.recoveryUserId);
20516
20504
  const { onRestoreSuccess } = useOnRestoreSuccess();
20517
- const [isWorking, setIsWorking] = useState19(false);
20518
- const [step, setStep] = useState19("idle");
20505
+ const [isWorking, setIsWorking] = useState20(false);
20506
+ const [step, setStep] = useState20("idle");
20519
20507
  const handleGuardianBackup = async () => {
20520
20508
  if (!restorePassword) {
20521
20509
  setError("Please enter a password");
@@ -21162,15 +21150,15 @@ var init_SumsubIframeManager = __esm({
21162
21150
  });
21163
21151
 
21164
21152
  // src/internal/components/KYC/useSumsubIframe.ts
21165
- import { useEffect as useEffect34, useRef as useRef16, useState as useState20 } from "react";
21153
+ import { useEffect as useEffect34, useRef as useRef16, useState as useState21 } from "react";
21166
21154
  function useSumsubIframe({ iframeUrl }) {
21167
21155
  const config = useProviderConfig().config;
21168
21156
  const { colorMode } = useColorMode();
21169
21157
  const iframeRef = useRef16(null);
21170
- const [isLoading, setIsLoading] = useState20(true);
21171
- const [error, setError] = useState20(null);
21172
- const [height, setHeight] = useState20(0);
21173
- const [status, setStatus] = useState20("");
21158
+ const [isLoading, setIsLoading] = useState21(true);
21159
+ const [error, setError] = useState21(null);
21160
+ const [height, setHeight] = useState21(0);
21161
+ const [status, setStatus] = useState21("");
21174
21162
  const levelName = config.current?.kyc?.options?.levelName;
21175
21163
  useEffect34(() => {
21176
21164
  setError(null);
@@ -22082,7 +22070,7 @@ var init_BalanceView2 = __esm({
22082
22070
  // src/internal/components/PortfolioMenu/PortfolioItem.tsx
22083
22071
  import { useQuery as useQuery18 } from "@tanstack/react-query";
22084
22072
  import { LoaderIcon as LoaderIcon11, ShieldAlertIcon, SparklesIcon } from "lucide-react";
22085
- import { useMemo as useMemo14, useState as useState21 } from "react";
22073
+ import { useMemo as useMemo14, useState as useState22 } from "react";
22086
22074
  import { formatUnits as formatUnits7 } from "viem";
22087
22075
  import { Fragment as Fragment32, jsx as jsx94, jsxs as jsxs85 } from "react/jsx-runtime";
22088
22076
  function openInExplorer(address) {
@@ -22122,8 +22110,8 @@ function SecurityTokenBadge() {
22122
22110
  }
22123
22111
  function PortfolioItemImage(props) {
22124
22112
  const { asset } = props;
22125
- const [logoError, setLogoError] = useState21(false);
22126
- const [nftImageError, setNftImageError] = useState21(false);
22113
+ const [logoError, setLogoError] = useState22(false);
22114
+ const [nftImageError, setNftImageError] = useState22(false);
22127
22115
  const resolvedImage = useMemo14(() => {
22128
22116
  const isNft = isNftAsset(asset);
22129
22117
  const nftImage = getNftImage(asset);
@@ -22729,7 +22717,7 @@ var init_useNicknameAvailability = __esm({
22729
22717
  // src/internal/components/NicknameMenu/NicknameEditForm.tsx
22730
22718
  import { useMutation as useMutation16, useQueryClient as useQueryClient21 } from "@tanstack/react-query";
22731
22719
  import { AtSignIcon, CopyIcon as CopyIcon2, LoaderIcon as LoaderIcon12, SaveIcon } from "lucide-react";
22732
- import { useCallback as useCallback26, useEffect as useEffect36, useRef as useRef18, useState as useState22 } from "react";
22720
+ import { useCallback as useCallback26, useEffect as useEffect36, useRef as useRef18, useState as useState23 } from "react";
22733
22721
  import { Fragment as Fragment34, jsx as jsx98, jsxs as jsxs89 } from "react/jsx-runtime";
22734
22722
  function NicknameEditForm(props) {
22735
22723
  const { isInitialUser, nicknameInfo } = props;
@@ -22742,7 +22730,7 @@ function NicknameEditForm(props) {
22742
22730
  const nicknameValue = useNicknameStore((st) => st.nicknameValue);
22743
22731
  const nicknameAvailability = useNicknameStore((st) => st.availability);
22744
22732
  const { isCheckingAvailability } = useNicknameAvailability(nicknameInfo ? nicknameInfo.handle : "");
22745
- const [isNicknameCopied, setIsNicknameCopied] = useState22(false);
22733
+ const [isNicknameCopied, setIsNicknameCopied] = useState23(false);
22746
22734
  const exitTimerRef = useRef18(null);
22747
22735
  useEffect36(() => () => {
22748
22736
  if (exitTimerRef.current) clearTimeout(exitTimerRef.current);
@@ -23120,7 +23108,7 @@ var init_nickname_fingerprint = __esm({
23120
23108
  import { useQuery as useQuery20 } from "@tanstack/react-query";
23121
23109
  import { ArrowLeft as ArrowLeft19, AtSignIcon as AtSignIcon2, CheckCircle2 as CheckCircle24, Copy as Copy2, FingerprintIcon, LoaderIcon as LoaderIcon13, Wallet2Icon as Wallet2Icon4 } from "lucide-react";
23122
23110
  import QRCode from "qrcode";
23123
- import { useEffect as useEffect38, useMemo as useMemo15, useState as useState23 } from "react";
23111
+ import { useEffect as useEffect38, useMemo as useMemo15, useState as useState24 } from "react";
23124
23112
  import { Fragment as Fragment35, jsx as jsx100, jsxs as jsxs91 } from "react/jsx-runtime";
23125
23113
  function ReceiveMenu() {
23126
23114
  const { t } = useT();
@@ -23133,10 +23121,10 @@ function ReceiveMenu() {
23133
23121
  queryKey: [QUERY_KEYS.nicknameInfo, address],
23134
23122
  queryFn: async () => await getNicknameInfo()
23135
23123
  });
23136
- const [qrCodeUrl, setQrCodeUrl] = useState23("");
23137
- const [isAddressCopied, setAddressCopied] = useState23(false);
23138
- const [isNicknameCopied, setNicknameCopied] = useState23(false);
23139
- const [fingerprintCopied, setFingerprintCopied] = useState23(false);
23124
+ const [qrCodeUrl, setQrCodeUrl] = useState24("");
23125
+ const [isAddressCopied, setAddressCopied] = useState24(false);
23126
+ const [isNicknameCopied, setNicknameCopied] = useState24(false);
23127
+ const [fingerprintCopied, setFingerprintCopied] = useState24(false);
23140
23128
  useOnboardingTourAvailable(true);
23141
23129
  const fingerprint = useMemo15(() => {
23142
23130
  if (!session?.ownerAddress) return null;
@@ -23948,7 +23936,7 @@ var init_utils10 = __esm({
23948
23936
  });
23949
23937
 
23950
23938
  // src/internal/components/SecurityMenu/UserPolicies/usePolicyForm.ts
23951
- import { useEffect as useEffect39, useState as useState24 } from "react";
23939
+ import { useEffect as useEffect39, useState as useState25 } from "react";
23952
23940
  import { create as create14 } from "zustand";
23953
23941
  function updateDestinations(patch) {
23954
23942
  usePolicyForm.setState((st) => ({ ...st, destinations: { ...st?.destinations, ...patch } }));
@@ -23957,7 +23945,7 @@ function updateLimits(patch) {
23957
23945
  usePolicyForm.setState((st) => ({ ...st, limits: { ...st?.limits, ...patch } }));
23958
23946
  }
23959
23947
  function useWatchFormData() {
23960
- const [showFormErrors, setShowFormErrors] = useState24(false);
23948
+ const [showFormErrors, setShowFormErrors] = useState25(false);
23961
23949
  const formData = usePolicyForm();
23962
23950
  const formState = usePolicyFormValidation();
23963
23951
  useEffect39(() => {
@@ -24030,13 +24018,13 @@ var init_useUserAssetsPolicies = __esm({
24030
24018
  // src/internal/components/SecurityMenu/UserPolicies/PolicyForm.tsx
24031
24019
  import { useMutation as useMutation18, useQueryClient as useQueryClient23 } from "@tanstack/react-query";
24032
24020
  import { ChevronRightIcon as ChevronRightIcon2, ChevronUpIcon as ChevronUpIcon2, LoaderIcon as LoaderIcon16, PlusIcon, TrashIcon } from "lucide-react";
24033
- import { useCallback as useCallback27, useState as useState25 } from "react";
24021
+ import { useCallback as useCallback27, useState as useState26 } from "react";
24034
24022
  import { Fragment as Fragment37, jsx as jsx106, jsxs as jsxs97 } from "react/jsx-runtime";
24035
24023
  function AddressListEditor(props) {
24036
24024
  const { label, assets = [], addresses, onChange } = props;
24037
- const [isAssetSelector, setIsAssetSelector] = useState25(false);
24038
- const [customAddress, setCustomAddress] = useState25("");
24039
- const [customAddressError, setCustomAddressError] = useState25(null);
24025
+ const [isAssetSelector, setIsAssetSelector] = useState26(false);
24026
+ const [customAddress, setCustomAddress] = useState26("");
24027
+ const [customAddressError, setCustomAddressError] = useState26(null);
24040
24028
  const handleAddress = useCallback27(
24041
24029
  (addressToAdd) => {
24042
24030
  if (!isValidAddress(addressToAdd)) {
@@ -24294,7 +24282,7 @@ var init_constants8 = __esm({
24294
24282
  import { useMutation as useMutation19, useQueryClient as useQueryClient24 } from "@tanstack/react-query";
24295
24283
  import cn3 from "clsx";
24296
24284
  import { LoaderIcon as LoaderIcon17, PencilIcon, TrashIcon as TrashIcon2 } from "lucide-react";
24297
- import { useState as useState26 } from "react";
24285
+ import { useState as useState27 } from "react";
24298
24286
  import { jsx as jsx107, jsxs as jsxs98 } from "react/jsx-runtime";
24299
24287
  function RulesSummary(props) {
24300
24288
  const { t } = useT();
@@ -24353,7 +24341,7 @@ function UserPolicies() {
24353
24341
  const config = useProviderConfig().config;
24354
24342
  const mpcUserId = useSession((st) => st.session?.mpcUserId);
24355
24343
  const activeChainId = useSession((st) => st.activeChainId);
24356
- const [isConfirmingDelete, setIsConfirmingDelete] = useState26(false);
24344
+ const [isConfirmingDelete, setIsConfirmingDelete] = useState27(false);
24357
24345
  const { data: policyView, isLoading: isPolicyLoading } = useUserAssetsPolicies(activeChainId);
24358
24346
  const { mutate: cancelPending, isPending: isCancellingPending } = useMutation19({
24359
24347
  mutationFn: async () => {
@@ -24758,7 +24746,8 @@ function SenderSelector(props) {
24758
24746
  const {
24759
24747
  mutate: connectExternalWallet,
24760
24748
  isPending: isConnectingExternalWallet,
24761
- variables: pendingConnectVariables
24749
+ variables: pendingConnectVariables,
24750
+ isAvailable: isConnectExternalWalletAvailable
24762
24751
  } = useExternalWalletConnnect();
24763
24752
  const directWalletAddress = useExternalWalletStore((st) => st.externalAddress);
24764
24753
  const directWalletIsConnected = useExternalWalletStore((st) => st.isExternalConnected);
@@ -24771,7 +24760,7 @@ function SenderSelector(props) {
24771
24760
  variant: "secondary",
24772
24761
  size: "large",
24773
24762
  className: "justify-between",
24774
- disabled: isConnectingExternalWallet,
24763
+ disabled: !isConnectExternalWalletAvailable || isConnectingExternalWallet,
24775
24764
  onClick: async () => {
24776
24765
  switch (sender.type) {
24777
24766
  case "embarkai-wallet":
@@ -26293,11 +26282,11 @@ var init_checkbox = __esm({
26293
26282
 
26294
26283
  // src/internal/components/SendMenu/hyperbridge/steps/ConfirmStep.tsx
26295
26284
  import { LoaderIcon as LoaderIcon19 } from "lucide-react";
26296
- import { useState as useState27 } from "react";
26285
+ import { useState as useState28 } from "react";
26297
26286
  import { jsx as jsx113, jsxs as jsxs102 } from "react/jsx-runtime";
26298
26287
  function ConfirmStep(props) {
26299
26288
  const { isAssetBridging, bridgeAsset, hyperlaneWarpRoutes } = props;
26300
- const [userConsent, setUserConsent] = useState27(false);
26289
+ const [userConsent, setUserConsent] = useState28(false);
26301
26290
  const { t } = useT();
26302
26291
  const address = useSession((st) => st.address);
26303
26292
  const bridgeSender = useBridgeStore((st) => st.bridgeSenders.find((s) => s.type === st.bridgeSender));
@@ -27059,7 +27048,7 @@ var init_useErc3643Compliance = __esm({
27059
27048
 
27060
27049
  // src/hooks/useNicknameResolve.ts
27061
27050
  import { useQuery as useQuery26 } from "@tanstack/react-query";
27062
- import { useEffect as useEffect47, useMemo as useMemo18, useState as useState28 } from "react";
27051
+ import { useEffect as useEffect47, useMemo as useMemo18, useState as useState29 } from "react";
27063
27052
  function looksLikeNickname(input) {
27064
27053
  if (!input) return false;
27065
27054
  if (input.startsWith("0x")) return false;
@@ -27069,8 +27058,8 @@ function looksLikeNickname(input) {
27069
27058
  }
27070
27059
  function useNicknameResolve(input, options) {
27071
27060
  const { enabled = true, chainId } = options;
27072
- const [debouncedInput, setDebouncedInput] = useState28("");
27073
- const [isDebouncing, setIsDebouncing] = useState28(false);
27061
+ const [debouncedInput, setDebouncedInput] = useState29("");
27062
+ const [isDebouncing, setIsDebouncing] = useState29(false);
27074
27063
  const normalized = normalizeNickname(input);
27075
27064
  const isNicknameInput = looksLikeNickname(input) && normalized.length >= 3;
27076
27065
  useEffect47(() => {
@@ -27133,14 +27122,14 @@ var init_useNicknameResolve = __esm({
27133
27122
  });
27134
27123
 
27135
27124
  // src/hooks/useSendTransaction.ts
27136
- import { useCallback as useCallback30, useState as useState29 } from "react";
27125
+ import { useCallback as useCallback30, useState as useState30 } from "react";
27137
27126
  import { encodeFunctionData as encodeFunctionData2, isAddress as isAddress2, parseEther as parseEther2, parseUnits } from "viem";
27138
27127
  function useSendTransaction() {
27139
27128
  const session = useSession((st) => st.session);
27140
27129
  const address = useSession((st) => st.address);
27141
- const [isLoading, setIsLoading] = useState29(false);
27142
- const [error, setError] = useState29(null);
27143
- const [userOpHash, setUserOpHash] = useState29(null);
27130
+ const [isLoading, setIsLoading] = useState30(false);
27131
+ const [error, setError] = useState30(null);
27132
+ const [userOpHash, setUserOpHash] = useState30(null);
27144
27133
  const sendTransaction = useCallback30(
27145
27134
  async (params) => {
27146
27135
  if (!session || !address) {
@@ -27401,10 +27390,10 @@ var init_AssetInputIcon = __esm({
27401
27390
 
27402
27391
  // src/internal/components/SendMenu/send/components/NftDisplayCard.tsx
27403
27392
  import { Image as ImageIcon2, Sparkles as Sparkles2 } from "lucide-react";
27404
- import { useState as useState30 } from "react";
27393
+ import { useState as useState31 } from "react";
27405
27394
  import { jsx as jsx120, jsxs as jsxs108 } from "react/jsx-runtime";
27406
27395
  function NftDisplayCard({ asset }) {
27407
- const [imageError, setImageError] = useState30(false);
27396
+ const [imageError, setImageError] = useState31(false);
27408
27397
  const nftImage = asset.image || asset.nftMetadata?.image;
27409
27398
  return /* @__PURE__ */ jsxs108("div", { className: "flex items-center gap-3 p-3 rounded-[var(--ui-kit-el-bdrs)] bg-[var(--ui-kit-bg-secondary)]", children: [
27410
27399
  nftImage && !imageError ? /* @__PURE__ */ jsx120(
@@ -29367,7 +29356,7 @@ var init_TransactionsGroup = __esm({
29367
29356
  // src/internal/components/TransactionsMenu/TransactionsMenu.tsx
29368
29357
  import { useQuery as useQuery28, useQueryClient as useQueryClient28 } from "@tanstack/react-query";
29369
29358
  import { ArrowLeft as ArrowLeft22, Loader as Loader29, RefreshCw as RefreshCw3, XCircle as XCircle2 } from "lucide-react";
29370
- import { useCallback as useCallback31, useState as useState31 } from "react";
29359
+ import { useCallback as useCallback31, useState as useState32 } from "react";
29371
29360
  import { jsx as jsx128, jsxs as jsxs116 } from "react/jsx-runtime";
29372
29361
  function TransactionsMenu() {
29373
29362
  const qc = useQueryClient28();
@@ -29376,7 +29365,7 @@ function TransactionsMenu() {
29376
29365
  const { t } = useT();
29377
29366
  useOnboardingTourAvailable(true);
29378
29367
  const setPage = useLayoutDataStore((st) => st.setPage);
29379
- const [expandedGroups, setExpandedGroups] = useState31({});
29368
+ const [expandedGroups, setExpandedGroups] = useState32({});
29380
29369
  const historySupported = isTransactionHistorySupported(chainConfig?.id);
29381
29370
  const {
29382
29371
  data: txHistoryGroups = [],
@@ -29858,7 +29847,7 @@ var init_package = __esm({
29858
29847
  "package.json"() {
29859
29848
  package_default = {
29860
29849
  name: "@embarkai/ui-kit",
29861
- version: "0.4.103",
29850
+ version: "0.4.104",
29862
29851
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
29863
29852
  type: "module",
29864
29853
  main: "./dist/index.cjs",
@@ -30183,7 +30172,7 @@ var init_onborading_setup = __esm({
30183
30172
 
30184
30173
  // src/internal/components/Header/Header.tsx
30185
30174
  import { CircleQuestionMarkIcon, Copy as Copy4, Loader as Loader31 } from "lucide-react";
30186
- import { useCallback as useCallback33, useRef as useRef21, useState as useState32 } from "react";
30175
+ import { useCallback as useCallback33, useRef as useRef21, useState as useState33 } from "react";
30187
30176
  import { Fragment as Fragment46, jsx as jsx132, jsxs as jsxs119 } from "react/jsx-runtime";
30188
30177
  function formatAddress3(addr) {
30189
30178
  if (!addr) return "";
@@ -30196,8 +30185,8 @@ function Header() {
30196
30185
  const embarkPage = useLayoutDataStore((st) => st.page);
30197
30186
  const isOnboardingTourAvailable = useOnboardingStore((st) => st.isTourAvailable);
30198
30187
  const proMode = useProMode();
30199
- const [proToast, setProToast] = useState32(false);
30200
- const [copied, setCopied] = useState32(false);
30188
+ const [proToast, setProToast] = useState33(false);
30189
+ const [copied, setCopied] = useState33(false);
30201
30190
  const clickCountRef = useRef21(0);
30202
30191
  const clickTimerRef = useRef21(null);
30203
30192
  const handleAvatarClick = useCallback33(() => {
@@ -34046,12 +34035,12 @@ var Hash = ({
34046
34035
 
34047
34036
  // src/internal/components/TransactionsMenu/TransactionsList.tsx
34048
34037
  init_base3();
34049
- import { useEffect as useEffect59, useState as useState36 } from "react";
34038
+ import { useEffect as useEffect59, useState as useState37 } from "react";
34050
34039
  import { jsx as jsx144, jsxs as jsxs127 } from "react/jsx-runtime";
34051
34040
  var TransactionsList = ({ address, itemsCount = 10 }) => {
34052
- const [transactions, setTransactions] = useState36([]);
34053
- const [loading, setLoading] = useState36(true);
34054
- const [error, setError] = useState36(null);
34041
+ const [transactions, setTransactions] = useState37([]);
34042
+ const [loading, setLoading] = useState37(true);
34043
+ const [error, setError] = useState37(null);
34055
34044
  useEffect59(() => {
34056
34045
  const fetchTransactions2 = async () => {
34057
34046
  try {
@@ -34396,7 +34385,7 @@ function useDirectWallet() {
34396
34385
 
34397
34386
  // src/hooks/useSendDirectTransaction.ts
34398
34387
  init_useExternalWalletStore();
34399
- import { useCallback as useCallback40, useState as useState38 } from "react";
34388
+ import { useCallback as useCallback40, useState as useState39 } from "react";
34400
34389
  import { isAddress as isAddress4, parseEther as parseEther3 } from "viem";
34401
34390
  import { useSendTransaction as useWagmiSendTransaction, useSwitchChain as useSwitchChain3 } from "wagmi";
34402
34391
  function useSendDirectTransaction() {
@@ -34404,9 +34393,9 @@ function useSendDirectTransaction() {
34404
34393
  const externalChainId = useExternalWalletStore((st) => st.externalChainId);
34405
34394
  const { sendTransactionAsync } = useWagmiSendTransaction();
34406
34395
  const { switchChainAsync } = useSwitchChain3();
34407
- const [isPending, setIsPending] = useState38(false);
34408
- const [error, setError] = useState38(null);
34409
- const [txHash, setTxHash] = useState38(null);
34396
+ const [isPending, setIsPending] = useState39(false);
34397
+ const [error, setError] = useState39(null);
34398
+ const [txHash, setTxHash] = useState39(null);
34410
34399
  const sendTransaction = useCallback40(
34411
34400
  async (params) => {
34412
34401
  if (!isConnected) {
@@ -34453,7 +34442,7 @@ function useSendDirectTransaction() {
34453
34442
  init_SessionContext();
34454
34443
  init_account2();
34455
34444
  init_linkedProfiles();
34456
- import { useCallback as useCallback41, useMemo as useMemo23, useState as useState39 } from "react";
34445
+ import { useCallback as useCallback41, useMemo as useMemo23, useState as useState40 } from "react";
34457
34446
  import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress5, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
34458
34447
  var ERC20_TRANSFER_ABI2 = [
34459
34448
  {
@@ -34469,9 +34458,9 @@ var ERC20_TRANSFER_ABI2 = [
34469
34458
  function useTransferToLinkedWallet() {
34470
34459
  const session = useSession((st) => st.session);
34471
34460
  const { profiles } = useLinkedProfiles();
34472
- const [isPending, setIsPending] = useState39(false);
34473
- const [error, setError] = useState39(null);
34474
- const [userOpHash, setUserOpHash] = useState39(null);
34461
+ const [isPending, setIsPending] = useState40(false);
34462
+ const [error, setError] = useState40(null);
34463
+ const [userOpHash, setUserOpHash] = useState40(null);
34475
34464
  const linkedWallets = useMemo23(
34476
34465
  () => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
34477
34466
  [profiles]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embarkai/ui-kit",
3
- "version": "0.4.103",
3
+ "version": "0.4.104",
4
4
  "description": "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",