|
|
|
@ -288,21 +288,32 @@ ConfigManager.prototype.getCurrentFiat = function () { |
|
|
|
|
return ('fiatCurrency' in data) && data.fiatCurrency |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ConfigManager.prototype.updateConversionRate = function () { |
|
|
|
|
ConfigManager.prototype.updateConversionRate = function (mock = false, mockCurrency = 'USD') { |
|
|
|
|
var data = this.getData() |
|
|
|
|
return rp(`https://www.cryptonator.com/api/ticker/eth-${data.fiatCurrency}`) |
|
|
|
|
.then((response) => { |
|
|
|
|
const parsedResponse = JSON.parse(response) |
|
|
|
|
this.setConversionPrice(parsedResponse.ticker.price) |
|
|
|
|
this.setConversionDate(parsedResponse.timestamp) |
|
|
|
|
}).catch((err) => { |
|
|
|
|
console.error('Error in conversion.', err) |
|
|
|
|
this.setConversionPrice(0) |
|
|
|
|
this.setConversionDate('N/A') |
|
|
|
|
}) |
|
|
|
|
if (!mock) { |
|
|
|
|
return rp(`https://www.cryptonator.com/api/ticker/eth-${data.fiatCurrency}`) |
|
|
|
|
.then((response) => { |
|
|
|
|
const parsedResponse = JSON.parse(response) |
|
|
|
|
this.setConversionPrice(parsedResponse.ticker.price) |
|
|
|
|
this.setConversionDate(parsedResponse.timestamp) |
|
|
|
|
}).catch((err) => { |
|
|
|
|
console.error('Error in conversion.', err) |
|
|
|
|
this.setConversionPrice(0) |
|
|
|
|
this.setConversionDate('N/A') |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
return new Promise(function(resolve, reject) { resolve() }).then((response) => { |
|
|
|
|
this.setConversionPrice('11.01') |
|
|
|
|
this.setConversionDate(1472065924) |
|
|
|
|
}).catch((err) => { |
|
|
|
|
console.error('Error in conversion.', err) |
|
|
|
|
this.setConversionPrice('11.01') |
|
|
|
|
this.setConversionDate(1472065924) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ConfigManager.prototype.setConversionPrice = function(price) { |
|
|
|
|
ConfigManager.prototype.setConversionPrice = function (price) { |
|
|
|
|
var data = this.getData() |
|
|
|
|
data.conversionRate = Number(price) |
|
|
|
|
this.setData(data) |
|
|
|
@ -372,4 +383,3 @@ ConfigManager.prototype.createShapeShiftTx = function (depositAddress, depositTy |
|
|
|
|
} |
|
|
|
|
this.setData(data) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|