From 67f3fc1e7983491421840019bd7fec9c305ef123 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Fri, 26 Apr 2019 16:47:45 -0700 Subject: [PATCH] Include token checksum address in prices lookup for token rates --- app/scripts/controllers/token-rates.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/token-rates.js b/app/scripts/controllers/token-rates.js index 4e396bb59327..6b6265dbafa7 100644 --- a/app/scripts/controllers/token-rates.js +++ b/app/scripts/controllers/token-rates.js @@ -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) {