MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.99k stars 4.91k forks source link

[Bug]: Wallet API - When I'm conneting to the test dapp for the first time, I'm switched to Mainnet automatically, despite not having this network selected #27891

Open seaona opened 1 week ago

seaona commented 1 week ago

Describe the bug

When I'm conneting to the test dapp for the first time, I'm switched to Mainnet automatically, despite not having this network selected. This is not happening in current production, but it has changed recently (happening on develop, meaning it will appear in 12.7.0). This also makes fail the snaps test very frequently for this reason, see here.

Expected behavior

Preserve my selected network, like we did before?

Screenshots/Recordings

See current behaviour (switched automatically) and production behaviour (preserving my selected network)

https://github.com/user-attachments/assets/59e60695-1256-453b-89ec-aac5ce3b0e23

Steps to reproduce

  1. Select localhost network
  2. Go to the test dapp
  3. Click connect
  4. Connect
  5. See you are switched to Mainnet automatically

Error messages or log output

No response

Detection stage

On the development branch

Version

12.7.0

Build type

None

Browser

Chrome

Operating system

Linux

Hardware wallet

No response

Additional context

No response

Severity

No response

jiexi commented 1 week ago

In the first part of the reproduction when you are connecting, only mainnet and linea are selected. For ganache to remain the selected network for the dapp after connection, ganache must also be selected at the time of connection

seaona commented 1 week ago

hey @jiexi , from the slack thread, the solution should be:

Feels like an easy win to add the currently selected network to the list of preselected networks. Also makes it seem less like a regression / more backwards compatible