Skip to content

Commit

Permalink
Fix builder results parsing issues (#229)
Browse files Browse the repository at this point in the history
* fix #227

* more resilient
  • Loading branch information
shouc authored Oct 6, 2023
1 parent 719e838 commit b26a55a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/evm/blaz/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,16 @@ impl BuildJobResult {
let source_objs = json["sources"].as_object().expect("get sources failed");
let mut sources = vec![(String::new(), String::new()); source_objs.len()];
for (k, v) in source_objs {
let idx = v["id"].as_u64().expect("get source id failed") as usize;


let idx = match &v["id"] {
Value::Number(v) => { v.as_u64().unwrap() as usize }
Value::String(v) => { v.parse::<usize>().unwrap() }
_ => {
println!("{:?} is not a valid source id", v["id"]);
return None;
}
};
let code = v["source"].as_str().expect("get source code failed");
sources[idx] = (k.clone(), code.to_string());
}
Expand Down

0 comments on commit b26a55a

Please sign in to comment.