-
Notifications
You must be signed in to change notification settings - Fork 47
feat: Include method tag in solana rpc result #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughIntroduces 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
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 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 testNo 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 SolanaRpcResultVerified that all expected
methodliterals (feeEstimate, transferTransaction, prepareTransaction, signTransaction, signAndSendTransaction, getSupportedTokens, getFeaturesEnabled) appear exactly once in theoneOf. 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.
📒 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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Summary by CodeRabbit
Refactor
Documentation