import { colors, EtherscanLinkSuffixes, utils as sharedUtils } from '@0xproject/react-shared'; import * as _ from 'lodash'; import * as React from 'react'; import ReactTooltip = require('react-tooltip'); import { EthereumAddress } from 'ts/components/ui/ethereum_address'; import { Identicon } from 'ts/components/ui/identicon'; import { utils } from 'ts/utils/utils'; const IMAGE_DIMENSION = 100; const IDENTICON_DIAMETER = 95; interface PartyProps { label: string; address: string; networkId: number; alternativeImage?: string; identiconDiameter?: number; identiconStyle?: React.CSSProperties; isInTokenRegistry?: boolean; hasUniqueNameAndSymbol?: boolean; } interface PartyState {} export class Party extends React.Component { public static defaultProps: Partial = { identiconStyle: {}, identiconDiameter: IDENTICON_DIAMETER, }; public render() { const label = this.props.label; const address = this.props.address; const identiconDiameter = this.props.identiconDiameter; const emptyIdenticonStyles = { width: identiconDiameter, height: identiconDiameter, backgroundColor: 'lightgray', marginTop: 13, marginBottom: 10, }; const tokenImageStyle = { width: IMAGE_DIMENSION, height: IMAGE_DIMENSION, }; const etherscanLinkIfExists = sharedUtils.getEtherScanLinkIfExists( this.props.address, this.props.networkId, EtherscanLinkSuffixes.Address, ); const isRegistered = this.props.isInTokenRegistry; const registeredTooltipId = `${this.props.address}-${isRegistered}-registeredTooltip`; const uniqueNameAndSymbolTooltipId = `${this.props.address}-${isRegistered}-uniqueTooltip`; return (
{label}
{_.isEmpty(address) ? (
) : ( {isRegistered && !_.isUndefined(this.props.alternativeImage) ? ( ) : (
)}
)}
{!_.isUndefined(this.props.isInTokenRegistry) && (
{' '} {isRegistered ? 'Registered' : 'Unregistered'} token {isRegistered ? (
This token address was found in the token registry
smart contract and is therefore believed to be a
legitimate token.
) : (
This token is not included in the token registry
smart contract. We cannot guarantee the legitimacy
of this token. Make sure to verify its address on Etherscan.
)}
)} {!_.isUndefined(this.props.hasUniqueNameAndSymbol) && !this.props.hasUniqueNameAndSymbol && (
{' '} Suspicious token This token shares it's name, symbol or both with
a token in the 0x Token Registry but it has a different
smart contract address. This is most likely a scam token!
)}
); } }