Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check if build exists before deploying contract with pop up #177

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
**/node_modules/
/src/x.rs

debug
**/debug/

.DS_Store

# IDEs
.idea
.vscode
.vscode
19 changes: 17 additions & 2 deletions crates/pop-cli/src/commands/up/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,6 +54,21 @@ 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/ink",
);

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()))?;
bolajahmad marked this conversation as resolved.
Show resolved Hide resolved
// 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 {
Expand Down
Loading