[Bug]: Multichain - Resolved ENS address not updated after switching networks
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
- Select Goerli network
- Start a tx
- Add an ENS as recipient ie
vitalik.eth - See how address is resolved correctly
- Change to Sepolia (ENS not suported there)
- See how we continue to see
vitalik.ethand 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
@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);
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:
-
0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045in Mainnet -
0xFD50b031E778fAb33DfD2Fc3Ca66a1EeF0652165in Goerli - no supported` in Sepolia or other nets after every network switch while on the Send flow
Dev build from git id 23a9982, Chrome.
- ENS is not displayed on networks without ENS support - works as expected;
- The same address is still applied to a different network when switching;
- 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