From 21eff03e47c05da8f93be4c765d891dbd9069037 Mon Sep 17 00:00:00 2001 From: Prithvish Date: Wed, 29 Oct 2025 04:05:48 +0530 Subject: [PATCH] fix dyn sol value handling for tuple arrays --- server/src/http/dyn_contract.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/server/src/http/dyn_contract.rs b/server/src/http/dyn_contract.rs index 63437e0..8887e18 100644 --- a/server/src/http/dyn_contract.rs +++ b/server/src/http/dyn_contract.rs @@ -234,9 +234,27 @@ impl ContractCall { .as_array() .ok_or_else(|| "Expected array for complex type".to_string())?; - let dyn_sol_value = Self::json_to_sol(json_value, &json_abi_param.components)?; - - parsed_params.push(DynSolValue::Tuple(dyn_sol_value)); + // if the json_abi_param.ty is tuple[], + // then instead of deconstructing the json_value into the components directly, + // we treat it as components[] + + if json_abi_param.ty == "tuple[]" { + // for each element in json_value, try to parse it as component + let mut components = Vec::new(); + for element in json_value { + let component = Self::json_to_sol( + element + .as_array() + .ok_or_else(|| "Expected array for complex type".to_string())?, + &json_abi_param.components, + )?; + components.push(DynSolValue::Tuple(component)); + } + parsed_params.push(DynSolValue::Array(components)); + } else { + let dyn_sol_value = Self::json_to_sol(json_value, &json_abi_param.components)?; + parsed_params.push(DynSolValue::Tuple(dyn_sol_value)); + } } else { let sol_type: DynSolType = json_abi_param .ty @@ -258,7 +276,6 @@ impl ContractCall { parsed_params.push(parsed_value); } } - Ok(parsed_params) }