@embarkai/ui-kit 0.3.1 → 0.3.3
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 +41 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15499,7 +15499,7 @@ var init_package = __esm({
|
|
|
15499
15499
|
"package.json"() {
|
|
15500
15500
|
package_default = {
|
|
15501
15501
|
name: "@embarkai/ui-kit",
|
|
15502
|
-
version: "0.3.
|
|
15502
|
+
version: "0.3.3",
|
|
15503
15503
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
15504
15504
|
type: "module",
|
|
15505
15505
|
main: "./dist/index.cjs",
|
|
@@ -16319,6 +16319,7 @@ function WalletConnectHandler() {
|
|
|
16319
16319
|
const setPage = useLayoutDataStore((st) => st.setPage);
|
|
16320
16320
|
const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
|
|
16321
16321
|
const setAuthError = useAuthStore((st) => st.setAlert);
|
|
16322
|
+
const setAuthStep = useAuthStore((st) => st.setStep);
|
|
16322
16323
|
const setManageWalletLinkError = useManageWalletStore((st) => st.setLinkError);
|
|
16323
16324
|
const setLinkIsLoading = useManageWalletStore((st) => st.setLinkIsLoading);
|
|
16324
16325
|
const setProviderType = useManageWalletStore((st) => st.setProviderType);
|
|
@@ -16357,6 +16358,8 @@ function WalletConnectHandler() {
|
|
|
16357
16358
|
[qc, passportWalletAddress, setProviderType, setPage, setIsWalletLinking]
|
|
16358
16359
|
);
|
|
16359
16360
|
const [hasStartedLinking, setHasStartedLinking] = React8.useState(false);
|
|
16361
|
+
const [modalWasOpened, setModalWasOpened] = React8.useState(false);
|
|
16362
|
+
const [pendingModalOpen, setPendingModalOpen] = React8.useState(false);
|
|
16360
16363
|
useEffect36(() => {
|
|
16361
16364
|
if (isWalletLinking && !hasStartedLinking) {
|
|
16362
16365
|
console.log("[WalletConnectHandler] Starting wallet link flow:", {
|
|
@@ -16366,20 +16369,22 @@ function WalletConnectHandler() {
|
|
|
16366
16369
|
});
|
|
16367
16370
|
setHasStartedLinking(true);
|
|
16368
16371
|
setProviderType(null);
|
|
16369
|
-
|
|
16370
|
-
|
|
16371
|
-
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
|
|
16375
|
-
|
|
16376
|
-
|
|
16377
|
-
|
|
16378
|
-
|
|
16379
|
-
}
|
|
16372
|
+
setPage(null);
|
|
16373
|
+
if (isConnected) {
|
|
16374
|
+
disconnect();
|
|
16375
|
+
setPendingModalOpen(true);
|
|
16376
|
+
} else if (openConnectModal) {
|
|
16377
|
+
openConnectModal();
|
|
16378
|
+
} else {
|
|
16379
|
+
console.error("[WalletConnectHandler] openConnectModal is undefined!");
|
|
16380
|
+
setIsWalletLinking(false);
|
|
16381
|
+
setHasStartedLinking(false);
|
|
16382
|
+
}
|
|
16380
16383
|
}
|
|
16381
16384
|
if (!isWalletLinking && hasStartedLinking) {
|
|
16382
16385
|
setHasStartedLinking(false);
|
|
16386
|
+
setModalWasOpened(false);
|
|
16387
|
+
setPendingModalOpen(false);
|
|
16383
16388
|
const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
|
|
16384
16389
|
if (isConnected && !shouldKeepConnected) disconnect();
|
|
16385
16390
|
}
|
|
@@ -16394,12 +16399,24 @@ function WalletConnectHandler() {
|
|
|
16394
16399
|
walletMode
|
|
16395
16400
|
]);
|
|
16396
16401
|
useEffect36(() => {
|
|
16397
|
-
if (
|
|
16402
|
+
if (pendingModalOpen && !isConnected && openConnectModal) {
|
|
16403
|
+
setPendingModalOpen(false);
|
|
16404
|
+
openConnectModal();
|
|
16405
|
+
}
|
|
16406
|
+
}, [pendingModalOpen, isConnected, openConnectModal]);
|
|
16407
|
+
useEffect36(() => {
|
|
16408
|
+
if (connectModalOpen && hasStartedLinking) {
|
|
16409
|
+
setModalWasOpened(true);
|
|
16410
|
+
}
|
|
16411
|
+
}, [connectModalOpen, hasStartedLinking]);
|
|
16412
|
+
useEffect36(() => {
|
|
16413
|
+
if (modalWasOpened && !connectModalOpen && !isConnected && isWalletLinking) {
|
|
16398
16414
|
console.log("[WalletConnectHandler] Modal closed without connecting");
|
|
16399
16415
|
onLinkingComplete(false);
|
|
16400
16416
|
setHasStartedLinking(false);
|
|
16417
|
+
setModalWasOpened(false);
|
|
16401
16418
|
}
|
|
16402
|
-
}, [connectModalOpen,
|
|
16419
|
+
}, [connectModalOpen, modalWasOpened, isConnected, isWalletLinking]);
|
|
16403
16420
|
useEffect36(() => {
|
|
16404
16421
|
if (isWalletLinking) {
|
|
16405
16422
|
const timeout = setTimeout(() => {
|
|
@@ -16414,7 +16431,7 @@ function WalletConnectHandler() {
|
|
|
16414
16431
|
setAuthError({ title: "Connection timed out", message: "Wallet did not respond. Please try again." });
|
|
16415
16432
|
setPage("auth" /* AUTH */);
|
|
16416
16433
|
}
|
|
16417
|
-
},
|
|
16434
|
+
}, 3e5);
|
|
16418
16435
|
return () => clearTimeout(timeout);
|
|
16419
16436
|
}
|
|
16420
16437
|
}, [isWalletLinking, setIsWalletLinking, disconnect]);
|
|
@@ -16441,7 +16458,7 @@ function WalletConnectHandler() {
|
|
|
16441
16458
|
const signature = await Promise.race([
|
|
16442
16459
|
signMessageAsync({ message, account: signingWalletAddress }),
|
|
16443
16460
|
new Promise(
|
|
16444
|
-
(_, reject) => setTimeout(() => reject(new Error("Signature request timed out. Please try again.")),
|
|
16461
|
+
(_, reject) => setTimeout(() => reject(new Error("Signature request timed out. Please try again.")), 12e4)
|
|
16445
16462
|
)
|
|
16446
16463
|
]);
|
|
16447
16464
|
if (!signature) {
|
|
@@ -16496,6 +16513,7 @@ function WalletConnectHandler() {
|
|
|
16496
16513
|
onLinkingComplete(false);
|
|
16497
16514
|
setHasStartedLinking(false);
|
|
16498
16515
|
setLinkIsLoading(false);
|
|
16516
|
+
setAuthStep("signin");
|
|
16499
16517
|
const errorMsg = err?.message || (isAuthFlow ? "Wallet login failed" : "Failed to link wallet");
|
|
16500
16518
|
if (errorMsg.includes("User rejected") || errorMsg.includes("User denied")) {
|
|
16501
16519
|
if (passportWalletAddress) {
|
|
@@ -16520,11 +16538,15 @@ function WalletConnectHandler() {
|
|
|
16520
16538
|
}
|
|
16521
16539
|
});
|
|
16522
16540
|
useEffect36(() => {
|
|
16523
|
-
if (!!chain?.id && isConnected && walletAddress && isWalletLinking && hasStartedLinking) {
|
|
16541
|
+
if (!!chain?.id && isConnected && walletAddress && isWalletLinking && hasStartedLinking && modalWasOpened && !pendingModalOpen) {
|
|
16524
16542
|
console.log("[WalletConnectHandler] handleWalletSign triggered");
|
|
16543
|
+
if (!passportWalletAddress) {
|
|
16544
|
+
setPage("auth" /* AUTH */);
|
|
16545
|
+
setAuthStep("loading");
|
|
16546
|
+
}
|
|
16525
16547
|
handleWalletSign({ chainId: chain.id, signingWalletAddress: walletAddress });
|
|
16526
16548
|
}
|
|
16527
|
-
}, [chain, isConnected, walletAddress, isWalletLinking, hasStartedLinking]);
|
|
16549
|
+
}, [chain, isConnected, walletAddress, isWalletLinking, hasStartedLinking, modalWasOpened, pendingModalOpen]);
|
|
16528
16550
|
useEffect36(() => {
|
|
16529
16551
|
if (isConnected && !chain?.id && isWalletLinking && hasStartedLinking && !connectModalOpen && !isWalletSigning) {
|
|
16530
16552
|
const timeout = setTimeout(() => {
|
|
@@ -19484,7 +19506,7 @@ function Provider(props) {
|
|
|
19484
19506
|
[config, updateConfig, callbacks, updateCallbacks]
|
|
19485
19507
|
);
|
|
19486
19508
|
if (!!initialConfig?.wallet?.enabled)
|
|
19487
|
-
return /* @__PURE__ */ jsx96(
|
|
19509
|
+
return /* @__PURE__ */ jsx96(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx96(RainbowKitProvider, { children: /* @__PURE__ */ jsx96(SessionProvider, { children }) }) });
|
|
19488
19510
|
return /* @__PURE__ */ jsx96(WagmiProvider2, { children: /* @__PURE__ */ jsx96(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx96(SessionProvider, { children }) }) });
|
|
19489
19511
|
}
|
|
19490
19512
|
var UIContext, useProviderConfig;
|