Avoid mutating module export (#8775)

The `eth-contracts-metadata` export was mutated in `token-list.js` to
add the token address to the contract metadata, and this was taken
advantage of in the token search component.

Instead, the address is now added to a copy of the token metadata in
the one place it's used. The module export is no longer mutated, and
the unused `defaultTokens` variable in `token-list.js` has been
removed.
feature/default_network_editable
Mark Stacey 4 years ago committed by GitHub
parent f4c255b7c7
commit cfadc7592e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      ui/app/components/app/token-list/token-list.js
  2. 2
      ui/app/pages/add-token/token-search/token-search.component.js

@ -1,6 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'
import contracts from 'eth-contract-metadata'
import { isEqual } from 'lodash'
import TokenCell from '../token-cell'
@ -10,15 +9,6 @@ import { useSelector } from 'react-redux'
import { getAssetImages } from '../../../selectors'
import { getTokens } from '../../../ducks/metamask/metamask'
const defaultTokens = []
for (const address in contracts) {
const contract = contracts[address]
if (contract.erc20) {
contract.address = address
defaultTokens.push(contract)
}
}
export default function TokenList ({ onTokenClick }) {
const t = useI18nContext()
const assetImages = useSelector(getAssetImages)

@ -6,7 +6,7 @@ import InputAdornment from '@material-ui/core/InputAdornment'
import TextField from '../../../components/ui/text-field'
const contractList = Object.entries(contractMap)
.map(([ _, tokenData]) => tokenData)
.map(([address, tokenData]) => Object.assign({}, tokenData, { address }))
.filter((tokenData) => Boolean(tokenData.erc20))
const fuse = new Fuse(contractList, {

Loading…
Cancel
Save