diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5544c9486..6d6a95f1b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -634,52 +634,6 @@ jobs: exit 1 fi - contract_voting_with_uuid: - name: contract_voting_with_uuid - runs-on: ubuntu-latest - env: - working-directory: ./contracts/voting-with-uuid - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.60.0 - target: wasm32-unknown-unknown - profile: minimal - override: true - - name: Cache cargo - uses: actions/cache@v3 - with: - path: ~/.cargo - key: cargocache-v2-contract_staking-rust:1.60.0-${{ hashFiles('contracts/voting-with-uuid/Cargo.lock') }} - - name: Version information - run: rustc --version; cargo --version; rustup --version; rustup target list --installed - - name: Add wasm32 target - run: rustup target add wasm32-unknown-unknown && rustup target list --installed - - name: Build wasm binary - working-directory: ${{env.working-directory}} - run: cargo wasm --locked - - name: Unit tests - working-directory: ${{env.working-directory}} - run: cargo unit-test --locked - - name: Integration tests (singlepass backend) - working-directory: ${{env.working-directory}} - run: cargo integration-test-for-ci --locked --no-default-features - - name: Build and run schema generator - working-directory: ${{env.working-directory}} - run: cargo schema --locked - - name: Ensure schemas are up-to-date - working-directory: ${{env.working-directory}} - run: | - CHANGES_IN_REPO=$(git status --porcelain) - if [[ -n "$CHANGES_IN_REPO" ]]; then - echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:" - git status && git --no-pager diff - exit 1 - fi - fmt: name: fmt runs-on: ubuntu-latest diff --git a/contracts/README.md b/contracts/README.md index f8e722104..3fbf683b8 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -64,11 +64,6 @@ docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="devcontract_cache_staking",target=/code/contracts/staking/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/rust-optimizer:0.12.9 ./contracts/staking - -docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="devcontract_cache_voting_with_uuid",target=/code/contracts/voting-with-uuid/target \ - --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/rust-optimizer:0.12.9 ./contracts/voting-with-uuid ``` ## Entry points @@ -84,4 +79,3 @@ points in order to demonstrate and test the flexibility we have. | queue | yes | yes | | reflect | yes | no | | staking | yes | no | -| voting-with-uuid | yes | no | diff --git a/contracts/voting-with-uuid/.cargo/config b/contracts/voting-with-uuid/.cargo/config deleted file mode 100644 index 9a1df2e20..000000000 --- a/contracts/voting-with-uuid/.cargo/config +++ /dev/null @@ -1,7 +0,0 @@ -[alias] -wasm = "build --release --target wasm32-unknown-unknown" -wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib" -integration-test = "test --test integration -- --color always --nocapture" -integration-test-for-ci = "test --test integration" -schema = "run --example schema" diff --git a/contracts/voting-with-uuid/.gitignore b/contracts/voting-with-uuid/.gitignore deleted file mode 100644 index 6815fd944..000000000 --- a/contracts/voting-with-uuid/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target -**/*.rs.bk -*.iml -.idea diff --git a/contracts/voting-with-uuid/Cargo.lock b/contracts/voting-with-uuid/Cargo.lock deleted file mode 100644 index 193aece72..000000000 --- a/contracts/voting-with-uuid/Cargo.lock +++ /dev/null @@ -1,1935 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli 0.27.0", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object 0.30.0", - "rustc-demangle", -] - -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64ct" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-buffer" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bumpalo" -version = "3.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" - -[[package]] -name = "bytecheck" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f" -dependencies = [ - "bytecheck_derive", - "ptr_meta", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cc" -version = "1.0.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clru" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" - -[[package]] -name = "const-oid" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "corosensei" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9847f90f32a50b0dcbd68bc23ff242798b13080b97b0569f6ed96a45ce4cf2cd" -dependencies = [ - "autocfg", - "cfg-if", - "libc", - "scopeguard", - "windows-sys", -] - -[[package]] -name = "cosmwasm-crypto" -version = "1.1.9+0.9.0" -dependencies = [ - "digest 0.10.6", - "ed25519-zebra", - "k256", - "rand_core 0.6.4", - "sha-1", - "thiserror", -] - -[[package]] -name = "cosmwasm-derive" -version = "1.1.9+0.9.0" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "cosmwasm-schema" -version = "1.1.9+0.9.0" -dependencies = [ - "cosmwasm-schema-derive", - "schemars", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "cosmwasm-schema-derive" -version = "1.1.9+0.9.0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "cosmwasm-std" -version = "1.1.9+0.9.0" -dependencies = [ - "base64", - "cosmwasm-crypto", - "cosmwasm-derive", - "derivative", - "forward_ref", - "hex", - "schemars", - "serde", - "serde-json-wasm", - "thiserror", - "uint", - "uuid", -] - -[[package]] -name = "cosmwasm-storage" -version = "1.1.9+0.9.0" -dependencies = [ - "cosmwasm-std", - "serde", -] - -[[package]] -name = "cosmwasm-vm" -version = "1.1.9+0.9.0" -dependencies = [ - "bitflags", - "bytecheck", - "clru", - "cosmwasm-crypto", - "cosmwasm-std", - "enumset", - "hex", - "loupe", - "parity-wasm", - "schemars", - "serde", - "serde_json", - "sha2 0.10.6", - "thiserror", - "wasmer", - "wasmer-middlewares", -] - -[[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - -[[package]] -name = "cranelift-bforest" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b" -dependencies = [ - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.26.2", - "log", - "regalloc", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24" -dependencies = [ - "cranelift-codegen-shared", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc" - -[[package]] -name = "cranelift-entity" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf" - -[[package]] -name = "cranelift-frontend" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset 0.7.1", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "cw-voting-with-uuid" -version = "0.10.0" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cosmwasm-vm", - "hex", - "schemars", - "serde", - "thiserror", -] - -[[package]] -name = "darling" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" -dependencies = [ - "darling_core", - "quote", - "syn", -] - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer 0.10.3", - "crypto-common", - "subtle", -] - -[[package]] -name = "dyn-clone" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" - -[[package]] -name = "dynasm" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add9a102807b524ec050363f09e06f1504214b0e1c7797f64261c891022dce8b" -dependencies = [ - "bitflags", - "byteorder", - "lazy_static", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "dynasmrt" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64fba5a42bd76a17cad4bfa00de168ee1cbfa06a5e8ce992ae880218c05641a9" -dependencies = [ - "byteorder", - "dynasm", - "memmap2", -] - -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", -] - -[[package]] -name = "ed25519-zebra" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" -dependencies = [ - "curve25519-dalek", - "hashbrown 0.12.3", - "hex", - "rand_core 0.6.4", - "serde", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "either" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" - -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct", - "crypto-bigint", - "der", - "digest 0.10.6", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core 0.6.4", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "enum-iterator" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "enumset" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fastrand" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] - -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "forward_ref" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" - -[[package]] -name = "generic-array" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - -[[package]] -name = "gimli" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" - -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.6", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "itoa" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" - -[[package]] -name = "js-sys" -version = "0.3.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "k256" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - -[[package]] -name = "libc" -version = "0.2.138" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" - -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memmap2" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - -[[package]] -name = "more-asserts" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" - -[[package]] -name = "num_cpus" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" -dependencies = [ - "crc32fast", - "hashbrown 0.11.2", - "indexmap", - "memchr", -] - -[[package]] -name = "object" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "quote" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rayon" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regalloc" -version = "0.0.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02" -dependencies = [ - "log", - "rustc-hash", - "smallvec", -] - -[[package]] -name = "region" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "rend" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint", - "hmac", - "zeroize", -] - -[[package]] -name = "rkyv" -version = "0.7.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15" -dependencies = [ - "bytecheck", - "hashbrown 0.12.3", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eaedadc88b53e36dd32d940ed21ae4d850d5916f2581526921f553a72ac34c4" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustversion" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" - -[[package]] -name = "ryu" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" - -[[package]] -name = "schemars" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" -dependencies = [ - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "serde" -version = "1.0.150" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-json-wasm" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479b4dbc401ca13ee8ce902851b834893251404c4f3c65370a49e047a6be09a5" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_bytes" -version = "0.11.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfc50e8183eeeb6178dcb167ae34a8051d63535023ae38b5d8d12beae193d37b" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.150" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_derive_internals" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.6", -] - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.6", - "rand_core 0.6.4", -] - -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.105" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "target-lexicon" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" - -[[package]] -name = "tempfile" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" -dependencies = [ - "cfg-if", - "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "log", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" -dependencies = [ - "once_cell", -] - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unicode-ident" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" - -[[package]] -name = "uuid" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" -dependencies = [ - "serde", - "sha1_smol", -] - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" - -[[package]] -name = "wasmer" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8d8361c9d006ea3d7797de7bd6b1492ffd0f91a22430cfda6c1658ad57bedf" -dependencies = [ - "cfg-if", - "indexmap", - "js-sys", - "loupe", - "more-asserts", - "target-lexicon", - "thiserror", - "wasm-bindgen", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-compiler-cranelift", - "wasmer-compiler-singlepass", - "wasmer-derive", - "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-artifact" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aaf9428c29c1d8ad2ac0e45889ba8a568a835e33fd058964e5e500f2f7ce325" -dependencies = [ - "enumset", - "loupe", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-compiler" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67a6cd866aed456656db2cfea96c18baabbd33f676578482b85c51e1ee19d2c" -dependencies = [ - "enumset", - "loupe", - "rkyv", - "serde", - "serde_bytes", - "smallvec", - "target-lexicon", - "thiserror", - "wasmer-types", - "wasmparser", -] - -[[package]] -name = "wasmer-compiler-cranelift" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48be2f9f6495f08649e4f8b946a2cbbe119faf5a654aa1457f9504a99d23dae0" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "gimli 0.26.2", - "loupe", - "more-asserts", - "rayon", - "smallvec", - "target-lexicon", - "tracing", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-compiler-singlepass" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ca2a35204d8befa85062bc7aac259a8db8070b801b8a783770ba58231d729e" -dependencies = [ - "byteorder", - "dynasm", - "dynasmrt", - "gimli 0.26.2", - "lazy_static", - "loupe", - "more-asserts", - "rayon", - "smallvec", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-derive" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e50405cc2a2f74ff574584710a5f2c1d5c93744acce2ca0866084739284b51" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "wasmer-engine" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f98f010978c244db431b392aeab0661df7ea0822343334f8f2a920763548e45" -dependencies = [ - "backtrace", - "enumset", - "lazy_static", - "loupe", - "memmap2", - "more-asserts", - "rustc-demangle", - "serde", - "serde_bytes", - "target-lexicon", - "thiserror", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-engine-dylib" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0358af9c154724587731175553805648d9acb8f6657880d165e378672b7e53" -dependencies = [ - "cfg-if", - "enum-iterator", - "enumset", - "leb128", - "libloading", - "loupe", - "object 0.28.4", - "rkyv", - "serde", - "tempfile", - "tracing", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-engine", - "wasmer-object", - "wasmer-types", - "wasmer-vm", - "which", -] - -[[package]] -name = "wasmer-engine-universal" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440dc3d93c9ca47865a4f4edd037ea81bf983b5796b59b3d712d844b32dbef15" -dependencies = [ - "cfg-if", - "enumset", - "leb128", - "loupe", - "region", - "rkyv", - "wasmer-compiler", - "wasmer-engine", - "wasmer-engine-universal-artifact", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-engine-universal-artifact" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f1db3f54152657eb6e86c44b66525ff7801dad8328fe677da48dd06af9ad41" -dependencies = [ - "enum-iterator", - "enumset", - "loupe", - "rkyv", - "thiserror", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-middlewares" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7812438ed2f37203a37007cdb5332b8475cb2b16e15d51299b2647894e9ed3a" -dependencies = [ - "loupe", - "wasmer", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-object" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d831335ff3a44ecf451303f6f891175c642488036b92ceceb24ac8623a8fa8b" -dependencies = [ - "object 0.28.4", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-types" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39df01ea05dc0a9bab67e054c7cb01521e53b35a7bb90bd02eca564ed0b2667f" -dependencies = [ - "backtrace", - "enum-iterator", - "indexmap", - "loupe", - "more-asserts", - "rkyv", - "serde", - "thiserror", -] - -[[package]] -name = "wasmer-vm" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d965fa61f4dc4cdb35a54daaf7ecec3563fbb94154a6c35433f879466247dd" -dependencies = [ - "backtrace", - "cc", - "cfg-if", - "corosensei", - "enum-iterator", - "indexmap", - "lazy_static", - "libc", - "loupe", - "mach", - "memoffset 0.6.5", - "more-asserts", - "region", - "rkyv", - "scopeguard", - "serde", - "thiserror", - "wasmer-artifact", - "wasmer-types", - "winapi", -] - -[[package]] -name = "wasmparser" -version = "0.83.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" - -[[package]] -name = "which" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" -dependencies = [ - "either", - "libc", - "once_cell", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43dbb096663629518eb1dfa72d80243ca5a6aca764cae62a2df70af760a9be75" -dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" - -[[package]] -name = "windows_i686_gnu" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" - -[[package]] -name = "windows_i686_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" - -[[package]] -name = "zeroize" -version = "1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/contracts/voting-with-uuid/Cargo.toml b/contracts/voting-with-uuid/Cargo.toml deleted file mode 100644 index 07c9ad022..000000000 --- a/contracts/voting-with-uuid/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "cw-voting-with-uuid" -version = "0.10.0" -authors = ["Jiyong Ha "] -edition = "2021" -license = "Apache-2.0" -description = "Simple CosmWasm contract for voting with using the UUID" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib", "rlib"] - -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - -[features] -# Change this to [] if you don't need Windows support and want faster integration tests. -default = ["cranelift"] -# Use cranelift backend instead of singlepass. This is required for development on Windows. -cranelift = ["cosmwasm-vm/cranelift"] -# For quicker tests, cargo test --lib. for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"] - - -[dependencies] -cosmwasm-std = { path = "../../packages/std", features = ["iterator"] } -cosmwasm-storage = { path = "../../packages/storage"} -schemars = "0.8.1" -serde = { version = "1.0.125", default-features = false, features = ["derive"] } -hex = "0.4" -thiserror = { version = "1.0.23" } - -[dev-dependencies] -cosmwasm-schema = { path = "../../packages/schema" } -cosmwasm-vm = { path = "../../packages/vm", default-features = false, features = ["iterator"] } diff --git a/contracts/voting-with-uuid/LICENSE b/contracts/voting-with-uuid/LICENSE deleted file mode 100644 index 3be3a520b..000000000 --- a/contracts/voting-with-uuid/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/contracts/voting-with-uuid/NOTICE b/contracts/voting-with-uuid/NOTICE deleted file mode 100644 index 2fab26ed7..000000000 --- a/contracts/voting-with-uuid/NOTICE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2019 Ethan Frey - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/contracts/voting-with-uuid/README.md b/contracts/voting-with-uuid/README.md deleted file mode 100644 index 591ec5185..000000000 --- a/contracts/voting-with-uuid/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Voting - -This is a simple voting contract. It creates a contract to manage token weighted polls, -where voters deposit native coins in order to vote. -Voters can withdraw their stake, but not while a poll they've participated in is still in progress. - -Anyone can create a poll, and as the poll creator, only they are allowed to end/tally the poll. - -This contract is mainly considered as a simple tutorial example. diff --git a/contracts/voting-with-uuid/examples/schema.rs b/contracts/voting-with-uuid/examples/schema.rs deleted file mode 100644 index 894a4a3de..000000000 --- a/contracts/voting-with-uuid/examples/schema.rs +++ /dev/null @@ -1,22 +0,0 @@ -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use std::env::current_dir; -use std::fs::create_dir_all; - -use cw_voting_with_uuid::msg::{ - ExecuteMsg, InstantiateMsg, PollResponse, QueryMsg, TokenStakeResponse, -}; -use cw_voting_with_uuid::state::State; - -fn main() { - let mut out_dir = current_dir().unwrap(); - out_dir.push("schema"); - create_dir_all(&out_dir).unwrap(); - remove_schemas(&out_dir).unwrap(); - - export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(PollResponse), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); - export_schema(&schema_for!(State), &out_dir); - export_schema(&schema_for!(TokenStakeResponse), &out_dir); -} diff --git a/contracts/voting-with-uuid/rustfmt.toml b/contracts/voting-with-uuid/rustfmt.toml deleted file mode 100644 index 11a85e6a9..000000000 --- a/contracts/voting-with-uuid/rustfmt.toml +++ /dev/null @@ -1,15 +0,0 @@ -# stable -newline_style = "unix" -hard_tabs = false -tab_spaces = 4 - -# unstable... should we require `rustup run nightly cargo fmt` ? -# or just update the style guide when they are stable? -#fn_single_line = true -#format_code_in_doc_comments = true -#overflow_delimited_expr = true -#reorder_impl_items = true -#struct_field_align_threshold = 20 -#struct_lit_single_line = true -#report_todo = "Always" - diff --git a/contracts/voting-with-uuid/schema/execute_msg.json b/contracts/voting-with-uuid/schema/execute_msg.json deleted file mode 100644 index 96d983ed5..000000000 --- a/contracts/voting-with-uuid/schema/execute_msg.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "cast_vote" - ], - "properties": { - "cast_vote": { - "type": "object", - "required": [ - "poll_id", - "vote", - "weight" - ], - "properties": { - "poll_id": { - "$ref": "#/definitions/Uuid" - }, - "vote": { - "type": "string" - }, - "weight": { - "$ref": "#/definitions/Uint128" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "stake_voting_tokens" - ], - "properties": { - "stake_voting_tokens": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "withdraw_voting_tokens" - ], - "properties": { - "withdraw_voting_tokens": { - "type": "object", - "properties": { - "amount": { - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "create_poll" - ], - "properties": { - "create_poll": { - "type": "object", - "required": [ - "description" - ], - "properties": { - "description": { - "type": "string" - }, - "end_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "quorum_percentage": { - "type": [ - "integer", - "null" - ], - "format": "uint8", - "minimum": 0.0 - }, - "start_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "end_poll" - ], - "properties": { - "end_poll": { - "type": "object", - "required": [ - "poll_id" - ], - "properties": { - "poll_id": { - "$ref": "#/definitions/Uuid" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "make_uuid" - ], - "properties": { - "make_uuid": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "make_sequence_id" - ], - "properties": { - "make_sequence_id": { - "type": "object" - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - }, - "Uuid": { - "description": "Uuid Provides a Uuid that can be used deterministically. Use internally Uuidv5 and NAMESPACE_OID. The name is combined with cahin id, contract address, block height, and increased sequential.", - "type": "string" - } - } -} diff --git a/contracts/voting-with-uuid/schema/instantiate_msg.json b/contracts/voting-with-uuid/schema/instantiate_msg.json deleted file mode 100644 index 8dfd5190e..000000000 --- a/contracts/voting-with-uuid/schema/instantiate_msg.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "type": "object", - "required": [ - "denom" - ], - "properties": { - "denom": { - "type": "string" - } - } -} diff --git a/contracts/voting-with-uuid/schema/poll_response.json b/contracts/voting-with-uuid/schema/poll_response.json deleted file mode 100644 index 0e92a8f6d..000000000 --- a/contracts/voting-with-uuid/schema/poll_response.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "PollResponse", - "type": "object", - "required": [ - "creator", - "description", - "status" - ], - "properties": { - "creator": { - "type": "string" - }, - "description": { - "type": "string" - }, - "end_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "quorum_percentage": { - "type": [ - "integer", - "null" - ], - "format": "uint8", - "minimum": 0.0 - }, - "start_height": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "status": { - "$ref": "#/definitions/PollStatus" - } - }, - "definitions": { - "PollStatus": { - "type": "string", - "enum": [ - "InProgress", - "Tally", - "Passed", - "Rejected" - ] - } - } -} diff --git a/contracts/voting-with-uuid/schema/query_msg.json b/contracts/voting-with-uuid/schema/query_msg.json deleted file mode 100644 index f8b20e7b1..000000000 --- a/contracts/voting-with-uuid/schema/query_msg.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "oneOf": [ - { - "type": "object", - "required": [ - "config" - ], - "properties": { - "config": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "token_stake" - ], - "properties": { - "token_stake": { - "type": "object", - "required": [ - "address" - ], - "properties": { - "address": { - "type": "string" - } - } - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "poll" - ], - "properties": { - "poll": { - "type": "object", - "required": [ - "poll_id" - ], - "properties": { - "poll_id": { - "$ref": "#/definitions/Uuid" - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Uuid": { - "description": "Uuid Provides a Uuid that can be used deterministically. Use internally Uuidv5 and NAMESPACE_OID. The name is combined with cahin id, contract address, block height, and increased sequential.", - "type": "string" - } - } -} diff --git a/contracts/voting-with-uuid/schema/state.json b/contracts/voting-with-uuid/schema/state.json deleted file mode 100644 index cf1d285b0..000000000 --- a/contracts/voting-with-uuid/schema/state.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "State", - "type": "object", - "required": [ - "denom", - "owner", - "staked_tokens" - ], - "properties": { - "denom": { - "type": "string" - }, - "owner": { - "$ref": "#/definitions/Addr" - }, - "staked_tokens": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Addr": { - "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", - "type": "string" - }, - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/voting-with-uuid/schema/token_stake_response.json b/contracts/voting-with-uuid/schema/token_stake_response.json deleted file mode 100644 index c249d29fd..000000000 --- a/contracts/voting-with-uuid/schema/token_stake_response.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "TokenStakeResponse", - "type": "object", - "required": [ - "token_balance" - ], - "properties": { - "token_balance": { - "$ref": "#/definitions/Uint128" - } - }, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/contracts/voting-with-uuid/src/coin_helpers.rs b/contracts/voting-with-uuid/src/coin_helpers.rs deleted file mode 100644 index 97fbeb493..000000000 --- a/contracts/voting-with-uuid/src/coin_helpers.rs +++ /dev/null @@ -1,62 +0,0 @@ -use crate::error::ContractError; -use cosmwasm_std::Coin; - -pub fn validate_sent_sufficient_coin( - sent: &[Coin], - required: Option, -) -> Result<(), ContractError> { - if let Some(required_coin) = required { - let required_amount = required_coin.amount.u128(); - if required_amount > 0 { - let sent_sufficient_funds = sent.iter().any(|coin| { - // check if a given sent coin matches denom - // and has sufficient amount - coin.denom == required_coin.denom && coin.amount.u128() >= required_amount - }); - - return if sent_sufficient_funds { - Ok(()) - } else { - Err(ContractError::InsufficientFundsSent {}) - }; - } - } - Ok(()) -} - -#[cfg(test)] -mod test { - use super::*; - use cosmwasm_std::{coin, coins}; - - #[test] - fn assert_sent_sufficient_coin_works() { - match validate_sent_sufficient_coin(&[], Some(coin(0, "token"))) { - Ok(()) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - }; - - match validate_sent_sufficient_coin(&[], Some(coin(5, "token"))) { - Ok(()) => panic!("Should have raised insufficient funds error"), - Err(ContractError::InsufficientFundsSent {}) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - }; - - match validate_sent_sufficient_coin(&coins(10, "smokin"), Some(coin(5, "token"))) { - Ok(()) => panic!("Should have raised insufficient funds error"), - Err(ContractError::InsufficientFundsSent {}) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - }; - - match validate_sent_sufficient_coin(&coins(10, "token"), Some(coin(5, "token"))) { - Ok(()) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - }; - - let sent_coins = vec![coin(2, "smokin"), coin(5, "token"), coin(1, "earth")]; - match validate_sent_sufficient_coin(&sent_coins, Some(coin(5, "token"))) { - Ok(()) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - }; - } -} diff --git a/contracts/voting-with-uuid/src/contract.rs b/contracts/voting-with-uuid/src/contract.rs deleted file mode 100644 index d5829b467..000000000 --- a/contracts/voting-with-uuid/src/contract.rs +++ /dev/null @@ -1,476 +0,0 @@ -use crate::coin_helpers::validate_sent_sufficient_coin; -use crate::error::ContractError; -use crate::msg::{ - CreatePollResponse, ExecuteMsg, InstantiateMsg, PollResponse, QueryMsg, TokenStakeResponse, -}; -use crate::state::{ - bank, bank_read, config, config_read, poll, poll_read, Poll, PollStatus, State, Voter, -}; -use cosmwasm_std::{ - attr, coin, entry_point, new_uuid, to_binary, Addr, BankMsg, Binary, Coin, CosmosMsg, Deps, - DepsMut, Env, MessageInfo, Response, StdError, StdResult, Storage, Uint128, Uuid, -}; - -pub const VOTING_TOKEN: &str = "voting_token"; -pub const DEFAULT_END_HEIGHT_BLOCKS: &u64 = &100_800_u64; -const MIN_STAKE_AMOUNT: u128 = 1; -const MIN_DESC_LENGTH: u64 = 3; -const MAX_DESC_LENGTH: u64 = 64; - -#[entry_point] -pub fn instantiate( - deps: DepsMut, - _env: Env, - info: MessageInfo, - msg: InstantiateMsg, -) -> Result { - let state = State { - denom: msg.denom, - owner: info.sender, - staked_tokens: Uint128::zero(), - }; - - config(deps.storage).save(&state)?; - - Ok(Response::default()) -} - -#[entry_point] -pub fn execute( - deps: DepsMut, - env: Env, - info: MessageInfo, - msg: ExecuteMsg, -) -> Result { - match msg { - ExecuteMsg::StakeVotingTokens {} => stake_voting_tokens(deps, env, info), - ExecuteMsg::WithdrawVotingTokens { amount } => { - withdraw_voting_tokens(deps, env, info, amount) - } - ExecuteMsg::CastVote { - poll_id, - vote, - weight, - } => cast_vote(deps, env, info, poll_id, vote, weight), - ExecuteMsg::EndPoll { poll_id } => end_poll(deps, env, info, poll_id), - ExecuteMsg::CreatePoll { - quorum_percentage, - description, - start_height, - end_height, - } => create_poll( - deps, - env, - info, - quorum_percentage, - description, - start_height, - end_height, - ), - ExecuteMsg::MakeUuid {} => make_uuid(deps, env, info), - ExecuteMsg::MakeSequenceId {} => make_seq_id(deps, env, info), - } -} - -pub fn stake_voting_tokens( - deps: DepsMut, - _env: Env, - info: MessageInfo, -) -> Result { - let key = info.sender.as_str().as_bytes(); - - let mut token_manager = bank_read(deps.storage).may_load(key)?.unwrap_or_default(); - - let mut state = config(deps.storage).load()?; - - validate_sent_sufficient_coin(&info.funds, Some(coin(MIN_STAKE_AMOUNT, &state.denom)))?; - let funds = info - .funds - .iter() - .find(|coin| coin.denom.eq(&state.denom)) - .unwrap(); - - token_manager.token_balance += funds.amount; - - let staked_tokens = state.staked_tokens.u128() + funds.amount.u128(); - state.staked_tokens = Uint128::from(staked_tokens); - config(deps.storage).save(&state)?; - - bank(deps.storage).save(key, &token_manager)?; - - Ok(Response::default()) -} - -// Withdraw amount if not staked. By default all funds will be withdrawn. -pub fn withdraw_voting_tokens( - deps: DepsMut, - _env: Env, - info: MessageInfo, - amount: Option, -) -> Result { - let sender_address_raw = info.sender.as_str().as_bytes(); - - if let Some(mut token_manager) = bank_read(deps.storage).may_load(sender_address_raw)? { - let largest_staked = locked_amount(sender_address_raw, deps.storage); - let withdraw_amount = amount.unwrap_or(token_manager.token_balance); - if largest_staked + withdraw_amount > token_manager.token_balance { - let max_amount = token_manager.token_balance.checked_sub(largest_staked)?; - Err(ContractError::ExcessiveWithdraw { max_amount }) - } else { - let balance = token_manager.token_balance.checked_sub(withdraw_amount)?; - token_manager.token_balance = balance; - - bank(deps.storage).save(sender_address_raw, &token_manager)?; - - let mut state = config(deps.storage).load()?; - let staked_tokens = state.staked_tokens.checked_sub(withdraw_amount)?; - state.staked_tokens = staked_tokens; - config(deps.storage).save(&state)?; - - Ok(send_tokens( - &info.sender, - vec![coin(withdraw_amount.u128(), &state.denom)], - "approve", - )) - } - } else { - Err(ContractError::PollNoStake {}) - } -} - -/// validate_description returns an error if the description is invalid -fn validate_description(description: &str) -> Result<(), ContractError> { - if (description.len() as u64) < MIN_DESC_LENGTH { - Err(ContractError::DescriptionTooShort { - min_desc_length: MIN_DESC_LENGTH, - }) - } else if (description.len() as u64) > MAX_DESC_LENGTH { - Err(ContractError::DescriptionTooLong { - max_desc_length: MAX_DESC_LENGTH, - }) - } else { - Ok(()) - } -} - -/// validate_quorum_percentage returns an error if the quorum_percentage is invalid -/// (we require 0-100) -fn validate_quorum_percentage(quorum_percentage: Option) -> Result<(), ContractError> { - match quorum_percentage { - Some(qp) => { - if qp > 100 { - return Err(ContractError::PollQuorumPercentageMismatch { - quorum_percentage: qp, - }); - } - Ok(()) - } - None => Ok(()), - } -} - -/// validate_end_height returns an error if the poll ends in the past -fn validate_end_height(end_height: Option, env: Env) -> Result<(), ContractError> { - if end_height.is_some() && env.block.height >= end_height.unwrap() { - Err(ContractError::PollCannotEndInPast {}) - } else { - Ok(()) - } -} - -/// create a new poll -pub fn create_poll( - deps: DepsMut, - env: Env, - info: MessageInfo, - quorum_percentage: Option, - description: String, - start_height: Option, - end_height: Option, -) -> Result { - validate_quorum_percentage(quorum_percentage)?; - validate_end_height(end_height, env.clone())?; - validate_description(&description)?; - - let poll_id = new_uuid(&env, deps.storage, deps.api)?; - - let new_poll = Poll { - creator: info.sender, - status: PollStatus::InProgress, - quorum_percentage, - yes_votes: Uint128::zero(), - no_votes: Uint128::zero(), - voters: vec![], - voter_info: vec![], - end_height: end_height.unwrap_or(env.block.height + DEFAULT_END_HEIGHT_BLOCKS), - start_height, - description, - }; - poll(deps.storage).save(poll_id.as_slice(), &new_poll)?; - - let r = Response::new() - .add_attribute("action", "create_poll") - .add_attribute("creator", new_poll.creator) - .add_attribute("poll_id", poll_id.to_string()) - .add_attribute( - "quorum_percentage", - quorum_percentage.unwrap_or(0).to_string(), - ) - .add_attribute("end_height", new_poll.end_height.to_string()) - .add_attribute("start_height", start_height.unwrap_or(0).to_string()) - .set_data(to_binary(&CreatePollResponse { poll_id })?); - Ok(r) -} - -/* - * Ends a poll. Only the creator of a given poll can end that poll. - */ -pub fn end_poll( - deps: DepsMut, - env: Env, - info: MessageInfo, - poll_id: Uuid, -) -> Result { - let mut a_poll = poll(deps.storage).load(poll_id.as_slice())?; - - if a_poll.creator != info.sender { - return Err(ContractError::PollNotCreator { - creator: a_poll.creator.to_string(), - sender: info.sender.to_string(), - }); - } - - if a_poll.status != PollStatus::InProgress { - return Err(ContractError::PollNotInProgress {}); - } - - if let Some(start_height) = a_poll.start_height { - if start_height > env.block.height { - return Err(ContractError::PoolVotingPeriodNotStarted { start_height }); - } - } - - if a_poll.end_height > env.block.height { - return Err(ContractError::PollVotingPeriodNotExpired { - expire_height: a_poll.end_height, - }); - } - - let mut no = 0u128; - let mut yes = 0u128; - - for voter in &a_poll.voter_info { - if voter.vote == "yes" { - yes += voter.weight.u128(); - } else { - no += voter.weight.u128(); - } - } - let tallied_weight = yes + no; - - let mut rejected_reason = ""; - let mut passed = false; - - if tallied_weight > 0 { - let state = config_read(deps.storage).load()?; - - let staked_weight = deps - .querier - .query_balance(&env.contract.address, &state.denom) - .unwrap() - .amount - .u128(); - - if staked_weight == 0 { - return Err(ContractError::PollNoStake {}); - } - - let quorum = ((tallied_weight / staked_weight) * 100) as u8; - if a_poll.quorum_percentage.is_some() && quorum < a_poll.quorum_percentage.unwrap() { - // Quorum: More than quorum_percentage of the total staked tokens at the end of the voting - // period need to have participated in the vote. - rejected_reason = "Quorum not reached"; - } else if yes > tallied_weight / 2 { - //Threshold: More than 50% of the tokens that participated in the vote - // (after excluding “Abstain” votes) need to have voted in favor of the proposal (“Yes”). - a_poll.status = PollStatus::Passed; - passed = true; - } else { - rejected_reason = "Threshold not reached"; - } - } else { - rejected_reason = "Quorum not reached"; - } - if !passed { - a_poll.status = PollStatus::Rejected - } - poll(deps.storage).save(poll_id.as_slice(), &a_poll)?; - - for voter in &a_poll.voters { - unlock_tokens(deps.storage, voter, poll_id)?; - } - - let attributes = vec![ - attr("action", "end_poll"), - attr("poll_id", poll_id.to_string()), - attr("rejected_reason", rejected_reason), - attr("passed", &passed.to_string()), - ]; - - Ok(Response::new().add_attributes(attributes)) -} - -// unlock voter's tokens in a given poll -fn unlock_tokens( - storage: &mut dyn Storage, - voter: &Addr, - poll_id: Uuid, -) -> Result { - let voter_key = &voter.as_str().as_bytes(); - let mut token_manager = bank_read(storage).load(voter_key).unwrap(); - - // unlock entails removing the mapped poll_id, retaining the rest - token_manager.locked_tokens.retain(|(k, _)| k != &poll_id); - bank(storage).save(voter_key, &token_manager)?; - Ok(Response::default()) -} - -// finds the largest locked amount in participated polls. -fn locked_amount(voter: &[u8], storage: &dyn Storage) -> Uint128 { - let token_manager = bank_read(storage).load(voter).unwrap(); - token_manager - .locked_tokens - .iter() - .map(|(_, v)| *v) - .max() - .unwrap_or_default() -} - -fn has_voted(voter: &Addr, a_poll: &Poll) -> bool { - a_poll.voters.iter().any(|i| i == voter) -} - -pub fn cast_vote( - deps: DepsMut, - _env: Env, - info: MessageInfo, - poll_id: Uuid, - vote: String, - weight: Uint128, -) -> Result { - let poll_key = poll_id.as_bytes(); - - let mut a_poll = match poll(deps.storage).load(poll_key) { - Ok(poll) => poll, - Err(_) => return Err(ContractError::PollNotExist {}), - }; - - if a_poll.status != PollStatus::InProgress { - return Err(ContractError::PollNotInProgress {}); - } - - if has_voted(&info.sender, &a_poll) { - return Err(ContractError::PollSenderVoted {}); - } - - let key = info.sender.as_str().as_bytes(); - let mut token_manager = bank_read(deps.storage).may_load(key)?.unwrap_or_default(); - - if token_manager.token_balance < weight { - return Err(ContractError::PollInsufficientStake {}); - } - token_manager.participated_polls.push(poll_id); - token_manager.locked_tokens.push((poll_id, weight)); - bank(deps.storage).save(key, &token_manager)?; - - a_poll.voters.push(info.sender.clone()); - - let voter_info = Voter { vote, weight }; - - a_poll.voter_info.push(voter_info); - poll(deps.storage).save(poll_key, &a_poll)?; - - let attributes = vec![ - attr("action", "vote_casted"), - attr("poll_id", poll_id.to_string()), - attr("weight", &weight.to_string()), - attr("voter", &info.sender), - ]; - - Ok(Response::new().add_attributes(attributes)) -} - -fn send_tokens(to_address: &Addr, amount: Vec, action: &str) -> Response { - let attributes = vec![attr("action", action), attr("to", to_address.clone())]; - - Response::new() - .add_message(CosmosMsg::Bank(BankMsg::Send { - to_address: to_address.to_string(), - amount, - })) - .add_attributes(attributes) -} - -pub fn make_uuid(deps: DepsMut, env: Env, _info: MessageInfo) -> Result { - let uuid = new_uuid(&env, deps.storage, deps.api)?; - let r = Response::new() - .add_attribute("action", "make_uuid") - .add_attribute("uuid", uuid.to_string()); - Ok(r) -} - -pub fn make_seq_id( - _deps: DepsMut, - _env: Env, - _info: MessageInfo, -) -> Result { - let seq_id: u64 = 0; - - let r = Response::new() - .add_attribute("action", "make_seq_id") - .add_attribute("uuid", seq_id.to_string()); - Ok(r) -} - -#[entry_point] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::Config {} => to_binary(&config_read(deps.storage).load()?), - QueryMsg::TokenStake { address } => { - token_balance(deps, deps.api.addr_validate(address.as_str())?) - } - QueryMsg::Poll { poll_id } => query_poll(deps, poll_id), - } -} - -fn query_poll(deps: Deps, poll_id: Uuid) -> StdResult { - let key = poll_id.as_bytes(); - - let poll = match poll_read(deps.storage).may_load(key)? { - Some(poll) => Some(poll), - None => return Err(StdError::generic_err("Poll does not exist")), - } - .unwrap(); - - let resp = PollResponse { - creator: poll.creator.to_string(), - status: poll.status, - quorum_percentage: poll.quorum_percentage, - end_height: Some(poll.end_height), - start_height: poll.start_height, - description: poll.description, - }; - to_binary(&resp) -} - -fn token_balance(deps: Deps, address: Addr) -> StdResult { - let token_manager = bank_read(deps.storage) - .may_load(address.as_str().as_bytes())? - .unwrap_or_default(); - - let resp = TokenStakeResponse { - token_balance: token_manager.token_balance, - }; - - to_binary(&resp) -} diff --git a/contracts/voting-with-uuid/src/error.rs b/contracts/voting-with-uuid/src/error.rs deleted file mode 100644 index be2e4aa07..000000000 --- a/contracts/voting-with-uuid/src/error.rs +++ /dev/null @@ -1,53 +0,0 @@ -use cosmwasm_std::{OverflowError, StdError, Uint128}; -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ContractError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("{0}")] - OverflowError(#[from] OverflowError), - - #[error("insufficient funds sent")] - InsufficientFundsSent {}, - - #[error("excessive withdrawal amount (max_amount {max_amount})")] - ExcessiveWithdraw { max_amount: Uint128 }, - - #[error("description too short (minimum description length {min_desc_length})")] - DescriptionTooShort { min_desc_length: u64 }, - - #[error("description too long (maximum description length {max_desc_length})")] - DescriptionTooLong { max_desc_length: u64 }, - - #[error("no stake")] - PollNoStake {}, - - #[error("poll do not exist")] - PollNotExist {}, - - #[error("poll cannot end in past")] - PollCannotEndInPast {}, - - #[error("sender is not the creator of the poll (sender {sender} creator {creator})")] - PollNotCreator { sender: String, creator: String }, - - #[error("poll is not in progress")] - PollNotInProgress {}, - - #[error("poll voting period has not started (start_height {start_height})")] - PoolVotingPeriodNotStarted { start_height: u64 }, - - #[error("poll voting period has not expired (expire_height {expire_height})")] - PollVotingPeriodNotExpired { expire_height: u64 }, - - #[error("sender has already voted in poll")] - PollSenderVoted {}, - - #[error("sender staked tokens insufficient")] - PollInsufficientStake {}, - - #[error("quorum percentage must be 0 to 100 (quorum_percentage: {quorum_percentage})")] - PollQuorumPercentageMismatch { quorum_percentage: u8 }, -} diff --git a/contracts/voting-with-uuid/src/lib.rs b/contracts/voting-with-uuid/src/lib.rs deleted file mode 100644 index edb52327d..000000000 --- a/contracts/voting-with-uuid/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod coin_helpers; -pub mod contract; -mod error; -pub mod msg; -pub mod state; - -#[cfg(test)] -mod tests; diff --git a/contracts/voting-with-uuid/src/msg.rs b/contracts/voting-with-uuid/src/msg.rs deleted file mode 100644 index 8bfcbc0b3..000000000 --- a/contracts/voting-with-uuid/src/msg.rs +++ /dev/null @@ -1,77 +0,0 @@ -use crate::state::PollStatus; -use cosmwasm_std::{Uint128, Uuid}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg { - pub denom: String, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg { - CastVote { - poll_id: Uuid, - vote: String, - weight: Uint128, - }, - StakeVotingTokens {}, - WithdrawVotingTokens { - amount: Option, - }, - CreatePoll { - quorum_percentage: Option, - description: String, - start_height: Option, - end_height: Option, - }, - EndPoll { - poll_id: Uuid, - }, - MakeUuid {}, - MakeSequenceId {}, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum QueryMsg { - Config {}, - TokenStake { address: String }, - Poll { poll_id: Uuid }, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)] -pub struct PollResponse { - pub creator: String, - pub status: PollStatus, - pub quorum_percentage: Option, - pub end_height: Option, - pub start_height: Option, - pub description: String, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)] -pub struct CreatePollResponse { - pub poll_id: Uuid, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)] -pub struct PollCountResponse { - pub poll_count: u64, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)] -pub struct TokenStakeResponse { - pub token_balance: Uint128, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)] -pub struct MakeUuidResponse { - pub uuid: Uuid, -} - -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema)] -pub struct MakeSequenceIdResponse { - pub seq_id: u64, -} diff --git a/contracts/voting-with-uuid/src/state.rs b/contracts/voting-with-uuid/src/state.rs deleted file mode 100644 index 5a73a0d7f..000000000 --- a/contracts/voting-with-uuid/src/state.rs +++ /dev/null @@ -1,77 +0,0 @@ -use cosmwasm_std::{Addr, Storage, Uint128, Uuid}; -use cosmwasm_storage::{ - bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton, - Singleton, -}; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -static CONFIG_KEY: &[u8] = b"config"; -static POLL_KEY: &[u8] = b"polls"; -static BANK_KEY: &[u8] = b"bank"; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct State { - pub denom: String, - pub owner: Addr, - pub staked_tokens: Uint128, -} - -#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct TokenManager { - pub token_balance: Uint128, // total staked balance - pub locked_tokens: Vec<(Uuid, Uint128)>, //maps poll_id to weight voted - pub participated_polls: Vec, // poll_id -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct Voter { - pub vote: String, - pub weight: Uint128, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub enum PollStatus { - InProgress, - Tally, - Passed, - Rejected, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct Poll { - pub creator: Addr, - pub status: PollStatus, - pub quorum_percentage: Option, - pub yes_votes: Uint128, - pub no_votes: Uint128, - pub voters: Vec, - pub voter_info: Vec, - pub end_height: u64, - pub start_height: Option, - pub description: String, -} - -pub fn config(storage: &mut dyn Storage) -> Singleton { - singleton(storage, CONFIG_KEY) -} - -pub fn config_read(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, CONFIG_KEY) -} - -pub fn poll(storage: &mut dyn Storage) -> Bucket { - bucket(storage, POLL_KEY) -} - -pub fn poll_read(storage: &dyn Storage) -> ReadonlyBucket { - bucket_read(storage, POLL_KEY) -} - -pub fn bank(storage: &mut dyn Storage) -> Bucket { - bucket(storage, BANK_KEY) -} - -pub fn bank_read(storage: &dyn Storage) -> ReadonlyBucket { - bucket_read(storage, BANK_KEY) -} diff --git a/contracts/voting-with-uuid/src/tests.rs b/contracts/voting-with-uuid/src/tests.rs deleted file mode 100644 index 568f4792e..000000000 --- a/contracts/voting-with-uuid/src/tests.rs +++ /dev/null @@ -1,901 +0,0 @@ -use crate::contract::{execute, instantiate, query, VOTING_TOKEN}; -use crate::error::ContractError; -use crate::msg::{ExecuteMsg, InstantiateMsg, PollResponse, QueryMsg}; -use crate::state::{config_read, PollStatus, State}; -use cosmwasm_std::testing::{ - mock_dependencies, mock_dependencies_with_balance, mock_env, mock_info, -}; -use cosmwasm_std::{ - attr, coins, from_binary, Addr, BankMsg, Coin, CosmosMsg, DepsMut, Env, MessageInfo, Response, - StdError, Timestamp, Uint128, Uuid, -}; -use std::str::FromStr; - -const DEFAULT_END_HEIGHT: u64 = 100800u64; -const TEST_CREATOR: &str = "creator"; -const TEST_VOTER: &str = "voter1"; -const TEST_VOTER_2: &str = "voter2"; - -fn mock_instantiate(deps: DepsMut) { - let msg = InstantiateMsg { - denom: String::from(VOTING_TOKEN), - }; - - let info = mock_info(TEST_CREATOR, &coins(2, &msg.denom)); - let _res = instantiate(deps, mock_env(), info, msg) - .expect("contract successfully executes InstantiateMsg"); -} - -fn mock_info_height(sender: &str, sent: &[Coin], height: u64, time: u64) -> (Env, MessageInfo) { - let info = mock_info(sender, sent); - let mut env = mock_env(); - env.block.height = height; - env.block.time = Timestamp::from_nanos(time); - (env, info) -} - -fn init_msg() -> InstantiateMsg { - InstantiateMsg { - denom: String::from(VOTING_TOKEN), - } -} - -#[test] -fn proper_initialization() { - let mut deps = mock_dependencies(); - - let msg = init_msg(); - let info = mock_info(TEST_CREATOR, &coins(2, VOTING_TOKEN)); - let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(0, res.messages.len()); - - let state = config_read(&deps.storage).load().unwrap(); - assert_eq!( - state, - State { - denom: String::from(VOTING_TOKEN), - owner: Addr::unchecked(TEST_CREATOR), - staked_tokens: Uint128::zero(), - } - ); -} - -#[test] -fn poll_not_found() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - let res = query(deps.as_ref(), mock_env(), QueryMsg::Poll { poll_id }); - - match res { - Err(StdError::GenericErr { msg, .. }) => assert_eq!(msg, "Poll does not exist"), - Err(e) => panic!("Unexpected error: {:?}", e), - _ => panic!("Must return error"), - } -} - -#[test] -fn fails_create_poll_invalid_quorum_percentage() { - let mut deps = mock_dependencies(); - let info = mock_info("voter", &coins(11, VOTING_TOKEN)); - - let qp = 101; - let msg = create_poll_msg(qp, "test".to_string(), None, None); - - let res = execute(deps.as_mut(), mock_env(), info, msg); - - match res { - Ok(_) => panic!("Must return error"), - Err(ContractError::PollQuorumPercentageMismatch { quorum_percentage }) => { - assert_eq!(quorum_percentage, qp) - } - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn fails_create_poll_invalid_description() { - let mut deps = mock_dependencies(); - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - - let msg = create_poll_msg(30, "a".to_string(), None, None); - - match execute(deps.as_mut(), mock_env(), info.clone(), msg) { - Ok(_) => panic!("Must return error"), - Err(ContractError::DescriptionTooShort { .. }) => {} - Err(_) => panic!("Unknown error"), - } - - let msg = create_poll_msg( - 100, - "01234567890123456789012345678901234567890123456789012345678901234".to_string(), - None, - None, - ); - - match execute(deps.as_mut(), mock_env(), info, msg) { - Ok(_) => panic!("Must return error"), - Err(ContractError::DescriptionTooLong { .. }) => {} - Err(_) => panic!("Unknown error"), - } -} - -fn create_poll_msg( - quorum_percentage: u8, - description: String, - start_height: Option, - end_height: Option, -) -> ExecuteMsg { - ExecuteMsg::CreatePoll { - quorum_percentage: Some(quorum_percentage), - description, - start_height, - end_height, - } -} - -#[test] -fn happy_days_create_poll() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - let (env, info) = mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 10000); - - let quorum = 30; - let msg = create_poll_msg(quorum, "test".to_string(), None, None); - - let execute_res = execute(deps.as_mut(), env, info, msg).unwrap(); - assert_create_poll_result( - &poll_id, - quorum, - DEFAULT_END_HEIGHT, - 0, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); -} - -#[test] -fn create_poll_no_quorum() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - let (env, info) = mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 10000); - - let quorum = 0; - let msg = create_poll_msg(quorum, "test".to_string(), None, None); - - let execute_res = execute(deps.as_mut(), env, info, msg).unwrap(); - assert_create_poll_result( - &poll_id, - quorum, - DEFAULT_END_HEIGHT, - 0, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); -} - -#[test] -fn fails_end_poll_before_end_height() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - let (env, info) = mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 10000); - - let msg_end_height = 10001; - let msg = create_poll_msg(0, "test".to_string(), None, Some(msg_end_height)); - - let execute_res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_create_poll_result( - &poll_id, - 0, - msg_end_height, - 0, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); - - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let res = query(deps.as_ref(), mock_env(), QueryMsg::Poll { poll_id }).unwrap(); - let value: PollResponse = from_binary(&res).unwrap(); - assert_eq!(Some(10001), value.end_height); - - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let msg = ExecuteMsg::EndPoll { poll_id }; - - let execute_res = execute(deps.as_mut(), env, info, msg); - - match execute_res { - Ok(_) => panic!("Must return error"), - Err(ContractError::PollVotingPeriodNotExpired { expire_height }) => { - assert_eq!(expire_height, msg_end_height) - } - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn happy_days_end_poll() { - const POLL_END_HEIGHT: u64 = 1000; - let poll_id = Uuid::from_str("ad9daf0b-b439-5a5e-b79e-d0b8bbf04879").unwrap(); - let stake_amount = 1000; - - let mut deps = mock_dependencies_with_balance(&coins(1000, VOTING_TOKEN)); - mock_instantiate(deps.as_mut()); - let (mut creator_env, creator_info) = mock_info_height( - TEST_CREATOR, - &coins(2, VOTING_TOKEN), - POLL_END_HEIGHT, - 10000, - ); - - let msg = create_poll_msg( - 0, - "test".to_string(), - None, - Some(creator_env.block.height + 1), - ); - - let execute_res = execute( - deps.as_mut(), - creator_env.clone(), - creator_info.clone(), - msg, - ) - .unwrap(); - - assert_create_poll_result( - &poll_id, - 0, - creator_env.block.height + 1, - 0, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); - - let msg = ExecuteMsg::StakeVotingTokens {}; - let env = mock_env(); - let info = mock_info(TEST_VOTER, &coins(stake_amount, VOTING_TOKEN)); - - let execute_res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_stake_tokens_result(stake_amount, execute_res, deps.as_mut()); - - let msg = ExecuteMsg::CastVote { - poll_id, - vote: "yes".to_string(), - weight: Uint128::from(stake_amount), - }; - let execute_res = execute(deps.as_mut(), env, info, msg).unwrap(); - - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "vote_casted"), - attr("poll_id", poll_id.to_string()), - attr("weight", "1000"), - attr("voter", TEST_VOTER), - ] - ); - - creator_env.block.height = &creator_env.block.height + 1; - - let msg = ExecuteMsg::EndPoll { poll_id }; - - let execute_res = execute(deps.as_mut(), creator_env, creator_info, msg).unwrap(); - - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "end_poll"), - attr("poll_id", poll_id.to_string()), - attr("rejected_reason", ""), - attr("passed", "true"), - ] - ); - let res = query(deps.as_ref(), mock_env(), QueryMsg::Poll { poll_id }).unwrap(); - let value: PollResponse = from_binary(&res).unwrap(); - assert_eq!(PollStatus::Passed, value.status); -} - -#[test] -fn end_poll_zero_quorum() { - let poll_id = Uuid::from_str("ad9daf0b-b439-5a5e-b79e-d0b8bbf04879").unwrap(); - let mut deps = mock_dependencies_with_balance(&coins(1000, VOTING_TOKEN)); - mock_instantiate(deps.as_mut()); - let (mut env, info) = mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 1000, 10000); - - let msg = create_poll_msg(0, "test".to_string(), None, Some(env.block.height + 1)); - - let execute_res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_create_poll_result( - &poll_id, - 0, - 1001, - 0, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); - let msg = ExecuteMsg::EndPoll { poll_id }; - env.block.height = &env.block.height + 2; - - let execute_res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); - - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "end_poll"), - attr("poll_id", poll_id.to_string()), - attr("rejected_reason", "Quorum not reached"), - attr("passed", "false"), - ] - ); - - let res = query(deps.as_ref(), env, QueryMsg::Poll { poll_id }).unwrap(); - let value: PollResponse = from_binary(&res).unwrap(); - assert_eq!(PollStatus::Rejected, value.status); -} - -#[test] -fn end_poll_quorum_rejected() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let mut deps = mock_dependencies_with_balance(&coins(100, VOTING_TOKEN)); - mock_instantiate(deps.as_mut()); - let (mut creator_env, creator_info) = - mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 0); - - let msg = create_poll_msg( - 30, - "test".to_string(), - None, - Some(creator_env.block.height + 1), - ); - - let execute_res = execute( - deps.as_mut(), - creator_env.clone(), - creator_info.clone(), - msg, - ) - .unwrap(); - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "create_poll"), - attr("creator", TEST_CREATOR), - attr("poll_id", poll_id.to_string()), - attr("quorum_percentage", "30"), - attr("end_height", "1"), - attr("start_height", "0"), - ] - ); - - let msg = ExecuteMsg::StakeVotingTokens {}; - let stake_amount = 100; - let (env, info) = mock_info_height(TEST_VOTER, &coins(stake_amount, VOTING_TOKEN), 0, 0); - - let execute_res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_stake_tokens_result(stake_amount, execute_res, deps.as_mut()); - - let msg = ExecuteMsg::CastVote { - poll_id, - vote: "yes".to_string(), - weight: Uint128::from(10u128), - }; - let execute_res = execute(deps.as_mut(), env, info, msg).unwrap(); - - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "vote_casted"), - attr("poll_id", poll_id.to_string()), - attr("weight", "10"), - attr("voter", TEST_VOTER), - ] - ); - - let msg = ExecuteMsg::EndPoll { poll_id }; - - creator_env.block.height = &creator_env.block.height + 2; - - let execute_res = execute(deps.as_mut(), creator_env, creator_info, msg).unwrap(); - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "end_poll"), - attr("poll_id", poll_id.to_string()), - attr("rejected_reason", "Quorum not reached"), - attr("passed", "false"), - ] - ); - - let res = query(deps.as_ref(), mock_env(), QueryMsg::Poll { poll_id }).unwrap(); - let value: PollResponse = from_binary(&res).unwrap(); - assert_eq!(PollStatus::Rejected, value.status); -} - -#[test] -fn end_poll_nay_rejected() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - - let voter1_stake = 100; - let voter2_stake = 1000; - let mut deps = mock_dependencies_with_balance(&coins(voter1_stake, VOTING_TOKEN)); - mock_instantiate(deps.as_mut()); - let (mut creator_env, creator_info) = - mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 0); - - let msg = create_poll_msg( - 10, - "test".to_string(), - None, - Some(creator_env.block.height + 1), - ); - - let execute_res = execute( - deps.as_mut(), - creator_env.clone(), - creator_info.clone(), - msg, - ) - .unwrap(); - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "create_poll"), - attr("creator", TEST_CREATOR), - attr("poll_id", poll_id.to_string()), - attr("quorum_percentage", "10"), - attr("end_height", "1"), - attr("start_height", "0"), - ] - ); - - let msg = ExecuteMsg::StakeVotingTokens {}; - let (_, info) = mock_info_height(TEST_VOTER, &coins(voter1_stake, VOTING_TOKEN), 0, 0); - - let execute_res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_stake_tokens_result(voter1_stake, execute_res, deps.as_mut()); - - let msg = ExecuteMsg::StakeVotingTokens {}; - let info = mock_info(TEST_VOTER_2, &coins(voter2_stake, VOTING_TOKEN)); - - let execute_res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_stake_tokens_result(voter1_stake + voter2_stake, execute_res, deps.as_mut()); - - let (env, info) = mock_info_height(TEST_VOTER_2, &[], 0, 0); - let msg = ExecuteMsg::CastVote { - poll_id, - vote: "no".to_string(), - weight: Uint128::from(voter2_stake), - }; - let execute_res = execute(deps.as_mut(), env, info, msg).unwrap(); - assert_cast_vote_success(TEST_VOTER_2, voter2_stake, &poll_id, execute_res); - - let msg = ExecuteMsg::EndPoll { poll_id }; - - creator_env.block.height = &creator_env.block.height + 2; - let execute_res = execute(deps.as_mut(), creator_env, creator_info, msg).unwrap(); - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "end_poll"), - attr("poll_id", poll_id.to_string()), - attr("rejected_reason", "Threshold not reached"), - attr("passed", "false"), - ] - ); - - let res = query(deps.as_ref(), mock_env(), QueryMsg::Poll { poll_id }).unwrap(); - let value: PollResponse = from_binary(&res).unwrap(); - assert_eq!(PollStatus::Rejected, value.status); -} - -#[test] -fn fails_end_poll_before_start_height() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - let (env, info) = mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 10000); - - let msg_start_height = 1001; - let quorum_percentage = 30; - let msg = create_poll_msg( - quorum_percentage, - "test".to_string(), - Some(msg_start_height), - None, - ); - - let execute_res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_create_poll_result( - &poll_id, - quorum_percentage, - DEFAULT_END_HEIGHT, - msg_start_height, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); - let msg = ExecuteMsg::EndPoll { poll_id }; - - let execute_res = execute(deps.as_mut(), env, info, msg); - - match execute_res { - Ok(_) => panic!("Must return error"), - Err(ContractError::PoolVotingPeriodNotStarted { start_height }) => { - assert_eq!(start_height, msg_start_height) - } - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn fails_cast_vote_not_enough_staked() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - let (env, info) = mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 10000); - - let msg = create_poll_msg(0, "test".to_string(), None, None); - - let execute_res = execute(deps.as_mut(), env, info, msg).unwrap(); - assert_create_poll_result( - &poll_id, - 0, - DEFAULT_END_HEIGHT, - 0, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); - - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - let msg = ExecuteMsg::CastVote { - poll_id, - vote: "yes".to_string(), - weight: Uint128::from(1u128), - }; - - let res = execute(deps.as_mut(), mock_env(), info, msg); - - match res { - Ok(_) => panic!("Must return error"), - Err(ContractError::PollInsufficientStake {}) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn happy_days_cast_vote() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - - let (env, info) = mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 10000); - - let quorum_percentage = 30; - - let msg = create_poll_msg(quorum_percentage, "test".to_string(), None, None); - - let execute_res = execute(deps.as_mut(), env, info, msg).unwrap(); - assert_create_poll_result( - &poll_id, - quorum_percentage, - DEFAULT_END_HEIGHT, - 0, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); - - let msg = ExecuteMsg::StakeVotingTokens {}; - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - - let execute_res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_stake_tokens_result(11, execute_res, deps.as_mut()); - - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - let weight = 10u128; - let msg = ExecuteMsg::CastVote { - poll_id, - vote: "yes".to_string(), - weight: Uint128::from(weight), - }; - - let execute_res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_cast_vote_success(TEST_VOTER, weight, &poll_id, execute_res); -} - -#[test] -fn happy_days_withdraw_voting_tokens() { - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - - let msg = ExecuteMsg::StakeVotingTokens {}; - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - - let execute_res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_stake_tokens_result(11, execute_res, deps.as_mut()); - - let state = config_read(&deps.storage).load().unwrap(); - assert_eq!( - state, - State { - denom: String::from(VOTING_TOKEN), - owner: Addr::unchecked(TEST_CREATOR), - staked_tokens: Uint128::from(11u128), - } - ); - - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - let msg = ExecuteMsg::WithdrawVotingTokens { - amount: Some(Uint128::from(11u128)), - }; - - let execute_res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - let msg = execute_res.messages.get(0).expect("no message"); - - assert_eq!( - msg.msg, - CosmosMsg::Bank(BankMsg::Send { - to_address: TEST_VOTER.to_string(), - amount: coins(11, VOTING_TOKEN), - }) - ); - - let state = config_read(&deps.storage).load().unwrap(); - assert_eq!( - state, - State { - denom: String::from(VOTING_TOKEN), - owner: Addr::unchecked(TEST_CREATOR), - staked_tokens: Uint128::zero(), - } - ); -} - -#[test] -fn fails_withdraw_voting_tokens_no_stake() { - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - let msg = ExecuteMsg::WithdrawVotingTokens { - amount: Some(Uint128::from(11u128)), - }; - - let res = execute(deps.as_mut(), mock_env(), info, msg); - - match res { - Ok(_) => panic!("Must return error"), - Err(ContractError::PollNoStake {}) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn fails_withdraw_too_many_tokens() { - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - - let msg = ExecuteMsg::StakeVotingTokens {}; - let info = mock_info(TEST_VOTER, &coins(10, VOTING_TOKEN)); - - let execute_res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_stake_tokens_result(10, execute_res, deps.as_mut()); - - let info = mock_info(TEST_VOTER, &[]); - let msg = ExecuteMsg::WithdrawVotingTokens { - amount: Some(Uint128::from(11u128)), - }; - - let res = execute(deps.as_mut(), mock_env(), info, msg); - - match res { - Ok(_) => panic!("Must return error"), - Err(ContractError::ExcessiveWithdraw { max_amount }) => { - assert_eq!(max_amount, Uint128::from(10u32)) - } - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn fails_cast_vote_twice() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - - let (env, info) = mock_info_height(TEST_CREATOR, &coins(2, VOTING_TOKEN), 0, 10000); - - let quorum_percentage = 30; - let msg = create_poll_msg(quorum_percentage, "test".to_string(), None, None); - let execute_res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); - - assert_create_poll_result( - &poll_id, - quorum_percentage, - DEFAULT_END_HEIGHT, - 0, - TEST_CREATOR, - execute_res, - deps.as_mut(), - ); - - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - let msg = ExecuteMsg::StakeVotingTokens {}; - - let execute_res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_stake_tokens_result(11, execute_res, deps.as_mut()); - - let weight = 1u128; - let msg = ExecuteMsg::CastVote { - poll_id, - vote: "yes".to_string(), - weight: Uint128::from(weight), - }; - let execute_res = execute(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - assert_cast_vote_success(TEST_VOTER, weight, &poll_id, execute_res); - - let msg = ExecuteMsg::CastVote { - poll_id, - vote: "yes".to_string(), - weight: Uint128::from(weight), - }; - let res = execute(deps.as_mut(), env, info, msg); - - match res { - Ok(_) => panic!("Must return error"), - Err(ContractError::PollSenderVoted {}) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn fails_cast_vote_without_poll() { - let poll_id = Uuid::from_str("849c1f99-e882-53e6-8e63-e5aa001359c2").unwrap(); - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - - let msg = ExecuteMsg::CastVote { - poll_id, - vote: "yes".to_string(), - weight: Uint128::from(1u128), - }; - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - - let res = execute(deps.as_mut(), mock_env(), info, msg); - - match res { - Ok(_) => panic!("Must return error"), - Err(ContractError::PollNotExist {}) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn happy_days_stake_voting_tokens() { - let mut deps = mock_dependencies(); - mock_instantiate(deps.as_mut()); - - let msg = ExecuteMsg::StakeVotingTokens {}; - - let info = mock_info(TEST_VOTER, &coins(11, VOTING_TOKEN)); - - let execute_res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_stake_tokens_result(11, execute_res, deps.as_mut()); -} - -#[test] -fn fails_insufficient_funds() { - let mut deps = mock_dependencies(); - - // initialize the store - let msg = init_msg(); - let info = mock_info(TEST_VOTER, &coins(2, VOTING_TOKEN)); - let init_res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(0, init_res.messages.len()); - - // insufficient token - let msg = ExecuteMsg::StakeVotingTokens {}; - let info = mock_info(TEST_VOTER, &coins(0, VOTING_TOKEN)); - - let res = execute(deps.as_mut(), mock_env(), info, msg); - - match res { - Ok(_) => panic!("Must return error"), - Err(ContractError::InsufficientFundsSent {}) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -#[test] -fn fails_staking_wrong_token() { - let mut deps = mock_dependencies(); - - // initialize the store - let msg = init_msg(); - let info = mock_info(TEST_VOTER, &coins(2, VOTING_TOKEN)); - let init_res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(0, init_res.messages.len()); - - // wrong token - let msg = ExecuteMsg::StakeVotingTokens {}; - let info = mock_info(TEST_VOTER, &coins(11, "play money")); - - let res = execute(deps.as_mut(), mock_env(), info, msg); - - match res { - Ok(_) => panic!("Must return error"), - Err(ContractError::InsufficientFundsSent {}) => {} - Err(e) => panic!("Unexpected error: {:?}", e), - } -} - -// helper to confirm the expected create_poll response -fn assert_create_poll_result( - poll_id: &Uuid, - quorum: u8, - end_height: u64, - start_height: u64, - creator: &str, - execute_res: Response, - deps: DepsMut, -) { - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "create_poll"), - attr("creator", creator), - attr("poll_id", poll_id.to_string()), - attr("quorum_percentage", quorum.to_string()), - attr("end_height", end_height.to_string()), - attr("start_height", start_height.to_string()), - ] - ); - - //confirm poll count - let state = config_read(deps.storage).load().unwrap(); - assert_eq!( - state, - State { - denom: String::from(VOTING_TOKEN), - owner: Addr::unchecked(TEST_CREATOR), - staked_tokens: Uint128::zero(), - } - ); -} - -fn assert_stake_tokens_result(staked_tokens: u128, execute_res: Response, deps: DepsMut) { - assert_eq!(execute_res, Response::default()); - - let state = config_read(deps.storage).load().unwrap(); - assert_eq!( - state, - State { - denom: String::from(VOTING_TOKEN), - owner: Addr::unchecked(TEST_CREATOR), - staked_tokens: Uint128::from(staked_tokens), - } - ); -} - -fn assert_cast_vote_success(voter: &str, weight: u128, poll_id: &Uuid, execute_res: Response) { - assert_eq!( - execute_res.attributes, - vec![ - attr("action", "vote_casted"), - attr("poll_id", poll_id.to_string()), - attr("weight", weight.to_string()), - attr("voter", voter), - ] - ); -} diff --git a/contracts/voting-with-uuid/tests/integration.rs b/contracts/voting-with-uuid/tests/integration.rs deleted file mode 100644 index f481b3495..000000000 --- a/contracts/voting-with-uuid/tests/integration.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! This integration test tries to run and call the generated wasm. -//! It depends on a Wasm build being available, which you can create with `cargo wasm`. -//! Then running `cargo integration-test` will validate we can properly call into that generated Wasm. -//! -//! You can easily convert unit tests to integration tests as follows: -//! 1. Copy them over verbatim -//! 2. Then change -//! let mut deps = mock_dependencies(20, &[]); -//! to -//! let mut deps = mock_instance(WASM, &[]); -//! 3. If you access raw storage, where ever you see something like: -//! deps.storage.get(CONFIG_KEY).expect("no data stored"); -//! replace it with: -//! deps.with_storage(|store| { -//! let data = store.get(CONFIG_KEY).expect("no data stored"); -//! //... -//! }); -//! 4. Anywhere you see query(&deps, ...) you must replace it with query(&mut deps, ...) - -use cosmwasm_std::{coins, Response}; -use cosmwasm_vm::testing::{execute, instantiate, mock_env, mock_info, mock_instance}; - -use cw_voting_with_uuid::msg::{ExecuteMsg, InstantiateMsg}; - -static WASM: &[u8] = - include_bytes!("../target/wasm32-unknown-unknown/release/cw_voting_with_uuid.wasm"); -const DENOM: &str = "voting_token"; - -#[test] -fn compare_gas_spent() { - let mut deps = mock_instance(WASM, &[]); - let env = mock_env(); - let creator = String::from("creator"); - let info = mock_info(&creator, &coins(1000, "earth")); - - let msg = InstantiateMsg { - denom: String::from(DENOM), - }; - let res: Response = instantiate(&mut deps, env.clone(), info.clone(), msg).unwrap(); - assert_eq!(res.messages.len(), 0); - - let uuid_msg = ExecuteMsg::MakeUuid {}; - let before_gas1 = deps.get_gas_left(); - let _execute_res: Response = execute(&mut deps, env.clone(), info.clone(), uuid_msg).unwrap(); - let gas_used_uuid = before_gas1 - deps.get_gas_left(); - - let seq_msg = ExecuteMsg::MakeSequenceId {}; - let before_gas2 = deps.get_gas_left(); - let _execute_res: Response = execute(&mut deps, env, info, seq_msg).unwrap(); - let gas_used_seq_id = before_gas2 - deps.get_gas_left(); - - assert!(gas_used_seq_id < gas_used_uuid); - println!("gas_seq_id {} gas_uuid {}", gas_used_seq_id, gas_used_uuid); -}