aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
authorFrankie <frankie.diamond@gmail.com>2016-12-22 06:31:07 +0800
committerGitHub <noreply@github.com>2016-12-22 06:31:07 +0800
commit6f7c23fd28ef37ae51478b735c1f5888c97bbaf5 (patch)
treeb927871ed00c33a66341a26de09f00cf006314b8 /app/scripts/metamask-controller.js
parenta85c691b71d5142d2412000930328fbe9161760a (diff)
parent73cdf0bfd49470bad1f0da4d0d894278c87af54e (diff)
downloadtangerine-wallet-browser-6f7c23fd28ef37ae51478b735c1f5888c97bbaf5.tar.gz
tangerine-wallet-browser-6f7c23fd28ef37ae51478b735c1f5888c97bbaf5.tar.zst
tangerine-wallet-browser-6f7c23fd28ef37ae51478b735c1f5888c97bbaf5.zip
Merge branch 'dev' into TxManager
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js32
1 files changed, 24 insertions, 8 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 7798a6a60..125753063 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -2,6 +2,7 @@ const extend = require('xtend')
const EthStore = require('eth-store')
const MetaMaskProvider = require('web3-provider-engine/zero.js')
const KeyringController = require('./keyring-controller')
+const NoticeController = require('./notice-controller')
const messageManager = require('./lib/message-manager')
const TxManager = require('./transaction-manager')
const HostStore = require('./lib/remote-store.js').HostStore
@@ -23,6 +24,13 @@ module.exports = class MetamaskController {
txManager: this.txManager,
getNetwork: this.getStateNetwork.bind(this),
})
+ // notices
+ this.noticeController = new NoticeController({
+ configManager: this.configManager,
+ })
+ this.noticeController.updateNoticesList()
+ // to be uncommented when retrieving notices from a remote server.
+ // this.noticeController.startPolling()
this.provider = this.initializeProvider(opts)
this.ethStore = new EthStore(this.provider)
this.keyringController.setStore(this.ethStore)
@@ -57,12 +65,15 @@ module.exports = class MetamaskController {
this.configManager.getConfig(),
this.keyringController.getState(),
this.txManager.getState()
+ this.noticeController.getState()
)
}
getApi () {
const keyringController = this.keyringController
const txManager = this.txManager
+ const noticeController = this.noticeController
+
return {
getState: (cb) => { cb(null, this.getState()) },
setRpcTarget: this.setRpcTarget.bind(this),
@@ -101,6 +112,9 @@ module.exports = class MetamaskController {
buyEth: this.buyEth.bind(this),
// shapeshift
createShapeShiftTx: this.createShapeShiftTx.bind(this),
+ // notices
+ checkNotices: noticeController.updateNoticesList.bind(noticeController),
+ markNoticeRead: noticeController.markNoticeRead.bind(noticeController),
}
}
@@ -292,7 +306,7 @@ module.exports = class MetamaskController {
setTOSHash (hash) {
try {
this.configManager.setTOSHash(hash)
- } catch (e) {
+ } catch (err) {
console.error('Error in setting terms of service hash.')
}
}
@@ -304,17 +318,19 @@ module.exports = class MetamaskController {
this.resetDisclaimer()
this.setTOSHash(global.TOS_HASH)
}
- } catch (e) {
+ } catch (err) {
console.error('Error in checking TOS change.')
}
}
+ // disclaimer
+
agreeToDisclaimer (cb) {
try {
this.configManager.setConfirmedDisclaimer(true)
cb()
- } catch (e) {
- cb(e)
+ } catch (err) {
+ cb(err)
}
}
@@ -337,8 +353,8 @@ module.exports = class MetamaskController {
conversionDate: this.configManager.getConversionDate(),
}
cb(data)
- } catch (e) {
- cb(null, e)
+ } catch (err) {
+ cb(null, err)
}
}
@@ -411,8 +427,8 @@ module.exports = class MetamaskController {
try {
this.configManager.setGasMultiplier(gasMultiplier)
cb()
- } catch (e) {
- cb(e)
+ } catch (err) {
+ cb(err)
}
}