|
|
|
@ -44,14 +44,15 @@ class CurrencyController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async updateConversionRate () { |
|
|
|
|
let currentCurrency |
|
|
|
|
try { |
|
|
|
|
const currentCurrency = this.getCurrentCurrency() |
|
|
|
|
currentCurrency = this.getCurrentCurrency() |
|
|
|
|
const response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) |
|
|
|
|
const parsedResponse = await response.json() |
|
|
|
|
this.setConversionRate(Number(parsedResponse.bid)) |
|
|
|
|
this.setConversionDate(Number(parsedResponse.timestamp)) |
|
|
|
|
} catch (err) { |
|
|
|
|
console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) |
|
|
|
|
log.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) |
|
|
|
|
this.setConversionRate(0) |
|
|
|
|
this.setConversionDate('N/A') |
|
|
|
|
} |
|
|
|
|