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

Include token checksum address in prices lookup for token rates (#6526)

This commit is contained in:
Thomas Huang 2019-04-30 09:49:58 -07:00 committed by Whymarrh Whitby
parent 4fea9d0cc2
commit c7492f4f54

View File

@ -1,6 +1,8 @@
const ObservableStore = require('obs-store')
const log = require('loglevel')
const normalizeAddress = require('eth-sig-util').normalize
const ethUtil = require('ethereumjs-util')
// By default, poll every 3 minutes
const DEFAULT_INTERVAL = 180 * 1000
@ -36,7 +38,7 @@ class TokenRatesController {
const response = await fetch(`https://api.coingecko.com/api/v3/simple/token_price/ethereum?${query}`)
const prices = await response.json()
this._tokens.forEach(token => {
const price = prices[token.address.toLowerCase()]
const price = prices[token.address.toLowerCase()] || prices[ethUtil.toChecksumAddress(token.address)]
contractExchangeRates[normalizeAddress(token.address)] = price ? price[nativeCurrency] : 0
})
} catch (error) {