diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3d36f20 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.rs] +indent_size = 4 diff --git a/.gitignore b/.gitignore index f298c58..f6f627c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /target **/*.rs.bk -*.iml \ No newline at end of file +*.iml diff --git a/README.md b/README.md index 00c9a1b..f429176 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Cosmwasm Starter Pack -This is a template to build smart contracts in Rust to run inside a +This is a template to build smart contracts in Rust to run inside a [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) module on all chains that enable it. To understand the framework better, please read the overview in the [cosmwasm repo](https://github.com/confio/cosmwasm/blob/master/README.md). @@ -8,9 +8,9 @@ This assumes you understand the theory and just want to get coding. ## Creating a new repo from template -Before starting, make sure you have [rustup](https://rustup.rs/) along with a recent `rustc` and `cargo` -version installed. Currently, we are testing on 1.37+. - +Before starting, make sure you have [rustup](https://rustup.rs/) along with a recent `rustc` and `cargo` +version installed. Currently, we are testing on 1.37+. + And you need to have the `wasm32-unknown-unknown` target installed as well. You can check that via: @@ -23,7 +23,7 @@ rustup target list --installed rustup target add wasm32-unknown-unknown ``` -You will also need to have +You will also need to have [cargo generate](https://github.com/ashleygwilliams/cargo-generate) installed. Unless you did that before, run this line now: @@ -44,7 +44,7 @@ containing a simple working contract and build system that you can customize. ## Compiling and running tests Now that you created your custom contract, make sure you can compile and run it before -making any changes. Go into the +making any changes. Go into the ```shell script # this will produce a wasm build in ./target/wasm32-unknown-unknown/release/YOUR_NAME_HERE.wasm @@ -64,15 +64,15 @@ cargo test --no-default-features --features singlepass cargo schema ``` -The wasmer engine, embedded in `cosmwasm-vm` supports multiple backends: +The wasmer engine, embedded in `cosmwasm-vm` supports multiple backends: singlepass and cranelift. Singlepass has fast compile times and slower run times, and supportes gas metering. It also requires rust `nightly`. This is used as default when embedding `cosmwasm-vm` in `go-cosmwasm` and is needed to use if you want to -check the gas usage. +check the gas usage. However, when just building contacts, if you don't want to worry about installing two rust toolchains, you can run all tests with cranelift. The integration tests -may take a small bit longer, but the results will be the same. The only difference +may take a small bit longer, but the results will be the same. The only difference is that you can not check gas usage here, so if you wish to optimize gas, you must switch to nightly and run with cranelift. @@ -82,7 +82,7 @@ The main code is in `src/contract.rs` and the unit tests there run in pure rust, which makes them very quick to execute and give nice output on failures, especially if you do `RUST_BACKTRACE=1 cargo test`. -However, we don't just want to test the logic rust, but also the compiled wasm artifact +However, we don't just want to test the logic rust, but also the compiled wasm artifact inside a vm. You can look in `tests/integration.rs` to see some examples there. They load the wasm binary into the vm and call the contract externally. Effort has been made that the syntax is very similar to the calls in the native rust contract and @@ -129,4 +129,4 @@ compilation cache with your host system, in order to provide the most consistent We also track the versions of cosmwasm that we aim for compatibility. The most important aspect is the same version of wasm-pack and wasm-bindgen. For 0.4.1 we are tied to -wasm-pack 0.8.1, wasm-bindgen 0.2.53, and rust 1.38. \ No newline at end of file +wasm-pack 0.8.1, wasm-bindgen 0.2.53, and rust 1.38.