Skip to content

Commit

Permalink
ABS-166: Create accountability module (#47)
Browse files Browse the repository at this point in the history
* create initial structure

* create initial state

* create handlers and msg

* create execute handler

* update names update state

* update handlers

* add vote handler logic

* fix handler compiler errors

* refactor, cleanup

* update execute msg, more refactors

* create wasm test update toml

* create wasm test and setup for e2e

* create integration tests

* add more tests

* add friend test cases

* add vote cases

* updates

* integrate adairrr feedback

* update charge_penalty logic

* rebuilt wasms

* rebuilt wasms

* fix tests and cleanup

* clippy

* integrate PR feedback

* add impl methods on Vote and Friend

* update tests

* fix tests, refactor, cleanup

* integrate Buckram feedback

* add admin strike functionality and add challenge status

* update charge_penalty logic

* fix failing tests

* fix flaxy test, add remainder attribute

* update to Timestamp use EndKind enum for user input

* add Timestamp to Checkin and vote_status

* update contract logic

* remodel state, fix new ownership errors

* update charge penalty math and state

* fix tests intergrate feedback

* update composite key and field names

* update test after composite keys change

* remove redundant

* update comments

* update responses

* add transfer msg

* clippy

* clippy more

* run release_build

* Update modules/contracts/apps/challenge/src/handlers/execute.rs

Co-authored-by: Mykhailo Donchenko <[email protected]>

* Update modules/contracts/apps/challenge/src/handlers/execute.rs

Co-authored-by: Mykhailo Donchenko <[email protected]>

* integrate buckram feedback

* generate schema

* bump osmosis-test-tube

* integrate buckram123 feedback

* bump chrono

* bump chrono again

* chrono to 0.4.23

* chrono to 0.4.27

* chrono to 0.4.23

* croncat version bump

---------

Co-authored-by: Mykhailo Donchenko <[email protected]>
Co-authored-by: Buckram <[email protected]>
  • Loading branch information
3 people authored Sep 11, 2023
1 parent 266ff56 commit d3c1d81
Show file tree
Hide file tree
Showing 46 changed files with 4,845 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app-template/artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c2ea249ee0244d88defe24e09de2ba63f829614cb8866e7d74c9daa2ede7f4d2 app.wasm
4e4b097907a9eb0a31d4757f73ba741ca4452e1b9f632a4500cc1dfbeba01f4d app-aarch64.wasm
2 changes: 1 addition & 1 deletion app-template/artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9a0d0614b1b6ddc9707739b30ab330ff65c6f244fdfd3893c6f7fca5b471b0e8 ./target/wasm32-unknown-unknown/release/app.wasm
6a3347162d4e89d6aebafd8c7cbd40c686d8161e4b68797b39e1ca49bb4cfb49 ./target/wasm32-unknown-unknown/release/app.wasm
58 changes: 58 additions & 0 deletions integrations/osmosis/tests/osmosis-std-cosmwasm-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[package]
authors = ["Supanat Potiwarakorn <[email protected]>"]
edition = "2021"
name = "osmosis-std-cosmwasm-test"
version = "0.1.0"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
panic = 'abort'
rpath = false

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """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.6
"""

[dependencies]
cosmwasm-schema = "1.1.2"
cosmwasm-std = "1.1.2"
cosmwasm-storage = "1.1.2"
cw-storage-plus = "0.15"
cw2 = "0.13.2"
jsonformat = "2.0.0"
osmosis-std = { path = "../../packages/osmosis-std" }
schemars = "0.8.8"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.31" }

[dev-dependencies]
cw-multi-test = "0.13.2"
prost = "0.11.0"
serde_json = "1.0.85"
osmosis-test-tube = "19.0.0"
1 change: 1 addition & 0 deletions modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ serde = { version = "1.0", default-features = false, features = ["derive"] }
thiserror = { version = "1.0" }
protobuf = { version = "2", features = ["with-bytes"] }

chrono = { version = "0.4.23", default-features = false }
clap = { version = "4.0.32", features = ["derive"] }
semver = "1.0"
cw-semver = { version = "1.0" }
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added modules/artifacts/abstract_dca_app-aarch64.wasm
Binary file not shown.
Binary file not shown.
Binary file added modules/artifacts/abstract_etf-aarch64.wasm
Binary file not shown.
Binary file not shown.
14 changes: 8 additions & 6 deletions modules/artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
4ac9807ef85cb49b1833806702b5195e65744af76db8b490e8acbb5d0c63a728 target/wasm32-unknown-unknown/release/abstract_cw_staking.wasm
80166da60c09fe9cad73f18870a0b4675523b34a41a5833433a56e31c21f2d40 target/wasm32-unknown-unknown/release/abstract_dca_app.wasm
9be0995a2dbff62f0101189362f85a25dec45ddfbc417c9d93545dc98cfa9b07 target/wasm32-unknown-unknown/release/abstract_dex_adapter.wasm
04f8e8894190e762e98d80309650b0df8ccbcce1d655f2e03215b0622ee7f9ba target/wasm32-unknown-unknown/release/abstract_etf.wasm
3290043a8be44d63b5abc9b86231f8a0b98bd82286cf24bbbf1f9bcf717c3fbc target/wasm32-unknown-unknown/release/abstract_tendermint_staking_adapter.wasm
f4407c14b82dd969f93471bb43e4000fa9697c200ff0dca923a56c69cbd22357 target/wasm32-unknown-unknown/release/croncat_app.wasm
f6ff4989cbc6aac3d5ada6ebe6c4ea00d7bd1b2b889506d0f3cfba6c35d2fd7b target/wasm32-unknown-unknown/release/abstract_challenge_app.wasm
049aaf16853b1bb40841360d9f4763326cd338880dadbf7179d9b3fee073f3a8 target/wasm32-unknown-unknown/release/abstract_cw_staking.wasm
1e964735ea5b06b2040b258ee3d2d3c0b2f82ffaa2a3e4765c4ddfcdb66faaae target/wasm32-unknown-unknown/release/abstract_dca_app.wasm
3d16149cc183f6d75e8c665d5f9a9f2d32ed10beec54627db60f613845fa6e4c target/wasm32-unknown-unknown/release/abstract_dex_adapter.wasm
b0ab08be4104af9d09d812aed56ac24b3f197e5e2f9aec702e9bd61f0c75fedc target/wasm32-unknown-unknown/release/abstract_etf.wasm
81d2a2090c5baca4c8054f893742426377d2528c614350a65efeeea7394aedb3 target/wasm32-unknown-unknown/release/abstract_tendermint_staking_adapter.wasm
d2204708c0925b41ef75f5744cec3bf2e02793107b95b02fe398344c4dd18503 target/wasm32-unknown-unknown/release/croncat_app.wasm

Binary file added modules/artifacts/croncat_app-aarch64.wasm
Binary file not shown.
78 changes: 78 additions & 0 deletions modules/contracts/apps/challenge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[package]
name = "abstract-challenge-app"
version = "0.0.1"
authors = [
"CyberHoward <[email protected]>",
"Adair <[email protected]>",
"Abstract Money <[email protected]>",
"0xmovses <[email protected]>",
]
edition = "2021"
homepage = ""
documentation = ""
repository = ""
license = "GPL-3.0-or-later"
keywords = ["cosmos", "cosmwasm", "abstractsdk"]
resolver = "2"

exclude = ["contract.wasm", "hash.txt"]

[lib]
crate-type = ["cdylib", "rlib"]

[[example]]
name = "schema"
required-features = ["schema"]

[features]
default = ["export"]
export = []
# enable node-backed tests (ensure Docker is running)
# run with `cargo test --jobs 1 --features node-tests`
node-tests = ["interface"]
interface = ["export", "dep:abstract-interface", "dep:cw-orch"]
schema = ["abstract-app/schema"]

[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw-address-like = { workspace = true }
cw-controllers = { workspace = true }
cw-storage-plus = { workspace = true }
thiserror = { workspace = true }
schemars = { workspace = true }
cw-asset = { workspace = true }
cw-utils = { workspace = true }

abstract-core = { workspace = true }
abstract-app = { workspace = true }
abstract-sdk = { workspace = true }

chrono = { workspace = true, default-features = false }

# Dependencies for interface
abstract-interface = { workspace = true, optional = true }
cw-orch = { workspace = true, optional = true }
croncat-app = { workspace = true, default-features = false }
abstract-dex-adapter = { workspace = true, default-features = false }

[dev-dependencies]
abstract-challenge-app = { path = ".", features = ["interface"] }
abstract-interface = { workspace = true, features = ["daemon"] }
abstract-testing = { workspace = true }
abstract-sdk = { workspace = true, features = ["test-utils"] }
speculoos = "0.11.0"
semver = "1.0"
dotenv = "0.15.0"
env_logger = "0.10.0"
cw-orch = { workspace = true, features = ["daemon"] }
lazy_static = "1.4.0"

croncat-integration-testing = { version = "1.1.1", git = "https://github.com/CronCats/cw-croncat", branch = "unlocked-schedule" }
wyndex-bundle = { workspace = true }
abstract-dex-adapter = { workspace = true, features = [
"interface",
"juno",
"testing",
] }
croncat-app = { workspace = true, features = ["interface"] }
Empty file.
28 changes: 28 additions & 0 deletions modules/contracts/apps/challenge/examples/deploy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use cw_orch::{
anyhow,
prelude::{networks::parse_network, DaemonBuilder},
tokio::runtime::Runtime,
};

use abstract_challenge_app::{contract::CHALLENGE_APP_ID, ChallengeApp};
use abstract_interface::AppDeployer;
use semver::Version;

const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

fn main() -> anyhow::Result<()> {
dotenv().ok();
env_logger::init();
let chain = parse_network("uni-6");
use dotenv::dotenv;
let version: Version = CONTRACT_VERSION.parse().unwrap();
let rt = Runtime::new()?;
let chain = DaemonBuilder::default()
.chain(chain)
.handle(rt.handle())
.build()?;
let app = ChallengeApp::new(CHALLENGE_APP_ID, chain);

app.deploy(version)?;
Ok(())
}
14 changes: 14 additions & 0 deletions modules/contracts/apps/challenge/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use abstract_challenge_app::contract::ChallengeApp as App;
use cosmwasm_schema::remove_schemas;
use std::env::current_dir;
use std::fs::create_dir_all;

fn main() {
let mut out_dir = current_dir().unwrap();
out_dir.push("schema");
create_dir_all(&out_dir).unwrap();
remove_schemas(&out_dir).unwrap();

#[cfg(feature = "schema")]
App::export_schema(&out_dir);
}
110 changes: 110 additions & 0 deletions modules/contracts/apps/challenge/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Install the tools that are used in this justfile
install-tools:
cargo install cargo-nextest --locked
cargo install taplo-cli --locked
cargo install cargo-watch
cargo install cargo-limit

# Build everything
build:
cargo build --all-features

# Test everything
test:
cargo nextest run

watch-test:
cargo watch -x "nextest run"

# Format your code and `Cargo.toml` files
fmt:
cargo fmt --all
find . -type f -iname "*.toml" -print0 | xargs -0 taplo format

lint:
cargo clippy --all -- -D warnings

lintfix:
cargo clippy --fix --allow-staged --allow-dirty --all-features
just fmt

watch:
cargo watch -x "lcheck --all-features"

check:
cargo check --all-features

deploy:
cargo run --example deploy --features

wasm:
#!/usr/bin/env bash
# Delete all the current wasms first
rm -rf ./artifacts/*.wasm

if [[ $(arch) == "arm64" ]]; then
image="cosmwasm/rust-optimizer-arm64"
else
image="cosmwasm/rust-optimizer"
fi

# Optimized builds
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 \
${image}:0.12.13

# Generate the schemas for the app contract
schema:
cargo schema

# Generate the typescript client for the app contract
ts-codegen: schema
(cd typescript && npm run codegen)

# Publish the typescript sdk
ts-publish: ts-codegen
(cd typescript && npm publish --access public)

# Generate the schemas for this app and publish them to the schemas repository for access in the Abstract frontend
publish-schemas namespace name version: schema
#!/usr/bin/env bash
set -euxo pipefail
# Pre-run check for 'gh' CLI tool
if ! command -v gh &> /dev/null; then \
echo "'gh' could not be found. Please install GitHub CLI."; exit; \
fi

# check that the metadata exists
if [ ! -e "./metadata.json" ]; then \
echo "Please create metadata.json for module metadata"; exit; \
fi

tmp_dir="$(mktemp -d)"
schema_out_dir="$tmp_dir/{{namespace}}/{{name}}/{{version}}"
metadata_out_dir="$tmp_dir/{{namespace}}/{{name}}"

# Clone the repository to the temporary directory
git clone https://github.com/AbstractSDK/schemas "$tmp_dir"

# Create target directory structure and copy schemas
mkdir -p "$schema_out_dir"
cp -a "./schema/." "$schema_out_dir"

# Copy metadata.json to the target directory
cp "./metadata.json" "$metadata_out_dir"

# Create a new branch with a name based on the inputs
cd "$tmp_dir"
git checkout -b '{{namespace}}/{{name}}/{{version}}'

# Stage all new and changed files for commit
git add .

# Commit the changes with a message
git commit -m 'Add schemas for {{namespace}} {{name}} {{version}}'

# Create a pull request using 'gh' CLI tool
gh pr create --title 'Add schemas for {{namespace}} {{name}} {{version}}' --body ""
9 changes: 9 additions & 0 deletions modules/contracts/apps/challenge/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Challenge",
"description": "Create personal challenges and invite your friends to hold yourself accountable",
"website": "https://abstract.money/",
"docs": "",
"type": "app",
"icon": "RiCoinsLine",
"enabled": false
}
Loading

0 comments on commit d3c1d81

Please sign in to comment.