@embarkai/ui-kit 0.4.100 → 0.4.101
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 +363 -335
- package/dist/index.js +50 -22
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -17243,6 +17243,28 @@ var init_useConnectExternalWalletMenuParams = __esm({
|
|
|
17243
17243
|
}
|
|
17244
17244
|
});
|
|
17245
17245
|
|
|
17246
|
+
// src/internal/components/ConnectExternalWalletMenu/useHasInjectedWallet.ts
|
|
17247
|
+
import { createStore } from "mipd";
|
|
17248
|
+
import { useSyncExternalStore } from "react";
|
|
17249
|
+
function hasInjectedWallet() {
|
|
17250
|
+
if (typeof window === "undefined") return false;
|
|
17251
|
+
return mipdStore.getProviders().length > 0 || !!window.ethereum;
|
|
17252
|
+
}
|
|
17253
|
+
function useHasInjectedWallet() {
|
|
17254
|
+
return useSyncExternalStore(
|
|
17255
|
+
(onStoreChange) => mipdStore?.subscribe(onStoreChange) ?? (() => {
|
|
17256
|
+
}),
|
|
17257
|
+
hasInjectedWallet,
|
|
17258
|
+
() => false
|
|
17259
|
+
);
|
|
17260
|
+
}
|
|
17261
|
+
var mipdStore;
|
|
17262
|
+
var init_useHasInjectedWallet = __esm({
|
|
17263
|
+
"src/internal/components/ConnectExternalWalletMenu/useHasInjectedWallet.ts"() {
|
|
17264
|
+
mipdStore = typeof window !== "undefined" ? createStore() : void 0;
|
|
17265
|
+
}
|
|
17266
|
+
});
|
|
17267
|
+
|
|
17246
17268
|
// src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx
|
|
17247
17269
|
import { useMutation as useMutation10, useQuery as useQuery9, useQueryClient as useQueryClient14 } from "@tanstack/react-query";
|
|
17248
17270
|
import { ArrowLeft as ArrowLeft8, Loader as Loader11, Wallet2Icon as Wallet2Icon2 } from "lucide-react";
|
|
@@ -17261,9 +17283,10 @@ function ConnectExternalWalletMenu() {
|
|
|
17261
17283
|
const qc = useQueryClient14();
|
|
17262
17284
|
const { t } = useT();
|
|
17263
17285
|
const { address: embarkAiAddress } = useSession();
|
|
17264
|
-
const { open: openEmbarkAI } = useOpenPage();
|
|
17286
|
+
const { open: openEmbarkAI, close: closeEmbarkAI } = useOpenPage();
|
|
17265
17287
|
const menuParams = useConnectExternalWalletMenuParams();
|
|
17266
17288
|
const connectors = useConnectors();
|
|
17289
|
+
const hasInjectedWallet2 = useHasInjectedWallet();
|
|
17267
17290
|
const { isConnected: isExternalWalletConnected } = useConnection();
|
|
17268
17291
|
const { mutate: disconnect } = useDisconnect2();
|
|
17269
17292
|
const { mutateAsync: signMessageAsync } = useSignMessage();
|
|
@@ -17323,6 +17346,7 @@ function ConnectExternalWalletMenu() {
|
|
|
17323
17346
|
},
|
|
17324
17347
|
onError: (err, { walletData, connectFlowType }) => {
|
|
17325
17348
|
disconnect();
|
|
17349
|
+
useLayoutStore.getState().setIsDialogForced(false);
|
|
17326
17350
|
const errorMsg = err?.message || "Failed to connect wallet";
|
|
17327
17351
|
const setAuthError = useAuthStore.getState().setAlert;
|
|
17328
17352
|
const setManageWalletLinkError = useManageWalletStore.getState().setAlert;
|
|
@@ -17365,7 +17389,6 @@ function ConnectExternalWalletMenu() {
|
|
|
17365
17389
|
}
|
|
17366
17390
|
switch (connectFlowType) {
|
|
17367
17391
|
case "auth":
|
|
17368
|
-
useLayoutDataStore.getState().setPage("auth" /* AUTH */);
|
|
17369
17392
|
break;
|
|
17370
17393
|
case "link":
|
|
17371
17394
|
onLinkingComplete(false);
|
|
@@ -17374,7 +17397,6 @@ function ConnectExternalWalletMenu() {
|
|
|
17374
17397
|
openEmbarkAI(walletMenuOpenedFrom || "main-menu" /* MAIN_MENU */);
|
|
17375
17398
|
break;
|
|
17376
17399
|
}
|
|
17377
|
-
useLayoutStore.getState().setIsDialogForced(false);
|
|
17378
17400
|
}
|
|
17379
17401
|
});
|
|
17380
17402
|
const {
|
|
@@ -17439,7 +17461,6 @@ function ConnectExternalWalletMenu() {
|
|
|
17439
17461
|
title: `Failed to connect: ${connector.name}`,
|
|
17440
17462
|
message: error2?.message || "Failed to connect wallet"
|
|
17441
17463
|
});
|
|
17442
|
-
setPage("auth" /* AUTH */);
|
|
17443
17464
|
break;
|
|
17444
17465
|
case "link":
|
|
17445
17466
|
useManageWalletStore.getState().setAlert({
|
|
@@ -17462,6 +17483,10 @@ function ConnectExternalWalletMenu() {
|
|
|
17462
17483
|
const unique = connectors.filter((connector) => {
|
|
17463
17484
|
const skipConnector = seen.has(connector.uid);
|
|
17464
17485
|
if (skipConnector) return false;
|
|
17486
|
+
if (connector.id === "extensionProvider" && !hasInjectedWallet2) {
|
|
17487
|
+
seen.add(connector.uid);
|
|
17488
|
+
return false;
|
|
17489
|
+
}
|
|
17465
17490
|
seen.add(connector.uid);
|
|
17466
17491
|
return true;
|
|
17467
17492
|
});
|
|
@@ -17470,7 +17495,7 @@ function ConnectExternalWalletMenu() {
|
|
|
17470
17495
|
return unique.filter(
|
|
17471
17496
|
(connector) => allowed.includes(connector.id.toLowerCase()) || allowed.includes(connector.name.toLowerCase())
|
|
17472
17497
|
);
|
|
17473
|
-
}, [connectors, allowedWallets]);
|
|
17498
|
+
}, [connectors, allowedWallets, hasInjectedWallet2]);
|
|
17474
17499
|
const getInstructionSteps = useCallback17(() => {
|
|
17475
17500
|
const connectFlowType = getConnectFlowType({
|
|
17476
17501
|
isEmbarkAI: !!embarkAiAddress,
|
|
@@ -17515,7 +17540,17 @@ function ConnectExternalWalletMenu() {
|
|
|
17515
17540
|
disconnect();
|
|
17516
17541
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
17517
17542
|
}
|
|
17518
|
-
|
|
17543
|
+
switch (true) {
|
|
17544
|
+
case (connector.id === "metaMaskSDK" && !hasInjectedWallet2):
|
|
17545
|
+
closeEmbarkAI();
|
|
17546
|
+
break;
|
|
17547
|
+
// case connector.id === 'walletConnect':
|
|
17548
|
+
// closeEmbarkAI() // close embarkAI since WalletConnect has dedicated UI
|
|
17549
|
+
// break
|
|
17550
|
+
default:
|
|
17551
|
+
useLayoutStore.getState().setIsDialogForced(true);
|
|
17552
|
+
break;
|
|
17553
|
+
}
|
|
17519
17554
|
try {
|
|
17520
17555
|
await connect({ connector });
|
|
17521
17556
|
} catch {
|
|
@@ -17560,6 +17595,7 @@ var init_ConnectExternalWalletMenu = __esm({
|
|
|
17560
17595
|
init_button();
|
|
17561
17596
|
init_highlight();
|
|
17562
17597
|
init_useConnectExternalWalletMenuParams();
|
|
17598
|
+
init_useHasInjectedWallet();
|
|
17563
17599
|
}
|
|
17564
17600
|
});
|
|
17565
17601
|
|
|
@@ -28491,7 +28527,7 @@ var init_SendMenu2 = __esm({
|
|
|
28491
28527
|
});
|
|
28492
28528
|
|
|
28493
28529
|
// src/internal/lib/pro-mode.ts
|
|
28494
|
-
import { useSyncExternalStore } from "react";
|
|
28530
|
+
import { useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
28495
28531
|
function isProMode() {
|
|
28496
28532
|
try {
|
|
28497
28533
|
return localStorage.getItem(STORAGE_KEY) === "1";
|
|
@@ -28521,7 +28557,7 @@ function getServerSnapshot() {
|
|
|
28521
28557
|
return false;
|
|
28522
28558
|
}
|
|
28523
28559
|
function useProMode() {
|
|
28524
|
-
return
|
|
28560
|
+
return useSyncExternalStore2(subscribe, getSnapshot, getServerSnapshot);
|
|
28525
28561
|
}
|
|
28526
28562
|
var STORAGE_KEY, EVENT_NAME;
|
|
28527
28563
|
var init_pro_mode = __esm({
|
|
@@ -29822,7 +29858,7 @@ var init_package = __esm({
|
|
|
29822
29858
|
"package.json"() {
|
|
29823
29859
|
package_default = {
|
|
29824
29860
|
name: "@embarkai/ui-kit",
|
|
29825
|
-
version: "0.4.
|
|
29861
|
+
version: "0.4.101",
|
|
29826
29862
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
29827
29863
|
type: "module",
|
|
29828
29864
|
main: "./dist/index.cjs",
|
|
@@ -29879,6 +29915,7 @@ var init_package = __esm({
|
|
|
29879
29915
|
"dkls23-wasm": "^0.1.1",
|
|
29880
29916
|
"lodash-es": "^4.18.1",
|
|
29881
29917
|
"lucide-react": "^1.28.0",
|
|
29918
|
+
mipd: "^0.0.7",
|
|
29882
29919
|
motion: "^13.1.1",
|
|
29883
29920
|
qrcode: "^1.5.4",
|
|
29884
29921
|
viem: "^2.52.2",
|
|
@@ -33170,7 +33207,7 @@ var init_utils14 = __esm({
|
|
|
33170
33207
|
});
|
|
33171
33208
|
|
|
33172
33209
|
// src/context/ProviderContext.tsx
|
|
33173
|
-
import {
|
|
33210
|
+
import { getWagmiConfig } from "@embarkai/core";
|
|
33174
33211
|
import { initSdkErrorTracking } from "@embarkai/core/internal/error-tracking";
|
|
33175
33212
|
import { merge as merge3 } from "lodash-es";
|
|
33176
33213
|
import {
|
|
@@ -33181,7 +33218,7 @@ import {
|
|
|
33181
33218
|
useMemo as useMemo21,
|
|
33182
33219
|
useRef as useRef22
|
|
33183
33220
|
} from "react";
|
|
33184
|
-
import {
|
|
33221
|
+
import { WagmiProvider } from "wagmi";
|
|
33185
33222
|
import { jsx as jsx137 } from "react/jsx-runtime";
|
|
33186
33223
|
function clearLegacyWagmiStorage() {
|
|
33187
33224
|
if (typeof window === "undefined" || !window.localStorage) return;
|
|
@@ -33203,6 +33240,7 @@ function Provider(props) {
|
|
|
33203
33240
|
const callbacksRef = useRef22(callbacks);
|
|
33204
33241
|
useEffect56(() => notifyNoProjetctId(projectId), [projectId]);
|
|
33205
33242
|
const config = useRef22(merge3({}, DEFAULT_PROVIDER_CONFIG, { projectId }, initialConfig));
|
|
33243
|
+
const wagmiConfig3 = useRef22(getWagmiConfig(config.current?.wallet?.walletConnectId || null));
|
|
33206
33244
|
const updateConfig = useCallback35((updates) => {
|
|
33207
33245
|
const prev = config.current;
|
|
33208
33246
|
const next = { ...prev };
|
|
@@ -33302,17 +33340,7 @@ function Provider(props) {
|
|
|
33302
33340
|
}),
|
|
33303
33341
|
[config, updateConfig, callbacks, updateCallbacks]
|
|
33304
33342
|
);
|
|
33305
|
-
return /* @__PURE__ */ jsx137(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx137(
|
|
33306
|
-
WagmiProvider,
|
|
33307
|
-
{
|
|
33308
|
-
config: createWagmiConfig({
|
|
33309
|
-
chains: WAGMI_CONFIG_CHAINS,
|
|
33310
|
-
connectors: getWagmiConnectors(config.current?.wallet?.walletConnectId || null),
|
|
33311
|
-
transports: WAGMI_CONFIG_TRANSPORTS
|
|
33312
|
-
}),
|
|
33313
|
-
children: /* @__PURE__ */ jsx137(SessionProvider, { children })
|
|
33314
|
-
}
|
|
33315
|
-
) });
|
|
33343
|
+
return /* @__PURE__ */ jsx137(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx137(WagmiProvider, { config: wagmiConfig3.current, children: /* @__PURE__ */ jsx137(SessionProvider, { children }) }) });
|
|
33316
33344
|
}
|
|
33317
33345
|
var UIContext, useProviderConfig;
|
|
33318
33346
|
var init_ProviderContext = __esm({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embarkai/ui-kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.101",
|
|
4
4
|
"description": "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -45,12 +45,13 @@
|
|
|
45
45
|
"dkls23-wasm": "^0.1.1",
|
|
46
46
|
"lodash-es": "^4.18.1",
|
|
47
47
|
"lucide-react": "^1.28.0",
|
|
48
|
+
"mipd": "^0.0.7",
|
|
48
49
|
"motion": "^13.1.1",
|
|
49
50
|
"qrcode": "^1.5.4",
|
|
50
51
|
"viem": "^2.52.2",
|
|
51
52
|
"wagmi": "^3.7.5",
|
|
52
53
|
"zustand": "^5.0.14",
|
|
53
|
-
"@embarkai/core": "0.4.
|
|
54
|
+
"@embarkai/core": "0.4.21"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@svgr/core": "^8.1.0",
|