aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-10-12 05:33:30 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-10-12 05:33:30 +0800
commit79a99ac93bf1655b431471cf084bb718063c9928 (patch)
tree47886b8974aa6e21088bf8c661edc6b4bddd5886 /app/scripts
parent26bd4b25ef1611c2cb4021ebcefad5b860449f02 (diff)
downloadtangerine-wallet-browser-79a99ac93bf1655b431471cf084bb718063c9928.tar
tangerine-wallet-browser-79a99ac93bf1655b431471cf084bb718063c9928.tar.gz
tangerine-wallet-browser-79a99ac93bf1655b431471cf084bb718063c9928.tar.bz2
tangerine-wallet-browser-79a99ac93bf1655b431471cf084bb718063c9928.tar.lz
tangerine-wallet-browser-79a99ac93bf1655b431471cf084bb718063c9928.tar.xz
tangerine-wallet-browser-79a99ac93bf1655b431471cf084bb718063c9928.tar.zst
tangerine-wallet-browser-79a99ac93bf1655b431471cf084bb718063c9928.zip
Move tos hash comparison logic from background to mm controller.
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/background.js18
-rw-r--r--app/scripts/metamask-controller.js25
2 files changed, 16 insertions, 27 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index adde3a87f..652acc113 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -8,10 +8,6 @@ const messageManager = require('./lib/message-manager')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const MetamaskController = require('./metamask-controller')
const extension = require('./lib/extension')
-const fs = require('fs')
-const path = require('path')
-const disclaimer = fs.readFileSync(path.join(__dirname, '..', '..', 'USER_AGREEMENT.md')).toString()
-const stringHash = require('string-hash')
const STORAGE_KEY = 'metamask-config'
var popupIsOpen = false
@@ -33,20 +29,8 @@ function triggerUi () {
// On first install, open a window to MetaMask website to how-it-works.
extension.runtime.onInstalled.addListener(function (details) {
- const newTOSHash = stringHash(disclaimer)
if (details.reason === 'install') {
- controller.setTOSHash(newTOSHash, () => {
- extension.tabs.create({url: 'https://metamask.io/#how-it-works'})
- })
- } else if (details.reason === 'update') {
- controller.checkTOSChange(newTOSHash, (hasChanged) => {
- if (hasChanged) {
- controller.resetDisclaimer()
- controller.setTOSHash(newTOSHash, () => {
- extension.tabs.create({url: 'https://metamask.io/terms.html'})
- })
- }
- })
+ extension.tabs.create({url: 'https://metamask.io/#how-it-works'})
}
})
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index c763d571c..29c62a85d 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -7,6 +7,7 @@ const HostStore = require('./lib/remote-store.js').HostStore
const Web3 = require('web3')
const ConfigManager = require('./lib/config-manager')
const extension = require('./lib/extension')
+const newTOSHash = global.TOS_HASH
module.exports = class MetamaskController {
@@ -22,12 +23,15 @@ module.exports = class MetamaskController {
this.idStore.setStore(this.ethStore)
this.messageManager = messageManager
this.publicConfigStore = this.initPublicConfigStore()
+
var currentFiat = this.configManager.getCurrentFiat() || 'USD'
this.configManager.setCurrentFiat(currentFiat)
this.configManager.updateConversionRate()
- var currentHash = this.configManager.getTOSHash() || 0
- this.configManager.setTOSHash(currentHash)
+
+ this.checkTOSChange()
+
this.scheduleConversionInterval()
+
}
getState () {
@@ -266,22 +270,23 @@ module.exports = class MetamaskController {
// config
//
- setTOSHash (hash, cb) {
+ setTOSHash (hash) {
try {
this.configManager.setTOSHash(hash)
- cb(this.configManager.getTOSHash())
} catch (e) {
- cb(null, e)
+ console.error('Error in setting terms of service hash.')
}
}
- checkTOSChange (newHash, cb) {
+ checkTOSChange () {
try {
- var currentHash = this.configManager.getTOSHash()
- var change = !(currentHash === newHash)
- cb(change)
+ const storedHash = this.configManager.getTOSHash() || 0
+ if (storedHash !== global.newTOSHash) {
+ this.resetDisclaimer()
+ this.setTOSHash(global.newTOSHash)
+ }
} catch (e) {
- cb(null, e)
+ console.error("Error in checking TOS change.")
}
}