Add __isMetaMaskShim__ property to injected web3 (#9972)

feature/default_network_editable
Erik Marks 4 years ago committed by GitHub
parent 1da9ad77a4
commit 5fb2e544d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/scripts/lib/setupWeb3.js

@ -27,7 +27,12 @@ export default function setupWeb3(log) {
web3.setProvider = function () { web3.setProvider = function () {
log.debug('MetaMask - overrode web3.setProvider') log.debug('MetaMask - overrode web3.setProvider')
} }
log.debug('MetaMask - injected web3') Object.defineProperty(web3, '__isMetaMaskShim__', {
value: true,
enumerable: false,
configurable: false,
writable: false,
})
Object.defineProperty(window.ethereum, '_web3Ref', { Object.defineProperty(window.ethereum, '_web3Ref', {
enumerable: false, enumerable: false,
@ -180,12 +185,13 @@ export default function setupWeb3(log) {
}, },
}) })
Object.defineProperty(global, 'web3', { Object.defineProperty(window, 'web3', {
enumerable: false, enumerable: false,
writable: true, writable: true,
configurable: true, configurable: true,
value: web3Proxy, value: web3Proxy,
}) })
log.debug('MetaMask - injected web3')
window.ethereum._publicConfigStore.subscribe((state) => { window.ethereum._publicConfigStore.subscribe((state) => {
// if the auto refresh on network change is false do not // if the auto refresh on network change is false do not
@ -231,7 +237,7 @@ export default function setupWeb3(log) {
// reload the page // reload the page
function triggerReset() { function triggerReset() {
global.location.reload() window.location.reload()
} }
/** /**

Loading…
Cancel
Save