metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

[Bug]: Multichain - Resolved ENS address not updated after switching networks

Open seaona opened this issue 1 year ago • 2 comments

Describe the bug

Problem: whenever I initiate a transaction, if I add an ENS recipient and then I switch networks, I can see how the recipient address with the ENS resolution is not updated. I.e. You can try adding an ENS for Goerli, see that it resolves correctly and then switching to Sepolia (we do not support ENS resolution in Sepolia at the moment). You'll see that the recipient still shows the ENS and its resolved address from Goerli. Also notice that ENS can resolve to different addresses in different networks

Expected behavior

We should update the recipient // Clear the ENS resolution or re-do it again and/or display a warning for the user?

Screenshots/Recordings

https://github.com/MetaMask/metamask-extension/assets/54408225/032a0a82-2eb7-4d28-8252-c5c1d270f101

Steps to reproduce

  1. Select Goerli network
  2. Start a tx
  3. Add an ENS as recipient ie vitalik.eth
  4. See how address is resolved correctly
  5. Change to Sepolia (ENS not suported there)
  6. See how we continue to see vitalik.eth and its resolved address

Error messages or log output

No response

Version

develop - with multichain flag

Build type

None

Browser

Chrome

Operating system

Linux

Hardware wallet

No response

Additional context

No response

Severity

No response

seaona avatar Feb 14 '24 09:02 seaona

@Gudahtt pointed out that we have a library, ethereum-ens-network-map, to help determine ENS support:

/* from: ui/ducks/domains.js */

// import
import ensNetworkMap from 'ethereum-ens-network-map';

// usage
const chainIdInt = parseInt(chainId, 16);
const ensAddress = ensNetworkMap[chainIdInt.toString()];
const networkIsSupported = Boolean(ensAddress);

darkwing avatar Feb 14 '24 21:02 darkwing

Good point! The ENS resolution should be run again after switching networks, to update the resolution (either if it resolved or if it's not supported). I.e. vitalik.eth should resolve to:

  • 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 in Mainnet
  • 0xFD50b031E778fAb33DfD2Fc3Ca66a1EeF0652165 in Goerli
  • no supported` in Sepolia or other nets after every network switch while on the Send flow

seaona avatar Feb 16 '24 08:02 seaona

Dev build from git id 23a9982, Chrome.

  1. ENS is not displayed on networks without ENS support - works as expected;
  2. The same address is still applied to a different network when switching;
  3. When switching back to Eth mainnet recipient field ('To') doesn't display ENS name which was visible before - not sure if this is expected behavior.

https://github.com/MetaMask/metamask-extension/assets/104780023/462ee829-e5b2-4c3b-a04d-672c3eccfa2d

@darkwing

sleepytanya avatar Mar 01 '24 18:03 sleepytanya