Skip to content

feat: add Solscan wallet analytics tools - #250

Open
Florcitaq wants to merge 3 commits into
NeurProjects:mainfrom
Florcitaq:solscan-integration-47
Open

feat: add Solscan wallet analytics tools#250
Florcitaq wants to merge 3 commits into
NeurProjects:mainfrom
Florcitaq:solscan-integration-47

Conversation

@Florcitaq

@Florcitaq Florcitaq commented Jul 1, 2026

Copy link
Copy Markdown

Closes #47.

Summary

  • Adds Solscan-backed wallet analytics tools for account transactions, DeFi activities, and portfolio lookup.
  • Renders transaction and DeFi activity tables with Solscan links, plus portfolio summary and JSON details.
  • Registers the tools in the DeFi toolset and documents SOLSCAN_API_KEY / SOLSCAN_BASE_URL.

Verification

  • prettier --check .env.example src/ai/providers.tsx src/ai/solana/solscan.tsx src/server/actions/solscan.ts
  • prisma generate
  • sc --noEmit --pretty false currently reaches an existing install limitation: solana-agent-kit is unavailable because the git-hosted dependency build scripts are blocked unless allowlisted; no Solscan files are reported in the type errors.

Summary by CodeRabbit

  • New Features
    • Added Solscan-backed wallet transactions, DeFi activity, and portfolio data retrieval.
    • Introduced Solscan result views in the app, including a transactions table, DeFi activities table, and a portfolio summary card.
    • Expanded AI tool configuration to support Solscan analytics and related Solana DeFi capabilities.
  • Bug Fixes
    • Improved data validation and error handling for Solscan responses, with consistent error display in the UI.
  • Chores
    • Updated the sample environment configuration with required Solscan settings (SOLSCAN_API_KEY, SOLSCAN_BASE_URL).

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@Florcitaq is attempting to deploy a commit to the Neur Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 029a64de-23a3-4e7d-8560-31447538f496

📥 Commits

Reviewing files that changed from the base of the PR and between a8a7765 and 3e295f5.

📒 Files selected for processing (1)
  • src/server/actions/solscan.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/server/actions/solscan.ts

📝 Walkthrough

Walkthrough

Adds Solscan analytics support with server-side API wrappers, AI tools that render transactions/DeFi/portfolio data, registry wiring, and new environment variables.

Changes

Solscan Integration

Layer / File(s) Summary
Solscan API client and typed wrappers
src/server/actions/solscan.ts, .env.example
Adds Solscan base URL and API key configuration, response validation, typed response interfaces, a generic fetch helper, and cached account transactions, DeFi activities, and portfolio wrappers.
Solscan AI tools and UI renderers
src/ai/solana/solscan.tsx
Adds timestamp, link, and error helpers; transactions, DeFi activities, and portfolio renderers; response validation; and the exported Solscan tool definitions with Zod-validated parameters and execute/render logic.
Tool registry and toolset wiring
src/ai/providers.tsx
Imports Solscan tools, includes them in defaultTools, and adds them to the defiTools toolset contents and description.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding Solscan wallet analytics tools.
Linked Issues check ✅ Passed The PR adds Solscan-backed transaction, DeFi activity, and portfolio tools with UI rendering, matching the issue's requirements.
Out of Scope Changes check ✅ Passed The changes stay focused on Solscan integration, tool registration, and related config/docs with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
src/server/actions/solscan.ts (2)

87-91: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

solscanResponseSchema.parse can throw a raw ZodError that propagates to the user-facing error message.

If Solscan returns an unexpected shape, .parse() throws a ZodError; since it's an Error instance, callers in src/ai/solana/solscan.tsx (error instanceof Error ? error.message : ...) will surface the verbose Zod validation message directly to the end user instead of a clean fallback message.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/server/actions/solscan.ts` around lines 87 - 91, The Solscan response
parsing in solscanResponseSchema.parse is allowed to throw a raw ZodError, which
then bubbles up as the user-facing message. Update the parsing flow in the
Solscan action to catch schema validation failures and convert them into a clean
fallback error before throwing, so callers like the Solscan UI path see a
generic “request failed” message instead of the verbose Zod details. Use the
existing parsed handling in the Solscan action to keep the error contract
consistent.

96-153: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

