Skip to content

Commit

Permalink
Include token checksum address in prices lookup for token rates
Browse files Browse the repository at this point in the history
  • Loading branch information
tmashuang committed Apr 26, 2019
1 parent 0dac3eb commit 67f3fc1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/scripts/controllers/token-rates.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 67f3fc1

Please sign in to comment.