pub fn sbox() -> errors::Result<()> {
    let config_path = "ebox.json";
    let config_exist = utils::file_exist(config_path);
    let contract_dir = "contracts";
    let contract_dir_exist = utils::dir_exist(contract_dir);

    if !config_exist {
        return Err("ebox.json not found, consider init this project first".into());
    }

    if !contract_dir_exist {
        return Err("contracts directory not found".into());
    }

    let conf_str = utils::file_read(config_path)?;
    let conf = config_decode(&conf_str)?;
    let c_optimize = conf.compiler.optimize;
    let c_runs = conf.compiler.runs.to_string();
    let mut opts: Vec<String> = Vec::new();

    if c_optimize {
        opts.push(String::from("--optimize"));
        opts.push(String::from("--optimize-runs"));
        opts.push(c_runs);
    }

    let contracts = utils::dir_read(contract_dir)?;
    let solc = compiler::new("solc");

    for ele in contracts {
        let path_str = format!("{}/{}", contract_dir, &ele);
        let path = PathBuf::from(&path_str);
        if path.is_file() {
            if path.extension().unwrap() == "sol" {
                let _ = solc.compile(&path_str, "artifacts", &opts)?;
            }
        }
    }

    Ok(())
}
// actions for compile the project.
actions for compile the project.
actions for compile the project .
pub fn sbox() -> errors::Result<()> {
    let config_path = "ebox.json";
    let config_exist = utils::file_exist(config_path);
    let contract_dir = "contracts";
    let contract_dir_exist = utils::dir_exist(contract_dir);
    if !config_exist {
        return Err("ebox.json not found, consider init this project first".into());
    }
    if !contract_dir_exist {
        return Err("contracts directory not found".into());
    }
    let conf_str = utils::file_read(config_path)?;
    let conf = config_decode(&conf_str)?;
    let c_optimize = conf.compiler.optimize;
    let c_runs = conf.compiler.runs.to_string();
    let mut opts: Vec<String> = Vec::new();
    if c_optimize {
        opts.push(String::from("--optimize"));
        opts.push(String::from("--optimize-runs"));
        opts.push(c_runs);
    }
    let contracts = utils::dir_read(contract_dir)?;
    let solc = compiler::new("solc");
    for ele in contracts {
        let path_str = format!("{}/{}", contract_dir, &ele);
        let path = PathBuf::from(&path_str);
        if path.is_file() {
            if path.extension().unwrap() == "sol" {
                let _ = solc.compile(&path_str, "artifacts", &opts)?;
            }
        }
    }
    Ok(())
}
pub fn sbox ( ) -> errors :: Result < ( ) > { let config_path = " " ; let config_exist = utils :: file_exist ( config_path ) ; let contract_dir = " " ; let contract_dir_exist = utils :: dir_exist ( contract_dir ) ; if ! config_exist { return Err ( " " . into ( ) ) ; } if ! contract_dir_exist { return Err ( " " . into ( ) ) ; } let conf_str = utils :: file_read ( config_path ) ? ; let conf = config_decode ( & conf_str ) ? ; let c_optimize = conf . compiler . optimize ; let c_runs = conf . compiler . runs . to_string ( ) ; let mut opts : Vec < String > = Vec :: new ( ) ; if c_optimize { opts . push ( String :: from ( " " ) ) ; opts . push ( String :: from ( " " ) ) ; opts . push ( c_runs ) ; } let contracts = utils :: dir_read ( contract_dir ) ? ; let solc = compiler :: new ( " " ) ; for ele in contracts { let path_str = format ! ( " " contract_dir ele ) ; let path = PathBuf :: from ( & path_str ) ; if path . is_file ( ) { if path . extension ( ) . unwrap ( ) == " " { let _ = solc . compile ( & path_str , " " , & opts ) ? ; } } } Ok ( ( ) ) }
actions for compile the project.
actions for compile the project .