modify compile_solidity (#49)

* modify compile_yul

* modified format

* deleted unneccesary comments

* fix error
This commit is contained in:
Minhee Hong
2023-09-28 18:41:42 +09:00
committed by GitHub
parent 0e7ff92047
commit 37b99a3187

View File

@@ -3,7 +3,7 @@ use crate::{
util::{arithmetic::PrimeField, Itertools},
};
use std::{
io::Write,
io::{self, Write},
iter,
process::{Command, Stdio},
};
@@ -103,13 +103,22 @@ pub fn estimate_gas(cost: Cost) -> usize {
/// Compile given Solidity `code` into deployment bytecode.
pub fn compile_solidity(code: &str) -> Vec<u8> {
let mut cmd = Command::new("solc")
let mut cmd = match Command::new("solc")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.arg("--bin")
.arg("-")
.spawn()
.unwrap();
{
Ok(cmd) => cmd,
Err(err) if err.kind() == io::ErrorKind::NotFound => {
panic!("Command 'solc' not found");
}
Err(err) => {
panic!("Failed to spawn cmd with command 'solc':\n{err}");
}
};
cmd.stdin
.take()
.unwrap()