Open Number000001 opened 3 weeks ago
Hey @Number000001 thanks for your report here. We have a fix for this issue that is rolling out with version 11.16.7
Hey @Number000001 thanks for your report here. We have a fix for this issue that is rolling out with version 11.16.7
Thank you for your reply.
However, for users who have not updated to version 11.16.7, if they change the network after connecting to DApps, the user still cannot obtain the network ID, so this is not a complete solution.
After investigating, I found that even if a user has not updated to version 11.16.7, after connecting MetaMask to DApps, only “window.ethereum.networkVersion” can get the changed network ID.
However, there is a warning that “window.ethereum.networkVersion” is scheduled to be deleted, so please let us know if there is an alternative.
Please do not delete “window.ethereum.networkVersion” if possible.
Thank you.
Describe the bug
Can someone help me? I'm having trouble with "await web3.eth.net.getId();". If I connect MetaMask to a DApps, even if I change the network, will "await web3.eth.net.getId();" only return the network ID selected when I connected to the DApps?
If I have not connected my MetaMask account to the DApps, when I change the network, "await web3.eth.net.getId();" returns the changed network ID, but if I connect MetaMask to the DApps, "await web3.eth.net.getId();" returns only the network ID selected when connecting to the DApps.
Is there a way to get the changed network ID even after connecting MetaMask to the DApps, other than "window.ethereum.on('chainChanged', async (chainId) =>"?
Expected behavior
Is there a way, even after logging into MetaMask, to actively retrieve the updated network ID, similar to await web3.eth.net.getId();, when the network is changed?
Screenshots/Recordings
No response
Steps to reproduce
1.Log in to MetaMask in the Dapp. 2.Change the network. 3.Unable to retrieve the updated network ID using const currentNetworkId = await web3.eth.net.getId();, only returns the network ID at the time of login.
Error messages or log output
No response
Version
11.16.5
Build type
None
Browser
Chrome
Operating system
Windows
Hardware wallet
No response
Additional context
No response
Severity
No response