@@ -14,10 +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" ;
2021import { getDefaultWallets } from "../../wallets/defaultWallets.js" ;
22+ import { AutoConnect } from "../AutoConnect/AutoConnect.js" ;
2123import { ThemedButton , ThemedButtonWithIcon } from "../components/button.js" ;
2224import { type ContainerType , Header } from "../components/Header.js" ;
2325import { RNImage } from "../components/RNImage.js" ;
@@ -32,6 +34,7 @@ import { TW_ICON, WALLET_ICON } from "../icons/svgs.js";
3234import { ErrorView } from "./ErrorView.js" ;
3335import { AllWalletsList , ExternalWalletsList } from "./ExternalWalletsList.js" ;
3436import { InAppWalletUI , OtpLogin , PasskeyView } from "./InAppWalletUI.js" ;
37+ import { LoadingView } from "./LoadingView.js" ;
3538import WalletLoadingThumbnail from "./WalletLoadingThumbnail.js" ;
3639
3740export type ModalState =
@@ -74,14 +77,43 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
7477 ...props ,
7578 connectModal : { ...props } ,
7679 } as ConnectButtonProps ;
77- return isConnected ? null : (
78- < ConnectModal
79- { ...adaptedProps }
80- containerType = "embed"
80+ const isAutoConnecting = useIsAutoConnecting ( ) ;
81+ const wallets = props . wallets || getDefaultWallets ( props ) ;
82+
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 }
8190 siweAuth = { siweAuth }
82- theme = { theme }
91+ timeout = {
92+ typeof props . autoConnect === "boolean"
93+ ? undefined
94+ : props . autoConnect ?. timeout
95+ }
96+ wallets = { wallets }
8397 />
8498 ) ;
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+ ) ;
85117}
86118
87119export function ConnectModal (
0 commit comments