Skip to content

Commit 4146419

Browse files
0xrinegadeclaude
andcommitted
fix(rpc): update RPC parameter passing to use object configs
Updated both AI prompts and RPC bridge to properly handle Solana RPC params: AI Prompt changes (ai_service.rs): - Changed tool call syntax from :param style to object config style - Example: (getSignaturesForAddress addr {:limit 1000}) - Updated pagination example to use config objects RPC Bridge changes (rpc_bridge.rs): - Improved config object building for getSignaturesForAddress - Now properly wraps limit/before in config struct - Handles both object and positional parameter styles This fixes the RPC error: "invalid type: integer 1000, expected struct RpcSignaturesForAddressConfig" Now generates correct Solana RPC format: ["address", {"limit": 1000}] ✅ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7615abe commit 4146419

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

src/services/ai_service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ Data Structures:
633633
634634
Tool Calls:
635635
(toolName arg1 arg2)
636-
(toolName :param1 value1 :param2 value2)
636+
(toolName "primary_arg" {:param1 value1 :param2 value2})
637637
638638
# Plan Structure
639639
@@ -812,8 +812,8 @@ The Solana RPC has a **HARD LIMIT of 1000 results per call** for methods like `g
812812
(while continue
813813
(define batch
814814
(if (== before null)
815-
(getSignaturesForAddress :address address :limit MAX_RESULTS_PER_CALL)
816-
(getSignaturesForAddress :address address :limit MAX_RESULTS_PER_CALL :before before)))
815+
(getSignaturesForAddress address {:limit MAX_RESULTS_PER_CALL})
816+
(getSignaturesForAddress address {:limit MAX_RESULTS_PER_CALL :before before})))
817817
818818
(define batch_size (COUNT batch))
819819

src/utils/rpc_bridge.rs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,35 +79,38 @@ impl Tool for RpcBridgeTool {
7979
rpc_params.push(ovsm_value_to_json(&args[0]));
8080

8181
// Build config object from remaining arguments
82-
// For now, we use generic field names since OVSM doesn't preserve parameter names
83-
// The specific RPC method determines how to interpret these
84-
let mut config = serde_json::Map::new();
82+
// Check if second argument is already an object (named params)
83+
if args.len() == 2 && matches!(&args[1], OvsmValue::Object(_)) {
84+
// Second arg is a config object, use it directly
85+
rpc_params.push(ovsm_value_to_json(&args[1]));
86+
} else {
87+
// Build config from positional args
88+
let mut config = serde_json::Map::new();
8589

86-
// Common Solana RPC config fields
87-
if args.len() == 2 {
88-
// Second arg is typically 'limit' for getSignaturesForAddress
90+
// For getSignaturesForAddress specifically
8991
if matches!(self.name.as_str(), "getSignaturesForAddress") {
90-
config.insert("limit".to_string(), ovsm_value_to_json(&args[1]));
92+
if args.len() >= 2 {
93+
config.insert("limit".to_string(), ovsm_value_to_json(&args[1]));
94+
}
95+
if args.len() >= 3 {
96+
config.insert("before".to_string(), ovsm_value_to_json(&args[2]));
97+
}
9198
} else {
92-
// For other methods, treat as config object
93-
if let OvsmValue::Object(obj) = &args[1] {
94-
for (k, v) in obj.iter() {
95-
config.insert(k.clone(), ovsm_value_to_json(v));
99+
// For other methods, try to infer config structure
100+
for (i, arg) in args.iter().enumerate().skip(1) {
101+
if let OvsmValue::Object(obj) = arg {
102+
for (k, v) in obj.iter() {
103+
config.insert(k.clone(), ovsm_value_to_json(v));
104+
}
105+
} else {
106+
config.insert(format!("param{}", i), ovsm_value_to_json(arg));
96107
}
97-
} else {
98-
config.insert("config".to_string(), ovsm_value_to_json(&args[1]));
99108
}
100109
}
101-
} else if args.len() == 3 {
102-
// Third arg could be 'before' for pagination
103-
if matches!(self.name.as_str(), "getSignaturesForAddress") {
104-
config.insert("limit".to_string(), ovsm_value_to_json(&args[1]));
105-
config.insert("before".to_string(), ovsm_value_to_json(&args[2]));
106-
}
107-
}
108110

109-
if !config.is_empty() {
110-
rpc_params.push(Value::Object(config));
111+
if !config.is_empty() {
112+
rpc_params.push(Value::Object(config));
113+
}
111114
}
112115
}
113116

0 commit comments

Comments
 (0)