feat: Add new channel fund for x402 payments#103
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR introduces an optional x402 Fund Relayer feature enabling specialized fee bumping through a separate relayer. Changes include documentation updates, environment variable configuration (X402_FUND_RELAYER_ID), request type extensions, validation logic, conditional fund relayer selection in the handler, concurrency improvements for tests, and comprehensive test coverage. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Handler
participant Config
participant FundRelayer
participant DefaultRelayer
Client->>Handler: ChannelAccountsRequest (x402: true/false)
Handler->>Config: Load x402FundRelayerId configuration
Config-->>Handler: x402FundRelayerId or undefined
alt x402 = true and x402FundRelayerId configured
Handler->>FundRelayer: Select x402 Fund Relayer
FundRelayer-->>Handler: x402 relayer instance
Handler->>FundRelayer: Process transaction (fee bumping)
FundRelayer-->>Handler: Result
else x402 = true and x402FundRelayerId missing
Handler-->>Client: CONFIG_MISSING error
else x402 = false or get-transaction type
Handler->>DefaultRelayer: Select default relayer
DefaultRelayer-->>Handler: default relayer instance
Handler->>DefaultRelayer: Process transaction
DefaultRelayer-->>Handler: Result
end
Handler-->>Client: Response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
README.md (1)
225-225: Unify example relayer IDs across x402 docs.Line 225 uses
x402-channels-fundwhile Line 321 usesx402-fund. Keeping one consistent example name would reduce setup mistakes.Also applies to: 321-321
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` at line 225, The README uses two different example relayer IDs ("x402-channels-fund" at the export X402_FUND_RELAYER_ID line and "x402-fund" elsewhere); standardize them to a single example name across the doc by replacing the one at the export (export X402_FUND_RELAYER_ID="x402-channels-fund") to match the chosen canonical example (e.g., "x402-fund"), and update the adjacent comment text if needed so all references to the fund relayer ID (the X402_FUND_RELAYER_ID export and any mentions later in the document) are identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/plugin/handler.ts`:
- Around line 290-291: The error payloads are still using config.fundRelayerId
instead of the computed fundRelayerId when x402 is enabled; update the code
paths that build downstream error details to reference the local fundRelayerId
variable (computed from config.x402FundRelayerId and config.fundRelayerId)
rather than directly reading config.fundRelayerId, and ensure any places that
attach relayer identifiers to errors (where fundRelayer and related error
objects are created) include the selected fundRelayerId so the actual relayer
used is reflected in logged/returned error payloads.
---
Nitpick comments:
In `@README.md`:
- Line 225: The README uses two different example relayer IDs
("x402-channels-fund" at the export X402_FUND_RELAYER_ID line and "x402-fund"
elsewhere); standardize them to a single example name across the doc by
replacing the one at the export (export
X402_FUND_RELAYER_ID="x402-channels-fund") to match the chosen canonical example
(e.g., "x402-fund"), and update the adjacent comment text if needed so all
references to the fund relayer ID (the X402_FUND_RELAYER_ID export and any
mentions later in the document) are identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ce2898dd-d50b-419b-ae99-d4ac934136dd
📒 Files selected for processing (9)
README.mdscripts/smoke.tssrc/client/types.tssrc/plugin/config.tssrc/plugin/handler.tssrc/plugin/types.tssrc/plugin/validation.tstest/handler.x402.test.tstest/validation.test.ts
tirumerla
left a comment
There was a problem hiding this comment.
Overall lgtm, we should also support get transaction methods for x402 so that they get correct relayerId.
zeljkoX
left a comment
There was a problem hiding this comment.
Thanks for working on this one.
I think we should just make it generic and not tied to x402.
For example param could be related fundRelayer like fundRelayerId=x402 and not x402=true
This way we are not coupling these two things and users are able to extend it for their needs.
Summary by CodeRabbit
New Features
Documentation
Tests