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:
parent
f4c255b7c7
commit
cfadc7592e
@ -1,6 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import contracts from 'eth-contract-metadata'
|
|
||||||
import { isEqual } from 'lodash'
|
import { isEqual } from 'lodash'
|
||||||
|
|
||||||
import TokenCell from '../token-cell'
|
import TokenCell from '../token-cell'
|
||||||
@ -10,15 +9,6 @@ import { useSelector } from 'react-redux'
|
|||||||
import { getAssetImages } from '../../../selectors'
|
import { getAssetImages } from '../../../selectors'
|
||||||
import { getTokens } from '../../../ducks/metamask/metamask'
|
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 }) {
|
export default function TokenList ({ onTokenClick }) {
|
||||||
const t = useI18nContext()
|
const t = useI18nContext()
|
||||||
const assetImages = useSelector(getAssetImages)
|
const assetImages = useSelector(getAssetImages)
|
||||||
|
@ -6,7 +6,7 @@ import InputAdornment from '@material-ui/core/InputAdornment'
|
|||||||
import TextField from '../../../components/ui/text-field'
|
import TextField from '../../../components/ui/text-field'
|
||||||
|
|
||||||
const contractList = Object.entries(contractMap)
|
const contractList = Object.entries(contractMap)
|
||||||
.map(([ _, tokenData]) => tokenData)
|
.map(([address, tokenData]) => Object.assign({}, tokenData, { address }))
|
||||||
.filter((tokenData) => Boolean(tokenData.erc20))
|
.filter((tokenData) => Boolean(tokenData.erc20))
|
||||||
|
|
||||||
const fuse = new Fuse(contractList, {
|
const fuse = new Fuse(contractList, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user