diff options
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r-- | app/scripts/inpage.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index 5b5c02c26..c5f4ee4c9 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -50,6 +50,19 @@ inpageProvider.enable = function () { }) } +inpageProvider.isEnabled = function () { + return new Promise((resolve, reject) => { + window.addEventListener('ethereumproviderstatus', ({ detail }) => { + if (typeof detail.error !== 'undefined') { + reject(detail.error) + } else { + resolve(detail.isEnabled) + } + }) + window.postMessage({ type: 'ETHEREUM_PROVIDER_STATUS' }, '*') + }) +} + // Work around for web3@1.0 deleting the bound `sendAsync` but not the unbound // `sendAsync` method on the prototype, causing `this` reference issues with drizzle const proxiedInpageProvider = new Proxy(inpageProvider, { @@ -60,6 +73,7 @@ const proxiedInpageProvider = new Proxy(inpageProvider, { window.ethereum = proxiedInpageProvider + // // setup web3 // |