diff --git a/README.md b/README.md index c8651ccf7..c175d035e 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,15 @@ opt-level = "z" incremental = false opt-level = "z" +# Following features helps are used when building or testing a contract +[features] +constructor = [] # required +constructor-test = [] # required +``` + +```toml +# sewup.toml + # Following section including the parameters to deploy the contract [deploy] url = "http://localhost:8545" # url for rpc node @@ -68,11 +77,6 @@ address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" # account address # gas = 5000000 # optional # gas_price = 1 # optional - -# Following features helps are used when building or testing a contract -[features] -constructor = [] # required -constructor-test = [] # required ``` Place [.cargo/config](./examples/hello-contract/.cargo/config) file in your project to specify the flags for build. diff --git a/SewUp.wiki b/SewUp.wiki index 9046f0697..06eeee5f4 160000 --- a/SewUp.wiki +++ b/SewUp.wiki @@ -1 +1 @@ -Subproject commit 9046f0697a5e6de8bc334f7f754a0e3406e26864 +Subproject commit 06eeee5f4058cbb29c1c2390550a8c64b4a9897d diff --git a/cargo-sewup/src/build.rs b/cargo-sewup/src/build.rs index 6ba177f48..0d3302347 100644 --- a/cargo-sewup/src/build.rs +++ b/cargo-sewup/src/build.rs @@ -10,14 +10,14 @@ use tokio::{ use wasmprinter::print_file; use wat; -use cargo_sewup::config::Toml; +use cargo_sewup::config::CargoToml; use cargo_sewup::deploy_wasm; async fn check_cargo_toml() -> Result { let config_contents = read_to_string("Cargo.toml") .await .context("can not read Cargo.toml")?; - let config: Toml = toml::from_str(config_contents.as_str())?; + let config: CargoToml = toml::from_str(config_contents.as_str())?; // TODO: more toml config checking here diff --git a/cargo-sewup/src/config.rs b/cargo-sewup/src/config.rs index d9fd9f6d7..ba36794a8 100644 --- a/cargo-sewup/src/config.rs +++ b/cargo-sewup/src/config.rs @@ -5,7 +5,6 @@ use serde_derive::Deserialize; use tokio::fs::read_to_string; use crate::constants::{DEFAULT_GAS, DEFAULT_GAS_PRICE}; -use crate::errors::DeployError; #[derive(Deserialize)] pub struct Deploy { @@ -37,20 +36,20 @@ pub struct Package { } #[derive(Deserialize)] -pub struct Toml { +pub struct CargoToml { pub package: Package, - pub deploy: Option, +} + +#[derive(Deserialize)] +pub struct DeployToml { + pub deploy: Deploy, } pub async fn get_deploy_config() -> Result { - let config_contents = read_to_string("Cargo.toml") + let config_contents = read_to_string("sewup.toml") .await - .context("can not read Cargo.toml")?; - let config: Toml = toml::from_str(config_contents.as_str())?; + .context("can not read sewup.toml")?; + let config: DeployToml = toml::from_str(config_contents.as_str())?; - if let Some(deploy) = config.deploy { - Ok(deploy) - } else { - Err(DeployError::ConfigIncorrect.into()) - } + Ok(config.deploy) } diff --git a/examples/default-contract/Cargo.toml b/examples/default-contract/Cargo.toml index afd496637..0a2238439 100644 --- a/examples/default-contract/Cargo.toml +++ b/examples/default-contract/Cargo.toml @@ -27,13 +27,6 @@ opt-level = "z" incremental = false opt-level = "z" -[deploy] -url = "http://localhost:8545" -private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -gas = 5000000 -gas_price = 1 - [features] constructor = [] constructor-test = [] diff --git a/examples/default-contract/sewup.toml b/examples/default-contract/sewup.toml new file mode 100644 index 000000000..e83d91670 --- /dev/null +++ b/examples/default-contract/sewup.toml @@ -0,0 +1,7 @@ +# This config file is for examples, it is good for you to ignore this config in your sewup project +[deploy] +url = "http://localhost:8545" +private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +gas = 5000000 +gas_price = 1 diff --git a/examples/erc1155-contract/Cargo.toml b/examples/erc1155-contract/Cargo.toml index a88291ab3..e6804dd7d 100644 --- a/examples/erc1155-contract/Cargo.toml +++ b/examples/erc1155-contract/Cargo.toml @@ -27,11 +27,6 @@ opt-level = "z" incremental = false opt-level = "z" -[deploy] -url = "http://localhost:8545" -private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - [features] constructor = [] constructor-test = [] diff --git a/examples/erc1155-contract/sewup.toml b/examples/erc1155-contract/sewup.toml new file mode 100644 index 000000000..16b9bab71 --- /dev/null +++ b/examples/erc1155-contract/sewup.toml @@ -0,0 +1,5 @@ +# This config file is for examples, it is good for you to ignore this config in your sewup project +[deploy] +url = "http://localhost:8545" +private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" diff --git a/examples/erc20-contract/Cargo.toml b/examples/erc20-contract/Cargo.toml index 4e8216043..5a3f5bc20 100644 --- a/examples/erc20-contract/Cargo.toml +++ b/examples/erc20-contract/Cargo.toml @@ -27,11 +27,6 @@ opt-level = "z" incremental = false opt-level = "z" -[deploy] -url = "http://localhost:8545" -private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - [features] constructor = [] constructor-test = [] diff --git a/examples/erc20-contract/sewup.toml b/examples/erc20-contract/sewup.toml new file mode 100644 index 000000000..16b9bab71 --- /dev/null +++ b/examples/erc20-contract/sewup.toml @@ -0,0 +1,5 @@ +# This config file is for examples, it is good for you to ignore this config in your sewup project +[deploy] +url = "http://localhost:8545" +private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" diff --git a/examples/erc721-contract/Cargo.toml b/examples/erc721-contract/Cargo.toml index 741f744c7..95415d54c 100644 --- a/examples/erc721-contract/Cargo.toml +++ b/examples/erc721-contract/Cargo.toml @@ -27,11 +27,6 @@ opt-level = "z" incremental = false opt-level = "z" -[deploy] -url = "http://localhost:8545" -private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - [features] constructor = [] constructor-test = [] diff --git a/examples/erc721-contract/sewup.toml b/examples/erc721-contract/sewup.toml new file mode 100644 index 000000000..16b9bab71 --- /dev/null +++ b/examples/erc721-contract/sewup.toml @@ -0,0 +1,5 @@ +# This config file is for examples, it is good for you to ignore this config in your sewup project +[deploy] +url = "http://localhost:8545" +private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" diff --git a/examples/hello-contract/Cargo.toml b/examples/hello-contract/Cargo.toml index 6247dcd9d..14e22f73a 100644 --- a/examples/hello-contract/Cargo.toml +++ b/examples/hello-contract/Cargo.toml @@ -37,11 +37,6 @@ opt-level = "z" incremental = false opt-level = "z" -[deploy] -url = "http://localhost:8545" -private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - [features] constructor = [] constructor-test = [] diff --git a/examples/hello-contract/sewup.toml b/examples/hello-contract/sewup.toml new file mode 100644 index 000000000..16b9bab71 --- /dev/null +++ b/examples/hello-contract/sewup.toml @@ -0,0 +1,5 @@ +# This config file is for examples, it is good for you to ignore this config in your sewup project +[deploy] +url = "http://localhost:8545" +private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" diff --git a/examples/kv-contract/Cargo.toml b/examples/kv-contract/Cargo.toml index 8eef5c11b..3db16db8c 100644 --- a/examples/kv-contract/Cargo.toml +++ b/examples/kv-contract/Cargo.toml @@ -41,11 +41,6 @@ opt-level = "z" incremental = false opt-level = "z" -[deploy] -url = "http://localhost:8545" -private = "0000000000000000000000000000000000000000000000000000000000000000" -address = "0x0000000000000000000000000000000000000000" - [features] client = [ "web3", "tokio", "secp256k1", "reqwest", "serde_json", "bincode", "cargo-sewup"] constructor = [] diff --git a/examples/kv-contract/sewup.toml b/examples/kv-contract/sewup.toml new file mode 100644 index 000000000..4ec36daa8 --- /dev/null +++ b/examples/kv-contract/sewup.toml @@ -0,0 +1,5 @@ +# This config file is for examples, it is good for you to ignore this config in your sewup project +[deploy] +url = "http://localhost:8545" +private = "0000000000000000000000000000000000000000000000000000000000000000" +address = "0x0000000000000000000000000000000000000000" diff --git a/examples/rdb-contract/Cargo.toml b/examples/rdb-contract/Cargo.toml index a6eae69e8..84dd99a9d 100644 --- a/examples/rdb-contract/Cargo.toml +++ b/examples/rdb-contract/Cargo.toml @@ -43,11 +43,6 @@ opt-level = "z" incremental = false opt-level = "z" -[deploy] -url = "http://localhost:8545" -private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - [features] client = [ "web3", "tokio", "secp256k1", "reqwest", "serde_json", "bincode", "cargo-sewup"] constructor = [] diff --git a/examples/rdb-contract/sewup.toml b/examples/rdb-contract/sewup.toml new file mode 100644 index 000000000..16b9bab71 --- /dev/null +++ b/examples/rdb-contract/sewup.toml @@ -0,0 +1,5 @@ +# This config file is for examples, it is good for you to ignore this config in your sewup project +[deploy] +url = "http://localhost:8545" +private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" diff --git a/examples/rusty-contract/Cargo.toml b/examples/rusty-contract/Cargo.toml index a2d1090fc..5e6d03753 100644 --- a/examples/rusty-contract/Cargo.toml +++ b/examples/rusty-contract/Cargo.toml @@ -25,11 +25,6 @@ opt-level = "z" incremental = false opt-level = "z" -[deploy] -url = "http://localhost:8545" -private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" - [features] constructor = [] constructor-test = [] diff --git a/examples/rusty-contract/sewup.toml b/examples/rusty-contract/sewup.toml new file mode 100644 index 000000000..16b9bab71 --- /dev/null +++ b/examples/rusty-contract/sewup.toml @@ -0,0 +1,5 @@ +# This config file is for examples, it is good for you to ignore this config in your sewup project +[deploy] +url = "http://localhost:8545" +private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"