Skip to content

Fix: ENS getEnsName() should enforce normalization#4756

Open
adraffy wants to merge 1 commit into
wevm:mainfrom
adraffy:fix/ens-reverse-norm
Open

Fix: ENS getEnsName() should enforce normalization#4756
adraffy wants to merge 1 commit into
wevm:mainfrom
adraffy:fix/ens-reverse-norm

Conversation

@adraffy

@adraffy adraffy commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

ENSIP-23 states:

If the primary name is unnormalized, eg. normalize("Nick.eth") != "nick.eth", then name and resolver are invalid.


  • changed getEnsName() to return null if not normalized
  • added test with unnormalized name
  • added test with offchain reverse resolver

  • Replace ENS names with official test cases

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@adraffy is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 13bdc70

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/viem@4756

commit: 13bdc70

@adraffy adraffy changed the title Fix: ENS getEnsName should enforce normalization Fix: ENS getEnsName() should enforce normalization Jun 23, 2026
type ReadContractParameters,
readContract,
} from '../public/readContract.js'
import { normalize } from '../../ens/index.js'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would it take for ens-normalize to be much lighter in terms of bundle size? :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an async context, switch to dynamic import and guard it with a regex that covers common cases?

Now that LLMs are pretty good, I could revisit the normalization compression logic.

@adraffy adraffy Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, can you tell me what minimum JS engine you're supporting? There is an approach that leverages regex \p.

The actual library logic is extremely small — nearly all of the size is the compressed Unicode data.


I've been contemplating making a ens-normalize.ts variant since the current library is basically the research version and all of the other language ports are clean and typed.

pull Bot pushed a commit to Hawthorne001/ensjs-v3 that referenced this pull request Jun 24, 2026
getName previously coerced the reverse-resolved name via normalise(),
silently returning a different name than what was resolved. It now uses
viem's normalize() to verify the name is already normalised and returns
null otherwise, matching viem's getEnsName (wevm/viem#4756) and v5.

Applies to both the match and allowMismatch paths. Preserves the
encode/decode batching API and the existing return body.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants