Skip to content

Commit c4a0cc9

Browse files
fix(apollo_compile_to_casm): extract the casm json from the compilers output
1 parent ec3911c commit c4a0cc9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/apollo_compile_to_casm/src/compiler.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@ impl SierraToCasmCompiler {
4545
additional_args,
4646
resource_limits,
4747
)?;
48-
Ok(serde_json::from_slice::<CasmContractClass>(&stdout)?)
48+
49+
if let Some(pos) = stdout.iter().position(|&b| b == b'{') {
50+
// Extract the JSON representation of `CasmContractClass` by removing leading non-JSON
51+
// compiler output.
52+
Ok(serde_json::from_slice::<CasmContractClass>(&stdout[pos..])?)
53+
} else {
54+
Err(CompilationUtilError::UnexpectedError(format!(
55+
"Failed to find the start of the JSON output in the compilation output: {:?}",
56+
stdout
57+
)))
58+
}
4959
}
5060
}
5161

0 commit comments

Comments
 (0)