Skip to content

feat(scan): migrate to agentcash-router, update integration prompt#686

Merged
zdql merged 22 commits intomainfrom
shafu/migrate-to-agentcash-router
Mar 12, 2026
Merged

feat(scan): migrate to agentcash-router, update integration prompt#686
zdql merged 22 commits intomainfrom
shafu/migrate-to-agentcash-router

Conversation

@shafu0x
Copy link
Copy Markdown
Contributor

@shafu0x shafu0x commented Mar 5, 2026

Summary

  • Migrate all 13 /api/data/* route handlers from x402-next proxy middleware to @agentcash/router fluent builder API
  • Migrate /api/send to the router with dynamic pricing (.paid((body) => body.amount.toString())) and dynamic payTo (payment goes to the recipient address in the body)
  • Register/register-origin routes use .siwx() (wallet identity, no payment)
  • All other data routes use .paid() with static pricing via the router
  • Add /openapi.json endpoint auto-generated from the route registry — no more manual spec patching
  • Add .path() to dynamic-segment routes so OpenAPI paths render correctly ({address}, {id})
  • Add barrel file (routes-barrel.ts) to ensure all routes register before discovery endpoints run
  • CORS handled per-route via withCors wrapper instead of middleware
  • Add mppx to serverExternalPackages to fix Turbopack build with @agentcash/router
  • Delete proxy.ts (old x402 middleware) and extensions.ts (only used by proxy)
  • Update agent integration prompt: add agentcash MCP install step, use fetch_with_auth for register-origin (SIWX auth required)
  • Upgrade viem 2.44.1 → 2.47.0 (mppx imports tempo from viem/chains, which was added in viem 2.47.0)

Breaking changes

  • POST /api/send now expects amount, address, and chain in the JSON request body instead of query parameters. Callers must update from ?amount=1&address=0x...&chain=base to { "amount": 1, "address": "0x...", "chain": "base" }.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 5, 2026

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

Project Deployment Actions Updated (UTC)
x402scan Ready Ready Preview, Comment Mar 12, 2026 3:02am

@shafu0x shafu0x changed the title feat(scan): migrate data routes to agentcash-router ues agentcash-router Mar 5, 2026
@shafu0x shafu0x changed the title ues agentcash-router feat(scan): migrate to agentcash-router Mar 5, 2026
Comment thread apps/scan/src/app/openapi.json/route.ts Outdated
@shafu0x shafu0x changed the title feat(scan): migrate to agentcash-router feat(scan): migrate to agentcash-router, update integration prompt Mar 5, 2026
@shafu0x shafu0x marked this pull request as ready for review March 5, 2026 23:33
{ headers: corsHeaders }
);
};
export const POST = withCors(
Copy link
Copy Markdown
Contributor

@vercel vercel Bot Mar 5, 2026

Choose a reason for hiding this comment

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

Module-level mutable state lastParsedAddress causes race conditions when multiple concurrent requests are processed, allowing request B to overwrite the address used by request A's pricing function

Fix on Vercel

Comment thread apps/scan/next.config.ts Outdated
zdql and others added 2 commits March 11, 2026 21:39
Resolved conflicts:
- package.json: kept @agentcash/router, updated @agentcash/discovery to 1.0.0
- integration-spec/page.tsx: kept HEAD "done when" criteria (includes registration step), took main's "ALL" wording
- registry-register.ts: kept HEAD import paths (/x402/_lib/)
- Deleted proxy.ts, api/send/route.ts, data/_lib/utils.ts (superseded by agentcash-router migration)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o latest

- Ported BigInt serialization fix from main's data/_lib/utils.ts into new x402/_lib/utils.ts
- @agentcash/discovery 1.0.0 → ^1.1.0, @agentcash/router ^0.7.0 → ^1.0.1

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@vercel vercel Bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

Version mismatch in @x402/core causing TypeScript type incompatibility - package catalog specifies 2.3.0 but 2.5.0 is resolved, creating duplicate types

Fix on Vercel

Comment thread package.json Outdated
@agentcash/discovery@1.1.0 requires @x402/core@^2.5.0 which caused a
dual-version conflict with the app's @x402/evm@2.3.0 types. Reverted
discovery to 1.0.0 (same as main) and added pnpm overrides to pin all
@x402/* packages to 2.3.0, preventing lockfile drift from pulling in
breaking type changes unrelated to this PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Not used anywhere in the app — only present as an optional peer of @agentcash/router.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zdql and others added 2 commits March 11, 2026 22:59
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@zdql zdql merged commit 323ac04 into main Mar 12, 2026
2 of 3 checks passed
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