2022-05-09 19:47:06 +02:00
|
|
|
import React from 'react';
|
2022-03-25 20:29:16 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2022-05-09 19:47:06 +02:00
|
|
|
|
|
|
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
2022-03-25 20:29:16 +01:00
|
|
|
import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard';
|
|
|
|
|
|
|
|
import Box from '../../../ui/box';
|
|
|
|
import Button from '../../../ui/button';
|
|
|
|
import Tooltip from '../../../ui/tooltip';
|
|
|
|
|
|
|
|
import {
|
|
|
|
DISPLAY,
|
2023-02-02 21:15:26 +01:00
|
|
|
TextColor,
|
2023-04-24 11:19:35 +02:00
|
|
|
TextVariant,
|
2022-03-25 20:29:16 +01:00
|
|
|
} from '../../../../helpers/constants/design-system';
|
|
|
|
|
|
|
|
import { shortenAddress } from '../../../../helpers/utils/util';
|
2023-04-24 11:19:35 +02:00
|
|
|
import { Text } from '../../../component-library';
|
2022-03-25 20:29:16 +01:00
|
|
|
|
2022-05-09 19:47:06 +02:00
|
|
|
const DetectedTokenAddress = ({ tokenAddress }) => {
|
|
|
|
const t = useI18nContext();
|
2022-03-25 20:29:16 +01:00
|
|
|
const [copied, handleCopy] = useCopyToClipboard();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box display={DISPLAY.INLINE_FLEX} className="detected-token-address">
|
2023-04-24 11:19:35 +02:00
|
|
|
<Text variant={TextVariant.bodySm} as="h6" color={TextColor.textDefault}>
|
2022-03-25 20:29:16 +01:00
|
|
|
{`${t('tokenAddress')}:`}
|
2023-04-24 11:19:35 +02:00
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
variant={TextVariant.bodySm}
|
|
|
|
as="h6"
|
2023-02-02 21:15:26 +01:00
|
|
|
color={TextColor.primaryDefault}
|
2022-07-20 22:47:51 +02:00
|
|
|
marginLeft={2}
|
|
|
|
marginRight={2}
|
2022-03-25 20:29:16 +01:00
|
|
|
>
|
2022-05-09 19:47:06 +02:00
|
|
|
{shortenAddress(tokenAddress)}
|
2023-04-24 11:19:35 +02:00
|
|
|
</Text>
|
2022-03-25 20:29:16 +01:00
|
|
|
<Tooltip
|
|
|
|
position="bottom"
|
|
|
|
title={copied ? t('copiedExclamation') : t('copyToClipboard')}
|
|
|
|
>
|
|
|
|
<Button
|
|
|
|
type="link"
|
|
|
|
className="detected-token-address__copy-link"
|
|
|
|
onClick={() => {
|
2022-05-09 19:47:06 +02:00
|
|
|
handleCopy(tokenAddress);
|
2022-03-25 20:29:16 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<i className="fa fa-copy" />
|
|
|
|
</Button>
|
|
|
|
</Tooltip>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
DetectedTokenAddress.propTypes = {
|
2022-05-09 19:47:06 +02:00
|
|
|
tokenAddress: PropTypes.string,
|
2022-03-25 20:29:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default DetectedTokenAddress;
|