diff options
author | bitpshr <mail@bitpshr.net> | 2018-10-18 06:38:31 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | 84874a639d217da36926869fa3cb235c05725cf5 (patch) | |
tree | 63f44fd5e63bd5e483e18ab46fc312298e431915 /app/scripts/inpage.js | |
parent | 573139b9357ccd97eb6b866721fafc93ceb080b6 (diff) | |
download | tangerine-wallet-browser-84874a639d217da36926869fa3cb235c05725cf5.tar tangerine-wallet-browser-84874a639d217da36926869fa3cb235c05725cf5.tar.gz tangerine-wallet-browser-84874a639d217da36926869fa3cb235c05725cf5.tar.bz2 tangerine-wallet-browser-84874a639d217da36926869fa3cb235c05725cf5.tar.lz tangerine-wallet-browser-84874a639d217da36926869fa3cb235c05725cf5.tar.xz tangerine-wallet-browser-84874a639d217da36926869fa3cb235c05725cf5.tar.zst tangerine-wallet-browser-84874a639d217da36926869fa3cb235c05725cf5.zip |
Add isUnlocked provider hook
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r-- | app/scripts/inpage.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index 88831c0cc..72f7033f9 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -71,7 +71,16 @@ inpageProvider.isApproved = function () { } inpageProvider.isUnlocked = function () { - + return new Promise((resolve, reject) => { + window.addEventListener('metamaskunlockstatus', ({ detail }) => { + if (typeof detail.error !== 'undefined') { + reject(detail.error) + } else { + resolve(!!detail.isUnlocked) + } + }) + window.postMessage({ type: 'METAMASK_UNLOCK_STATUS' }, '*') + }) } // Work around for web3@1.0 deleting the bound `sendAsync` but not the unbound |