mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge branch 'develop' into nonce-tracker-mutex-fix
This commit is contained in:
commit
5032d6e4c5
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- Fix bug where account reset did not work with custom RPC providers.
|
- Fix bug where account reset did not work with custom RPC providers.
|
||||||
- Fix bug where nonce mutex was never released
|
- Fix bug where nonce mutex was never released
|
||||||
|
- Stop reloading browser page on Ethereum network change
|
||||||
|
|
||||||
## 4.7.4 Tue Jun 05 2018
|
## 4.7.4 Tue Jun 05 2018
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ cleanContextForImports()
|
|||||||
require('web3/dist/web3.min.js')
|
require('web3/dist/web3.min.js')
|
||||||
const log = require('loglevel')
|
const log = require('loglevel')
|
||||||
const LocalMessageDuplexStream = require('post-message-stream')
|
const LocalMessageDuplexStream = require('post-message-stream')
|
||||||
const setupDappAutoReload = require('./lib/auto-reload.js')
|
|
||||||
const MetamaskInpageProvider = require('./lib/inpage-provider.js')
|
const MetamaskInpageProvider = require('./lib/inpage-provider.js')
|
||||||
restoreContextAfterImports()
|
restoreContextAfterImports()
|
||||||
|
|
||||||
@ -38,8 +37,24 @@ web3.setProvider = function () {
|
|||||||
log.debug('MetaMask - overrode web3.setProvider')
|
log.debug('MetaMask - overrode web3.setProvider')
|
||||||
}
|
}
|
||||||
log.debug('MetaMask - injected web3')
|
log.debug('MetaMask - injected web3')
|
||||||
// export global web3, with usage-detection
|
|
||||||
setupDappAutoReload(web3, inpageProvider.publicConfigStore)
|
// export global web3, with usage-detection and deprecation warning
|
||||||
|
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
|
// set web3 defaultAccount
|
||||||
inpageProvider.publicConfigStore.subscribe(function (state) {
|
inpageProvider.publicConfigStore.subscribe(function (state) {
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
module.exports = setupDappAutoReload
|
|
||||||
|
|
||||||
function setupDappAutoReload (web3, observable) {
|
|
||||||
// export web3 as a global, checking for usage
|
|
||||||
let hasBeenWarned = false
|
|
||||||
let reloadInProgress = false
|
|
||||||
let lastTimeUsed
|
|
||||||
let lastSeenNetwork
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
// get the time of use
|
|
||||||
lastTimeUsed = Date.now()
|
|
||||||
// return value normally
|
|
||||||
return _web3[key]
|
|
||||||
},
|
|
||||||
set: (_web3, key, value) => {
|
|
||||||
// set value normally
|
|
||||||
_web3[key] = value
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
observable.subscribe(function (state) {
|
|
||||||
// if reload in progress, no need to check reload logic
|
|
||||||
if (reloadInProgress) return
|
|
||||||
|
|
||||||
const currentNetwork = state.networkVersion
|
|
||||||
|
|
||||||
// set the initial network
|
|
||||||
if (!lastSeenNetwork) {
|
|
||||||
lastSeenNetwork = currentNetwork
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// skip reload logic if web3 not used
|
|
||||||
if (!lastTimeUsed) return
|
|
||||||
|
|
||||||
// if network did not change, exit
|
|
||||||
if (currentNetwork === lastSeenNetwork) return
|
|
||||||
|
|
||||||
// initiate page reload
|
|
||||||
reloadInProgress = true
|
|
||||||
const timeSinceUse = Date.now() - lastTimeUsed
|
|
||||||
// if web3 was recently used then delay the reloading of the page
|
|
||||||
if (timeSinceUse > 500) {
|
|
||||||
triggerReset()
|
|
||||||
} else {
|
|
||||||
setTimeout(triggerReset, 500)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// reload the page
|
|
||||||
function triggerReset () {
|
|
||||||
global.location.reload()
|
|
||||||
}
|
|
12992
package-lock.json
generated
12992
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
|||||||
"dist": "gulp dist",
|
"dist": "gulp dist",
|
||||||
"doc": "jsdoc -c development/tools/.jsdoc.json",
|
"doc": "jsdoc -c development/tools/.jsdoc.json",
|
||||||
"test": "npm run test:unit && npm run test:integration && npm run lint",
|
"test": "npm run test:unit && npm run test:integration && npm run lint",
|
||||||
|
"watch:test:unit": "nodemon --exec \"npm run test:unit\" ./test ./app ./ui",
|
||||||
"test:unit": "cross-env METAMASK_ENV=test mocha --exit --require test/setup.js --recursive \"test/unit/**/*.js\" \"ui/app/**/*.test.js\" && dot-only-hunter",
|
"test:unit": "cross-env METAMASK_ENV=test mocha --exit --require test/setup.js --recursive \"test/unit/**/*.js\" \"ui/app/**/*.test.js\" && dot-only-hunter",
|
||||||
"test:single": "cross-env METAMASK_ENV=test mocha --require test/helper.js",
|
"test:single": "cross-env METAMASK_ENV=test mocha --require test/helper.js",
|
||||||
"test:integration": "npm run test:integration:build && npm run test:flat && npm run test:mascara",
|
"test:integration": "npm run test:integration:build && npm run test:flat && npm run test:mascara",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user