import { useMemo } from 'react' import { Avatar, Card, Col, Row, Space, Typography } from 'antd' import WalletAction, { WalletActionType } from './walletAction' import WalletName from './walletName' import WalletAvatar from './walletAvatar' import { useWalletAddress } from 'hooks/useWallet' import { isGuestAddress, shortenAddress } from 'shared/util' import storage from 'shared/storage' import PHANTOM from 'static/images/wallet/phantom.png' import SOLFLARE from 'static/images/wallet/solflare.png' import SOLLET from 'static/images/wallet/sollet.png' import SLOPE from 'static/images/wallet/slope.svg' import COIN98 from 'static/images/wallet/coin98.png' import CLOVER from 'static/images/wallet/clover.png' import EXODUS from 'static/images/wallet/exodus.svg' import SENTRE from 'static/images/actionCenter/logo-sentre.svg' import './index.os.less' const LOGO_WALLET: Record = { Coin98: COIN98, Phantom: PHANTOM, SolletWeb: SOLLET, Slope: SLOPE, SolflareWeb: SOLFLARE, SolflareExtension: SOLFLARE, Clover: CLOVER, Exodus: EXODUS, } export type WalletProfileProps = { onClick?: () => void visible?: boolean avatarSize?: number padding?: number sideBar?: boolean } const WalletProfile = ({ onClick = () => {}, visible = false, avatarSize = 32, padding = 0, sideBar = true, }: WalletProfileProps) => { const walletAddress = useWalletAddress() const walletLogo = useMemo(() => { const walletType = storage.get('WalletType') return LOGO_WALLET[walletType] || SENTRE }, []) const actions: WalletActionType[] = useMemo(() => { if (isGuestAddress(walletAddress)) return [] if (sideBar) return ['copy', 'qr'] return ['copy', 'qr', 'explorer'] }, [walletAddress, sideBar]) return ( {visible && ( {!sideBar && } {shortenAddress(walletAddress, 3)} )} ) } export default WalletProfile