@@ -14,11 +14,12 @@ import type { ConnectEmbedProps } from "../../../core/hooks/connection/ConnectEm
1414import { useActiveAccount } from "../../../core/hooks/wallets/useActiveAccount.js" ;
1515import { useActiveWallet } from "../../../core/hooks/wallets/useActiveWallet.js" ;
1616import { useDisconnect } from "../../../core/hooks/wallets/useDisconnect.js" ;
17+ import { useIsAutoConnecting } from "../../../core/hooks/wallets/useIsAutoConnecting.js" ;
1718import { useConnectionManager } from "../../../core/providers/connection-manager.js" ;
1819import { useWalletInfo } from "../../../core/utils/wallet.js" ;
1920import { radius , spacing } from "../../design-system/index.js" ;
20- import { useAutoConnect } from "../../hooks/wallets/useAutoConnect.js" ;
2121import { getDefaultWallets } from "../../wallets/defaultWallets.js" ;
22+ import { AutoConnect } from "../AutoConnect/AutoConnect.js" ;
2223import { ThemedButton , ThemedButtonWithIcon } from "../components/button.js" ;
2324import { type ContainerType , Header } from "../components/Header.js" ;
2425import { RNImage } from "../components/RNImage.js" ;
@@ -33,6 +34,7 @@ import { TW_ICON, WALLET_ICON } from "../icons/svgs.js";
3334import { ErrorView } from "./ErrorView.js" ;
3435import { AllWalletsList , ExternalWalletsList } from "./ExternalWalletsList.js" ;
3536import { InAppWalletUI , OtpLogin , PasskeyView } from "./InAppWalletUI.js" ;
37+ import { LoadingView } from "./LoadingView.js" ;
3638import WalletLoadingThumbnail from "./WalletLoadingThumbnail.js" ;
3739
3840export type ModalState =
@@ -75,19 +77,43 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
7577 ...props ,
7678 connectModal : { ...props } ,
7779 } as ConnectButtonProps ;
78- useAutoConnect ( {
79- ...props ,
80- siweAuth : siweAuth ,
81- } ) ;
80+ const isAutoConnecting = useIsAutoConnecting ( ) ;
81+ const wallets = props . wallets || getDefaultWallets ( props ) ;
8282
83- return isConnected ? null : (
84- < ConnectModal
85- { ...adaptedProps }
86- containerType = "embed"
83+ const autoConnectComp = props . autoConnect !== false && (
84+ < AutoConnect
85+ accountAbstraction = { props . accountAbstraction }
86+ appMetadata = { props . appMetadata }
87+ chain = { props . chain }
88+ client = { props . client }
89+ onConnect = { props . onConnect }
8790 siweAuth = { siweAuth }
88- theme = { theme }
91+ timeout = {
92+ typeof props . autoConnect === "boolean"
93+ ? undefined
94+ : props . autoConnect ?. timeout
95+ }
96+ wallets = { wallets }
8997 />
9098 ) ;
99+
100+ if ( isAutoConnecting ) {
101+ return < LoadingView theme = { theme } /> ;
102+ }
103+
104+ return isConnected ? (
105+ autoConnectComp
106+ ) : (
107+ < >
108+ < ConnectModal
109+ { ...adaptedProps }
110+ containerType = "embed"
111+ siweAuth = { siweAuth }
112+ theme = { theme }
113+ />
114+ { autoConnectComp }
115+ </ >
116+ ) ;
91117}
92118
93119export function ConnectModal (
0 commit comments