diff --git a/packages/ui/react-ui/src/WalletModal.tsx b/packages/ui/react-ui/src/WalletModal.tsx index c4853af72..983cf2521 100644 --- a/packages/ui/react-ui/src/WalletModal.tsx +++ b/packages/ui/react-ui/src/WalletModal.tsx @@ -9,6 +9,8 @@ import { Collapse } from './Collapse.js'; import { WalletListItem } from './WalletListItem.js'; import { WalletSVG } from './WalletSVG.js'; import { useWalletModal } from './useWalletModal.js'; +import { SolanaMobileWalletAdapterWalletName } from '@solana-mobile/wallet-adapter-mobile'; +import { Button } from './Button.js'; export interface WalletModalProps { className?: string; @@ -23,19 +25,23 @@ export const WalletModal: FC = ({ className = '', container = const [fadeIn, setFadeIn] = useState(false); const [portal, setPortal] = useState(null); - const [listedWallets, collapsedWallets] = useMemo(() => { + const [listedWallets, collapsedWallets, mobileWalletAdapter] = useMemo(() => { const installed: Wallet[] = []; const notInstalled: Wallet[] = []; - + let mobileWalletAdapter; for (const wallet of wallets) { - if (wallet.readyState === WalletReadyState.Installed) { + if (wallet.adapter.name === SolanaMobileWalletAdapterWalletName) { + mobileWalletAdapter = wallet; + } else if (wallet.readyState === WalletReadyState.Installed) { installed.push(wallet); } else { notInstalled.push(wallet); } } - return installed.length ? [installed, notInstalled] : [notInstalled, []]; + return installed.length + ? [installed, notInstalled, mobileWalletAdapter] + : [notInstalled, [], mobileWalletAdapter]; }, [wallets]); const hideModal = useCallback(() => { @@ -137,16 +143,40 @@ export const WalletModal: FC = ({ className = '', container = {listedWallets.length ? ( <>

Connect a wallet on Solana to continue

+ {mobileWalletAdapter && ( + <> +

On your phone:

+ + + )}
    - {listedWallets.map((wallet) => ( - handleWalletClick(event, wallet.adapter.name)} - wallet={wallet} - /> - ))} + {mobileWalletAdapter && !collapsedWallets.length && ( +

    Other wallets:

    + )} + {listedWallets.map((wallet) => { + if (wallet.adapter.name === SolanaMobileWalletAdapterWalletName) { + return; + } + return ( + handleWalletClick(event, wallet.adapter.name)} + wallet={wallet} + /> + ); + })} {collapsedWallets.length ? ( + {mobileWalletAdapter && listedWallets.length === 1 && ( +

    Other wallets:

    + )} {collapsedWallets.map((wallet) => (