Skip to content

Commit 89ccd72

Browse files
committed
Inject polkavm settings into resolc standard JSON input
1 parent 4a4ac7e commit 89ccd72

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

crates/compiler/src/revive_resolc.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ impl Resolc {
8282
false,
8383
)
8484
}
85+
86+
fn inject_polkavm_settings(input: &SolcStandardJsonInput) -> Result<serde_json::Value> {
87+
let mut input_value = serde_json::to_value(&input)
88+
.context("Failed to serialize Standard JSON input for resolc")?;
89+
if let Some(settings) = input_value.get_mut("settings") {
90+
settings["polkavm"] = serde_json::to_value(&Self::polkavm_settings()).unwrap();
91+
}
92+
Ok(input_value)
93+
}
8594
}
8695

8796
impl SolidityCompiler for Resolc {
@@ -167,7 +176,13 @@ impl SolidityCompiler for Resolc {
167176
detect_missing_libraries: false,
168177
},
169178
};
170-
Span::current().record("json_in", display(serde_json::to_string(&input).unwrap()));
179+
// Manually inject polkavm settings since it's marked skip_serializing in the upstream crate
180+
let std_input_json = Self::inject_polkavm_settings(&input)?;
181+
182+
Span::current().record(
183+
"json_in",
184+
display(serde_json::to_string(&std_input_json).unwrap()),
185+
);
171186

172187
let path = &self.0.resolc_path;
173188
let mut command = AsyncCommand::new(path);
@@ -196,8 +211,9 @@ impl SolidityCompiler for Resolc {
196211
.with_context(|| format!("Failed to spawn resolc at {}", path.display()))?;
197212

198213
let stdin_pipe = child.stdin.as_mut().expect("stdin must be piped");
199-
let serialized_input = serde_json::to_vec(&input)
214+
let serialized_input = serde_json::to_vec(&std_input_json)
200215
.context("Failed to serialize Standard JSON input for resolc")?;
216+
201217
stdin_pipe
202218
.write_all(&serialized_input)
203219
.await

0 commit comments

Comments
 (0)