pub fn read_wasm_file_bytes<T: AsRef<Path>>(contract_file: T) -> Vec<u8> {
    let mut attempted_paths = vec![];

    if contract_file.as_ref().is_relative() {
        // Find first path to a given file found in a list of paths
        for wasm_path in WASM_PATHS.iter() {
            let mut filename = wasm_path.clone();
            filename.push(contract_file.as_ref());
            if let Ok(wasm_bytes) = fs::read(&filename) {
                return wasm_bytes;
            }
            attempted_paths.push(filename);
        }
    }
    // Try just opening in case the arg is a valid path relative to current working dir, or is a
    // valid absolute path.
    if let Ok(wasm_bytes) = fs::read(contract_file.as_ref()) {
        return wasm_bytes;
    }
    attempted_paths.push(contract_file.as_ref().to_owned());

    let mut error_msg =
        "\nFailed to open compiled Wasm file.  Tried the following locations:\n".to_string();
    for attempted_path in attempted_paths {
        error_msg = format!("{}    - {}\n", error_msg, attempted_path.display());
    }

    panic!("{}\n", error_msg);
}
/// Reads a given compiled contract file based on path
Reads a given compiled contract file based on path
Reads a given compiled contract file based on path
pub fn read_wasm_file_bytes<T: AsRef<Path>>(contract_file: T) -> Vec<u8> {
    let mut attempted_paths = vec![];
    if contract_file.as_ref().is_relative() {
        // Find first path to a given file found in a list of paths
        for wasm_path in WASM_PATHS.iter() {
            let mut filename = wasm_path.clone();
            filename.push(contract_file.as_ref());
            if let Ok(wasm_bytes) = fs::read(&filename) {
                return wasm_bytes;
            }
            attempted_paths.push(filename);
        }
    }
    // Try just opening in case the arg is a valid path relative to current working dir, or is a
    // valid absolute path.
    if let Ok(wasm_bytes) = fs::read(contract_file.as_ref()) {
        return wasm_bytes;
    }
    attempted_paths.push(contract_file.as_ref().to_owned());
    let mut error_msg =
        "\nFailed to open compiled Wasm file.  Tried the following locations:\n".to_string();
    for attempted_path in attempted_paths {
        error_msg = format!("{}    - {}\n", error_msg, attempted_path.display());
    }
    panic!("{}\n", error_msg);
}
pub fn read_wasm_file_bytes < T : AsRef < Path > > ( contract_file : T ) -> Vec < u8 > { let mut attempted_paths = vec ! [ ] ; if contract_file . as_ref ( ) . is_relative ( ) { // Find first path to a given file found in a list of paths for wasm_path in WASM_PATHS . iter ( ) { let mut filename = wasm_path . clone ( ) ; filename . push ( contract_file . as_ref ( ) ) ; if let Ok ( wasm_bytes ) = fs :: read ( & filename ) { return wasm_bytes ; } attempted_paths . push ( filename ) ; } } // Try just opening in case the arg is a valid path relative to current working dir, or is a // valid absolute path. if let Ok ( wasm_bytes ) = fs :: read ( contract_file . as_ref ( ) ) { return wasm_bytes ; } attempted_paths . push ( contract_file . as_ref ( ) . to_owned ( ) ) ; let mut error_msg = " \n \n " . to_string ( ) ; for attempted_path in attempted_paths { error_msg = format ! ( " \n " error_msg attempted_path display ( ) ) ; } panic ! ( " \n " error_msg ) ; }
Reads a given compiled contract file based on path
Reads a given compiled contract file based on path
contract_file
T
contract_file
T