@embarkai/ui-kit 0.4.114 → 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 +464 -400
- package/dist/index.js +155 -94
- 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,14 +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,
|
|
17333
|
-
useConfig,
|
|
17394
|
+
useConfig as useConfig2,
|
|
17334
17395
|
useConnect,
|
|
17335
17396
|
useConnections as useConnections2,
|
|
17336
17397
|
useConnectors,
|
|
17337
|
-
useDisconnect as useDisconnect2,
|
|
17338
17398
|
useSignMessage,
|
|
17339
17399
|
useSwitchChain,
|
|
17340
17400
|
useSwitchConnection
|
|
@@ -17357,10 +17417,10 @@ function ConnectExternalWalletMenu() {
|
|
|
17357
17417
|
const menuParams = useConnectExternalWalletMenuParams();
|
|
17358
17418
|
const connectors = useConnectors();
|
|
17359
17419
|
const hasInjectedWallet2 = useHasInjectedWallet();
|
|
17360
|
-
const wagmiConfig3 =
|
|
17420
|
+
const wagmiConfig3 = useConfig2();
|
|
17361
17421
|
const chains = useChains();
|
|
17362
17422
|
const connections = useConnections2();
|
|
17363
|
-
const { mutate: disconnect, mutateAsync: disconnectAsync } =
|
|
17423
|
+
const { mutate: disconnect, mutateAsync: disconnectAsync } = useSafeDisconnect();
|
|
17364
17424
|
const { mutateAsync: signMessageAsync } = useSignMessage();
|
|
17365
17425
|
const { mutateAsync: switchChainAsync } = useSwitchChain();
|
|
17366
17426
|
const { mutateAsync: switchConnectionAsync } = useSwitchConnection();
|
|
@@ -17563,7 +17623,7 @@ function ConnectExternalWalletMenu() {
|
|
|
17563
17623
|
(connector) => allowed.includes(connector.id.toLowerCase()) || allowed.includes(connector.name.toLowerCase())
|
|
17564
17624
|
);
|
|
17565
17625
|
}, [connectors, allowedWallets, hasInjectedWallet2]);
|
|
17566
|
-
const getInstructionSteps =
|
|
17626
|
+
const getInstructionSteps = useCallback18(() => {
|
|
17567
17627
|
const connectFlowType = getConnectFlowType({
|
|
17568
17628
|
isEmbarkAI: !!embarkAiAddress,
|
|
17569
17629
|
connectFlow: menuParams.current?.connectFlowType || "auth"
|
|
@@ -17679,6 +17739,7 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17679
17739
|
init_useOpenPage();
|
|
17680
17740
|
init_i18n();
|
|
17681
17741
|
init_wallets();
|
|
17742
|
+
init_useSafeDisconnect();
|
|
17682
17743
|
init_connect_errors();
|
|
17683
17744
|
init_linkedProfiles();
|
|
17684
17745
|
init_common();
|
|
@@ -17698,29 +17759,28 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17698
17759
|
|
|
17699
17760
|
// src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts
|
|
17700
17761
|
import { omit as omit2 } from "lodash-es";
|
|
17701
|
-
import { useCallback as
|
|
17762
|
+
import { useCallback as useCallback19 } from "react";
|
|
17702
17763
|
import {
|
|
17703
|
-
useConfig as
|
|
17764
|
+
useConfig as useConfig3,
|
|
17704
17765
|
useConnect as useConnect2,
|
|
17705
17766
|
useConnections as useConnections3,
|
|
17706
|
-
useConnectors as useConnectors2
|
|
17707
|
-
useDisconnect as useDisconnect3
|
|
17767
|
+
useConnectors as useConnectors2
|
|
17708
17768
|
} from "wagmi";
|
|
17709
17769
|
function useExternalWalletConnnect(options) {
|
|
17710
17770
|
const { onSuccess, onError } = options || {};
|
|
17711
17771
|
const { config } = useProviderConfig();
|
|
17712
17772
|
const walletMode = config.current?.wallet?.mode;
|
|
17713
|
-
const wagmiConfig3 =
|
|
17773
|
+
const wagmiConfig3 = useConfig3();
|
|
17714
17774
|
const connectors = useConnectors2();
|
|
17715
17775
|
const connections = useConnections3();
|
|
17716
17776
|
const { mutate: connect, mutateAsync: connectAsync, ...restUseConnect } = useConnect2();
|
|
17717
|
-
const { mutateAsync: disconnectAsync } =
|
|
17718
|
-
const disconnectExternalWallet =
|
|
17777
|
+
const { mutateAsync: disconnectAsync } = useSafeDisconnect();
|
|
17778
|
+
const disconnectExternalWallet = useCallback19(async () => {
|
|
17719
17779
|
await disconnectAsync();
|
|
17720
17780
|
const { externalAddress, clearExternalWallet } = useExternalWalletStore.getState();
|
|
17721
17781
|
if (!!externalAddress) clearExternalWallet();
|
|
17722
17782
|
}, [disconnectAsync]);
|
|
17723
|
-
const connectExternalWallet =
|
|
17783
|
+
const connectExternalWallet = useCallback19(
|
|
17724
17784
|
async (walletConnectorType) => {
|
|
17725
17785
|
const connector = connectors.find((c) => c.id === walletConnectorType);
|
|
17726
17786
|
if (!connector) {
|
|
@@ -17777,6 +17837,7 @@ function useExternalWalletConnnect(options) {
|
|
|
17777
17837
|
var init_useExternalWalletConnect = __esm({
|
|
17778
17838
|
"src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts"() {
|
|
17779
17839
|
init_ProviderContext();
|
|
17840
|
+
init_useSafeDisconnect();
|
|
17780
17841
|
init_useLayoutStore();
|
|
17781
17842
|
init_connect_errors();
|
|
17782
17843
|
init_useExternalWalletStore();
|
|
@@ -18444,7 +18505,7 @@ var init_guardian_backup = __esm({
|
|
|
18444
18505
|
|
|
18445
18506
|
// src/internal/components/DevicesMenu/DeviceManageScreen.tsx
|
|
18446
18507
|
import { ArrowLeft as ArrowLeft10, Cpu, Download, HardDrive, Loader2 as Loader23, Trash2, Upload } from "lucide-react";
|
|
18447
|
-
import { useCallback as
|
|
18508
|
+
import { useCallback as useCallback20, useEffect as useEffect27, useRef as useRef14, useState as useState16 } from "react";
|
|
18448
18509
|
import { Fragment as Fragment20, jsx as jsx76, jsxs as jsxs67 } from "react/jsx-runtime";
|
|
18449
18510
|
function formatSize(bytes) {
|
|
18450
18511
|
if (bytes < 1024) return `${bytes} B`;
|
|
@@ -18501,7 +18562,7 @@ function DeviceManageScreen() {
|
|
|
18501
18562
|
guardianRef.current?.close();
|
|
18502
18563
|
};
|
|
18503
18564
|
}, [deviceId]);
|
|
18504
|
-
const refreshList =
|
|
18565
|
+
const refreshList = useCallback20(async () => {
|
|
18505
18566
|
const guardian = guardianRef.current;
|
|
18506
18567
|
if (!guardian || screen.step !== "connected") return;
|
|
18507
18568
|
try {
|
|
@@ -18510,7 +18571,7 @@ function DeviceManageScreen() {
|
|
|
18510
18571
|
} catch {
|
|
18511
18572
|
}
|
|
18512
18573
|
}, [screen]);
|
|
18513
|
-
const handleBackup =
|
|
18574
|
+
const handleBackup = useCallback20(async () => {
|
|
18514
18575
|
const guardian = guardianRef.current;
|
|
18515
18576
|
const iframe6 = getIframeManager();
|
|
18516
18577
|
if (!guardian || !iframe6 || !userId) return;
|
|
@@ -18534,7 +18595,7 @@ function DeviceManageScreen() {
|
|
|
18534
18595
|
setActionState(null);
|
|
18535
18596
|
}
|
|
18536
18597
|
}, [password, userId, refreshList]);
|
|
18537
|
-
const handleOverwrite =
|
|
18598
|
+
const handleOverwrite = useCallback20(async () => {
|
|
18538
18599
|
const guardian = guardianRef.current;
|
|
18539
18600
|
const iframe6 = getIframeManager();
|
|
18540
18601
|
if (!guardian || !iframe6 || !userId) return;
|
|
@@ -18554,7 +18615,7 @@ function DeviceManageScreen() {
|
|
|
18554
18615
|
setActionState(null);
|
|
18555
18616
|
}
|
|
18556
18617
|
}, [password, userId, refreshList]);
|
|
18557
|
-
const handleDelete =
|
|
18618
|
+
const handleDelete = useCallback20(
|
|
18558
18619
|
async (keyshareId) => {
|
|
18559
18620
|
const guardian = guardianRef.current;
|
|
18560
18621
|
if (!guardian) return;
|
|
@@ -18754,7 +18815,7 @@ var init_DeviceManageScreen = __esm({
|
|
|
18754
18815
|
|
|
18755
18816
|
// src/internal/components/DevicesMenu/DeviceRestoreScreen.tsx
|
|
18756
18817
|
import { AlertTriangle as AlertTriangle2, ArrowLeft as ArrowLeft11, Download as Download2, Loader2 as Loader24 } from "lucide-react";
|
|
18757
|
-
import { useCallback as
|
|
18818
|
+
import { useCallback as useCallback21, useState as useState17 } from "react";
|
|
18758
18819
|
import { Fragment as Fragment21, jsx as jsx77, jsxs as jsxs68 } from "react/jsx-runtime";
|
|
18759
18820
|
function DeviceRestoreScreen() {
|
|
18760
18821
|
const setPage = useLayoutDataStore((s) => s.setPage);
|
|
@@ -18768,7 +18829,7 @@ function DeviceRestoreScreen() {
|
|
|
18768
18829
|
const [isWorking, setIsWorking] = useState17(false);
|
|
18769
18830
|
const [statusMessage, setStatusMessage] = useState17(null);
|
|
18770
18831
|
const [errorMessage, setErrorMessage] = useState17(null);
|
|
18771
|
-
const handleRestore =
|
|
18832
|
+
const handleRestore = useCallback21(async () => {
|
|
18772
18833
|
if (!password || !keyshareId || !userId) return;
|
|
18773
18834
|
const iframe6 = getIframeManager();
|
|
18774
18835
|
if (!iframe6) {
|
|
@@ -19019,7 +19080,7 @@ var init_useRestoreStore = __esm({
|
|
|
19019
19080
|
});
|
|
19020
19081
|
|
|
19021
19082
|
// src/internal/components/KeyshareRestoreMenu/hooks/useOnRestoreSuccess.ts
|
|
19022
|
-
import { useCallback as
|
|
19083
|
+
import { useCallback as useCallback22 } from "react";
|
|
19023
19084
|
function useOnRestoreSuccess() {
|
|
19024
19085
|
const { config, callbacksRef } = useProviderConfig();
|
|
19025
19086
|
const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
|
|
@@ -19035,7 +19096,7 @@ function useOnRestoreSuccess() {
|
|
|
19035
19096
|
setStatus
|
|
19036
19097
|
} = useSession();
|
|
19037
19098
|
const { setError, setSuccess } = useRestoreStore();
|
|
19038
|
-
const createSessionWithKeyshare =
|
|
19099
|
+
const createSessionWithKeyshare = useCallback22(
|
|
19039
19100
|
async (userId, hasServerKeyshare, isNewUser) => {
|
|
19040
19101
|
try {
|
|
19041
19102
|
try {
|
|
@@ -19076,7 +19137,7 @@ function useOnRestoreSuccess() {
|
|
|
19076
19137
|
},
|
|
19077
19138
|
[setStatus, usePaymaster, activeChainId, publicClient]
|
|
19078
19139
|
);
|
|
19079
|
-
const onRestoreSuccess =
|
|
19140
|
+
const onRestoreSuccess = useCallback22(async () => {
|
|
19080
19141
|
const { verifyToken: verifyToken2, jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
19081
19142
|
const verify = await verifyToken2();
|
|
19082
19143
|
const hasServerKeyshare = verify?.hasKeyshare ?? jwtTokenManager4.getHasKeyshare() ?? false;
|
|
@@ -19401,7 +19462,7 @@ var init_cloudStorage = __esm({
|
|
|
19401
19462
|
|
|
19402
19463
|
// src/internal/components/KeyshareRestoreMenu/hooks/useCreateBackup.ts
|
|
19403
19464
|
import { useMutation as useMutation12, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
|
|
19404
|
-
import { useCallback as
|
|
19465
|
+
import { useCallback as useCallback23, useEffect as useEffect28 } from "react";
|
|
19405
19466
|
function useCreateBackup() {
|
|
19406
19467
|
const qc = useQueryClient16();
|
|
19407
19468
|
const session = useSession((st) => st.session);
|
|
@@ -19418,7 +19479,7 @@ function useCreateBackup() {
|
|
|
19418
19479
|
}, [hasServerVault]);
|
|
19419
19480
|
const recoveryUserId = useSession((st) => st.recoveryUserId);
|
|
19420
19481
|
const passportUserId = session?.mpcUserId || recoveryUserId || "";
|
|
19421
|
-
const onBackupSuccess =
|
|
19482
|
+
const onBackupSuccess = useCallback23((method) => {
|
|
19422
19483
|
console.log(`[EMBARKAI BACKUP] ${method} backup created successfully`);
|
|
19423
19484
|
if (method !== "server") return;
|
|
19424
19485
|
const { setIsDialogForced } = useLayoutStore.getState();
|
|
@@ -20789,7 +20850,6 @@ var init_methods = __esm({
|
|
|
20789
20850
|
import { useMutation as useMutation14, useQuery as useQuery12, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
|
|
20790
20851
|
import { AlertCircle as AlertCircle2, CheckCircle2 as CheckCircle22, CloudDownload as CloudDownload2, Loader as Loader14, UserCircle as UserCircle2 } from "lucide-react";
|
|
20791
20852
|
import { useEffect as useEffect33 } from "react";
|
|
20792
|
-
import { useDisconnect as useDisconnect4 } from "wagmi";
|
|
20793
20853
|
import { Fragment as Fragment29, jsx as jsx87, jsxs as jsxs78 } from "react/jsx-runtime";
|
|
20794
20854
|
var RESTORE_COMPONENTS, KeyshareRestoreMenu;
|
|
20795
20855
|
var init_KeyshareRestoreMenu = __esm({
|
|
@@ -20797,6 +20857,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
20797
20857
|
init_ProviderContext();
|
|
20798
20858
|
init_SessionContext();
|
|
20799
20859
|
init_i18n();
|
|
20860
|
+
init_useSafeDisconnect();
|
|
20800
20861
|
init_useLayoutDataStore();
|
|
20801
20862
|
init_useLayoutStore();
|
|
20802
20863
|
init_useExternalWalletStore();
|
|
@@ -20837,7 +20898,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
20837
20898
|
setIsDialogForced(false);
|
|
20838
20899
|
};
|
|
20839
20900
|
}, []);
|
|
20840
|
-
const { mutate: wagmiDisconnect } =
|
|
20901
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
20841
20902
|
mutation: {
|
|
20842
20903
|
onSuccess: () => {
|
|
20843
20904
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -21841,7 +21902,7 @@ var init_utils9 = __esm({
|
|
|
21841
21902
|
// src/internal/hooks/useBlockscoutAssets/useBlockscoutAssets.ts
|
|
21842
21903
|
import { createBlockscoutClient as createBlockscoutClient2, nonBlockscoutClient } from "@embarkai/core";
|
|
21843
21904
|
import { useQuery as useQuery17, useQueryClient as useQueryClient19 } from "@tanstack/react-query";
|
|
21844
|
-
import { useCallback as
|
|
21905
|
+
import { useCallback as useCallback24, useMemo as useMemo13, useRef as useRef17 } from "react";
|
|
21845
21906
|
function useBlockscoutAssets(options) {
|
|
21846
21907
|
const { address, chainId, enabled = true, detectSecurityTokens = true } = options;
|
|
21847
21908
|
const qc = useQueryClient19();
|
|
@@ -22079,7 +22140,7 @@ function useBlockscoutAssets(options) {
|
|
|
22079
22140
|
if (!blockscoutError) return null;
|
|
22080
22141
|
return createError(blockscoutError);
|
|
22081
22142
|
}, [blockscoutError]);
|
|
22082
|
-
const refreshBalances =
|
|
22143
|
+
const refreshBalances = useCallback24(async () => {
|
|
22083
22144
|
const now = Date.now();
|
|
22084
22145
|
if (now - lastRefreshRef.current < BLOCKSCOUT_REFRESH_DEBOUNCE) {
|
|
22085
22146
|
return;
|
|
@@ -22095,7 +22156,7 @@ function useBlockscoutAssets(options) {
|
|
|
22095
22156
|
qc.invalidateQueries({ queryKey: [WATCH_TOKENS_QUERY_KEY] })
|
|
22096
22157
|
]);
|
|
22097
22158
|
}, [qc, customTokenBalancesQueryKey]);
|
|
22098
|
-
const getTokenBalance =
|
|
22159
|
+
const getTokenBalance = useCallback24(
|
|
22099
22160
|
(tokenAddress) => {
|
|
22100
22161
|
return assets.find((a) => a.address?.toLowerCase() === tokenAddress.toLowerCase()) || null;
|
|
22101
22162
|
},
|
|
@@ -22416,7 +22477,7 @@ var init_PortfolioItem = __esm({
|
|
|
22416
22477
|
// src/internal/components/PortfolioMenu/PortfolioMenu.tsx
|
|
22417
22478
|
import { useQueryClient as useQueryClient20 } from "@tanstack/react-query";
|
|
22418
22479
|
import { ArrowLeft as ArrowLeft17, Gem, Loader as Loader16, RefreshCw as RefreshCw2 } from "lucide-react";
|
|
22419
|
-
import { useCallback as
|
|
22480
|
+
import { useCallback as useCallback25 } from "react";
|
|
22420
22481
|
import { jsx as jsx95, jsxs as jsxs86 } from "react/jsx-runtime";
|
|
22421
22482
|
function PortfolioMenu() {
|
|
22422
22483
|
const { assets: projectAssets = [] } = useProviderConfig().config.current?.projectAssets || {};
|
|
@@ -22435,7 +22496,7 @@ function PortfolioMenu() {
|
|
|
22435
22496
|
enabled: !!address
|
|
22436
22497
|
});
|
|
22437
22498
|
const shownProjectAssets = projectAssets.filter((asset) => !asset.hideInPortfolio);
|
|
22438
|
-
const refreshAllAssetsBalances =
|
|
22499
|
+
const refreshAllAssetsBalances = useCallback25(() => {
|
|
22439
22500
|
Promise.all(shownProjectAssets.map((asset) => qc.invalidateQueries({ queryKey: asset.balanceQueryKey })));
|
|
22440
22501
|
refreshBlockscoutBalances();
|
|
22441
22502
|
}, [qc, shownProjectAssets, refreshBlockscoutBalances]);
|
|
@@ -22793,7 +22854,7 @@ var init_useNicknameStore = __esm({
|
|
|
22793
22854
|
// src/internal/components/NicknameMenu/useNicknameAvailability.ts
|
|
22794
22855
|
import { useMutation as useMutation15 } from "@tanstack/react-query";
|
|
22795
22856
|
import { debounce as debounce4 } from "lodash-es";
|
|
22796
|
-
import { useCallback as
|
|
22857
|
+
import { useCallback as useCallback26, useEffect as useEffect36 } from "react";
|
|
22797
22858
|
function useNicknameAvailability(currentNickname) {
|
|
22798
22859
|
const { t } = useT();
|
|
22799
22860
|
const nicknameValue = useNicknameStore((st) => st.nicknameValue);
|
|
@@ -22818,7 +22879,7 @@ function useNicknameAvailability(currentNickname) {
|
|
|
22818
22879
|
useNicknameStore.getState().setError(error?.message || "Failed to check nickname availability");
|
|
22819
22880
|
}
|
|
22820
22881
|
});
|
|
22821
|
-
const debouncedCheckAvailability =
|
|
22882
|
+
const debouncedCheckAvailability = useCallback26(debounce4(checkAvailability, DEBOUNCE_MS), [checkAvailability]);
|
|
22822
22883
|
useEffect36(() => {
|
|
22823
22884
|
if (!currentNickname) return;
|
|
22824
22885
|
const normalizedInputValue = normalizeNickname(nicknameValue);
|
|
@@ -22848,7 +22909,7 @@ var init_useNicknameAvailability = __esm({
|
|
|
22848
22909
|
// src/internal/components/NicknameMenu/NicknameEditForm.tsx
|
|
22849
22910
|
import { useMutation as useMutation16, useQueryClient as useQueryClient21 } from "@tanstack/react-query";
|
|
22850
22911
|
import { AtSignIcon, CopyIcon as CopyIcon2, LoaderIcon as LoaderIcon12, SaveIcon } from "lucide-react";
|
|
22851
|
-
import { useCallback as
|
|
22912
|
+
import { useCallback as useCallback27, useEffect as useEffect37, useRef as useRef18, useState as useState23 } from "react";
|
|
22852
22913
|
import { Fragment as Fragment34, jsx as jsx98, jsxs as jsxs89 } from "react/jsx-runtime";
|
|
22853
22914
|
function NicknameEditForm(props) {
|
|
22854
22915
|
const { isInitialUser, nicknameInfo } = props;
|
|
@@ -22897,7 +22958,7 @@ function NicknameEditForm(props) {
|
|
|
22897
22958
|
);
|
|
22898
22959
|
}
|
|
22899
22960
|
});
|
|
22900
|
-
const handleNicknameInputChange =
|
|
22961
|
+
const handleNicknameInputChange = useCallback27(
|
|
22901
22962
|
(e) => {
|
|
22902
22963
|
const { error, setError, setNicknameValue } = useNicknameStore.getState();
|
|
22903
22964
|
const nextInputValue = e.target.value;
|
|
@@ -22911,7 +22972,7 @@ function NicknameEditForm(props) {
|
|
|
22911
22972
|
},
|
|
22912
22973
|
[t]
|
|
22913
22974
|
);
|
|
22914
|
-
const handleSubmit =
|
|
22975
|
+
const handleSubmit = useCallback27(
|
|
22915
22976
|
(e) => {
|
|
22916
22977
|
const { nicknameValue: nicknameValue2, setError } = useNicknameStore.getState();
|
|
22917
22978
|
if (!canChange) {
|
|
@@ -24149,14 +24210,14 @@ var init_useUserAssetsPolicies = __esm({
|
|
|
24149
24210
|
// src/internal/components/SecurityMenu/UserPolicies/PolicyForm.tsx
|
|
24150
24211
|
import { useMutation as useMutation18, useQueryClient as useQueryClient23 } from "@tanstack/react-query";
|
|
24151
24212
|
import { ChevronRightIcon as ChevronRightIcon2, ChevronUpIcon as ChevronUpIcon2, LoaderIcon as LoaderIcon16, PlusIcon, TrashIcon } from "lucide-react";
|
|
24152
|
-
import { useCallback as
|
|
24213
|
+
import { useCallback as useCallback28, useState as useState26 } from "react";
|
|
24153
24214
|
import { Fragment as Fragment37, jsx as jsx106, jsxs as jsxs97 } from "react/jsx-runtime";
|
|
24154
24215
|
function AddressListEditor(props) {
|
|
24155
24216
|
const { label, assets = [], addresses, onChange } = props;
|
|
24156
24217
|
const [isAssetSelector, setIsAssetSelector] = useState26(false);
|
|
24157
24218
|
const [customAddress, setCustomAddress] = useState26("");
|
|
24158
24219
|
const [customAddressError, setCustomAddressError] = useState26(null);
|
|
24159
|
-
const handleAddress =
|
|
24220
|
+
const handleAddress = useCallback28(
|
|
24160
24221
|
(addressToAdd) => {
|
|
24161
24222
|
if (!isValidAddress(addressToAdd)) {
|
|
24162
24223
|
setCustomAddressError("Bad address");
|
|
@@ -25470,7 +25531,7 @@ var init_useOperationHashesStore = __esm({
|
|
|
25470
25531
|
|
|
25471
25532
|
// src/internal/components/SendMenu/hyperbridge/hooks/useBridge.ts
|
|
25472
25533
|
import { useMutation as useMutation20, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
|
|
25473
|
-
import { useCallback as
|
|
25534
|
+
import { useCallback as useCallback29 } from "react";
|
|
25474
25535
|
import { useSwitchChain as useSwitchChain2, useWalletClient } from "wagmi";
|
|
25475
25536
|
function useBridge() {
|
|
25476
25537
|
const qc = useQueryClient25();
|
|
@@ -25478,7 +25539,7 @@ function useBridge() {
|
|
|
25478
25539
|
const address = useSession((st) => st.address);
|
|
25479
25540
|
const { data: walletClient } = useWalletClient();
|
|
25480
25541
|
const { mutateAsync: switchChainAsync } = useSwitchChain2();
|
|
25481
|
-
const swapDirection =
|
|
25542
|
+
const swapDirection = useCallback29(() => {
|
|
25482
25543
|
const {
|
|
25483
25544
|
// bridgeStep,
|
|
25484
25545
|
originChain,
|
|
@@ -25529,7 +25590,7 @@ function useBridge() {
|
|
|
25529
25590
|
useFlowSelectorStore.getState().setError(error instanceof Error ? error.message : String(error));
|
|
25530
25591
|
}
|
|
25531
25592
|
});
|
|
25532
|
-
const handleQuoteEstimation =
|
|
25593
|
+
const handleQuoteEstimation = useCallback29((amnt) => {
|
|
25533
25594
|
const { originChain, destinationChain, bridgeSender } = useBridgeStore.getState();
|
|
25534
25595
|
if (!amnt || !Number(amnt)) {
|
|
25535
25596
|
useBridgeStore.getState().setQuote(null);
|
|
@@ -25947,7 +26008,7 @@ var init_ResolveChainIcon = __esm({
|
|
|
25947
26008
|
// src/internal/components/SendMenu/hyperbridge/hooks/useBridgeBalance.ts
|
|
25948
26009
|
import { CHAINS_BROWSERS_TRANSPORTS as CHAINS_BROWSERS_TRANSPORTS2 } from "@embarkai/core";
|
|
25949
26010
|
import { useQuery as useQuery25, useQueryClient as useQueryClient26 } from "@tanstack/react-query";
|
|
25950
|
-
import { useCallback as
|
|
26011
|
+
import { useCallback as useCallback30, useEffect as useEffect46 } from "react";
|
|
25951
26012
|
import { createPublicClient as createPublicClient2, erc20Abi as erc20Abi3, formatUnits as formatUnits9, http as http3 } from "viem";
|
|
25952
26013
|
import { useSwitchChain as useSwitchChain3 } from "wagmi";
|
|
25953
26014
|
function useBridgeBalance(isLoadingWarpRoutes, hyperlaneWarpRoutes) {
|
|
@@ -26037,7 +26098,7 @@ function useBridgeBalance(isLoadingWarpRoutes, hyperlaneWarpRoutes) {
|
|
|
26037
26098
|
};
|
|
26038
26099
|
}
|
|
26039
26100
|
});
|
|
26040
|
-
const refreshRouteTokenBalance =
|
|
26101
|
+
const refreshRouteTokenBalance = useCallback30(
|
|
26041
26102
|
(senderWallet) => {
|
|
26042
26103
|
switch (true) {
|
|
26043
26104
|
case senderWallet === "embarkai-wallet":
|
|
@@ -27253,7 +27314,7 @@ var init_useNicknameResolve = __esm({
|
|
|
27253
27314
|
});
|
|
27254
27315
|
|
|
27255
27316
|
// src/hooks/useSendTransaction.ts
|
|
27256
|
-
import { useCallback as
|
|
27317
|
+
import { useCallback as useCallback31, useState as useState30 } from "react";
|
|
27257
27318
|
import { encodeFunctionData as encodeFunctionData2, isAddress as isAddress2, parseEther as parseEther2, parseUnits } from "viem";
|
|
27258
27319
|
function useSendTransaction() {
|
|
27259
27320
|
const session = useSession((st) => st.session);
|
|
@@ -27261,7 +27322,7 @@ function useSendTransaction() {
|
|
|
27261
27322
|
const [isLoading, setIsLoading] = useState30(false);
|
|
27262
27323
|
const [error, setError] = useState30(null);
|
|
27263
27324
|
const [userOpHash, setUserOpHash] = useState30(null);
|
|
27264
|
-
const sendTransaction =
|
|
27325
|
+
const sendTransaction = useCallback31(
|
|
27265
27326
|
async (params) => {
|
|
27266
27327
|
if (!session || !address) {
|
|
27267
27328
|
setError("No active session");
|
|
@@ -27358,7 +27419,7 @@ function useSendTransaction() {
|
|
|
27358
27419
|
},
|
|
27359
27420
|
[session, address]
|
|
27360
27421
|
);
|
|
27361
|
-
const reset =
|
|
27422
|
+
const reset = useCallback31(() => {
|
|
27362
27423
|
setError(null);
|
|
27363
27424
|
setUserOpHash(null);
|
|
27364
27425
|
setIsLoading(false);
|
|
@@ -29487,7 +29548,7 @@ var init_TransactionsGroup = __esm({
|
|
|
29487
29548
|
// src/internal/components/TransactionsMenu/TransactionsMenu.tsx
|
|
29488
29549
|
import { useQuery as useQuery28, useQueryClient as useQueryClient28 } from "@tanstack/react-query";
|
|
29489
29550
|
import { ArrowLeft as ArrowLeft22, Loader as Loader29, RefreshCw as RefreshCw3, XCircle as XCircle2 } from "lucide-react";
|
|
29490
|
-
import { useCallback as
|
|
29551
|
+
import { useCallback as useCallback32, useState as useState32 } from "react";
|
|
29491
29552
|
import { jsx as jsx128, jsxs as jsxs116 } from "react/jsx-runtime";
|
|
29492
29553
|
function TransactionsMenu() {
|
|
29493
29554
|
const qc = useQueryClient28();
|
|
@@ -29509,7 +29570,7 @@ function TransactionsMenu() {
|
|
|
29509
29570
|
queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address],
|
|
29510
29571
|
queryFn: () => getTransactionsListQuery({ address, chainConfig })
|
|
29511
29572
|
});
|
|
29512
|
-
const refreshTxHistory =
|
|
29573
|
+
const refreshTxHistory = useCallback32(
|
|
29513
29574
|
() => qc.invalidateQueries({ queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address] }),
|
|
29514
29575
|
[qc, chainConfig.id, address]
|
|
29515
29576
|
);
|
|
@@ -29887,11 +29948,11 @@ var init_PageMap = __esm({
|
|
|
29887
29948
|
});
|
|
29888
29949
|
|
|
29889
29950
|
// src/internal/hooks/usePageMapper.tsx
|
|
29890
|
-
import { useCallback as
|
|
29951
|
+
import { useCallback as useCallback33, useEffect as useEffect53 } from "react";
|
|
29891
29952
|
import { jsx as jsx130 } from "react/jsx-runtime";
|
|
29892
29953
|
function usePageMapper() {
|
|
29893
29954
|
const page = useLayoutDataStore((st) => st.page);
|
|
29894
|
-
const closeDialog =
|
|
29955
|
+
const closeDialog = useCallback33(() => {
|
|
29895
29956
|
useLayoutStore.setState({ isDialogAnimating: true });
|
|
29896
29957
|
setTimeout(() => {
|
|
29897
29958
|
useLayoutStore.setState({
|
|
@@ -29903,7 +29964,7 @@ function usePageMapper() {
|
|
|
29903
29964
|
});
|
|
29904
29965
|
}, CLEAR_DIALOG_TIMEOUT);
|
|
29905
29966
|
}, []);
|
|
29906
|
-
const openDialog =
|
|
29967
|
+
const openDialog = useCallback33((pageItem) => {
|
|
29907
29968
|
useLayoutStore.setState({
|
|
29908
29969
|
dialogContent: /* @__PURE__ */ jsx130(pageItem.component, {}),
|
|
29909
29970
|
isDialogOpen: true
|
|
@@ -29978,7 +30039,7 @@ var init_package = __esm({
|
|
|
29978
30039
|
"package.json"() {
|
|
29979
30040
|
package_default = {
|
|
29980
30041
|
name: "@embarkai/ui-kit",
|
|
29981
|
-
version: "0.4.
|
|
30042
|
+
version: "0.4.115",
|
|
29982
30043
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
29983
30044
|
type: "module",
|
|
29984
30045
|
main: "./dist/index.cjs",
|
|
@@ -30084,7 +30145,6 @@ var init_package = __esm({
|
|
|
30084
30145
|
// src/internal/components/Footer/Footer.tsx
|
|
30085
30146
|
import { useMutation as useMutation22, useQueryClient as useQueryClient29 } from "@tanstack/react-query";
|
|
30086
30147
|
import { Loader as Loader30, LogOut } from "lucide-react";
|
|
30087
|
-
import { useDisconnect as useDisconnect5 } from "wagmi";
|
|
30088
30148
|
import { jsx as jsx131, jsxs as jsxs118 } from "react/jsx-runtime";
|
|
30089
30149
|
function Footer() {
|
|
30090
30150
|
const qc = useQueryClient29();
|
|
@@ -30093,7 +30153,7 @@ function Footer() {
|
|
|
30093
30153
|
const address = useSession((st) => st.address);
|
|
30094
30154
|
const chainConfig = useSession((st) => st.chainConfig);
|
|
30095
30155
|
const isDialogForced = useLayoutStore((st) => st.isDialogForced);
|
|
30096
|
-
const { mutate: wagmiDisconnect } =
|
|
30156
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
30097
30157
|
mutation: {
|
|
30098
30158
|
onSuccess: () => {
|
|
30099
30159
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -30207,6 +30267,7 @@ var init_Footer = __esm({
|
|
|
30207
30267
|
init_ProviderContext();
|
|
30208
30268
|
init_SessionContext();
|
|
30209
30269
|
init_i18n();
|
|
30270
|
+
init_useSafeDisconnect();
|
|
30210
30271
|
init_auth();
|
|
30211
30272
|
init_base3();
|
|
30212
30273
|
init_useLayoutDataStore();
|
|
@@ -30303,7 +30364,7 @@ var init_onborading_setup = __esm({
|
|
|
30303
30364
|
|
|
30304
30365
|
// src/internal/components/Header/Header.tsx
|
|
30305
30366
|
import { CircleQuestionMarkIcon, Copy as Copy4, Loader as Loader31 } from "lucide-react";
|
|
30306
|
-
import { useCallback as
|
|
30367
|
+
import { useCallback as useCallback34, useRef as useRef21, useState as useState33 } from "react";
|
|
30307
30368
|
import { Fragment as Fragment46, jsx as jsx132, jsxs as jsxs119 } from "react/jsx-runtime";
|
|
30308
30369
|
function formatAddress3(addr) {
|
|
30309
30370
|
if (!addr) return "";
|
|
@@ -30320,7 +30381,7 @@ function Header() {
|
|
|
30320
30381
|
const [copied, setCopied] = useState33(false);
|
|
30321
30382
|
const clickCountRef = useRef21(0);
|
|
30322
30383
|
const clickTimerRef = useRef21(null);
|
|
30323
|
-
const handleAvatarClick =
|
|
30384
|
+
const handleAvatarClick = useCallback34(() => {
|
|
30324
30385
|
clickCountRef.current += 1;
|
|
30325
30386
|
if (clickTimerRef.current) {
|
|
30326
30387
|
clearTimeout(clickTimerRef.current);
|
|
@@ -30784,7 +30845,7 @@ var init_DirectWalletHandler = __esm({
|
|
|
30784
30845
|
});
|
|
30785
30846
|
|
|
30786
30847
|
// src/internal/components/TssManager.tsx
|
|
30787
|
-
import React32, { useCallback as
|
|
30848
|
+
import React32, { useCallback as useCallback35 } from "react";
|
|
30788
30849
|
var TssManagerWithRef;
|
|
30789
30850
|
var init_TssManager = __esm({
|
|
30790
30851
|
"src/internal/components/TssManager.tsx"() {
|
|
@@ -30799,7 +30860,7 @@ var init_TssManager = __esm({
|
|
|
30799
30860
|
const setStatus = useSession((st) => st.setStatus);
|
|
30800
30861
|
const setSession = useSession((st) => st.setSession);
|
|
30801
30862
|
const setAddress = useSession((st) => st.setAddress);
|
|
30802
|
-
const onSessionCreated =
|
|
30863
|
+
const onSessionCreated = useCallback35(
|
|
30803
30864
|
(session, address) => {
|
|
30804
30865
|
setSession(session);
|
|
30805
30866
|
setAddress(address);
|
|
@@ -32250,7 +32311,7 @@ var init_iframe_manager = __esm({
|
|
|
32250
32311
|
*/
|
|
32251
32312
|
handleMessage(event) {
|
|
32252
32313
|
const message = event.data;
|
|
32253
|
-
if (!message || typeof message !== "object" || !message.type) {
|
|
32314
|
+
if (!message || typeof message !== "object" || typeof message.type !== "string" || !message.type) {
|
|
32254
32315
|
return;
|
|
32255
32316
|
}
|
|
32256
32317
|
message.type = this.normalizeMessageType(message.type);
|
|
@@ -33343,7 +33404,7 @@ import { initSdkErrorTracking } from "@embarkai/core/internal/error-tracking";
|
|
|
33343
33404
|
import { merge as merge3 } from "lodash-es";
|
|
33344
33405
|
import {
|
|
33345
33406
|
createContext,
|
|
33346
|
-
useCallback as
|
|
33407
|
+
useCallback as useCallback36,
|
|
33347
33408
|
useContext,
|
|
33348
33409
|
useEffect as useEffect57,
|
|
33349
33410
|
useMemo as useMemo21,
|
|
@@ -33372,7 +33433,7 @@ function Provider(props) {
|
|
|
33372
33433
|
useEffect57(() => notifyNoProjetctId(projectId), [projectId]);
|
|
33373
33434
|
const config = useRef22(merge3({}, DEFAULT_PROVIDER_CONFIG, { projectId }, initialConfig));
|
|
33374
33435
|
const wagmiConfig3 = useRef22(getWagmiConfig(config.current?.wallet?.walletConnectId || null));
|
|
33375
|
-
const updateConfig =
|
|
33436
|
+
const updateConfig = useCallback36((updates) => {
|
|
33376
33437
|
const prev = config.current;
|
|
33377
33438
|
const next = { ...prev };
|
|
33378
33439
|
if (updates.projectId !== void 0) next.projectId = updates.projectId;
|
|
@@ -33406,7 +33467,7 @@ function Provider(props) {
|
|
|
33406
33467
|
if (updates.translations) next.translations = { ...next.translations, ...updates.translations };
|
|
33407
33468
|
config.current = next;
|
|
33408
33469
|
}, []);
|
|
33409
|
-
const updateCallbacks =
|
|
33470
|
+
const updateCallbacks = useCallback36((updates) => {
|
|
33410
33471
|
const prev = callbacksRef.current;
|
|
33411
33472
|
const next = updates ? { ...prev, ...updates } : void 0;
|
|
33412
33473
|
callbacksRef.current = next;
|
|
@@ -34475,12 +34536,12 @@ init_useErc3643Compliance();
|
|
|
34475
34536
|
|
|
34476
34537
|
// src/hooks/useWalletMode.ts
|
|
34477
34538
|
init_useExternalWalletStore();
|
|
34478
|
-
import { useCallback as
|
|
34539
|
+
import { useCallback as useCallback39 } from "react";
|
|
34479
34540
|
function useWalletMode() {
|
|
34480
34541
|
const configMode = useExternalWalletStore((st) => st.configMode);
|
|
34481
34542
|
const activeMode = useExternalWalletStore((st) => st.activeMode);
|
|
34482
34543
|
const setActiveMode = useExternalWalletStore((st) => st.setActiveMode);
|
|
34483
|
-
const switchMode =
|
|
34544
|
+
const switchMode = useCallback39(
|
|
34484
34545
|
(mode) => {
|
|
34485
34546
|
if (configMode !== "both") return;
|
|
34486
34547
|
setActiveMode(mode);
|
|
@@ -34497,8 +34558,8 @@ function useWalletMode() {
|
|
|
34497
34558
|
|
|
34498
34559
|
// src/hooks/useDirectWallet.ts
|
|
34499
34560
|
init_useOpenPage();
|
|
34500
|
-
|
|
34501
|
-
import {
|
|
34561
|
+
init_useSafeDisconnect();
|
|
34562
|
+
import { useCallback as useCallback40 } from "react";
|
|
34502
34563
|
init_useExternalWalletStore();
|
|
34503
34564
|
function useDirectWallet() {
|
|
34504
34565
|
const address = useExternalWalletStore((st) => st.externalAddress);
|
|
@@ -34506,11 +34567,11 @@ function useDirectWallet() {
|
|
|
34506
34567
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
34507
34568
|
const connectorName = useExternalWalletStore((st) => st.connectorName);
|
|
34508
34569
|
const { open: openEmbarkAI } = useOpenPage();
|
|
34509
|
-
const { mutate: wagmiDisconnect } =
|
|
34510
|
-
const connect =
|
|
34570
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect();
|
|
34571
|
+
const connect = useCallback40((connectFlowType = "connect") => {
|
|
34511
34572
|
openEmbarkAI("connect-external-wallet" /* CONNECT_EXTERNAL_WALLET */, { connectFlowType });
|
|
34512
34573
|
}, []);
|
|
34513
|
-
const disconnect =
|
|
34574
|
+
const disconnect = useCallback40(() => {
|
|
34514
34575
|
wagmiDisconnect();
|
|
34515
34576
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
34516
34577
|
}, [wagmiDisconnect]);
|
|
@@ -34526,7 +34587,7 @@ function useDirectWallet() {
|
|
|
34526
34587
|
}
|
|
34527
34588
|
|
|
34528
34589
|
// src/hooks/useSendDirectTransaction.ts
|
|
34529
|
-
import { useCallback as
|
|
34590
|
+
import { useCallback as useCallback41, useState as useState39 } from "react";
|
|
34530
34591
|
import { isAddress as isAddress4, parseEther as parseEther3 } from "viem";
|
|
34531
34592
|
import { useConnection as useConnection2, useSwitchChain as useSwitchChain4, useSendTransaction as useWagmiSendTransaction } from "wagmi";
|
|
34532
34593
|
|
|
@@ -34552,7 +34613,7 @@ function useSendDirectTransaction() {
|
|
|
34552
34613
|
const [isPending, setIsPending] = useState39(false);
|
|
34553
34614
|
const [error, setError] = useState39(null);
|
|
34554
34615
|
const [txHash, setTxHash] = useState39(null);
|
|
34555
|
-
const sendTransactionAsync =
|
|
34616
|
+
const sendTransactionAsync = useCallback41(
|
|
34556
34617
|
async (params) => {
|
|
34557
34618
|
if (!isConnected || !connector) {
|
|
34558
34619
|
const message = "No external wallet connected";
|
|
@@ -34589,7 +34650,7 @@ function useSendDirectTransaction() {
|
|
|
34589
34650
|
},
|
|
34590
34651
|
[isConnected, connector, sendWagmiTransactionAsync, switchChainAsync]
|
|
34591
34652
|
);
|
|
34592
|
-
const sendTransaction =
|
|
34653
|
+
const sendTransaction = useCallback41(
|
|
34593
34654
|
async (params) => {
|
|
34594
34655
|
try {
|
|
34595
34656
|
return await sendTransactionAsync(params);
|
|
@@ -34599,7 +34660,7 @@ function useSendDirectTransaction() {
|
|
|
34599
34660
|
},
|
|
34600
34661
|
[sendTransactionAsync]
|
|
34601
34662
|
);
|
|
34602
|
-
const reset =
|
|
34663
|
+
const reset = useCallback41(() => {
|
|
34603
34664
|
setError(null);
|
|
34604
34665
|
setTxHash(null);
|
|
34605
34666
|
setIsPending(false);
|
|
@@ -34611,7 +34672,7 @@ function useSendDirectTransaction() {
|
|
|
34611
34672
|
init_SessionContext();
|
|
34612
34673
|
init_account2();
|
|
34613
34674
|
init_linkedProfiles();
|
|
34614
|
-
import { useCallback as
|
|
34675
|
+
import { useCallback as useCallback42, useMemo as useMemo23, useState as useState40 } from "react";
|
|
34615
34676
|
import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress5, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
|
|
34616
34677
|
var ERC20_TRANSFER_ABI2 = [
|
|
34617
34678
|
{
|
|
@@ -34634,7 +34695,7 @@ function useTransferToLinkedWallet() {
|
|
|
34634
34695
|
() => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
|
|
34635
34696
|
[profiles]
|
|
34636
34697
|
);
|
|
34637
|
-
const transfer =
|
|
34698
|
+
const transfer = useCallback42(
|
|
34638
34699
|
async (params) => {
|
|
34639
34700
|
if (!session) {
|
|
34640
34701
|
setError("No active session");
|
|
@@ -34685,7 +34746,7 @@ function useTransferToLinkedWallet() {
|
|
|
34685
34746
|
},
|
|
34686
34747
|
[session, linkedWallets]
|
|
34687
34748
|
);
|
|
34688
|
-
const reset =
|
|
34749
|
+
const reset = useCallback42(() => {
|
|
34689
34750
|
setError(null);
|
|
34690
34751
|
setUserOpHash(null);
|
|
34691
34752
|
setIsPending(false);
|
|
@@ -34708,16 +34769,16 @@ function useNativeWalletSignature() {
|
|
|
34708
34769
|
}
|
|
34709
34770
|
|
|
34710
34771
|
// src/hooks/useLogout.ts
|
|
34772
|
+
init_useSafeDisconnect();
|
|
34711
34773
|
init_ProviderContext();
|
|
34712
34774
|
init_SessionContext();
|
|
34713
34775
|
init_useExternalWalletStore();
|
|
34714
34776
|
import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
|
|
34715
|
-
import { useCallback as
|
|
34716
|
-
import { useDisconnect as useDisconnect7 } from "wagmi";
|
|
34777
|
+
import { useCallback as useCallback43 } from "react";
|
|
34717
34778
|
function useLogout() {
|
|
34718
34779
|
const { callbacksRef } = useProviderConfig();
|
|
34719
34780
|
const address = useSession((st) => st.address);
|
|
34720
|
-
const { mutate: wagmiDisconnect } =
|
|
34781
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
34721
34782
|
mutation: {
|
|
34722
34783
|
onSuccess: () => {
|
|
34723
34784
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -34728,7 +34789,7 @@ function useLogout() {
|
|
|
34728
34789
|
}
|
|
34729
34790
|
}
|
|
34730
34791
|
});
|
|
34731
|
-
const logout2 =
|
|
34792
|
+
const logout2 = useCallback43(async () => {
|
|
34732
34793
|
const { setSession, setIsLoading, setAddress, setStatus, setError } = useSession.getState();
|
|
34733
34794
|
const prevAddress = address;
|
|
34734
34795
|
let userId = null;
|