-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
enhancementNew feature or improvement.New feature or improvement.fixed/completeThis Bug is fixed or Enhancement is complete and published.This Bug is fixed or Enhancement is complete and published.v6Issues regarding v6Issues regarding v6
Description
Ethers Version
6.10
Search Terms
dnsEncode, ccip, ensip-10, wrapper
Describe the Problem
dnsEncode()
throws on >63
but should throw for >255
. This causes longer names to be unreachable via CCIP and can't decode NameWrapper names()
function.
Possibly the function needs renamed if this was used for other purposes.
Example:
// throws "invalid DNS encoded entry; length exceeds 63 bytes"
ethers.dnsEncode('a'.repeat(64));
Suggested implementation:
function dnsEncode(name: string): string
const MAX_LABEL = 255;
let v = ensNameSplit(name).map(u => {
if (u.length > MAX_LABEL) throw new Error(`label too long: ${u.length} > ${MAX_LABEL}`);
return u;
});
v.push(0);
return hexlify(v);
}
You can also massively simplify ensNameSplit()
:
function ensNameSplit(name: string): Array<Uint8Array> {
const norm = ensNormalize(name); // empty string or all labels nonempty
return norm ? norm.split('.').map(toUtf8Bytes) : [];
}
Code Snippet
No response
Contract ABI
No response
Errors
invalid DNS encoded entry; length exceeds 63 bytes
Environment
node.js (v12 or newer)
Environment (Other)
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or improvement.New feature or improvement.fixed/completeThis Bug is fixed or Enhancement is complete and published.This Bug is fixed or Enhancement is complete and published.v6Issues regarding v6Issues regarding v6