@embarkai/ui-kit 0.4.105 → 0.4.107
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 +226 -161
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +178 -103
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7575,6 +7575,7 @@ var init_en = __esm({
|
|
|
7575
7575
|
connectMenu: {
|
|
7576
7576
|
connectWallet: "Connect Wallet Profile",
|
|
7577
7577
|
noWallets: "No wallets available to connect",
|
|
7578
|
+
requestPending: "{{wallet}} already has a pending request from this site. Open {{wallet}}, reject or close that request, then try again.",
|
|
7578
7579
|
instructions: {
|
|
7579
7580
|
follow: "Watch your connecting wallet app.\nYou will be asked to:\n {{steps}}",
|
|
7580
7581
|
confirm: "- 1. Confirm your wallet connection into embarkAI",
|
|
@@ -8167,6 +8168,7 @@ var init_ru = __esm({
|
|
|
8167
8168
|
connectMenu: {
|
|
8168
8169
|
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",
|
|
8169
8170
|
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",
|
|
8171
|
+
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.",
|
|
8170
8172
|
instructions: {
|
|
8171
8173
|
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}}",
|
|
8172
8174
|
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",
|
|
@@ -8759,6 +8761,7 @@ var init_zh = __esm({
|
|
|
8759
8761
|
connectMenu: {
|
|
8760
8762
|
connectWallet: "\u8FDE\u63A5\u94B1\u5305\u914D\u7F6E\u6587\u4EF6",
|
|
8761
8763
|
noWallets: "\u6CA1\u6709\u53EF\u8FDE\u63A5\u7684\u94B1\u5305",
|
|
8764
|
+
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",
|
|
8762
8765
|
instructions: {
|
|
8763
8766
|
follow: "\u8BF7\u67E5\u770B\u60A8\u6B63\u5728\u8FDE\u63A5\u7684\u94B1\u5305\u5E94\u7528\u3002\n\u60A8\u5C06\u88AB\u8981\u6C42\uFF1A\n {{steps}}",
|
|
8764
8767
|
confirm: "- 1. \u786E\u8BA4\u5C06\u60A8\u7684\u94B1\u5305\u8FDE\u63A5\u5230 embarkAI",
|
|
@@ -16806,16 +16809,19 @@ function getProviderCaption(provider) {
|
|
|
16806
16809
|
function ProviderCard(props) {
|
|
16807
16810
|
const { provider, meta, externalId, disabled } = props;
|
|
16808
16811
|
const { t } = useT();
|
|
16809
|
-
const
|
|
16812
|
+
const connections = (0, import_wagmi.useConnections)();
|
|
16810
16813
|
const {
|
|
16811
16814
|
mutate: connectExternalWallet,
|
|
16812
16815
|
disconnect: disconnectExternalWallet,
|
|
16813
16816
|
isPending: isConnectingExternalWallet,
|
|
16814
16817
|
variables: pendingConnectVariables,
|
|
16815
16818
|
isAvailable: isConnectExternalWalletAvailable
|
|
16816
|
-
} = useExternalWalletConnnect(
|
|
16817
|
-
|
|
16818
|
-
|
|
16819
|
+
} = useExternalWalletConnnect({
|
|
16820
|
+
// onSuccess: undefined,
|
|
16821
|
+
onError: ({ connector, error }) => {
|
|
16822
|
+
console.warn("[useExternalWalletConnect]", connector, error);
|
|
16823
|
+
}
|
|
16824
|
+
});
|
|
16819
16825
|
const { data: providers = [] } = useProvidersList();
|
|
16820
16826
|
if (!provider) {
|
|
16821
16827
|
console.warn("[ProviderCard] Received undefined provider");
|
|
@@ -16828,7 +16834,7 @@ function ProviderCard(props) {
|
|
|
16828
16834
|
};
|
|
16829
16835
|
const info = getProviderDisplayInfo(provider);
|
|
16830
16836
|
const allowUnlink = canUnlink(props);
|
|
16831
|
-
const isWalletProviderConnected =
|
|
16837
|
+
const isWalletProviderConnected = provider === "wallet" && connections.some((c) => c.accounts.includes(externalId));
|
|
16832
16838
|
const IconComponent = provider === "wallet" ? WALLET_ICONS[meta?.walletType || "default"] || WALLET_ICONS.default : info.icon;
|
|
16833
16839
|
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "w-full flex items-center justify-between gap-[var(--ui-kit-gap)]", children: [
|
|
16834
16840
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
@@ -16906,8 +16912,8 @@ function ProviderCard(props) {
|
|
|
16906
16912
|
disabled: disabled || isConnectingExternalWallet,
|
|
16907
16913
|
title: t("passport:common.delete"),
|
|
16908
16914
|
onClick: () => {
|
|
16909
|
-
setConfirmUnlink({ provider, providerName: info.name, externalId });
|
|
16910
|
-
setPage("unlink-provider" /* UNLINK_PROVIDER */);
|
|
16915
|
+
useManageWalletStore.getState().setConfirmUnlink({ provider, providerName: info.name, externalId });
|
|
16916
|
+
useLayoutDataStore.getState().setPage("unlink-provider" /* UNLINK_PROVIDER */);
|
|
16911
16917
|
},
|
|
16912
16918
|
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_lucide_react30.Trash2Icon, { className: "w-4 h-4 text-[var(--ui-kit-bg-error)]" })
|
|
16913
16919
|
}
|
|
@@ -16915,15 +16921,15 @@ function ProviderCard(props) {
|
|
|
16915
16921
|
] })
|
|
16916
16922
|
] });
|
|
16917
16923
|
}
|
|
16918
|
-
var import_lucide_react30, import_jsx_runtime71;
|
|
16924
|
+
var import_lucide_react30, import_wagmi, import_jsx_runtime71;
|
|
16919
16925
|
var init_ProviderCard = __esm({
|
|
16920
16926
|
"src/internal/components/ManageWalletMenu/ProviderCard.tsx"() {
|
|
16921
16927
|
init_useLayoutDataStore();
|
|
16922
16928
|
init_useT();
|
|
16923
16929
|
init_wallets();
|
|
16924
16930
|
import_lucide_react30 = require("lucide-react");
|
|
16931
|
+
import_wagmi = require("wagmi");
|
|
16925
16932
|
init_types();
|
|
16926
|
-
init_useExternalWalletStore();
|
|
16927
16933
|
init_cn();
|
|
16928
16934
|
init_ConnectExternalWalletMenu2();
|
|
16929
16935
|
init_button();
|
|
@@ -17139,7 +17145,7 @@ function UnlinkProviderMenu() {
|
|
|
17139
17145
|
const qc = (0, import_react_query24.useQueryClient)();
|
|
17140
17146
|
const address = useSession((st) => st.address);
|
|
17141
17147
|
const { callbacksRef } = useProviderConfig();
|
|
17142
|
-
const { disconnect: disconnectExternalWallet } = (0,
|
|
17148
|
+
const { disconnect: disconnectExternalWallet } = (0, import_wagmi2.useDisconnect)();
|
|
17143
17149
|
const isExternalConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
17144
17150
|
const { t } = useT();
|
|
17145
17151
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
@@ -17226,7 +17232,7 @@ function UnlinkProviderMenu() {
|
|
|
17226
17232
|
] })
|
|
17227
17233
|
] });
|
|
17228
17234
|
}
|
|
17229
|
-
var import_react_query24, import_lucide_react32, import_react43,
|
|
17235
|
+
var import_react_query24, import_lucide_react32, import_react43, import_wagmi2, import_jsx_runtime73;
|
|
17230
17236
|
var init_UnlinkProviderMenu = __esm({
|
|
17231
17237
|
"src/internal/components/ManageWalletMenu/UnlinkProviderMenu.tsx"() {
|
|
17232
17238
|
init_useLayoutDataStore();
|
|
@@ -17237,7 +17243,7 @@ var init_UnlinkProviderMenu = __esm({
|
|
|
17237
17243
|
import_react_query24 = require("@tanstack/react-query");
|
|
17238
17244
|
import_lucide_react32 = require("lucide-react");
|
|
17239
17245
|
import_react43 = require("react");
|
|
17240
|
-
|
|
17246
|
+
import_wagmi2 = require("wagmi");
|
|
17241
17247
|
init_auth();
|
|
17242
17248
|
init_useExternalWalletStore();
|
|
17243
17249
|
init_button();
|
|
@@ -17323,19 +17329,50 @@ function getConnectFlowType(params) {
|
|
|
17323
17329
|
if (!isEmbarkAI) return "auth";
|
|
17324
17330
|
return connectFlow;
|
|
17325
17331
|
}
|
|
17332
|
+
function someInErrorChain(error, predicate) {
|
|
17333
|
+
let current = error;
|
|
17334
|
+
for (let depth = 0; current && depth < 10; depth++) {
|
|
17335
|
+
if (predicate(current)) return true;
|
|
17336
|
+
current = current.cause;
|
|
17337
|
+
}
|
|
17338
|
+
return false;
|
|
17339
|
+
}
|
|
17326
17340
|
function ConnectExternalWalletMenu() {
|
|
17327
17341
|
const { config, callbacksRef } = useProviderConfig();
|
|
17328
17342
|
const allowedWallets = config.current?.wallet?.allowedWallets;
|
|
17329
17343
|
const walletMode = config.current?.wallet?.mode || "both";
|
|
17330
17344
|
const qc = (0, import_react_query25.useQueryClient)();
|
|
17331
17345
|
const { t } = useT();
|
|
17332
|
-
const
|
|
17333
|
-
const {
|
|
17346
|
+
const embarkAiAddress = useSession((st) => st.address);
|
|
17347
|
+
const { close: closeEmbarkAI } = useOpenPage();
|
|
17334
17348
|
const menuParams = useConnectExternalWalletMenuParams();
|
|
17335
|
-
const connectors = (0,
|
|
17349
|
+
const connectors = (0, import_wagmi3.useConnectors)();
|
|
17336
17350
|
const hasInjectedWallet2 = useHasInjectedWallet();
|
|
17337
|
-
const
|
|
17338
|
-
const
|
|
17351
|
+
const wagmiConfig3 = (0, import_wagmi3.useConfig)();
|
|
17352
|
+
const connections = (0, import_wagmi3.useConnections)();
|
|
17353
|
+
const { mutate: disconnect, mutateAsync: disconnectAsync } = (0, import_wagmi3.useDisconnect)();
|
|
17354
|
+
const { mutateAsync: signMessageAsync } = (0, import_wagmi3.useSignMessage)();
|
|
17355
|
+
const { mutateAsync: switchChainAsync } = (0, import_wagmi3.useSwitchChain)();
|
|
17356
|
+
const { mutateAsync: switchConnectionAsync } = (0, import_wagmi3.useSwitchConnection)();
|
|
17357
|
+
const [isPreparingConnect, setIsPreparingConnect] = (0, import_react46.useState)(false);
|
|
17358
|
+
const signOnSupportedChain = async (params) => {
|
|
17359
|
+
const { connector, account, message } = params;
|
|
17360
|
+
const signOnce = async (viaFallback = false) => {
|
|
17361
|
+
let chainId = await connector.getChainId();
|
|
17362
|
+
if (viaFallback) {
|
|
17363
|
+
await switchChainAsync({ connector, chainId: SIGN_FALLBACK_CHAIN_ID });
|
|
17364
|
+
chainId = SIGN_FALLBACK_CHAIN_ID;
|
|
17365
|
+
}
|
|
17366
|
+
const signature = await signMessageAsync({ connector, account, message });
|
|
17367
|
+
return { chainId, signature };
|
|
17368
|
+
};
|
|
17369
|
+
try {
|
|
17370
|
+
return await signOnce(false);
|
|
17371
|
+
} catch (error) {
|
|
17372
|
+
if (!isUnsupportedChainError(error)) throw error;
|
|
17373
|
+
return await signOnce(true);
|
|
17374
|
+
}
|
|
17375
|
+
};
|
|
17339
17376
|
const walletMenuOpenedFrom = useLayoutDataStore((st) => st.walletMenuOpenedFrom);
|
|
17340
17377
|
const { data: providers = [] } = (0, import_react_query25.useQuery)({
|
|
17341
17378
|
retry: false,
|
|
@@ -17355,7 +17392,24 @@ function ConnectExternalWalletMenu() {
|
|
|
17355
17392
|
callbacksRef.current?.onAccountUpdate?.({ providers: providers2 });
|
|
17356
17393
|
}
|
|
17357
17394
|
});
|
|
17358
|
-
const
|
|
17395
|
+
const keepOrReleaseExternalWallet = (connector, address, chainId) => {
|
|
17396
|
+
if (walletMode === "direct" || walletMode === "both") {
|
|
17397
|
+
useExternalWalletStore.getState().setExternalWallet({
|
|
17398
|
+
address,
|
|
17399
|
+
chainId,
|
|
17400
|
+
connectorName: connector.name || "Unknown Wallet"
|
|
17401
|
+
});
|
|
17402
|
+
} else {
|
|
17403
|
+
disconnect();
|
|
17404
|
+
const { externalAddress, clearExternalWallet } = useExternalWalletStore.getState();
|
|
17405
|
+
if (!!externalAddress) clearExternalWallet();
|
|
17406
|
+
}
|
|
17407
|
+
};
|
|
17408
|
+
const completeExternalConnect = (connector, address, chainId) => {
|
|
17409
|
+
useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "manage-wallet" /* MANAGE_WALLET */);
|
|
17410
|
+
keepOrReleaseExternalWallet(connector, address, chainId);
|
|
17411
|
+
};
|
|
17412
|
+
const { mutateAsync: loginOrLinkWallet, isPending: isLoginOrLinkWallet } = (0, import_react_query25.useMutation)({
|
|
17359
17413
|
mutationFn: async (payload) => {
|
|
17360
17414
|
const { walletData, connectFlowType } = payload;
|
|
17361
17415
|
switch (connectFlowType) {
|
|
@@ -17370,13 +17424,9 @@ function ConnectExternalWalletMenu() {
|
|
|
17370
17424
|
await linkWallet(walletData);
|
|
17371
17425
|
await onLinkingComplete(true);
|
|
17372
17426
|
return { linked: true, message: `Address ${walletData.address} linked` };
|
|
17373
|
-
// Connect external wallet flow, only if embarkAI is connected
|
|
17374
|
-
case "connect":
|
|
17375
|
-
return null;
|
|
17376
17427
|
}
|
|
17377
17428
|
},
|
|
17378
17429
|
onSuccess: async (response, { walletData, connector, connectFlowType }) => {
|
|
17379
|
-
let shouldKeepConnected = walletMode === "direct" || walletMode === "both";
|
|
17380
17430
|
switch (connectFlowType) {
|
|
17381
17431
|
case "auth":
|
|
17382
17432
|
useLayoutDataStore.getState().setPendingWalletLogin(response);
|
|
@@ -17386,23 +17436,11 @@ function ConnectExternalWalletMenu() {
|
|
|
17386
17436
|
const { linked, message } = response || {};
|
|
17387
17437
|
if (!linked && message.includes("already linked")) {
|
|
17388
17438
|
console.warn("[LINK STATUS] already linked", response);
|
|
17389
|
-
|
|
17390
|
-
useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "manage-wallet" /* MANAGE_WALLET */);
|
|
17439
|
+
await onLinkingComplete(false);
|
|
17391
17440
|
}
|
|
17392
17441
|
break;
|
|
17393
|
-
case "connect":
|
|
17394
|
-
useLayoutDataStore.getState().setPage(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
|
|
17395
|
-
break;
|
|
17396
|
-
}
|
|
17397
|
-
if (shouldKeepConnected && walletData.chainId && connector) {
|
|
17398
|
-
useExternalWalletStore.getState().setExternalWallet({
|
|
17399
|
-
address: walletData.address,
|
|
17400
|
-
chainId: walletData.chainId,
|
|
17401
|
-
connectorName: connector.name || "Unknown Wallet"
|
|
17402
|
-
});
|
|
17403
|
-
} else {
|
|
17404
|
-
disconnect();
|
|
17405
17442
|
}
|
|
17443
|
+
keepOrReleaseExternalWallet(connector, walletData.address, walletData.chainId);
|
|
17406
17444
|
useLayoutStore.getState().setIsDialogForced(false);
|
|
17407
17445
|
},
|
|
17408
17446
|
onError: async (err, { walletData, connectFlowType }) => {
|
|
@@ -17417,9 +17455,6 @@ function ConnectExternalWalletMenu() {
|
|
|
17417
17455
|
useManageWalletStore.getState().setAlert({ title: "Error", message: errorMsg });
|
|
17418
17456
|
await onLinkingComplete(false);
|
|
17419
17457
|
break;
|
|
17420
|
-
case "connect":
|
|
17421
|
-
openEmbarkAI(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
|
|
17422
|
-
break;
|
|
17423
17458
|
}
|
|
17424
17459
|
}
|
|
17425
17460
|
});
|
|
@@ -17427,77 +17462,77 @@ function ConnectExternalWalletMenu() {
|
|
|
17427
17462
|
mutateAsync: connect,
|
|
17428
17463
|
isPending: isConnectingExternalWallet,
|
|
17429
17464
|
variables: pendingConnectVariables
|
|
17430
|
-
} = (0,
|
|
17465
|
+
} = (0, import_wagmi3.useConnect)({
|
|
17431
17466
|
mutation: {
|
|
17432
|
-
onSuccess: async (
|
|
17433
|
-
const
|
|
17434
|
-
const projectId = config.current?.projectId;
|
|
17435
|
-
const projectName = projectId ? await fetchProjectName(projectId) : "EmbarkAI";
|
|
17467
|
+
onSuccess: async ({ chainId, accounts }, variables) => {
|
|
17468
|
+
const connector = variables.connector;
|
|
17436
17469
|
const signingWalletAddress = accounts[0];
|
|
17437
17470
|
const connectFlowType = getConnectFlowType({
|
|
17438
17471
|
isEmbarkAI: !!embarkAiAddress,
|
|
17439
17472
|
connectFlow: menuParams.current?.connectFlowType || "auth"
|
|
17440
17473
|
});
|
|
17441
|
-
|
|
17442
|
-
|
|
17443
|
-
|
|
17444
|
-
|
|
17445
|
-
message = createLoginMessage(signingWalletAddress, projectName);
|
|
17446
|
-
signature = await signMessageAsync({ message, account: signingWalletAddress });
|
|
17447
|
-
break;
|
|
17448
|
-
case "link":
|
|
17449
|
-
message = createSignatureMessage(signingWalletAddress, projectName);
|
|
17450
|
-
signature = await signMessageAsync({ message, account: signingWalletAddress });
|
|
17451
|
-
break;
|
|
17452
|
-
case "connect":
|
|
17453
|
-
message = "UNUSED_MESSAGE";
|
|
17454
|
-
signature = "0xUNUSED_SIGNATURE";
|
|
17455
|
-
break;
|
|
17456
|
-
}
|
|
17457
|
-
if (!message || !signature) {
|
|
17458
|
-
throw new Error("Failed to get sign message & signature");
|
|
17474
|
+
if (connectFlowType === "connect") {
|
|
17475
|
+
completeExternalConnect(connector, signingWalletAddress, chainId);
|
|
17476
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
17477
|
+
return;
|
|
17459
17478
|
}
|
|
17460
|
-
|
|
17479
|
+
const projectId = config.current?.projectId;
|
|
17480
|
+
const projectName = projectId ? await fetchProjectName(projectId) : "EmbarkAI";
|
|
17481
|
+
const createMessage = connectFlowType === "auth" ? createLoginMessage : createSignatureMessage;
|
|
17482
|
+
const message = createMessage(signingWalletAddress, projectName);
|
|
17483
|
+
const { signature, chainId: signedChainId } = await signOnSupportedChain({
|
|
17484
|
+
connector,
|
|
17485
|
+
account: signingWalletAddress,
|
|
17486
|
+
message
|
|
17487
|
+
});
|
|
17488
|
+
await loginOrLinkWallet({
|
|
17461
17489
|
connector,
|
|
17462
17490
|
connectFlowType,
|
|
17463
17491
|
walletData: {
|
|
17464
|
-
chainId,
|
|
17492
|
+
chainId: signedChainId,
|
|
17465
17493
|
address: signingWalletAddress,
|
|
17466
17494
|
signature,
|
|
17467
17495
|
message,
|
|
17468
|
-
walletName: connector
|
|
17469
|
-
|
|
17470
|
-
walletType: connector?.id || "unknown"
|
|
17496
|
+
walletName: connector.name || "Unknown Wallet",
|
|
17497
|
+
walletType: connector.id || "unknown"
|
|
17471
17498
|
}
|
|
17472
17499
|
});
|
|
17473
17500
|
},
|
|
17474
|
-
onError: (error, { connector }) =>
|
|
17475
|
-
const connectFlowType = getConnectFlowType({
|
|
17476
|
-
isEmbarkAI: !!embarkAiAddress,
|
|
17477
|
-
connectFlow: menuParams.current?.connectFlowType || "auth"
|
|
17478
|
-
});
|
|
17479
|
-
const setPage = useLayoutDataStore.getState().setPage;
|
|
17480
|
-
setTimeout(() => {
|
|
17481
|
-
switch (connectFlowType) {
|
|
17482
|
-
case "auth":
|
|
17483
|
-
setConnectError(error?.message || "Failed to connect wallet");
|
|
17484
|
-
break;
|
|
17485
|
-
case "link":
|
|
17486
|
-
setPage("manage-wallet" /* MANAGE_WALLET */);
|
|
17487
|
-
useManageWalletStore.getState().setAlert({
|
|
17488
|
-
title: `Failed to connect: ${connector.name}`,
|
|
17489
|
-
message: error?.message || "Failed to connect wallet before linking"
|
|
17490
|
-
});
|
|
17491
|
-
break;
|
|
17492
|
-
case "connect":
|
|
17493
|
-
setConnectError(error?.message || "Failed to connect wallet");
|
|
17494
|
-
break;
|
|
17495
|
-
}
|
|
17496
|
-
useLayoutStore.getState().setIsDialogForced(false);
|
|
17497
|
-
}, 100);
|
|
17498
|
-
}
|
|
17501
|
+
onError: (error, { connector }) => reportConnectError(error, connector)
|
|
17499
17502
|
}
|
|
17500
17503
|
});
|
|
17504
|
+
function reportConnectError(error, connector) {
|
|
17505
|
+
const connectFlowType = getConnectFlowType({
|
|
17506
|
+
isEmbarkAI: !!embarkAiAddress,
|
|
17507
|
+
connectFlow: menuParams.current?.connectFlowType || "auth"
|
|
17508
|
+
});
|
|
17509
|
+
const isRequestPending = isRequestPendingError(error);
|
|
17510
|
+
if (!isRequestPending && connectFlowType !== "connect" && wagmiConfig3.state.connections.has(connector.uid)) {
|
|
17511
|
+
disconnect({ connector });
|
|
17512
|
+
}
|
|
17513
|
+
const errorMessage = isRequestPending ? (
|
|
17514
|
+
// @ts-expect-error i18n typing
|
|
17515
|
+
t("passport:connectMenu.requestPending", { wallet: connector.name })
|
|
17516
|
+
) : error?.message;
|
|
17517
|
+
setTimeout(() => {
|
|
17518
|
+
switch (connectFlowType) {
|
|
17519
|
+
case "auth":
|
|
17520
|
+
setConnectError(errorMessage || "Failed to connect wallet");
|
|
17521
|
+
break;
|
|
17522
|
+
case "link":
|
|
17523
|
+
useLayoutDataStore.getState().setPage("manage-wallet" /* MANAGE_WALLET */);
|
|
17524
|
+
useManageWalletStore.getState().setAlert({
|
|
17525
|
+
title: `Failed to connect: ${connector.name}`,
|
|
17526
|
+
message: errorMessage || "Failed to connect wallet before linking"
|
|
17527
|
+
});
|
|
17528
|
+
break;
|
|
17529
|
+
case "connect":
|
|
17530
|
+
setConnectError(errorMessage || "Failed to connect wallet");
|
|
17531
|
+
break;
|
|
17532
|
+
}
|
|
17533
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
17534
|
+
}, 100);
|
|
17535
|
+
}
|
|
17501
17536
|
const visibleConnectors = (0, import_react46.useMemo)(() => {
|
|
17502
17537
|
const seen = /* @__PURE__ */ new Set();
|
|
17503
17538
|
const unique = connectors.filter((connector) => {
|
|
@@ -17537,8 +17572,8 @@ function ConnectExternalWalletMenu() {
|
|
|
17537
17572
|
variant: "ghost",
|
|
17538
17573
|
size: "icon",
|
|
17539
17574
|
title: t("passport:common.back"),
|
|
17540
|
-
disabled: isConnectingExternalWallet ||
|
|
17541
|
-
onClick: () => useLayoutDataStore.getState().setPage(walletMenuOpenedFrom ?? "
|
|
17575
|
+
disabled: isConnectingExternalWallet || isLoginOrLinkWallet,
|
|
17576
|
+
onClick: () => useLayoutDataStore.getState().setPage(walletMenuOpenedFrom ?? "manage-wallet" /* MANAGE_WALLET */),
|
|
17542
17577
|
children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_lucide_react33.ArrowLeft, { className: "h-4 w-4" })
|
|
17543
17578
|
}
|
|
17544
17579
|
),
|
|
@@ -17554,14 +17589,32 @@ function ConnectExternalWalletMenu() {
|
|
|
17554
17589
|
variant: "secondary",
|
|
17555
17590
|
size: "large",
|
|
17556
17591
|
className: "w-full justify-center",
|
|
17557
|
-
disabled: isConnectingExternalWallet,
|
|
17592
|
+
disabled: isConnectingExternalWallet || isPreparingConnect || isLoginOrLinkWallet,
|
|
17558
17593
|
onClick: async () => {
|
|
17559
17594
|
if (connectError) setConnectError(null);
|
|
17595
|
+
const connectFlowType = getConnectFlowType({
|
|
17596
|
+
isEmbarkAI: !!embarkAiAddress,
|
|
17597
|
+
connectFlow: menuParams.current?.connectFlowType || "auth"
|
|
17598
|
+
});
|
|
17599
|
+
setIsPreparingConnect(true);
|
|
17560
17600
|
try {
|
|
17561
|
-
|
|
17562
|
-
|
|
17601
|
+
const existingConnection = connections.find((c) => c.connector.uid === connector.uid);
|
|
17602
|
+
if (connectFlowType === "connect" && existingConnection?.accounts[0]) {
|
|
17603
|
+
await switchConnectionAsync({ connector });
|
|
17604
|
+
completeExternalConnect(connector, existingConnection.accounts[0], existingConnection.chainId);
|
|
17605
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
17606
|
+
return;
|
|
17607
|
+
}
|
|
17608
|
+
const connectionsToDrop = connections.filter((c) => c.connector.uid === connector.uid);
|
|
17609
|
+
for (const { connector: connectedConnector } of connectionsToDrop) {
|
|
17610
|
+
await disconnectAsync({ connector: connectedConnector });
|
|
17611
|
+
}
|
|
17612
|
+
} catch (error) {
|
|
17613
|
+
reportConnectError(error, connector);
|
|
17614
|
+
return;
|
|
17615
|
+
} finally {
|
|
17616
|
+
setIsPreparingConnect(false);
|
|
17563
17617
|
}
|
|
17564
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
17565
17618
|
switch (true) {
|
|
17566
17619
|
case (connector.id === "metaMaskSDK" && !hasInjectedWallet2):
|
|
17567
17620
|
closeEmbarkAI();
|
|
@@ -17613,7 +17666,7 @@ function ConnectExternalWalletMenu() {
|
|
|
17613
17666
|
] })
|
|
17614
17667
|
] });
|
|
17615
17668
|
}
|
|
17616
|
-
var import_react_query25, import_lucide_react33, import_react46,
|
|
17669
|
+
var import_react_query25, import_lucide_react33, import_react46, import_wagmi3, import_chains, import_jsx_runtime74, SIGN_FALLBACK_CHAIN_ID, REQUEST_PENDING_ERROR_CODE, isRequestPendingError, isUnsupportedChainError;
|
|
17617
17670
|
var init_ConnectExternalWalletMenu = __esm({
|
|
17618
17671
|
"src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx"() {
|
|
17619
17672
|
init_ProviderContext();
|
|
@@ -17625,7 +17678,8 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17625
17678
|
import_react_query25 = require("@tanstack/react-query");
|
|
17626
17679
|
import_lucide_react33 = require("lucide-react");
|
|
17627
17680
|
import_react46 = require("react");
|
|
17628
|
-
|
|
17681
|
+
import_wagmi3 = require("wagmi");
|
|
17682
|
+
import_chains = require("wagmi/chains");
|
|
17629
17683
|
init_common();
|
|
17630
17684
|
init_wallet();
|
|
17631
17685
|
init_useLayoutDataStore();
|
|
@@ -17638,16 +17692,21 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17638
17692
|
init_useConnectExternalWalletMenuParams();
|
|
17639
17693
|
init_useHasInjectedWallet();
|
|
17640
17694
|
import_jsx_runtime74 = require("react/jsx-runtime");
|
|
17695
|
+
SIGN_FALLBACK_CHAIN_ID = import_chains.mainnet.id;
|
|
17696
|
+
REQUEST_PENDING_ERROR_CODE = -32002;
|
|
17697
|
+
isRequestPendingError = (error) => someInErrorChain(error, (e) => e.code === REQUEST_PENDING_ERROR_CODE);
|
|
17698
|
+
isUnsupportedChainError = (error) => someInErrorChain(error, (e) => typeof e.message === "string" && e.message.includes("supportedNetworks"));
|
|
17641
17699
|
}
|
|
17642
17700
|
});
|
|
17643
17701
|
|
|
17644
17702
|
// src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts
|
|
17645
|
-
function useExternalWalletConnnect() {
|
|
17703
|
+
function useExternalWalletConnnect(options) {
|
|
17704
|
+
const { onSuccess, onError } = options || {};
|
|
17646
17705
|
const { config } = useProviderConfig();
|
|
17647
17706
|
const walletMode = config.current?.wallet?.mode;
|
|
17648
|
-
const connectors = (0,
|
|
17649
|
-
const { mutate: disconnect } = (0,
|
|
17650
|
-
const { mutate: connect, ...restUseConnect } = (0,
|
|
17707
|
+
const connectors = (0, import_wagmi4.useConnectors)();
|
|
17708
|
+
const { mutate: disconnect } = (0, import_wagmi4.useDisconnect)();
|
|
17709
|
+
const { mutate: connect, ...restUseConnect } = (0, import_wagmi4.useConnect)({
|
|
17651
17710
|
mutation: {
|
|
17652
17711
|
onSuccess: (connectionData, { connector }) => {
|
|
17653
17712
|
const { chainId, accounts } = connectionData;
|
|
@@ -17657,9 +17716,15 @@ function useExternalWalletConnnect() {
|
|
|
17657
17716
|
chainId,
|
|
17658
17717
|
connectorName: connector.name || "Unknown Wallet"
|
|
17659
17718
|
});
|
|
17719
|
+
onSuccess?.({ connected: true, address: signingWalletAddress });
|
|
17660
17720
|
useLayoutStore.getState().setIsDialogForced(false);
|
|
17661
17721
|
},
|
|
17662
|
-
onError: (error,
|
|
17722
|
+
onError: (error, { connector }) => {
|
|
17723
|
+
onError?.({
|
|
17724
|
+
connected: false,
|
|
17725
|
+
connector: connector?.name || "Unknown Wallet",
|
|
17726
|
+
error
|
|
17727
|
+
});
|
|
17663
17728
|
useLayoutStore.getState().setIsDialogForced(false);
|
|
17664
17729
|
}
|
|
17665
17730
|
}
|
|
@@ -17695,12 +17760,12 @@ function useExternalWalletConnnect() {
|
|
|
17695
17760
|
...restUseConnect
|
|
17696
17761
|
};
|
|
17697
17762
|
}
|
|
17698
|
-
var import_react47,
|
|
17763
|
+
var import_react47, import_wagmi4;
|
|
17699
17764
|
var init_useExternalWalletConnect = __esm({
|
|
17700
17765
|
"src/internal/components/ConnectExternalWalletMenu/useExternalWalletConnect.ts"() {
|
|
17701
17766
|
init_ProviderContext();
|
|
17702
17767
|
import_react47 = require("react");
|
|
17703
|
-
|
|
17768
|
+
import_wagmi4 = require("wagmi");
|
|
17704
17769
|
init_useLayoutStore();
|
|
17705
17770
|
init_useExternalWalletStore();
|
|
17706
17771
|
}
|
|
@@ -20723,7 +20788,7 @@ var init_methods = __esm({
|
|
|
20723
20788
|
});
|
|
20724
20789
|
|
|
20725
20790
|
// src/internal/components/KeyshareRestoreMenu/KeyshareRestoreMenu.tsx
|
|
20726
|
-
var import_react_query31, import_lucide_react46, import_react60,
|
|
20791
|
+
var import_react_query31, import_lucide_react46, import_react60, import_wagmi5, import_jsx_runtime87, RESTORE_COMPONENTS, KeyshareRestoreMenu;
|
|
20727
20792
|
var init_KeyshareRestoreMenu = __esm({
|
|
20728
20793
|
"src/internal/components/KeyshareRestoreMenu/KeyshareRestoreMenu.tsx"() {
|
|
20729
20794
|
init_ProviderContext();
|
|
@@ -20732,7 +20797,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
20732
20797
|
import_react_query31 = require("@tanstack/react-query");
|
|
20733
20798
|
import_lucide_react46 = require("lucide-react");
|
|
20734
20799
|
import_react60 = require("react");
|
|
20735
|
-
|
|
20800
|
+
import_wagmi5 = require("wagmi");
|
|
20736
20801
|
init_useLayoutDataStore();
|
|
20737
20802
|
init_useLayoutStore();
|
|
20738
20803
|
init_useExternalWalletStore();
|
|
@@ -20774,7 +20839,7 @@ var init_KeyshareRestoreMenu = __esm({
|
|
|
20774
20839
|
setIsDialogForced(false);
|
|
20775
20840
|
};
|
|
20776
20841
|
}, []);
|
|
20777
|
-
const { mutate: wagmiDisconnect } = (0,
|
|
20842
|
+
const { mutate: wagmiDisconnect } = (0, import_wagmi5.useDisconnect)({
|
|
20778
20843
|
mutation: {
|
|
20779
20844
|
onSuccess: () => {
|
|
20780
20845
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -25080,12 +25145,12 @@ var init_api5 = __esm({
|
|
|
25080
25145
|
});
|
|
25081
25146
|
|
|
25082
25147
|
// src/internal/components/SendMenu/hyperbridge/lib/chains.ts
|
|
25083
|
-
var import_read17,
|
|
25148
|
+
var import_read17, import_chains2, CHAINS_UI_META;
|
|
25084
25149
|
var init_chains = __esm({
|
|
25085
25150
|
"src/internal/components/SendMenu/hyperbridge/lib/chains.ts"() {
|
|
25086
25151
|
init_networks2();
|
|
25087
25152
|
import_read17 = require("@embarkai/core/read");
|
|
25088
|
-
|
|
25153
|
+
import_chains2 = require("wagmi/chains");
|
|
25089
25154
|
CHAINS_UI_META = {
|
|
25090
25155
|
lumiaprism: {
|
|
25091
25156
|
chainID: import_read17.lumiaMainnetChain.id,
|
|
@@ -25097,22 +25162,22 @@ var init_chains = __esm({
|
|
|
25097
25162
|
chain: import_read17.lumiaMainnetChain
|
|
25098
25163
|
},
|
|
25099
25164
|
bsc: {
|
|
25100
|
-
chainID:
|
|
25101
|
-
chainLabel:
|
|
25165
|
+
chainID: import_chains2.bsc.id,
|
|
25166
|
+
chainLabel: import_chains2.bsc.name,
|
|
25102
25167
|
chainName: "bsc",
|
|
25103
25168
|
// exact hyperlane registry chain name
|
|
25104
|
-
Icon: NETWORKS_ICONS[
|
|
25105
|
-
explorerUrl:
|
|
25106
|
-
chain:
|
|
25169
|
+
Icon: NETWORKS_ICONS[import_chains2.bsc.id],
|
|
25170
|
+
explorerUrl: import_chains2.bsc.blockExplorers.default.url,
|
|
25171
|
+
chain: import_chains2.bsc
|
|
25107
25172
|
},
|
|
25108
25173
|
ethereum: {
|
|
25109
|
-
chainID:
|
|
25110
|
-
chainLabel:
|
|
25174
|
+
chainID: import_chains2.mainnet.id,
|
|
25175
|
+
chainLabel: import_chains2.mainnet.name,
|
|
25111
25176
|
chainName: "ethereum",
|
|
25112
25177
|
// exact hyperlane registry chain name
|
|
25113
|
-
Icon: NETWORKS_ICONS[
|
|
25114
|
-
explorerUrl:
|
|
25115
|
-
chain:
|
|
25178
|
+
Icon: NETWORKS_ICONS[import_chains2.mainnet.id],
|
|
25179
|
+
explorerUrl: import_chains2.mainnet.blockExplorers.default.url,
|
|
25180
|
+
chain: import_chains2.mainnet
|
|
25116
25181
|
}
|
|
25117
25182
|
};
|
|
25118
25183
|
}
|
|
@@ -25436,8 +25501,8 @@ function useBridge() {
|
|
|
25436
25501
|
const qc = (0, import_react_query50.useQueryClient)();
|
|
25437
25502
|
const { t } = useT();
|
|
25438
25503
|
const address = useSession((st) => st.address);
|
|
25439
|
-
const { data: walletClient } = (0,
|
|
25440
|
-
const { mutateAsync: switchChainAsync } = (0,
|
|
25504
|
+
const { data: walletClient } = (0, import_wagmi6.useWalletClient)();
|
|
25505
|
+
const { mutateAsync: switchChainAsync } = (0, import_wagmi6.useSwitchChain)();
|
|
25441
25506
|
const swapDirection = (0, import_react80.useCallback)(() => {
|
|
25442
25507
|
const {
|
|
25443
25508
|
// bridgeStep,
|
|
@@ -25624,14 +25689,14 @@ function useBridge() {
|
|
|
25624
25689
|
isAssetBridging
|
|
25625
25690
|
};
|
|
25626
25691
|
}
|
|
25627
|
-
var import_react_query50, import_react80,
|
|
25692
|
+
var import_react_query50, import_react80, import_wagmi6;
|
|
25628
25693
|
var init_useBridge = __esm({
|
|
25629
25694
|
"src/internal/components/SendMenu/hyperbridge/hooks/useBridge.ts"() {
|
|
25630
25695
|
init_SessionContext();
|
|
25631
25696
|
init_i18n();
|
|
25632
25697
|
import_react_query50 = require("@tanstack/react-query");
|
|
25633
25698
|
import_react80 = require("react");
|
|
25634
|
-
|
|
25699
|
+
import_wagmi6 = require("wagmi");
|
|
25635
25700
|
init_useLayoutStore();
|
|
25636
25701
|
init_useExternalWalletStore();
|
|
25637
25702
|
init_useFlowSelector();
|
|
@@ -25918,7 +25983,7 @@ function useBridgeBalance(isLoadingWarpRoutes, hyperlaneWarpRoutes) {
|
|
|
25918
25983
|
const activeChainId = useSession((st) => st.activeChainId);
|
|
25919
25984
|
const directWalletAddress = useExternalWalletStore((st) => st.externalAddress);
|
|
25920
25985
|
const directWalletChainId = useExternalWalletStore((st) => st.externalChainId);
|
|
25921
|
-
const { mutateAsync: switchChainAsync } = (0,
|
|
25986
|
+
const { mutateAsync: switchChainAsync } = (0, import_wagmi7.useSwitchChain)();
|
|
25922
25987
|
const hyperRoute = useBridgeStore((st) => st.hyperRoute);
|
|
25923
25988
|
const bridgeSender = useBridgeStore((st) => st.bridgeSender);
|
|
25924
25989
|
const originChain = useBridgeStore((st) => st.originChain);
|
|
@@ -26045,7 +26110,7 @@ function useBridgeBalance(isLoadingWarpRoutes, hyperlaneWarpRoutes) {
|
|
|
26045
26110
|
isRouteTokenBalanceLoading: isAssetsLoading || isExternalBalanceLoading || isExternalNativeBalanceLoading
|
|
26046
26111
|
};
|
|
26047
26112
|
}
|
|
26048
|
-
var import_core8, import_react_query52, import_react83, import_viem15,
|
|
26113
|
+
var import_core8, import_react_query52, import_react83, import_viem15, import_wagmi7, EXTERNAL_WALLET_BRIDGING_BALANCE_QUERY, EXTERNAL_WALLET_BRIDGING_NATIVE_BALANCE_QUERY;
|
|
26049
26114
|
var init_useBridgeBalance = __esm({
|
|
26050
26115
|
"src/internal/components/SendMenu/hyperbridge/hooks/useBridgeBalance.ts"() {
|
|
26051
26116
|
init_SessionContext();
|
|
@@ -26054,7 +26119,7 @@ var init_useBridgeBalance = __esm({
|
|
|
26054
26119
|
import_react_query52 = require("@tanstack/react-query");
|
|
26055
26120
|
import_react83 = require("react");
|
|
26056
26121
|
import_viem15 = require("viem");
|
|
26057
|
-
|
|
26122
|
+
import_wagmi7 = require("wagmi");
|
|
26058
26123
|
init_useBlockscoutAssets2();
|
|
26059
26124
|
init_useExternalWalletStore();
|
|
26060
26125
|
init_BalanceFeedProvider2();
|
|
@@ -27093,7 +27158,7 @@ function useErc3643Compliance(options) {
|
|
|
27093
27158
|
isLoading,
|
|
27094
27159
|
error: queryError,
|
|
27095
27160
|
refetch
|
|
27096
|
-
} = (0,
|
|
27161
|
+
} = (0, import_wagmi8.useReadContract)({
|
|
27097
27162
|
address: tokenAddress,
|
|
27098
27163
|
abi: ERC3643_CAN_TRANSFER_ABI,
|
|
27099
27164
|
functionName: "canTransfer",
|
|
@@ -27130,10 +27195,10 @@ function useErc3643Compliance(options) {
|
|
|
27130
27195
|
refetch
|
|
27131
27196
|
};
|
|
27132
27197
|
}
|
|
27133
|
-
var
|
|
27198
|
+
var import_wagmi8, ERC3643_CAN_TRANSFER_ABI;
|
|
27134
27199
|
var init_useErc3643Compliance = __esm({
|
|
27135
27200
|
"src/hooks/useErc3643Compliance.ts"() {
|
|
27136
|
-
|
|
27201
|
+
import_wagmi8 = require("wagmi");
|
|
27137
27202
|
ERC3643_CAN_TRANSFER_ABI = [
|
|
27138
27203
|
{
|
|
27139
27204
|
type: "function",
|
|
@@ -29956,7 +30021,7 @@ var init_package = __esm({
|
|
|
29956
30021
|
"package.json"() {
|
|
29957
30022
|
package_default = {
|
|
29958
30023
|
name: "@embarkai/ui-kit",
|
|
29959
|
-
version: "0.4.
|
|
30024
|
+
version: "0.4.107",
|
|
29960
30025
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
29961
30026
|
type: "module",
|
|
29962
30027
|
main: "./dist/index.cjs",
|
|
@@ -30067,7 +30132,7 @@ function Footer() {
|
|
|
30067
30132
|
const address = useSession((st) => st.address);
|
|
30068
30133
|
const chainConfig = useSession((st) => st.chainConfig);
|
|
30069
30134
|
const isDialogForced = useLayoutStore((st) => st.isDialogForced);
|
|
30070
|
-
const { mutate: wagmiDisconnect } = (0,
|
|
30135
|
+
const { mutate: wagmiDisconnect } = (0, import_wagmi9.useDisconnect)({
|
|
30071
30136
|
mutation: {
|
|
30072
30137
|
onSuccess: () => {
|
|
30073
30138
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -30173,7 +30238,7 @@ function Footer() {
|
|
|
30173
30238
|
}
|
|
30174
30239
|
);
|
|
30175
30240
|
}
|
|
30176
|
-
var import_react_query59, import_lucide_react83,
|
|
30241
|
+
var import_react_query59, import_lucide_react83, import_wagmi9, import_jsx_runtime131, FOOTER_ONBOARDING_CHAIN_BUTTON, FOOTER_ONBOARDING_LOGOUT_BUTTON, FOOTER_TOUR;
|
|
30177
30242
|
var init_Footer = __esm({
|
|
30178
30243
|
"src/internal/components/Footer/Footer.tsx"() {
|
|
30179
30244
|
init_package();
|
|
@@ -30183,7 +30248,7 @@ var init_Footer = __esm({
|
|
|
30183
30248
|
init_i18n();
|
|
30184
30249
|
import_react_query59 = require("@tanstack/react-query");
|
|
30185
30250
|
import_lucide_react83 = require("lucide-react");
|
|
30186
|
-
|
|
30251
|
+
import_wagmi9 = require("wagmi");
|
|
30187
30252
|
init_auth();
|
|
30188
30253
|
init_base3();
|
|
30189
30254
|
init_useLayoutDataStore();
|
|
@@ -30722,7 +30787,7 @@ function DirectWalletHandler() {
|
|
|
30722
30787
|
const walletMode = useProviderConfig().config.current?.wallet?.mode || "both";
|
|
30723
30788
|
const externalAddress = useExternalWalletStore((st) => st.externalAddress);
|
|
30724
30789
|
const isExternalConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
30725
|
-
const { address, isConnected, chain, connector } = (0,
|
|
30790
|
+
const { address, isConnected, chain, connector } = (0, import_wagmi10.useConnection)();
|
|
30726
30791
|
(0, import_react104.useEffect)(() => {
|
|
30727
30792
|
const { setConfigMode, setActiveMode } = useExternalWalletStore.getState();
|
|
30728
30793
|
setConfigMode(walletMode);
|
|
@@ -30743,11 +30808,11 @@ function DirectWalletHandler() {
|
|
|
30743
30808
|
}, [isConnected, address, isExternalConnected, externalAddress, connector, chain]);
|
|
30744
30809
|
return null;
|
|
30745
30810
|
}
|
|
30746
|
-
var import_react104,
|
|
30811
|
+
var import_react104, import_wagmi10;
|
|
30747
30812
|
var init_DirectWalletHandler = __esm({
|
|
30748
30813
|
"src/internal/components/DirectWalletHandler.tsx"() {
|
|
30749
30814
|
import_react104 = require("react");
|
|
30750
|
-
|
|
30815
|
+
import_wagmi10 = require("wagmi");
|
|
30751
30816
|
init_ProviderContext();
|
|
30752
30817
|
init_useExternalWalletStore();
|
|
30753
30818
|
}
|
|
@@ -33407,16 +33472,16 @@ function Provider(props) {
|
|
|
33407
33472
|
}),
|
|
33408
33473
|
[config, updateConfig, callbacks, updateCallbacks]
|
|
33409
33474
|
);
|
|
33410
|
-
return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(
|
|
33475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_wagmi11.WagmiProvider, { config: wagmiConfig3.current, children: /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(SessionProvider, { children }) }) });
|
|
33411
33476
|
}
|
|
33412
|
-
var import_core9, import_error_tracking4, import_lodash_es17, import_react107,
|
|
33477
|
+
var import_core9, import_error_tracking4, import_lodash_es17, import_react107, import_wagmi11, import_jsx_runtime137, UIContext, useProviderConfig;
|
|
33413
33478
|
var init_ProviderContext = __esm({
|
|
33414
33479
|
"src/context/ProviderContext.tsx"() {
|
|
33415
33480
|
import_core9 = require("@embarkai/core");
|
|
33416
33481
|
import_error_tracking4 = require("@embarkai/core/internal/error-tracking");
|
|
33417
33482
|
import_lodash_es17 = require("lodash-es");
|
|
33418
33483
|
import_react107 = require("react");
|
|
33419
|
-
|
|
33484
|
+
import_wagmi11 = require("wagmi");
|
|
33420
33485
|
init_initial();
|
|
33421
33486
|
init_iframe_manager();
|
|
33422
33487
|
init_SessionContext();
|
|
@@ -34544,7 +34609,7 @@ function useWalletMode() {
|
|
|
34544
34609
|
// src/hooks/useDirectWallet.ts
|
|
34545
34610
|
init_useOpenPage();
|
|
34546
34611
|
var import_react111 = require("react");
|
|
34547
|
-
var
|
|
34612
|
+
var import_wagmi12 = require("wagmi");
|
|
34548
34613
|
init_useExternalWalletStore();
|
|
34549
34614
|
function useDirectWallet() {
|
|
34550
34615
|
const address = useExternalWalletStore((st) => st.externalAddress);
|
|
@@ -34552,7 +34617,7 @@ function useDirectWallet() {
|
|
|
34552
34617
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
34553
34618
|
const connectorName = useExternalWalletStore((st) => st.connectorName);
|
|
34554
34619
|
const { open: openEmbarkAI } = useOpenPage();
|
|
34555
|
-
const { mutate: wagmiDisconnect } = (0,
|
|
34620
|
+
const { mutate: wagmiDisconnect } = (0, import_wagmi12.useDisconnect)();
|
|
34556
34621
|
const connect = (0, import_react111.useCallback)((connectFlowType = "connect") => {
|
|
34557
34622
|
openEmbarkAI("connect-external-wallet" /* CONNECT_EXTERNAL_WALLET */, { connectFlowType });
|
|
34558
34623
|
}, []);
|
|
@@ -34574,13 +34639,13 @@ function useDirectWallet() {
|
|
|
34574
34639
|
// src/hooks/useSendDirectTransaction.ts
|
|
34575
34640
|
var import_react112 = require("react");
|
|
34576
34641
|
var import_viem23 = require("viem");
|
|
34577
|
-
var
|
|
34642
|
+
var import_wagmi13 = require("wagmi");
|
|
34578
34643
|
init_useExternalWalletStore();
|
|
34579
34644
|
function useSendDirectTransaction() {
|
|
34580
34645
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
34581
34646
|
const externalChainId = useExternalWalletStore((st) => st.externalChainId);
|
|
34582
|
-
const { sendTransactionAsync } = (0,
|
|
34583
|
-
const { switchChainAsync } = (0,
|
|
34647
|
+
const { sendTransactionAsync } = (0, import_wagmi13.useSendTransaction)();
|
|
34648
|
+
const { switchChainAsync } = (0, import_wagmi13.useSwitchChain)();
|
|
34584
34649
|
const [isPending, setIsPending] = (0, import_react112.useState)(false);
|
|
34585
34650
|
const [error, setError] = (0, import_react112.useState)(null);
|
|
34586
34651
|
const [txHash, setTxHash] = (0, import_react112.useState)(null);
|
|
@@ -34713,11 +34778,11 @@ function useTransferToLinkedWallet() {
|
|
|
34713
34778
|
}
|
|
34714
34779
|
|
|
34715
34780
|
// src/hooks/useNativeWalletSignature.ts
|
|
34716
|
-
var
|
|
34781
|
+
var import_wagmi14 = require("wagmi");
|
|
34717
34782
|
init_providers();
|
|
34718
34783
|
function useNativeWalletSignature() {
|
|
34719
|
-
const signMessage = (0,
|
|
34720
|
-
const signTypedMessage = (0,
|
|
34784
|
+
const signMessage = (0, import_wagmi14.useSignMessage)();
|
|
34785
|
+
const signTypedMessage = (0, import_wagmi14.useSignTypedData)();
|
|
34721
34786
|
return {
|
|
34722
34787
|
signMessage,
|
|
34723
34788
|
/** EIP-712 signature */
|
|
@@ -34729,14 +34794,14 @@ function useNativeWalletSignature() {
|
|
|
34729
34794
|
// src/hooks/useLogout.ts
|
|
34730
34795
|
var import_auth27 = require("@embarkai/core/auth");
|
|
34731
34796
|
var import_react114 = require("react");
|
|
34732
|
-
var
|
|
34797
|
+
var import_wagmi15 = require("wagmi");
|
|
34733
34798
|
init_ProviderContext();
|
|
34734
34799
|
init_SessionContext();
|
|
34735
34800
|
init_useExternalWalletStore();
|
|
34736
34801
|
function useLogout() {
|
|
34737
34802
|
const { callbacksRef } = useProviderConfig();
|
|
34738
34803
|
const address = useSession((st) => st.address);
|
|
34739
|
-
const { mutate: wagmiDisconnect } = (0,
|
|
34804
|
+
const { mutate: wagmiDisconnect } = (0, import_wagmi15.useDisconnect)({
|
|
34740
34805
|
mutation: {
|
|
34741
34806
|
onSuccess: () => {
|
|
34742
34807
|
useExternalWalletStore.getState().clearExternalWallet();
|
|
@@ -34802,13 +34867,13 @@ init_useBlockscoutAssets2();
|
|
|
34802
34867
|
init_SessionContext();
|
|
34803
34868
|
var import_read24 = require("@embarkai/core/read");
|
|
34804
34869
|
var import_viem25 = require("viem");
|
|
34805
|
-
var
|
|
34870
|
+
var import_wagmi16 = require("wagmi");
|
|
34806
34871
|
function useTransactions() {
|
|
34807
34872
|
const chainId = requireActiveChainId();
|
|
34808
34873
|
const viemChain = (0, import_read24.getViemChain)(chainId);
|
|
34809
|
-
const publicClient = (0,
|
|
34810
|
-
const { data: walletClient } = (0,
|
|
34811
|
-
const { address } = (0,
|
|
34874
|
+
const publicClient = (0, import_wagmi16.usePublicClient)({ chainId });
|
|
34875
|
+
const { data: walletClient } = (0, import_wagmi16.useWalletClient)();
|
|
34876
|
+
const { address } = (0, import_wagmi16.useAccount)();
|
|
34812
34877
|
const sendTransaction = async (params) => {
|
|
34813
34878
|
if (!walletClient) {
|
|
34814
34879
|
throw new Error("Wallet not connected");
|
|
@@ -34868,7 +34933,7 @@ function useTransactions() {
|
|
|
34868
34933
|
init_SessionContext();
|
|
34869
34934
|
var import_react115 = __toESM(require("react"), 1);
|
|
34870
34935
|
var import_viem26 = require("viem");
|
|
34871
|
-
var
|
|
34936
|
+
var import_wagmi17 = require("wagmi");
|
|
34872
34937
|
var COMMON_TOKENS = [
|
|
34873
34938
|
// Add real token addresses here when available
|
|
34874
34939
|
// {
|
|
@@ -34885,7 +34950,7 @@ function useAssets(address) {
|
|
|
34885
34950
|
data: nativeBalance,
|
|
34886
34951
|
isLoading: nativeBalanceLoading,
|
|
34887
34952
|
refetch: refetchNativeBalance
|
|
34888
|
-
} = (0,
|
|
34953
|
+
} = (0, import_wagmi17.useBalance)({
|
|
34889
34954
|
address,
|
|
34890
34955
|
chainId,
|
|
34891
34956
|
query: {
|
|
@@ -34903,7 +34968,7 @@ function useAssets(address) {
|
|
|
34903
34968
|
data: tokenBalances,
|
|
34904
34969
|
isLoading: tokenBalancesLoading,
|
|
34905
34970
|
refetch: refetchTokenBalances
|
|
34906
|
-
} = (0,
|
|
34971
|
+
} = (0, import_wagmi17.useReadContracts)({
|
|
34907
34972
|
contracts: tokenContracts,
|
|
34908
34973
|
query: {
|
|
34909
34974
|
enabled: !!address && COMMON_TOKENS.length > 0
|
|
@@ -34979,7 +35044,7 @@ function useAssets(address) {
|
|
|
34979
35044
|
}
|
|
34980
35045
|
function useTokenInfo(tokenAddress) {
|
|
34981
35046
|
const chainId = requireActiveChainId();
|
|
34982
|
-
const readContractsResult = (0,
|
|
35047
|
+
const readContractsResult = (0, import_wagmi17.useReadContracts)({
|
|
34983
35048
|
contracts: [
|
|
34984
35049
|
{ address: tokenAddress, abi: import_viem26.erc20Abi, functionName: "name", chainId },
|
|
34985
35050
|
{ address: tokenAddress, abi: import_viem26.erc20Abi, functionName: "symbol", chainId },
|
|
@@ -35010,7 +35075,7 @@ function useTokenBalance2(tokenAddress, userAddress) {
|
|
|
35010
35075
|
data: balance,
|
|
35011
35076
|
isLoading,
|
|
35012
35077
|
refetch
|
|
35013
|
-
} = (0,
|
|
35078
|
+
} = (0, import_wagmi17.useReadContract)({
|
|
35014
35079
|
address: tokenAddress,
|
|
35015
35080
|
abi: import_viem26.erc20Abi,
|
|
35016
35081
|
functionName: "balanceOf",
|