@embarkai/ui-kit 0.4.114 → 0.4.116
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 +488 -412
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +179 -106
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7581,6 +7581,7 @@ var init_en = __esm({
|
|
|
7581
7581
|
connectWallet: "Connect Wallet Profile",
|
|
7582
7582
|
noWallets: "No wallets available to connect",
|
|
7583
7583
|
requestPending: "{{wallet}} already has a pending request from this site. Open {{wallet}}, reject or close that request, then try again.",
|
|
7584
|
+
projectInfoUnavailable: "Could not load the app details needed to sign in. Check your connection and try again.",
|
|
7584
7585
|
instructions: {
|
|
7585
7586
|
follow: "Watch your connecting wallet app.\nYou will be asked to:\n {{steps}}",
|
|
7586
7587
|
confirm: "- 1. Confirm your wallet connection into embarkAI",
|
|
@@ -8174,6 +8175,7 @@ var init_ru = __esm({
|
|
|
8174
8175
|
connectWallet: "\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043F\u0440\u043E\u0444\u0438\u043B\u044C \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0430",
|
|
8175
8176
|
noWallets: "\u041D\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0445 \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u043E\u0432 \u0434\u043B\u044F \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F",
|
|
8176
8177
|
requestPending: "\u0412 {{wallet}} \u0443\u0436\u0435 \u0432\u0438\u0441\u0438\u0442 \u0437\u0430\u043F\u0440\u043E\u0441 \u043E\u0442 \u044D\u0442\u043E\u0433\u043E \u0441\u0430\u0439\u0442\u0430. \u041E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 {{wallet}}, \u043E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u0435 \u0438\u043B\u0438 \u0437\u0430\u043A\u0440\u043E\u0439\u0442\u0435 \u044D\u0442\u043E\u0442 \u0437\u0430\u043F\u0440\u043E\u0441 \u0438 \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u0441\u043D\u043E\u0432\u0430.",
|
|
8178
|
+
projectInfoUnavailable: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \u0434\u043B\u044F \u0432\u0445\u043E\u0434\u0430. \u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0435 \u0438 \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u0441\u043D\u043E\u0432\u0430.",
|
|
8177
8179
|
instructions: {
|
|
8178
8180
|
follow: "\u0421\u043B\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0430\u0435\u043C\u044B\u043C \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435\u043C \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0430.\n\u0412\u0430\u043C \u0431\u0443\u0434\u0435\u0442 \u043F\u0440\u0435\u0434\u043B\u043E\u0436\u0435\u043D\u043E:\n {{steps}}",
|
|
8179
8181
|
confirm: "- 1. \u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435 \u043A\u043E\u0448\u0435\u043B\u044C\u043A\u0430 \u043A embarkAI",
|
|
@@ -8767,6 +8769,7 @@ var init_zh = __esm({
|
|
|
8767
8769
|
connectWallet: "\u8FDE\u63A5\u94B1\u5305\u914D\u7F6E\u6587\u4EF6",
|
|
8768
8770
|
noWallets: "\u6CA1\u6709\u53EF\u8FDE\u63A5\u7684\u94B1\u5305",
|
|
8769
8771
|
requestPending: "{{wallet}} \u4E2D\u5DF2\u6709\u6765\u81EA\u672C\u7F51\u7AD9\u7684\u5F85\u5904\u7406\u8BF7\u6C42\u3002\u8BF7\u6253\u5F00 {{wallet}}\uFF0C\u62D2\u7EDD\u6216\u5173\u95ED\u8BE5\u8BF7\u6C42\uFF0C\u7136\u540E\u91CD\u8BD5\u3002",
|
|
8772
|
+
projectInfoUnavailable: "\u65E0\u6CD5\u52A0\u8F7D\u767B\u5F55\u6240\u9700\u7684\u5E94\u7528\u4FE1\u606F\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u540E\u91CD\u8BD5\u3002",
|
|
8770
8773
|
instructions: {
|
|
8771
8774
|
follow: "\u8BF7\u67E5\u770B\u60A8\u6B63\u5728\u8FDE\u63A5\u7684\u94B1\u5305\u5E94\u7528\u3002\n\u60A8\u5C06\u88AB\u8981\u6C42\uFF1A\n {{steps}}",
|
|
8772
8775
|
confirm: "- 1. \u786E\u8BA4\u5C06\u60A8\u7684\u94B1\u5305\u8FDE\u63A5\u5230 embarkAI",
|
|
@@ -11605,12 +11608,6 @@ var init_AuthMenu = __esm({
|
|
|
11605
11608
|
setAlert(null);
|
|
11606
11609
|
};
|
|
11607
11610
|
}, []);
|
|
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
11611
|
const stepContent = useMemo2(
|
|
11615
11612
|
() => ({
|
|
11616
11613
|
"loading": /* @__PURE__ */ jsx26(LoadingStep, {}),
|
|
@@ -11628,6 +11625,12 @@ var init_AuthMenu = __esm({
|
|
|
11628
11625
|
}),
|
|
11629
11626
|
[onAuthSuccess, goBackToSignIn]
|
|
11630
11627
|
);
|
|
11628
|
+
if (!isIframeReady) {
|
|
11629
|
+
return /* @__PURE__ */ jsxs20(Expandable, { isExpanded: true, className: "w-full p-8 flex flex-col justify-center items-center gap-[var(--ui-kit-gap)]", children: [
|
|
11630
|
+
/* @__PURE__ */ jsx26(Loader4, { className: "w-4 h-4 animate-spin" }),
|
|
11631
|
+
/* @__PURE__ */ jsx26("span", { className: "text-sm text-[var(--ui-kit-fg-muted)]", children: "Initializing wallet..." })
|
|
11632
|
+
] });
|
|
11633
|
+
}
|
|
11631
11634
|
return /* @__PURE__ */ jsxs20(Expandable, { isExpanded: true, contentClassName: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: [
|
|
11632
11635
|
stepContent[step],
|
|
11633
11636
|
alert2 && /* @__PURE__ */ jsxs20(Highlight, { type: "error", children: [
|
|
@@ -15693,6 +15696,67 @@ var init_wallets = __esm({
|
|
|
15693
15696
|
}
|
|
15694
15697
|
});
|
|
15695
15698
|
|
|
15699
|
+
// src/internal/lib/disconnect-guard.ts
|
|
15700
|
+
function waitForReconnect(config) {
|
|
15701
|
+
if (config.state.status !== "reconnecting") return Promise.resolve();
|
|
15702
|
+
return new Promise((resolve) => {
|
|
15703
|
+
const unsubscribe = config.subscribe(
|
|
15704
|
+
(state) => state.status,
|
|
15705
|
+
(status) => {
|
|
15706
|
+
if (status === "reconnecting") return;
|
|
15707
|
+
unsubscribe();
|
|
15708
|
+
resolve();
|
|
15709
|
+
}
|
|
15710
|
+
);
|
|
15711
|
+
});
|
|
15712
|
+
}
|
|
15713
|
+
function hasUnusableCurrentConnector(config) {
|
|
15714
|
+
const { current, connections } = config.state;
|
|
15715
|
+
if (!current) return false;
|
|
15716
|
+
const connector = connections.get(current)?.connector;
|
|
15717
|
+
return !!connector && typeof connector.disconnect !== "function";
|
|
15718
|
+
}
|
|
15719
|
+
var init_disconnect_guard = __esm({
|
|
15720
|
+
"src/internal/lib/disconnect-guard.ts"() {
|
|
15721
|
+
}
|
|
15722
|
+
});
|
|
15723
|
+
|
|
15724
|
+
// src/internal/hooks/useSafeDisconnect.ts
|
|
15725
|
+
import { useCallback as useCallback15 } from "react";
|
|
15726
|
+
import { useConfig, useDisconnect } from "wagmi";
|
|
15727
|
+
function useSafeDisconnect(options) {
|
|
15728
|
+
const config = useConfig();
|
|
15729
|
+
const mutation = useDisconnect(options);
|
|
15730
|
+
const { mutateAsync } = mutation;
|
|
15731
|
+
const disconnectAsync = useCallback15(
|
|
15732
|
+
async (parameters) => {
|
|
15733
|
+
await waitForReconnect(config);
|
|
15734
|
+
if (!parameters?.connector && hasUnusableCurrentConnector(config)) return;
|
|
15735
|
+
await mutateAsync(parameters);
|
|
15736
|
+
},
|
|
15737
|
+
[config, mutateAsync]
|
|
15738
|
+
);
|
|
15739
|
+
const disconnect = useCallback15(
|
|
15740
|
+
(parameters) => {
|
|
15741
|
+
disconnectAsync(parameters).catch(() => {
|
|
15742
|
+
});
|
|
15743
|
+
},
|
|
15744
|
+
[disconnectAsync]
|
|
15745
|
+
);
|
|
15746
|
+
return {
|
|
15747
|
+
...mutation,
|
|
15748
|
+
mutate: disconnect,
|
|
15749
|
+
mutateAsync: disconnectAsync,
|
|
15750
|
+
disconnect,
|
|
15751
|
+
disconnectAsync
|
|
15752
|
+
};
|
|
15753
|
+
}
|
|
15754
|
+
var init_useSafeDisconnect = __esm({
|
|
15755
|
+
"src/internal/hooks/useSafeDisconnect.ts"() {
|
|
15756
|
+
init_disconnect_guard();
|
|
15757
|
+
}
|
|
15758
|
+
});
|
|
15759
|
+
|
|
15696
15760
|
// src/internal/lib/connect-errors.ts
|
|
15697
15761
|
function someInErrorChain(error, predicate) {
|
|
15698
15762
|
let current = error;
|
|
@@ -15802,7 +15866,7 @@ var init_common = __esm({
|
|
|
15802
15866
|
|
|
15803
15867
|
// src/modules/linkedProfiles.ts
|
|
15804
15868
|
import { useQuery as useQuery7, useQueryClient as useQueryClient8 } from "@tanstack/react-query";
|
|
15805
|
-
import { useCallback as
|
|
15869
|
+
import { useCallback as useCallback16 } from "react";
|
|
15806
15870
|
function useLinkedProfiles() {
|
|
15807
15871
|
const qc = useQueryClient8();
|
|
15808
15872
|
const address = useSession((st) => st.address);
|
|
@@ -15826,7 +15890,7 @@ function useLinkedProfiles() {
|
|
|
15826
15890
|
}
|
|
15827
15891
|
});
|
|
15828
15892
|
const { profiles = [], avatar = null } = data || {};
|
|
15829
|
-
const refresh =
|
|
15893
|
+
const refresh = useCallback16(async () => {
|
|
15830
15894
|
await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
|
|
15831
15895
|
}, [qc, address]);
|
|
15832
15896
|
return { profiles, avatar, isLoading, isFetching, error, refresh };
|
|
@@ -15882,20 +15946,27 @@ async function unlinkWallet(address) {
|
|
|
15882
15946
|
throw new Error(errorData.message || `Failed to unlink wallet: ${response.statusText}`);
|
|
15883
15947
|
}
|
|
15884
15948
|
}
|
|
15885
|
-
async function
|
|
15886
|
-
const
|
|
15887
|
-
if (
|
|
15949
|
+
async function requestProjectName(projectId) {
|
|
15950
|
+
const response = await fetch(`${METADATA_API_URL}/${projectId}/metadata`);
|
|
15951
|
+
if (!response.ok) throw new Error(`Project metadata request failed with status ${response.status}`);
|
|
15952
|
+
const metadata = await response.json();
|
|
15953
|
+
if (!metadata?.name) throw new Error("Project metadata has no name");
|
|
15954
|
+
metadataCache = { data: metadata, timestamp: Date.now() };
|
|
15955
|
+
return metadata.name;
|
|
15956
|
+
}
|
|
15957
|
+
async function fetchProjectName(projectId, attempts = 2) {
|
|
15958
|
+
if (metadataCache && Date.now() - metadataCache.timestamp < METADATA_CACHE_TTL) {
|
|
15888
15959
|
return metadataCache.data.name;
|
|
15889
15960
|
}
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
|
|
15893
|
-
|
|
15894
|
-
|
|
15895
|
-
|
|
15896
|
-
|
|
15897
|
-
return "EmbarkAI";
|
|
15961
|
+
let lastError;
|
|
15962
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
15963
|
+
try {
|
|
15964
|
+
return await requestProjectName(projectId);
|
|
15965
|
+
} catch (error) {
|
|
15966
|
+
lastError = error;
|
|
15967
|
+
}
|
|
15898
15968
|
}
|
|
15969
|
+
throw lastError;
|
|
15899
15970
|
}
|
|
15900
15971
|
function createSignatureMessage(address, projectName, nonce) {
|
|
15901
15972
|
const timestamp = Date.now();
|
|
@@ -16706,7 +16777,7 @@ var init_telegram2 = __esm({
|
|
|
16706
16777
|
|
|
16707
16778
|
// src/internal/components/ManageWalletMenu/hooks/useLinkTelegram.ts
|
|
16708
16779
|
import { useQueryClient as useQueryClient12 } from "@tanstack/react-query";
|
|
16709
|
-
import { useCallback as
|
|
16780
|
+
import { useCallback as useCallback17, useEffect as useEffect25, useState as useState12 } from "react";
|
|
16710
16781
|
function useLinkTelegram() {
|
|
16711
16782
|
const {
|
|
16712
16783
|
config: { current: config },
|
|
@@ -16716,7 +16787,7 @@ function useLinkTelegram() {
|
|
|
16716
16787
|
const address = useSession((st) => st.address);
|
|
16717
16788
|
const { providerType, linkIsLoading, setLinkIsLoading, setProviderType, setAlert } = useManageWalletStore();
|
|
16718
16789
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
16719
|
-
const handleLinkTelegram =
|
|
16790
|
+
const handleLinkTelegram = useCallback17(async () => {
|
|
16720
16791
|
try {
|
|
16721
16792
|
if (shouldBlockSocialAuthInTelegram("telegram")) {
|
|
16722
16793
|
setAlert(buildTelegramBrowserRestriction("Telegram", "linking"));
|
|
@@ -17147,13 +17218,12 @@ var init_ManageWallet = __esm({
|
|
|
17147
17218
|
import { useMutation as useMutation9, useQueryClient as useQueryClient13 } from "@tanstack/react-query";
|
|
17148
17219
|
import { Key as Key4, Loader as Loader10 } from "lucide-react";
|
|
17149
17220
|
import { useState as useState13 } from "react";
|
|
17150
|
-
import { useDisconnect } from "wagmi";
|
|
17151
17221
|
import { jsx as jsx73, jsxs as jsxs64 } from "react/jsx-runtime";
|
|
17152
17222
|
function UnlinkProviderMenu() {
|
|
17153
17223
|
const qc = useQueryClient13();
|
|
17154
17224
|
const address = useSession((st) => st.address);
|
|
17155
17225
|
const { callbacksRef } = useProviderConfig();
|
|
17156
|
-
const { disconnect: disconnectExternalWallet } =
|
|
17226
|
+
const { disconnect: disconnectExternalWallet } = useSafeDisconnect();
|
|
17157
17227
|
const isExternalConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
17158
17228
|
const { t } = useT();
|
|
17159
17229
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
@@ -17246,6 +17316,7 @@ var init_UnlinkProviderMenu = __esm({
|
|
|
17246
17316
|
init_ProviderContext();
|
|
17247
17317
|
init_SessionContext();
|
|
17248
17318
|
init_useT();
|
|
17319
|
+
init_useSafeDisconnect();
|
|
17249
17320
|
init_linkedProfiles();
|
|
17250
17321
|
init_auth();
|
|
17251
17322
|
init_useExternalWalletStore();
|
|
@@ -17327,14 +17398,13 @@ var init_useHasInjectedWallet = __esm({
|
|
|
17327
17398
|
// src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx
|
|
17328
17399
|
import { useMutation as useMutation10, useQuery as useQuery9, useQueryClient as useQueryClient14 } from "@tanstack/react-query";
|
|
17329
17400
|
import { ArrowLeft as ArrowLeft8, Loader as Loader11, Wallet2Icon as Wallet2Icon2 } from "lucide-react";
|
|
17330
|
-
import { useCallback as
|
|
17401
|
+
import { useCallback as useCallback18, useMemo as useMemo9, useState as useState14 } from "react";
|
|
17331
17402
|
import {
|
|
17332
17403
|
useChains,
|
|
17333
|
-
useConfig,
|
|
17404
|
+
useConfig as useConfig2,
|
|
17334
17405
|
useConnect,
|
|
17335
17406
|
useConnections as useConnections2,
|
|
17336
17407
|
useConnectors,
|
|
17337
|
-
useDisconnect as useDisconnect2,
|
|
17338
17408
|
useSignMessage,
|
|
17339
17409
|
useSwitchChain,
|
|
17340
17410
|
useSwitchConnection
|
|
@@ -17357,10 +17427,10 @@ function ConnectExternalWalletMenu() {
|
|
|
17357
17427
|
const menuParams = useConnectExternalWalletMenuParams();
|
|
17358
17428
|
const connectors = useConnectors();
|
|
17359
17429
|
const hasInjectedWallet2 = useHasInjectedWallet();
|
|
17360
|
-
const wagmiConfig3 =
|
|
17430
|
+
const wagmiConfig3 = useConfig2();
|
|
17361
17431
|
const chains = useChains();
|
|
17362
17432
|
const connections = useConnections2();
|
|
17363
|
-
const { mutate: disconnect, mutateAsync: disconnectAsync } =
|
|
17433
|
+
const { mutate: disconnect, mutateAsync: disconnectAsync } = useSafeDisconnect();
|
|
17364
17434
|
const { mutateAsync: signMessageAsync } = useSignMessage();
|
|
17365
17435
|
const { mutateAsync: switchChainAsync } = useSwitchChain();
|
|
17366
17436
|
const { mutateAsync: switchConnectionAsync } = useSwitchConnection();
|
|
@@ -17488,7 +17558,9 @@ function ConnectExternalWalletMenu() {
|
|
|
17488
17558
|
return;
|
|
17489
17559
|
}
|
|
17490
17560
|
const projectId = config.current?.projectId;
|
|
17491
|
-
const projectName = projectId ? await fetchProjectName(projectId)
|
|
17561
|
+
const projectName = projectId ? await fetchProjectName(projectId).catch(() => {
|
|
17562
|
+
throw new Error(t("passport:connectMenu.projectInfoUnavailable"));
|
|
17563
|
+
}) : "EmbarkAI";
|
|
17492
17564
|
const createMessage = connectFlowType === "auth" ? createLoginMessage : createSignatureMessage;
|
|
17493
17565
|
const message = createMessage(signingWalletAddress, projectName);
|
|
17494
17566
|
const { signature, chainId: signedChainId } = await signOnSupportedChain({
|
|
@@ -17563,7 +17635,7 @@ function ConnectExternalWalletMenu() {
|
|
|
17563
17635
|
(connector) => allowed.includes(connector.id.toLowerCase()) || allowed.includes(connector.name.toLowerCase())
|
|
17564
17636
|
);
|
|
17565
17637
|
}, [connectors, allowedWallets, hasInjectedWallet2]);
|
|
17566
|
-
const getInstructionSteps =
|
|
17638
|
+
const getInstructionSteps = useCallback18(() => {
|
|
17567
17639
|
const connectFlowType = getConnectFlowType({
|
|
17568
17640
|
isEmbarkAI: !!embarkAiAddress,
|
|
17569
17641
|
connectFlow: menuParams.current?.connectFlowType || "auth"
|
|
@@ -17679,6 +17751,7 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17679
17751
|
init_useOpenPage();
|
|
17680
17752
|
init_i18n();
|
|
17681
17753
|
init_wallets();
|
|
17754
|
+
init_useSafeDisconnect();
|
|
17682
17755
|
init_connect_errors();
|
|
17683
17756
|
init_linkedProfiles();
|
|
17684
17757
|
init_common();
|
|
@@ -17698,29 +17771,28 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17698
17771
|
|
|
17699
17772
|
// src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts
|
|
17700
17773
|
import { omit as omit2 } from "lodash-es";
|
|
17701
|
-
import { useCallback as
|
|
17774
|
+
import { useCallback as useCallback19 } from "react";
|
|
17702
17775
|
import {
|
|
17703
|
-
useConfig as
|
|
17776
|
+
useConfig as useConfig3,
|
|
17704
17777
|
useConnect as useConnect2,
|
|
17705
17778
|
useConnections as useConnections3,
|
|
17706
|
-
useConnectors as useConnectors2
|
|
17707
|
-
useDisconnect as useDisconnect3
|
|
17779
|
+
useConnectors as useConnectors2
|
|
17708
17780
|
} from "wagmi";
|
|
17709
17781
|
function useExternalWalletConnnect(options) {
|
|
17710
17782
|
const { onSuccess, onError } = options || {};
|
|
17711
17783
|
const { config } = useProviderConfig();
|
|
17712
17784
|
const walletMode = config.current?.wallet?.mode;
|
|
17713
|
-
const wagmiConfig3 =
|
|
17785
|
+
const wagmiConfig3 = useConfig3();
|
|
17714
17786
|
const connectors = useConnectors2();
|
|
17715
17787
|
const connections = useConnections3();
|
|
17716
17788
|
const { mutate: connect, mutateAsync: connectAsync, ...restUseConnect } = useConnect2();
|
|
17717
|
-
const { mutateAsync: disconnectAsync } =
|
|
17718
|
-
const disconnectExternalWallet =
|
|
17789
|
+
const { mutateAsync: disconnectAsync } = useSafeDisconnect();
|
|
17790
|
+
const disconnectExternalWallet = useCallback19(async () => {
|
|
17719
17791
|
await disconnectAsync();
|
|
17720
17792
|
const { externalAddress, clearExternalWallet } = useExternalWalletStore.getState();
|
|
17721
17793
|
if (!!externalAddress) clearExternalWallet();
|
|
17722
17794
|
}, [disconnectAsync]);
|
|
17723
|
-
const connectExternalWallet =
|
|
17795
|
+
const connectExternalWallet = useCallback19(
|
|
17724
17796
|
async (walletConnectorType) => {
|
|
17725
17797
|
const connector = connectors.find((c) => c.id === walletConnectorType);
|
|
17726
17798
|
if (!connector) {
|
|
@@ -17777,6 +17849,7 @@ function useExternalWalletConnnect(options) {
|
|
|
17777
17849
|
var init_useExternalWalletConnect = __esm({
|
|
17778
17850
|
"src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts"() {
|
|
17779
17851
|
init_ProviderContext();
|
|
17852
|
+
init_useSafeDisconnect();
|
|
17780
17853
|
init_useLayoutStore();
|
|
17781
17854
|
init_connect_errors();
|
|
17782
17855
|
init_useExternalWalletStore();
|
|
@@ -18444,7 +18517,7 @@ var init_guardian_backup = __esm({
|
|
|
18444
18517
|
|
|
18445
18518
|
// src/internal/components/DevicesMenu/DeviceManageScreen.tsx
|
|
18446
18519
|
import { ArrowLeft as ArrowLeft10, Cpu, Download, HardDrive, Loader2 as Loader23, Trash2, Upload } from "lucide-react";
|
|
18447
|
-
import { useCallback as
|
|
18520
|
+
import { useCallback as useCallback20, useEffect as useEffect27, useRef as useRef14, useState as useState16 } from "react";
|
|
18448
18521
|
import { Fragment as Fragment20, jsx as jsx76, jsxs as jsxs67 } from "react/jsx-runtime";
|
|
18449
18522
|
function formatSize(bytes) {
|
|
18450
18523
|
if (bytes < 1024) return `${bytes} B`;
|
|
@@ -18501,7 +18574,7 @@ function DeviceManageScreen() {
|
|
|
18501
18574
|
guardianRef.current?.close();
|
|
18502
18575
|
};
|
|
18503
18576
|
}, [deviceId]);
|
|
18504
|
-
const refreshList =
|
|
18577
|
+
const refreshList = useCallback20(async () => {
|
|
18505
18578
|
const guardian = guardianRef.current;
|
|
18506
18579
|
if (!guardian || screen.step !== "connected") return;
|
|
18507
18580
|
try {
|
|
@@ -18510,7 +18583,7 @@ function DeviceManageScreen() {
|
|
|
18510
18583
|
} catch {
|
|
18511
18584
|
}
|
|
18512
18585
|
}, [screen]);
|
|
18513
|
-
const handleBackup =
|
|
18586
|
+
const handleBackup = useCallback20(async () => {
|
|
18514
18587
|
const guardian = guardianRef.current;
|
|
18515
18588
|
const iframe6 = getIframeManager();
|
|
18516
18589
|
if (!guardian || !iframe6 || !userId) return;
|
|
@@ -18534,7 +18607,7 @@ function DeviceManageScreen() {
|
|
|
18534
18607
|
setActionState(null);
|
|
18535
18608
|
}
|
|
18536
18609
|
}, [password, userId, refreshList]);
|
|
18537
|
-
const handleOverwrite =
|
|
18610
|
+
const handleOverwrite = useCallback20(async () => {
|
|
18538
18611
|
const guardian = guardianRef.current;
|
|
18539
18612
|
const iframe6 = getIframeManager();
|
|
18540
18613
|
if (!guardian || !iframe6 || !userId) return;
|
|
@@ -18554,7 +18627,7 @@ function DeviceManageScreen() {
|
|
|
18554
18627
|
setActionState(null);
|
|
18555
18628
|
}
|
|
18556
18629
|
}, [password, userId, refreshList]);
|
|
18557
|
-
const handleDelete =
|
|
18630
|
+
const handleDelete = useCallback20(
|
|
18558
18631
|
async (keyshareId) => {
|
|
18559
18632
|
const guardian = guardianRef.current;
|
|
18560
18633
|
if (!guardian) return;
|
|
@@ -18754,7 +18827,7 @@ var init_DeviceManageScreen = __esm({
|
|
|
18754
18827
|
|
|
18755
18828
|
// src/internal/components/DevicesMenu/DeviceRestoreScreen.tsx
|
|
18756
18829
|
import { AlertTriangle as AlertTriangle2, ArrowLeft as ArrowLeft11, Download as Download2, Loader2 as Loader24 } from "lucide-react";
|
|
18757
|
-
import { useCallback as
|
|
18830
|
+
import { useCallback as useCallback21, useState as useState17 } from "react";
|
|
18758
18831
|
import { Fragment as Fragment21, jsx as jsx77, jsxs as jsxs68 } from "react/jsx-runtime";
|
|
18759
18832
|
function DeviceRestoreScreen() {
|
|
18760
18833
|
const setPage = useLayoutDataStore((s) => s.setPage);
|
|
@@ -18768,7 +18841,7 @@ function DeviceRestoreScreen() {
|
|
|
18768
18841
|
const [isWorking, setIsWorking] = useState17(false);
|
|
18769
18842
|
const [statusMessage, setStatusMessage] = useState17(null);
|
|
18770
18843
|
const [errorMessage, setErrorMessage] = useState17(null);
|
|
18771
|
-
const handleRestore =
|
|
18844
|
+
const handleRestore = useCallback21(async () => {
|
|
18772
18845
|
if (!password || !keyshareId || !userId) return;
|
|
18773
18846
|
const iframe6 = getIframeManager();
|
|
18774
18847
|
if (!iframe6) {
|
|
@@ -19019,7 +19092,7 @@ var init_useRestoreStore = __esm({
|
|
|
19019
19092
|
});
|
|
19020
19093
|
|
|
19021
19094
|
// src/internal/components/KeyshareRestoreMenu/hooks/useOnRestoreSuccess.ts
|
|
19022
|
-
import { useCallback as
|
|
19095
|
+
import { useCallback as useCallback22 } from "react";
|
|
19023
19096
|
function useOnRestoreSuccess() {
|
|
19024
19097
|
const { config, callbacksRef } = useProviderConfig();
|
|
19025
19098
|
const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
|
|
@@ -19035,7 +19108,7 @@ function useOnRestoreSuccess() {
|
|
|
19035
19108
|
setStatus
|
|
19036
19109
|
} = useSession();
|
|
19037
19110
|
const { setError, setSuccess } = useRestoreStore();
|
|
19038
|
-
const createSessionWithKeyshare =
|
|
19111
|
+
const createSessionWithKeyshare = useCallback22(
|
|
19039
19112
|
async (userId, hasServerKeyshare, isNewUser) => {
|
|
19040
19113
|
try {
|
|
19041
19114
|
try {
|
|
@@ -19076,7 +19149,7 @@ function useOnRestoreSuccess() {
|
|
|
19076
19149
|
},
|
|
19077
19150
|
[setStatus, usePaymaster, activeChainId, publicClient]
|
|
19078
19151
|
);
|
|
19079
|
-
const onRestoreSuccess =
|
|
19152
|
+
const onRestoreSuccess = useCallback22(async () => {
|
|
19080
19153
|
const { verifyToken: verifyToken2, jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
19081
19154
|
const verify = await verifyToken2();
|
|
19082
19155
|
const hasServerKeyshare = verify?.hasKeyshare ?? jwtTokenManager4.getHasKeyshare() ?? false;
|
|
@@ -19401,7 +19474,7 @@ var init_cloudStorage = __esm({
|
|
|
19401
19474
|
|
|
19402
19475
|
// src/internal/components/KeyshareRestoreMenu/hooks/useCreateBackup.ts
|
|
19403
19476
|
import { useMutation as useMutation12, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
|
|
19404
|
-
import { useCallback as
|
|
19477
|
+
import { useCallback as useCallback23, useEffect as useEffect28 } from "react";
|
|
19405
19478
|
function useCreateBackup() {
|
|
19406
19479
|
const qc = useQueryClient16();
|
|
19407
19480
|
const session = useSession((st) => st.session);
|
|
@@ -19418,7 +19491,7 @@ function useCreateBackup() {
|
|
|
19418
19491
|
}, [hasServerVault]);
|
|
19419
19492
|
const recoveryUserId = useSession((st) => st.recoveryUserId);
|
|
19420
19493
|
const passportUserId = session?.mpcUserId || recoveryUserId || "";
|
|
19421
|
-
const onBackupSuccess =
|
|
19494
|
+
const onBackupSuccess = useCallback23((method) => {
|
|
19422
19495
|
console.log(`[EMBARKAI BACKUP] ${method} backup created successfully`);
|
|
19423
19496
|
if (method !== "server") return;
|
|
19424
19497
|
const { setIsDialogForced } = useLayoutStore.getState();
|
|
@@ -20789,7 +20862,6 @@ var init_methods = __esm({
|
|
|
20789
20862
|
import { useMutation as useMutation14, useQuery as useQuery12, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
|
|
20790
20863
|
import { AlertCircle as AlertCircle2, CheckCircle2 as CheckCircle22, CloudDownload as CloudDownload2, Loader as Loader14, UserCircle as UserCircle2 } from "lucide-react";
|
|
20791
20864
|
import { useEffect as useEffect33 } from "react";
|
|
20792
|
-
import { useDisconnect as useDisconnect4 } from "wagmi";
|
|
20793
20865
|
import { Fragment as Fragment29, jsx as jsx87, jsxs as jsxs78 } from "react/jsx-runtime";
|
|
20794
20866
|
var RESTORE_COMPONENTS, KeyshareRestoreMenu;
|
|
20795
20867
|
var init_KeyshareRestoreMenu = __esm({
|
|
@@ -20797,6 +20869,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
20797
20869
|
init_ProviderContext();
|
|
20798
20870
|
init_SessionContext();
|
|
20799
20871
|
init_i18n();
|
|
20872
|
+
init_useSafeDisconnect();
|
|
20800
20873
|
init_useLayoutDataStore();
|
|
20801
20874
|
init_useLayoutStore();
|
|
20802
20875
|
init_useExternalWalletStore();
|
|
@@ -20837,7 +20910,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
20837
20910
|
setIsDialogForced(false);
|
|
20838
20911
|
};
|
|
20839
20912
|
}, []);
|
|
20840
|
-
const { mutate: wagmiDisconnect } =
|
|
20913
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
20841
20914
|
mutation: {
|
|
20842
20915
|
onSuccess: () => {
|
|
20843
20916
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -21841,7 +21914,7 @@ var init_utils9 = __esm({
|
|
|
21841
21914
|
// src/internal/hooks/useBlockscoutAssets/useBlockscoutAssets.ts
|
|
21842
21915
|
import { createBlockscoutClient as createBlockscoutClient2, nonBlockscoutClient } from "@embarkai/core";
|
|
21843
21916
|
import { useQuery as useQuery17, useQueryClient as useQueryClient19 } from "@tanstack/react-query";
|
|
21844
|
-
import { useCallback as
|
|
21917
|
+
import { useCallback as useCallback24, useMemo as useMemo13, useRef as useRef17 } from "react";
|
|
21845
21918
|
function useBlockscoutAssets(options) {
|
|
21846
21919
|
const { address, chainId, enabled = true, detectSecurityTokens = true } = options;
|
|
21847
21920
|
const qc = useQueryClient19();
|
|
@@ -22079,7 +22152,7 @@ function useBlockscoutAssets(options) {
|
|
|
22079
22152
|
if (!blockscoutError) return null;
|
|
22080
22153
|
return createError(blockscoutError);
|
|
22081
22154
|
}, [blockscoutError]);
|
|
22082
|
-
const refreshBalances =
|
|
22155
|
+
const refreshBalances = useCallback24(async () => {
|
|
22083
22156
|
const now = Date.now();
|
|
22084
22157
|
if (now - lastRefreshRef.current < BLOCKSCOUT_REFRESH_DEBOUNCE) {
|
|
22085
22158
|
return;
|
|
@@ -22095,7 +22168,7 @@ function useBlockscoutAssets(options) {
|
|
|
22095
22168
|
qc.invalidateQueries({ queryKey: [WATCH_TOKENS_QUERY_KEY] })
|
|
22096
22169
|
]);
|
|
22097
22170
|
}, [qc, customTokenBalancesQueryKey]);
|
|
22098
|
-
const getTokenBalance =
|
|
22171
|
+
const getTokenBalance = useCallback24(
|
|
22099
22172
|
(tokenAddress) => {
|
|
22100
22173
|
return assets.find((a) => a.address?.toLowerCase() === tokenAddress.toLowerCase()) || null;
|
|
22101
22174
|
},
|
|
@@ -22416,7 +22489,7 @@ var init_PortfolioItem = __esm({
|
|
|
22416
22489
|
// src/internal/components/PortfolioMenu/PortfolioMenu.tsx
|
|
22417
22490
|
import { useQueryClient as useQueryClient20 } from "@tanstack/react-query";
|
|
22418
22491
|
import { ArrowLeft as ArrowLeft17, Gem, Loader as Loader16, RefreshCw as RefreshCw2 } from "lucide-react";
|
|
22419
|
-
import { useCallback as
|
|
22492
|
+
import { useCallback as useCallback25 } from "react";
|
|
22420
22493
|
import { jsx as jsx95, jsxs as jsxs86 } from "react/jsx-runtime";
|
|
22421
22494
|
function PortfolioMenu() {
|
|
22422
22495
|
const { assets: projectAssets = [] } = useProviderConfig().config.current?.projectAssets || {};
|
|
@@ -22435,7 +22508,7 @@ function PortfolioMenu() {
|
|
|
22435
22508
|
enabled: !!address
|
|
22436
22509
|
});
|
|
22437
22510
|
const shownProjectAssets = projectAssets.filter((asset) => !asset.hideInPortfolio);
|
|
22438
|
-
const refreshAllAssetsBalances =
|
|
22511
|
+
const refreshAllAssetsBalances = useCallback25(() => {
|
|
22439
22512
|
Promise.all(shownProjectAssets.map((asset) => qc.invalidateQueries({ queryKey: asset.balanceQueryKey })));
|
|
22440
22513
|
refreshBlockscoutBalances();
|
|
22441
22514
|
}, [qc, shownProjectAssets, refreshBlockscoutBalances]);
|
|
@@ -22793,7 +22866,7 @@ var init_useNicknameStore = __esm({
|
|
|
22793
22866
|
// src/internal/components/NicknameMenu/useNicknameAvailability.ts
|
|
22794
22867
|
import { useMutation as useMutation15 } from "@tanstack/react-query";
|
|
22795
22868
|
import { debounce as debounce4 } from "lodash-es";
|
|
22796
|
-
import { useCallback as
|
|
22869
|
+
import { useCallback as useCallback26, useEffect as useEffect36 } from "react";
|
|
22797
22870
|
function useNicknameAvailability(currentNickname) {
|
|
22798
22871
|
const { t } = useT();
|
|
22799
22872
|
const nicknameValue = useNicknameStore((st) => st.nicknameValue);
|
|
@@ -22818,7 +22891,7 @@ function useNicknameAvailability(currentNickname) {
|
|
|
22818
22891
|
useNicknameStore.getState().setError(error?.message || "Failed to check nickname availability");
|
|
22819
22892
|
}
|
|
22820
22893
|
});
|
|
22821
|
-
const debouncedCheckAvailability =
|
|
22894
|
+
const debouncedCheckAvailability = useCallback26(debounce4(checkAvailability, DEBOUNCE_MS), [checkAvailability]);
|
|
22822
22895
|
useEffect36(() => {
|
|
22823
22896
|
if (!currentNickname) return;
|
|
22824
22897
|
const normalizedInputValue = normalizeNickname(nicknameValue);
|
|
@@ -22848,7 +22921,7 @@ var init_useNicknameAvailability = __esm({
|
|
|
22848
22921
|
// src/internal/components/NicknameMenu/NicknameEditForm.tsx
|
|
22849
22922
|
import { useMutation as useMutation16, useQueryClient as useQueryClient21 } from "@tanstack/react-query";
|
|
22850
22923
|
import { AtSignIcon, CopyIcon as CopyIcon2, LoaderIcon as LoaderIcon12, SaveIcon } from "lucide-react";
|
|
22851
|
-
import { useCallback as
|
|
22924
|
+
import { useCallback as useCallback27, useEffect as useEffect37, useRef as useRef18, useState as useState23 } from "react";
|
|
22852
22925
|
import { Fragment as Fragment34, jsx as jsx98, jsxs as jsxs89 } from "react/jsx-runtime";
|
|
22853
22926
|
function NicknameEditForm(props) {
|
|
22854
22927
|
const { isInitialUser, nicknameInfo } = props;
|
|
@@ -22897,7 +22970,7 @@ function NicknameEditForm(props) {
|
|
|
22897
22970
|
);
|
|
22898
22971
|
}
|
|
22899
22972
|
});
|
|
22900
|
-
const handleNicknameInputChange =
|
|
22973
|
+
const handleNicknameInputChange = useCallback27(
|
|
22901
22974
|
(e) => {
|
|
22902
22975
|
const { error, setError, setNicknameValue } = useNicknameStore.getState();
|
|
22903
22976
|
const nextInputValue = e.target.value;
|
|
@@ -22911,7 +22984,7 @@ function NicknameEditForm(props) {
|
|
|
22911
22984
|
},
|
|
22912
22985
|
[t]
|
|
22913
22986
|
);
|
|
22914
|
-
const handleSubmit =
|
|
22987
|
+
const handleSubmit = useCallback27(
|
|
22915
22988
|
(e) => {
|
|
22916
22989
|
const { nicknameValue: nicknameValue2, setError } = useNicknameStore.getState();
|
|
22917
22990
|
if (!canChange) {
|
|
@@ -24149,14 +24222,14 @@ var init_useUserAssetsPolicies = __esm({
|
|
|
24149
24222
|
// src/internal/components/SecurityMenu/UserPolicies/PolicyForm.tsx
|
|
24150
24223
|
import { useMutation as useMutation18, useQueryClient as useQueryClient23 } from "@tanstack/react-query";
|
|
24151
24224
|
import { ChevronRightIcon as ChevronRightIcon2, ChevronUpIcon as ChevronUpIcon2, LoaderIcon as LoaderIcon16, PlusIcon, TrashIcon } from "lucide-react";
|
|
24152
|
-
import { useCallback as
|
|
24225
|
+
import { useCallback as useCallback28, useState as useState26 } from "react";
|
|
24153
24226
|
import { Fragment as Fragment37, jsx as jsx106, jsxs as jsxs97 } from "react/jsx-runtime";
|
|
24154
24227
|
function AddressListEditor(props) {
|
|
24155
24228
|
const { label, assets = [], addresses, onChange } = props;
|
|
24156
24229
|
const [isAssetSelector, setIsAssetSelector] = useState26(false);
|
|
24157
24230
|
const [customAddress, setCustomAddress] = useState26("");
|
|
24158
24231
|
const [customAddressError, setCustomAddressError] = useState26(null);
|
|
24159
|
-
const handleAddress =
|
|
24232
|
+
const handleAddress = useCallback28(
|
|
24160
24233
|
(addressToAdd) => {
|
|
24161
24234
|
if (!isValidAddress(addressToAdd)) {
|
|
24162
24235
|
setCustomAddressError("Bad address");
|
|
@@ -25470,7 +25543,7 @@ var init_useOperationHashesStore = __esm({
|
|
|
25470
25543
|
|
|
25471
25544
|
// src/internal/components/SendMenu/hyperbridge/hooks/useBridge.ts
|
|
25472
25545
|
import { useMutation as useMutation20, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
|
|
25473
|
-
import { useCallback as
|
|
25546
|
+
import { useCallback as useCallback29 } from "react";
|
|
25474
25547
|
import { useSwitchChain as useSwitchChain2, useWalletClient } from "wagmi";
|
|
25475
25548
|
function useBridge() {
|
|
25476
25549
|
const qc = useQueryClient25();
|
|
@@ -25478,7 +25551,7 @@ function useBridge() {
|
|
|
25478
25551
|
const address = useSession((st) => st.address);
|
|
25479
25552
|
const { data: walletClient } = useWalletClient();
|
|
25480
25553
|
const { mutateAsync: switchChainAsync } = useSwitchChain2();
|
|
25481
|
-
const swapDirection =
|
|
25554
|
+
const swapDirection = useCallback29(() => {
|
|
25482
25555
|
const {
|
|
25483
25556
|
// bridgeStep,
|
|
25484
25557
|
originChain,
|
|
@@ -25529,7 +25602,7 @@ function useBridge() {
|
|
|
25529
25602
|
useFlowSelectorStore.getState().setError(error instanceof Error ? error.message : String(error));
|
|
25530
25603
|
}
|
|
25531
25604
|
});
|
|
25532
|
-
const handleQuoteEstimation =
|
|
25605
|
+
const handleQuoteEstimation = useCallback29((amnt) => {
|
|
25533
25606
|
const { originChain, destinationChain, bridgeSender } = useBridgeStore.getState();
|
|
25534
25607
|
if (!amnt || !Number(amnt)) {
|
|
25535
25608
|
useBridgeStore.getState().setQuote(null);
|
|
@@ -25947,7 +26020,7 @@ var init_ResolveChainIcon = __esm({
|
|
|
25947
26020
|
// src/internal/components/SendMenu/hyperbridge/hooks/useBridgeBalance.ts
|
|
25948
26021
|
import { CHAINS_BROWSERS_TRANSPORTS as CHAINS_BROWSERS_TRANSPORTS2 } from "@embarkai/core";
|
|
25949
26022
|
import { useQuery as useQuery25, useQueryClient as useQueryClient26 } from "@tanstack/react-query";
|
|
25950
|
-
import { useCallback as
|
|
26023
|
+
import { useCallback as useCallback30, useEffect as useEffect46 } from "react";
|
|
25951
26024
|
import { createPublicClient as createPublicClient2, erc20Abi as erc20Abi3, formatUnits as formatUnits9, http as http3 } from "viem";
|
|
25952
26025
|
import { useSwitchChain as useSwitchChain3 } from "wagmi";
|
|
25953
26026
|
function useBridgeBalance(isLoadingWarpRoutes, hyperlaneWarpRoutes) {
|
|
@@ -26037,7 +26110,7 @@ function useBridgeBalance(isLoadingWarpRoutes, hyperlaneWarpRoutes) {
|
|
|
26037
26110
|
};
|
|
26038
26111
|
}
|
|
26039
26112
|
});
|
|
26040
|
-
const refreshRouteTokenBalance =
|
|
26113
|
+
const refreshRouteTokenBalance = useCallback30(
|
|
26041
26114
|
(senderWallet) => {
|
|
26042
26115
|
switch (true) {
|
|
26043
26116
|
case senderWallet === "embarkai-wallet":
|
|
@@ -27253,7 +27326,7 @@ var init_useNicknameResolve = __esm({
|
|
|
27253
27326
|
});
|
|
27254
27327
|
|
|
27255
27328
|
// src/hooks/useSendTransaction.ts
|
|
27256
|
-
import { useCallback as
|
|
27329
|
+
import { useCallback as useCallback31, useState as useState30 } from "react";
|
|
27257
27330
|
import { encodeFunctionData as encodeFunctionData2, isAddress as isAddress2, parseEther as parseEther2, parseUnits } from "viem";
|
|
27258
27331
|
function useSendTransaction() {
|
|
27259
27332
|
const session = useSession((st) => st.session);
|
|
@@ -27261,7 +27334,7 @@ function useSendTransaction() {
|
|
|
27261
27334
|
const [isLoading, setIsLoading] = useState30(false);
|
|
27262
27335
|
const [error, setError] = useState30(null);
|
|
27263
27336
|
const [userOpHash, setUserOpHash] = useState30(null);
|
|
27264
|
-
const sendTransaction =
|
|
27337
|
+
const sendTransaction = useCallback31(
|
|
27265
27338
|
async (params) => {
|
|
27266
27339
|
if (!session || !address) {
|
|
27267
27340
|
setError("No active session");
|
|
@@ -27358,7 +27431,7 @@ function useSendTransaction() {
|
|
|
27358
27431
|
},
|
|
27359
27432
|
[session, address]
|
|
27360
27433
|
);
|
|
27361
|
-
const reset =
|
|
27434
|
+
const reset = useCallback31(() => {
|
|
27362
27435
|
setError(null);
|
|
27363
27436
|
setUserOpHash(null);
|
|
27364
27437
|
setIsLoading(false);
|
|
@@ -29487,7 +29560,7 @@ var init_TransactionsGroup = __esm({
|
|
|
29487
29560
|
// src/internal/components/TransactionsMenu/TransactionsMenu.tsx
|
|
29488
29561
|
import { useQuery as useQuery28, useQueryClient as useQueryClient28 } from "@tanstack/react-query";
|
|
29489
29562
|
import { ArrowLeft as ArrowLeft22, Loader as Loader29, RefreshCw as RefreshCw3, XCircle as XCircle2 } from "lucide-react";
|
|
29490
|
-
import { useCallback as
|
|
29563
|
+
import { useCallback as useCallback32, useState as useState32 } from "react";
|
|
29491
29564
|
import { jsx as jsx128, jsxs as jsxs116 } from "react/jsx-runtime";
|
|
29492
29565
|
function TransactionsMenu() {
|
|
29493
29566
|
const qc = useQueryClient28();
|
|
@@ -29509,7 +29582,7 @@ function TransactionsMenu() {
|
|
|
29509
29582
|
queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address],
|
|
29510
29583
|
queryFn: () => getTransactionsListQuery({ address, chainConfig })
|
|
29511
29584
|
});
|
|
29512
|
-
const refreshTxHistory =
|
|
29585
|
+
const refreshTxHistory = useCallback32(
|
|
29513
29586
|
() => qc.invalidateQueries({ queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address] }),
|
|
29514
29587
|
[qc, chainConfig.id, address]
|
|
29515
29588
|
);
|
|
@@ -29887,11 +29960,11 @@ var init_PageMap = __esm({
|
|
|
29887
29960
|
});
|
|
29888
29961
|
|
|
29889
29962
|
// src/internal/hooks/usePageMapper.tsx
|
|
29890
|
-
import { useCallback as
|
|
29963
|
+
import { useCallback as useCallback33, useEffect as useEffect53 } from "react";
|
|
29891
29964
|
import { jsx as jsx130 } from "react/jsx-runtime";
|
|
29892
29965
|
function usePageMapper() {
|
|
29893
29966
|
const page = useLayoutDataStore((st) => st.page);
|
|
29894
|
-
const closeDialog =
|
|
29967
|
+
const closeDialog = useCallback33(() => {
|
|
29895
29968
|
useLayoutStore.setState({ isDialogAnimating: true });
|
|
29896
29969
|
setTimeout(() => {
|
|
29897
29970
|
useLayoutStore.setState({
|
|
@@ -29903,7 +29976,7 @@ function usePageMapper() {
|
|
|
29903
29976
|
});
|
|
29904
29977
|
}, CLEAR_DIALOG_TIMEOUT);
|
|
29905
29978
|
}, []);
|
|
29906
|
-
const openDialog =
|
|
29979
|
+
const openDialog = useCallback33((pageItem) => {
|
|
29907
29980
|
useLayoutStore.setState({
|
|
29908
29981
|
dialogContent: /* @__PURE__ */ jsx130(pageItem.component, {}),
|
|
29909
29982
|
isDialogOpen: true
|
|
@@ -29978,7 +30051,7 @@ var init_package = __esm({
|
|
|
29978
30051
|
"package.json"() {
|
|
29979
30052
|
package_default = {
|
|
29980
30053
|
name: "@embarkai/ui-kit",
|
|
29981
|
-
version: "0.4.
|
|
30054
|
+
version: "0.4.116",
|
|
29982
30055
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
29983
30056
|
type: "module",
|
|
29984
30057
|
main: "./dist/index.cjs",
|
|
@@ -30084,7 +30157,6 @@ var init_package = __esm({
|
|
|
30084
30157
|
// src/internal/components/Footer/Footer.tsx
|
|
30085
30158
|
import { useMutation as useMutation22, useQueryClient as useQueryClient29 } from "@tanstack/react-query";
|
|
30086
30159
|
import { Loader as Loader30, LogOut } from "lucide-react";
|
|
30087
|
-
import { useDisconnect as useDisconnect5 } from "wagmi";
|
|
30088
30160
|
import { jsx as jsx131, jsxs as jsxs118 } from "react/jsx-runtime";
|
|
30089
30161
|
function Footer() {
|
|
30090
30162
|
const qc = useQueryClient29();
|
|
@@ -30093,7 +30165,7 @@ function Footer() {
|
|
|
30093
30165
|
const address = useSession((st) => st.address);
|
|
30094
30166
|
const chainConfig = useSession((st) => st.chainConfig);
|
|
30095
30167
|
const isDialogForced = useLayoutStore((st) => st.isDialogForced);
|
|
30096
|
-
const { mutate: wagmiDisconnect } =
|
|
30168
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
30097
30169
|
mutation: {
|
|
30098
30170
|
onSuccess: () => {
|
|
30099
30171
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -30207,6 +30279,7 @@ var init_Footer = __esm({
|
|
|
30207
30279
|
init_ProviderContext();
|
|
30208
30280
|
init_SessionContext();
|
|
30209
30281
|
init_i18n();
|
|
30282
|
+
init_useSafeDisconnect();
|
|
30210
30283
|
init_auth();
|
|
30211
30284
|
init_base3();
|
|
30212
30285
|
init_useLayoutDataStore();
|
|
@@ -30303,7 +30376,7 @@ var init_onborading_setup = __esm({
|
|
|
30303
30376
|
|
|
30304
30377
|
// src/internal/components/Header/Header.tsx
|
|
30305
30378
|
import { CircleQuestionMarkIcon, Copy as Copy4, Loader as Loader31 } from "lucide-react";
|
|
30306
|
-
import { useCallback as
|
|
30379
|
+
import { useCallback as useCallback34, useRef as useRef21, useState as useState33 } from "react";
|
|
30307
30380
|
import { Fragment as Fragment46, jsx as jsx132, jsxs as jsxs119 } from "react/jsx-runtime";
|
|
30308
30381
|
function formatAddress3(addr) {
|
|
30309
30382
|
if (!addr) return "";
|
|
@@ -30320,7 +30393,7 @@ function Header() {
|
|
|
30320
30393
|
const [copied, setCopied] = useState33(false);
|
|
30321
30394
|
const clickCountRef = useRef21(0);
|
|
30322
30395
|
const clickTimerRef = useRef21(null);
|
|
30323
|
-
const handleAvatarClick =
|
|
30396
|
+
const handleAvatarClick = useCallback34(() => {
|
|
30324
30397
|
clickCountRef.current += 1;
|
|
30325
30398
|
if (clickTimerRef.current) {
|
|
30326
30399
|
clearTimeout(clickTimerRef.current);
|
|
@@ -30784,7 +30857,7 @@ var init_DirectWalletHandler = __esm({
|
|
|
30784
30857
|
});
|
|
30785
30858
|
|
|
30786
30859
|
// src/internal/components/TssManager.tsx
|
|
30787
|
-
import React32, { useCallback as
|
|
30860
|
+
import React32, { useCallback as useCallback35 } from "react";
|
|
30788
30861
|
var TssManagerWithRef;
|
|
30789
30862
|
var init_TssManager = __esm({
|
|
30790
30863
|
"src/internal/components/TssManager.tsx"() {
|
|
@@ -30799,7 +30872,7 @@ var init_TssManager = __esm({
|
|
|
30799
30872
|
const setStatus = useSession((st) => st.setStatus);
|
|
30800
30873
|
const setSession = useSession((st) => st.setSession);
|
|
30801
30874
|
const setAddress = useSession((st) => st.setAddress);
|
|
30802
|
-
const onSessionCreated =
|
|
30875
|
+
const onSessionCreated = useCallback35(
|
|
30803
30876
|
(session, address) => {
|
|
30804
30877
|
setSession(session);
|
|
30805
30878
|
setAddress(address);
|
|
@@ -32250,7 +32323,7 @@ var init_iframe_manager = __esm({
|
|
|
32250
32323
|
*/
|
|
32251
32324
|
handleMessage(event) {
|
|
32252
32325
|
const message = event.data;
|
|
32253
|
-
if (!message || typeof message !== "object" || !message.type) {
|
|
32326
|
+
if (!message || typeof message !== "object" || typeof message.type !== "string" || !message.type) {
|
|
32254
32327
|
return;
|
|
32255
32328
|
}
|
|
32256
32329
|
message.type = this.normalizeMessageType(message.type);
|
|
@@ -33343,7 +33416,7 @@ import { initSdkErrorTracking } from "@embarkai/core/internal/error-tracking";
|
|
|
33343
33416
|
import { merge as merge3 } from "lodash-es";
|
|
33344
33417
|
import {
|
|
33345
33418
|
createContext,
|
|
33346
|
-
useCallback as
|
|
33419
|
+
useCallback as useCallback36,
|
|
33347
33420
|
useContext,
|
|
33348
33421
|
useEffect as useEffect57,
|
|
33349
33422
|
useMemo as useMemo21,
|
|
@@ -33372,7 +33445,7 @@ function Provider(props) {
|
|
|
33372
33445
|
useEffect57(() => notifyNoProjetctId(projectId), [projectId]);
|
|
33373
33446
|
const config = useRef22(merge3({}, DEFAULT_PROVIDER_CONFIG, { projectId }, initialConfig));
|
|
33374
33447
|
const wagmiConfig3 = useRef22(getWagmiConfig(config.current?.wallet?.walletConnectId || null));
|
|
33375
|
-
const updateConfig =
|
|
33448
|
+
const updateConfig = useCallback36((updates) => {
|
|
33376
33449
|
const prev = config.current;
|
|
33377
33450
|
const next = { ...prev };
|
|
33378
33451
|
if (updates.projectId !== void 0) next.projectId = updates.projectId;
|
|
@@ -33406,7 +33479,7 @@ function Provider(props) {
|
|
|
33406
33479
|
if (updates.translations) next.translations = { ...next.translations, ...updates.translations };
|
|
33407
33480
|
config.current = next;
|
|
33408
33481
|
}, []);
|
|
33409
|
-
const updateCallbacks =
|
|
33482
|
+
const updateCallbacks = useCallback36((updates) => {
|
|
33410
33483
|
const prev = callbacksRef.current;
|
|
33411
33484
|
const next = updates ? { ...prev, ...updates } : void 0;
|
|
33412
33485
|
callbacksRef.current = next;
|
|
@@ -34475,12 +34548,12 @@ init_useErc3643Compliance();
|
|
|
34475
34548
|
|
|
34476
34549
|
// src/hooks/useWalletMode.ts
|
|
34477
34550
|
init_useExternalWalletStore();
|
|
34478
|
-
import { useCallback as
|
|
34551
|
+
import { useCallback as useCallback39 } from "react";
|
|
34479
34552
|
function useWalletMode() {
|
|
34480
34553
|
const configMode = useExternalWalletStore((st) => st.configMode);
|
|
34481
34554
|
const activeMode = useExternalWalletStore((st) => st.activeMode);
|
|
34482
34555
|
const setActiveMode = useExternalWalletStore((st) => st.setActiveMode);
|
|
34483
|
-
const switchMode =
|
|
34556
|
+
const switchMode = useCallback39(
|
|
34484
34557
|
(mode) => {
|
|
34485
34558
|
if (configMode !== "both") return;
|
|
34486
34559
|
setActiveMode(mode);
|
|
@@ -34497,8 +34570,8 @@ function useWalletMode() {
|
|
|
34497
34570
|
|
|
34498
34571
|
// src/hooks/useDirectWallet.ts
|
|
34499
34572
|
init_useOpenPage();
|
|
34500
|
-
|
|
34501
|
-
import {
|
|
34573
|
+
init_useSafeDisconnect();
|
|
34574
|
+
import { useCallback as useCallback40 } from "react";
|
|
34502
34575
|
init_useExternalWalletStore();
|
|
34503
34576
|
function useDirectWallet() {
|
|
34504
34577
|
const address = useExternalWalletStore((st) => st.externalAddress);
|
|
@@ -34506,11 +34579,11 @@ function useDirectWallet() {
|
|
|
34506
34579
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
34507
34580
|
const connectorName = useExternalWalletStore((st) => st.connectorName);
|
|
34508
34581
|
const { open: openEmbarkAI } = useOpenPage();
|
|
34509
|
-
const { mutate: wagmiDisconnect } =
|
|
34510
|
-
const connect =
|
|
34582
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect();
|
|
34583
|
+
const connect = useCallback40((connectFlowType = "connect") => {
|
|
34511
34584
|
openEmbarkAI("connect-external-wallet" /* CONNECT_EXTERNAL_WALLET */, { connectFlowType });
|
|
34512
34585
|
}, []);
|
|
34513
|
-
const disconnect =
|
|
34586
|
+
const disconnect = useCallback40(() => {
|
|
34514
34587
|
wagmiDisconnect();
|
|
34515
34588
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
34516
34589
|
}, [wagmiDisconnect]);
|
|
@@ -34526,7 +34599,7 @@ function useDirectWallet() {
|
|
|
34526
34599
|
}
|
|
34527
34600
|
|
|
34528
34601
|
// src/hooks/useSendDirectTransaction.ts
|
|
34529
|
-
import { useCallback as
|
|
34602
|
+
import { useCallback as useCallback41, useState as useState39 } from "react";
|
|
34530
34603
|
import { isAddress as isAddress4, parseEther as parseEther3 } from "viem";
|
|
34531
34604
|
import { useConnection as useConnection2, useSwitchChain as useSwitchChain4, useSendTransaction as useWagmiSendTransaction } from "wagmi";
|
|
34532
34605
|
|
|
@@ -34552,7 +34625,7 @@ function useSendDirectTransaction() {
|
|
|
34552
34625
|
const [isPending, setIsPending] = useState39(false);
|
|
34553
34626
|
const [error, setError] = useState39(null);
|
|
34554
34627
|
const [txHash, setTxHash] = useState39(null);
|
|
34555
|
-
const sendTransactionAsync =
|
|
34628
|
+
const sendTransactionAsync = useCallback41(
|
|
34556
34629
|
async (params) => {
|
|
34557
34630
|
if (!isConnected || !connector) {
|
|
34558
34631
|
const message = "No external wallet connected";
|
|
@@ -34589,7 +34662,7 @@ function useSendDirectTransaction() {
|
|
|
34589
34662
|
},
|
|
34590
34663
|
[isConnected, connector, sendWagmiTransactionAsync, switchChainAsync]
|
|
34591
34664
|
);
|
|
34592
|
-
const sendTransaction =
|
|
34665
|
+
const sendTransaction = useCallback41(
|
|
34593
34666
|
async (params) => {
|
|
34594
34667
|
try {
|
|
34595
34668
|
return await sendTransactionAsync(params);
|
|
@@ -34599,7 +34672,7 @@ function useSendDirectTransaction() {
|
|
|
34599
34672
|
},
|
|
34600
34673
|
[sendTransactionAsync]
|
|
34601
34674
|
);
|
|
34602
|
-
const reset =
|
|
34675
|
+
const reset = useCallback41(() => {
|
|
34603
34676
|
setError(null);
|
|
34604
34677
|
setTxHash(null);
|
|
34605
34678
|
setIsPending(false);
|
|
@@ -34611,7 +34684,7 @@ function useSendDirectTransaction() {
|
|
|
34611
34684
|
init_SessionContext();
|
|
34612
34685
|
init_account2();
|
|
34613
34686
|
init_linkedProfiles();
|
|
34614
|
-
import { useCallback as
|
|
34687
|
+
import { useCallback as useCallback42, useMemo as useMemo23, useState as useState40 } from "react";
|
|
34615
34688
|
import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress5, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
|
|
34616
34689
|
var ERC20_TRANSFER_ABI2 = [
|
|
34617
34690
|
{
|
|
@@ -34634,7 +34707,7 @@ function useTransferToLinkedWallet() {
|
|
|
34634
34707
|
() => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
|
|
34635
34708
|
[profiles]
|
|
34636
34709
|
);
|
|
34637
|
-
const transfer =
|
|
34710
|
+
const transfer = useCallback42(
|
|
34638
34711
|
async (params) => {
|
|
34639
34712
|
if (!session) {
|
|
34640
34713
|
setError("No active session");
|
|
@@ -34685,7 +34758,7 @@ function useTransferToLinkedWallet() {
|
|
|
34685
34758
|
},
|
|
34686
34759
|
[session, linkedWallets]
|
|
34687
34760
|
);
|
|
34688
|
-
const reset =
|
|
34761
|
+
const reset = useCallback42(() => {
|
|
34689
34762
|
setError(null);
|
|
34690
34763
|
setUserOpHash(null);
|
|
34691
34764
|
setIsPending(false);
|
|
@@ -34708,16 +34781,16 @@ function useNativeWalletSignature() {
|
|
|
34708
34781
|
}
|
|
34709
34782
|
|
|
34710
34783
|
// src/hooks/useLogout.ts
|
|
34784
|
+
init_useSafeDisconnect();
|
|
34711
34785
|
init_ProviderContext();
|
|
34712
34786
|
init_SessionContext();
|
|
34713
34787
|
init_useExternalWalletStore();
|
|
34714
34788
|
import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
|
|
34715
|
-
import { useCallback as
|
|
34716
|
-
import { useDisconnect as useDisconnect7 } from "wagmi";
|
|
34789
|
+
import { useCallback as useCallback43 } from "react";
|
|
34717
34790
|
function useLogout() {
|
|
34718
34791
|
const { callbacksRef } = useProviderConfig();
|
|
34719
34792
|
const address = useSession((st) => st.address);
|
|
34720
|
-
const { mutate: wagmiDisconnect } =
|
|
34793
|
+
const { mutate: wagmiDisconnect } = useSafeDisconnect({
|
|
34721
34794
|
mutation: {
|
|
34722
34795
|
onSuccess: () => {
|
|
34723
34796
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -34728,7 +34801,7 @@ function useLogout() {
|
|
|
34728
34801
|
}
|
|
34729
34802
|
}
|
|
34730
34803
|
});
|
|
34731
|
-
const logout2 =
|
|
34804
|
+
const logout2 = useCallback43(async () => {
|
|
34732
34805
|
const { setSession, setIsLoading, setAddress, setStatus, setError } = useSession.getState();
|
|
34733
34806
|
const prevAddress = address;
|
|
34734
34807
|
let userId = null;
|