Skip to content

Commit

Permalink
bugfix: normalize contract addresss when fetching exchange rates (#5863)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpshr authored Nov 30, 2018
1 parent c7233e2 commit 45a9f40
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,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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 45a9f40

Please sign in to comment.