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

bugfix: normalize contract addresss when fetching exchange rates (#5863)

This commit is contained in:
Paul Bouchon 2018-11-30 11:52:00 -05:00 committed by GitHub
parent c7233e2cc7
commit 45a9f40aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)