diff --git a/@3rdweb-sdk/react/components/connect-wallet/index.tsx b/@3rdweb-sdk/react/components/connect-wallet/index.tsx index e0636fcf3..1bc520c9a 100644 --- a/@3rdweb-sdk/react/components/connect-wallet/index.tsx +++ b/@3rdweb-sdk/react/components/connect-wallet/index.tsx @@ -37,11 +37,11 @@ import { useChainId, useConnect, useDisconnect, - useGnosis, - useMagic, useMetamask, useNetwork, -} from "@thirdweb-dev/react"; +} from "@thirdweb-dev/react/evm"; +import { useGnosis } from "@thirdweb-dev/react/evm/connectors/gnosis-safe"; +import { useMagic } from "@thirdweb-dev/react/evm/connectors/magic"; import { ChakraNextImage } from "components/Image"; import { MismatchButton } from "components/buttons/MismatchButton"; import { ens } from "components/contract-components/hooks"; @@ -100,7 +100,7 @@ export const ConnectWallet: React.FC = ({ const { getNetworkMetadata } = useWeb3(); const { isOpen, onOpen, onClose } = useDisclosure(); const disconnect = useDisconnect(); - const disconnectFully = useDisconnect({ reconnectAfterGnosis: false }); + const disconnectFully = useDisconnect({ reconnectPrevious: false }); const [network, switchNetwork] = useNetwork(); const address = useAddress(); const chainId = useChainId(); diff --git a/components/app-layouts/providers.tsx b/components/app-layouts/providers.tsx index cb6648b64..e9f7a0897 100644 --- a/components/app-layouts/providers.tsx +++ b/components/app-layouts/providers.tsx @@ -2,27 +2,14 @@ import { SolanaProvider } from "./solana-provider"; import { useDashboardEVMChainId } from "@3rdweb-sdk/react"; import { useQueryClient } from "@tanstack/react-query"; import { ThirdwebProvider, WalletConnector } from "@thirdweb-dev/react"; +import { GnosisSafeConnector } from "@thirdweb-dev/react/evm/connectors/gnosis-safe"; +import { MagicConnector } from "@thirdweb-dev/react/evm/connectors/magic"; import { EVM_RPC_URL_MAP, getEVMRPC } from "constants/rpc"; import { useNativeColorMode } from "hooks/useNativeColorMode"; import { StorageSingleton } from "lib/sdk"; +import { useMemo } from "react"; import { ComponentWithChildren } from "types/component-with-children"; -const walletConnectors: WalletConnector[] = [ - "metamask", - "walletConnect", - "walletLink", - "gnosis", -]; -if (process.env.NEXT_PUBLIC_MAGIC_KEY) { - walletConnectors.push({ - name: "magic", - options: { - apiKey: process.env.NEXT_PUBLIC_MAGIC_KEY, - rpcUrls: EVM_RPC_URL_MAP, - }, - }); -} - export const DashboardThirdwebProvider: ComponentWithChildren = ({ children, }) => { @@ -31,6 +18,31 @@ export const DashboardThirdwebProvider: ComponentWithChildren = ({ const activeChainId = useDashboardEVMChainId(); + const walletConnectors = useMemo(() => { + let wc: WalletConnector[] = [ + "metamask", + "walletConnect", + "walletLink", + new GnosisSafeConnector({}), + ]; + if (process.env.NEXT_PUBLIC_MAGIC_KEY) { + wc = wc.concat( + new MagicConnector({ + options: { + apiKey: process.env.NEXT_PUBLIC_MAGIC_KEY, + rpcUrls: EVM_RPC_URL_MAP, + network: activeChainId && { + rpcUrl: getEVMRPC(activeChainId), + chainId: activeChainId, + }, + doNotAutoConnect: true, + }, + }), + ); + } + return wc; + }, [activeChainId]); + return (