2022-06-28 15:11:19 +02:00
|
|
|
import React, { useContext } from 'react';
|
2022-03-25 20:29:16 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2022-06-28 15:11:19 +02:00
|
|
|
import { I18nContext } from '../../../../contexts/i18n';
|
2022-03-25 20:29:16 +01:00
|
|
|
import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard';
|
|
|
|
|
|
|
|
import Box from '../../../ui/box';
|
|
|
|
import Button from '../../../ui/button';
|
|
|
|
import Typography from '../../../ui/typography';
|
|
|
|
import Tooltip from '../../../ui/tooltip';
|
|
|
|
|
|
|
|
import {
|
|
|
|
COLORS,
|
|
|
|
DISPLAY,
|
|
|
|
TYPOGRAPHY,
|
|
|
|
} from '../../../../helpers/constants/design-system';
|
|
|
|
|
|
|
|
import { shortenAddress } from '../../../../helpers/utils/util';
|
|
|
|
|
2022-06-28 15:11:19 +02:00
|
|
|
const DetectedTokenAddress = ({ address }) => {
|
|
|
|
const t = useContext(I18nContext);
|
2022-03-25 20:29:16 +01:00
|
|
|
const [copied, handleCopy] = useCopyToClipboard();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box display={DISPLAY.INLINE_FLEX} className="detected-token-address">
|
|
|
|
<Typography variant={TYPOGRAPHY.H7} color={COLORS.TEXT_DEFAULT}>
|
|
|
|
{`${t('tokenAddress')}:`}
|
|
|
|
</Typography>
|
|
|
|
<Typography
|
|
|
|
variant={TYPOGRAPHY.H7}
|
|
|
|
color={COLORS.PRIMARY_DEFAULT}
|
|
|
|
margin={[1, 2]}
|
|
|
|
>
|
2022-06-28 15:11:19 +02:00
|
|
|
{shortenAddress(address)}
|
2022-03-25 20:29:16 +01:00
|
|
|
</Typography>
|
|
|
|
<Tooltip
|
|
|
|
position="bottom"
|
|
|
|
title={copied ? t('copiedExclamation') : t('copyToClipboard')}
|
|
|
|
>
|
|
|
|
<Button
|
|
|
|
type="link"
|
|
|
|
className="detected-token-address__copy-link"
|
|
|
|
onClick={() => {
|
2022-06-28 15:11:19 +02:00
|
|
|
handleCopy(address);
|
2022-03-25 20:29:16 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<i className="fa fa-copy" />
|
|
|
|
</Button>
|
|
|
|
</Tooltip>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
DetectedTokenAddress.propTypes = {
|
2022-06-28 15:11:19 +02:00
|
|
|
address: PropTypes.string,
|
2022-03-25 20:29:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default DetectedTokenAddress;
|