From 89ccd72d20ec2fa49f91d1162e8586e872ba0a47 Mon Sep 17 00:00:00 2001 From: Marian Radu Date: Thu, 15 Jan 2026 17:24:10 +0200 Subject: [PATCH] Inject polkavm settings into resolc standard JSON input --- crates/compiler/src/revive_resolc.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/compiler/src/revive_resolc.rs b/crates/compiler/src/revive_resolc.rs index 6b80d13..fc8adca 100644 --- a/crates/compiler/src/revive_resolc.rs +++ b/crates/compiler/src/revive_resolc.rs @@ -82,6 +82,15 @@ impl Resolc { false, ) } + + fn inject_polkavm_settings(input: &SolcStandardJsonInput) -> Result { + let mut input_value = serde_json::to_value(&input) + .context("Failed to serialize Standard JSON input for resolc")?; + if let Some(settings) = input_value.get_mut("settings") { + settings["polkavm"] = serde_json::to_value(&Self::polkavm_settings()).unwrap(); + } + Ok(input_value) + } } impl SolidityCompiler for Resolc { @@ -167,7 +176,13 @@ impl SolidityCompiler for Resolc { detect_missing_libraries: false, }, }; - Span::current().record("json_in", display(serde_json::to_string(&input).unwrap())); + // Manually inject polkavm settings since it's marked skip_serializing in the upstream crate + let std_input_json = Self::inject_polkavm_settings(&input)?; + + Span::current().record( + "json_in", + display(serde_json::to_string(&std_input_json).unwrap()), + ); let path = &self.0.resolc_path; let mut command = AsyncCommand::new(path); @@ -196,8 +211,9 @@ impl SolidityCompiler for Resolc { .with_context(|| format!("Failed to spawn resolc at {}", path.display()))?; let stdin_pipe = child.stdin.as_mut().expect("stdin must be piped"); - let serialized_input = serde_json::to_vec(&input) + let serialized_input = serde_json::to_vec(&std_input_json) .context("Failed to serialize Standard JSON input for resolc")?; + stdin_pipe .write_all(&serialized_input) .await