import { useCallback, useState } from 'react' import styled from '@emotion/styled' import useMangoStore from '../stores/useMangoStore' import { Menu } from '@headlessui/react' import { CurrencyDollarIcon, DuplicateIcon, LogoutIcon, } from '@heroicons/react/outline' import { WALLET_PROVIDERS, DEFAULT_PROVIDER } from '../hooks/useWallet' import useLocalStorageState from '../hooks/useLocalStorageState' import { abbreviateAddress, copyToClipboard } from '../utils' import WalletSelect from './WalletSelect' import { WalletIcon, ProfileIcon } from './icons' import AccountsModal from './AccountsModal' const StyledWalletTypeLabel = styled.div` font-size: 0.65rem; ` const ConnectWalletButton = () => { const wallet = useMangoStore((s) => s.wallet.current) const connected = useMangoStore((s) => s.wallet.connected) const set = useMangoStore((s) => s.set) const [showAccountsModal, setShowAccountsModal] = useState(false) const [savedProviderUrl] = useLocalStorageState( 'walletProvider', DEFAULT_PROVIDER.url ) const handleWalletConect = () => { wallet.connect() set((state) => { state.selectedMangoAccount.initialLoad = true }) } const handleCloseAccounts = useCallback(() => { setShowAccountsModal(false) }, []) return ( <> {connected && wallet?.publicKey ? (
) : (