@@ -3,40 +3,39 @@ import { createWallet } from "../create-wallet.js";
33import { getDefaultWallets } from "../defaultWallets.js" ;
44import { getInstalledWalletProviders } from "../injected/mipdStore.js" ;
55import type { Wallet } from "../interfaces/wallet.js" ;
6- import type { ConnectionManager } from "../manager/index.js" ;
6+ import { createConnectionManager } from "../manager/index.js" ;
77import { autoConnectCore } from "./autoConnectCore.js" ;
88import type { AutoConnectProps } from "./types.js" ;
99
1010/**
11- * Attempts to automatically connect to a wallet based on the provided configuration .
11+ * Attempts to automatically connect to the last connected wallet .
1212 * It combines both specified wallets and installed wallet providers that aren't already specified.
1313 *
1414 * @example
1515 *
1616 * ```tsx
1717 * import { autoConnect } from "thirdweb/wallets";
1818 *
19- * const walletManager = createConnectionManager();
2019 * const autoConnected = await autoConnect({
2120 * client,
22- * walletManager,
21+ * onConnect: (wallet) => {
22+ * console.log("wallet", wallet);
23+ * },
2324 * });
2425 * ```
2526 *
26- *
2727 * @param props - The auto-connect configuration properties
2828 * @param props.wallets - Array of wallet instances to consider for auto-connection
29- * @param walletManager - The connection manager instance handling wallet connections
3029 * @returns {boolean } a promise resolving to true or false depending on whether the auto connect function connected to a wallet or not
3130 */
3231export const autoConnect = async (
3332 props : AutoConnectProps & {
34- wallets : Wallet [ ] ;
35- walletManager : ConnectionManager ;
33+ wallets ?: Wallet [ ] ;
3634 } ,
3735) => {
3836 const wallets = props . wallets || getDefaultWallets ( props ) ;
39- return autoConnectCore ( {
37+ const manager = createConnectionManager ( webLocalStorage ) ;
38+ const result = await autoConnectCore ( {
4039 storage : webLocalStorage ,
4140 props : {
4241 ...props ,
@@ -53,6 +52,7 @@ export const autoConnect = async (
5352
5453 return installedWallets ;
5554 } ,
56- manager : props . walletManager ,
55+ manager,
5756 } ) ;
57+ return result ;
5858} ;
0 commit comments