From 7e8f9078e4841ef4ca3851dbba22cfe675aae546 Mon Sep 17 00:00:00 2001 From: Yin Guanhao Date: Fri, 22 Dec 2023 17:04:41 +0800 Subject: [PATCH] chore: deprecate deploy --- README.md | 3 --- crates/tests/test-contract/capsule.toml | 2 -- src/bin/capsule.rs | 4 +++- src/config.rs | 2 +- src/generator/mod.rs | 1 - src/project_context.rs | 7 ++++++- templates/capsule.toml | 2 -- templates/deployment.toml | 27 ------------------------- 8 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 templates/deployment.toml diff --git a/README.md b/README.md index c1f11b2..a0031e3 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,6 @@ The following must be installed and available to use Capsule. $ cargo install cross --git https://github.com/cross-rs/cross ``` -- ckb-cli (optional) - Capsule requires `ckb-cli` to enable the smart contract deployment feature. https://github.com/nervosnetwork/ckb-cli/releases - Note: All commands must be accessible in the `PATH` in order for them to be used by Capsule. Note: The current user must have permission to manage Docker instances. [How to manage Docker as a non-root user.](https://docs.docker.com/engine/install/linux-postinstall/) @@ -88,7 +86,6 @@ capsule test ### Project Layout * `capsule.toml` - Capsule manifest file. -* `deployment.toml` - Deployment configuration. * `contracts` - Contracts directory. * `tests` - Contracts tests. * `build` - Contracts binaries. diff --git a/crates/tests/test-contract/capsule.toml b/crates/tests/test-contract/capsule.toml index f032b3a..338766e 100644 --- a/crates/tests/test-contract/capsule.toml +++ b/crates/tests/test-contract/capsule.toml @@ -5,8 +5,6 @@ # capsule version version = "0.10.0" -# path of deployment config file -deployment = "deployment.toml" [[contracts]] name = "test-contract" diff --git a/src/bin/capsule.rs b/src/bin/capsule.rs index 7fbbf82..674620d 100644 --- a/src/bin/capsule.rs +++ b/src/bin/capsule.rs @@ -127,7 +127,7 @@ fn run_cli() -> Result<()> { ).display_order(5)) .subcommand( SubCommand::with_name("deploy") - .about("Deploy contracts, edit deployment.toml to custodian deployment recipe.") + .about("[DEPRECATED] Deploy contracts, edit deployment.toml to custodian deployment recipe.") .args(&[ Arg::with_name("address").long("address").help( "Denote which address provides cells", @@ -374,6 +374,8 @@ fn run_cli() -> Result<()> { Tester::run(&context, build_env, test_name)?; } ("deploy", Some(args)) => { + eprintln!("Warning: capsule deploy is deprecated in favor of ckb-cli deploy"); + let ckb_cli_bin = args.value_of("ckb-cli").expect("ckb-cli"); Checker::build(ckb_cli_bin).check_ckb_cli()?; let address = { diff --git a/src/config.rs b/src/config.rs index 45dd439..d00244b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -50,7 +50,7 @@ pub struct Config { pub version: String, #[serde(default)] pub contracts: Vec, - pub deployment: PathBuf, // path of deployment config file + pub deployment: Option, // path of deployment config file #[serde(default)] pub rust: RustConfig, } diff --git a/src/generator/mod.rs b/src/generator/mod.rs index cdb12b2..8072056 100644 --- a/src/generator/mod.rs +++ b/src/generator/mod.rs @@ -64,7 +64,6 @@ fn gen_project_layout>(name: String, project_path: P) -> Result<( })?; for (f, template_name) in &[ ("capsule.toml", None), - ("deployment.toml", None), ("README.md", None), ("rust-toolchain", None), ("Cross.toml", None), diff --git a/src/project_context.rs b/src/project_context.rs index b82a87d..e3d99ae 100644 --- a/src/project_context.rs +++ b/src/project_context.rs @@ -150,7 +150,12 @@ impl Context { pub fn load_deployment(&self) -> Result { let mut path = self.project_path.clone(); - path.push(&self.config.deployment); + path.push( + self.config + .deployment + .as_deref() + .unwrap_or_else(|| Path::new("deployment.toml")), + ); match toml_edit::de::from_str(&fs::read_to_string(&path)?) { Ok(deployment) => Ok(deployment), Err(err) => { diff --git a/templates/capsule.toml b/templates/capsule.toml index bea5618..5aa0861 100644 --- a/templates/capsule.toml +++ b/templates/capsule.toml @@ -5,5 +5,3 @@ # capsule version version = "{{ version }}" -# path of deployment config file -deployment = "deployment.toml" diff --git a/templates/deployment.toml b/templates/deployment.toml deleted file mode 100644 index 62d23d4..0000000 --- a/templates/deployment.toml +++ /dev/null @@ -1,27 +0,0 @@ -# [[cells]] -# name = "my_cell" -# enable_type_id = false -# location = { file = "build/release/my_cell" } -# -# # reference to on-chain cells -# [[cells]] -# name = "genesis_cell" -# enable_type_id = false -# location = { tx_hash = "0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c", index = 0 } - - -# # Dep group cells -# [[dep_groups]] -# name = "my_dep_group" -# cells = [ -# "my_cell", -# "genesis_cell" -# ] - -# # Replace with your own lock if you want to unlock deployed cells. -# # For example the secp256k1 lock -# [lock] -# code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" -# args = "0x0000000000000000000000000000000000000000" -# hash_type = "type" -