Skip to content

fix: resolve ENS reverse records via viem Universal Resolver#679

Merged
rickstaa merged 1 commit into
mainfrom
fix/ens-viem-reverse-resolution
May 25, 2026
Merged

fix: resolve ENS reverse records via viem Universal Resolver#679
rickstaa merged 1 commit into
mainfrom
fix/ens-viem-reverse-resolution

Conversation

@rickstaa
Copy link
Copy Markdown
Member

@rickstaa rickstaa commented May 25, 2026

Problem

Orchestrators who set their ENS primary name via the current ENS flow (ENSIP-19 / L2 primary names) show only their address on the profile — no ENS name or avatar.

Cause

Reverse resolution used ethers v5 lookupAddress, which only reads the legacy addr.reverse registry node. Names set through the modern flow live elsewhere, so resolution returned null.

Fix

Switch getEnsForAddress / getEnsForVotes to viem's getEnsName / getEnsText on the existing l1PublicClient, whose Universal Resolver resolves both legacy and modern reverse records. Avatar presence now uses the avatar text record (the image proxy already resolves the image).

Summary by CodeRabbit

  • Bug Fixes
    • Improved ENS address validation and data resolution for more reliable address lookups
    • Enhanced ENS text record retrieval (including descriptions, URLs, and social profiles)
    • Refined avatar field handling for better data accuracy

Review Change Stack

ethers v5 lookupAddress only reads the legacy addr.reverse node, so
orchestrators who set their ENS primary name via the modern (ENSIP-19/L2)
flow showed no name/avatar on their profile. Switch getEnsForAddress and
getEnsForVotes to viem getEnsName/getEnsText, whose Universal Resolver
honors both legacy and modern reverse records.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 25, 2026 14:48
@rickstaa rickstaa requested a review from ECWireless as a code owner May 25, 2026 14:48
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment May 25, 2026 2:50pm

Request Review

@rickstaa rickstaa merged commit 4f63efa into main May 25, 2026
10 of 11 checks passed
@rickstaa rickstaa deleted the fix/ens-viem-reverse-resolution branch May 25, 2026 14:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates ENS reverse resolution in the Explorer API to support modern ENS primary names (ENSIP-19 / L2 primary names) by switching from ethers v5 reverse lookup to viem’s Universal Resolver-backed ENS helpers.

Changes:

  • Replace ethers lookupAddress usage with l1PublicClient.getEnsName for reverse resolution.
  • Fetch ENS text records (description, url, socials, avatar) via l1PublicClient.getEnsText using a normalized name.
  • Update avatar presence logic to rely on the avatar text record.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/api/ens.ts
Comment on lines 80 to 84
url,
twitter,
github,
avatar: avatar?.url ? `/api/ens-data/image/${name}` : null,
avatar: avatar ? `/api/ens-data/image/${name}` : null,
};
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9c7dd908-3519-4fd9-90e8-80e242d79d15

📥 Commits

Reviewing files that changed from the base of the PR and between 371ac2e and 45e61de.

📒 Files selected for processing (1)
  • lib/api/ens.ts

📝 Walkthrough

Walkthrough

The ENS module migrates name resolution from the deprecated l1Provider to l1PublicClient, adding input validation via isAddress and name normalization. Both getEnsForAddress and getEnsForVotes now safely resolve ENS names only for valid addresses, with normalized names used for fetching text records.

Changes

ENS API Migration

Layer / File(s) Summary
Import updates and validation helpers
lib/api/ens.ts
Module imports switch from l1Provider to l1PublicClient, and isAddress and normalize are added for input validation and name normalization.
getEnsForAddress refactoring
lib/api/ens.ts
ENS name is fetched via l1PublicClient.getEnsName only when address passes isAddress validation, normalized, and used to fetch text records. Avatar field logic updated to check the fetched avatar value directly.
getEnsForVotes refactoring
lib/api/ens.ts
ENS name resolution now uses l1PublicClient.getEnsName with isAddress validation, replacing l1Provider.lookupAddress.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers Problem, Cause, and Fix clearly but omits required template sections like Type of Change, Changes Made, Testing, and Impact/Risk assessments. Add missing sections from the template: mark the change type (fix), list specific changes (switch to viem's getEnsName/getEnsText, update imports, change avatar logic), document testing performed, and include Impact/Risk analysis.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: switching to viem's Universal Resolver for ENS reverse resolution instead of ethers v5's lookupAddress.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ens-viem-reverse-resolution

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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