From 491b9cddc5fe1a7d0899d29c9a53aa71f04b9b28 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 21 Jul 2016 09:30:58 -0700 Subject: Add fiat actions to metamask controllere and actions. --- app/scripts/metamask-controller.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 63970799d..bcf5203fe 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -39,6 +39,7 @@ module.exports = class MetamaskController { setProviderType: this.setProviderType.bind(this), useEtherscanProvider: this.useEtherscanProvider.bind(this), agreeToDisclaimer: this.agreeToDisclaimer.bind(this), + setCurrentFiat: this.setCurrentFiat.bind(this), // forward directly to idStore createNewVault: idStore.createNewVault.bind(idStore), recoverFromSeed: idStore.recoverFromSeed.bind(idStore), @@ -236,6 +237,15 @@ module.exports = class MetamaskController { } } + setCurrentFiat (fiat, cb) { + try { + this.configManager.setCurrentFiat(fiat) + this.configManager.setConversionRate() + } catch (e) { + cb(e) + } + } + // called from popup setRpcTarget (rpcTarget) { this.configManager.setRpcTarget(rpcTarget) -- cgit v1.2.3 From 4a9d5b1c258912acedd6f1e89fb632526d9c910b Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 21 Jul 2016 10:15:34 -0700 Subject: Add data field to pass up parameters up to reducer. --- app/scripts/metamask-controller.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index bcf5203fe..1b3b69932 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -241,8 +241,13 @@ module.exports = class MetamaskController { try { this.configManager.setCurrentFiat(fiat) this.configManager.setConversionRate() + const data = { + conversionRate: this.configManager.getConversionRate, + currentFiat: this.configManager.getCurrentFiat, + } + cb(data) } catch (e) { - cb(e) + cb(null,e) } } -- cgit v1.2.3 From 716e65424d2ba490a384bfc1f0591685eb2867fa Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 21 Jul 2016 14:08:26 -0700 Subject: Add date access throughout the data flow. --- app/scripts/metamask-controller.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 7bf8fd5ea..99769fa3c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -245,6 +245,7 @@ module.exports = class MetamaskController { const data = { conversionRate: this.configManager.getConversionRate, currentFiat: this.configManager.getCurrentFiat, + conversionDate: this.configManager.getConversionDate, } cb(data) } catch (e) { -- cgit v1.2.3 From a612fcee64422ca43c470d7832a263f5e490611d Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 21 Jul 2016 16:44:50 -0700 Subject: Change function names. Add interval polling for api. Refactor functions. --- app/scripts/metamask-controller.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 99769fa3c..e121fad6a 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -21,6 +21,7 @@ module.exports = class MetamaskController { this.idStore.setStore(this.ethStore) this.messageManager = messageManager this.publicConfigStore = this.initPublicConfigStore() + this.scheduleConversionInterval() } getState () { @@ -241,7 +242,8 @@ module.exports = class MetamaskController { setCurrentFiat (fiat, cb) { try { this.configManager.setCurrentFiat(fiat) - this.configManager.setConversionRate() + this.configManager.updateConversionRate() + this.scheduleConversionInterval() const data = { conversionRate: this.configManager.getConversionRate, currentFiat: this.configManager.getCurrentFiat, @@ -253,6 +255,16 @@ module.exports = class MetamaskController { } } + scheduleConversionInterval () { + if (this.conversionInterval) { + clearInterval(this.conversionInterval) + } + this.conversionInterval = setInterval(() => { + console.log("Updated currency!") + this.configManager.updateConversionRate() + }, 1000) + } + // called from popup setRpcTarget (rpcTarget) { this.configManager.setRpcTarget(rpcTarget) -- cgit v1.2.3 From 22528002e1edef84ade67d5bc30b2580e6542c05 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 22 Jul 2016 10:15:39 -0700 Subject: Linting! --- app/scripts/metamask-controller.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index e121fad6a..0537bda97 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -251,7 +251,7 @@ module.exports = class MetamaskController { } cb(data) } catch (e) { - cb(null,e) + cb(null, e) } } @@ -260,7 +260,9 @@ module.exports = class MetamaskController { clearInterval(this.conversionInterval) } this.conversionInterval = setInterval(() => { - console.log("Updated currency!") + console.log('=================') + console.log('Updated currency!') + console.log('=================') this.configManager.updateConversionRate() }, 1000) } -- cgit v1.2.3 From 637d3978b716a7f32cf603b70155d8db90509af2 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 9 Aug 2016 16:33:58 -0700 Subject: Fix default value. Add loading indication for async. --- app/scripts/metamask-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 45305ee8f..1550f0937 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -21,7 +21,7 @@ module.exports = class MetamaskController { this.idStore.setStore(this.ethStore) this.messageManager = messageManager this.publicConfigStore = this.initPublicConfigStore - this.configManager.setCurrentFiat('usd') + this.configManager.setCurrentFiat('USD') this.configManager.updateConversionRate() this.scheduleConversionInterval() } -- cgit v1.2.3 From cb0c1f25bacab5f6ee9348dbc3dc112f4d77560f Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 9 Aug 2016 16:49:15 -0700 Subject: Did not previously call functions before! --- app/scripts/metamask-controller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 1550f0937..b5052e438 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -252,9 +252,9 @@ module.exports = class MetamaskController { this.configManager.updateConversionRate() this.scheduleConversionInterval() const data = { - conversionRate: this.configManager.getConversionRate, - currentFiat: this.configManager.getCurrentFiat, - conversionDate: this.configManager.getConversionDate, + conversionRate: this.configManager.getConversionRate(), + currentFiat: this.configManager.getCurrentFiat(), + conversionDate: this.configManager.getConversionDate(), } cb(data) } catch (e) { -- cgit v1.2.3 From 58e3042a3b105d9481cddc3f1c6253ccc6f19565 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 16 Aug 2016 13:21:16 -0700 Subject: Remove logging. Clean up duplicate entries in currency list. --- app/scripts/metamask-controller.js | 1 - 1 file changed, 1 deletion(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 6dbc5e50e..d7f3df534 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -271,7 +271,6 @@ module.exports = class MetamaskController { clearInterval(this.conversionInterval) } this.conversionInterval = setInterval(() => { - console.log('started update conversion rate.') this.configManager.updateConversionRate() }, 300000) } -- cgit v1.2.3 From d43ac808ff3a0891fc3de5f370c3ebe1efbd86b2 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 16 Aug 2016 14:28:32 -0700 Subject: Fix uncalled fn. --- app/scripts/metamask-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index d7f3df534..d21eb5fc1 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -20,7 +20,7 @@ module.exports = class MetamaskController { this.ethStore = new EthStore(this.provider) this.idStore.setStore(this.ethStore) this.messageManager = messageManager - this.publicConfigStore = this.initPublicConfigStore + this.publicConfigStore = this.initPublicConfigStore() this.configManager.setCurrentFiat('USD') this.configManager.updateConversionRate() this.scheduleConversionInterval() -- cgit v1.2.3