2022-04-02 23:33:35 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2022-09-15 17:23:18 +02:00
|
|
|
import { useSelector } from 'react-redux';
|
2022-04-02 23:33:35 +02:00
|
|
|
|
2023-07-12 18:42:24 +02:00
|
|
|
import { Box } from '../../../component-library';
|
2022-04-02 23:33:35 +02:00
|
|
|
import Identicon from '../../../ui/identicon';
|
|
|
|
import DetectedTokenValues from '../detected-token-values/detected-token-values';
|
|
|
|
import DetectedTokenAddress from '../detected-token-address/detected-token-address';
|
|
|
|
import DetectedTokenAggregators from '../detected-token-aggregators/detected-token-aggregators';
|
2023-07-12 18:42:24 +02:00
|
|
|
import { Display } from '../../../../helpers/constants/design-system';
|
2022-09-15 17:23:18 +02:00
|
|
|
import { getTokenList } from '../../../../selectors';
|
2022-04-02 23:33:35 +02:00
|
|
|
|
2022-05-09 19:47:06 +02:00
|
|
|
const DetectedTokenDetails = ({
|
|
|
|
token,
|
|
|
|
handleTokenSelection,
|
|
|
|
tokensListDetected,
|
|
|
|
}) => {
|
2022-09-15 17:23:18 +02:00
|
|
|
const tokenList = useSelector(getTokenList);
|
|
|
|
const tokenData = tokenList[token.address?.toLowerCase()];
|
|
|
|
|
2022-04-02 23:33:35 +02:00
|
|
|
return (
|
2022-05-09 19:47:06 +02:00
|
|
|
<Box
|
2023-07-12 18:42:24 +02:00
|
|
|
display={Display.Flex}
|
2022-05-09 19:47:06 +02:00
|
|
|
className="detected-token-details"
|
|
|
|
marginBottom={4}
|
|
|
|
>
|
2022-04-02 23:33:35 +02:00
|
|
|
<Identicon
|
|
|
|
className="detected-token-details__identicon"
|
2022-05-09 19:47:06 +02:00
|
|
|
address={token.address}
|
2022-04-02 23:33:35 +02:00
|
|
|
diameter={40}
|
|
|
|
/>
|
|
|
|
<Box
|
2023-07-12 18:42:24 +02:00
|
|
|
display={Display.Grid}
|
2022-04-02 23:33:35 +02:00
|
|
|
marginLeft={2}
|
|
|
|
className="detected-token-details__data"
|
|
|
|
>
|
2022-05-09 19:47:06 +02:00
|
|
|
<DetectedTokenValues
|
|
|
|
token={token}
|
|
|
|
handleTokenSelection={handleTokenSelection}
|
|
|
|
tokensListDetected={tokensListDetected}
|
|
|
|
/>
|
|
|
|
<DetectedTokenAddress tokenAddress={token.address} />
|
2022-09-15 17:23:18 +02:00
|
|
|
{tokenData?.aggregators.length > 0 && (
|
|
|
|
<DetectedTokenAggregators aggregators={tokenData?.aggregators} />
|
2022-09-14 17:34:46 +02:00
|
|
|
)}
|
2022-04-02 23:33:35 +02:00
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
DetectedTokenDetails.propTypes = {
|
2022-05-09 19:47:06 +02:00
|
|
|
token: PropTypes.shape({
|
|
|
|
address: PropTypes.string.isRequired,
|
|
|
|
decimals: PropTypes.number,
|
|
|
|
symbol: PropTypes.string,
|
|
|
|
iconUrl: PropTypes.string,
|
|
|
|
aggregators: PropTypes.array,
|
|
|
|
}),
|
|
|
|
handleTokenSelection: PropTypes.func.isRequired,
|
|
|
|
tokensListDetected: PropTypes.object,
|
2022-04-02 23:33:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default DetectedTokenDetails;
|