import React from 'react'; import PropTypes from 'prop-types'; import { getAccountLink } from '@metamask/etherscan-link'; import { useSelector } from 'react-redux'; import classnames from 'classnames'; import Box from '../../../ui/box'; import IconCopy from '../../../ui/icon/icon-copy'; import IconBlockExplorer from '../../../ui/icon/icon-block-explorer'; import Button from '../../../ui/button/button.component'; import Tooltip from '../../../ui/tooltip/tooltip'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import Identicon from '../../../ui/identicon'; import { ellipsify } from '../../../../pages/send/send.utils'; import Popover from '../../../ui/popover'; import Typography from '../../../ui/typography'; import { FONT_WEIGHT, TYPOGRAPHY, DISPLAY, COLORS, JUSTIFY_CONTENT, SIZES, BORDER_STYLE, } from '../../../../helpers/constants/design-system'; import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard'; import UrlIcon from '../../../ui/url-icon/url-icon'; import { getAddressBookEntry } from '../../../../selectors'; export default function ContractDetailsModal({ onClose, tokenName, tokenAddress, toAddress, chainId, rpcPrefs, origin, siteImage, }) { const t = useI18nContext(); const [copiedTokenAddress, handleCopyTokenAddress] = useCopyToClipboard(); const [copiedToAddress, handleCopyToAddress] = useCopyToClipboard(); const addressBookEntry = useSelector((state) => ({ data: getAddressBookEntry(state, toAddress), })); return ( {t('contractTitle')} {t('contractDescription')} {t('contractToken')} {tokenName || ellipsify(tokenAddress)} {tokenName && ( {ellipsify(tokenAddress)} )} {t('contractRequestingSpendingCap')} {addressBookEntry?.data?.name || ellipsify(toAddress)} {addressBookEntry?.data?.name && ( {ellipsify(toAddress)} )} ); } ContractDetailsModal.propTypes = { /** * Function that should close the modal */ onClose: PropTypes.func, /** * Name of the token that is waiting to be allowed */ tokenName: PropTypes.string, /** * Address of the token that is waiting to be allowed */ tokenAddress: PropTypes.string, /** * Contract address requesting spending cap */ toAddress: PropTypes.string, /** * Current network chainId */ chainId: PropTypes.string, /** * RPC prefs of the current network */ rpcPrefs: PropTypes.object, /** * Dapp URL */ origin: PropTypes.string, /** * Dapp image */ siteImage: PropTypes.string, };