utils#isTokenOnList TypeScript Examples

The following examples show how to use utils#isTokenOnList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CurrencyList.tsx    From glide-frontend with GNU General Public License v3.0 5 votes vote down vote up
function CurrencyRow({
  origin,
  currency,
  onSelect,
  isSelected,
  otherSelected,
  style,
}: {
  origin: number
  currency: Currency
  onSelect: () => void
  isSelected: boolean
  otherSelected: boolean
  style: CSSProperties
}) {
  const { t } = useTranslation()
  const { account } = useActiveWeb3React()
  const key = currencyKey(currency)
  const selectedTokenList = useCombinedActiveList()
  const isOnSelectedList = isTokenOnList(selectedTokenList, currency)
  const customAdded = useIsUserAddedToken(currency)
  const balance = useCurrencyBalance(account ?? undefined, currency)

  const token = currency ? Object.prototype.hasOwnProperty.call(currency, 'address') : undefined

  // only show add or remove buttons if not on selected list
  return (
    <MenuItem
      style={style}
      className={`token-item-${key}`}
      onClick={() => (isSelected ? null : onSelect())}
      disabled={isSelected}
      selected={otherSelected}
    >
      <CurrencyLogo currency={currency} size="24px" style={{ marginRight: '8px' }} chain={origin} />
      <Column>
        {/* <Text bold>{token ? currency.symbol : currency.symbol === 'ELA' && chainId === 1 ? 'ETH' : currency.symbol === 'ELA' && chainId === 128 ? 'HT' : currency.symbol}</Text> */}
        <Text bold>
          {token
            ? currency.symbol
            : origin === 20
            ? 'ELA'
            : origin === 1
            ? 'ETH'
            : origin === 128
            ? 'HT'
            : origin === 56 && 'BNB'}
        </Text>
        {/* <Text color="textSubtle" small ellipsis maxWidth="200px">
          {!isOnSelectedList && customAdded && 'Added by user •'} {token ? currency.name : currency.symbol === 'ELA' && chainId === 1 ? 'Ethereum' : currency.symbol === 'ELA' && chainId === 128 ? 'Huobi Token' : currency.symbol === 'ELA' && chainId === 20 ? 'Elastos' : currency.name }
        </Text> */}
        <Text color="textSubtle" small ellipsis maxWidth="200px">
          {!isOnSelectedList && customAdded && t('Added by user')}
          {'• '}
          {token
            ? currency.name
            : origin === 20
            ? 'Elastos'
            : origin === 1
            ? 'Ethereum'
            : origin === 128
            ? 'Huobi Token'
            : origin === 56 && 'Binance Coin'}
        </Text>
      </Column>
      <RowFixed style={{ justifySelf: 'flex-end' }}>
        {balance ? <Balance balance={balance} /> : account ? <CircleLoader /> : null}
      </RowFixed>
    </MenuItem>
  )
}