blocknative / web3-onboard

Client library to onboard users to web3 apps
https://onboard.blocknative.com/
MIT License
827 stars 486 forks source link

Error on @web3-onboard/react ENS resolution #1774

Open gbonumore opened 1 year ago

gbonumore commented 1 year ago

Current Behavior

Using @web3-onboard/react, ENS name and avatar resolution is broken.

Expected Behavior

It is possible to retrieve ENS name and avatar. The issue comes from the version of ethers.js used in which method getContentHash() doesn't recognize IPNS, which was introduced on a later version of ethers.

Steps To Reproduce

Error can be seen here: https://onboard.blocknative.com/examples/connect-wallet while connecting with a wallet which has a ENS name which gets resolved in a content hash data starting with 0xe5010172.

What package is effected by this issue?

@web3-onboard/react

Is this a build or a runtime issue?

Runtime

Package Version

2.8.5

Node Version

No response

What browsers are you seeing the problem on?

Chrome

Relevant log output

// Patching the relevant piece of code with this in order to make it work for now.

const ipfs = hexBytes.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);
    if (ipfs) {
        const scheme = (ipfs[1] === "e3010170") ? "ipfs": "ipns";
        const length = parseInt(ipfs[4], 16);
        if (ipfs[5].length === length * 2) {
            return `${ scheme }:/\/${ Base58.encode("0x" + ipfs[2])}`;
        }
    }

Anything else?

Screenshot 2023-06-14 at 09 22 51

Sanity Check

Adamj1232 commented 1 year ago

@gbonumore thanks for reporting this issue. I am a little unclear, are you thinkingwe need to update our version of ethers to return the updated IPNS? Does this error happen when connecting a wallet or at some other point? Are you seeing the same issue on our demo here? I am able to connect my wallet and see my avatar and ens at the demo notes above on Goerli. I also dont get an error when connecting to onboard.blocknative.com with an Eth account and associated avatar and ens.

gbonumore commented 1 year ago

I made this a little unclear, my ens domain contains a content hash record which starts with ipns:// (I am using eth.limo to serve a dapp through my ens handle, myhandle.eth.limo, which points to the ipns in question) That's why it matches ipns scheme, 0xe5010172, which was not supported on the ethers.js version used on this library. If I of course remove that contenthash the resolver wouldn't break. Let me know if further informations are needed.