| 2256 | } |
| 2257 | |
| 2258 | fn verification_reports_from_value( |
| 2259 | reports: serde_json::Value, |
| 2260 | ) -> napi::Result<Vec<RustVerificationReport>> { |
| 2261 | let reports = match reports { |
| 2262 | serde_json::Value::Array(_) => serde_json::from_value(reports), |
| 2263 | serde_json::Value::Object(_) => { |
| 2264 | serde_json::from_value::<RustVerificationReport>(reports).map(|report| vec![report]) |
| 2265 | } |
| 2266 | _ => { |
| 2267 | return Err(napi::Error::from_reason( |
| 2268 | "verification reports must be an array or object", |
| 2269 | )); |
| 2270 | } |
| 2271 | }; |
| 2272 | reports.map_err(|e| napi::Error::from_reason(format!("Invalid verification report: {e}"))) |
| 2273 | } |
| 2274 | |
| 2275 | fn js_auto_delegation_to_rust( |
| 2276 | options: AutoDelegationOptions, |