Skip to content

Commit

Permalink
simplify wasm file logic and improve error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
itegulov committed Feb 21, 2022
1 parent ebf1a05 commit a4cbc39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 7 additions & 2 deletions workspaces/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ pub fn build_cargo_project<P: AsRef<Path> + Debug>(
.collect())
} else {
Err(anyhow!(
"Failed to build project '{:?}': {}",
"Failed to build project '{:?}'.
Stderr:
{}
Stdout:
{}",
project_path,
String::from_utf8(output.stderr)?
String::from_utf8(output.stderr)?,
String::from_utf8(output.stdout)?,
))
}
}
16 changes: 6 additions & 10 deletions workspaces/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,16 @@ where
.iter()
.filter(|f| f.as_str().ends_with(".wasm"))
.collect::<Vec<_>>();
if wasm_files.is_empty() {
Err(anyhow!(
match wasm_files.as_slice() {
[] => Err(anyhow!(
"Compilation resulted in no '.wasm' target files. \
Please check that your project contains a NEAR smart contract."
))
} else if wasm_files.len() > 1 {
Err(anyhow!(
)),
[file] => self.dev_deploy(&fs::read(file.canonicalize()?)?).await,
_ => Err(anyhow!(
"Compilation resulted in more than one '.wasm' target file: {:?}",
wasm_files
))
} else {
let file = wasm_files.first().unwrap();
let wasm = fs::read(file.canonicalize()?)?;
self.dev_deploy(&wasm).await
)),
}
}
}
Expand Down

0 comments on commit a4cbc39

Please sign in to comment.