cache() won’t dedupe these calls as written. React.cache keys by argument identity, and these call sites pass a fresh object literal on each invocation, so repeated calls miss unless the exact same object instance is reused. Switch these helpers to primitive parameters or reuse a stable argument object if request-level memoization is the goal.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/server/actions/solscan.ts` around lines 96 - 153, `cache()` is not
deduping these Solscan helpers because each call passes a new object literal, so
repeated requests miss memoization. Update the `getSolscanAccountTransactions`,
`getSolscanAccountDefiActivities`, and `getSolscanAccountPortfolio` wrappers to
use stable primitive arguments (or otherwise reuse a shared argument object) so
`cache` can key them consistently and dedupe identical calls.
src/ai/solana/solscan.tsx (1)

200-206: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

renderResult casts raw without runtime validation.

raw as { success: boolean; data?: T; error?: string } blindly trusts the shape returned by execute. Since execute always constructs this shape internally, the risk is low, but a lightweight Zod check would guard against future drift between execute return shapes and render expectations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/ai/solana/solscan.tsx` around lines 200 - 206, `renderResult` in
`solscan.tsx` is trusting `raw` via a type cast without validating the runtime
shape. Add a lightweight Zod schema (or equivalent runtime guard) inside
`renderResult` to validate the `{ success, data, error }` structure before
accessing it, and only call the `render` callback when the parsed value is
valid; otherwise fall back to `ErrorCard`. Use `renderResult` and the `execute`
result shape as the key symbols to update.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/server/actions/solscan.ts`:
- Around line 96-112: The `getSolscanAccountTransactions` helper is clamping
`limit` to a minimum of 10, which overrides valid smaller caller values. Update
the `Math.max(10, Math.min(limit, 40))` logic in `getSolscanAccountTransactions`
so it preserves requested limits down to the lower bound accepted by the
caller/schema, while still enforcing the upper cap of 40. Keep the change
localized to this function and ensure the `limit` defaulting behavior remains
intact.
- Around line 75-85: The Solscan request in the fetch flow has no timeout, so a
hanging upstream call can block callers indefinitely. Update the outbound
request in the Solscan action to use an AbortController or equivalent timeout
wrapper around the fetch call, and make sure the timeout is applied alongside
the existing next revalidate and headers options. Keep the existing response
handling in the same flow so the timeout failure is surfaced clearly from the
Solscan request path.

---

Nitpick comments:
In `@src/ai/solana/solscan.tsx`:
- Around line 200-206: `renderResult` in `solscan.tsx` is trusting `raw` via a
type cast without validating the runtime shape. Add a lightweight Zod schema (or
equivalent runtime guard) inside `renderResult` to validate the `{ success,
data, error }` structure before accessing it, and only call the `render`
callback when the parsed value is valid; otherwise fall back to `ErrorCard`. Use
`renderResult` and the `execute` result shape as the key symbols to update.

In `@src/server/actions/solscan.ts`:
- Around line 87-91: The Solscan response parsing in solscanResponseSchema.parse
is allowed to throw a raw ZodError, which then bubbles up as the user-facing
message. Update the parsing flow in the Solscan action to catch schema
validation failures and convert them into a clean fallback error before
throwing, so callers like the Solscan UI path see a generic “request failed”
message instead of the verbose Zod details. Use the existing parsed handling in
the Solscan action to keep the error contract consistent.
- Around line 96-153: `cache()` is not deduping these Solscan helpers because
each call passes a new object literal, so repeated requests miss memoization.
Update the `getSolscanAccountTransactions`, `getSolscanAccountDefiActivities`,
and `getSolscanAccountPortfolio` wrappers to use stable primitive arguments (or
otherwise reuse a shared argument object) so `cache` can key them consistently
and dedupe identical calls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6cbc69d8-a7c4-4dda-9a54-f15f5a2690a5

📥 Commits

Reviewing files that changed from the base of the PR and between 2713bd4 and 94379f3.

📒 Files selected for processing (4)
  • .env.example
  • src/ai/providers.tsx
  • src/ai/solana/solscan.tsx
  • src/server/actions/solscan.ts

Comment thread src/server/actions/solscan.ts Outdated
Comment thread src/server/actions/solscan.ts
@Florcitaq

Copy link
Copy Markdown
Author

Addressed the CodeRabbit review in �8a7765:

  • Added an AbortController timeout to outbound Solscan requests.
  • Preserved transaction limit values down to 1 while keeping the 40 item cap.
  • Converted Solscan response schema failures into a clean request failure.
  • Switched cached Solscan helpers to primitive arguments for stable cache() keys.
  • Added lightweight runtime validation for rendered tool result envelopes.

Verification:

  • prettier --check src/server/actions/solscan.ts src/ai/solana/solscan.tsx
  • git diff --check
  • sc --noEmit --pretty false still only reports the existing solana-agent-kit install/type resolution issue in src/lib/solana/PrivyEmbeddedWallet.ts and src/server/actions/ai.ts.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/server/actions/solscan.ts`:
- Around line 88-90: The non-2xx handling in the Solscan request path is
dropping the API’s JSON error payload and only throwing the status code. Update
the response handling in the Solscan action flow so the code in the
request/parse block reads the JSON body when response.ok is false, then prefers
errors.message from the Solscan payload in the thrown Error. Keep the existing
request flow intact and ensure the thrown message still falls back to the HTTP
status if no API message is present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: abc40c9f-5db4-460f-b761-87fbe138ebdc

📥 Commits

Reviewing files that changed from the base of the PR and between 94379f3 and a8a7765.

📒 Files selected for processing (2)
  • src/ai/solana/solscan.tsx
  • src/server/actions/solscan.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/ai/solana/solscan.tsx

Comment thread src/server/actions/solscan.ts
@Florcitaq

Copy link
Copy Markdown
Author

Addressed the follow-up CodeRabbit comment in 3e295f5:

  • The Solscan fetch path now reads the JSON response body before non-2xx handling.
  • For Solscan-shaped error payloads, it prefers errors.message and falls back to Solscan request failed with when the body is missing or malformed.

Verification:

  • prettier --check src/server/actions/solscan.ts src/ai/solana/solscan.tsx
  • git diff --check
  • sc --noEmit --pretty false still only reports the existing solana-agent-kit install/type resolution issue in src/lib/solana/PrivyEmbeddedWallet.ts and src/server/actions/ai.ts.

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.

Solscan Integration

1 participant