Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lucashenning opened this issue Mar 3, 2022 · 3 comments
Labels
duplicate Duplicate of another issue.

Comments

@lucashenning
Copy link

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

@lucashenning lucashenning added the investigate Under investigation and may be a bug. label Mar 3, 2022
@ricmoo
Copy link
Member

ricmoo commented Mar 3, 2022

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. :)

@ricmoo
Copy link
Member

ricmoo commented Aug 19, 2022

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

@xwartz
Copy link

xwartz commented Sep 27, 2022

@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
Labels
duplicate Duplicate of another issue.
Projects
None yet
Development

No branches or pull requests

3 participants