1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Add controller functions for storing and checking TOS hashes.

This commit is contained in:
Kevin Serrano 2016-10-06 03:24:28 -07:00
parent db06813404
commit 4ea3246912
No known key found for this signature in database
GPG Key ID: 7CC862A58D2889B4

View File

@ -25,6 +25,7 @@ module.exports = class MetamaskController {
var currentFiat = this.configManager.getCurrentFiat() || 'USD'
this.configManager.setCurrentFiat(currentFiat)
this.configManager.updateConversionRate()
this.configManager.setTOSHash(0)
this.scheduleConversionInterval()
}
@ -45,8 +46,11 @@ module.exports = class MetamaskController {
setProviderType: this.setProviderType.bind(this),
useEtherscanProvider: this.useEtherscanProvider.bind(this),
agreeToDisclaimer: this.agreeToDisclaimer.bind(this),
resetDisclaimer: this.resetDisclaimer.bind(this),
setCurrentFiat: this.setCurrentFiat.bind(this),
agreeToEthWarning: this.agreeToEthWarning.bind(this),
setTOSHash: this.setTOSHash.bind(this),
checkTOSChange: this.checkTOSChange.bind(this),
// forward directly to idStore
createNewVault: idStore.createNewVault.bind(idStore),
@ -261,6 +265,26 @@ module.exports = class MetamaskController {
// config
//
setTOSHash (hash, cb) {
try {
this.configManager.setTOSHash(hash)
cb(this.configManager.getTOSHash())
} catch (e) {
cb(null, e)
}
}
checkTOSChange (newHash, cb) {
try {
var currentHash = this.configManager.getTOSHash()
var change = !(currentHash === newHash)
cb(change)
} catch (e) {
cb(null, e)
}
}
agreeToDisclaimer (cb) {
try {
this.configManager.setConfirmed(true)
@ -270,6 +294,14 @@ module.exports = class MetamaskController {
}
}
resetDisclaimer () {
try {
this.configManager.setConfirmed(false)
} catch (e) {
console.error(e)
}
}
setCurrentFiat (fiat, cb) {
try {
this.configManager.setCurrentFiat(fiat)
@ -304,6 +336,8 @@ module.exports = class MetamaskController {
}
}
// called from popup
setRpcTarget (rpcTarget) {
this.configManager.setRpcTarget(rpcTarget)
@ -341,4 +375,3 @@ module.exports = class MetamaskController {
this.configManager.createShapeShiftTx(depositAddress, depositType)
}
}