diff options
author | bitpshr <mail@bitpshr.net> | 2018-09-28 02:19:09 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | c76c9ca2c86317f902f443db2c5704d4bf6311c0 (patch) | |
tree | e6b182dd8b0eb849d93143ecbd1217640aa8f490 /app/scripts/inpage.js | |
parent | 2d4ff1dd82252cbe1abe06206fb2664f96905d91 (diff) | |
download | tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.tar tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.tar.gz tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.tar.bz2 tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.tar.lz tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.tar.xz tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.tar.zst tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.zip |
EIP-1102: updated implementation
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r-- | app/scripts/inpage.js | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index b885a7e05..25bfe1416 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -31,19 +31,18 @@ var inpageProvider = new MetamaskInpageProvider(metamaskStream) inpageProvider.setMaxListeners(100) // Augment the provider with its enable method -inpageProvider.enable = function (options = {}) { +inpageProvider.enable = function () { return new Promise((resolve, reject) => { - if (options.mockRejection) { - reject('User rejected account access') - } else { - inpageProvider.sendAsync({ method: 'eth_accounts', params: [] }, (error, response) => { - if (error) { - reject(error) - } else { - resolve(response.result) - } - }) - } + window.addEventListener('ethereumprovider', ({ detail }) => { + if (typeof detail.error !== 'undefined') { + reject(detail.error) + } else { + inpageProvider.publicConfigStore.once('update', () => { + resolve(inpageProvider.send({ method: 'eth_accounts' }).result) + }) + } + }) + window.postMessage({ type: 'ETHEREUM_ENABLE_PROVIDER' }, '*') }) } |