Skip to content

Conversation

@zeljkoX
Copy link
Collaborator

@zeljkoX zeljkoX commented Aug 28, 2025

Summary

This PR extends SolanaRpcResult with a method tag to resolve type collisions in SDK consumers caused by multiple RPC methods sharing the same payload format.

SDK PR: OpenZeppelin/openzeppelin-relayer-sdk#174

Testing Process

Checklist

  • Add a reference to related issues in the PR description.
  • Add unit tests if applicable.

Summary by CodeRabbit

  • Refactor

    • RPC responses for Solana, Stellar, and Network now include a required method field to identify the result type, aligning response formats across methods. This may require client updates if parsing untagged responses.
  • Documentation

    • OpenAPI spec updated to reflect method-discriminated RPC results.
    • Removed the description for the Stellar policy field concurrent_transactions (type unchanged).

@zeljkoX zeljkoX requested review from a team as code owners August 28, 2025 08:33
@coderabbitai
Copy link

coderabbitai bot commented Aug 28, 2025

Walkthrough

Introduces method-discriminated RPC result schemas across OpenAPI, wrapping existing results with allOf to include a required method field. Updates NetworkRpcResult similarly. Removes a description from a Stellar policy field. In Rust, switches SolanaRpcResult from untagged to tagged serde enum using method with camelCase variant names.

Changes

Cohort / File(s) Summary
OpenAPI RPC schema updates
docs/openapi.json
Reworked Solana/Stellar/Network RpcResult definitions to oneOf of allOf wrappers adding required method enums (feeEstimate, transferTransaction, prepareTransaction, signTransaction, signAndSendTransaction, getSupportedTokens, getFeaturesEnabled). Removed description from RelayerStellarPolicy.concurrent_transactions (type unchanged).
Rust Solana model tagging
src/models/rpc/solana/mod.rs
Changed serde from untagged to tagged: #[serde(tag = "method", rename_all = "camelCase")] on SolanaRpcResult; variants unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Server

  Note over Server: Builds RPC result with explicit discriminator<br/>field method (camelCase)

  Client->>Server: JSON-RPC request (e.g., signTransaction)
  Server-->>Client: JsonRpcResponse { result: { method: "signTransaction", ... } }

  rect rgba(200,230,255,0.3)
  Note over Client: Deserialization keyed by method
  Client->>Client: Match result.method to variant<br/>(feeEstimate | transferTransaction | prepareTransaction | signTransaction | signAndSendTransaction | getSupportedTokens | getFeaturesEnabled)
  end

  alt Unknown method
    Client-->>Client: Fallback/error on unknown discriminator
  else Known method
    Client-->>Client: Parse payload into matching result type
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

Thump-thump! I tag my trails with cheer,
A method nibble makes intent appear.
One hop, one enum, neatly named,
Results unjumbled, clearly framed.
Docs align, the warren’s bright—
Now every call lands just right. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch extend-solana-rpc-result-with-method-tag

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.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit 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:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

@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 (3)
src/models/rpc/solana/mod.rs (1)

243-252: Add schema discriminator and serde roundtrip test

No lingering deserialization of the old untagged shape was found. Apply the discriminator attribute to keep OpenAPI docs in sync and (optionally) add a focused test:

 #[derive(Debug, Serialize, Deserialize, ToSchema, PartialEq)]
 #[serde(tag = "method", rename_all = "camelCase")]
+#[schema(discriminator = "method")]
 pub enum SolanaRpcResult {

(Optional) add:

#[test]
fn test_solana_rpc_result_tagged_shape() {
    let res = SolanaRpcResult::FeeEstimate(FeeEstimateResult {
        estimated_fee: "123".into(),
        conversion_rate: "1.0".into(),
    });
    let json = serde_json::to_value(&res).unwrap();
    assert_eq!(json["method"], "feeEstimate");
    assert_eq!(json["estimated_fee"], "123");
    assert_eq!(json["conversion_rate"], "1.0");
    let de: SolanaRpcResult = serde_json::from_value(json).unwrap();
    assert_eq!(de, res);
}
docs/openapi.json (2)

6012-6017: Nit: consider keeping a short description for concurrent_transactions.

Dropping the description reduces clarity in SDKs/docs. Suggest re-adding a brief note (e.g., “Allow processing multiple Stellar transactions concurrently”).


6756-6901: Add explicit discriminator to SolanaRpcResult

Verified that all expected method literals (feeEstimate, transferTransaction, prepareTransaction, signTransaction, signAndSendTransaction, getSupportedTokens, getFeaturesEnabled) appear exactly once in the oneOf. Adding a discriminator improves variant resolution in generated SDKs.

Apply near the SolanaRpcResult schema:

-      "SolanaRpcResult": {
+      "SolanaRpcResult": {
+        "discriminator": { "propertyName": "method" },
         "oneOf": [
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between efede36 and 33b9737.

📒 Files selected for processing (2)
  • docs/openapi.json (2 hunks)
  • src/models/rpc/solana/mod.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: boostsecurity - boostsecurityio/semgrep-pro
  • GitHub Check: clippy
  • GitHub Check: test
  • GitHub Check: msrv
  • GitHub Check: Redirect rules - openzeppelin-relayer
  • GitHub Check: Header rules - openzeppelin-relayer
  • GitHub Check: Pages changed - openzeppelin-relayer
  • GitHub Check: Analyze (rust)

@codecov
Copy link

codecov bot commented Aug 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.0%. Comparing base (efede36) to head (33b9737).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #437   +/-   ##
=====================================
  Coverage   93.0%   93.0%           
=====================================
  Files        217     217           
  Lines      74164   74164           
=====================================
  Hits       68995   68995           
  Misses      5169    5169           
Flag Coverage Δ
integration 0.5% <ø> (ø)
properties <0.1% <ø> (ø)
unittests 93.0% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zeljkoX zeljkoX merged commit 53ad7b0 into main Sep 3, 2025
26 of 27 checks passed
@zeljkoX zeljkoX deleted the extend-solana-rpc-result-with-method-tag branch September 3, 2025 16:07
@github-actions github-actions bot locked and limited conversation to collaborators Sep 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants