From f63ae7683233cb91e2004701d4b803fbb17fff31 Mon Sep 17 00:00:00 2001 From: hu55a1n1 Date: Wed, 29 Nov 2023 08:34:24 -0800 Subject: [PATCH] Update README.md --- bisenzone-cw-mvp/README.md | 139 +++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/bisenzone-cw-mvp/README.md b/bisenzone-cw-mvp/README.md index 6264428..ac586cc 100644 --- a/bisenzone-cw-mvp/README.md +++ b/bisenzone-cw-mvp/README.md @@ -1,85 +1,88 @@ -# CosmWasm Starter Pack +# Bisenzone CosmWasm MVP -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/CosmWasm/cosmwasm/blob/master/README.md), -and dig into the [cosmwasm docs](https://www.cosmwasm.com). -This assumes you understand the theory and just want to get coding. +CosmWasm smart contracts used in the Bisenzone MVP. -## Creating a new repo from template +## Testing instructions -Assuming you have a recent version of Rust and Cargo installed -(via [rustup](https://rustup.rs/)), -then the following should get you a new repo to start a contract: +* Deploy the smart contract on a local wasmd instance + (see [Obligation Clearing Mvp: Local setup](https://github.com/informalsystems/obligation-clearing-mvp#local-setup)) + * Should normally be as simple as running the following scripts -> + ```bash + # terminal-1 + ./scripts/keygen.sh + ./scripts/init-node.sh + ./scripts/run-node.sh + ``` + ```bash + # terminal-2 + ./scripts/build-contract.sh + ./scripts/deploy-contract.sh artifacts/cw_mtcs.wasm + ``` +* Set contract env var (using the output of the `deploy.sh` script) - -Install [cargo-generate](https://github.com/ashleygwilliams/cargo-generate) and cargo-run-script. -Unless you did that before, run this line now: - -```sh -cargo install cargo-generate --features vendored-openssl -cargo install cargo-run-script +``` +export CONTRACT="wasm13we0myxwzlpx8l5ark8elw5gj5d59dl6cjkzmt80c5q5cv5rt54qhmta7s" ``` -Now, use it to create your new contract. -Go to the folder in which you want to place it and run: +* Upload a cycle of obligations - -**Latest** +``` +export EXECUTE='{ + "upload_obligation": { + "creditor": "wasm19u72czh0w4jraan8esalv48nrwemh8kgax69yw", + "amount": "100", + "memo": "alice -> bob" + } +}' +wasmd tx wasm execute "$CONTRACT" "$EXECUTE" --from alice --chain-id testing -y -```sh -cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME +export EXECUTE='{ + "upload_obligation": { + "creditor": "wasm12r9t5wmre89rwakr0e5nyhfmaf4kdleyltsm9f", + "amount": "80", + "memo": "bob -> charlie" + } +}' +wasmd tx wasm execute "$CONTRACT" "$EXECUTE" --from bob --chain-id testing -y + +export EXECUTE='{ + "upload_obligation": { + "creditor": "wasm19xlctyn7ha6pqg7pk9lnk8y60rk8646dm86qgv", + "amount": "70", + "memo": "charlie -> alice" + } +}' +wasmd tx wasm execute "$CONTRACT" "$EXECUTE" --from charlie --chain-id testing -y ``` -For cloning minimal code repo: +* Clear cycle - -```sh -cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME -d minimal=true +``` +export EXECUTE='{ + "apply_cycle": { + "path": ["wasm19xlctyn7ha6pqg7pk9lnk8y60rk8646dm86qgv", "wasm19u72czh0w4jraan8esalv48nrwemh8kgax69yw", "wasm12r9t5wmre89rwakr0e5nyhfmaf4kdleyltsm9f", "wasm19xlctyn7ha6pqg7pk9lnk8y60rk8646dm86qgv"], + "amount": "70" + } +}' +wasmd tx wasm execute "$CONTRACT" "$EXECUTE" --from alice --chain-id testing -y ``` -You will now have a new folder called `PROJECT_NAME` (I hope you changed that to something else) -containing a simple working contract and build system that you can customize. +* Query obligations - -## Create a Repo - -After generating, you have a initialized local git repo, but no commits, and no remote. -Go to a server (eg. github) and create a new upstream repo (called `YOUR-GIT-URL` below). -Then run the following: - -```sh -# this is needed to create a valid Cargo.lock file (see below) -cargo check -git branch -M main -git add . -git commit -m 'Initial Commit' -git remote add origin YOUR-GIT-URL -git push -u origin main +``` +* wasmd query wasm contract-state smart "$CONTRACT" '{ + "get_obligations": { + "creditor": "wasm19u72czh0w4jraan8esalv48nrwemh8kgax69yw" + } +}' ``` -## CI Support +* Check balance of the solver (to confirm increase in karma) - -We have template configurations for both [GitHub Actions](.github/workflows/Basic.yml) -and [Circle CI](.circleci/config.yml) in the generated project, so you can -get up and running with CI right away. - -One note is that the CI runs all `cargo` commands -with `--locked` to ensure it uses the exact same versions as you have locally. This also means -you must have an up-to-date `Cargo.lock` file, which is not auto-generated. -The first time you set up the project (or after adding any dep), you should ensure the -`Cargo.lock` file is updated, so the CI will test properly. This can be done simply by -running `cargo check` or `cargo unit-test`. - -## Using your project - -Once you have your custom repo, you should check out [Developing](./Developing.md) to explain -more on how to run tests and develop code. Or go through the -[online tutorial](https://docs.cosmwasm.com/) to get a better feel -of how to develop. - -[Publishing](./Publishing.md) contains useful information on how to publish your contract -to the world, once you are ready to deploy it on a running blockchain. And -[Importing](./Importing.md) contains information about pulling in other contracts or crates -that have been published. - -Please replace this README file with information about your specific project. You can keep -the `Developing.md` and `Publishing.md` files as useful references, but please set some -proper description in the README. +``` +wasmd query wasm contract-state smart "$CONTRACT" '{ + "balance": { + "address": "wasm19xlctyn7ha6pqg7pk9lnk8y60rk8646dm86qgv" + } +}' +```