aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-10-09 04:54:13 +0800
committerkumavis <aaron@kumavis.me>2018-10-09 04:54:13 +0800
commit45feb43f306f4b21ef007e0c8897cda384c28fc5 (patch)
tree61bda68944e2472e61d65bc5e6a02153bc4ce212
parent9bce0ae84de9b48af33953bd25e5bbef003b1a9e (diff)
downloadtangerine-wallet-browser-45feb43f306f4b21ef007e0c8897cda384c28fc5.tar
tangerine-wallet-browser-45feb43f306f4b21ef007e0c8897cda384c28fc5.tar.gz
tangerine-wallet-browser-45feb43f306f4b21ef007e0c8897cda384c28fc5.tar.bz2
tangerine-wallet-browser-45feb43f306f4b21ef007e0c8897cda384c28fc5.tar.lz
tangerine-wallet-browser-45feb43f306f4b21ef007e0c8897cda384c28fc5.tar.xz
tangerine-wallet-browser-45feb43f306f4b21ef007e0c8897cda384c28fc5.tar.zst
tangerine-wallet-browser-45feb43f306f4b21ef007e0c8897cda384c28fc5.zip
workaround - fix for drizzle
-rw-r--r--app/scripts/inpage.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index d924be516..431702d63 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -5,6 +5,7 @@ const log = require('loglevel')
const LocalMessageDuplexStream = require('post-message-stream')
const setupDappAutoReload = require('./lib/auto-reload.js')
const MetamaskInpageProvider = require('metamask-inpage-provider')
+
restoreContextAfterImports()
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
@@ -44,7 +45,15 @@ inpageProvider.enable = function (options = {}) {
})
}
-window.ethereum = inpageProvider
+// 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, {
+ // straight up lie that we deleted the property so that it doesnt
+ // throw an error in strict mode
+ deleteProperty: () => true,
+})
+
+window.ethereum = proxiedInpageProvider
//
// setup web3
@@ -58,7 +67,7 @@ if (typeof window.web3 !== 'undefined') {
and try again.`)
}
-var web3 = new Web3(inpageProvider)
+var web3 = new Web3(proxiedInpageProvider)
web3.setProvider = function () {
log.debug('MetaMask - overrode web3.setProvider')
}