import { useCopyTimeout } from '@vegaprotocol/react-helpers'; import { TradingButton as Button, VegaIcon, VegaIconNames, } from '@vegaprotocol/ui-toolkit'; import { truncateByChars } from '@vegaprotocol/utils'; import { useVegaWallet, type PubKey } from '@vegaprotocol/wallet'; import { useCallback, useMemo } from 'react'; import CopyToClipboard from 'react-copy-to-clipboard'; import { ViewType, useSidebar } from '../sidebar'; import { useGetCurrentRouteId } from '../../lib/hooks/use-get-current-route-id'; import { useT } from '../../lib/use-t'; export const VegaWalletMenu = ({ setMenu, }: { setMenu: (open: 'nav' | 'wallet' | null) => void; }) => { const t = useT(); const { pubKey, pubKeys, selectPubKey, disconnect } = useVegaWallet(); const currentRouteId = useGetCurrentRouteId(); const setViews = useSidebar((store) => store.setViews); const activeKey = useMemo(() => { return pubKeys?.find((pk) => pk.publicKey === pubKey); }, [pubKey, pubKeys]); const onSelectItem = useCallback( (pubkey: string) => { selectPubKey(pubkey); }, [selectPubKey] ); return (
{(pubKeys || []).map((pk) => ( ))}
); }; const KeypairListItem = ({ pk, isActive, onSelectItem, }: { pk: PubKey; isActive: boolean; onSelectItem: (pk: string) => void; }) => { const t = useT(); const [copied, setCopied] = useCopyTimeout(); return (
{isActive && } {truncateByChars(pk.publicKey)}{' '} setCopied(true)}> {copied && {t('Copied')}}
); };