diff --git a/.github/workflows/contract_tests.yml b/.github/workflows/contract_tests.yml index 7add6c16f..5791ab745 100644 --- a/.github/workflows/contract_tests.yml +++ b/.github/workflows/contract_tests.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - contract: [burner, crypto-verify, cyberpunk, hackatom, ibc-reflect, ibc-reflect-send, queue, query-queue, reflect, floaty, staking, voting-with-uuid] + contract: [burner, crypto-verify, cyberpunk, hackatom, ibc-reflect, ibc-reflect-send, queue, query-queue, reflect, floaty, staking] env: working-directory: ./contracts/${{ matrix.contract }} steps: diff --git a/Cargo.toml b/Cargo.toml index 311069d0c..0339ccffe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = ["packages/*"] -exclude = ["contracts"] +exclude = ["contracts", "packages/vm/tests/try-sha1"] # Resolver has to be set explicitely in workspaces # due to https://github.com/rust-lang/cargo/issues/9956 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/.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/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); -} diff --git a/packages/crypto/benches/main.rs b/packages/crypto/benches/main.rs index b395724b6..9135759c5 100644 --- a/packages/crypto/benches/main.rs +++ b/packages/crypto/benches/main.rs @@ -13,7 +13,6 @@ use sha2::Sha256; use cosmwasm_crypto::{ ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify, - sha1_calculate, }; use std::cmp::min; @@ -75,8 +74,6 @@ fn read_decode_cosmos_sigs() -> (Vec>, Vec>, Vec>) { } fn bench_crypto(c: &mut Criterion) { - // same as vm::imports::MAX_LENGTH_SHA1_MESSAGE (=80) - const MAX_LENGTH_SHA1_MESSAGE: usize = 80; let mut group = c.benchmark_group("Crypto"); group.bench_function("secp256k1_verify", |b| { @@ -110,33 +107,6 @@ fn bench_crypto(c: &mut Criterion) { }); }); - group.bench_function("sha1_calculate_one", |b| { - let inputs: Vec<&[u8]> = vec![&[0; MAX_LENGTH_SHA1_MESSAGE]]; - b.iter(|| { - let hash = sha1_calculate(&inputs).unwrap(); - assert_eq!(hash.len(), 20); - }); - }); - group.bench_function("sha1_calculate_two", |b| { - let inputs: Vec<&[u8]> = vec![&[0; MAX_LENGTH_SHA1_MESSAGE], &[1; MAX_LENGTH_SHA1_MESSAGE]]; - b.iter(|| { - let hash = sha1_calculate(&inputs).unwrap(); - assert_eq!(hash.len(), 20); - }); - }); - group.bench_function("sha1_calculate_four", |b| { - let inputs: Vec<&[u8]> = vec![ - &[0; MAX_LENGTH_SHA1_MESSAGE], - &[1; MAX_LENGTH_SHA1_MESSAGE], - &[2; MAX_LENGTH_SHA1_MESSAGE], - &[3; MAX_LENGTH_SHA1_MESSAGE], - ]; - b.iter(|| { - let hash = sha1_calculate(&inputs).unwrap(); - assert_eq!(hash.len(), 20); - }); - }); - group.bench_function("ed25519_verify", |b| { let message = hex::decode(COSMOS_ED25519_MSG_HEX).unwrap(); let signature = hex::decode(COSMOS_ED25519_SIGNATURE_HEX).unwrap(); diff --git a/packages/crypto/src/lib.rs b/packages/crypto/src/lib.rs index 2bf21cbfa..97bf244c4 100644 --- a/packages/crypto/src/lib.rs +++ b/packages/crypto/src/lib.rs @@ -8,7 +8,6 @@ mod ed25519; mod errors; mod identity_digest; mod secp256k1; -mod sha1; #[doc(hidden)] pub use crate::ed25519::EDDSA_PUBKEY_LEN; @@ -20,5 +19,3 @@ pub use crate::errors::{CryptoError, CryptoResult}; pub use crate::secp256k1::{secp256k1_recover_pubkey, secp256k1_verify}; #[doc(hidden)] pub use crate::secp256k1::{ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, MESSAGE_HASH_MAX_LEN}; -#[doc(hidden)] -pub use crate::sha1::sha1_calculate; diff --git a/packages/crypto/src/sha1.rs b/packages/crypto/src/sha1.rs deleted file mode 100644 index 6dc6f2d69..000000000 --- a/packages/crypto/src/sha1.rs +++ /dev/null @@ -1,26 +0,0 @@ -use sha1::{Digest, Sha1}; - -use crate::errors::CryptoResult; - -pub fn sha1_calculate(hash_inputs: &[&[u8]]) -> CryptoResult<[u8; 20]> { - let mut hasher = Sha1::new(); - for &hash_input in hash_inputs.iter() { - hasher.update(hash_input); - } - let buffer: [u8; 20] = hasher.finalize().into(); - Ok(buffer) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_sha1_calculate() { - let input1: &str = "input_data1"; - let input2: &str = "input_data2"; - let inputs = &[input1.as_bytes(), input2.as_bytes()]; - let calc_result = sha1_calculate(inputs).unwrap(); - assert_eq!(20, calc_result.len()) - } -} diff --git a/packages/std/src/errors/hash_calculation_error.rs b/packages/std/src/errors/hash_calculation_error.rs deleted file mode 100644 index b5715aaea..000000000 --- a/packages/std/src/errors/hash_calculation_error.rs +++ /dev/null @@ -1,86 +0,0 @@ -#[cfg(feature = "backtraces")] -use std::backtrace::Backtrace; -use std::fmt::Debug; -use thiserror::Error; - -#[cfg(not(target_arch = "wasm32"))] -use cosmwasm_crypto::CryptoError; - -#[derive(Error, Debug)] -pub enum HashCalculationError { - #[error("Inputs are larger than supported")] - InputsTooLarger, - #[error("Input is longer than supported")] - InputTooLonger, - #[error("Unknown error: {error_code}")] - UnknownErr { - error_code: u32, - #[cfg(feature = "backtraces")] - backtrace: Backtrace, - }, -} - -impl HashCalculationError { - pub fn unknown_err(error_code: u32) -> Self { - HashCalculationError::UnknownErr { - error_code, - #[cfg(feature = "backtraces")] - backtrace: Backtrace::capture(), - } - } -} - -impl PartialEq for HashCalculationError { - fn eq(&self, rhs: &HashCalculationError) -> bool { - match self { - HashCalculationError::InputsTooLarger => { - matches!(rhs, HashCalculationError::InputsTooLarger) - } - HashCalculationError::InputTooLonger => { - matches!(rhs, HashCalculationError::InputTooLonger) - } - HashCalculationError::UnknownErr { error_code, .. } => { - if let HashCalculationError::UnknownErr { - error_code: rhs_error_code, - .. - } = rhs - { - error_code == rhs_error_code - } else { - false - } - } - } - } -} - -#[cfg(not(target_arch = "wasm32"))] -impl From for HashCalculationError { - fn from(original: CryptoError) -> Self { - match original { - CryptoError::InputsTooLarger { .. } => HashCalculationError::InputsTooLarger, - CryptoError::InputTooLong { .. } => HashCalculationError::InputTooLonger, - CryptoError::InvalidHashFormat { .. } - | CryptoError::InvalidPubkeyFormat { .. } - | CryptoError::InvalidSignatureFormat { .. } - | CryptoError::GenericErr { .. } - | CryptoError::InvalidRecoveryParam { .. } - | CryptoError::BatchErr { .. } => panic!("Conversion not supported"), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - // constructors - #[test] - fn unknown_err_works() { - let error = HashCalculationError::unknown_err(123); - match error { - HashCalculationError::UnknownErr { error_code, .. } => assert_eq!(error_code, 123), - _ => panic!("wrong error type!"), - } - } -} diff --git a/packages/std/src/errors/mod.rs b/packages/std/src/errors/mod.rs index d11c5604e..bf7e61f43 100644 --- a/packages/std/src/errors/mod.rs +++ b/packages/std/src/errors/mod.rs @@ -1,10 +1,8 @@ -mod hash_calculation_error; mod recover_pubkey_error; mod std_error; mod system_error; mod verification_error; -pub use hash_calculation_error::HashCalculationError; pub use recover_pubkey_error::RecoverPubkeyError; pub use std_error::{ CheckedFromRatioError, CheckedMultiplyRatioError, ConversionOverflowError, DivideByZeroError, diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index ede4b87a5..fa5c27f32 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -3,7 +3,7 @@ use std::backtrace::Backtrace; use std::fmt; use thiserror::Error; -use crate::errors::{HashCalculationError, RecoverPubkeyError, VerificationError}; +use crate::errors::{RecoverPubkeyError, VerificationError}; /// Structured error type for init, execute and query. /// @@ -34,12 +34,6 @@ pub enum StdError { #[cfg(feature = "backtraces")] backtrace: Backtrace, }, - #[error("Hash Calculation error: {source}")] - HashCalculationError { - source: HashCalculationError, - #[cfg(feature = "backtraces")] - backtrace: Backtrace, - }, /// Whenever there is no specific error type available #[error("Generic error: {msg}")] GenericErr { @@ -133,14 +127,6 @@ impl StdError { } } - pub fn hash_calculation_err(source: HashCalculationError) -> Self { - StdError::HashCalculationError { - source, - #[cfg(feature = "backtraces")] - backtrace: Backtrace::capture(), - } - } - pub fn generic_err(msg: impl Into) -> Self { StdError::GenericErr { msg: msg.into(), @@ -261,22 +247,6 @@ impl PartialEq for StdError { false } } - StdError::HashCalculationError { - source, - #[cfg(feature = "backtraces")] - backtrace: _, - } => { - if let StdError::HashCalculationError { - source: rhs_source, - #[cfg(feature = "backtraces")] - backtrace: _, - } = rhs - { - source == rhs_source - } else { - false - } - } StdError::GenericErr { msg, #[cfg(feature = "backtraces")] @@ -487,12 +457,6 @@ impl From for StdError { } } -impl From for StdError { - fn from(source: HashCalculationError) -> Self { - Self::hash_calculation_err(source) - } -} - impl From for StdError { fn from(source: OverflowError) -> Self { Self::overflow(source) diff --git a/packages/std/src/imports.rs b/packages/std/src/imports.rs index b8b50bd05..99d3598bc 100644 --- a/packages/std/src/imports.rs +++ b/packages/std/src/imports.rs @@ -1,10 +1,7 @@ -use std::convert::TryInto; use std::vec::Vec; use crate::addresses::{Addr, CanonicalAddr}; -use crate::errors::{ - HashCalculationError, RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError, -}; +use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; use crate::import_helpers::{from_high_half, from_low_half}; use crate::memory::{alloc, build_region, consume_region, Region}; use crate::results::SystemResult; @@ -68,7 +65,6 @@ extern "C" { /// Returns 0 on verification success, 1 on verification failure, and values /// greater than 1 in case of error. fn ed25519_batch_verify(messages_ptr: u32, signatures_ptr: u32, public_keys_ptr: u32) -> u32; - fn sha1_calculate(inputs_ptr: u32) -> u64; /// Writes a debug message (UFT-8 encoded) to the host for debugging purposes. /// The host is free to log or process this in any way it considers appropriate. @@ -360,28 +356,6 @@ impl Api for ExternalApi { } } - fn sha1_calculate(&self, inputs: &[&[u8]]) -> Result<[u8; 20], HashCalculationError> { - let inputs_encoded = encode_sections(inputs); - let inputs_send = build_region(&inputs_encoded); - let inputs_send_ptr = &*inputs_send as *const Region as u32; - - let result = unsafe { sha1_calculate(inputs_send_ptr) }; - let error_code = from_high_half(result); - let hash_ptr = from_low_half(result); - match error_code { - 0 => { - let hash = unsafe { consume_region(hash_ptr as *mut Region) }; - let hash_array: [u8; 20] = hash.try_into().unwrap_or_else(|v: Vec| { - panic!("Expected a Vec of length {} but it was {}", 20, v.len()) - }); - Ok(hash_array) - } - 1 => Err(HashCalculationError::InputsTooLarger), - 2 => panic!("Error code 2 unused since CosmWasm 0.15. This is a bug in the VM."), - error_code => Err(HashCalculationError::unknown_err(error_code)), - } - } - fn debug(&self, message: &str) { // keep the boxes in scope, so we free it at the end (don't cast to pointers same line as build_region) let region = build_region(message.as_bytes()); diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index 683153f4d..c1e27debf 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -24,7 +24,6 @@ mod storage; mod timestamp; mod traits; mod types; -mod uuid; pub use crate::addresses::{Addr, CanonicalAddr}; pub use crate::binary::Binary; @@ -78,7 +77,6 @@ pub use crate::storage::MemoryStorage; pub use crate::timestamp::Timestamp; pub use crate::traits::{Api, Querier, QuerierResult, QuerierWrapper, Storage}; pub use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo, TransactionInfo}; -pub use crate::uuid::{new_uuid, Uuid}; // Exposed in wasm build only diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index 350c16927..96d7b952f 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -8,9 +8,7 @@ use crate::addresses::{Addr, CanonicalAddr}; use crate::binary::Binary; use crate::coin::Coin; use crate::deps::OwnedDeps; -use crate::errors::{ - HashCalculationError, RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError, -}; +use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; #[cfg(feature = "stargate")] use crate::ibc::{ IbcAcknowledgement, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, @@ -216,10 +214,6 @@ impl Api for MockApi { )?) } - fn sha1_calculate(&self, inputs: &[&[u8]]) -> Result<[u8; 20], HashCalculationError> { - Ok(cosmwasm_crypto::sha1_calculate(inputs)?) - } - fn debug(&self, message: &str) { println!("{}", message); } diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index 8097db0b5..57bd5d81b 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -5,9 +5,7 @@ use std::ops::Deref; use crate::addresses::{Addr, CanonicalAddr}; use crate::binary::Binary; use crate::coin::Coin; -use crate::errors::{ - HashCalculationError, RecoverPubkeyError, StdError, StdResult, VerificationError, -}; +use crate::errors::{RecoverPubkeyError, StdError, StdResult, VerificationError}; #[cfg(feature = "iterator")] use crate::iterator::{Order, Record}; #[cfg(feature = "cosmwasm_1_1")] @@ -138,8 +136,6 @@ pub trait Api { public_keys: &[&[u8]], ) -> Result; - fn sha1_calculate(&self, inputs: &[&[u8]]) -> Result<[u8; 20], HashCalculationError>; - /// Emits a debugging message that is handled depending on the environment (typically printed to console or ignored). /// Those messages are not persisted to chain. fn debug(&self, message: &str); diff --git a/packages/std/src/uuid.rs b/packages/std/src/uuid.rs deleted file mode 100644 index 41798b408..000000000 --- a/packages/std/src/uuid.rs +++ /dev/null @@ -1,134 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use std::ops::Deref; -use std::str::FromStr; -use uuid as raw_uuid; - -use crate::{from_slice, to_vec}; -use crate::{Api, Env, StdResult, Storage}; - -/// 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. -#[derive( - Serialize, Deserialize, Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema, -)] -pub struct Uuid(#[schemars(with = "String")] raw_uuid::Uuid); -impl Uuid { - pub fn as_slice(&self) -> &[u8] { - &self.as_bytes()[0..16] - } - - // Port the new_v5 implementation of uuid to use deps.api - // https://github.com/uuid-rs/uuid/blob/2d6c147bdfca9612263dd7e82e26155f7ef8bf32/src/v5.rs#L33 - fn new_v5(api: &dyn Api, namespace: &Uuid, name: &[u8]) -> StdResult { - let inputs = [namespace.as_bytes(), name]; - let buffer = api.sha1_calculate(&inputs)?; - - let mut bytes = raw_uuid::Bytes::default(); - bytes.copy_from_slice(&buffer[..16]); - let mut builder = raw_uuid::Builder::from_bytes(bytes); - builder - .set_variant(raw_uuid::Variant::RFC4122) - .set_version(raw_uuid::Version::Sha1); - - Ok(Uuid(builder.into_uuid())) - } -} - -const CONTRACT_UUID_SEQ_NUM_KEY: &[u8] = b"contract_uuid_seq_num"; - -pub fn new_uuid(env: &Env, storage: &mut dyn Storage, api: &dyn Api) -> StdResult { - let raw_seq_num = storage.get(CONTRACT_UUID_SEQ_NUM_KEY); - let seq_num: u16 = match raw_seq_num { - Some(data) => from_slice(&data).unwrap(), - None => 0, - }; - let next_seq_num: u16 = seq_num.wrapping_add(1); - - let uuid_name = format!("{} {} {}", env.contract.address, env.block.height, seq_num); - storage.set(CONTRACT_UUID_SEQ_NUM_KEY, &(to_vec(&next_seq_num).unwrap())); - - Uuid::new_v5( - api, - &Uuid(raw_uuid::Uuid::NAMESPACE_OID), - uuid_name.as_bytes(), - ) -} - -impl Deref for Uuid { - type Target = raw_uuid::Uuid; - fn deref(&self) -> &raw_uuid::Uuid { - &self.0 - } -} - -impl FromStr for Uuid { - type Err = uuid::Error; - fn from_str(s: &str) -> Result { - let parsed = raw_uuid::Uuid::parse_str(s); - match parsed { - Ok(data) => Ok(Uuid(data)), - Err(err) => Err(err), - } - } -} - -#[cfg(test)] -mod tests { - use crate::testing::{mock_env, MockApi, MockStorage}; - use crate::{new_uuid, Uuid}; - use crate::{to_vec, Addr, Storage}; - use std::str::FromStr; - use uuid as raw_uuid; - - const CONTRACT_UUID_SEQ_NUM_KEY: &[u8] = b"contract_uuid_seq_num"; - - #[test] - fn generate_uuid_v5() { - let env = mock_env(); - let api = MockApi::default(); - let mut storage = MockStorage::new(); - - let uuid = new_uuid(&env, &mut storage, &api).unwrap(); - let uuid2 = new_uuid(&env, &mut storage, &api).unwrap(); - - assert_eq!(uuid.to_string(), "417d3461-5f6c-584b-8035-482a70997aee"); - assert_eq!(uuid.get_variant(), uuid::Variant::RFC4122); - assert_eq!(uuid.get_version(), Some(uuid::Version::Sha1)); - let parsed_uuid = Uuid::from_str("417d3461-5f6c-584b-8035-482a70997aee"); - assert_eq!(uuid, parsed_uuid.unwrap()); - - assert_eq!(uuid2.to_string(), "61b5574c-d3e4-5d06-8a87-ab28a7353dfd"); - assert_ne!(uuid, uuid2); - } - - #[test] - fn same_output_as_raw_uuid() { - let env = mock_env(); - let api = MockApi::default(); - let mut storage = MockStorage::new(); - let our_uuid = new_uuid(&env, &mut storage, &api).unwrap(); - - let uuid_name = format!("{} {} {}", env.contract.address, env.block.height, 0); - let raw = raw_uuid::Uuid::new_v5(&raw_uuid::Uuid::NAMESPACE_OID, uuid_name.as_bytes()); - - assert_eq!(our_uuid.to_string(), raw.to_string()); - } - - #[test] - fn work_fine_as_longest_name() { - let mut env = mock_env(); - let api = MockApi::default(); - let mut storage = MockStorage::new(); - - //enforce the max value - env.contract.address = Addr::unchecked("link1qyqszqgpqyqszqgpqyqszqgpqyqszqgp8apuk5"); - env.block.height = u64::MAX; - let stor: &mut dyn Storage = &mut storage; - stor.set(CONTRACT_UUID_SEQ_NUM_KEY, &(to_vec(&u16::MAX).unwrap())); - - let uuid = new_uuid(&env, &mut storage, &api); - assert!(uuid.is_ok()); - } -} diff --git a/packages/vm/src/environment.rs b/packages/vm/src/environment.rs index aa2cae848..d9e0b8000 100644 --- a/packages/vm/src/environment.rs +++ b/packages/vm/src/environment.rs @@ -29,15 +29,12 @@ pub struct GasConfig { pub ed25519_batch_verify_cost: u64, /// ed25519 batch signature verification cost (single public key) pub ed25519_batch_verify_one_pubkey_cost: u64, - /// sha1 hash calculation cost (single input) - pub sha1_calculate_cost: u64, } impl Default for GasConfig { fn default() -> Self { // Target is 10^12 per millisecond (see GAS.md), i.e. 10^9 gas per ยต second. const GAS_PER_US: u64 = 1_000_000_000; - const GAS_PER_NS: u64 = 1_000_000; Self { // ~154 us in crypto benchmarks secp256k1_verify_cost: 154 * GAS_PER_US, @@ -49,7 +46,6 @@ impl Default for GasConfig { // From https://docs.rs/ed25519-zebra/2.2.0/ed25519_zebra/batch/index.html ed25519_batch_verify_cost: 63 * GAS_PER_US / 2, ed25519_batch_verify_one_pubkey_cost: 63 * GAS_PER_US / 4, - sha1_calculate_cost: 269 * GAS_PER_NS, } } } diff --git a/packages/vm/src/imports.rs b/packages/vm/src/imports.rs index a0d60f145..60b4c5737 100644 --- a/packages/vm/src/imports.rs +++ b/packages/vm/src/imports.rs @@ -3,8 +3,7 @@ use std::cmp::max; use cosmwasm_crypto::{ - ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify, - sha1_calculate, CryptoError, + ed25519_batch_verify, ed25519_verify, secp256k1_recover_pubkey, secp256k1_verify, CryptoError, }; use cosmwasm_crypto::{ ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, EDDSA_PUBKEY_LEN, MESSAGE_HASH_MAX_LEN, @@ -51,15 +50,6 @@ const MAX_LENGTH_ED25519_MESSAGE: usize = 128 * 1024; /// This is an arbitrary value, for performance / memory contraints. If you need to batch-verify a /// larger number of signatures, let us know. const MAX_COUNT_ED25519_BATCH: usize = 256; -/// Max count of a inputs for sha1. -/// A limit is set to prevent malicious excessive input. -/// Now, we limit ourselves to only small sizes for use cases in Uuid. -pub const MAX_COUNT_SHA1_INPUT: usize = 4; -/// Max length of a input for sha1 -/// After executing the crypto bench according to this, -/// the gas factor is determined based on the result. -/// If you modify this value, you need to adjust the gas factor. -pub const MAX_LENGTH_SHA1_MESSAGE: usize = 80; /// Max length for a debug message const MAX_LENGTH_DEBUG: usize = 2 * MI; @@ -362,43 +352,11 @@ pub fn do_ed25519_batch_verify( } pub fn do_sha1_calculate( - env: &Environment, - hash_inputs_ptr: u32, + _env: &Environment, + _hash_inputs_ptr: u32, ) -> VmResult { - let hash_inputs = read_region( - &env.memory(), - hash_inputs_ptr, - (MAX_LENGTH_SHA1_MESSAGE + 4) * MAX_COUNT_SHA1_INPUT, - )?; - - let hash_inputs = decode_sections(&hash_inputs); - let result = sha1_calculate(&hash_inputs); - let mut gas_cost = env.gas_config.sha1_calculate_cost; - //For sha1, the execution time does not increase linearly by the number of updates(count of inputs). - if hash_inputs.len() > 1 { - gas_cost += (env.gas_config.sha1_calculate_cost * (hash_inputs.len() - 1) as u64) / 2; - } - let gas_info = GasInfo::with_cost(gas_cost); - process_gas_info::(env, gas_info)?; - match result { - Ok(hash) => { - let hash_ptr = write_to_contract::(env, &hash)?; - Ok(to_low_half(hash_ptr)) - } - Err(err) => match err { - CryptoError::InputsTooLarger { .. } | CryptoError::InputTooLong { .. } => { - Ok(to_high_half(err.code())) - } - CryptoError::BatchErr { .. } - | CryptoError::InvalidPubkeyFormat { .. } - | CryptoError::InvalidSignatureFormat { .. } - | CryptoError::GenericErr { .. } - | CryptoError::InvalidHashFormat { .. } - | CryptoError::InvalidRecoveryParam { .. } => { - panic!("Error must not happen for this call") - } - }, - } + // error code for generic error + Ok(to_high_half(10)) } /// Prints a debug message to console. diff --git a/packages/vm/src/instance.rs b/packages/vm/src/instance.rs index 7656cf02d..093d2d2e9 100644 --- a/packages/vm/src/instance.rs +++ b/packages/vm/src/instance.rs @@ -172,10 +172,8 @@ where Function::new_native_with_env(store, env.clone(), do_ed25519_batch_verify), ); - // Calculates the inputs using the sha1 - // Returns 0 if inputs are some invalid and pointer to result region otherwise. - // Ownership of the inputs pointer is not transferred to the host. - // Ownership of the hash pointer is transferred to the contract. + // No longer supported + // This function only returns an error to wasm. env_imports.insert( "sha1_calculate", Function::new_native_with_env(store, env.clone(), do_sha1_calculate), diff --git a/contracts/voting-with-uuid/.cargo/config b/packages/vm/tests/.cargo/config similarity index 57% rename from contracts/voting-with-uuid/.cargo/config rename to packages/vm/tests/.cargo/config index 9a1df2e20..8d4bc738b 100644 --- a/contracts/voting-with-uuid/.cargo/config +++ b/packages/vm/tests/.cargo/config @@ -2,6 +2,5 @@ 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" +integration-test = "test --test integration" schema = "run --example schema" diff --git a/packages/vm/tests/README.md b/packages/vm/tests/README.md new file mode 100644 index 000000000..f63ff69d8 --- /dev/null +++ b/packages/vm/tests/README.md @@ -0,0 +1,4 @@ +# integration test for vm +## try-sha1 +test that the sha1-calculate API is no longer supported. +`try-sha1.wasm` is needed and which is compiled wasm of `try-sha1`. diff --git a/packages/vm/tests/try-sha1.wasm b/packages/vm/tests/try-sha1.wasm new file mode 100644 index 000000000..b967e71cf Binary files /dev/null and b/packages/vm/tests/try-sha1.wasm differ diff --git a/packages/vm/tests/try-sha1/.cargo/config b/packages/vm/tests/try-sha1/.cargo/config new file mode 100644 index 000000000..8d4bc738b --- /dev/null +++ b/packages/vm/tests/try-sha1/.cargo/config @@ -0,0 +1,6 @@ +[alias] +wasm = "build --release --target wasm32-unknown-unknown" +wasm-debug = "build --target wasm32-unknown-unknown" +unit-test = "test --lib" +integration-test = "test --test integration" +schema = "run --example schema" diff --git a/packages/vm/tests/try-sha1/Cargo.lock b/packages/vm/tests/try-sha1/Cargo.lock new file mode 100644 index 000000000..8b174ffa6 --- /dev/null +++ b/packages/vm/tests/try-sha1/Cargo.lock @@ -0,0 +1,719 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[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.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cosmwasm-crypto" +version = "1.1.9+0.9.0" +source = "git+https://github.com/Finschia/cosmwasm?tag=v1.1.9+0.9.0#516512fbb743d8625cda072d6e5ac307b99ff5aa" +dependencies = [ + "digest 0.10.7", + "ed25519-zebra", + "k256", + "rand_core 0.6.4", + "sha-1", + "thiserror", +] + +[[package]] +name = "cosmwasm-derive" +version = "1.1.9+0.9.0" +source = "git+https://github.com/Finschia/cosmwasm?tag=v1.1.9+0.9.0#516512fbb743d8625cda072d6e5ac307b99ff5aa" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-schema" +version = "1.1.9+0.9.0" +source = "git+https://github.com/Finschia/cosmwasm?tag=v1.1.9+0.9.0#516512fbb743d8625cda072d6e5ac307b99ff5aa" +dependencies = [ + "cosmwasm-schema-derive", + "schemars", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "1.1.9+0.9.0" +source = "git+https://github.com/Finschia/cosmwasm?tag=v1.1.9+0.9.0#516512fbb743d8625cda072d6e5ac307b99ff5aa" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-std" +version = "1.1.9+0.9.0" +source = "git+https://github.com/Finschia/cosmwasm?tag=v1.1.9+0.9.0#516512fbb743d8625cda072d6e5ac307b99ff5aa" +dependencies = [ + "base64", + "cosmwasm-crypto", + "cosmwasm-derive", + "derivative", + "forward_ref", + "hex", + "schemars", + "serde", + "serde-json-wasm", + "thiserror", + "uint", + "uuid", +] + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[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 = "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 1.0.109", +] + +[[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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + +[[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", + "hex", + "rand_core 0.6.4", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[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.7", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[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 = "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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[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.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[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.7", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[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.8", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[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-macro2" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +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 = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.66", +] + +[[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.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +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_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +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.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[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.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "try-sha1" +version = "0.0.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "schemars", + "serde", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[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.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +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 = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/packages/vm/tests/try-sha1/Cargo.toml b/packages/vm/tests/try-sha1/Cargo.toml new file mode 100644 index 000000000..1ee682512 --- /dev/null +++ b/packages/vm/tests/try-sha1/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "try-sha1" +version = "0.0.0" +authors = ["loloicci "] +edition = "2021" +publish = false +license = "Apache-2.0" + +# 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] +# Add feature "cranelift" to default if you need 32 bit or ARM support +default = [] +# for quicker tests, cargo test --lib +# for more explicit tests, cargo test --features=backtraces +backtraces = ["cosmwasm-std/backtraces"] + +[dependencies] +cosmwasm-schema = { git = "https://github.com/Finschia/cosmwasm", tag = "v1.1.9+0.9.0" } +cosmwasm-std = { git = "https://github.com/Finschia/cosmwasm", tag = "v1.1.9+0.9.0" } +schemars = "0.8.3" +serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/voting-with-uuid/LICENSE b/packages/vm/tests/try-sha1/LICENSE similarity index 99% rename from contracts/voting-with-uuid/LICENSE rename to packages/vm/tests/try-sha1/LICENSE index 3be3a520b..d64569567 100644 --- a/contracts/voting-with-uuid/LICENSE +++ b/packages/vm/tests/try-sha1/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -186,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. -Copyright [yyyy] [name of copyright owner] + 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. diff --git a/contracts/voting-with-uuid/NOTICE b/packages/vm/tests/try-sha1/NOTICE similarity index 93% rename from contracts/voting-with-uuid/NOTICE rename to packages/vm/tests/try-sha1/NOTICE index 2fab26ed7..e505e5b1b 100644 --- a/contracts/voting-with-uuid/NOTICE +++ b/packages/vm/tests/try-sha1/NOTICE @@ -1,4 +1,4 @@ -Copyright 2019 Ethan Frey +Copyright 2023 Finschia Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/packages/vm/tests/try-sha1/README.md b/packages/vm/tests/try-sha1/README.md new file mode 100644 index 000000000..d088fd231 --- /dev/null +++ b/packages/vm/tests/try-sha1/README.md @@ -0,0 +1,11 @@ +# try-sha1 contract +This is a simple contract for tests which calls sha1-calculate. +This is an API which is no longer supported. + +## build +``` +docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="devcontract_cache_try_sha1",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/rust-optimizer:0.15.0 ./ +``` diff --git a/packages/vm/tests/try-sha1/examples/schema.rs b/packages/vm/tests/try-sha1/examples/schema.rs new file mode 100644 index 000000000..1076e3a7d --- /dev/null +++ b/packages/vm/tests/try-sha1/examples/schema.rs @@ -0,0 +1,9 @@ +use cosmwasm_schema::write_api; + +use try_sha1::msg::InstantiateMsg; + +fn main() { + write_api! { + instantiate: InstantiateMsg, + } +} diff --git a/packages/vm/tests/try-sha1/schema/try-sha1.json b/packages/vm/tests/try-sha1/schema/try-sha1.json new file mode 100644 index 000000000..de7c6a116 --- /dev/null +++ b/packages/vm/tests/try-sha1/schema/try-sha1.json @@ -0,0 +1,16 @@ +{ + "contract_name": "try-sha1", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "additionalProperties": false + }, + "execute": null, + "query": null, + "migrate": null, + "sudo": null, + "responses": null +} diff --git a/packages/vm/tests/try-sha1/src/contract.rs b/packages/vm/tests/try-sha1/src/contract.rs new file mode 100644 index 000000000..8f130b8d1 --- /dev/null +++ b/packages/vm/tests/try-sha1/src/contract.rs @@ -0,0 +1,16 @@ +use cosmwasm_std::{ + entry_point, DepsMut, Env, MessageInfo, Response, StdResult, +}; + +use crate::msg::InstantiateMsg; + +#[entry_point] +pub fn instantiate( + deps: DepsMut, + _env: Env, + _info: MessageInfo, + _msg: InstantiateMsg, +) -> StdResult { + let _ = deps.api.sha1_calculate(&[&[]])?; + Ok(Response::default()) +} diff --git a/packages/vm/tests/try-sha1/src/lib.rs b/packages/vm/tests/try-sha1/src/lib.rs new file mode 100644 index 000000000..112ecadc8 --- /dev/null +++ b/packages/vm/tests/try-sha1/src/lib.rs @@ -0,0 +1,2 @@ +pub mod contract; +pub mod msg; diff --git a/packages/vm/tests/try-sha1/src/msg.rs b/packages/vm/tests/try-sha1/src/msg.rs new file mode 100644 index 000000000..1ca3d31cf --- /dev/null +++ b/packages/vm/tests/try-sha1/src/msg.rs @@ -0,0 +1,4 @@ +use cosmwasm_schema::cw_serde; + +#[cw_serde] +pub struct InstantiateMsg {} diff --git a/packages/vm/tests/try_sha1.rs b/packages/vm/tests/try_sha1.rs new file mode 100644 index 000000000..bd4898b8f --- /dev/null +++ b/packages/vm/tests/try_sha1.rs @@ -0,0 +1,20 @@ +use cosmwasm_std::{coins, ContractResult, Response}; +use cosmwasm_vm::testing::{instantiate, mock_env, mock_info, mock_instance}; +use schemars::JsonSchema; +use serde::Serialize; + +static WASM: &[u8] = include_bytes!("./try-sha1.wasm"); + +#[derive(Serialize, JsonSchema)] +struct InstantiateMsg {} + +#[test] +fn sha1_fails_with_error_code_10() { + let mut deps = mock_instance(WASM, &[]); + + let info = mock_info("creator", &coins(1000, "earth")); + // we can just call .unwrap() to assert this was a success + let res: ContractResult = instantiate(&mut deps, mock_env(), info, InstantiateMsg {}); + let msg = res.unwrap_err(); + assert_eq!(msg, "Hash Calculation error: Unknown error: 10") +}