fix: remove redundant parse checks

This commit is contained in:
royvardhan
2025-02-05 20:50:44 +05:30
parent d3ad0ba5bf
commit c4f9fd0fa6

View File

@@ -52,24 +52,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
std::process::exit(1); std::process::exit(1);
} }
// Parse the JSON input to verify it's valid
let input_json: Value =
serde_json::from_str(&buffer).map_err(|e| format!("Failed to parse JSON input: {}", e))?;
// Check if direct_execution is false and private_key is missing
if let Some(obj) = input_json.as_object() {
if let Some(direct_execution) = obj
.get("direct_execution")
.and_then(|v| v.as_bool())
{
if !direct_execution && private_key.is_none() {
eprintln!("Error: Private key is required when direct_execution is false");
eprintln!("{}", lib::help::HELP_TEXT);
std::process::exit(1);
}
}
}
// Encode the solution // Encode the solution
let encoded = encode_swaps(&buffer, router_address, private_key)?; let encoded = encode_swaps(&buffer, router_address, private_key)?;