|
|
@ -7,6 +7,7 @@ const HostStore = require('./lib/remote-store.js').HostStore |
|
|
|
const Web3 = require('web3') |
|
|
|
const Web3 = require('web3') |
|
|
|
const ConfigManager = require('./lib/config-manager') |
|
|
|
const ConfigManager = require('./lib/config-manager') |
|
|
|
const extension = require('./lib/extension') |
|
|
|
const extension = require('./lib/extension') |
|
|
|
|
|
|
|
const newTOSHash = global.TOS_HASH |
|
|
|
|
|
|
|
|
|
|
|
module.exports = class MetamaskController { |
|
|
|
module.exports = class MetamaskController { |
|
|
|
|
|
|
|
|
|
|
@ -22,12 +23,15 @@ module.exports = class MetamaskController { |
|
|
|
this.idStore.setStore(this.ethStore) |
|
|
|
this.idStore.setStore(this.ethStore) |
|
|
|
this.messageManager = messageManager |
|
|
|
this.messageManager = messageManager |
|
|
|
this.publicConfigStore = this.initPublicConfigStore() |
|
|
|
this.publicConfigStore = this.initPublicConfigStore() |
|
|
|
|
|
|
|
|
|
|
|
var currentFiat = this.configManager.getCurrentFiat() || 'USD' |
|
|
|
var currentFiat = this.configManager.getCurrentFiat() || 'USD' |
|
|
|
this.configManager.setCurrentFiat(currentFiat) |
|
|
|
this.configManager.setCurrentFiat(currentFiat) |
|
|
|
this.configManager.updateConversionRate() |
|
|
|
this.configManager.updateConversionRate() |
|
|
|
var currentHash = this.configManager.getTOSHash() || 0 |
|
|
|
|
|
|
|
this.configManager.setTOSHash(currentHash) |
|
|
|
this.checkTOSChange() |
|
|
|
|
|
|
|
|
|
|
|
this.scheduleConversionInterval() |
|
|
|
this.scheduleConversionInterval() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getState () { |
|
|
|
getState () { |
|
|
@ -266,22 +270,23 @@ module.exports = class MetamaskController { |
|
|
|
// config
|
|
|
|
// config
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
setTOSHash (hash, cb) { |
|
|
|
setTOSHash (hash) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
this.configManager.setTOSHash(hash) |
|
|
|
this.configManager.setTOSHash(hash) |
|
|
|
cb(this.configManager.getTOSHash()) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
cb(null, e) |
|
|
|
console.error('Error in setting terms of service hash.') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
checkTOSChange (newHash, cb) { |
|
|
|
checkTOSChange () { |
|
|
|
try { |
|
|
|
try { |
|
|
|
var currentHash = this.configManager.getTOSHash() |
|
|
|
const storedHash = this.configManager.getTOSHash() || 0 |
|
|
|
var change = !(currentHash === newHash) |
|
|
|
if (storedHash !== global.newTOSHash) { |
|
|
|
cb(change) |
|
|
|
this.resetDisclaimer() |
|
|
|
|
|
|
|
this.setTOSHash(global.newTOSHash) |
|
|
|
|
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
cb(null, e) |
|
|
|
console.error("Error in checking TOS change.") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|