import { CopyIcon, CloseIcon as DisconnectIcon, RepeatIcon as SwitchIcon } from '@chakra-ui/icons'; import type { ButtonProps } from '@chakra-ui/react'; import { Button, Collapse, Menu, MenuItem } from '@chakra-ui/react'; import { useWallet } from '@solana/wallet-adapter-react'; import type { FC } from 'react'; import React, { useMemo, useState } from 'react'; import { useWalletDialog } from './useWalletDialog.js'; import { WalletConnectButton } from './WalletConnectButton.js'; import { WalletDialogButton } from './WalletDialogButton.js'; import { WalletIcon } from './WalletIcon.js'; export const WalletMultiButton: FC = ({ color = 'primary', variant = 'contained', type = 'button', children, ...props }) => { const { publicKey, wallet, disconnect } = useWallet(); const { onOpen } = useWalletDialog(); const [anchor, setAnchor] = useState(); const base58 = useMemo(() => publicKey?.toBase58(), [publicKey]); const content = useMemo(() => { if (children) return children; if (!wallet || !base58) return null; return base58.slice(0, 4) + '..' + base58.slice(-4); }, [children, wallet, base58]); if (!wallet) { return ( {children} ); } if (!base58) { return ( {children} ); } return ( <> setAnchor(undefined)}> setAnchor(undefined)}> { setAnchor(undefined); await navigator.clipboard.writeText(base58); }} icon={} > Copy address { setAnchor(undefined); onOpen; }} icon={} > Change wallet { setAnchor(undefined); // eslint-disable-next-line @typescript-eslint/no-empty-function disconnect().catch(() => { // Silently catch because any errors are caught by the context `onError` handler }); }} icon={} > Disconnect ); };