use alloy_dyn_abi::DynSolValue; use serde_json::{json, Value}; pub fn decode_dynsol(val: &DynSolValue) -> Value { match val { DynSolValue::Address(addr) => json!(format!("{addr:?}")), DynSolValue::Uint(u, _) => json!(u.to_string()), DynSolValue::Int(i, _) => json!(i.to_string()), DynSolValue::Bool(b) => json!(b), DynSolValue::String(s) => json!(s.clone()), DynSolValue::Bytes(b) => json!(format!("0x{}", hex::encode(b))), DynSolValue::FixedBytes(b, _) => json!(format!("0x{}", hex::encode(b))), DynSolValue::Array(arr) => { let inner = arr.iter().map(decode_dynsol).collect::>(); Value::Array(inner) } DynSolValue::FixedArray(arr) => { let inner = arr.iter().map(decode_dynsol).collect::>(); Value::Array(inner) } DynSolValue::Tuple(t) => { let inner = t.iter().map(decode_dynsol).collect::>(); Value::Array(inner) } other => panic!("Unsupported type: {:?}", other), } }