cowprotocol / cowswap

🐮 CowSwap: First CoW Protocol UI
https://swap.cow.fi/
GNU General Public License v3.0
118 stars 88 forks source link

[widget, standalone] impossible to change a network #4870

Open elena-zh opened 1 week ago

elena-zh commented 1 week ago
  1. Open the widget configurator
  2. Select Standalone mode
  3. Connect to MM wallet
  4. Open MM and change a network from there

AR:

  1. the network is not changed: balances are still shown from a previous network.
  2. However, the configurator itself shows the newly selected network.
  3. The new network is not picked when disconnect-reconnect a wallet again chain change chain

ER: the network should be changed.

shoom3301 commented 5 days ago

I've investigated the case and found out that it's a Metamask's bug...

Key point - Metamask browser extension does not send events (e.g. chanChanged) to iframes.

How to check that:

  1. Try using Metamask mobile via WalletConnect change network in the wallet and it should be updated in the widget)
  2. Cheat the Metamask browser extension:

It happens because in the 5th step we make Metamask think that current active tab is swap.cow.fi and it starts sending events to the widget iframe (which is actually swap.cow.fi). Unfortunately I don't see any ways how we can improve this on our side :disappointed: The only way is to report the problem to Metamask and wait.