From 8819475a2ed2ee7c34e983ebb5ab12661be1a961 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 7 Dec 2016 14:34:15 -0800 Subject: Add ability to show notices to user & get confirmation. Implement generation of markdown for notice files. Create npm command. Enhance notice generation. Add test files to test multiple notices. Add basic markdown support to notices. Interval checks for updates. Add extensionizer and linker Add terms and conditions state file Add link support to disclaimer. Changelog addition. --- app/scripts/metamask-controller.js | 42 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 631411bed..65619af82 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 IdentityStore = require('./lib/idStore') +const NoticeController = require('./notice-controller') const messageManager = require('./lib/message-manager') const HostStore = require('./lib/remote-store.js').HostStore const Web3 = require('web3') @@ -17,6 +18,9 @@ module.exports = class MetamaskController { this.idStore = new IdentityStore({ configManager: this.configManager, }) + this.noticeController = new NoticeController({ + configManager: this.configManager, + }) this.provider = this.initializeProvider(opts) this.ethStore = new EthStore(this.provider) this.idStore.setStore(this.ethStore) @@ -27,17 +31,19 @@ module.exports = class MetamaskController { this.configManager.setCurrentFiat(currentFiat) this.configManager.updateConversionRate() + this.checkNotices() this.checkTOSChange() this.scheduleConversionInterval() - + this.scheduleNoticeCheck() } getState () { return extend( this.ethStore.getState(), this.idStore.getState(), - this.configManager.getConfig() + this.configManager.getConfig(), + this.noticeController.getState() ) } @@ -55,6 +61,7 @@ module.exports = class MetamaskController { agreeToEthWarning: this.agreeToEthWarning.bind(this), setTOSHash: this.setTOSHash.bind(this), checkTOSChange: this.checkTOSChange.bind(this), + checkNotices: this.checkNotices.bind(this), setGasMultiplier: this.setGasMultiplier.bind(this), // forward directly to idStore @@ -77,6 +84,8 @@ module.exports = class MetamaskController { buyEth: this.buyEth.bind(this), // shapeshift createShapeShiftTx: this.createShapeShiftTx.bind(this), + // notices + markNoticeRead: this.markNoticeRead.bind(this), } } @@ -289,6 +298,25 @@ module.exports = class MetamaskController { } + checkNotices () { + try { + this.configManager.updateNoticesList() + } catch (e) { + console.error('Error in checking notices.') + } + } + + // notice + + markNoticeRead (notice, cb) { + try { + this.configManager.markNoticeRead(notice) + cb(null, this.configManager.getLatestUnreadNotice()) + } catch (e) { + cb(e) + } + } + agreeToDisclaimer (cb) { try { this.configManager.setConfirmed(true) @@ -331,6 +359,7 @@ module.exports = class MetamaskController { }, 300000) } +<<<<<<< HEAD agreeToEthWarning (cb) { try { this.configManager.setShouldntShowWarning() @@ -338,6 +367,15 @@ module.exports = class MetamaskController { } catch (e) { cb(e) } +======= + scheduleNoticeCheck () { + if (this.noticeCheck) { + clearInterval(this.noticeCheck) + } + this.noticeCheck = setInterval(() => { + this.configManager.updateNoticesList() + }, 300000) +>>>>>>> 25acad7... Add ability to show notices to user & get confirmation. } // called from popup -- cgit v1.2.3 From 851ba66cdd50aae8e2f9cb70fbed016990df2a2a Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 7 Dec 2016 14:34:15 -0800 Subject: Add ability to show notices to user & get confirmation. Implement generation of markdown for notice files. Create npm command. Enhance notice generation. Add test files to test multiple notices. Add basic markdown support to notices. Interval checks for updates. Add extensionizer and linker Add terms and conditions state file Add link support to disclaimer. Changelog addition. --- app/scripts/metamask-controller.js | 40 +++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 65619af82..65eda7342 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -21,6 +21,9 @@ module.exports = class MetamaskController { this.noticeController = new NoticeController({ configManager: this.configManager, }) + this.noticeController = new NoticeController({ + configManager: this.configManager, + }) this.provider = this.initializeProvider(opts) this.ethStore = new EthStore(this.provider) this.idStore.setStore(this.ethStore) @@ -298,14 +301,6 @@ module.exports = class MetamaskController { } - checkNotices () { - try { - this.configManager.updateNoticesList() - } catch (e) { - console.error('Error in checking notices.') - } - } - // notice markNoticeRead (notice, cb) { @@ -317,6 +312,25 @@ module.exports = class MetamaskController { } } + checkNotices () { + try { + this.configManager.updateNoticesList() + } catch (e) { + console.error('Error in checking notices.') + } + } + + scheduleNoticeCheck () { + if (this.noticeCheck) { + clearInterval(this.noticeCheck) + } + this.noticeCheck = setInterval(() => { + this.configManager.updateNoticesList() + }, 300000) + } + + // disclaimer + agreeToDisclaimer (cb) { try { this.configManager.setConfirmed(true) @@ -359,7 +373,6 @@ module.exports = class MetamaskController { }, 300000) } -<<<<<<< HEAD agreeToEthWarning (cb) { try { this.configManager.setShouldntShowWarning() @@ -367,15 +380,6 @@ module.exports = class MetamaskController { } catch (e) { cb(e) } -======= - scheduleNoticeCheck () { - if (this.noticeCheck) { - clearInterval(this.noticeCheck) - } - this.noticeCheck = setInterval(() => { - this.configManager.updateNoticesList() - }, 300000) ->>>>>>> 25acad7... Add ability to show notices to user & get confirmation. } // called from popup -- cgit v1.2.3 From 2b1d821da3d7205254b9cccf34215e0bfb0fded8 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 16 Dec 2016 11:26:39 -0800 Subject: Cleanup --- app/scripts/metamask-controller.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 65eda7342..b22d53d11 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -21,9 +21,6 @@ module.exports = class MetamaskController { this.noticeController = new NoticeController({ configManager: this.configManager, }) - this.noticeController = new NoticeController({ - configManager: this.configManager, - }) this.provider = this.initializeProvider(opts) this.ethStore = new EthStore(this.provider) this.idStore.setStore(this.ethStore) -- cgit v1.2.3 From 1458b8c68ec1ae5e043d9ea08a862a38966b22c1 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 16 Dec 2016 11:39:41 -0800 Subject: Deactivate polling for now. --- app/scripts/metamask-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index b22d53d11..b7e37b3a5 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -35,7 +35,9 @@ module.exports = class MetamaskController { this.checkTOSChange() this.scheduleConversionInterval() - this.scheduleNoticeCheck() + + // to be uncommented when retrieving notices from a remote server. + // this.scheduleNoticeCheck() } getState () { -- cgit v1.2.3 From 73998feeb2b6ba4ebb9a16c6ed54cce195c09013 Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 16 Dec 2016 12:44:47 -0800 Subject: move notice code from metamask-controller + config-manager, in to notice-controller --- app/scripts/metamask-controller.js | 65 +++++++++++--------------------------- 1 file changed, 19 insertions(+), 46 deletions(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index b7e37b3a5..1477ce9e7 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -18,9 +18,13 @@ module.exports = class MetamaskController { this.idStore = new IdentityStore({ configManager: this.configManager, }) + // 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.idStore.setStore(this.ethStore) @@ -31,13 +35,9 @@ module.exports = class MetamaskController { this.configManager.setCurrentFiat(currentFiat) this.configManager.updateConversionRate() - this.checkNotices() this.checkTOSChange() this.scheduleConversionInterval() - - // to be uncommented when retrieving notices from a remote server. - // this.scheduleNoticeCheck() } getState () { @@ -51,6 +51,7 @@ module.exports = class MetamaskController { getApi () { const idStore = this.idStore + const noticeController = this.noticeController return { getState: (cb) => { cb(null, this.getState()) }, @@ -63,7 +64,6 @@ module.exports = class MetamaskController { agreeToEthWarning: this.agreeToEthWarning.bind(this), setTOSHash: this.setTOSHash.bind(this), checkTOSChange: this.checkTOSChange.bind(this), - checkNotices: this.checkNotices.bind(this), setGasMultiplier: this.setGasMultiplier.bind(this), // forward directly to idStore @@ -87,7 +87,8 @@ module.exports = class MetamaskController { // shapeshift createShapeShiftTx: this.createShapeShiftTx.bind(this), // notices - markNoticeRead: this.markNoticeRead.bind(this), + checkNotices: noticeController.updateNoticesList.bind(noticeController), + markNoticeRead: noticeController.markNoticeRead.bind(noticeController), } } @@ -282,7 +283,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.') } } @@ -294,56 +295,28 @@ module.exports = class MetamaskController { this.resetDisclaimer() this.setTOSHash(global.TOS_HASH) } - } catch (e) { + } catch (err) { console.error('Error in checking TOS change.') } } - // notice - - markNoticeRead (notice, cb) { - try { - this.configManager.markNoticeRead(notice) - cb(null, this.configManager.getLatestUnreadNotice()) - } catch (e) { - cb(e) - } - } - - checkNotices () { - try { - this.configManager.updateNoticesList() - } catch (e) { - console.error('Error in checking notices.') - } - } - - scheduleNoticeCheck () { - if (this.noticeCheck) { - clearInterval(this.noticeCheck) - } - this.noticeCheck = setInterval(() => { - this.configManager.updateNoticesList() - }, 300000) - } - // disclaimer agreeToDisclaimer (cb) { try { this.configManager.setConfirmed(true) cb() - } catch (e) { - cb(e) + } catch (err) { + cb(err) } } resetDisclaimer () { try { this.configManager.setConfirmed(false) - } catch (e) { - console.error(e) + } catch (err) { + console.error(err) } } @@ -358,8 +331,8 @@ module.exports = class MetamaskController { conversionDate: this.configManager.getConversionDate(), } cb(data) - } catch (e) { - cb(null, e) + } catch (err) { + cb(null, err) } } @@ -376,8 +349,8 @@ module.exports = class MetamaskController { try { this.configManager.setShouldntShowWarning() cb() - } catch (e) { - cb(e) + } catch (err) { + cb(err) } } @@ -422,8 +395,8 @@ module.exports = class MetamaskController { try { this.configManager.setGasMultiplier(gasMultiplier) cb() - } catch (e) { - cb(e) + } catch (err) { + cb(err) } } } -- cgit v1.2.3