From 89ae694b0795b8dec55c02fa568afd6c462034a1 Mon Sep 17 00:00:00 2001 From: Bolaji Ahmad <56865496+bolajahmad@users.noreply.github.com> Date: Thu, 16 May 2024 10:43:56 +0100 Subject: [PATCH 1/4] feature: check if build exists before deploying contract with pop up --- crates/pop-cli/src/commands/up/contract.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/pop-cli/src/commands/up/contract.rs b/crates/pop-cli/src/commands/up/contract.rs index 1c75cf9e..a7a46879 100644 --- a/crates/pop-cli/src/commands/up/contract.rs +++ b/crates/pop-cli/src/commands/up/contract.rs @@ -4,8 +4,8 @@ use anyhow::anyhow; use clap::Args; use cliclack::{clear_screen, intro, log, outro, outro_cancel}; use pop_contracts::{ - dry_run_gas_estimate_instantiate, instantiate_smart_contract, parse_hex_bytes, - set_up_deployment, UpOpts, + build_smart_contract, dry_run_gas_estimate_instantiate, instantiate_smart_contract, + parse_hex_bytes, set_up_deployment, UpOpts, }; use sp_core::Bytes; use sp_weights::Weight; @@ -54,7 +54,23 @@ pub struct UpContractCommand { impl UpContractCommand { pub(crate) async fn execute(&self) -> anyhow::Result<()> { clear_screen()?; + + // Check if build exists in the specified "Contract build folder" + let build_path = PathBuf::from( + self.path.clone().unwrap_or("/.".into()).to_string_lossy().to_string() + + "/target/release/ink", + ); + + if !build_path.exists() { + intro(format!("{}: Building a contract", style(" Pop CLI ").black().on_magenta()))?; + // Directory exists, proceed with the rest of the code + let result = build_smart_contract(&self.path)?; + log::success(result.to_string())?; + } + + // if build exists then proceed intro(format!("{}: Deploy a smart contract", style(" Pop CLI ").black().on_magenta()))?; + let instantiate_exec = set_up_deployment(UpOpts { path: self.path.clone(), constructor: self.constructor.clone(), From 4771cc7f1a6e984e99e5b411228f40a6af96c02c Mon Sep 17 00:00:00 2001 From: Bolaji Ahmad <56865496+bolajahmad@users.noreply.github.com> Date: Sat, 18 May 2024 23:47:39 +0100 Subject: [PATCH 2/4] fix: convert build_path check to check on path --- crates/pop-cli/src/commands/up/contract.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/pop-cli/src/commands/up/contract.rs b/crates/pop-cli/src/commands/up/contract.rs index a7a46879..0fc4ae4e 100644 --- a/crates/pop-cli/src/commands/up/contract.rs +++ b/crates/pop-cli/src/commands/up/contract.rs @@ -61,7 +61,10 @@ impl UpContractCommand { + "/target/release/ink", ); - if !build_path.exists() { + if !build_path.as_path().exists() { + log::warning(format!( + "NOTE: contract has not yet been built." + ))?; intro(format!("{}: Building a contract", style(" Pop CLI ").black().on_magenta()))?; // Directory exists, proceed with the rest of the code let result = build_smart_contract(&self.path)?; From c5770578c70d10c670a86c1f603a46f18fcc55ac Mon Sep 17 00:00:00 2001 From: Bolaji Ahmad <56865496+bolajahmad@users.noreply.github.com> Date: Tue, 21 May 2024 13:53:38 +0100 Subject: [PATCH 3/4] fix: removed the folder sturture for build to debug mode --- crates/pop-cli/src/commands/up/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/pop-cli/src/commands/up/contract.rs b/crates/pop-cli/src/commands/up/contract.rs index 0fc4ae4e..222b66ee 100644 --- a/crates/pop-cli/src/commands/up/contract.rs +++ b/crates/pop-cli/src/commands/up/contract.rs @@ -58,7 +58,7 @@ impl UpContractCommand { // Check if build exists in the specified "Contract build folder" let build_path = PathBuf::from( self.path.clone().unwrap_or("/.".into()).to_string_lossy().to_string() - + "/target/release/ink", + + "/target/ink", ); if !build_path.as_path().exists() { From 6d4fc38584e82650dc716a0d8ac9d33d60697b5c Mon Sep 17 00:00:00 2001 From: Bolaji Ahmad <56865496+bolajahmad@users.noreply.github.com> Date: Wed, 22 May 2024 08:26:54 +0100 Subject: [PATCH 4/4] run format on file changes; updated gitignore to ignore debug files possibly resulting from build --- .gitignore | 3 +++ crates/pop-cli/src/commands/up/contract.rs | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5fa23887..4bcbc5bd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ **/node_modules/ /src/x.rs +debug +**/debug/ + .DS_Store \ No newline at end of file diff --git a/crates/pop-cli/src/commands/up/contract.rs b/crates/pop-cli/src/commands/up/contract.rs index 222b66ee..d988dbcf 100644 --- a/crates/pop-cli/src/commands/up/contract.rs +++ b/crates/pop-cli/src/commands/up/contract.rs @@ -57,14 +57,11 @@ impl UpContractCommand { // Check if build exists in the specified "Contract build folder" let build_path = PathBuf::from( - self.path.clone().unwrap_or("/.".into()).to_string_lossy().to_string() - + "/target/ink", + self.path.clone().unwrap_or("/.".into()).to_string_lossy().to_string() + "/target/ink", ); if !build_path.as_path().exists() { - log::warning(format!( - "NOTE: contract has not yet been built." - ))?; + log::warning(format!("NOTE: contract has not yet been built."))?; intro(format!("{}: Building a contract", style(" Pop CLI ").black().on_magenta()))?; // Directory exists, proceed with the rest of the code let result = build_smart_contract(&self.path)?;