From bf32d73820e65a03ab987271949f3716d9901715 Mon Sep 17 00:00:00 2001 From: FroVolod <36816899+FroVolod@users.noreply.github.com> Date: Sun, 28 Jan 2024 00:30:28 +0200 Subject: [PATCH] refactor: Updated cargo-near to "0.5.2" (#347) --- workspaces/Cargo.toml | 2 +- workspaces/src/cargo/mod.rs | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/workspaces/Cargo.toml b/workspaces/Cargo.toml index 7565d916..ae56b816 100644 --- a/workspaces/Cargo.toml +++ b/workspaces/Cargo.toml @@ -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" diff --git a/workspaces/src/cargo/mod.rs b/workspaces/src/cargo/mod.rs index dd496e36..75cb4f5e 100644 --- a/workspaces/src/cargo/mod.rs +++ b/workspaces/src/cargo/mod.rs @@ -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 @@ -15,23 +15,28 @@ pub async fn compile_project(project_path: &str) -> crate::Result> { _ => 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