aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js33
1 files changed, 32 insertions, 1 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 2c141a402..6dbc5e50e 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -20,7 +20,10 @@ 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()
}
getState () {
@@ -40,7 +43,9 @@ module.exports = class MetamaskController {
setProviderType: this.setProviderType.bind(this),
useEtherscanProvider: this.useEtherscanProvider.bind(this),
agreeToDisclaimer: this.agreeToDisclaimer.bind(this),
+ setCurrentFiat: this.setCurrentFiat.bind(this),
agreeToEthWarning: this.agreeToEthWarning.bind(this),
+
// forward directly to idStore
createNewVault: idStore.createNewVault.bind(idStore),
recoverFromSeed: idStore.recoverFromSeed.bind(idStore),
@@ -245,6 +250,32 @@ module.exports = class MetamaskController {
}
}
+ setCurrentFiat (fiat, cb) {
+ try {
+ this.configManager.setCurrentFiat(fiat)
+ this.configManager.updateConversionRate()
+ this.scheduleConversionInterval()
+ const data = {
+ conversionRate: this.configManager.getConversionRate(),
+ currentFiat: this.configManager.getCurrentFiat(),
+ conversionDate: this.configManager.getConversionDate(),
+ }
+ cb(data)
+ } catch (e) {
+ cb(null, e)
+ }
+ }
+
+ scheduleConversionInterval () {
+ if (this.conversionInterval) {
+ clearInterval(this.conversionInterval)
+ }
+ this.conversionInterval = setInterval(() => {
+ console.log('started update conversion rate.')
+ this.configManager.updateConversionRate()
+ }, 300000)
+ }
+
agreeToEthWarning (cb) {
try {
this.configManager.setShouldntShowWarning()