import { Button, DialogActions, DialogContent, DialogContentText, List, } from '@mui/material'; import type { Wallet } from '@solana/wallet-adapter-react'; import { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; import type { Connector } from 'wagmi'; import { useAccount as useWagmiAccount } from 'wagmi'; import { Dialog } from '../../components/Dialog.js'; import { PageContainer } from '../../components/PageContainer.js'; import { useHeader } from '../../hooks/useHeader.js'; import { useWallets } from '../../hooks/useWallets.js'; import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'; import { EVMListItemButton } from './EVMListItemButton.js'; import { SVMListItemButton } from './SVMListItemButton.js'; import { TVMListItemButton } from './TVMListItemButton.js'; import { MVMListItemButton } from './MVMListItemButton.js'; import type { MVMWallet, TVMWallet } from '../../types/wallet.js'; export const SelectWalletPage = () => { const { t } = useTranslation(); const { chains, walletConfig } = useWidgetConfig(); const account = useWagmiAccount(); const [walletIdentity, setWalletIdentity] = useState<{ show: boolean; connector?: Connector; }>({ show: false }); useHeader(t(`header.selectWallet`)); const closeDialog = () => { setWalletIdentity((state) => ({ ...state, show: false, })); }; const handleNotInstalled = useCallback(async (connector: Connector) => { setWalletIdentity({ show: true, connector, }); }, []); const wallets = useWallets(walletConfig, chains); const renderWallets = () => { return wallets?.map((connector) => { if ((connector as Connector).uid) { return ( ); } // @ts-ignore if (connector.type === 'TVM') { return ( ); } // @ts-ignore if (connector.type === 'MVM') { return ( ); } if ((connector as Wallet).adapter) { return ( ); } return null; }); }; return ( {renderWallets()} {t('wallet.extensionNotFound', { name: walletIdentity.connector?.name, })} ); };