mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-30 16:18:07 +01:00
e10ddbe3a3
* add erc-721 token detection and flag to disable sending * addressing feedback * remove redundant provider instantiation * fix issue caused by unprotected destructuring * add tests and documentation * move add isERC721 flag to useTokenTracker hook * Update and unit tests * use memoizedTokens in useTokenTracker Co-authored-by: Dan Miller <danjm.com@gmail.com>
73 lines
1.8 KiB
JavaScript
73 lines
1.8 KiB
JavaScript
import classnames from 'classnames';
|
|
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
import { useSelector } from 'react-redux';
|
|
import AssetListItem from '../asset-list-item';
|
|
import { getSelectedAddress } from '../../../selectors';
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount';
|
|
|
|
export default function TokenCell({
|
|
address,
|
|
decimals,
|
|
balanceError,
|
|
symbol,
|
|
string,
|
|
image,
|
|
onClick,
|
|
isERC721,
|
|
}) {
|
|
const userAddress = useSelector(getSelectedAddress);
|
|
const t = useI18nContext();
|
|
|
|
const formattedFiat = useTokenFiatAmount(address, string, symbol);
|
|
|
|
const warning = balanceError ? (
|
|
<span>
|
|
{t('troubleTokenBalances')}
|
|
<a
|
|
href={`https://ethplorer.io/address/${userAddress}`}
|
|
rel="noopener noreferrer"
|
|
target="_blank"
|
|
onClick={(event) => event.stopPropagation()}
|
|
style={{ color: '#F7861C' }}
|
|
>
|
|
{t('here')}
|
|
</a>
|
|
</span>
|
|
) : null;
|
|
|
|
return (
|
|
<AssetListItem
|
|
className={classnames('token-cell', {
|
|
'token-cell--outdated': Boolean(balanceError),
|
|
})}
|
|
iconClassName="token-cell__icon"
|
|
onClick={onClick.bind(null, address)}
|
|
tokenAddress={address}
|
|
tokenImage={image}
|
|
tokenSymbol={symbol}
|
|
tokenDecimals={decimals}
|
|
warning={warning}
|
|
primary={`${string || 0}`}
|
|
secondary={formattedFiat}
|
|
isERC721={isERC721}
|
|
/>
|
|
);
|
|
}
|
|
|
|
TokenCell.propTypes = {
|
|
address: PropTypes.string,
|
|
balanceError: PropTypes.object,
|
|
symbol: PropTypes.string,
|
|
decimals: PropTypes.number,
|
|
string: PropTypes.string,
|
|
image: PropTypes.string,
|
|
onClick: PropTypes.func.isRequired,
|
|
isERC721: PropTypes.bool,
|
|
};
|
|
|
|
TokenCell.defaultProps = {
|
|
balanceError: null,
|
|
};
|