Commit 7132117f authored by tom's avatar tom

remove usage of TokenLogo

parent d9b5b3c9
...@@ -22,11 +22,11 @@ import TOKEN_TYPE from 'lib/token/tokenTypes'; ...@@ -22,11 +22,11 @@ import TOKEN_TYPE from 'lib/token/tokenTypes';
import { getTokenTransfersStub } from 'stubs/token'; import { getTokenTransfersStub } from 'stubs/token';
import ActionBar from 'ui/shared/ActionBar'; import ActionBar from 'ui/shared/ActionBar';
import DataListDisplay from 'ui/shared/DataListDisplay'; import DataListDisplay from 'ui/shared/DataListDisplay';
import * as TokenEntity from 'ui/shared/entities/token/TokenEntity';
import HashStringShorten from 'ui/shared/HashStringShorten'; import HashStringShorten from 'ui/shared/HashStringShorten';
import Pagination from 'ui/shared/pagination/Pagination'; import Pagination from 'ui/shared/pagination/Pagination';
import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages'; import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';
import * as SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice'; import * as SocketNewItemsNotice from 'ui/shared/SocketNewItemsNotice';
import TokenLogo from 'ui/shared/TokenLogo';
import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter'; import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter';
import TokenTransferList from 'ui/shared/TokenTransfer/TokenTransferList'; import TokenTransferList from 'ui/shared/TokenTransfer/TokenTransferList';
import TokenTransferTable from 'ui/shared/TokenTransfer/TokenTransferTable'; import TokenTransferTable from 'ui/shared/TokenTransfer/TokenTransferTable';
...@@ -227,19 +227,20 @@ const AddressTokenTransfers = ({ scrollRef, overloadCount = OVERLOAD_COUNT }: Pr ...@@ -227,19 +227,20 @@ const AddressTokenTransfers = ({ scrollRef, overloadCount = OVERLOAD_COUNT }: Pr
address: tokenFilter || '', address: tokenFilter || '',
name: '', name: '',
icon_url: '', icon_url: '',
symbol: '',
}), [ tokenFilter ]); }), [ tokenFilter ]);
const tokenFilterComponent = tokenFilter && ( const tokenFilterComponent = tokenFilter && (
<Flex alignItems="center" flexWrap="wrap" mb={{ base: isActionBarHidden ? 3 : 6, lg: 0 }} mr={ 4 }> <Flex alignItems="center" flexWrap="wrap" mb={{ base: isActionBarHidden ? 3 : 6, lg: 0 }} mr={ 4 }>
<Text whiteSpace="nowrap" mr={ 2 } py={ 1 }>Filtered by token</Text> <Text whiteSpace="nowrap" mr={ 2 } py={ 1 }>Filtered by token</Text>
<Flex alignItems="center" py={ 1 }> <Flex alignItems="center" py={ 1 }>
<TokenLogo data={ tokenData } boxSize={ 6 } mr={ 2 }/> <TokenEntity.Icon token={ tokenData } isLoading={ isPlaceholderData }/>
{ isMobile ? <HashStringShorten hash={ tokenFilter }/> : tokenFilter } { isMobile ? <HashStringShorten hash={ tokenFilter }/> : tokenFilter }
<Tooltip label="Reset filter"> <Tooltip label="Reset filter">
<Flex> <Flex>
<Icon <Icon
as={ crossIcon } as={ crossIcon }
boxSize={ 6 } boxSize={ 5 }
ml={ 1 } ml={ 1 }
color={ resetTokenIconColor } color={ resetTokenIconColor }
cursor="pointer" cursor="pointer"
......
...@@ -10,7 +10,6 @@ import useSocketChannel from 'lib/socket/useSocketChannel'; ...@@ -10,7 +10,6 @@ import useSocketChannel from 'lib/socket/useSocketChannel';
import useSocketMessage from 'lib/socket/useSocketMessage'; import useSocketMessage from 'lib/socket/useSocketMessage';
import CurrencyValue from 'ui/shared/CurrencyValue'; import CurrencyValue from 'ui/shared/CurrencyValue';
import DetailsInfoItem from 'ui/shared/DetailsInfoItem'; import DetailsInfoItem from 'ui/shared/DetailsInfoItem';
import TokenLogo from 'ui/shared/TokenLogo';
interface Props { interface Props {
data: Pick<Address, 'block_number_balance_updated_at' | 'coin_balance' | 'hash' | 'exchange_rate'>; data: Pick<Address, 'block_number_balance_updated_at' | 'coin_balance' | 'hash' | 'exchange_rate'>;
...@@ -64,11 +63,6 @@ const AddressBalance = ({ data, isLoading }: Props) => { ...@@ -64,11 +63,6 @@ const AddressBalance = ({ data, isLoading }: Props) => {
handler: handleNewCoinBalanceMessage, handler: handleNewCoinBalanceMessage,
}); });
const tokenData = React.useMemo(() => ({
name: config.chain.currency.name || '',
icon_url: '',
}), [ ]);
return ( return (
<DetailsInfoItem <DetailsInfoItem
title="Balance" title="Balance"
...@@ -77,13 +71,6 @@ const AddressBalance = ({ data, isLoading }: Props) => { ...@@ -77,13 +71,6 @@ const AddressBalance = ({ data, isLoading }: Props) => {
alignItems="flex-start" alignItems="flex-start"
isLoading={ isLoading } isLoading={ isLoading }
> >
<TokenLogo
data={ tokenData }
boxSize={ 5 }
mr={ 2 }
fontSize="sm"
isLoading={ isLoading }
/>
<CurrencyValue <CurrencyValue
value={ data.coin_balance || '0' } value={ data.coin_balance || '0' }
exchangeRate={ data.exchange_rate } exchangeRate={ data.exchange_rate }
......
...@@ -5,17 +5,14 @@ import type { AddressTokenBalance } from 'types/api/address'; ...@@ -5,17 +5,14 @@ import type { AddressTokenBalance } from 'types/api/address';
import getCurrencyValue from 'lib/getCurrencyValue'; import getCurrencyValue from 'lib/getCurrencyValue';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet'; import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
import AddressLink from 'ui/shared/address/AddressLink';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import TokenEntity from 'ui/shared/entities/token/TokenEntity';
import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TokenLogo from 'ui/shared/TokenLogo';
type Props = AddressTokenBalance & { isLoading: boolean}; type Props = AddressTokenBalance & { isLoading: boolean};
const ERC20TokensListItem = ({ token, value, isLoading }: Props) => { const ERC20TokensListItem = ({ token, value, isLoading }: Props) => {
const tokenString = [ token.name, token.symbol && `(${ token.symbol })` ].filter(Boolean).join(' ');
const { const {
valueStr: tokenQuantity, valueStr: tokenQuantity,
usd: tokenValue, usd: tokenValue,
...@@ -24,8 +21,13 @@ const ERC20TokensListItem = ({ token, value, isLoading }: Props) => { ...@@ -24,8 +21,13 @@ const ERC20TokensListItem = ({ token, value, isLoading }: Props) => {
return ( return (
<ListItemMobile rowGap={ 2 }> <ListItemMobile rowGap={ 2 }>
<Flex alignItems="center" width="100%"> <Flex alignItems="center" width="100%">
<TokenLogo data={ token } boxSize={ 6 } mr={ 2 } isLoading={ isLoading }/> <TokenEntity
<AddressLink fontWeight="700" hash={ token.address } type="token" alias={ tokenString } isLoading={ isLoading }/> token={ token }
isLoading={ isLoading }
noCopy
jointSymbol
fontWeight="700"
/>
</Flex> </Flex>
<Flex alignItems="center" pl={ 8 }> <Flex alignItems="center" pl={ 8 }>
<AddressEntity <AddressEntity
......
...@@ -5,9 +5,8 @@ import type { AddressTokenBalance } from 'types/api/address'; ...@@ -5,9 +5,8 @@ import type { AddressTokenBalance } from 'types/api/address';
import getCurrencyValue from 'lib/getCurrencyValue'; import getCurrencyValue from 'lib/getCurrencyValue';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet'; import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
import AddressLink from 'ui/shared/address/AddressLink';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import TokenLogo from 'ui/shared/TokenLogo'; import TokenEntity from 'ui/shared/entities/token/TokenEntity';
type Props = AddressTokenBalance & { isLoading: boolean }; type Props = AddressTokenBalance & { isLoading: boolean };
...@@ -17,8 +16,6 @@ const ERC20TokensTableItem = ({ ...@@ -17,8 +16,6 @@ const ERC20TokensTableItem = ({
isLoading, isLoading,
}: Props) => { }: Props) => {
const tokenString = [ token.name, token.symbol && `(${ token.symbol })` ].filter(Boolean).join(' ');
const { const {
valueStr: tokenQuantity, valueStr: tokenQuantity,
usd: tokenValue, usd: tokenValue,
...@@ -27,10 +24,13 @@ const ERC20TokensTableItem = ({ ...@@ -27,10 +24,13 @@ const ERC20TokensTableItem = ({
return ( return (
<Tr> <Tr>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
<Flex alignItems="center"> <TokenEntity
<TokenLogo data={ token } boxSize={ 6 } mr={ 2 } isLoading={ isLoading }/> token={ token }
<AddressLink fontWeight="700" hash={ token.address } type="token" alias={ tokenString } isLoading={ isLoading }/> isLoading={ isLoading }
</Flex> noCopy
jointSymbol
fontWeight="700"
/>
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
<Flex alignItems="center" width="150px" justifyContent="space-between"> <Flex alignItems="center" width="150px" justifyContent="space-between">
......
...@@ -5,10 +5,9 @@ import React from 'react'; ...@@ -5,10 +5,9 @@ import React from 'react';
import type { AddressTokenBalance } from 'types/api/address'; import type { AddressTokenBalance } from 'types/api/address';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet'; import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
import AddressLink from 'ui/shared/address/AddressLink';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import TokenEntityWithAddressFilter from 'ui/shared/entities/token/TokenEntityWithAddressFilter';
import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TokenLogo from 'ui/shared/TokenLogo';
type Props = AddressTokenBalance & { isLoading: boolean}; type Props = AddressTokenBalance & { isLoading: boolean};
...@@ -17,14 +16,16 @@ const ERC721TokensListItem = ({ token, value, isLoading }: Props) => { ...@@ -17,14 +16,16 @@ const ERC721TokensListItem = ({ token, value, isLoading }: Props) => {
const hash = router.query.hash?.toString() || ''; const hash = router.query.hash?.toString() || '';
const tokenString = [ token.name, token.symbol && `(${ token.symbol })` ].filter(Boolean).join(' ');
return ( return (
<ListItemMobile rowGap={ 2 }> <ListItemMobile rowGap={ 2 }>
<Flex alignItems="center" width="100%"> <TokenEntityWithAddressFilter
<TokenLogo data={ token } boxSize={ 6 } mr={ 2 } isLoading={ isLoading }/> token={ token }
<AddressLink fontWeight="700" hash={ hash } tokenHash={ token.address } type="address_token" alias={ tokenString } isLoading={ isLoading }/> isLoading={ isLoading }
</Flex> addressHash={ hash }
noCopy
jointSymbol
fontWeight={ 700 }
/>
<Flex alignItems="center" pl={ 8 }> <Flex alignItems="center" pl={ 8 }>
<AddressEntity <AddressEntity
address={{ hash: token.address }} address={{ hash: token.address }}
......
...@@ -5,9 +5,8 @@ import React from 'react'; ...@@ -5,9 +5,8 @@ import React from 'react';
import type { AddressTokenBalance } from 'types/api/address'; import type { AddressTokenBalance } from 'types/api/address';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet'; import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
import AddressLink from 'ui/shared/address/AddressLink';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import TokenLogo from 'ui/shared/TokenLogo'; import TokenEntityWithAddressFilter from 'ui/shared/entities/token/TokenEntityWithAddressFilter';
type Props = AddressTokenBalance & { isLoading: boolean}; type Props = AddressTokenBalance & { isLoading: boolean};
...@@ -19,15 +18,18 @@ const ERC721TokensTableItem = ({ ...@@ -19,15 +18,18 @@ const ERC721TokensTableItem = ({
const router = useRouter(); const router = useRouter();
const hash = router.query.hash?.toString() || ''; const hash = router.query.hash?.toString() || '';
const tokenString = [ token.name, token.symbol && `(${ token.symbol })` ].filter(Boolean).join(' ');
return ( return (
<Tr> <Tr>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
<Flex alignItems="center"> <TokenEntityWithAddressFilter
<TokenLogo data={ token } boxSize={ 6 } mr={ 2 } isLoading={ isLoading }/> token={ token }
<AddressLink fontWeight="700" hash={ hash } tokenHash={ token.address } type="address_token" alias={ tokenString } isLoading={ isLoading }/> addressHash={ hash }
</Flex> isLoading={ isLoading }
noCopy
jointSymbol
fontWeight="700"
/>
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
<Flex alignItems="center" width="150px" justifyContent="space-between"> <Flex alignItems="center" width="150px" justifyContent="space-between">
......
...@@ -5,10 +5,9 @@ import type { AddressTokenBalance } from 'types/api/address'; ...@@ -5,10 +5,9 @@ import type { AddressTokenBalance } from 'types/api/address';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import TokenEntity from 'ui/shared/entities/token/TokenEntity';
import NftMedia from 'ui/shared/nft/NftMedia'; import NftMedia from 'ui/shared/nft/NftMedia';
import TokenLogo from 'ui/shared/TokenLogo';
import TruncatedTextTooltip from 'ui/shared/TruncatedTextTooltip'; import TruncatedTextTooltip from 'ui/shared/TruncatedTextTooltip';
import TruncatedValue from 'ui/shared/TruncatedValue';
type Props = AddressTokenBalance & { isLoading: boolean }; type Props = AddressTokenBalance & { isLoading: boolean };
...@@ -53,12 +52,12 @@ const NFTItem = ({ token, token_id: tokenId, token_instance: tokenInstance, isLo ...@@ -53,12 +52,12 @@ const NFTItem = ({ token, token_id: tokenId, token_instance: tokenInstance, isLo
</TruncatedTextTooltip> </TruncatedTextTooltip>
</Flex> </Flex>
) } ) }
{ token.name && ( <TokenEntity
<Flex alignItems="center"> token={ token }
<TokenLogo data={ token } boxSize={ 6 } ml={ 1 } mr={ 1 } isLoading={ isLoading }/> isLoading={ isLoading }
<TruncatedValue isLoading={ isLoading } value={ token.name } color="text_secondary"/> noCopy
</Flex> noSymbol
) } />
</LinkBox> </LinkBox>
); );
}; };
......
...@@ -7,7 +7,7 @@ import config from 'configs/app'; ...@@ -7,7 +7,7 @@ import config from 'configs/app';
import globeIcon from 'icons/globe.svg'; import globeIcon from 'icons/globe.svg';
import txIcon from 'icons/transactions.svg'; import txIcon from 'icons/transactions.svg';
import { sortByDateDesc } from 'ui/shared/chart/utils/sorts'; import { sortByDateDesc } from 'ui/shared/chart/utils/sorts';
import TokenLogo from 'ui/shared/TokenLogo'; import * as TokenEntity from 'ui/shared/entities/token/TokenEntity';
const dailyTxsIndicator: TChainIndicator<'homepage_chart_txs'> = { const dailyTxsIndicator: TChainIndicator<'homepage_chart_txs'> = {
id: 'daily_txs', id: 'daily_txs',
...@@ -30,13 +30,15 @@ const dailyTxsIndicator: TChainIndicator<'homepage_chart_txs'> = { ...@@ -30,13 +30,15 @@ const dailyTxsIndicator: TChainIndicator<'homepage_chart_txs'> = {
const nativeTokenData = { const nativeTokenData = {
name: config.chain.currency.name || '', name: config.chain.currency.name || '',
icon_url: '', icon_url: '',
symbol: '',
address: '',
}; };
const coinPriceIndicator: TChainIndicator<'homepage_chart_market'> = { const coinPriceIndicator: TChainIndicator<'homepage_chart_market'> = {
id: 'coin_price', id: 'coin_price',
title: `${ config.chain.currency.symbol } price`, title: `${ config.chain.currency.symbol } price`,
value: (stats) => '$' + Number(stats.coin_price).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 6 }), value: (stats) => '$' + Number(stats.coin_price).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 6 }),
icon: <TokenLogo data={ nativeTokenData } boxSize={ 6 }/>, icon: <TokenEntity.Icon token={ nativeTokenData } iconSize="24"/>,
hint: `${ config.chain.currency.symbol } token daily price in USD.`, hint: `${ config.chain.currency.symbol } token daily price in USD.`,
api: { api: {
resourceName: 'homepage_chart_market', resourceName: 'homepage_chart_market',
......
...@@ -24,6 +24,7 @@ import * as tokenStubs from 'stubs/token'; ...@@ -24,6 +24,7 @@ import * as tokenStubs from 'stubs/token';
import { generateListStub } from 'stubs/utils'; import { generateListStub } from 'stubs/utils';
import AddressContract from 'ui/address/AddressContract'; import AddressContract from 'ui/address/AddressContract';
import TextAd from 'ui/shared/ad/TextAd'; import TextAd from 'ui/shared/ad/TextAd';
import * as TokenEntity from 'ui/shared/entities/token/TokenEntity';
import EntityTags from 'ui/shared/EntityTags'; import EntityTags from 'ui/shared/EntityTags';
import NetworkExplorers from 'ui/shared/NetworkExplorers'; import NetworkExplorers from 'ui/shared/NetworkExplorers';
import PageTitle from 'ui/shared/Page/PageTitle'; import PageTitle from 'ui/shared/Page/PageTitle';
...@@ -31,7 +32,6 @@ import Pagination from 'ui/shared/pagination/Pagination'; ...@@ -31,7 +32,6 @@ import Pagination from 'ui/shared/pagination/Pagination';
import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages'; import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';
import RoutedTabs from 'ui/shared/Tabs/RoutedTabs'; import RoutedTabs from 'ui/shared/Tabs/RoutedTabs';
import TabsSkeleton from 'ui/shared/Tabs/TabsSkeleton'; import TabsSkeleton from 'ui/shared/Tabs/TabsSkeleton';
import TokenLogo from 'ui/shared/TokenLogo';
import TokenContractInfo from 'ui/token/TokenContractInfo'; import TokenContractInfo from 'ui/token/TokenContractInfo';
import TokenDetails from 'ui/token/TokenDetails'; import TokenDetails from 'ui/token/TokenDetails';
import TokenHolders from 'ui/token/TokenHolders/TokenHolders'; import TokenHolders from 'ui/token/TokenHolders/TokenHolders';
...@@ -270,14 +270,13 @@ const TokenPageContent = () => { ...@@ -270,14 +270,13 @@ const TokenPageContent = () => {
title={ `${ tokenQuery.data?.name || 'Unnamed token' }${ tokenSymbolText }` } title={ `${ tokenQuery.data?.name || 'Unnamed token' }${ tokenSymbolText }` }
isLoading={ tokenQuery.isPlaceholderData } isLoading={ tokenQuery.isPlaceholderData }
backLink={ backLink } backLink={ backLink }
beforeTitle={ ( beforeTitle={ tokenQuery.data ? (
<TokenLogo <TokenEntity.Icon
data={ tokenQuery.data } token={ tokenQuery.data }
boxSize={ 6 }
isLoading={ tokenQuery.isPlaceholderData } isLoading={ tokenQuery.isPlaceholderData }
mr={ 2 } iconSize="lg"
/> />
) } ) : null }
contentAfter={ titleContentAfter } contentAfter={ titleContentAfter }
/> />
<TokenContractInfo tokenQuery={ tokenQuery } contractQuery={ contractQuery }/> <TokenContractInfo tokenQuery={ tokenQuery } contractQuery={ contractQuery }/>
......
...@@ -13,6 +13,7 @@ import * as mixpanel from 'lib/mixpanel/index'; ...@@ -13,6 +13,7 @@ import * as mixpanel from 'lib/mixpanel/index';
import { saveToRecentKeywords } from 'lib/recentSearchKeywords'; import { saveToRecentKeywords } from 'lib/recentSearchKeywords';
import * as AddressEntity from 'ui/shared/entities/address/AddressEntity'; import * as AddressEntity from 'ui/shared/entities/address/AddressEntity';
import * as BlockEntity from 'ui/shared/entities/block/BlockEntity'; import * as BlockEntity from 'ui/shared/entities/block/BlockEntity';
import * as TokenEntity from 'ui/shared/entities/token/TokenEntity';
import * as TxEntity from 'ui/shared/entities/tx/TxEntity'; import * as TxEntity from 'ui/shared/entities/tx/TxEntity';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
...@@ -20,7 +21,6 @@ import LinkInternal from 'ui/shared/LinkInternal'; ...@@ -20,7 +21,6 @@ import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import type { SearchResultAppItem } from 'ui/shared/search/utils'; import type { SearchResultAppItem } from 'ui/shared/search/utils';
import { getItemCategory, searchItemTitles } from 'ui/shared/search/utils'; import { getItemCategory, searchItemTitles } from 'ui/shared/search/utils';
import TokenLogo from 'ui/shared/TokenLogo';
interface Props { interface Props {
data: SearchResultItem | SearchResultAppItem; data: SearchResultItem | SearchResultAppItem;
...@@ -48,9 +48,8 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => { ...@@ -48,9 +48,8 @@ const SearchResultListItem = ({ data, searchTerm, isLoading }: Props) => {
return ( return (
<Flex alignItems="flex-start" flexGrow={ 1 } overflow="hidden"> <Flex alignItems="flex-start" flexGrow={ 1 } overflow="hidden">
<TokenLogo boxSize={ 6 } data={ data } flexShrink={ 0 } isLoading={ isLoading }/> <TokenEntity.Icon token={ data } isLoading={ isLoading }/>
<LinkInternal <LinkInternal
ml={ 2 }
href={ route({ pathname: '/token/[hash]', query: { hash: data.address } }) } href={ route({ pathname: '/token/[hash]', query: { hash: data.address } }) }
fontWeight={ 700 } fontWeight={ 700 }
wordBreak="break-all" wordBreak="break-all"
......
...@@ -13,13 +13,13 @@ import * as mixpanel from 'lib/mixpanel/index'; ...@@ -13,13 +13,13 @@ import * as mixpanel from 'lib/mixpanel/index';
import { saveToRecentKeywords } from 'lib/recentSearchKeywords'; import { saveToRecentKeywords } from 'lib/recentSearchKeywords';
import * as AddressEntity from 'ui/shared/entities/address/AddressEntity'; import * as AddressEntity from 'ui/shared/entities/address/AddressEntity';
import * as BlockEntity from 'ui/shared/entities/block/BlockEntity'; import * as BlockEntity from 'ui/shared/entities/block/BlockEntity';
import * as TokenEntity from 'ui/shared/entities/token/TokenEntity';
import * as TxEntity from 'ui/shared/entities/tx/TxEntity'; import * as TxEntity from 'ui/shared/entities/tx/TxEntity';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import type { SearchResultAppItem } from 'ui/shared/search/utils'; import type { SearchResultAppItem } from 'ui/shared/search/utils';
import { getItemCategory, searchItemTitles } from 'ui/shared/search/utils'; import { getItemCategory, searchItemTitles } from 'ui/shared/search/utils';
import TokenLogo from 'ui/shared/TokenLogo';
interface Props { interface Props {
data: SearchResultItem | SearchResultAppItem; data: SearchResultItem | SearchResultAppItem;
...@@ -49,9 +49,8 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => { ...@@ -49,9 +49,8 @@ const SearchResultTableItem = ({ data, searchTerm, isLoading }: Props) => {
<> <>
<Td fontSize="sm"> <Td fontSize="sm">
<Flex alignItems="center"> <Flex alignItems="center">
<TokenLogo boxSize={ 6 } data={ data } flexShrink={ 0 } isLoading={ isLoading }/> <TokenEntity.Icon token={ data } isLoading={ isLoading }/>
<LinkInternal <LinkInternal
ml={ 2 }
href={ route({ pathname: '/token/[hash]', query: { hash: data.address } }) } href={ route({ pathname: '/token/[hash]', query: { hash: data.address } }) }
fontWeight={ 700 } fontWeight={ 700 }
wordBreak="break-all" wordBreak="break-all"
......
...@@ -5,9 +5,9 @@ import type { TokenInfo } from 'types/api/token'; ...@@ -5,9 +5,9 @@ import type { TokenInfo } from 'types/api/token';
import iconVerifiedToken from 'icons/verified_token.svg'; import iconVerifiedToken from 'icons/verified_token.svg';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
import * as TokenEntity from 'ui/shared/entities/token/TokenEntity';
import EntityTags from 'ui/shared/EntityTags'; import EntityTags from 'ui/shared/EntityTags';
import NetworkExplorers from 'ui/shared/NetworkExplorers'; import NetworkExplorers from 'ui/shared/NetworkExplorers';
import TokenLogo from 'ui/shared/TokenLogo';
import PageTitle from '../PageTitle'; import PageTitle from '../PageTitle';
...@@ -49,7 +49,10 @@ const DefaultView = () => { ...@@ -49,7 +49,10 @@ const DefaultView = () => {
<PageTitle <PageTitle
title="Shavukha Token (SHVKH) token" title="Shavukha Token (SHVKH) token"
beforeTitle={ ( beforeTitle={ (
<TokenLogo data={ tokenData } boxSize={ 6 } mr={ 2 }/> <TokenEntity.Icon
token={ tokenData }
iconSize="lg"
/>
) } ) }
backLink={ backLink } backLink={ backLink }
contentAfter={ contentAfter } contentAfter={ contentAfter }
......
...@@ -7,9 +7,9 @@ import type { TokenInfo } from 'types/api/token'; ...@@ -7,9 +7,9 @@ import type { TokenInfo } from 'types/api/token';
import iconVerifiedToken from 'icons/verified_token.svg'; import iconVerifiedToken from 'icons/verified_token.svg';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
import { publicTag, privateTag, watchlistName } from 'mocks/address/tag'; import { publicTag, privateTag, watchlistName } from 'mocks/address/tag';
import * as TokenEntity from 'ui/shared/entities/token/TokenEntity';
import EntityTags from 'ui/shared/EntityTags'; import EntityTags from 'ui/shared/EntityTags';
import NetworkExplorers from 'ui/shared/NetworkExplorers'; import NetworkExplorers from 'ui/shared/NetworkExplorers';
import TokenLogo from 'ui/shared/TokenLogo';
import PageTitle from '../PageTitle'; import PageTitle from '../PageTitle';
...@@ -57,7 +57,10 @@ const LongNameAndManyTags = () => { ...@@ -57,7 +57,10 @@ const LongNameAndManyTags = () => {
<PageTitle <PageTitle
title={ `${ tokenData?.name }${ tokenSymbolText } token` } title={ `${ tokenData?.name }${ tokenSymbolText } token` }
beforeTitle={ ( beforeTitle={ (
<TokenLogo data={ tokenData } boxSize={ 6 } mr={ 2 }/> <TokenEntity.Icon
token={ tokenData }
iconSize="lg"
/>
) } ) }
contentAfter={ contentAfter } contentAfter={ contentAfter }
/> />
......
...@@ -11,6 +11,7 @@ export interface Props { ...@@ -11,6 +11,7 @@ export interface Props {
isLoading?: boolean; isLoading?: boolean;
} }
// TODO @tom2drum - remove this component
const TokenLogo = ({ className, isLoading, data }: Props) => { const TokenLogo = ({ className, isLoading, data }: Props) => {
if (isLoading) { if (isLoading) {
......
export type IconSize = 'md' | 'lg'; export type IconSize = 'md' | 'lg' | '24';
export function getIconProps(size: IconSize = 'md') { export function getIconProps(size: IconSize = 'md') {
switch (size) { switch (size) {
...@@ -12,5 +12,10 @@ export function getIconProps(size: IconSize = 'md') { ...@@ -12,5 +12,10 @@ export function getIconProps(size: IconSize = 'md') {
boxSize: '30px', // for headings boxSize: '30px', // for headings
}; };
} }
case '24': {
return {
boxSize: '24px', // deprecated
};
}
} }
} }
...@@ -28,11 +28,11 @@ const Link = chakra((props: LinkProps) => { ...@@ -28,11 +28,11 @@ const Link = chakra((props: LinkProps) => {
); );
}); });
type IconProps = Pick<EntityProps, 'token' | 'isLoading' | 'iconSize' | 'noIcon'> & { type IconProps = Pick<EntityProps, 'token' | 'isLoading' | 'iconSize' | 'noIcon' | 'className'> & {
asProp?: As; asProp?: As;
}; };
const Icon = (props: IconProps) => { const Icon = chakra((props: IconProps) => {
if (props.noIcon) { if (props.noIcon) {
return null; return null;
} }
...@@ -44,26 +44,30 @@ const Icon = (props: IconProps) => { ...@@ -44,26 +44,30 @@ const Icon = (props: IconProps) => {
}; };
if (props.isLoading) { if (props.isLoading) {
return <Skeleton { ...styles } flexShrink={ 0 }/>; return <Skeleton { ...styles } className={ props.className } flexShrink={ 0 }/>;
} }
return ( return (
<Image <Image
{ ...styles } { ...styles }
className={ props.className }
src={ props.token.icon_url ?? undefined } src={ props.token.icon_url ?? undefined }
alt={ `${ props.token.name || 'token' } logo` } alt={ `${ props.token.name || 'token' } logo` }
fallback={ <TokenLogoPlaceholder { ...styles }/> } fallback={ <TokenLogoPlaceholder { ...styles }/> }
/> />
); );
}; });
type ContentProps = Omit<EntityBase.ContentBaseProps, 'text'> & Pick<EntityProps, 'token'>; type ContentProps = Omit<EntityBase.ContentBaseProps, 'text'> & Pick<EntityProps, 'token' | 'jointSymbol'>;
const Content = chakra((props: ContentProps) => { const Content = chakra((props: ContentProps) => {
const name = props.token.name ?? 'Unnamed token'; const nameString = [
props.token.name ?? 'Unnamed token',
props.token.symbol && props.jointSymbol && `(${ props.token.symbol })`,
].filter(Boolean).join(' ');
return ( return (
<TruncatedTextTooltip label={ name }> <TruncatedTextTooltip label={ nameString }>
<Skeleton <Skeleton
isLoaded={ !props.isLoading } isLoaded={ !props.isLoading }
display="inline-block" display="inline-block"
...@@ -72,18 +76,18 @@ const Content = chakra((props: ContentProps) => { ...@@ -72,18 +76,18 @@ const Content = chakra((props: ContentProps) => {
textOverflow="ellipsis" textOverflow="ellipsis"
height="fit-content" height="fit-content"
> >
{ name } { nameString }
</Skeleton> </Skeleton>
</TruncatedTextTooltip> </TruncatedTextTooltip>
); );
}); });
type SymbolProps = Pick<EntityProps, 'token' | 'isLoading' | 'noSymbol'>; type SymbolProps = Pick<EntityProps, 'token' | 'isLoading' | 'noSymbol' | 'jointSymbol'>;
const Symbol = (props: SymbolProps) => { const Symbol = (props: SymbolProps) => {
const symbol = props.token.symbol; const symbol = props.token.symbol;
if (!symbol || props.noSymbol) { if (!symbol || props.noSymbol || props.jointSymbol) {
return null; return null;
} }
...@@ -129,6 +133,7 @@ const Container = EntityBase.Container; ...@@ -129,6 +133,7 @@ const Container = EntityBase.Container;
export interface EntityProps extends EntityBase.EntityBaseProps { export interface EntityProps extends EntityBase.EntityBaseProps {
token: Pick<TokenInfo, 'address' | 'icon_url' | 'name' | 'symbol'>; token: Pick<TokenInfo, 'address' | 'icon_url' | 'name' | 'symbol'>;
noSymbol?: boolean; noSymbol?: boolean;
jointSymbol?: boolean;
} }
const TokenEntity = (props: EntityProps) => { const TokenEntity = (props: EntityProps) => {
......
import { chakra } from '@chakra-ui/react';
import React from 'react';
import { route } from 'nextjs-routes';
import * as TokenEntity from './TokenEntity';
interface Props extends TokenEntity.EntityProps {
addressHash: string;
}
const TokenEntityWithAddressFilter = (props: Props) => {
const defaultHref = route({
pathname: '/address/[hash]',
query: {
...props.query,
hash: props.addressHash,
tab: 'token_transfers',
token: props.token.address,
scroll_to_tabs: 'true',
},
});
return (
<TokenEntity.default { ...props } href={ props.href ?? defaultHref }/>
);
};
export default chakra(TokenEntityWithAddressFilter);
...@@ -59,6 +59,7 @@ const TokenTransferTableItem = ({ ...@@ -59,6 +59,7 @@ const TokenTransferTableItem = ({
isLoading={ isLoading } isLoading={ isLoading }
truncation="constant" truncation="constant"
tokenHash={ token.address } tokenHash={ token.address }
my="5px"
/> />
</Td> </Td>
<Td px={ 0 }> <Td px={ 0 }>
...@@ -72,6 +73,7 @@ const TokenTransferTableItem = ({ ...@@ -72,6 +73,7 @@ const TokenTransferTableItem = ({
isLoading={ isLoading } isLoading={ isLoading }
truncation="constant" truncation="constant"
tokenHash={ token.address } tokenHash={ token.address }
my="5px"
/> />
</Td> </Td>
{ (token.type === 'ERC-721' || token.type === 'ERC-1155') && ( { (token.type === 'ERC-721' || token.type === 'ERC-1155') && (
......
...@@ -5,11 +5,10 @@ import React from 'react'; ...@@ -5,11 +5,10 @@ import React from 'react';
import type { TokenInfo } from 'types/api/token'; import type { TokenInfo } from 'types/api/token';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet'; import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
import AddressLink from 'ui/shared/address/AddressLink';
import Tag from 'ui/shared/chakra/Tag'; import Tag from 'ui/shared/chakra/Tag';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import TokenEntity from 'ui/shared/entities/token/TokenEntity';
import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TokenLogo from 'ui/shared/TokenLogo';
type Props = { type Props = {
token: TokenInfo; token: TokenInfo;
...@@ -31,14 +30,10 @@ const TokensTableItem = ({ ...@@ -31,14 +30,10 @@ const TokensTableItem = ({
address, address,
exchange_rate: exchangeRate, exchange_rate: exchangeRate,
type, type,
name,
symbol,
holders, holders,
circulating_market_cap: marketCap, circulating_market_cap: marketCap,
} = token; } = token;
const tokenString = [ name, symbol && `(${ symbol })` ].filter(Boolean).join(' ');
return ( return (
<ListItemMobile rowGap={ 3 }> <ListItemMobile rowGap={ 3 }>
<Grid <Grid
...@@ -46,11 +41,16 @@ const TokensTableItem = ({ ...@@ -46,11 +41,16 @@ const TokensTableItem = ({
gridTemplateColumns="minmax(0, 1fr)" gridTemplateColumns="minmax(0, 1fr)"
> >
<GridItem display="flex"> <GridItem display="flex">
<Flex overflow="hidden" mr={ 3 } alignItems="center"> <TokenEntity
<TokenLogo data={ token } boxSize={ 6 } mr={ 2 } isLoading={ isLoading }/> token={ token }
<AddressLink fontSize="sm" fontWeight="700" hash={ address } type="token" alias={ tokenString } isLoading={ isLoading } mr={ 3 }/> isLoading={ isLoading }
<Tag flexShrink={ 0 } isLoading={ isLoading }>{ type }</Tag> jointSymbol
</Flex> noCopy
w="auto"
fontSize="sm"
fontWeight="700"
/>
<Tag flexShrink={ 0 } isLoading={ isLoading } ml={ 3 }>{ type }</Tag>
<Skeleton isLoaded={ !isLoading } fontSize="sm" ml="auto" color="text_secondary" minW="24px" textAlign="right" lineHeight={ 6 }> <Skeleton isLoaded={ !isLoading } fontSize="sm" ml="auto" color="text_secondary" minW="24px" textAlign="right" lineHeight={ 6 }>
<span>{ (page - 1) * PAGE_SIZE + index + 1 }</span> <span>{ (page - 1) * PAGE_SIZE + index + 1 }</span>
</Skeleton> </Skeleton>
......
...@@ -5,11 +5,10 @@ import React from 'react'; ...@@ -5,11 +5,10 @@ import React from 'react';
import type { TokenInfo } from 'types/api/token'; import type { TokenInfo } from 'types/api/token';
import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet'; import AddressAddToWallet from 'ui/shared/address/AddressAddToWallet';
import AddressLink from 'ui/shared/address/AddressLink';
import Tag from 'ui/shared/chakra/Tag'; import Tag from 'ui/shared/chakra/Tag';
import type { EntityProps as AddressEntityProps } from 'ui/shared/entities/address/AddressEntity'; import type { EntityProps as AddressEntityProps } from 'ui/shared/entities/address/AddressEntity';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import TokenLogo from 'ui/shared/TokenLogo'; import TokenEntity from 'ui/shared/entities/token/TokenEntity';
type Props = { type Props = {
token: TokenInfo; token: TokenInfo;
...@@ -31,13 +30,10 @@ const TokensTableItem = ({ ...@@ -31,13 +30,10 @@ const TokensTableItem = ({
address, address,
exchange_rate: exchangeRate, exchange_rate: exchangeRate,
type, type,
name,
symbol,
holders, holders,
circulating_market_cap: marketCap, circulating_market_cap: marketCap,
} = token; } = token;
const tokenString = [ name, symbol && `(${ symbol })` ].filter(Boolean).join(' ');
const tokenAddress: AddressEntityProps['address'] = { const tokenAddress: AddressEntityProps['address'] = {
hash: address, hash: address,
name: '', name: '',
...@@ -53,7 +49,7 @@ const TokensTableItem = ({ ...@@ -53,7 +49,7 @@ const TokensTableItem = ({
<Skeleton <Skeleton
isLoaded={ !isLoading } isLoaded={ !isLoading }
fontSize="sm" fontSize="sm"
lineHeight="24px" lineHeight="20px"
fontWeight={ 600 } fontWeight={ 600 }
mr={ 3 } mr={ 3 }
minW="28px" minW="28px"
...@@ -61,10 +57,14 @@ const TokensTableItem = ({ ...@@ -61,10 +57,14 @@ const TokensTableItem = ({
{ (page - 1) * PAGE_SIZE + index + 1 } { (page - 1) * PAGE_SIZE + index + 1 }
</Skeleton> </Skeleton>
<Box overflow="hidden"> <Box overflow="hidden">
<Flex alignItems="center"> <TokenEntity
<TokenLogo data={ token } boxSize={ 6 } mr={ 2 } isLoading={ isLoading }/> token={ token }
<AddressLink fontSize="sm" fontWeight="700" hash={ address } type="token" alias={ tokenString } isLoading={ isLoading }/> isLoading={ isLoading }
</Flex> jointSymbol
noCopy
fontSize="sm"
fontWeight="700"
/>
<Box ml={ 8 } mt={ 2 }> <Box ml={ 8 } mt={ 2 }>
<Flex> <Flex>
<AddressEntity <AddressEntity
......
...@@ -12,7 +12,7 @@ import { nbsp } from 'lib/html-entities'; ...@@ -12,7 +12,7 @@ import { nbsp } from 'lib/html-entities';
import Icon from 'ui/shared/chakra/Icon'; import Icon from 'ui/shared/chakra/Icon';
import CurrencyValue from 'ui/shared/CurrencyValue'; import CurrencyValue from 'ui/shared/CurrencyValue';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import TokenLogo from 'ui/shared/TokenLogo'; import * as TokenEntity from 'ui/shared/entities/token/TokenEntity';
const WatchListAddressItem = ({ item, isLoading }: { item: WatchlistAddress; isLoading?: boolean }) => { const WatchListAddressItem = ({ item, isLoading }: { item: WatchlistAddress; isLoading?: boolean }) => {
const infoItemsPaddingLeft = { base: 1, lg: 8 }; const infoItemsPaddingLeft = { base: 1, lg: 8 };
...@@ -20,6 +20,8 @@ const WatchListAddressItem = ({ item, isLoading }: { item: WatchlistAddress; isL ...@@ -20,6 +20,8 @@ const WatchListAddressItem = ({ item, isLoading }: { item: WatchlistAddress; isL
const nativeTokenData = React.useMemo(() => ({ const nativeTokenData = React.useMemo(() => ({
name: config.chain.currency.name || '', name: config.chain.currency.name || '',
icon_url: '', icon_url: '',
symbol: '',
address: '',
}), [ ]); }), [ ]);
const { usdBn: usdNative } = getCurrencyValue({ value: item.address_balance, accuracy: 2, accuracyUsd: 2, exchangeRate: item.exchange_rate }); const { usdBn: usdNative } = getCurrencyValue({ value: item.address_balance, accuracy: 2, accuracyUsd: 2, exchangeRate: item.exchange_rate });
...@@ -33,11 +35,8 @@ const WatchListAddressItem = ({ item, isLoading }: { item: WatchlistAddress; isL ...@@ -33,11 +35,8 @@ const WatchListAddressItem = ({ item, isLoading }: { item: WatchlistAddress; isL
py="2px" py="2px"
/> />
<Flex fontSize="sm" pl={ infoItemsPaddingLeft } flexWrap="wrap" alignItems="center" rowGap={ 1 }> <Flex fontSize="sm" pl={ infoItemsPaddingLeft } flexWrap="wrap" alignItems="center" rowGap={ 1 }>
<TokenLogo <TokenEntity.Icon
data={ nativeTokenData } token={ nativeTokenData }
boxSize={ 5 }
borderRadius="sm"
mr={ 2 }
isLoading={ isLoading } isLoading={ isLoading }
/> />
<Skeleton isLoaded={ !isLoading } whiteSpace="pre" display="inline-flex"> <Skeleton isLoaded={ !isLoading } whiteSpace="pre" display="inline-flex">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment