mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Filter non-ERC-20 assets during mobile sync (#7035)
This commit is contained in:
parent
e47448362d
commit
6e081eb17c
@ -55,6 +55,7 @@ const HW_WALLETS_KEYRINGS = [TrezorKeyring.type, LedgerBridgeKeyring.type]
|
||||
const EthQuery = require('eth-query')
|
||||
const ethUtil = require('ethereumjs-util')
|
||||
const sigUtil = require('eth-sig-util')
|
||||
const contractMap = require('eth-contract-metadata')
|
||||
const {
|
||||
AddressBookController,
|
||||
CurrencyRateController,
|
||||
@ -63,7 +64,6 @@ const {
|
||||
} = require('gaba')
|
||||
const backEndMetaMetricsEvent = require('./lib/backend-metametrics')
|
||||
|
||||
|
||||
module.exports = class MetamaskController extends EventEmitter {
|
||||
|
||||
/**
|
||||
@ -650,8 +650,24 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
tokens,
|
||||
} = this.preferencesController.store.getState()
|
||||
|
||||
// Filter ERC20 tokens
|
||||
const filteredAccountTokens = {}
|
||||
Object.keys(accountTokens).forEach(address => {
|
||||
const checksummedAddress = ethUtil.toChecksumAddress(address)
|
||||
filteredAccountTokens[checksummedAddress] = {}
|
||||
Object.keys(accountTokens[address]).forEach(
|
||||
networkType => (filteredAccountTokens[checksummedAddress][networkType] = networkType !== 'mainnet' ?
|
||||
accountTokens[address][networkType] :
|
||||
accountTokens[address][networkType].filter(({ address }) => {
|
||||
const tokenAddress = ethUtil.toChecksumAddress(address)
|
||||
return contractMap[tokenAddress] ? contractMap[tokenAddress].erc20 : true
|
||||
})
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
const preferences = {
|
||||
accountTokens,
|
||||
accountTokens: filteredAccountTokens,
|
||||
currentLocale,
|
||||
frequentRpcList,
|
||||
identities,
|
||||
|
Loading…
Reference in New Issue
Block a user