-
Notifications
You must be signed in to change notification settings - Fork 2
convert tuple parameters correctly for dyn-abi #24
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
WalkthroughA new private helper function, Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Docstrings generation was requested by @d4mr. * #24 (comment) The following files were modified: * `server/src/http/dyn_contract.rs`
Note Generated docstrings for this pull request at #25 |
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 (1)
server/src/http/dyn_contract.rs (1)
217-263
: Well-structured recursive parameter conversion with comprehensive validation.The function correctly handles both simple and complex parameter types with proper error handling. The recursive approach for complex types is appropriate for nested tuple structures.
Consider these minor improvements:
- The complex type check assumes all complex types are tuples, but ABI could have other complex types like arrays
- Error messages could include parameter index/name for easier debugging
Optional enhancement for better error context:
- for (json_value, json_abi_param) in json_values.iter().zip(json_abi_params.iter()) { + for (i, (json_value, json_abi_param)) in json_values.iter().zip(json_abi_params.iter()).enumerate() { if json_abi_param.is_complex_type() { let json_value = json_value .as_array() - .ok_or_else(|| "Expected array for complex type".to_string())?; + .ok_or_else(|| format!("Expected array for complex type at parameter {}", i))?;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
server/src/http/dyn_contract.rs
(3 hunks)
🔇 Additional comments (2)
server/src/http/dyn_contract.rs (2)
2-2
: LGTM!The import addition is necessary for the new
json_to_sol
function and is correctly placed.
283-285
: LGTM! Clean delegation to the new helper function.The refactoring improves maintainability by centralizing parameter conversion logic while maintaining proper error handling and context.
Summary by CodeRabbit