@embarkai/ui-kit 0.4.113 → 0.4.115
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/iframe/index.html +1 -1
- package/dist/iframe/main.js +1 -1
- package/dist/index.cjs +527 -426
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +224 -125
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11605,12 +11605,6 @@ var init_AuthMenu = __esm({
|
|
|
11605
11605
|
setAlert(null);
|
|
11606
11606
|
};
|
|
11607
11607
|
}, []);
|
|
11608
|
-
if (!isIframeReady) {
|
|
11609
|
-
return /* @__PURE__ */ jsxs20(Expandable, { isExpanded: true, className: "w-full p-8 flex flex-col justify-center items-center gap-[var(--ui-kit-gap)]", children: [
|
|
11610
|
-
/* @__PURE__ */ jsx26(Loader4, { className: "w-4 h-4 animate-spin" }),
|
|
11611
|
-
/* @__PURE__ */ jsx26("span", { className: "text-sm text-[var(--ui-kit-fg-muted)]", children: "Initializing wallet..." })
|
|
11612
|
-
] });
|
|
11613
|
-
}
|
|
11614
11608
|
const stepContent = useMemo2(
|
|
11615
11609
|
() => ({
|
|
11616
11610
|
"loading": /* @__PURE__ */ jsx26(LoadingStep, {}),
|
|
@@ -11628,6 +11622,12 @@ var init_AuthMenu = __esm({
|
|
|
11628
11622
|
}),
|
|
11629
11623
|
[onAuthSuccess, goBackToSignIn]
|
|
11630
11624
|
);
|
|
11625
|
+
if (!isIframeReady) {
|
|
11626
|
+
return /* @__PURE__ */ jsxs20(Expandable, { isExpanded: true, className: "w-full p-8 flex flex-col justify-center items-center gap-[var(--ui-kit-gap)]", children: [
|
|
11627
|
+
/* @__PURE__ */ jsx26(Loader4, { className: "w-4 h-4 animate-spin" }),
|
|
11628
|
+
/* @__PURE__ */ jsx26("span", { className: "text-sm text-[var(--ui-kit-fg-muted)]", children: "Initializing wallet..." })
|
|
11629
|
+
] });
|
|
11630
|
+
}
|
|
11631
11631
|
return /* @__PURE__ */ jsxs20(Expandable, { isExpanded: true, contentClassName: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: [
|
|
11632
11632
|
stepContent[step],
|
|
11633
11633
|
alert2 && /* @__PURE__ */ jsxs20(Highlight, { type: "error", children: [
|
|
@@ -15693,6 +15693,67 @@ var init_wallets = __esm({
|
|
|
15693
15693
|
}
|
|
15694
15694
|
});
|
|
15695
15695
|
|
|
15696
|
+
// src/internal/lib/disconnect-guard.ts
|
|
15697
|
+
function waitForReconnect(config) {
|
|
15698
|
+
if (config.state.status !== "reconnecting") return Promise.resolve();
|
|
15699
|
+
return new Promise((resolve) => {
|
|
15700
|
+
const unsubscribe = config.subscribe(
|
|
15701
|
+
(state) => state.status,
|
|
15702
|
+
(status) => {
|
|
15703
|
+
if (status === "reconnecting") return;
|
|
15704
|
+
unsubscribe();
|
|
15705
|
+
resolve();
|
|
15706
|
+
}
|
|
15707
|
+
);
|
|
15708
|
+
});
|
|
15709
|
+
}
|
|
15710
|
+
function hasUnusableCurrentConnector(config) {
|
|
15711
|
+
const { current, connections } = config.state;
|
|
15712
|
+
if (!current) return false;
|
|
15713
|
+
const connector = connections.get(current)?.connector;
|
|
15714
|
+
return !!connector && typeof connector.disconnect !== "function";
|
|
15715
|
+
}
|
|
15716
|
+
var init_disconnect_guard = __esm({
|
|
15717
|
+
"src/internal/lib/disconnect-guard.ts"() {
|
|
15718
|
+
}
|
|
15719
|
+
});
|
|
15720
|
+
|
|
15721
|
+
// src/internal/hooks/useSafeDisconnect.ts
|
|
15722
|
+
import { useCallback as useCallback15 } from "react";
|
|
15723
|
+
import { useConfig, useDisconnect } from "wagmi";
|
|
15724
|
+
function useSafeDisconnect(options) {
|
|
15725
|
+
const config = useConfig();
|
|
15726
|
+
const mutation = useDisconnect(options);
|
|
15727
|
+
const { mutateAsync } = mutation;
|
|
15728
|
+
const disconnectAsync = useCallback15(
|
|
15729
|
+
async (parameters) => {
|
|
15730
|
+
await waitForReconnect(config);
|
|
15731
|
+
if (!parameters?.connector && hasUnusableCurrentConnector(config)) return;
|
|
15732
|
+
await mutateAsync(parameters);
|
|
15733
|
+
},
|
|
15734
|
+
[config, mutateAsync]
|
|
15735
|
+
);
|
|
15736
|
+
const disconnect = useCallback15(
|
|
15737
|
+
(parameters) => {
|
|
15738
|
+
disconnectAsync(parameters).catch(() => {
|
|
15739
|
+
});
|
|
15740
|
+
},
|
|
15741
|
+
[disconnectAsync]
|
|
15742
|
+
);
|
|
15743
|
+
return {
|
|
15744
|
+
...mutation,
|
|
15745
|
+
mutate: disconnect,
|
|
15746
|
+
mutateAsync: disconnectAsync,
|
|
15747
|
+
disconnect,
|
|
15748
|
+
disconnectAsync
|
|
15749
|
+
};
|
|
15750
|
+
}
|
|
15751
|
+
var init_useSafeDisconnect = __esm({
|
|
15752
|
+
"src/internal/hooks/useSafeDisconnect.ts"() {
|
|
15753
|
+
init_disconnect_guard();
|
|
15754
|
+
}
|
|
15755
|
+
});
|
|
15756
|
+
|
|
15696
15757
|
// src/internal/lib/connect-errors.ts
|
|
15697
15758
|
function someInErrorChain(error, predicate) {
|
|
15698
15759
|
let current = error;
|
|
@@ -15802,7 +15863,7 @@ var init_common = __esm({
|
|
|
15802
15863
|
|
|
15803
15864
|
// src/modules/linkedProfiles.ts
|
|
15804
15865
|
import { useQuery as useQuery7, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
|
|
15805
|
-
import { useCallback as
|
|
15866
|
+
import { useCallback as useCallback16 } from "react";
|
|
15806
15867
|
function useLinkedProfiles() {
|
|
15807
15868
|
const qc = useQueryClient8();
|
|
15808
15869
|
const address = useSession((st) => st.address);
|
|
@@ -15826,7 +15887,7 @@ function useLinkedProfiles() {
|
|
|
15826
15887
|
}
|
|
15827
15888
|
});
|
|
15828
15889
|
const { profiles = [], avatar = null } = data || {};
|
|
15829
|
-
const refresh =
|
|
15890
|
+
const refresh = useCallback16(async () => {
|
|
15830
15891
|
await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
|
|
15831
15892
|
}, [qc, address]);
|
|
15832
15893
|
return { profiles, avatar, isLoading, isFetching, error, refresh };
|
|
@@ -16706,7 +16767,7 @@ var init_telegram2 = __esm({
|
|
|
16706
16767
|
|
|
16707
16768
|
// src/internal/components/ManageWalletMenu/hooks/useLinkTelegram.ts
|
|
16708
16769
|
import { useQueryClient as useQueryClient12 } from "@tanstack/react-query";
|
|
16709
|
-
import { useCallback as
|
|
16770
|
+
import { useCallback as useCallback17, useEffect as useEffect25, useState as useState12 } from "react";
|
|
16710
16771
|
function useLinkTelegram() {
|
|
16711
16772
|
const {
|
|
16712
16773
|
config: { current: config },
|
|
@@ -16716,7 +16777,7 @@ function useLinkTelegram() {
|
|
|
16716
16777
|
const address = useSession((st) => st.address);
|
|
16717
16778
|
const { providerType, linkIsLoading, setLinkIsLoading, setProviderType, setAlert } = useManageWalletStore();
|
|
16718
16779
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
16719
|
-
const handleLinkTelegram =
|
|
16780
|
+
const handleLinkTelegram = useCallback17(async () => {
|
|
16720
16781
|
try {
|
|
16721
16782
|
if (shouldBlockSocialAuthInTelegram("telegram")) {
|
|
16722
16783
|
setAlert(buildTelegramBrowserRestriction("Telegram", "linking"));
|
|
@@ -17147,13 +17208,12 @@ var init_ManageWallet = __esm({
|
|
|
17147
17208
|
import { useMutation as useMutation9, useQueryClient as useQueryClient13 } from "@tanstack/react-query";
|
|
17148
17209
|
import { Key as Key4, Loader as Loader10 } from "lucide-react";
|
|
17149
17210
|
import { useState as useState13 } from "react";
|
|
17150
|
-
import { useDisconnect } from "wagmi";
|
|
17151
17211
|
import { jsx as jsx73, jsxs as jsxs64 } from "react/jsx-runtime";
|
|
17152
17212
|
function UnlinkProviderMenu() {
|
|
17153
17213
|
const qc = useQueryClient13();
|
|
17154
17214
|
const address = useSession((st) => st.address);
|
|
17155
17215
|
const { callbacksRef } = useProviderConfig();
|
|
17156
|
-
const { disconnect: disconnectExternalWallet } =
|
|
17216
|
+
const { disconnect: disconnectExternalWallet } = useSafeDisconnect();
|
|
17157
17217
|
const isExternalConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
17158
17218
|
const { t } = useT();
|
|
17159
17219
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
@@ -17246,6 +17306,7 @@ var init_UnlinkProviderMenu = __esm({
|
|
|
17246
17306
|
init_ProviderContext();
|
|
17247
17307
|
init_SessionContext();
|
|
17248
17308
|
init_useT();
|
|
17309
|
+
init_useSafeDisconnect();
|
|
17249
17310
|
init_linkedProfiles();
|
|
17250
17311
|
init_auth();
|
|
17251
17312
|
init_useExternalWalletStore();
|
|
@@ -17327,13 +17388,13 @@ var init_useHasInjectedWallet = __esm({
|
|
|
17327
17388
|
// src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx
|
|
17328
17389
|
import { useMutation as useMutation10, useQuery as useQuery9, useQueryClient as useQueryClient14 } from "@tanstack/react-query";
|
|
17329
17390
|
import { ArrowLeft as ArrowLeft8, Loader as Loader11, Wallet2Icon as Wallet2Icon2 } from "lucide-react";
|
|
17330
|
-
import { useCallback as
|
|
17391
|
+
import { useCallback as useCallback18, useMemo as useMemo9, useState as useState14 } from "react";
|
|
17331
17392
|
import {
|
|
17332
|
-
|
|
17393
|
+
useChains,
|
|
17394
|
+
useConfig as useConfig2,
|
|
17333
17395
|
useConnect,
|
|
17334
17396
|
useConnections as useConnections2,
|
|
17335
17397
|
useConnectors,
|
|
17336
|
-
useDisconnect as useDisconnect2,
|
|
17337
17398
|
useSignMessage,
|
|
17338
17399
|
useSwitchChain,
|
|
17339
17400
|
useSwitchConnection
|
|
@@ -17356,9 +17417,10 @@ function ConnectExternalWalletMenu() {
|
|
|
17356
17417
|
const menuParams = useConnectExternalWalletMenuParams();
|
|
17357
17418
|
const connectors = useConnectors();
|
|
17358
17419
|
const hasInjectedWallet2 = useHasInjectedWallet();
|
|
17359
|
-
const wagmiConfig3 =
|
|
17420
|
+
const wagmiConfig3 = useConfig2();
|
|
17421
|
+
const chains = useChains();
|
|
17360
17422
|
const connections = useConnections2();
|
|
17361
|
-
const { mutate: disconnect, mutateAsync: disconnectAsync } =
|
|
17423
|
+
const { mutate: disconnect, mutateAsync: disconnectAsync } = useSafeDisconnect();
|
|
17362
17424
|
const { mutateAsync: signMessageAsync } = useSignMessage();
|
|
17363
17425
|
const { mutateAsync: switchChainAsync } = useSwitchChain();
|
|
17364
17426
|
const { mutateAsync: switchConnectionAsync } = useSwitchConnection();
|
|
@@ -17367,7 +17429,8 @@ function ConnectExternalWalletMenu() {
|
|
|
17367
17429
|
const { connector, account, message } = params;
|
|
17368
17430
|
const signOnce = async (viaFallback = false) => {
|
|
17369
17431
|
let chainId = await connector.getChainId();
|
|
17370
|
-
|
|
17432
|
+
const isUnsupportedMetaMaskChain = connector.type === "metaMask" && !chains.some((chain) => chain.id === chainId);
|
|
17433
|
+
if (viaFallback || isUnsupportedMetaMaskChain) {
|
|
17371
17434
|
await switchChainAsync({ connector, chainId: SIGN_FALLBACK_CHAIN_ID });
|
|
17372
17435
|
chainId = SIGN_FALLBACK_CHAIN_ID;
|
|
17373
17436
|
}
|
|
@@ -17560,7 +17623,7 @@ function ConnectExternalWalletMenu() {
|
|
|
17560
17623
|
(connector) => allowed.includes(connector.id.toLowerCase()) || allowed.includes(connector.name.toLowerCase())
|
|
17561
17624
|
);
|
|
17562
17625
|
}, [connectors, allowedWallets, hasInjectedWallet2]);
|
|
17563
|
-
const getInstructionSteps =
|
|
17626
|
+
const getInstructionSteps = useCallback18(() => {
|
|
17564
17627
|
const connectFlowType = getConnectFlowType({
|
|
17565
17628
|
isEmbarkAI: !!embarkAiAddress,
|
|
17566
17629
|
connectFlow: menuParams.current?.connectFlowType || "auth"
|
|
@@ -17676,6 +17739,7 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17676
17739
|
init_useOpenPage();
|
|
17677
17740
|
init_i18n();
|
|
17678
17741
|
init_wallets();
|
|
17742
|
+
init_useSafeDisconnect();
|
|
17679
17743
|
init_connect_errors();
|
|
17680
17744
|
init_linkedProfiles();
|
|
17681
17745
|
init_common();
|
|
@@ -17695,29 +17759,28 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17695
17759
|
|
|
17696
17760
|
// src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts
|
|
17697
17761
|
import { omit as omit2 } from "lodash-es";
|
|
17698
|
-
import { useCallback as
|
|
17762
|
+
import { useCallback as useCallback19 } from "react";
|
|
17699
17763
|
import {
|
|
17700
|
-
useConfig as
|
|
17764
|
+
useConfig as useConfig3,
|
|
17701
17765
|
useConnect as useConnect2,
|
|
17702
17766
|
useConnections as useConnections3,
|
|
17703
|
-
useConnectors as useConnectors2
|
|
17704
|
-
useDisconnect as useDisconnect3
|
|
17767
|
+
useConnectors as useConnectors2
|
|
17705
17768
|
} from "wagmi";
|
|
17706
17769
|
function useExternalWalletConnnect(options) {
|
|
17707
17770
|
const { onSuccess, onError } = options || {};
|
|
17708
17771
|
const { config } = useProviderConfig();
|
|
17709
17772
|
const walletMode = config.current?.wallet?.mode;
|
|
17710
|
-
const wagmiConfig3 =
|
|
17773
|
+
const wagmiConfig3 = useConfig3();
|
|
17711
17774
|
const connectors = useConnectors2();
|
|
17712
17775
|
const connections = useConnections3();
|
|
17713
17776
|
const { mutate: connect, mutateAsync: connectAsync, ...restUseConnect } = useConnect2();
|
|
17714
|
-
const { mutateAsync: disconnectAsync } =
|
|
17715
|
-
const disconnectExternalWallet =
|
|
17777
|
+
const { mutateAsync: disconnectAsync } = useSafeDisconnect();
|
|
17778
|
+
const disconnectExternalWallet = useCallback19(async () => {
|
|
17716
17779
|
await disconnectAsync();
|
|
17717
17780
|
const { externalAddress, clearExternalWallet } = useExternalWalletStore.getState();
|
|
17718
17781
|
if (!!externalAddress) clearExternalWallet();
|
|
17719
17782
|
}, [disconnectAsync]);
|
|
17720
|
-
const connectExternalWallet =
|
|
17783
|
+
const connectExternalWallet = useCallback19(
|
|
17721
17784
|
async (walletConnectorType) => {
|
|
17722
17785
|
const connector = connectors.find((c) => c.id === walletConnectorType);
|
|
17723
17786
|
if (!connector) {
|
|
@@ -17774,6 +17837,7 @@ function useExternalWalletConnnect(options) {
|
|
|
17774
17837
|
var init_useExternalWalletConnect = __esm({
|
|
17775
17838
|
"src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts"() {
|
|
17776
17839
|
init_ProviderContext();
|
|
17840
|
+
init_useSafeDisconnect();
|
|
17777
17841
|
init_useLayoutStore();
|
|
17778
17842
|
init_connect_errors();
|
|
17779
17843
|
init_useExternalWalletStore();
|
|
@@ -18441,7 +18505,7 @@ var init_guardian_backup = __esm({
|
|
|
18441
18505
|
|
|
18442
18506
|
// src/internal/components/DevicesMenu/DeviceManageScreen.tsx
|
|
18443
18507
|
import { ArrowLeft as ArrowLeft10, Cpu, Download, HardDrive, Loader2 as Loader23, Trash2, Upload } from "lucide-react";
|
|
18444
|
-
import { useCallback as
|
|
18508
|
+
import { useCallback as useCallback20, useEffect as useEffect27, useRef as useRef14, useState as useState16 } from "react";
|
|
18445
18509
|
import { Fragment as Fragment20, jsx as jsx76, jsxs as jsxs67 } from "react/jsx-runtime";
|
|
18446
18510
|
function formatSize(bytes) {
|
|
18447
18511
|
if (bytes < 1024) return `${bytes} B`;
|
|
@@ -18498,7 +18562,7 @@ function DeviceManageScreen() {
|
|
|
18498
18562
|
guardianRef.current?.close();
|
|
18499
18563
|
};
|
|
18500
18564
|
}, [deviceId]);
|
|
18501
|
-
const refreshList =
|
|
18565
|
+
const refreshList = useCallback20(async () => {
|
|
18502
18566
|
const guardian = guardianRef.current;
|
|
18503
18567
|
if (!guardian || screen.step !== "connected") return;
|
|
18504
18568
|
try {
|
|
@@ -18507,7 +18571,7 @@ function DeviceManageScreen() {
|
|
|
18507
18571
|
} catch {
|
|
18508
18572
|
}
|
|
18509
18573
|
}, [screen]);
|
|
18510
|
-
const handleBackup =
|
|
18574
|
+
const handleBackup = useCallback20(async () => {
|
|
18511
18575
|
const guardian = guardianRef.current;
|
|
18512
18576
|
const iframe6 = getIframeManager();
|
|
18513
18577
|
if (!guardian || !iframe6 || !userId) return;
|
|
@@ -18531,7 +18595,7 @@ function DeviceManageScreen() {
|
|
|
18531
18595
|
setActionState(null);
|
|
18532
18596
|
}
|
|
18533
18597
|
}, [password, userId, refreshList]);
|
|
18534
|
-
const handleOverwrite =
|
|
18598
|
+
const handleOverwrite = useCallback20(async () => {
|
|
18535
18599
|
const guardian = guardianRef.current;
|
|
18536
18600
|
const iframe6 = getIframeManager();
|
|
18537
18601
|
if (!guardian || !iframe6 || !userId) return;
|
|
@@ -18551,7 +18615,7 @@ function DeviceManageScreen() {
|
|
|
18551
18615
|
setActionState(null);
|
|
18552
18616
|
}
|
|
18553
18617
|
}, [password, userId, refreshList]);
|
|
18554
|
-
const handleDelete =
|
|
18618
|
+
const handleDelete = useCallback20(
|
|
18555
18619
|
async (keyshareId) => {
|
|
18556
18620
|
const guardian = guardianRef.current;
|
|
18557
18621
|
if (!guardian) return;
|
|
@@ -18751,7 +18815,7 @@ var init_DeviceManageScreen = __esm({
|
|
|
18751
18815
|
|
|
18752
18816
|
// src/internal/components/DevicesMenu/DeviceRestoreScreen.tsx
|
|
18753
18817
|
import { AlertTriangle as AlertTriangle2, ArrowLeft as ArrowLeft11, Download as Download2, Loader2 as Loader24 } from "lucide-react";
|
|
18754
|
-
import { useCallback as
|
|
18818
|
+
import { useCallback as useCallback21, useState as useState17 } from "react";
|
|
18755
18819
|
import { Fragment as Fragment21, jsx as jsx77, jsxs as jsxs68 } from "react/jsx-runtime";
|
|
18756
18820
|
function DeviceRestoreScreen() {
|
|
18757
18821
|
const setPage = useLayoutDataStore((s) => s.setPage);
|
|
@@ -18765,7 +18829,7 @@ function DeviceRestoreScreen() {
|
|
|
18765
18829
|
const [isWorking, setIsWorking] = useState17(false);
|
|
18766
18830
|
const [statusMessage, setStatusMessage] = useState17(null);
|
|
18767
18831
|
const [errorMessage, setErrorMessage] = useState17(null);
|
|
18768
|
-
const handleRestore =
|
|
18832
|
+
const handleRestore = useCallback21(async () => {
|
|
18769
18833
|
if (!password || !keyshareId || !userId) return;
|
|
18770
18834
|
const iframe6 = getIframeManager();
|
|
18771
18835
|
if (!iframe6) {
|
|
@@ -19016,7 +19080,7 @@ var init_useRestoreStore = __esm({
|
|
|
19016
19080
|
});
|
|
19017
19081
|
|
|
19018
19082
|
// src/internal/components/KeyshareRestoreMenu/hooks/useOnRestoreSuccess.ts
|
|
19019
|
-
import { useCallback as
|
|
19083
|
+
import { useCallback as useCallback22 } from "react";
|
|
19020
19084
|
function useOnRestoreSuccess() {
|
|
19021
19085
|
const { config, callbacksRef } = useProviderConfig();
|
|
19022
19086
|
const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
|
|
@@ -19032,7 +19096,7 @@ function useOnRestoreSuccess() {
|
|
|
19032
19096
|
setStatus
|
|
19033
19097
|
} = useSession();
|
|
19034
19098
|
const { setError, setSuccess } = useRestoreStore();
|
|
19035
|
-
const createSessionWithKeyshare =
|
|
19099
|
+
const createSessionWithKeyshare = useCallback22(
|
|
19036
19100
|
async (userId, hasServerKeyshare, isNewUser) => {
|
|
19037
19101
|
try {
|
|
19038
19102
|
try {
|
|
@@ -19073,7 +19137,7 @@ function useOnRestoreSuccess() {
|
|
|
19073
19137
|
},
|
|
19074
19138
|
[setStatus, usePaymaster, activeChainId, publicClient]
|
|
19075
19139
|
);
|
|
19076
|
-
const onRestoreSuccess =
|
|
19140
|
+
const onRestoreSuccess = useCallback22(async () => {
|
|
19077
19141
|
const { verifyToken: verifyToken2, jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
19078
19142
|
const verify = await verifyToken2();
|
|
19079
19143
|
const hasServerKeyshare = verify?.hasKeyshare ?? jwtTokenManager4.getHasKeyshare() ?? false;
|
|
@@ -19398,7 +19462,7 @@ var init_cloudStorage = __esm({
|
|
|
19398
19462
|
|
|
19399
19463
|
// src/internal/components/KeyshareRestoreMenu/hooks/useCreateBackup.ts
|
|
19400
19464
|
import { useMutation as useMutation12, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
|
|
19401
|
-
import { useCallback as
|
|
19465
|
+
import { useCallback as useCallback23, useEffect as useEffect28 } from "react";
|
|
19402
19466
|
function useCreateBackup() {
|
|
19403
19467
|
const qc = useQueryClient16();
|
|
19404
19468
|
const session = useSession((st) => st.session);
|
|
@@ -19415,7 +19479,7 @@ function useCreateBackup() {
|
|
|
19415
19479
|
}, [hasServerVault]);
|
|
19416
19480
|
const recoveryUserId = useSession((st) => st.recoveryUserId);
|
|
19417
19481
|
const passportUserId = session?.mpcUserId || recoveryUserId || "";
|
|
19418
|
-
const onBackupSuccess =
|
|
19482
|
+
const onBackupSuccess = useCallback23((method) => {
|
|
19419
19483
|
console.log(`[EMBARKAI BACKUP] ${method} backup created successfully`);
|
|
19420
19484
|
if (method !== "server") return;
|
|
19421
19485
|
const { setIsDialogForced } = useLayoutStore.getState();
|
|
@@ -20786,7 +20850,6 @@ var init_methods = __esm({
|
|
|
20786
20850
|
import { useMutation as useMutation14, useQuery as useQuery12, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
|
|
20787
20851
|
import { AlertCircle as AlertCircle2, CheckCircle2 as CheckCircle22, CloudDownload as CloudDownload2, Loader as Loader14, UserCircle as UserCircle2 } from "lucide-react";
|
|
20788
20852
|
import { useEffect as useEffect33 } from "react";
|
|
20789
|
-
import { useDisconnect as useDisconnect4 } from "wagmi";
|
|
20790
20853
|
import { Fragment as Fragment29, jsx as jsx87, jsxs as jsxs78 } from "react/jsx-runtime";
|
|
20791
20854
|
var RESTORE_COMPONENTS, KeyshareRestoreMenu;
|
|
20792
20855
|
var init_KeyshareRestoreMenu = __esm({
|
|
@@ -20794,6 +20857,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
20794
20857
|
init_ProviderContext();
|
|
20795
20858
|
init_SessionContext();
|
|
20796
20859
|
init_i18n();
|
|
20860
|
+
init_useSafeDisconnect();
|
|
20797
20861
|
init_useLayoutDataStore();
|
|
20798
20862
|
init_useLayoutStore();
|
|
20799
20863
|
init_useExternalWalletStore();
|
|
@@ -20834,7 +20898,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
20834
20898
|
setIsDialogForced(false);
|
|
20835
20899
|
};
|
|
20836
20900
|
}, []);
|
|
20837
|
-
const { mutate: wagmiDisconnect } =
|
|
20901
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
20838
20902
|
mutation: {
|
|
20839
20903
|
onSuccess: () => {
|
|
20840
20904
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -21838,7 +21902,7 @@ var init_utils9 = __esm({
|
|
|
21838
21902
|
// src/internal/hooks/useBlockscoutAssets/useBlockscoutAssets.ts
|
|
21839
21903
|
import { createBlockscoutClient as createBlockscoutClient2, nonBlockscoutClient } from "@embarkai/core";
|
|
21840
21904
|
import { useQuery as useQuery17, useQueryClient as useQueryClient19 } from "@tanstack/react-query";
|
|
21841
|
-
import { useCallback as
|
|
21905
|
+
import { useCallback as useCallback24, useMemo as useMemo13, useRef as useRef17 } from "react";
|
|
21842
21906
|
function useBlockscoutAssets(options) {
|
|
21843
21907
|
const { address, chainId, enabled = true, detectSecurityTokens = true } = options;
|
|
21844
21908
|
const qc = useQueryClient19();
|
|
@@ -22076,7 +22140,7 @@ function useBlockscoutAssets(options) {
|
|
|
22076
22140
|
if (!blockscoutError) return null;
|
|
22077
22141
|
return createError(blockscoutError);
|
|
22078
22142
|
}, [blockscoutError]);
|
|
22079
|
-
const refreshBalances =
|
|
22143
|
+
const refreshBalances = useCallback24(async () => {
|
|
22080
22144
|
const now = Date.now();
|
|
22081
22145
|
if (now - lastRefreshRef.current < BLOCKSCOUT_REFRESH_DEBOUNCE) {
|
|
22082
22146
|
return;
|
|
@@ -22092,7 +22156,7 @@ function useBlockscoutAssets(options) {
|
|
|
22092
22156
|
qc.invalidateQueries({ queryKey: [WATCH_TOKENS_QUERY_KEY] })
|
|
22093
22157
|
]);
|
|
22094
22158
|
}, [qc, customTokenBalancesQueryKey]);
|
|
22095
|
-
const getTokenBalance =
|
|
22159
|
+
const getTokenBalance = useCallback24(
|
|
22096
22160
|
(tokenAddress) => {
|
|
22097
22161
|
return assets.find((a) => a.address?.toLowerCase() === tokenAddress.toLowerCase()) || null;
|
|
22098
22162
|
},
|
|
@@ -22413,7 +22477,7 @@ var init_PortfolioItem = __esm({
|
|
|
22413
22477
|
// src/internal/components/PortfolioMenu/PortfolioMenu.tsx
|
|
22414
22478
|
import { useQueryClient as useQueryClient20 } from "@tanstack/react-query";
|
|
22415
22479
|
import { ArrowLeft as ArrowLeft17, Gem, Loader as Loader16, RefreshCw as RefreshCw2 } from "lucide-react";
|
|
22416
|
-
import { useCallback as
|
|
22480
|
+
import { useCallback as useCallback25 } from "react";
|
|
22417
22481
|
import { jsx as jsx95, jsxs as jsxs86 } from "react/jsx-runtime";
|
|
22418
22482
|
function PortfolioMenu() {
|
|
22419
22483
|
const { assets: projectAssets = [] } = useProviderConfig().config.current?.projectAssets || {};
|
|
@@ -22432,7 +22496,7 @@ function PortfolioMenu() {
|
|
|
22432
22496
|
enabled: !!address
|
|
22433
22497
|
});
|
|
22434
22498
|
const shownProjectAssets = projectAssets.filter((asset) => !asset.hideInPortfolio);
|
|
22435
|
-
const refreshAllAssetsBalances =
|
|
22499
|
+
const refreshAllAssetsBalances = useCallback25(() => {
|
|
22436
22500
|
Promise.all(shownProjectAssets.map((asset) => qc.invalidateQueries({ queryKey: asset.balanceQueryKey })));
|
|
22437
22501
|
refreshBlockscoutBalances();
|
|
22438
22502
|
}, [qc, shownProjectAssets, refreshBlockscoutBalances]);
|
|
@@ -22790,7 +22854,7 @@ var init_useNicknameStore = __esm({
|
|
|
22790
22854
|
// src/internal/components/NicknameMenu/useNicknameAvailability.ts
|
|
22791
22855
|
import { useMutation as useMutation15 } from "@tanstack/react-query";
|
|
22792
22856
|
import { debounce as debounce4 } from "lodash-es";
|
|
22793
|
-
import { useCallback as
|
|
22857
|
+
import { useCallback as useCallback26, useEffect as useEffect36 } from "react";
|
|
22794
22858
|
function useNicknameAvailability(currentNickname) {
|
|
22795
22859
|
const { t } = useT();
|
|
22796
22860
|
const nicknameValue = useNicknameStore((st) => st.nicknameValue);
|
|
@@ -22815,7 +22879,7 @@ function useNicknameAvailability(currentNickname) {
|
|
|
22815
22879
|
useNicknameStore.getState().setError(error?.message || "Failed to check nickname availability");
|
|
22816
22880
|
}
|
|
22817
22881
|
});
|
|
22818
|
-
const debouncedCheckAvailability =
|
|
22882
|
+
const debouncedCheckAvailability = useCallback26(debounce4(checkAvailability, DEBOUNCE_MS), [checkAvailability]);
|
|
22819
22883
|
useEffect36(() => {
|
|
22820
22884
|
if (!currentNickname) return;
|
|
22821
22885
|
const normalizedInputValue = normalizeNickname(nicknameValue);
|
|
@@ -22845,7 +22909,7 @@ var init_useNicknameAvailability = __esm({
|
|
|
22845
22909
|
// src/internal/components/NicknameMenu/NicknameEditForm.tsx
|
|
22846
22910
|
import { useMutation as useMutation16, useQueryClient as useQueryClient21 } from "@tanstack/react-query";
|
|
22847
22911
|
import { AtSignIcon, CopyIcon as CopyIcon2, LoaderIcon as LoaderIcon12, SaveIcon } from "lucide-react";
|
|
22848
|
-
import { useCallback as
|
|
22912
|
+
import { useCallback as useCallback27, useEffect as useEffect37, useRef as useRef18, useState as useState23 } from "react";
|
|
22849
22913
|
import { Fragment as Fragment34, jsx as jsx98, jsxs as jsxs89 } from "react/jsx-runtime";
|
|
22850
22914
|
function NicknameEditForm(props) {
|
|
22851
22915
|
const { isInitialUser, nicknameInfo } = props;
|
|
@@ -22894,7 +22958,7 @@ function NicknameEditForm(props) {
|
|
|
22894
22958
|
);
|
|
22895
22959
|
}
|
|
22896
22960
|
});
|
|
22897
|
-
const handleNicknameInputChange =
|
|
22961
|
+
const handleNicknameInputChange = useCallback27(
|
|
22898
22962
|
(e) => {
|
|
22899
22963
|
const { error, setError, setNicknameValue } = useNicknameStore.getState();
|
|
22900
22964
|
const nextInputValue = e.target.value;
|
|
@@ -22908,7 +22972,7 @@ function NicknameEditForm(props) {
|
|
|
22908
22972
|
},
|
|
22909
22973
|
[t]
|
|
22910
22974
|
);
|
|
22911
|
-
const handleSubmit =
|
|
22975
|
+
const handleSubmit = useCallback27(
|
|
22912
22976
|
(e) => {
|
|
22913
22977
|
const { nicknameValue: nicknameValue2, setError } = useNicknameStore.getState();
|
|
22914
22978
|
if (!canChange) {
|
|
@@ -24146,14 +24210,14 @@ var init_useUserAssetsPolicies = __esm({
|
|
|
24146
24210
|
// src/internal/components/SecurityMenu/UserPolicies/PolicyForm.tsx
|
|
24147
24211
|
import { useMutation as useMutation18, useQueryClient as useQueryClient23 } from "@tanstack/react-query";
|
|
24148
24212
|
import { ChevronRightIcon as ChevronRightIcon2, ChevronUpIcon as ChevronUpIcon2, LoaderIcon as LoaderIcon16, PlusIcon, TrashIcon } from "lucide-react";
|
|
24149
|
-
import { useCallback as
|
|
24213
|
+
import { useCallback as useCallback28, useState as useState26 } from "react";
|
|
24150
24214
|
import { Fragment as Fragment37, jsx as jsx106, jsxs as jsxs97 } from "react/jsx-runtime";
|
|
24151
24215
|
function AddressListEditor(props) {
|
|
24152
24216
|
const { label, assets = [], addresses, onChange } = props;
|
|
24153
24217
|
const [isAssetSelector, setIsAssetSelector] = useState26(false);
|
|
24154
24218
|
const [customAddress, setCustomAddress] = useState26("");
|
|
24155
24219
|
const [customAddressError, setCustomAddressError] = useState26(null);
|
|
24156
|
-
const handleAddress =
|
|
24220
|
+
const handleAddress = useCallback28(
|
|
24157
24221
|
(addressToAdd) => {
|
|
24158
24222
|
if (!isValidAddress(addressToAdd)) {
|
|
24159
24223
|
setCustomAddressError("Bad address");
|
|
@@ -25467,7 +25531,7 @@ var init_useOperationHashesStore = __esm({
|
|
|
25467
25531
|
|
|
25468
25532
|
// src/internal/components/SendMenu/hyperbridge/hooks/useBridge.ts
|
|
25469
25533
|
import { useMutation as useMutation20, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
|
|
25470
|
-
import { useCallback as
|
|
25534
|
+
import { useCallback as useCallback29 } from "react";
|
|
25471
25535
|
import { useSwitchChain as useSwitchChain2, useWalletClient } from "wagmi";
|
|
25472
25536
|
function useBridge() {
|
|
25473
25537
|
const qc = useQueryClient25();
|
|
@@ -25475,7 +25539,7 @@ function useBridge() {
|
|
|
25475
25539
|
const address = useSession((st) => st.address);
|
|
25476
25540
|
const { data: walletClient } = useWalletClient();
|
|
25477
25541
|
const { mutateAsync: switchChainAsync } = useSwitchChain2();
|
|
25478
|
-
const swapDirection =
|
|
25542
|
+
const swapDirection = useCallback29(() => {
|
|
25479
25543
|
const {
|
|
25480
25544
|
// bridgeStep,
|
|
25481
25545
|
originChain,
|
|
@@ -25526,7 +25590,7 @@ function useBridge() {
|
|
|
25526
25590
|
useFlowSelectorStore.getState().setError(error instanceof Error ? error.message : String(error));
|
|
25527
25591
|
}
|
|
25528
25592
|
});
|
|
25529
|
-
const handleQuoteEstimation =
|
|
25593
|
+
const handleQuoteEstimation = useCallback29((amnt) => {
|
|
25530
25594
|
const { originChain, destinationChain, bridgeSender } = useBridgeStore.getState();
|
|
25531
25595
|
if (!amnt || !Number(amnt)) {
|
|
25532
25596
|
useBridgeStore.getState().setQuote(null);
|
|
@@ -25944,7 +26008,7 @@ var init_ResolveChainIcon = __esm({
|
|
|
25944
26008
|
// src/internal/components/SendMenu/hyperbridge/hooks/useBridgeBalance.ts
|
|
25945
26009
|
import { CHAINS_BROWSERS_TRANSPORTS as CHAINS_BROWSERS_TRANSPORTS2 } from "@embarkai/core";
|
|
25946
26010
|
import { useQuery as useQuery25, useQueryClient as useQueryClient26 } from "@tanstack/react-query";
|
|
25947
|
-
import { useCallback as
|
|
26011
|
+
import { useCallback as useCallback30, useEffect as useEffect46 } from "react";
|
|
25948
26012
|
import { createPublicClient as createPublicClient2, erc20Abi as erc20Abi3, formatUnits as formatUnits9, http as http3 } from "viem";
|
|
25949
26013
|
import { useSwitchChain as useSwitchChain3 } from "wagmi";
|
|
25950
26014
|
function useBridgeBalance(isLoadingWarpRoutes, hyperlaneWarpRoutes) {
|
|
@@ -26034,7 +26098,7 @@ function useBridgeBalance(isLoadingWarpRoutes, hyperlaneWarpRoutes) {
|
|
|
26034
26098
|
};
|
|
26035
26099
|
}
|
|
26036
26100
|
});
|
|
26037
|
-
const refreshRouteTokenBalance =
|
|
26101
|
+
const refreshRouteTokenBalance = useCallback30(
|
|
26038
26102
|
(senderWallet) => {
|
|
26039
26103
|
switch (true) {
|
|
26040
26104
|
case senderWallet === "embarkai-wallet":
|
|
@@ -27250,7 +27314,7 @@ var init_useNicknameResolve = __esm({
|
|
|
27250
27314
|
});
|
|
27251
27315
|
|
|
27252
27316
|
// src/hooks/useSendTransaction.ts
|
|
27253
|
-
import { useCallback as
|
|
27317
|
+
import { useCallback as useCallback31, useState as useState30 } from "react";
|
|
27254
27318
|
import { encodeFunctionData as encodeFunctionData2, isAddress as isAddress2, parseEther as parseEther2, parseUnits } from "viem";
|
|
27255
27319
|
function useSendTransaction() {
|
|
27256
27320
|
const session = useSession((st) => st.session);
|
|
@@ -27258,7 +27322,7 @@ function useSendTransaction() {
|
|
|
27258
27322
|
const [isLoading, setIsLoading] = useState30(false);
|
|
27259
27323
|
const [error, setError] = useState30(null);
|
|
27260
27324
|
const [userOpHash, setUserOpHash] = useState30(null);
|
|
27261
|
-
const sendTransaction =
|
|
27325
|
+
const sendTransaction = useCallback31(
|
|
27262
27326
|
async (params) => {
|
|
27263
27327
|
if (!session || !address) {
|
|
27264
27328
|
setError("No active session");
|
|
@@ -27355,7 +27419,7 @@ function useSendTransaction() {
|
|
|
27355
27419
|
},
|
|
27356
27420
|
[session, address]
|
|
27357
27421
|
);
|
|
27358
|
-
const reset =
|
|
27422
|
+
const reset = useCallback31(() => {
|
|
27359
27423
|
setError(null);
|
|
27360
27424
|
setUserOpHash(null);
|
|
27361
27425
|
setIsLoading(false);
|
|
@@ -29484,7 +29548,7 @@ var init_TransactionsGroup = __esm({
|
|
|
29484
29548
|
// src/internal/components/TransactionsMenu/TransactionsMenu.tsx
|
|
29485
29549
|
import { useQuery as useQuery28, useQueryClient as useQueryClient28 } from "@tanstack/react-query";
|
|
29486
29550
|
import { ArrowLeft as ArrowLeft22, Loader as Loader29, RefreshCw as RefreshCw3, XCircle as XCircle2 } from "lucide-react";
|
|
29487
|
-
import { useCallback as
|
|
29551
|
+
import { useCallback as useCallback32, useState as useState32 } from "react";
|
|
29488
29552
|
import { jsx as jsx128, jsxs as jsxs116 } from "react/jsx-runtime";
|
|
29489
29553
|
function TransactionsMenu() {
|
|
29490
29554
|
const qc = useQueryClient28();
|
|
@@ -29506,7 +29570,7 @@ function TransactionsMenu() {
|
|
|
29506
29570
|
queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address],
|
|
29507
29571
|
queryFn: () => getTransactionsListQuery({ address, chainConfig })
|
|
29508
29572
|
});
|
|
29509
|
-
const refreshTxHistory =
|
|
29573
|
+
const refreshTxHistory = useCallback32(
|
|
29510
29574
|
() => qc.invalidateQueries({ queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address] }),
|
|
29511
29575
|
[qc, chainConfig.id, address]
|
|
29512
29576
|
);
|
|
@@ -29884,11 +29948,11 @@ var init_PageMap = __esm({
|
|
|
29884
29948
|
});
|
|
29885
29949
|
|
|
29886
29950
|
// src/internal/hooks/usePageMapper.tsx
|
|
29887
|
-
import { useCallback as
|
|
29951
|
+
import { useCallback as useCallback33, useEffect as useEffect53 } from "react";
|
|
29888
29952
|
import { jsx as jsx130 } from "react/jsx-runtime";
|
|
29889
29953
|
function usePageMapper() {
|
|
29890
29954
|
const page = useLayoutDataStore((st) => st.page);
|
|
29891
|
-
const closeDialog =
|
|
29955
|
+
const closeDialog = useCallback33(() => {
|
|
29892
29956
|
useLayoutStore.setState({ isDialogAnimating: true });
|
|
29893
29957
|
setTimeout(() => {
|
|
29894
29958
|
useLayoutStore.setState({
|
|
@@ -29900,7 +29964,7 @@ function usePageMapper() {
|
|
|
29900
29964
|
});
|
|
29901
29965
|
}, CLEAR_DIALOG_TIMEOUT);
|
|
29902
29966
|
}, []);
|
|
29903
|
-
const openDialog =
|
|
29967
|
+
const openDialog = useCallback33((pageItem) => {
|
|
29904
29968
|
useLayoutStore.setState({
|
|
29905
29969
|
dialogContent: /* @__PURE__ */ jsx130(pageItem.component, {}),
|
|
29906
29970
|
isDialogOpen: true
|
|
@@ -29975,7 +30039,7 @@ var init_package = __esm({
|
|
|
29975
30039
|
"package.json"() {
|
|
29976
30040
|
package_default = {
|
|
29977
30041
|
name: "@embarkai/ui-kit",
|
|
29978
|
-
version: "0.4.
|
|
30042
|
+
version: "0.4.115",
|
|
29979
30043
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
29980
30044
|
type: "module",
|
|
29981
30045
|
main: "./dist/index.cjs",
|
|
@@ -30081,7 +30145,6 @@ var init_package = __esm({
|
|
|
30081
30145
|
// src/internal/components/Footer/Footer.tsx
|
|
30082
30146
|
import { useMutation as useMutation22, useQueryClient as useQueryClient29 } from "@tanstack/react-query";
|
|
30083
30147
|
import { Loader as Loader30, LogOut } from "lucide-react";
|
|
30084
|
-
import { useDisconnect as useDisconnect5 } from "wagmi";
|
|
30085
30148
|
import { jsx as jsx131, jsxs as jsxs118 } from "react/jsx-runtime";
|
|
30086
30149
|
function Footer() {
|
|
30087
30150
|
const qc = useQueryClient29();
|
|
@@ -30090,7 +30153,7 @@ function Footer() {
|
|
|
30090
30153
|
const address = useSession((st) => st.address);
|
|
30091
30154
|
const chainConfig = useSession((st) => st.chainConfig);
|
|
30092
30155
|
const isDialogForced = useLayoutStore((st) => st.isDialogForced);
|
|
30093
|
-
const { mutate: wagmiDisconnect } =
|
|
30156
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
30094
30157
|
mutation: {
|
|
30095
30158
|
onSuccess: () => {
|
|
30096
30159
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -30204,6 +30267,7 @@ var init_Footer = __esm({
|
|
|
30204
30267
|
init_ProviderContext();
|
|
30205
30268
|
init_SessionContext();
|
|
30206
30269
|
init_i18n();
|
|
30270
|
+
init_useSafeDisconnect();
|
|
30207
30271
|
init_auth();
|
|
30208
30272
|
init_base3();
|
|
30209
30273
|
init_useLayoutDataStore();
|
|
@@ -30300,7 +30364,7 @@ var init_onborading_setup = __esm({
|
|
|
30300
30364
|
|
|
30301
30365
|
// src/internal/components/Header/Header.tsx
|
|
30302
30366
|
import { CircleQuestionMarkIcon, Copy as Copy4, Loader as Loader31 } from "lucide-react";
|
|
30303
|
-
import { useCallback as
|
|
30367
|
+
import { useCallback as useCallback34, useRef as useRef21, useState as useState33 } from "react";
|
|
30304
30368
|
import { Fragment as Fragment46, jsx as jsx132, jsxs as jsxs119 } from "react/jsx-runtime";
|
|
30305
30369
|
function formatAddress3(addr) {
|
|
30306
30370
|
if (!addr) return "";
|
|
@@ -30317,7 +30381,7 @@ function Header() {
|
|
|
30317
30381
|
const [copied, setCopied] = useState33(false);
|
|
30318
30382
|
const clickCountRef = useRef21(0);
|
|
30319
30383
|
const clickTimerRef = useRef21(null);
|
|
30320
|
-
const handleAvatarClick =
|
|
30384
|
+
const handleAvatarClick = useCallback34(() => {
|
|
30321
30385
|
clickCountRef.current += 1;
|
|
30322
30386
|
if (clickTimerRef.current) {
|
|
30323
30387
|
clearTimeout(clickTimerRef.current);
|
|
@@ -30742,8 +30806,10 @@ import { useConnection } from "wagmi";
|
|
|
30742
30806
|
function DirectWalletHandler() {
|
|
30743
30807
|
const walletMode = useProviderConfig().config.current?.wallet?.mode || "both";
|
|
30744
30808
|
const externalAddress = useExternalWalletStore((st) => st.externalAddress);
|
|
30809
|
+
const externalChainId = useExternalWalletStore((st) => st.externalChainId);
|
|
30810
|
+
const externalConnectorName = useExternalWalletStore((st) => st.connectorName);
|
|
30745
30811
|
const isExternalConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
30746
|
-
const { address, isConnected,
|
|
30812
|
+
const { address, isConnected, chainId, connector } = useConnection();
|
|
30747
30813
|
useEffect56(() => {
|
|
30748
30814
|
const { setConfigMode, setActiveMode } = useExternalWalletStore.getState();
|
|
30749
30815
|
setConfigMode(walletMode);
|
|
@@ -30754,14 +30820,21 @@ function DirectWalletHandler() {
|
|
|
30754
30820
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
30755
30821
|
return;
|
|
30756
30822
|
}
|
|
30757
|
-
if (isConnected
|
|
30758
|
-
|
|
30759
|
-
|
|
30760
|
-
|
|
30761
|
-
connectorName: connector.name || "Unknown Wallet"
|
|
30762
|
-
});
|
|
30823
|
+
if (!isConnected || !address || !connector || !chainId) return;
|
|
30824
|
+
const connectorName = connector.name || "Unknown Wallet";
|
|
30825
|
+
if (externalAddress !== address || externalChainId !== chainId || externalConnectorName !== connectorName) {
|
|
30826
|
+
useExternalWalletStore.getState().setExternalWallet({ address, chainId, connectorName });
|
|
30763
30827
|
}
|
|
30764
|
-
}, [
|
|
30828
|
+
}, [
|
|
30829
|
+
isConnected,
|
|
30830
|
+
address,
|
|
30831
|
+
isExternalConnected,
|
|
30832
|
+
externalAddress,
|
|
30833
|
+
externalChainId,
|
|
30834
|
+
externalConnectorName,
|
|
30835
|
+
connector,
|
|
30836
|
+
chainId
|
|
30837
|
+
]);
|
|
30765
30838
|
return null;
|
|
30766
30839
|
}
|
|
30767
30840
|
var init_DirectWalletHandler = __esm({
|
|
@@ -30772,7 +30845,7 @@ var init_DirectWalletHandler = __esm({
|
|
|
30772
30845
|
});
|
|
30773
30846
|
|
|
30774
30847
|
// src/internal/components/TssManager.tsx
|
|
30775
|
-
import React32, { useCallback as
|
|
30848
|
+
import React32, { useCallback as useCallback35 } from "react";
|
|
30776
30849
|
var TssManagerWithRef;
|
|
30777
30850
|
var init_TssManager = __esm({
|
|
30778
30851
|
"src/internal/components/TssManager.tsx"() {
|
|
@@ -30787,7 +30860,7 @@ var init_TssManager = __esm({
|
|
|
30787
30860
|
const setStatus = useSession((st) => st.setStatus);
|
|
30788
30861
|
const setSession = useSession((st) => st.setSession);
|
|
30789
30862
|
const setAddress = useSession((st) => st.setAddress);
|
|
30790
|
-
const onSessionCreated =
|
|
30863
|
+
const onSessionCreated = useCallback35(
|
|
30791
30864
|
(session, address) => {
|
|
30792
30865
|
setSession(session);
|
|
30793
30866
|
setAddress(address);
|
|
@@ -32238,7 +32311,7 @@ var init_iframe_manager = __esm({
|
|
|
32238
32311
|
*/
|
|
32239
32312
|
handleMessage(event) {
|
|
32240
32313
|
const message = event.data;
|
|
32241
|
-
if (!message || typeof message !== "object" || !message.type) {
|
|
32314
|
+
if (!message || typeof message !== "object" || typeof message.type !== "string" || !message.type) {
|
|
32242
32315
|
return;
|
|
32243
32316
|
}
|
|
32244
32317
|
message.type = this.normalizeMessageType(message.type);
|
|
@@ -33331,7 +33404,7 @@ import { initSdkErrorTracking } from "@embarkai/core/internal/error-tracking";
|
|
|
33331
33404
|
import { merge as merge3 } from "lodash-es";
|
|
33332
33405
|
import {
|
|
33333
33406
|
createContext,
|
|
33334
|
-
useCallback as
|
|
33407
|
+
useCallback as useCallback36,
|
|
33335
33408
|
useContext,
|
|
33336
33409
|
useEffect as useEffect57,
|
|
33337
33410
|
useMemo as useMemo21,
|
|
@@ -33360,7 +33433,7 @@ function Provider(props) {
|
|
|
33360
33433
|
useEffect57(() => notifyNoProjetctId(projectId), [projectId]);
|
|
33361
33434
|
const config = useRef22(merge3({}, DEFAULT_PROVIDER_CONFIG, { projectId }, initialConfig));
|
|
33362
33435
|
const wagmiConfig3 = useRef22(getWagmiConfig(config.current?.wallet?.walletConnectId || null));
|
|
33363
|
-
const updateConfig =
|
|
33436
|
+
const updateConfig = useCallback36((updates) => {
|
|
33364
33437
|
const prev = config.current;
|
|
33365
33438
|
const next = { ...prev };
|
|
33366
33439
|
if (updates.projectId !== void 0) next.projectId = updates.projectId;
|
|
@@ -33394,7 +33467,7 @@ function Provider(props) {
|
|
|
33394
33467
|
if (updates.translations) next.translations = { ...next.translations, ...updates.translations };
|
|
33395
33468
|
config.current = next;
|
|
33396
33469
|
}, []);
|
|
33397
|
-
const updateCallbacks =
|
|
33470
|
+
const updateCallbacks = useCallback36((updates) => {
|
|
33398
33471
|
const prev = callbacksRef.current;
|
|
33399
33472
|
const next = updates ? { ...prev, ...updates } : void 0;
|
|
33400
33473
|
callbacksRef.current = next;
|
|
@@ -34463,12 +34536,12 @@ init_useErc3643Compliance();
|
|
|
34463
34536
|
|
|
34464
34537
|
// src/hooks/useWalletMode.ts
|
|
34465
34538
|
init_useExternalWalletStore();
|
|
34466
|
-
import { useCallback as
|
|
34539
|
+
import { useCallback as useCallback39 } from "react";
|
|
34467
34540
|
function useWalletMode() {
|
|
34468
34541
|
const configMode = useExternalWalletStore((st) => st.configMode);
|
|
34469
34542
|
const activeMode = useExternalWalletStore((st) => st.activeMode);
|
|
34470
34543
|
const setActiveMode = useExternalWalletStore((st) => st.setActiveMode);
|
|
34471
|
-
const switchMode =
|
|
34544
|
+
const switchMode = useCallback39(
|
|
34472
34545
|
(mode) => {
|
|
34473
34546
|
if (configMode !== "both") return;
|
|
34474
34547
|
setActiveMode(mode);
|
|
@@ -34485,8 +34558,8 @@ function useWalletMode() {
|
|
|
34485
34558
|
|
|
34486
34559
|
// src/hooks/useDirectWallet.ts
|
|
34487
34560
|
init_useOpenPage();
|
|
34488
|
-
|
|
34489
|
-
import {
|
|
34561
|
+
init_useSafeDisconnect();
|
|
34562
|
+
import { useCallback as useCallback40 } from "react";
|
|
34490
34563
|
init_useExternalWalletStore();
|
|
34491
34564
|
function useDirectWallet() {
|
|
34492
34565
|
const address = useExternalWalletStore((st) => st.externalAddress);
|
|
@@ -34494,11 +34567,11 @@ function useDirectWallet() {
|
|
|
34494
34567
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
34495
34568
|
const connectorName = useExternalWalletStore((st) => st.connectorName);
|
|
34496
34569
|
const { open: openEmbarkAI } = useOpenPage();
|
|
34497
|
-
const { mutate: wagmiDisconnect } =
|
|
34498
|
-
const connect =
|
|
34570
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect();
|
|
34571
|
+
const connect = useCallback40((connectFlowType = "connect") => {
|
|
34499
34572
|
openEmbarkAI("connect-external-wallet" /* CONNECT_EXTERNAL_WALLET */, { connectFlowType });
|
|
34500
34573
|
}, []);
|
|
34501
|
-
const disconnect =
|
|
34574
|
+
const disconnect = useCallback40(() => {
|
|
34502
34575
|
wagmiDisconnect();
|
|
34503
34576
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
34504
34577
|
}, [wagmiDisconnect]);
|
|
@@ -34514,66 +34587,92 @@ function useDirectWallet() {
|
|
|
34514
34587
|
}
|
|
34515
34588
|
|
|
34516
34589
|
// src/hooks/useSendDirectTransaction.ts
|
|
34517
|
-
|
|
34518
|
-
import { useCallback as useCallback40, useState as useState39 } from "react";
|
|
34590
|
+
import { useCallback as useCallback41, useState as useState39 } from "react";
|
|
34519
34591
|
import { isAddress as isAddress4, parseEther as parseEther3 } from "viem";
|
|
34520
|
-
import {
|
|
34592
|
+
import { useConnection as useConnection2, useSwitchChain as useSwitchChain4, useSendTransaction as useWagmiSendTransaction } from "wagmi";
|
|
34593
|
+
|
|
34594
|
+
// src/internal/lib/direct-transaction.ts
|
|
34595
|
+
async function submitDirectTransaction(request, deps) {
|
|
34596
|
+
const { connector, switchChain, send } = deps;
|
|
34597
|
+
if (request.chainId) {
|
|
34598
|
+
const walletChainId = await connector.getChainId();
|
|
34599
|
+
if (walletChainId !== request.chainId) {
|
|
34600
|
+
await switchChain({ connector, chainId: request.chainId });
|
|
34601
|
+
}
|
|
34602
|
+
}
|
|
34603
|
+
return send({ ...request, connector });
|
|
34604
|
+
}
|
|
34605
|
+
|
|
34606
|
+
// src/hooks/useSendDirectTransaction.ts
|
|
34607
|
+
init_useExternalWalletStore();
|
|
34521
34608
|
function useSendDirectTransaction() {
|
|
34522
34609
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
34523
|
-
const
|
|
34524
|
-
const { sendTransactionAsync } = useWagmiSendTransaction();
|
|
34610
|
+
const { connector } = useConnection2();
|
|
34611
|
+
const { sendTransactionAsync: sendWagmiTransactionAsync } = useWagmiSendTransaction();
|
|
34525
34612
|
const { switchChainAsync } = useSwitchChain4();
|
|
34526
34613
|
const [isPending, setIsPending] = useState39(false);
|
|
34527
34614
|
const [error, setError] = useState39(null);
|
|
34528
34615
|
const [txHash, setTxHash] = useState39(null);
|
|
34529
|
-
const
|
|
34616
|
+
const sendTransactionAsync = useCallback41(
|
|
34530
34617
|
async (params) => {
|
|
34531
|
-
if (!isConnected) {
|
|
34532
|
-
|
|
34533
|
-
|
|
34618
|
+
if (!isConnected || !connector) {
|
|
34619
|
+
const message = "No external wallet connected";
|
|
34620
|
+
setError(message);
|
|
34621
|
+
throw new Error(message);
|
|
34534
34622
|
}
|
|
34535
34623
|
if (!isAddress4(params.to)) {
|
|
34536
|
-
|
|
34537
|
-
|
|
34624
|
+
const message = "Invalid recipient address";
|
|
34625
|
+
setError(message);
|
|
34626
|
+
throw new Error(message);
|
|
34538
34627
|
}
|
|
34539
34628
|
setIsPending(true);
|
|
34540
34629
|
setError(null);
|
|
34541
34630
|
setTxHash(null);
|
|
34542
34631
|
try {
|
|
34543
|
-
|
|
34544
|
-
|
|
34545
|
-
|
|
34546
|
-
|
|
34547
|
-
|
|
34548
|
-
|
|
34549
|
-
|
|
34550
|
-
|
|
34551
|
-
|
|
34632
|
+
const hash = await submitDirectTransaction(
|
|
34633
|
+
{
|
|
34634
|
+
to: params.to,
|
|
34635
|
+
value: parseEther3(params.value),
|
|
34636
|
+
data: params.data,
|
|
34637
|
+
chainId: params.chainId,
|
|
34638
|
+
gas: params.gas
|
|
34639
|
+
},
|
|
34640
|
+
{ connector, switchChain: switchChainAsync, send: sendWagmiTransactionAsync }
|
|
34641
|
+
);
|
|
34552
34642
|
setTxHash(hash);
|
|
34553
34643
|
return hash;
|
|
34554
34644
|
} catch (err) {
|
|
34555
|
-
|
|
34556
|
-
|
|
34557
|
-
return null;
|
|
34645
|
+
setError(err instanceof Error ? err.message : "Transaction failed");
|
|
34646
|
+
throw err;
|
|
34558
34647
|
} finally {
|
|
34559
34648
|
setIsPending(false);
|
|
34560
34649
|
}
|
|
34561
34650
|
},
|
|
34562
|
-
[isConnected,
|
|
34651
|
+
[isConnected, connector, sendWagmiTransactionAsync, switchChainAsync]
|
|
34563
34652
|
);
|
|
34564
|
-
const
|
|
34653
|
+
const sendTransaction = useCallback41(
|
|
34654
|
+
async (params) => {
|
|
34655
|
+
try {
|
|
34656
|
+
return await sendTransactionAsync(params);
|
|
34657
|
+
} catch {
|
|
34658
|
+
return null;
|
|
34659
|
+
}
|
|
34660
|
+
},
|
|
34661
|
+
[sendTransactionAsync]
|
|
34662
|
+
);
|
|
34663
|
+
const reset = useCallback41(() => {
|
|
34565
34664
|
setError(null);
|
|
34566
34665
|
setTxHash(null);
|
|
34567
34666
|
setIsPending(false);
|
|
34568
34667
|
}, []);
|
|
34569
|
-
return { sendTransaction, isPending, error, txHash, reset };
|
|
34668
|
+
return { sendTransaction, sendTransactionAsync, isPending, error, txHash, reset };
|
|
34570
34669
|
}
|
|
34571
34670
|
|
|
34572
34671
|
// src/hooks/useTransferToLinkedWallet.ts
|
|
34573
34672
|
init_SessionContext();
|
|
34574
34673
|
init_account2();
|
|
34575
34674
|
init_linkedProfiles();
|
|
34576
|
-
import { useCallback as
|
|
34675
|
+
import { useCallback as useCallback42, useMemo as useMemo23, useState as useState40 } from "react";
|
|
34577
34676
|
import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress5, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
|
|
34578
34677
|
var ERC20_TRANSFER_ABI2 = [
|
|
34579
34678
|
{
|
|
@@ -34596,7 +34695,7 @@ function useTransferToLinkedWallet() {
|
|
|
34596
34695
|
() => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
|
|
34597
34696
|
[profiles]
|
|
34598
34697
|
);
|
|
34599
|
-
const transfer =
|
|
34698
|
+
const transfer = useCallback42(
|
|
34600
34699
|
async (params) => {
|
|
34601
34700
|
if (!session) {
|
|
34602
34701
|
setError("No active session");
|
|
@@ -34647,7 +34746,7 @@ function useTransferToLinkedWallet() {
|
|
|
34647
34746
|
},
|
|
34648
34747
|
[session, linkedWallets]
|
|
34649
34748
|
);
|
|
34650
|
-
const reset =
|
|
34749
|
+
const reset = useCallback42(() => {
|
|
34651
34750
|
setError(null);
|
|
34652
34751
|
setUserOpHash(null);
|
|
34653
34752
|
setIsPending(false);
|
|
@@ -34670,16 +34769,16 @@ function useNativeWalletSignature() {
|
|
|
34670
34769
|
}
|
|
34671
34770
|
|
|
34672
34771
|
// src/hooks/useLogout.ts
|
|
34772
|
+
init_useSafeDisconnect();
|
|
34673
34773
|
init_ProviderContext();
|
|
34674
34774
|
init_SessionContext();
|
|
34675
34775
|
init_useExternalWalletStore();
|
|
34676
34776
|
import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
|
|
34677
|
-
import { useCallback as
|
|
34678
|
-
import { useDisconnect as useDisconnect7 } from "wagmi";
|
|
34777
|
+
import { useCallback as useCallback43 } from "react";
|
|
34679
34778
|
function useLogout() {
|
|
34680
34779
|
const { callbacksRef } = useProviderConfig();
|
|
34681
34780
|
const address = useSession((st) => st.address);
|
|
34682
|
-
const { mutate: wagmiDisconnect } =
|
|
34781
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
34683
34782
|
mutation: {
|
|
34684
34783
|
onSuccess: () => {
|
|
34685
34784
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -34690,7 +34789,7 @@ function useLogout() {
|
|
|
34690
34789
|
}
|
|
34691
34790
|
}
|
|
34692
34791
|
});
|
|
34693
|
-
const logout2 =
|
|
34792
|
+
const logout2 = useCallback43(async () => {
|
|
34694
34793
|
const { setSession, setIsLoading, setAddress, setStatus, setError } = useSession.getState();
|
|
34695
34794
|
const prevAddress = address;
|
|
34696
34795
|
let userId = null;
|