Skip to content

provider.getResolver(name) not working for unicode characters (valid ENS names) #2754

Closed
@lucashenning

Description

@lucashenning

Describe the bug
The provider.getResolver(name) function does not work with all unicode characters. According to the definition of ENS names, unicode characters are valid. The function should resolve names including unicode characters, e.g. emoticons like 👋

Reproduction steps

const r1 = await provider.getResolver("foo.eth"); // this works
console.log(r1?.address); // output: 0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41
const r2 = await provider.getResolver("🚀🚀🚀.eth"); // this doesn't work, throws error
console.log(r2?.address); 

Stack Trace

(node:39562) UnhandledPromiseRejectionWarning: Error: STRINGPREP_CONTAINS_UNASSIGNED
    at /ens-test/node_modules/@ethersproject/strings/src.ts/idna.ts:193:19
    at Array.forEach (<anonymous>)
    at nameprep (/ens-test/node_modules/@ethersproject/strings/src.ts/idna.ts:191:11)
    at namehash (/ens-test/node_modules/@ethersproject/hash/src.ts/namehash.ts:40:43)
    at InfuraProvider.<anonymous> (/ens-test/node_modules/@ethersproject/providers/src.ts/base-provider.ts:1701:43)
    at step (/ens-test/node_modules/@ethersproject/providers/lib/base-provider.js:48:23)
    at Object.next (/ens-test/node_modules/@ethersproject/providers/lib/base-provider.js:29:53)
    at fulfilled (/ens-test/node_modules/@ethersproject/providers/lib/base-provider.js:20:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Affected function

async _getResolver(name: string, operation?: string): Promise<string> {
if (operation == null) { operation = "ENS"; }
const network = await this.getNetwork();
// No ENS...
if (!network.ensAddress) {
logger.throwError(
"network does not support ENS",
Logger.errors.UNSUPPORTED_OPERATION,
{ operation, network: network.name }
);
}
try {
// keccak256("resolver(bytes32)")
const addrData = await this.call({
to: network.ensAddress,
data: ("0x0178b8bf" + namehash(name).substring(2))
});
return this.formatter.callAddress(addrData);
} catch (error) {
// ENS registry cannot throw errors on resolver(bytes32)
}
return null;
}

The error seems to be generated here:

// Prohibit Unassigned Code Points (Table A.1)
codes.forEach((code) => {
if (_nameprepTableA1(code)) {
throw new Error("STRINGPREP_CONTAINS_UNASSIGNED");
}
});

Environment:

  • node v14.17.1
  • ethers v5.5.4

Search Terms
ENS name resolution resolve unicode characters

Related issues

Activity

ricmoo

ricmoo commented on Mar 3, 2022

@ricmoo
Member

This is a known issue, and is pending the updated stringprep-like normalization from ENS regarding UTF-8 joiners.

Closing as a duplicate of #2376, which is being kept updated. :)

added
duplicateDuplicate of another issue.
and removed
investigateUnder investigation and may be a bug.
on Mar 3, 2022
ricmoo

ricmoo commented on Aug 19, 2022

@ricmoo
Member

This has been address in v5.7.0. See the related issue for details.

xwartz

xwartz commented on Sep 27, 2022

@xwartz

@ricmoo v5.7.0 still has problems parsing ens with ZWSP, such as vitalik‌.eth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateDuplicate of another issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ricmoo@xwartz@lucashenning

        Issue actions

          provider.getResolver(name) not working for unicode characters (valid ENS names) · Issue #2754 · ethers-io/ethers.js