From 45a9f40aa614753e274275eaeb4dd6c0251dcf45 Mon Sep 17 00:00:00 2001 From: Paul Bouchon Date: Fri, 30 Nov 2018 11:52:00 -0500 Subject: [PATCH] bugfix: normalize contract addresss when fetching exchange rates (#5863) --- 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 a8936f13b..3f9482856 100644 --- a/app/scripts/controllers/token-rates.js +++ b/app/scripts/controllers/token-rates.js @@ -1,5 +1,6 @@ const ObservableStore = require('obs-store') const log = require('loglevel') +const normalizeAddress = require('eth-sig-util').normalize // By default, poll every 3 minutes const DEFAULT_INTERVAL = 180 * 1000 @@ -35,7 +36,8 @@ class TokenRatesController { const response = await fetch(`https://exchanges.balanc3.net/pie?${query}&autoConversion=true`) const { prices = [] } = await response.json() prices.forEach(({ pair, price }) => { - contractExchangeRates[pair.split('/')[0]] = typeof price === 'number' ? price : 0 + const address = pair.split('/')[0] + contractExchangeRates[normalizeAddress(address)] = typeof price === 'number' ? price : 0 }) } catch (error) { log.warn(`MetaMask - TokenRatesController exchange rate fetch failed.`, error)