Add web3 deprecation warning (#7334)

* Add web3 deprecation warning

* Update web3 deprecation article URL
feature/default_network_editable
Whymarrh Whitby 5 years ago committed by GitHub
parent 30606327f0
commit 6bd87e1f09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      app/scripts/inpage.js
  2. 6
      app/scripts/lib/auto-reload.js

@ -174,27 +174,6 @@ log.debug('MetaMask - injected web3')
setupDappAutoReload(web3, inpageProvider.publicConfigStore)
// export global web3, with usage-detection and deprecation warning
/* TODO: Uncomment this area once auto-reload.js has been deprecated:
let hasBeenWarned = false
global.web3 = new Proxy(web3, {
get: (_web3, key) => {
// show warning once on web3 access
if (!hasBeenWarned && key !== 'currentProvider') {
console.warn('MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider \nhttps://github.com/MetaMask/faq/blob/master/detecting_metamask.md#web3-deprecation')
hasBeenWarned = true
}
// return value normally
return _web3[key]
},
set: (_web3, key, value) => {
// set value normally
_web3[key] = value
},
})
*/
// set web3 defaultAccount
inpageProvider.publicConfigStore.subscribe(function (state) {
web3.eth.defaultAccount = state.selectedAddress

@ -5,11 +5,17 @@ function setupDappAutoReload (web3, observable) {
let reloadInProgress = false
let lastTimeUsed
let lastSeenNetwork
let hasBeenWarned = false
global.web3 = new Proxy(web3, {
get: (_web3, key) => {
// get the time of use
lastTimeUsed = Date.now()
// show warning once on web3 access
if (!hasBeenWarned && key !== 'currentProvider') {
console.warn('MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider\nhttps://medium.com/metamask/4a899ad6e59e')
hasBeenWarned = true
}
// return value normally
return _web3[key]
},

Loading…
Cancel
Save