import { BaseProvider } from '@ethersproject/providers' import { styled } from '@linaria/react' import { useSignificantBalance, useWalletInfo } from '@rainbow-me/kit-hooks' import { chainIDToToken } from '@rainbow-me/kit-utils' import React, { useMemo } from 'react' import { CopyAddressButton } from './CopyAddressButton' const DisconnectButton = styled.button` color: #ff494a; ` const CloseIcon = () => { return ( ) } const Menu = styled.ul` background: linear-gradient(179.83deg, rgba(26, 27, 31, 0.8) 0.15%, #1a1b1f 99.85%); box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.1); backdrop-filter: blur(20px); border-radius: 16px; position: absolute; top: 42px; min-width: 160px; margin: 0; padding: 12.5px 13px; img { display: inline-block; } li { font-size: 14px; list-style-type: none; } li:nth-child(1) { margin-bottom: 1rem; font-weight: 800; } li:nth-child(2) { margin-bottom: 11px; } li:nth-child(3) { padding-top: 11px; border-top: 2px solid rgba(255, 255, 255, 0.01); margin-top: 24px; margin-bottom: 0; } li:nth-child(1), li > button { display: flex; align-items: center; justify-content: space-between; width: 100%; } li > button { font-weight: 600; } ` export type WalletDropdownProps = { copyAddress?: boolean | ((props: { address: string }) => JSX.Element) address: string accountAddress: string chainId: number provider: BaseProvider disconnect: () => void } & React.ClassAttributes & React.HTMLAttributes const SelectedWalletWithBalance = ({ provider, accountAddress, chainId }: { provider: BaseProvider accountAddress: string chainId: number }) => { const bal = useSignificantBalance({ provider, address: accountAddress }) const symbol = useMemo(() => chainIDToToken(chainId), [chainId]) const { logoURI, name } = useWalletInfo() return (
  • {bal.slice(0, 5)} {symbol} {logoURI && {name}}
  • ) } export const WalletDropdown = ({ copyAddress: CopyAddressComponent, address, accountAddress, chainId, provider, disconnect, ...props }: WalletDropdownProps) => (
  • {CopyAddressComponent === true || CopyAddressComponent === undefined ? ( ) : ( typeof CopyAddressComponent !== 'boolean' && )}
  • disconnect()}> Disconnect
  • )