This is an example for cosmwasm smartcontracts to consume and query umee native modules.
- The actual lib to connect to umee native modules is inside
packages/umee-types
and is being used as an library insidesrc
folder
- To use the umee-types library you can do the same as the
src/contract.rs
andsrc/msg.rs
files that consumes all the queries availables with examples
- If you don't know that much about rust or cosmwasm, take a look at Rust Tips
- To compile the local example and it's dependences packages
$~ cargo build
- The
.wasm
file are the contract compiled used to deploy it in the blockchain - To test and generate an
.wasm
file form thesrc
folder
$~ cargo wasm
-
The generated wasm file will be inside
./target/wasm32-unknown-unknown/release/*.wasm
-
To generate the
.wasm
file optimized to production run
$~ docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.8
- Or, If you're on an arm64 machine, you should use a docker image built with arm64.
$ docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer-arm64:0.12.8
- This will generate the optimized compiled contract inside the
artifact
folder
- Schemas (
schema
folder) can be used to understand and communicate with the smartcontract they are basic the representation of the contract entrypoints messages and responses structures defined in json
tip: if you are used to solidity, it's almost the contract ABI
- To generate the schemas based on the current files changes
$~ cargo schema
- Tips on how to publish rust packages, look at Publishing
- To add new modules inside the umee-types package, copy the leverage query file, like
$~ cp ./packages/umee-types/src/query_leverage.rs ./packages/umee-types/src/query_${MODULE_NAME}.rs
- Change everything from leverage to the new module name
- Add the new enum module to the
pub enum UmeeQuery
inside./packages/umee-types/src/query.rs
- Create the structs for params and response in the respective query module
./packages/umee-types/src/query_${MODULE_NAME}.rs
and also a new entry in thepub enum UmeeQuery${MODULE_NAME}
and a newpub const ASSIGNED_QUERY_${QUERY_NAME}
that correspond to the same value in theumee-network/umee/app/wasm/query/types.go
from the umee public repository - Add a new property that represents the query in the
pub struct StructUmeeQuery
as anOption<QueryParams>
because it can be nil and a new function to instantiate theStructUmeeQuery
struct insideimpl StructUmeeQuery
inside./packages/umee-types/src/query.rs
- Expose the new query in
./packages/umee-types/src/lib.rs
It is expected that you have installed cargo-make
- After your changes, you can check if everything is running as expected at onde running the following script
$~ cargo make git_flow
Gitpod container-based development platform will be enabled on your project by default.
Workspace contains:
- rust: for builds
- wasmd: for local node setup and client
- jq: shell JSON manipulation tool
Follow Gitpod Getting Started and launch your workspace.