Skip to content

Commit

Permalink
refactor: Updated cargo-near to "0.5.2" (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod committed Jan 27, 2024
1 parent 5628eec commit bf32d73
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion workspaces/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async-trait = "0.1"
base64 = "0.21"
bs58 = "0.5"
cargo_metadata = { version = "0.18", optional = true }
cargo-near = "0.3.1"
cargo-near = { version = "0.5.2", default-features = false }
chrono = "0.4.19"
fs2 = "0.4"
rand = "0.8.4"
Expand Down
23 changes: 14 additions & 9 deletions workspaces/src/cargo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::convert::TryInto;

use crate::error::ErrorKind;

use cargo_near::commands::build_command::{build, BuildCommand};

/// Builds the cargo project located at `project_path` and returns the generated wasm file contents.
///
/// NOTE: This function does not check whether the resulting wasm file is a valid smart
Expand All @@ -15,23 +15,28 @@ pub async fn compile_project(project_path: &str) -> crate::Result<Vec<u8>> {
_ => ErrorKind::Io.custom(e),
})?;

let cargo_near_build_command = cargo_near::BuildCommand {
let cargo_near_build_command = BuildCommand {
release: true,
embed_abi: true,
doc: false,
color: cargo_near::ColorPreference::Always,
color: None,
no_abi: true,
out_dir: None,
manifest_path: Some(
project_path
.join("Cargo.toml")
.try_into()
.map_err(|e| ErrorKind::Io.custom(e))?,
cargo_near::types::utf8_path_buf::Utf8PathBuf::from_path_buf(
project_path.join("Cargo.toml"),
)
.map_err(|error_path| {
ErrorKind::Io.custom(format!(
"Unable to construct UTF-8 path from: {}",
error_path.display()
))
})?,
),
};

let compile_artifact =
cargo_near::build::run(cargo_near_build_command).map_err(|e| ErrorKind::Io.custom(e))?;
build::run(cargo_near_build_command).map_err(|e| ErrorKind::Io.custom(e))?;

let file = compile_artifact
.path
Expand Down

0 comments on commit bf32d73

Please sign in to comment.