From 84c2edb007a334454948de276bc0b7ee5c7ba671 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Thu, 5 Aug 2021 13:52:13 +0800 Subject: [PATCH] Update readme & version --- README.md | 24 ++++++++++++++++++++++-- cargo-sewup/Cargo.toml | 2 +- sewup-derive/Cargo.toml | 2 +- sewup/Cargo.toml | 4 ++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 030757832..e5462d623 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,20 @@ opt-level = "z" [profile.release.package.hello-contract] # package name incremental = false opt-level = "z" + +# Following section including the parameters to deploy the contract +[deploy] +url = "http://localhost:8545" # url for rpc node +private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # private key +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. @@ -62,7 +76,12 @@ Here is minimize example for writing a contract with sewup use anyhow::Result; use sewup::primitives::Contract; -use sewup_derive::{ewasm_fn, ewasm_fn_sig, ewasm_main, ewasm_test}; +use sewup_derive::{ewasm_constructor, ewasm_fn, ewasm_fn_sig, ewasm_main, ewasm_test}; + +#[ewasm_constructor] +fn constructor() { + # do something you want when the contract deploy on chain +} #[ewasm_fn] fn hello() -> Result { @@ -95,7 +114,8 @@ mod tests { ### Testing Run `cargo build --release --target=wasm32-unknown-unknown`, then the contract will build in `target/wasm32-unknown-unknown/release/*.wasm` -Besides, you can run deploy the ewasm contract on [WasmEdge](https://github.com/WasmEdge/WasmEdge) and run tests on it with `cargo test`. +Besides, you can run deploy the ewasm contract on [WasmEdge](https://github.com/WasmEdge/WasmEdge) and run tests on it with `cargo test`, +furthermore the constructor will also run when the contract deploying on [WasmEdge](https://github.com/WasmEdge/WasmEdge). ### Debugging Furthermore, you can debug your ewasm contract with debug macro `sewup::ewasm_dbg!`, and run the contract with message output by `cargo test -- --nocapture`. diff --git a/cargo-sewup/Cargo.toml b/cargo-sewup/Cargo.toml index 1a8f69233..a09bf2337 100644 --- a/cargo-sewup/Cargo.toml +++ b/cargo-sewup/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-sewup" -version = "0.0.7" +version = "0.0.8" edition = "2018" description = "A cli tool build sewup project to a deploy wasm" license = "Apache-2.0" diff --git a/sewup-derive/Cargo.toml b/sewup-derive/Cargo.toml index 70c4196ef..a43d468a5 100644 --- a/sewup-derive/Cargo.toml +++ b/sewup-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sewup-derive" -version = "0.0.7" +version = "0.0.8" authors = ["Antonio Yang "] edition = "2018" description = "Macros implementation for SewUp" diff --git a/sewup/Cargo.toml b/sewup/Cargo.toml index 7b615f451..609ce9cb2 100644 --- a/sewup/Cargo.toml +++ b/sewup/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sewup" -version = "0.0.7" +version = "0.0.8" authors = ["Antonio Yang "] edition = "2018" build="build.rs" @@ -18,7 +18,7 @@ serde-value = "0.7.0" toml = "0.5.8" ewasm_api = { version = "0.11.0", default-features = false, features = ["std", "qimalloc"], package = "ss_ewasm_api" } tiny-keccak = { version = "2.0.2", features = ["sha3", "keccak"] } -sewup-derive = { version = "0.0.7", path = "../sewup-derive" } +sewup-derive = { version = "0.0.8" } bincode = "1.3" cryptoxide = "0.3.3"