aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/config-manager.js
diff options
context:
space:
mode:
authorFrankie <frankie.pangilinan@consensys.net>2016-08-19 02:06:32 +0800
committerFrankie <frankie.pangilinan@consensys.net>2016-08-19 02:06:32 +0800
commitefa61f2cf892eb1383fcfacd60d906e76dbaa757 (patch)
tree4e19f1abbadc02f861f0b54027954bf9cb6b5fac /app/scripts/lib/config-manager.js
parent752d16f6c072b0dd54eb245209881a25ff06cb8e (diff)
parent90d6bec3ed51ba4b2d4696132642a4d97712dec9 (diff)
downloadtangerine-wallet-browser-efa61f2cf892eb1383fcfacd60d906e76dbaa757.tar
tangerine-wallet-browser-efa61f2cf892eb1383fcfacd60d906e76dbaa757.tar.gz
tangerine-wallet-browser-efa61f2cf892eb1383fcfacd60d906e76dbaa757.tar.bz2
tangerine-wallet-browser-efa61f2cf892eb1383fcfacd60d906e76dbaa757.tar.lz
tangerine-wallet-browser-efa61f2cf892eb1383fcfacd60d906e76dbaa757.tar.xz
tangerine-wallet-browser-efa61f2cf892eb1383fcfacd60d906e76dbaa757.tar.zst
tangerine-wallet-browser-efa61f2cf892eb1383fcfacd60d906e76dbaa757.zip
Merge branch 'master' into shapeshiftTx
Diffstat (limited to 'app/scripts/lib/config-manager.js')
-rw-r--r--app/scripts/lib/config-manager.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index 8e59d02f3..d6d10c8f2 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -1,6 +1,7 @@
const Migrator = require('pojo-migrator')
const MetamaskConfig = require('../config.js')
const migrations = require('./migrations')
+const rp = require('request-promise')
const TESTNET_RPC = MetamaskConfig.network.testnet
const MAINNET_RPC = MetamaskConfig.network.mainnet
@@ -270,6 +271,53 @@ ConfigManager.prototype.getConfirmed = function () {
return ('isConfirmed' in data) && data.isConfirmed
}
+ConfigManager.prototype.setCurrentFiat = function (currency) {
+ var data = this.getData()
+ data.fiatCurrency = currency
+ this.setData(data)
+}
+
+ConfigManager.prototype.getCurrentFiat = function () {
+ var data = this.getData()
+ return ('fiatCurrency' in data) && data.fiatCurrency
+}
+
+ConfigManager.prototype.updateConversionRate = function () {
+ 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')
+ })
+}
+
+ConfigManager.prototype.setConversionPrice = function(price) {
+ var data = this.getData()
+ data.conversionRate = Number(price)
+ this.setData(data)
+}
+
+ConfigManager.prototype.setConversionDate = function (datestring) {
+ var data = this.getData()
+ data.conversionDate = datestring
+ this.setData(data)
+}
+
+ConfigManager.prototype.getConversionRate = function () {
+ var data = this.getData()
+ return (('conversionRate' in data) && data.conversionRate) || 0
+}
+
+ConfigManager.prototype.getConversionDate = function () {
+ var data = this.getData()
+ return (('conversionDate' in data) && data.conversionDate) || 'N/A'
+}
+
ConfigManager.prototype.setShouldntShowWarning = function () {
var data = this.getData()
if (data.isEthConfirmed) {