import { useState, type SetStateAction } from 'react'; import { useSyncProviders } from './useSyncProviders'; import useAuth from '~/hooks/useAuth'; // code from https://metamask.io/news/how-to-implement-eip-6963-support-in-your-web3-dapp import type { EIP6963ProviderDetail } from "./EthereumProviderTypes"; export const DiscoverWalletProviders = () => { const providers = useSyncProviders(); const { auth, setAuth } = useAuth(); const handleConnect = async (providerWithInfo: EIP6963ProviderDetail) => { const accounts = await providerWithInfo.provider.request({ method: 'eth_requestAccounts' }).catch(console.error); if (Array.isArray(accounts) && accounts.length > 0 && accounts[0]) { setAuth({providerWithInfo: providerWithInfo, accounts: accounts}); } }; return ( <>

Wallets Detected:

{providers.length > 0 ? ( providers.map((provider) => { return ( ); }) ) : (
There are no announced providers.
)}

{auth.accounts.length > 0 ? 'Wallet Selected' : 'No Wallet Selected'}

{auth.accounts.length > 0 && (
{auth.providerWithInfo!.info.name}
{auth.providerWithInfo!.info.name}
({auth.accounts[0]})
)} ); };