web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

[bug] Alternate ENS name resolution is completely ignored if you have an ENS identity

Open dirtycajunrice opened this issue 2 years ago • 5 comments

Link to minimal reproducible example

https://web3modal.justfixit.dev/

Summary

Alternate ENS name resolution is completely ignored if you have an ENS identity

Reproduction Steps:

  1. Obtain and set a primary ens name onENS Domains
  2. Obtain and set a primary ens name onAvvy Domains
  3. Click the chain button
  4. Switch to Avalanche chain by clicking it
  5. Close the modal
  6. Observe the profile name in the account button not respecting the chain ensResolver

Traced issue: Your profile name and image are managed by AccountController here: https://github.com/WalletConnect/web3modal/blob/8eeae0f948c05449aa3f10f435dec2e66b55939c/packages/core/src/controllers/AccountController.ts#L54-L60 setProfileName is called in syncProfile here: https://github.com/WalletConnect/web3modal/blob/8eeae0f948c05449aa3f10f435dec2e66b55939c/packages/wagmi/src/client.ts#L291-L309 which calls fetchIdentity here: https://github.com/WalletConnect/web3modal/blob/8eeae0f948c05449aa3f10f435dec2e66b55939c/packages/core/src/controllers/BlockchainApiController.ts#L15-L23

Doing this completely disrespects the ensResolver set in the chain config. It would be infinitely less opinionated if you had additional checks prior like... "am i on chainId 1", "If im on chainId 1, is the ensResolver config different from default wagmi?" etc.

List of related npm package versions

https://github.com/dirtycajunrice/web3modal-bug-examples-2023-10-21/blob/9269c51dfe95d7ec2a5e0efebd3fb3923c9b79f1/package.json#L11-L19

  "dependencies": {
    "@web3modal/wagmi": "^3.1.0",
    "next": "13.5.6",
    "react": "^18",
    "react-code-blocks": "^0.1.4",
    "react-dom": "^18",
    "viem": "^1.16.6",
    "wagmi": "^1.4.5"
  },

dirtycajunrice avatar Oct 21 '23 09:10 dirtycajunrice

@enesozturk This was not completed. It removed showing the ENS name on other networks other than main, but now literally just drops all ENS resolution on other chains because of the main chain check for syncProfile.

dirtycajunrice avatar Dec 29 '23 23:12 dirtycajunrice

Hey @dirtycajunrice, oh, isn't expected to not show profile data from the ENS when the active chain is not Ethereum? Since the ENS is on Ethereum chain? Wouldn't showing ENS profiles on different chains be wrong?

enesozturk avatar Dec 29 '23 23:12 enesozturk

@enesozturk No it is not expected. MANY other chains have ENS Resolvers native to their chain.

import { avalanche } from "wagmi/chains";

const avvyDomainsResolver: Address = "0x40b0DC99681Db9703939bd62D76F4D448ab0fdE";

const chains = [
  {
    ...avalanche,
    contracts: {
      ...avalanche.contracts,
      ensUniversalResolver: {
        address: avvyDomainsResolver,
      },
    },
  },
];

This configuration using wagmi directly works exactly as intended for avalanche.

dirtycajunrice avatar Dec 30 '23 00:12 dirtycajunrice

I'll reopen it as feature requests since this wasn't integrated yet

glitch-txs avatar Dec 30 '23 00:12 glitch-txs

@enesozturk @glitch-txs if we submit a PR that fixes this would you be willing to review and merge?

connorbode avatar May 11 '24 19:05 connorbode