Skip to content

Conversation

kushagrasarathe
Copy link
Contributor

@kushagrasarathe kushagrasarathe commented Apr 21, 2025

fixes TASK-9912

Summary by CodeRabbit

  • New Features

    • ENS names are now displayed in link preview images when available, providing a more user-friendly identifier instead of raw Ethereum addresses.
  • Style

    • Minor adjustment to the TransactionBadge component to remove an unnecessary trailing space after the status text.

Copy link

vercel bot commented Apr 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
peanut-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 21, 2025 7:00pm

Copy link
Contributor

coderabbitai bot commented Apr 21, 2025

Walkthrough

This 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 TransactionBadge component, removing an unnecessary trailing space after the transaction status.

Changes

File(s) Change Summary
src/app/api/preview-image/route.tsx Added ENS name resolution logic via a new resolveAddress function; updated the GET handler to use ENS names.
src/components/Global/TransactionBadge/index.tsx Removed a trailing space after the rendered status string in the TransactionBadge component.

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
Loading

Possibly related PRs

  • peanutprotocol/peanut-ui#793: Simplifies address formatting by removing ENS-related logic from a UI component; both PRs address address-to-name resolution but in different layers.

Poem

A hop and a skip, the code takes a chance,
To swap out addresses for names that can dance.
ENS now shines in the preview's bright light,
Making links look snazzy, clear, and just right.
With badges now trimmed, the display is neat—
This bunny’s delighted, the update’s a treat! 🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a26dbb and 2a3c444.

📒 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:

  1. Resolving the address to an ENS name when available
  2. Gracefully falling back to the original address when ENS resolution fails
  3. Passing the appropriate value to the LinkPreviewImg component

This enhancement improves the user experience by displaying human-readable ENS names in link previews instead of raw Ethereum addresses.

@kushagrasarathe kushagrasarathe merged commit edf5eaa into peanut-wallet-dev Apr 21, 2025
5 checks passed
@Hugo0 Hugo0 deleted the fix/link-preview-address-resolution branch July 3, 2025 18:24
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.

1 participant