-
Notifications
You must be signed in to change notification settings - Fork 13
fix: resolve to ens names of an address if available in link previews #811
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
fix: resolve to ens names of an address if available in link previews #811
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis update introduces ENS name resolution to the preview image API route. When a request is made to generate a link preview image, the backend now attempts to resolve any provided Ethereum address to its corresponding ENS name using an external API. If an ENS name is found, it is displayed in the preview image instead of the raw address. Additionally, a minor adjustment is made to the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Route
participant JustAnName_API
participant LinkPreviewImg
Client->>API_Route: GET /api/preview-image?address=0x...
API_Route->>API_Route: validate address format
API_Route->>JustAnName_API: Fetch ENS subnames for address
JustAnName_API-->>API_Route: Return ENS subnames (if any)
API_Route->>API_Route: Select ENS name or fallback to address
API_Route->>LinkPreviewImg: Render preview image with ENS or address
LinkPreviewImg-->>API_Route: ImageResponse
API_Route-->>Client: Return preview image
Possibly related PRs
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/app/api/preview-image/route.tsx (1)
8-43
: Well-implemented ENS resolution utility function.The
resolveAddress
function is a well-structured implementation that:
- Validates address format before making API calls
- Makes proper use of type checking and error handling
- Safely navigates nested response properties
- Includes helpful comments explaining the logic
Consider these potential improvements:
- Move the API endpoint URL to an environment variable or config file for easier maintenance
- Add request timeout handling for the fetch operation
- Implement a simple caching mechanism to avoid redundant API calls for recently resolved addresses
- const response = await fetch(`https://api.justaname.id/ens/v1/subname/address?address=${address}&chainId=1`, { + const ENS_API_URL = process.env.ENS_API_URL || 'https://api.justaname.id/ens/v1/subname/address' + const response = await fetch(`${ENS_API_URL}?address=${address}&chainId=1`, {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/app/api/preview-image/route.tsx
(2 hunks)src/components/Global/TransactionBadge/index.tsx
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/app/api/preview-image/route.tsx (1)
src/components/Global/ImageGeneration/LinkPreview.tsx (1)
LinkPreviewImg
(29-115)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Deploy-Preview
🔇 Additional comments (2)
src/components/Global/TransactionBadge/index.tsx (1)
32-32
: Whitespace cleanup: Removed trailing space after status text.The removal of the trailing space after the lowercase status text improves the rendering consistency of the transaction badge component.
src/app/api/preview-image/route.tsx (1)
58-74
: Successful integration of ENS resolution into preview image generation.The changes correctly implement the PR objective by:
- Resolving the address to an ENS name when available
- Gracefully falling back to the original address when ENS resolution fails
- Passing the appropriate value to the
LinkPreviewImg
componentThis enhancement improves the user experience by displaying human-readable ENS names in link previews instead of raw Ethereum addresses.
fixes TASK-9912
Summary by CodeRabbit
New Features
Style