-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provider.getNetwork() Always Returns the Same Network #495
Comments
If the network is switched in MetaMask, I think it should refresh the page, no? Or has this changed? |
MetaMask's auto refresh on network change can be disabled https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.autorefreshonnetworkchange I take advantage of this feature in my Scratch extension for Ethereum |
Looks like that my version of Metamask doesn’t reload the page. Well, it reloads Remix IDE, but doesn’t reload other DApps. Might be an issue of some kind of old APIs used there. Anyway, new/the majority of DApps doesn’t refresh at their own for me, which is expected. |
This is going to have to be an issue that is addressed at a higher level. The intention of a provider is that it is immutable; I wasn't planning to incorporate multi-honed providers until the Eth2.0 versions (since it will be required for cross-shard communications). The issue is that this is not actually possible to handle at this level. We will need to build a ProviderManager which will dispatch a new provider on changes, and block (or more likely add conditional transactions) to non-focused providers. The I will put more thought into the easiest way to support this sort of thing for now, but I do not think it will be easy. Likely, it will require an `ethereum.on("network", teardownExistingAppAndRebuildNewAppWithNewProvider(network));'... |
i want to know whith ethereum node when i use ethers.js. thanks |
I've added preliminary support for networks that can change. When creating a Provider that you wish to be able to change networks spontaneously, you must specify the network parameter as If the When supporting changing networks, you should probably call This will be published in the next beta release and I'd love some feedback. :) |
This has been published in 5.0.0-beta.191. Any feedback is welcome. :) |
I'm closing this issue now, but have started a new issue to keep all the discussion across these related issues together. If you have any comments, please feel free to chime in on #866. :) Thanks! :) |
Hello!
Looks like
provider.getNetwork()
(where provider isnew providers.Web3Provider(window.web3.currentProvider)
) always returns the same value, even if the network is switched in Metamask. I suppose this is the case of the problem (the same promise is returned for all calls).Thanks!
The text was updated successfully, but these errors were encountered: