diff options
author | bitpshr <mail@bitpshr.net> | 2018-11-05 22:03:30 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | 879997af517b36cf701ec74c08ec4293a2206baa (patch) | |
tree | fdbea02d5c263dd7b3096a1aec35e4f0cdf0b968 /app/scripts/inpage.js | |
parent | 26ada8a828ab684c310080a18115a8ef3234aaee (diff) | |
download | tangerine-wallet-browser-879997af517b36cf701ec74c08ec4293a2206baa.tar tangerine-wallet-browser-879997af517b36cf701ec74c08ec4293a2206baa.tar.gz tangerine-wallet-browser-879997af517b36cf701ec74c08ec4293a2206baa.tar.bz2 tangerine-wallet-browser-879997af517b36cf701ec74c08ec4293a2206baa.tar.lz tangerine-wallet-browser-879997af517b36cf701ec74c08ec4293a2206baa.tar.xz tangerine-wallet-browser-879997af517b36cf701ec74c08ec4293a2206baa.tar.zst tangerine-wallet-browser-879997af517b36cf701ec74c08ec4293a2206baa.zip |
Add experimental RPC method support
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r-- | app/scripts/inpage.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index 2ca3abde2..e1948a522 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -44,7 +44,7 @@ window.addEventListener('metamasksetlocked', () => { }) // augment the provider with its enable method -inpageProvider.enable = function () { +inpageProvider.enable = function ({ force } = {}) { return new Promise((resolve, reject) => { window.removeEventListener('ethereumprovider', providerHandle) providerHandle = ({ detail }) => { @@ -85,10 +85,23 @@ inpageProvider.enable = function () { } } window.addEventListener('ethereumprovider', providerHandle) - window.postMessage({ type: 'ETHEREUM_ENABLE_PROVIDER' }, '*') + window.postMessage({ type: 'ETHEREUM_ENABLE_PROVIDER', force }, '*') }) } +// detect eth_requestAccounts and pipe to enable for now +function detectAccountRequest(method) { + const originalMethod = inpageProvider[method] + inpageProvider[method] = function ({ method }) { + if (method === 'eth_requestAccounts') { + return ethereum.enable() + } + return originalMethod.apply(this, arguments) + } +} +detectAccountRequest('send') +detectAccountRequest('sendAsync') + // add metamask-specific convenience methods inpageProvider._metamask = new Proxy({ /** |