diff --git a/Cargo.toml b/Cargo.toml index aed559173f7d9a93ef27b6c7e843ed3a907202f3..5fc193ed845ead5c3e7fc119ab4bbe4afdcc57fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,11 +24,12 @@ zip = { version = "0.5", default-features = false } pwasm-utils = "0.12" parity-wasm = "0.41" cargo_metadata = "0.9" -substrate-primitives = { git = "https://github.com/paritytech/substrate/", package = "substrate-primitives" } -subxt = { git = "https://github.com/paritytech/substrate-subxt/", branch = "v0.3", package = "substrate-subxt" } -tokio = "0.1" -futures = "0.1" -url = "1.7" + +substrate-primitives = { git = "https://github.com/paritytech/substrate/", package = "substrate-primitives", optional = true } +subxt = { git = "https://github.com/paritytech/substrate-subxt/", branch = "v0.3", package = "substrate-subxt", optional = true } +tokio = { version = "0.1", optional = true } +futures = { version = "0.1", optional = true } +url = { version = "1.7", optional = true } [build-dependencies] anyhow = "1.0" @@ -42,4 +43,5 @@ wabt = "0.9" [features] default = [] +deploy = ["substrate-primitives", "subxt", "tokio", "futures", "url"] test-ci-only = [] diff --git a/README.md b/README.md index f21c2ae4de83254c4438a24854ca7dac12ed76ac..f7781b596e19564484ab92c573d7fd80b66305c5 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,14 @@ SUBCOMMANDS: help Prints this message or the help of the given subcommand(s) ``` +## Feature + +The `deploy` subcommand is **disabled by default**, since it's not working properly at the moment and increases the build time. + +If you want to try it, you need to enable the `deploy` feature. + +Once it is working properly and the compilation time is acceptable, we will consider removing the `deploy` feature. + ## License The entire code within this repository is licensed under the [GPLv3](LICENSE). Please [contact us](https://www.parity.io/contact/) if you have questions about the licensing of our products. diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 7687c7e6d7dbe0de46571515549d80d2f23d6744..da1da85b2e7c8388754e6eae1518b27a5cb7820e 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -26,14 +26,7 @@ const MAX_MEMORY_PAGES: u32 = 16; /// Relevant metadata obtained from Cargo.toml. pub struct CrateMetadata { original_wasm: PathBuf, - dest_wasm: PathBuf, -} - -impl CrateMetadata { - /// Get the path of the wasm destination file - pub fn dest_wasm(self) -> PathBuf { - self.dest_wasm - } + pub dest_wasm: PathBuf, } /// Parses the contract manifest and returns relevant metadata. diff --git a/src/cmd/deploy.rs b/src/cmd/deploy.rs index cd9b8d8572203ff5a3df23e070bde5bbffbbc68f..245d79b2a184ddb426a492dcb8dfc36e4b816ca0 100644 --- a/src/cmd/deploy.rs +++ b/src/cmd/deploy.rs @@ -27,7 +27,7 @@ use crate::cmd::build::{self, CrateMetadata}; /// /// Defaults to the target contract wasm in the current project, inferred via the crate metadata. fn load_contract_code(path: Option<&PathBuf>) -> Result> { - let default_wasm_path = build::collect_crate_metadata(path).map(CrateMetadata::dest_wasm)?; + let default_wasm_path = build::collect_crate_metadata(path)?.dest_wasm; let contract_wasm_path = path.unwrap_or(&default_wasm_path); let mut data = Vec::new(); diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index b9fd558e34c2148eae77b0149b0212e5fba09774..64a93ec55c85a34bf0610233ec8fc1dbf6d50a8c 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -23,13 +23,15 @@ use std::{ use anyhow::Result; mod build; +#[cfg(feature = "deploy")] mod deploy; mod metadata; mod new; +#[cfg(feature = "deploy")] +pub(crate) use self::deploy::execute_deploy; pub(crate) use self::{ - build::execute_build, deploy::execute_deploy, metadata::execute_generate_metadata, - new::execute_new, + build::execute_build, metadata::execute_generate_metadata, new::execute_new, }; fn exec_cargo(command: &str, args: &[&'static str], working_dir: Option<&PathBuf>) -> Result<()> { diff --git a/src/main.rs b/src/main.rs index 1ada966a048043b747ebade2ed364f4c6acd85e2..5f3e529da1e4212164559ed21c5f5148c5e3b20e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,6 +91,7 @@ enum Command { #[structopt(name = "test")] Test {}, /// Deploy the smart contract on-chain. (Also for testing purposes.) + #[cfg(feature = "deploy")] #[structopt(name = "deploy")] Deploy { /// Websockets url of a substrate node @@ -136,6 +137,7 @@ fn exec(cmd: Command) -> Result { Command::Build {} => cmd::execute_build(None), Command::GenerateMetadata {} => cmd::execute_generate_metadata(None), Command::Test {} => Err(anyhow::anyhow!("Command unimplemented")), + #[cfg(feature = "deploy")] Command::Deploy { url, suri,