@embarkai/ui-kit 0.3.2 → 0.3.4
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 +76 -47
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +31 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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.4",
|
|
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);
|
|
@@ -16358,6 +16359,7 @@ function WalletConnectHandler() {
|
|
|
16358
16359
|
);
|
|
16359
16360
|
const [hasStartedLinking, setHasStartedLinking] = React8.useState(false);
|
|
16360
16361
|
const [modalWasOpened, setModalWasOpened] = React8.useState(false);
|
|
16362
|
+
const [pendingModalOpen, setPendingModalOpen] = React8.useState(false);
|
|
16361
16363
|
useEffect36(() => {
|
|
16362
16364
|
if (isWalletLinking && !hasStartedLinking) {
|
|
16363
16365
|
console.log("[WalletConnectHandler] Starting wallet link flow:", {
|
|
@@ -16367,21 +16369,22 @@ function WalletConnectHandler() {
|
|
|
16367
16369
|
});
|
|
16368
16370
|
setHasStartedLinking(true);
|
|
16369
16371
|
setProviderType(null);
|
|
16370
|
-
|
|
16371
|
-
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
|
|
16375
|
-
|
|
16376
|
-
|
|
16377
|
-
|
|
16378
|
-
|
|
16379
|
-
|
|
16380
|
-
}
|
|
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
|
+
}
|
|
16381
16383
|
}
|
|
16382
16384
|
if (!isWalletLinking && hasStartedLinking) {
|
|
16383
16385
|
setHasStartedLinking(false);
|
|
16384
16386
|
setModalWasOpened(false);
|
|
16387
|
+
setPendingModalOpen(false);
|
|
16385
16388
|
const shouldKeepConnected = walletMode === "direct" || walletMode === "both";
|
|
16386
16389
|
if (isConnected && !shouldKeepConnected) disconnect();
|
|
16387
16390
|
}
|
|
@@ -16395,6 +16398,12 @@ function WalletConnectHandler() {
|
|
|
16395
16398
|
setProviderType,
|
|
16396
16399
|
walletMode
|
|
16397
16400
|
]);
|
|
16401
|
+
useEffect36(() => {
|
|
16402
|
+
if (pendingModalOpen && !isConnected && openConnectModal) {
|
|
16403
|
+
setPendingModalOpen(false);
|
|
16404
|
+
openConnectModal();
|
|
16405
|
+
}
|
|
16406
|
+
}, [pendingModalOpen, isConnected, openConnectModal]);
|
|
16398
16407
|
useEffect36(() => {
|
|
16399
16408
|
if (connectModalOpen && hasStartedLinking) {
|
|
16400
16409
|
setModalWasOpened(true);
|
|
@@ -16422,7 +16431,7 @@ function WalletConnectHandler() {
|
|
|
16422
16431
|
setAuthError({ title: "Connection timed out", message: "Wallet did not respond. Please try again." });
|
|
16423
16432
|
setPage("auth" /* AUTH */);
|
|
16424
16433
|
}
|
|
16425
|
-
},
|
|
16434
|
+
}, 3e5);
|
|
16426
16435
|
return () => clearTimeout(timeout);
|
|
16427
16436
|
}
|
|
16428
16437
|
}, [isWalletLinking, setIsWalletLinking, disconnect]);
|
|
@@ -16449,7 +16458,7 @@ function WalletConnectHandler() {
|
|
|
16449
16458
|
const signature = await Promise.race([
|
|
16450
16459
|
signMessageAsync({ message, account: signingWalletAddress }),
|
|
16451
16460
|
new Promise(
|
|
16452
|
-
(_, 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)
|
|
16453
16462
|
)
|
|
16454
16463
|
]);
|
|
16455
16464
|
if (!signature) {
|
|
@@ -16504,6 +16513,7 @@ function WalletConnectHandler() {
|
|
|
16504
16513
|
onLinkingComplete(false);
|
|
16505
16514
|
setHasStartedLinking(false);
|
|
16506
16515
|
setLinkIsLoading(false);
|
|
16516
|
+
setAuthStep("signin");
|
|
16507
16517
|
const errorMsg = err?.message || (isAuthFlow ? "Wallet login failed" : "Failed to link wallet");
|
|
16508
16518
|
if (errorMsg.includes("User rejected") || errorMsg.includes("User denied")) {
|
|
16509
16519
|
if (passportWalletAddress) {
|
|
@@ -16528,11 +16538,15 @@ function WalletConnectHandler() {
|
|
|
16528
16538
|
}
|
|
16529
16539
|
});
|
|
16530
16540
|
useEffect36(() => {
|
|
16531
|
-
if (!!chain?.id && isConnected && walletAddress && isWalletLinking && hasStartedLinking) {
|
|
16541
|
+
if (!!chain?.id && isConnected && walletAddress && isWalletLinking && hasStartedLinking && modalWasOpened && !pendingModalOpen) {
|
|
16532
16542
|
console.log("[WalletConnectHandler] handleWalletSign triggered");
|
|
16543
|
+
if (!passportWalletAddress) {
|
|
16544
|
+
setPage("auth" /* AUTH */);
|
|
16545
|
+
setAuthStep("loading");
|
|
16546
|
+
}
|
|
16533
16547
|
handleWalletSign({ chainId: chain.id, signingWalletAddress: walletAddress });
|
|
16534
16548
|
}
|
|
16535
|
-
}, [chain, isConnected, walletAddress, isWalletLinking, hasStartedLinking]);
|
|
16549
|
+
}, [chain, isConnected, walletAddress, isWalletLinking, hasStartedLinking, modalWasOpened, pendingModalOpen]);
|
|
16536
16550
|
useEffect36(() => {
|
|
16537
16551
|
if (isConnected && !chain?.id && isWalletLinking && hasStartedLinking && !connectModalOpen && !isWalletSigning) {
|
|
16538
16552
|
const timeout = setTimeout(() => {
|
|
@@ -19492,7 +19506,7 @@ function Provider(props) {
|
|
|
19492
19506
|
[config, updateConfig, callbacks, updateCallbacks]
|
|
19493
19507
|
);
|
|
19494
19508
|
if (!!initialConfig?.wallet?.enabled)
|
|
19495
|
-
return /* @__PURE__ */ jsx96(
|
|
19509
|
+
return /* @__PURE__ */ jsx96(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx96(RainbowKitProvider, { children: /* @__PURE__ */ jsx96(SessionProvider, { children }) }) });
|
|
19496
19510
|
return /* @__PURE__ */ jsx96(WagmiProvider2, { children: /* @__PURE__ */ jsx96(UIContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx96(SessionProvider, { children }) }) });
|
|
19497
19511
|
}
|
|
19498
19512
|
var UIContext, useProviderConfig;
|