diff options
Merge branch 'dev' into TxManager
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r-- | app/scripts/metamask-controller.js | 32 |
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) } } |