Skip to content

fix(ensjs): getName should enforce normalization - #345

Merged
v1rtl merged 1 commit into
mainfrom
feature/web-533-ensjs-v4-getname-should-enforce-normalization
Jun 24, 2026
Merged

fix(ensjs): getName should enforce normalization#345
v1rtl merged 1 commit into
mainfrom
feature/web-533-ensjs-v4-getname-should-enforce-normalization

Conversation

@v1rtl

@v1rtl v1rtl commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

ENSjs v4 getName previously coerced the reverse-resolved name with normalise(), silently returning a name that differs from what reverse resolution actually returned. It now enforces normalization the same way viem's getEnsName does (wevm/viem#4756) and the same way ENSjs v5 already does: the name is returned only if it is already normalised, otherwise getName returns null.

Uses viem's normalize (viem/ens) under the hood for the check.

Closes WEB-533.

Changes

  • getName.ts:
    • Add an isNormalised helper using viem's normalize (returns false if normalize throws).
    • Replace coercion with a normalization match check in the success path (return raw name, or null).
    • Apply the same check in the ReverseAddressMismatch (allowMismatch: true) path.
  • getName.test.ts: add unit tests for both paths (unnormalised -> null, normalised -> unchanged).
  • Added a patch changeset.

Notes / design

  • Kept the existing encode/decode (generateFunction) architecture so getName.batch() and ENSjs's on-chain batch() multicall continue to work, and the return body ({ name, match, reverseResolverAddress, resolverAddress }) is unchanged.
  • viem's getEnsName itself was not used directly because it returns only string | null and is a monolithic action (no encode/decode), which would drop the match/resolver-address fields and break batching.

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
@v1rtl
v1rtl requested a review from svemat01 as a code owner June 24, 2026 15:50
@v1rtl
v1rtl merged commit cb44ae3 into main Jun 24, 2026
3 of 4 checks passed
@v1rtl
v1rtl deleted the feature/web-533-ensjs-v4-getname-should-enforce-normalization branch June 24, 2026 17:42
@sonarqubecloud

Copy link
Copy Markdown

@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
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