diff options
author | bitpshr <mail@bitpshr.net> | 2018-10-30 04:55:13 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | ba40fcbcb43c5adcb3a961afd4050cdb2025b7a6 (patch) | |
tree | 0e3d1fa0c609153cb0ca66dd89e9c9c3377672a4 /app/scripts/inpage.js | |
parent | f02e18dd80672a0b7440256cb7946feabf907ee1 (diff) | |
download | tangerine-wallet-browser-ba40fcbcb43c5adcb3a961afd4050cdb2025b7a6.tar tangerine-wallet-browser-ba40fcbcb43c5adcb3a961afd4050cdb2025b7a6.tar.gz tangerine-wallet-browser-ba40fcbcb43c5adcb3a961afd4050cdb2025b7a6.tar.bz2 tangerine-wallet-browser-ba40fcbcb43c5adcb3a961afd4050cdb2025b7a6.tar.lz tangerine-wallet-browser-ba40fcbcb43c5adcb3a961afd4050cdb2025b7a6.tar.xz tangerine-wallet-browser-ba40fcbcb43c5adcb3a961afd4050cdb2025b7a6.tar.zst tangerine-wallet-browser-ba40fcbcb43c5adcb3a961afd4050cdb2025b7a6.zip |
Handle logout gracefully
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r-- | app/scripts/inpage.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index cadc61727..49a18c5e9 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -33,6 +33,10 @@ inpageProvider.setMaxListeners(100) var isEnabled = false var warned = false +window.addEventListener('metamasksetlocked', () => { + isEnabled = false +}) + // augment the provider with its enable method inpageProvider.enable = function () { return new Promise((resolve, reject) => { @@ -91,14 +95,14 @@ inpageProvider._metamask = new Proxy({ */ isApproved: function() { return new Promise((resolve, reject) => { - window.addEventListener('ethereumproviderstatus', ({ detail }) => { + window.addEventListener('ethereumisapproved', ({ detail }) => { if (typeof detail.error !== 'undefined') { reject(detail.error) } else { - resolve(!!detail.isEnabled) + resolve(!!detail.isApproved) } }) - window.postMessage({ type: 'ETHEREUM_QUERY_STATUS' }, '*') + window.postMessage({ type: 'ETHEREUM_IS_APPROVED' }, '*') }) }, @@ -109,14 +113,14 @@ inpageProvider._metamask = new Proxy({ */ isUnlocked: function () { return new Promise((resolve, reject) => { - window.addEventListener('metamaskunlockstatus', ({ detail }) => { + window.addEventListener('metamaskisunlocked', ({ detail }) => { if (typeof detail.error !== 'undefined') { reject(detail.error) } else { resolve(!!detail.isUnlocked) } }) - window.postMessage({ type: 'METAMASK_UNLOCK_STATUS' }, '*') + window.postMessage({ type: 'METAMASK_IS_UNLOCKED' }, '*') }) }, }, { |