diff options
author | bitpshr <mail@bitpshr.net> | 2018-10-30 05:54:39 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | cc1bab6ebbef8d8219f83039fdc3baca6de718fd (patch) | |
tree | 778e470a3a1cf50937492eb054693d3590bc3dda /app | |
parent | d7618bd5c6cffe02d8737fe6925a31484a1fc0b0 (diff) | |
download | tangerine-wallet-browser-cc1bab6ebbef8d8219f83039fdc3baca6de718fd.tar tangerine-wallet-browser-cc1bab6ebbef8d8219f83039fdc3baca6de718fd.tar.gz tangerine-wallet-browser-cc1bab6ebbef8d8219f83039fdc3baca6de718fd.tar.bz2 tangerine-wallet-browser-cc1bab6ebbef8d8219f83039fdc3baca6de718fd.tar.lz tangerine-wallet-browser-cc1bab6ebbef8d8219f83039fdc3baca6de718fd.tar.xz tangerine-wallet-browser-cc1bab6ebbef8d8219f83039fdc3baca6de718fd.tar.zst tangerine-wallet-browser-cc1bab6ebbef8d8219f83039fdc3baca6de718fd.zip |
Differentiate locked and enabled
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/contentscript.js | 4 | ||||
-rw-r--r-- | app/scripts/controllers/provider-approval.js | 11 | ||||
-rw-r--r-- | app/scripts/inpage.js | 21 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 1 |
4 files changed, 10 insertions, 27 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 0723c03f7..2c2efda1c 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -157,10 +157,6 @@ function listenForProviderRequest () { case 'answer-is-unlocked': injectScript(`window.dispatchEvent(new CustomEvent('metamaskisunlocked', { detail: { isUnlocked: ${isUnlocked}}}))`) break - case 'metamask-set-locked': - isEnabled = false - injectScript(`window.dispatchEvent(new CustomEvent('metamasksetlocked', { detail: {}}))`) - break } }) } diff --git a/app/scripts/controllers/provider-approval.js b/app/scripts/controllers/provider-approval.js index 42393de85..66017c58e 100644 --- a/app/scripts/controllers/provider-approval.js +++ b/app/scripts/controllers/provider-approval.js @@ -44,8 +44,7 @@ class ProviderApprovalController { */ _handleProviderRequest (origin) { this.store.updateState({ providerRequests: [{ origin }] }) - const isUnlocked = this.keyringController.memStore.getState().isUnlocked - if (isUnlocked && this.isApproved(origin)) { + if (this.isApproved(origin)) { this.approveProviderRequest(origin) return } @@ -126,14 +125,6 @@ class ProviderApprovalController { const privacyMode = this.preferencesController.getFeatureFlags().privacyMode return !privacyMode || this.approvedOrigins[origin] } - - /** - * Tells all tabs that MetaMask is now locked. This is primarily used to set - * internal flags in the contentscript and inpage script. - */ - setLocked () { - this.platform.sendMessage({ action: 'metamask-set-locked' }) - } } module.exports = ProviderApprovalController diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index a5e0118d4..a60d19480 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -35,11 +35,6 @@ var inpageProvider = new MetamaskInpageProvider(metamaskStream) // set a high max listener count to avoid unnecesary warnings inpageProvider.setMaxListeners(100) -// set up a listener for when MetaMask is locked -window.addEventListener('metamasksetlocked', () => { - isEnabled = false -}) - // augment the provider with its enable method inpageProvider.enable = function () { return new Promise((resolve, reject) => { @@ -50,13 +45,15 @@ inpageProvider.enable = function () { // wait for the publicConfig store to populate with an account const publicConfig = new Promise((resolve) => { const { selectedAddress } = inpageProvider.publicConfigStore.getState() - if (selectedAddress) { - resolve() - } else { - inpageProvider.publicConfigStore.on('update', ({ selectedAddress }) => { - selectedAddress && resolve() - }) - } + inpageProvider._metamask.isUnlocked().then(unlocked => { + if (!unlocked || selectedAddress) { + resolve() + } else { + inpageProvider.publicConfigStore.on('update', ({ selectedAddress }) => { + selectedAddress && resolve() + }) + } + }) }) // wait for the background to update with an accoount diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 33278db85..c7fc42eb4 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1581,7 +1581,6 @@ module.exports = class MetamaskController extends EventEmitter { * Locks MetaMask */ setLocked() { - this.providerApprovalController.setLocked() return this.keyringController.setLocked() } } |