aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/inpage.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r--app/scripts/inpage.js17
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({
/**