aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-07-21 23:47:03 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-07-21 23:47:03 +0800
commitaac810b1eb3414c907010c30537b7014f303d20f (patch)
treebe963fe019c52e9f317ddafbdce20ee476d595e0 /app
parent5b895c2a229555f127e1bd4b6f5c2973a37537cc (diff)
downloadtangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.gz
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.bz2
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.lz
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.xz
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.zst
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.zip
Progress on config manager. Plus tests.
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/config-manager.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index caaae8a75..a5b319325 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,3 +271,29 @@ 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.setConversionRate = function () {
+ var data = this.getData()
+ return rp(`https://www.cryptonator.com/api/ticker/eth-${data.fiatCurrency}`)
+ .then(function (response) {
+ data.conversionRate = Number(JSON.parse(response).ticker.price)
+ this.setData(data)
+ }.bind(this)).catch(function (err) {
+ console.log('Error in conversion.', err)
+ })
+}
+
+ConfigManager.prototype.getConversionRate = function () {
+ var data = this.getData()
+ return ('conversionRate' in data) && data.conversionRate
+}