mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
Merge pull request #7047 from Gudahtt/auto-reload-deprecation-warning
Add warning about reload on network change
This commit is contained in:
commit
7badc0ea1a
@ -61,8 +61,19 @@ const inpageProvider = new MetamaskInpageProvider(metamaskStream)
|
|||||||
// set a high max listener count to avoid unnecesary warnings
|
// set a high max listener count to avoid unnecesary warnings
|
||||||
inpageProvider.setMaxListeners(100)
|
inpageProvider.setMaxListeners(100)
|
||||||
|
|
||||||
|
let warnedOfAutoRefreshDeprecation = false
|
||||||
// augment the provider with its enable method
|
// augment the provider with its enable method
|
||||||
inpageProvider.enable = function ({ force } = {}) {
|
inpageProvider.enable = function ({ force } = {}) {
|
||||||
|
if (
|
||||||
|
!warnedOfAutoRefreshDeprecation &&
|
||||||
|
inpageProvider.autoRefreshOnNetworkChange
|
||||||
|
) {
|
||||||
|
console.warn(`MetaMask: MetaMask will soon stop reloading pages on network change.
|
||||||
|
If you rely upon this behavior, add a 'networkChanged' event handler to trigger the reload manually: https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.on(eventname%2C-callback)
|
||||||
|
Set 'ethereum.autoRefreshOnNetworkChange' to 'false' to silence this warning: https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.autorefreshonnetworkchange'
|
||||||
|
`)
|
||||||
|
warnedOfAutoRefreshDeprecation = true
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
inpageProvider.sendAsync({ method: 'eth_requestAccounts', params: [force] }, (error, response) => {
|
inpageProvider.sendAsync({ method: 'eth_requestAccounts', params: [force] }, (error, response) => {
|
||||||
if (error || response.error) {
|
if (error || response.error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user