/* * Copyright (c) 2022 @automata-network/wallet-sdk authors and contributors. * This software may be modified and distributed under the terms of UNLICENSED * license. Refer to the LICENSE file for details. */ import React from 'react' import { useCopyToClipboard } from 'usehooks-ts' import CopySVG from '../../assets/copy.svg' import LogoutSVG from '../../assets/logout.svg' import NewTabSVG from '../../assets/new-tab.svg' import { useWallet } from '../../store/wallet' import { getAccountAddressExplorerUrl, getWalletIcon, truncateString } from '../../utils' import { Modal } from '../Modal/Modal' type Props = { open: boolean onClose: () => void } export const AccountModal: React.FC = ({ open, onClose }: Props) => { const { account, disconnect, prefixCls, chainId, chains, walletState } = useWallet() const [, copy] = useCopyToClipboard() if (!account) { return null } const chain = chains.find((item) => item.chainId === chainId) const accountUrl = chain ? getAccountAddressExplorerUrl(chain, account) : undefined return (
{`${walletState
Connected with {walletState ? walletState.label : 'wallet'}
{truncateString(account)}
{accountUrl ? ( ) : null}
) }