1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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.
This commit is contained in:
Mark Stacey 2020-06-10 13:27:35 -03:00 committed by GitHub
parent f4c255b7c7
commit cfadc7592e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 11 deletions

View File

@ -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)

View File

@ -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, {