import React, { useContext } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Redirect, useHistory, useParams } from 'react-router-dom'; import { getProviderConfig, getTokens } from '../../ducks/metamask/metamask'; import { getTokenList } from '../../selectors'; import { useCopyToClipboard } from '../../hooks/useCopyToClipboard'; import Identicon from '../../components/ui/identicon'; import { I18nContext } from '../../contexts/i18n'; import { useTokenTracker } from '../../hooks/useTokenTracker'; import { useTokenFiatAmount } from '../../hooks/useTokenFiatAmount'; import { showModal } from '../../store/actions'; import { NETWORK_TYPES } from '../../../shared/constants/network'; import { ASSET_ROUTE, DEFAULT_ROUTE } from '../../helpers/constants/routes'; import Tooltip from '../../components/ui/tooltip'; import Button from '../../components/ui/button'; import Box from '../../components/ui/box'; import { TextVariant, FontWeight, DISPLAY, TextAlign, OverflowWrap, TextColor, IconColor, } from '../../helpers/constants/design-system'; import { isEqualCaseInsensitive } from '../../../shared/modules/string-utils'; import { ButtonIcon, ButtonIconSize, IconName, } from '../../components/component-library'; import { Text } from '../../components/component-library/text/deprecated'; export default function TokenDetailsPage() { const dispatch = useDispatch(); const history = useHistory(); const t = useContext(I18nContext); const tokens = useSelector(getTokens); const tokenList = useSelector(getTokenList); const { address: tokenAddress } = useParams(); const tokenMetadata = tokenList[tokenAddress.toLowerCase()]; const aggregators = tokenMetadata?.aggregators?.join(', '); const token = tokens.find(({ address }) => isEqualCaseInsensitive(address, tokenAddress), ); const { tokensWithBalances } = useTokenTracker([token]); const tokenBalance = tokensWithBalances[0]?.string; const tokenCurrencyBalance = useTokenFiatAmount( token?.address, tokenBalance, token?.symbol, ); const { nickname, type: networkType } = useSelector(getProviderConfig); const [copied, handleCopy] = useCopyToClipboard(); if (!token) { return ; } return ( {t('tokenDetails')} ); }