diff --git a/.circleci/config.yml b/.circleci/config.yml index b2f1d6858..aeda41084 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -578,7 +578,7 @@ jobs: # We also sanity-check the resultant wasm files. wasm-build: docker: - - image: rust:1.58.1 + - image: rust:1.59.0 steps: - checkout: path: ~/project @@ -587,7 +587,7 @@ jobs: command: rustc --version; cargo --version; rustup --version - restore_cache: keys: - - cargocache-wasm-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} + - cargocache-wasm-rust:1.59.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Add wasm32 target command: rustup target add wasm32-unknown-unknown @@ -597,25 +597,20 @@ jobs: for C in ./contracts/*/ do echo "Compiling `basename $C`..." - (cd $C && cargo build --release --target wasm32-unknown-unknown --locked) + (cd $C && cargo build --release --lib --target wasm32-unknown-unknown --locked) done - run: - name: Install check_contract + name: Install cosmwasm-check # Uses --debug for compilation speed - command: cargo install --debug --version 1.0.0 --features iterator --example check_contract -- cosmwasm-vm + command: cargo install --debug --version 1.1.0-rc.1 cosmwasm-check - save_cache: paths: - /usr/local/cargo/registry - target - key: cargocache-wasm-rust:1.58.1-{{ checksum "~/project/Cargo.lock" }} + key: cargocache-wasm-rust:1.59.0-{{ checksum "~/project/Cargo.lock" }} - run: name: Check wasm contracts - command: | - for W in ./target/wasm32-unknown-unknown/release/*.wasm - do - echo -n "Checking `basename $W`... " - check_contract $W - done + command: cosmwasm-check ./target/wasm32-unknown-unknown/release/*.wasm package_multi_test: docker: diff --git a/Cargo.lock b/Cargo.lock index 40c190f9d..fb6fd8a45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anyhow" -version = "1.0.57" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" +checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305" dependencies = [ "backtrace", ] @@ -51,9 +51,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" dependencies = [ "addr2line", "cc", @@ -78,9 +78,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "base64ct" -version = "1.5.0" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" +checksum = "ea2b2456fd614d856680dcd9fcc660a51a820fa09daef2e49772b56a193c8474" [[package]] name = "bitflags" @@ -97,6 +97,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + [[package]] name = "bstr" version = "0.2.17" @@ -111,9 +120,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.9.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" +checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" [[package]] name = "byteorder" @@ -123,18 +132,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" [[package]] name = "cast" -version = "0.2.7" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" -dependencies = [ - "rustc_version", -] +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" @@ -161,17 +167,17 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" +checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" [[package]] name = "cosmwasm-crypto" -version = "1.0.0" +version = "1.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eb0afef2325df81aadbf9be1233f522ed8f6e91df870c764bc44cca2b1415bd" +checksum = "090841687cec685dd6a1914b8c9504e716b83d2f17a583af6f3b77a8034cfdb1" dependencies = [ - "digest", + "digest 0.10.3", "ed25519-zebra", "k256", "rand_core 0.6.3", @@ -180,32 +186,47 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.0.0" +version = "1.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b36e527620a2a3e00e46b6e731ab6c9b68d11069c986f7d7be8eba79ef081a4" +checksum = "73196b5f87f50ac75eb716ce9f0fc0aaa80394ba742382f7714c38f9b5420e97" dependencies = [ "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.0.0" +version = "1.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772e80bbad231a47a2068812b723a1ff81dd4a0d56c9391ac748177bea3a61da" +checksum = "3e420480fd492336e849bf1c24f7339abf12a8e2afa250bc6865d67cd84cf4b4" dependencies = [ + "cosmwasm-schema-derive", "schemars", + "serde", "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "1.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf475a7f85987e1f5ef623c510a39d8d294d1ee6807c68f08d96ada6905e850d" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] name = "cosmwasm-std" -version = "1.0.0" +version = "1.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875994993c2082a6fcd406937bf0fca21c349e4a624f3810253a14fa83a3a195" +checksum = "41e13a4bfb42768d53db5d930ce276356958a8f2d4da89ac44b3841393d1e45b" dependencies = [ "base64", "cosmwasm-crypto", "cosmwasm-derive", + "derivative", "forward_ref", "schemars", "serde", @@ -216,9 +237,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.0.0" +version = "1.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d18403b07304d15d304dad11040d45bbcaf78d603b4be3fb5e2685c16f9229b5" +checksum = "9cf3cd03affeaea2e250f431024fff6cee96f1e9c0f79b4202cb6554c917ba00" dependencies = [ "cosmwasm-std", "serde", @@ -226,18 +247,18 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "dc948ebb96241bb40ab73effeb80d9f93afaad49359d159a5e61be51619fe813" dependencies = [ "libc", ] [[package]] name = "criterion" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" +checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" dependencies = [ "atty", "cast", @@ -261,9 +282,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" +checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" dependencies = [ "cast", "itertools", @@ -271,9 +292,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ "cfg-if", "crossbeam-utils", @@ -281,9 +302,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -292,26 +313,26 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.8" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", "memoffset", + "once_cell", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" dependencies = [ "cfg-if", - "lazy_static", + "once_cell", ] [[package]] @@ -322,9 +343,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.3.2" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +checksum = "9f2b443d17d49dad5ef0ede301c3179cc923b8822f3393b4d2c28c269dd4a122" dependencies = [ "generic-array", "rand_core 0.6.3", @@ -333,13 +354,13 @@ dependencies = [ ] [[package]] -name = "crypto-mac" -version = "0.11.1" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "subtle", + "typenum", ] [[package]] @@ -371,7 +392,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", - "digest", + "digest 0.9.0", "rand_core 0.5.1", "subtle", "zeroize", @@ -381,6 +402,7 @@ dependencies = [ name = "cw-controllers" version = "0.14.0" dependencies = [ + "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", "cw-utils", @@ -432,6 +454,7 @@ dependencies = [ name = "cw-utils" version = "0.14.0" dependencies = [ + "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", "cw2", @@ -537,6 +560,7 @@ dependencies = [ name = "cw2" version = "0.14.0" dependencies = [ + "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", "schemars", @@ -682,11 +706,12 @@ dependencies = [ [[package]] name = "der" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" dependencies = [ "const-oid", + "zeroize", ] [[package]] @@ -709,17 +734,28 @@ dependencies = [ "generic-array", ] +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer 0.10.2", + "crypto-common", + "subtle", +] + [[package]] name = "dyn-clone" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" [[package]] name = "ecdsa" -version = "0.13.4" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +checksum = "e852f4174d2a8646a0fa8a34b55797856c722f86267deb0aa1e93f7f247f800e" dependencies = [ "der", "elliptic-curve", @@ -737,29 +773,31 @@ dependencies = [ "hex", "rand_core 0.6.3", "serde", - "sha2", + "sha2 0.9.9", "thiserror", "zeroize", ] [[package]] name = "either" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "elliptic-curve" -version = "0.11.12" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ "base16ct", "crypto-bigint", "der", + "digest 0.10.3", "ff", "generic-array", "group", + "pkcs8", "rand_core 0.6.3", "sec1", "subtle", @@ -768,9 +806,9 @@ dependencies = [ [[package]] name = "ff" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +checksum = "df689201f395c6b90dfe87127685f8dbfc083a5e779e613575d8bd7314300c3e" dependencies = [ "rand_core 0.6.3", "subtle", @@ -784,9 +822,9 @@ checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -805,26 +843,26 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "group" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +checksum = "7391856def869c1c81063a03457c676fbcd419709c3dfb33d8d319de484b154d" dependencies = [ "ff", "rand_core 0.6.3", @@ -854,12 +892,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "crypto-mac", - "digest", + "digest 0.10.3", ] [[package]] @@ -879,30 +916,29 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "js-sys" -version = "0.3.57" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.10.4" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" +checksum = "6db2573d3fd3e4cc741affc9b5ce1a8ce36cf29f09f80f36da4309d0ae6d7854" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sec1", - "sha2", + "sha2 0.10.2", ] [[package]] @@ -913,9 +949,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.125" +version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" +checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" [[package]] name = "log" @@ -943,9 +979,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" dependencies = [ "adler", ] @@ -971,13 +1007,19 @@ dependencies = [ [[package]] name = "object" -version = "0.28.4" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "memchr", ] +[[package]] +name = "once_cell" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" + [[package]] name = "oorandom" version = "11.1.3" @@ -992,20 +1034,19 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pkcs8" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ "der", "spki", - "zeroize", ] [[package]] name = "plotters" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +checksum = "716b4eeb6c4a1d3ecc956f75b43ec2e8e8ba80026413e70a3f41fd3313d3492b" dependencies = [ "num-traits", "plotters-backend", @@ -1016,15 +1057,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" dependencies = [ "plotters-backend", ] @@ -1037,9 +1078,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" dependencies = [ "unicode-ident", ] @@ -1069,9 +1110,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.18" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -1112,7 +1153,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", ] [[package]] @@ -1141,9 +1182,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.5" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "regex-syntax", ] @@ -1156,15 +1197,15 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "rfc6979" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +checksum = "88c86280f057430a52f4861551b092a01b419b8eacefc7c995eacb9dc132fe32" dependencies = [ "crypto-bigint", "hmac", @@ -1177,20 +1218,11 @@ version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "ryu" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "same-file" @@ -1203,9 +1235,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b5a3c80cea1ab61f4260238409510e814e38b4b563c06044edf91e7dc070e3" +checksum = "1847b767a3d62d95cbf3d8a9f0e421cf57a0d8aa4f411d4b16525afb0284d4ed" dependencies = [ "dyn-clone", "schemars_derive", @@ -1215,9 +1247,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ae4dce13e8614c46ac3c38ef1c0d668b101df6ac39817aebdaa26642ddae9b" +checksum = "af4d7e1b012cb3d9129567661a63755ea4b8a7386d339dc945ae187e403c6743" dependencies = [ "proc-macro2", "quote", @@ -1233,10 +1265,11 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "sec1" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ + "base16ct", "der", "generic-array", "pkcs8", @@ -1246,15 +1279,15 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.9" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" +checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" [[package]] name = "serde" -version = "1.0.137" +version = "1.0.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" dependencies = [ "serde_derive", ] @@ -1280,9 +1313,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" dependencies = [ "proc-macro2", "quote", @@ -1291,9 +1324,9 @@ dependencies = [ [[package]] name = "serde_derive_internals" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", @@ -1302,11 +1335,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" dependencies = [ - "itoa 1.0.2", + "itoa 1.0.3", "ryu", "serde", ] @@ -1317,28 +1350,39 @@ version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if", "cpufeatures", - "digest", + "digest 0.9.0", "opaque-debug", ] +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + [[package]] name = "signature" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +checksum = "f0ea32af43239f0d353a7dd75a22d94c329c8cdaafdcb4c1c1335aa10c298a4a" dependencies = [ - "digest", + "digest 0.10.3", "rand_core 0.6.3", ] [[package]] name = "spki" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" dependencies = [ "base64ct", "der", @@ -1358,9 +1402,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.96" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" dependencies = [ "proc-macro2", "quote", @@ -1378,18 +1422,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" dependencies = [ "proc-macro2", "quote", @@ -1426,9 +1470,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" [[package]] name = "unicode-width" @@ -1461,15 +1505,15 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.80" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" +checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1477,13 +1521,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.80" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" +checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", "syn", @@ -1492,9 +1536,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.80" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" +checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1502,9 +1546,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.80" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" +checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" dependencies = [ "proc-macro2", "quote", @@ -1515,15 +1559,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.80" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" +checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" [[package]] name = "web-sys" -version = "0.3.57" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" +checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1" dependencies = [ "js-sys", "wasm-bindgen", @@ -1562,6 +1606,6 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "zeroize" -version = "1.5.5" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/contracts/cw1-subkeys/Cargo.toml b/contracts/cw1-subkeys/Cargo.toml index 3db259ffa..560c6d88a 100644 --- a/contracts/cw1-subkeys/Cargo.toml +++ b/contracts/cw1-subkeys/Cargo.toml @@ -19,12 +19,12 @@ library = [] test-utils = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw1 = { path = "../../packages/cw1", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } cw1-whitelist = { path = "../cw1-whitelist", version = "0.14.0", features = ["library"] } -cosmwasm-std = { version = "1.0.0", features = ["staking"] } +cosmwasm-std = { version = "1.1.0-rc.1", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw1-subkeys/src/bin/schema.rs b/contracts/cw1-subkeys/src/bin/schema.rs index aba98a7fd..1616b5f58 100644 --- a/contracts/cw1-subkeys/src/bin/schema.rs +++ b/contracts/cw1-subkeys/src/bin/schema.rs @@ -1,22 +1,13 @@ -use std::env::current_dir; -use std::fs::create_dir_all; +use cosmwasm_schema::write_api; -use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for}; +use cw1_subkeys::msg::{ExecuteMsg, QueryMsg}; -use cw1_subkeys::msg::{AllAllowancesResponse, ExecuteMsg, QueryMsg}; -use cw1_subkeys::state::Allowance; -use cw1_whitelist::msg::{AdminListResponse, InstantiateMsg}; +use cw1_whitelist::msg::InstantiateMsg; 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_with_title(&schema_for!(ExecuteMsg), &out_dir, "ExecuteMsg"); - export_schema_with_title(&schema_for!(QueryMsg), &out_dir, "QueryMsg"); - export_schema(&schema_for!(Allowance), &out_dir); - export_schema(&schema_for!(AdminListResponse), &out_dir); - export_schema(&schema_for!(AllAllowancesResponse), &out_dir); + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } } diff --git a/contracts/cw1-subkeys/src/msg.rs b/contracts/cw1-subkeys/src/msg.rs index 3af6943ef..a3f17a0cf 100644 --- a/contracts/cw1-subkeys/src/msg.rs +++ b/contracts/cw1-subkeys/src/msg.rs @@ -1,14 +1,14 @@ use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; + use std::fmt; +use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Coin, CosmosMsg, Empty}; use cw_utils::{Expiration, NativeBalance}; use crate::state::Permissions; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg where T: Clone + fmt::Debug + PartialEq + JsonSchema, @@ -43,40 +43,41 @@ where }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg where T: Clone + fmt::Debug + PartialEq + JsonSchema, { /// Shows all admins and whether or not it is mutable - /// Returns cw1-whitelist::AdminListResponse + #[returns(cw1_whitelist::msg::AdminListResponse)] AdminList {}, /// Get the current allowance for the given subkey (how much it can spend) - /// Returns crate::state::Allowance + #[returns(crate::state::Allowance)] Allowance { spender: String }, /// Get the current permissions for the given subkey (how much it can spend) - /// Returns PermissionsInfo + #[returns(PermissionsInfo)] Permissions { spender: String }, /// Checks permissions of the caller on this proxy. /// If CanExecute returns true then a call to `Execute` with the same message, /// before any further state changes, should also succeed. + #[returns(cw1::CanExecuteResponse)] CanExecute { sender: String, msg: CosmosMsg }, /// Gets all Allowances for this contract - /// Returns AllAllowancesResponse + #[returns(AllAllowancesResponse)] AllAllowances { start_after: Option, limit: Option, }, /// Gets all Permissions for this contract - /// Returns AllPermissionsResponse + #[returns(AllPermissionsResponse)] AllPermissions { start_after: Option, limit: Option, }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct AllAllowancesResponse { pub allowances: Vec, } @@ -94,7 +95,7 @@ impl AllAllowancesResponse { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct AllowanceInfo { pub spender: String, pub balance: NativeBalance, @@ -114,7 +115,7 @@ impl AllowanceInfo { /// ``` /// # use cw_utils::{Expiration, NativeBalance}; /// # use cw1_subkeys::msg::AllowanceInfo; - /// # use cosmwasm_std::coin; + /// # use cosmwasm_schema::{cw_serde, QueryResponses};use cosmwasm_std::coin; /// /// let mut allows = vec![AllowanceInfo { /// spender: "spender2".to_owned(), @@ -143,7 +144,7 @@ impl AllowanceInfo { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct PermissionsInfo { pub spender: String, pub permissions: Permissions, @@ -183,7 +184,7 @@ impl PermissionsInfo { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct AllPermissionsResponse { pub permissions: Vec, } diff --git a/contracts/cw1-subkeys/src/state.rs b/contracts/cw1-subkeys/src/state.rs index 866e419eb..2b621ea4a 100644 --- a/contracts/cw1-subkeys/src/state.rs +++ b/contracts/cw1-subkeys/src/state.rs @@ -10,7 +10,7 @@ use cw_utils::{Expiration, NativeBalance}; // Could have implemented permissions for each cosmos module(StakingPermissions, GovPermissions etc...) // But that meant a lot of code for each module. Keeping the permissions inside one struct is more // optimal. Define other modules permissions here. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, Default, Copy)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default, Copy)] pub struct Permissions { pub delegate: bool, pub redelegate: bool, diff --git a/contracts/cw1-whitelist-ng/Cargo.toml b/contracts/cw1-whitelist-ng/Cargo.toml index 7ca6293cf..a452aa3b6 100644 --- a/contracts/cw1-whitelist-ng/Cargo.toml +++ b/contracts/cw1-whitelist-ng/Cargo.toml @@ -22,11 +22,11 @@ querier = ["library"] multitest = ["cw-multi-test", "anyhow"] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw1 = { path = "../../packages/cw1", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0", features = ["staking"] } +cosmwasm-std = { version = "1.1.0-rc.1", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw1-whitelist-ng/src/msg.rs b/contracts/cw1-whitelist-ng/src/msg.rs index 17fe069a5..9b8826caf 100644 --- a/contracts/cw1-whitelist-ng/src/msg.rs +++ b/contracts/cw1-whitelist-ng/src/msg.rs @@ -4,6 +4,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{ to_binary, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdError, }; @@ -31,8 +32,7 @@ impl InstantiateMsg { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Cw1ExecMsg { /// Execute requests the contract to re-dispatch all these messages with the /// contract's address as sender. Every implementation has it's own logic to @@ -40,8 +40,7 @@ pub enum Cw1ExecMsg { Execute { msgs: Vec> }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum WhitelistExecMsg { /// Freeze will make a mutable contract immutable, must be called by an admin Freeze {}, @@ -89,8 +88,7 @@ impl WhitelistExecMsg { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Cw1QueryMsg { /// Checks permissions of the caller on this proxy. /// If CanExecute returns true then a call to `Execute` with the same message, @@ -118,8 +116,7 @@ impl Cw1QueryMsg { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum WhitelistQueryMsg { /// Shows all admins and whether or not it is mutable AdminList {}, @@ -145,7 +142,7 @@ impl WhitelistQueryMsg { } } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct AdminListResponse { pub admins: Vec, pub mutable: bool, diff --git a/contracts/cw1-whitelist-ng/src/multitest/contract.rs b/contracts/cw1-whitelist-ng/src/multitest/contract.rs index 59a2063de..b14fcb354 100644 --- a/contracts/cw1-whitelist-ng/src/multitest/contract.rs +++ b/contracts/cw1-whitelist-ng/src/multitest/contract.rs @@ -54,7 +54,7 @@ where } } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[must_use] pub struct Cw1Executor<'a, App> { addr: Addr, @@ -87,7 +87,7 @@ impl<'a, App> Cw1Executor<'a, App> { } } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[must_use] pub struct WhitelistExecutor<'a, App> { addr: Addr, @@ -133,7 +133,7 @@ impl<'a, App> WhitelistExecutor<'a, App> { } } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] #[must_use] pub struct Instantiator<'a, App> { code_id: u64, @@ -185,7 +185,7 @@ impl<'a, App> Instantiator<'a, App> { } // Proxy for direct execution in multitest. -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub struct Cw1WhitelistProxy(Addr); impl Cw1WhitelistProxy { diff --git a/contracts/cw1-whitelist-ng/src/state.rs b/contracts/cw1-whitelist-ng/src/state.rs index af03b1529..336fdfdda 100644 --- a/contracts/cw1-whitelist-ng/src/state.rs +++ b/contracts/cw1-whitelist-ng/src/state.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::{Addr, Empty}; use cw_storage_plus::Item; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)] pub struct AdminList { pub admins: Vec, pub mutable: bool, diff --git a/contracts/cw1-whitelist/Cargo.toml b/contracts/cw1-whitelist/Cargo.toml index e64a7751c..2c2c57a03 100644 --- a/contracts/cw1-whitelist/Cargo.toml +++ b/contracts/cw1-whitelist/Cargo.toml @@ -19,11 +19,11 @@ library = [] test-utils = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw1 = { path = "../../packages/cw1", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0", features = ["staking"] } +cosmwasm-std = { version = "1.1.0-rc.1", features = ["staking"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw1-whitelist/src/bin/schema.rs b/contracts/cw1-whitelist/src/bin/schema.rs index 59dde62cc..e72e54623 100644 --- a/contracts/cw1-whitelist/src/bin/schema.rs +++ b/contracts/cw1-whitelist/src/bin/schema.rs @@ -1,18 +1,11 @@ -use std::env::current_dir; -use std::fs::create_dir_all; +use cosmwasm_schema::write_api; -use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for}; - -use cw1_whitelist::msg::{AdminListResponse, ExecuteMsg, InstantiateMsg, QueryMsg}; +use cw1_whitelist::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 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_with_title(&schema_for!(ExecuteMsg), &out_dir, "ExecuteMsg"); - export_schema_with_title(&schema_for!(QueryMsg), &out_dir, "QueryMsg"); - export_schema(&schema_for!(AdminListResponse), &out_dir); + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } } diff --git a/contracts/cw1-whitelist/src/msg.rs b/contracts/cw1-whitelist/src/msg.rs index bdfb6d2f5..16d7537b4 100644 --- a/contracts/cw1-whitelist/src/msg.rs +++ b/contracts/cw1-whitelist/src/msg.rs @@ -1,17 +1,17 @@ use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; + use std::fmt; +use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{CosmosMsg, Empty}; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct InstantiateMsg { pub admins: Vec, pub mutable: bool, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg where T: Clone + fmt::Debug + PartialEq + JsonSchema, @@ -27,21 +27,23 @@ where UpdateAdmins { admins: Vec }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg where T: Clone + fmt::Debug + PartialEq + JsonSchema, { /// Shows all admins and whether or not it is mutable + #[returns(AdminListResponse)] AdminList {}, /// Checks permissions of the caller on this proxy. /// If CanExecute returns true then a call to `Execute` with the same message, /// before any further state changes, should also succeed. + #[returns(cw1::CanExecuteResponse)] CanExecute { sender: String, msg: CosmosMsg }, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct AdminListResponse { pub admins: Vec, pub mutable: bool, diff --git a/contracts/cw1-whitelist/src/state.rs b/contracts/cw1-whitelist/src/state.rs index 9d3ec6d17..4b6f31ce5 100644 --- a/contracts/cw1-whitelist/src/state.rs +++ b/contracts/cw1-whitelist/src/state.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use cosmwasm_std::Addr; use cw_storage_plus::Item; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)] pub struct AdminList { pub admins: Vec, pub mutable: bool, diff --git a/contracts/cw1155-base/Cargo.toml b/contracts/cw1155-base/Cargo.toml index 44b19e703..4daed8a0f 100644 --- a/contracts/cw1155-base/Cargo.toml +++ b/contracts/cw1155-base/Cargo.toml @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } cw1155 = { path = "../../packages/cw1155", version = "0.14.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-std = { version = "1.1.0-rc.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } diff --git a/contracts/cw1155-base/src/bin/schema.rs b/contracts/cw1155-base/src/bin/schema.rs index 3fc9e8d63..a4c4d13d2 100644 --- a/contracts/cw1155-base/src/bin/schema.rs +++ b/contracts/cw1155-base/src/bin/schema.rs @@ -1,30 +1,12 @@ -use std::env::current_dir; -use std::fs::create_dir_all; +use cosmwasm_schema::write_api; -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw1155::{ - ApprovedForAllResponse, BalanceResponse, BatchBalanceResponse, Cw1155BatchReceiveMsg, - Cw1155ExecuteMsg, Cw1155QueryMsg, Cw1155ReceiveMsg, IsApprovedForAllResponse, - TokenInfoResponse, TokensResponse, -}; +use cw1155::{Cw1155ExecuteMsg, Cw1155QueryMsg}; use cw1155_base::msg::InstantiateMsg; 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!(Cw1155ExecuteMsg), &out_dir); - export_schema(&schema_for!(Cw1155QueryMsg), &out_dir); - export_schema(&schema_for!(Cw1155ReceiveMsg), &out_dir); - export_schema(&schema_for!(Cw1155BatchReceiveMsg), &out_dir); - export_schema(&schema_for!(BalanceResponse), &out_dir); - export_schema(&schema_for!(BatchBalanceResponse), &out_dir); - export_schema(&schema_for!(ApprovedForAllResponse), &out_dir); - export_schema(&schema_for!(IsApprovedForAllResponse), &out_dir); - export_schema(&schema_for!(TokenInfoResponse), &out_dir); - export_schema(&schema_for!(TokensResponse), &out_dir); + write_api! { + instantiate: InstantiateMsg, + execute: Cw1155ExecuteMsg, + query: Cw1155QueryMsg, + } } diff --git a/contracts/cw1155-base/src/msg.rs b/contracts/cw1155-base/src/msg.rs index 4962c81c0..07e718d5b 100644 --- a/contracts/cw1155-base/src/msg.rs +++ b/contracts/cw1155-base/src/msg.rs @@ -1,7 +1,6 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct InstantiateMsg { /// The minter is the only one who can create new tokens. /// This is designed for a base token platform that is controlled by an external program or diff --git a/contracts/cw20-base/Cargo.toml b/contracts/cw20-base/Cargo.toml index ee071fd12..08ba32a88 100644 --- a/contracts/cw20-base/Cargo.toml +++ b/contracts/cw20-base/Cargo.toml @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } cw20 = { path = "../../packages/cw20", version = "0.14.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-std = { version = "1.1.0-rc.1" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/cw20-base/src/bin/schema.rs b/contracts/cw20-base/src/bin/schema.rs index e715901a6..40d16fd4f 100644 --- a/contracts/cw20-base/src/bin/schema.rs +++ b/contracts/cw20-base/src/bin/schema.rs @@ -1,27 +1,11 @@ -use std::env::current_dir; -use std::fs::create_dir_all; +use cosmwasm_schema::write_api; -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw20::{ - AllAccountsResponse, AllAllowancesResponse, AllSpenderAllowancesResponse, AllowanceResponse, - BalanceResponse, TokenInfoResponse, -}; use cw20_base::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 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!(QueryMsg), &out_dir); - export_schema(&schema_for!(AllowanceResponse), &out_dir); - export_schema(&schema_for!(BalanceResponse), &out_dir); - export_schema(&schema_for!(TokenInfoResponse), &out_dir); - export_schema(&schema_for!(AllAllowancesResponse), &out_dir); - export_schema(&schema_for!(AllSpenderAllowancesResponse), &out_dir); - export_schema(&schema_for!(AllAccountsResponse), &out_dir); + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } } diff --git a/contracts/cw20-base/src/msg.rs b/contracts/cw20-base/src/msg.rs index 27f3a5b52..208871255 100644 --- a/contracts/cw20-base/src/msg.rs +++ b/contracts/cw20-base/src/msg.rs @@ -1,3 +1,4 @@ +use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{StdError, StdResult, Uint128}; use cw20::{Cw20Coin, Logo, MinterResponse}; use schemars::JsonSchema; @@ -5,7 +6,7 @@ use serde::{Deserialize, Serialize}; pub use cw20::Cw20ExecuteMsg as ExecuteMsg; -#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, PartialEq)] +#[cw_serde] pub struct InstantiateMarketingInfo { pub project: Option, pub description: Option, @@ -13,7 +14,7 @@ pub struct InstantiateMarketingInfo { pub logo: Option, } -#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, PartialEq)] +#[cw_serde] #[cfg_attr(test, derive(Default))] pub struct InstantiateMsg { pub name: String, @@ -69,26 +70,26 @@ impl InstantiateMsg { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg { /// Returns the current balance of the given address, 0 if unset. - /// Return type: BalanceResponse. + #[returns(cw20::BalanceResponse)] Balance { address: String }, /// Returns metadata on the contract - name, decimals, supply, etc. - /// Return type: TokenInfoResponse. + #[returns(cw20::TokenInfoResponse)] TokenInfo {}, /// Only with "mintable" extension. /// Returns who can mint and the hard cap on maximum tokens after minting. - /// Return type: MinterResponse. + #[returns(cw20::MinterResponse)] Minter {}, /// Only with "allowance" extension. /// Returns how much spender can use from owner account, 0 if unset. - /// Return type: AllowanceResponse. + #[returns(cw20::AllowanceResponse)] Allowance { owner: String, spender: String }, /// Only with "enumerable" extension (and "allowances") /// Returns all allowances this owner has approved. Supports pagination. - /// Return type: AllAllowancesResponse. + #[returns(cw20::AllAllowancesResponse)] AllAllowances { owner: String, start_after: Option, @@ -96,7 +97,7 @@ pub enum QueryMsg { }, /// Only with "enumerable" extension (and "allowances") /// Returns all allowances this spender has been granted. Supports pagination. - /// Return type: AllSpenderAllowancesResponse. + #[returns(cw20::AllSpenderAllowancesResponse)] AllSpenderAllowances { spender: String, start_after: Option, @@ -104,7 +105,7 @@ pub enum QueryMsg { }, /// Only with "enumerable" extension /// Returns all accounts that have balances. Supports pagination. - /// Return type: AllAccountsResponse. + #[returns(cw20::AllAccountsResponse)] AllAccounts { start_after: Option, limit: Option, @@ -112,12 +113,12 @@ pub enum QueryMsg { /// Only with "marketing" extension /// Returns more metadata on the contract to display in the client: /// - description, logo, project url, etc. - /// Return type: MarketingInfoResponse + #[returns(cw20::MarketingInfoResponse)] MarketingInfo {}, /// Only with "marketing" extension /// Downloads the embedded logo data (if stored on chain). Errors if no logo data is stored for this /// contract. - /// Return type: DownloadLogoResponse. + #[returns(cw20::DownloadLogoResponse)] DownloadLogo {}, } diff --git a/contracts/cw20-base/src/state.rs b/contracts/cw20-base/src/state.rs index 5202b4911..dc02c6f19 100644 --- a/contracts/cw20-base/src/state.rs +++ b/contracts/cw20-base/src/state.rs @@ -1,13 +1,10 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Uint128}; use cw_storage_plus::{Item, Map}; use cw20::{AllowanceResponse, Logo, MarketingInfoResponse}; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub struct TokenInfo { pub name: String, pub symbol: String, @@ -16,7 +13,7 @@ pub struct TokenInfo { pub mint: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct MinterData { pub minter: Addr, /// cap is how many more tokens can be issued by the minter diff --git a/contracts/cw20-ics20/Cargo.toml b/contracts/cw20-ics20/Cargo.toml index a143085fa..cfcaae353 100644 --- a/contracts/cw20-ics20/Cargo.toml +++ b/contracts/cw20-ics20/Cargo.toml @@ -18,11 +18,11 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } cw20 = { path = "../../packages/cw20", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0", features = ["stargate"] } +cosmwasm-std = { version = "1.1.0-rc.1", features = ["stargate"] } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } cw-controllers = { path = "../../packages/controllers", version = "0.14.0" } schemars = "0.8.1" diff --git a/contracts/cw20-ics20/src/amount.rs b/contracts/cw20-ics20/src/amount.rs index f9e8dd532..a0c42d9f8 100644 --- a/contracts/cw20-ics20/src/amount.rs +++ b/contracts/cw20-ics20/src/amount.rs @@ -1,13 +1,10 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - use crate::error::ContractError; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Coin, Uint128}; use cw20::Cw20Coin; use std::convert::TryInto; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Amount { Native(Coin), // FIXME? USe Cw20CoinVerified, and validate cw20 addresses diff --git a/contracts/cw20-ics20/src/bin/schema.rs b/contracts/cw20-ics20/src/bin/schema.rs index fb3b116a2..55c982ad0 100644 --- a/contracts/cw20-ics20/src/bin/schema.rs +++ b/contracts/cw20-ics20/src/bin/schema.rs @@ -1,23 +1,11 @@ -use std::env::current_dir; -use std::fs::create_dir_all; +use cosmwasm_schema::write_api; -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; - -use cw20_ics20::msg::{ - ChannelResponse, ExecuteMsg, InitMsg, ListChannelsResponse, PortResponse, QueryMsg, TransferMsg, -}; +use cw20_ics20::msg::{ExecuteMsg, InitMsg, QueryMsg}; 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!(InitMsg), &out_dir); - export_schema(&schema_for!(ExecuteMsg), &out_dir); - export_schema(&schema_for!(QueryMsg), &out_dir); - export_schema(&schema_for!(TransferMsg), &out_dir); - export_schema(&schema_for!(ChannelResponse), &out_dir); - export_schema(&schema_for!(ListChannelsResponse), &out_dir); - export_schema(&schema_for!(PortResponse), &out_dir); + write_api! { + instantiate: InitMsg, + execute: ExecuteMsg, + query: QueryMsg, + } } diff --git a/contracts/cw20-ics20/src/ibc.rs b/contracts/cw20-ics20/src/ibc.rs index f5f2dc213..74f77581c 100644 --- a/contracts/cw20-ics20/src/ibc.rs +++ b/contracts/cw20-ics20/src/ibc.rs @@ -1,6 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{ attr, entry_point, from_binary, to_binary, BankMsg, Binary, CosmosMsg, Deps, DepsMut, Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, @@ -22,7 +23,7 @@ pub const ICS20_ORDERING: IbcOrder = IbcOrder::Unordered; /// The format for sending an ics20 packet. /// Proto defined here: https://github.com/cosmos/cosmos-sdk/blob/v0.42.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20 /// This is compatible with the JSON serialization -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)] pub struct Ics20Packet { /// amount of tokens to transfer is encoded as a string, but limited to u64 max pub amount: Uint128, @@ -56,8 +57,7 @@ impl Ics20Packet { /// This is a generic ICS acknowledgement format. /// Proto defined here: https://github.com/cosmos/cosmos-sdk/blob/v0.42.0/proto/ibc/core/channel/v1/channel.proto#L141-L147 /// This is compatible with the JSON serialization -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Ics20Ack { Result(Binary), Error(String), diff --git a/contracts/cw20-ics20/src/migrations.rs b/contracts/cw20-ics20/src/migrations.rs index 8c67b6b49..3ff2fe09f 100644 --- a/contracts/cw20-ics20/src/migrations.rs +++ b/contracts/cw20-ics20/src/migrations.rs @@ -1,12 +1,11 @@ // v1 format is anything older than 0.12.0 pub mod v1 { - use schemars::JsonSchema; - use serde::{Deserialize, Serialize}; + use cosmwasm_schema::cw_serde; use cosmwasm_std::Addr; use cw_storage_plus::Item; - #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] + #[cw_serde] pub struct Config { pub default_timeout: u64, pub gov_contract: Addr, diff --git a/contracts/cw20-ics20/src/msg.rs b/contracts/cw20-ics20/src/msg.rs index 6cb68ccbe..c137a8149 100644 --- a/contracts/cw20-ics20/src/msg.rs +++ b/contracts/cw20-ics20/src/msg.rs @@ -1,12 +1,10 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::{cw_serde, QueryResponses}; use cw20::Cw20ReceiveMsg; use crate::amount::Amount; use crate::state::ChannelInfo; -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)] +#[cw_serde] pub struct InitMsg { /// Default timeout for ics20 packets, specified in seconds pub default_timeout: u64, @@ -19,19 +17,18 @@ pub struct InitMsg { pub default_gas_limit: Option, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct AllowMsg { pub contract: String, pub gas_limit: Option, } -#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)] +#[cw_serde] pub struct MigrateMsg { pub default_gas_limit: Option, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg { /// This accepts a properly-encoded ReceiveMsg from a cw20 contract Receive(Cw20ReceiveMsg), @@ -44,7 +41,7 @@ pub enum ExecuteMsg { } /// This is the message we accept via Receive -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct TransferMsg { /// The local channel to send the packets on pub channel: String, @@ -56,35 +53,40 @@ pub struct TransferMsg { pub timeout: Option, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg { - /// Return the port ID bound by this contract. Returns PortResponse + /// Return the port ID bound by this contract. + #[returns(PortResponse)] Port {}, - /// Show all channels we have connected to. Return type is ListChannelsResponse. + /// Show all channels we have connected to. + #[returns(ListChannelsResponse)] ListChannels {}, /// Returns the details of the name channel, error if not created. - /// Return type: ChannelResponse. + #[returns(ChannelResponse)] Channel { id: String }, - /// Show the Config. Returns ConfigResponse (currently including admin as well) + /// Show the Config. + #[returns(ConfigResponse)] Config {}, - /// Return AdminResponse + #[returns(cw_controllers::AdminResponse)] Admin {}, - /// Query if a given cw20 contract is allowed. Returns AllowedResponse + /// Query if a given cw20 contract is allowed. + #[returns(AllowedResponse)] Allowed { contract: String }, - /// List all allowed cw20 contracts. Returns ListAllowedResponse + /// List all allowed cw20 contracts. + #[returns(ListAllowedResponse)] ListAllowed { start_after: Option, limit: Option, }, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ListChannelsResponse { pub channels: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ChannelResponse { /// Information on the channel's connection pub info: ChannelInfo, @@ -95,30 +97,30 @@ pub struct ChannelResponse { pub total_sent: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct PortResponse { pub port_id: String, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ConfigResponse { pub default_timeout: u64, pub default_gas_limit: Option, pub gov_contract: String, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct AllowedResponse { pub is_allowed: bool, pub gas_limit: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ListAllowedResponse { pub allow: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct AllowedInfo { pub contract: String, pub gas_limit: Option, diff --git a/contracts/cw20-ics20/src/state.rs b/contracts/cw20-ics20/src/state.rs index 57cbe0a0a..19e05a482 100644 --- a/contracts/cw20-ics20/src/state.rs +++ b/contracts/cw20-ics20/src/state.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, IbcEndpoint, StdResult, Storage, Uint128}; use cw_controllers::Admin; use cw_storage_plus::{Item, Map}; @@ -23,19 +21,20 @@ pub const CHANNEL_STATE: Map<(&str, &str), ChannelState> = Map::new("channel_sta /// Every cw20 contract we allow to be sent is stored here, possibly with a gas_limit pub const ALLOW_LIST: Map<&Addr, AllowInfo> = Map::new("allow_list"); -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[cw_serde] +#[derive(Default)] pub struct ChannelState { pub outstanding: Uint128, pub total_sent: Uint128, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Config { pub default_timeout: u64, pub default_gas_limit: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ChannelInfo { /// id of this channel pub id: String, @@ -45,12 +44,12 @@ pub struct ChannelInfo { pub connection_id: String, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct AllowInfo { pub gas_limit: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ReplyArgs { pub channel: String, pub denom: String, diff --git a/contracts/cw3-fixed-multisig/Cargo.toml b/contracts/cw3-fixed-multisig/Cargo.toml index 6c0a6928a..db016d6ab 100644 --- a/contracts/cw3-fixed-multisig/Cargo.toml +++ b/contracts/cw3-fixed-multisig/Cargo.toml @@ -18,12 +18,12 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } cw3 = { path = "../../packages/cw3", version = "0.14.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-std = { version = "1.1.0-rc.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw3-fixed-multisig/src/bin/schema.rs b/contracts/cw3-fixed-multisig/src/bin/schema.rs index acbce1f87..80810258f 100644 --- a/contracts/cw3-fixed-multisig/src/bin/schema.rs +++ b/contracts/cw3-fixed-multisig/src/bin/schema.rs @@ -1,17 +1,11 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for}; +use cosmwasm_schema::write_api; use cw3_fixed_multisig::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 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_with_title(&schema_for!(ExecuteMsg), &out_dir, "ExecuteMsg"); - export_schema_with_title(&schema_for!(QueryMsg), &out_dir, "QueryMsg"); + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } } diff --git a/contracts/cw3-fixed-multisig/src/msg.rs b/contracts/cw3-fixed-multisig/src/msg.rs index 18ed4eedd..c21908c33 100644 --- a/contracts/cw3-fixed-multisig/src/msg.rs +++ b/contracts/cw3-fixed-multisig/src/msg.rs @@ -1,26 +1,23 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{CosmosMsg, Empty}; use cw3::Vote; use cw_utils::{Duration, Expiration, Threshold}; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct InstantiateMsg { pub voters: Vec, pub threshold: Threshold, pub max_voting_period: Duration, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Voter { pub addr: String, pub weight: u64, } // TODO: add some T variants? Maybe good enough as fixed Empty for now -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg { Propose { title: String, @@ -42,34 +39,34 @@ pub enum ExecuteMsg { } // We can also add this as a cw3 extension -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg { - /// Return ThresholdResponse + #[returns(cw_utils::ThresholdResponse)] Threshold {}, - /// Returns ProposalResponse + #[returns(cw3::ProposalResponse)] Proposal { proposal_id: u64 }, - /// Returns ProposalListResponse + #[returns(cw3::ProposalListResponse)] ListProposals { start_after: Option, limit: Option, }, - /// Returns ProposalListResponse + #[returns(cw3::ProposalListResponse)] ReverseProposals { start_before: Option, limit: Option, }, - /// Returns VoteResponse + #[returns(cw3::VoteResponse)] Vote { proposal_id: u64, voter: String }, - /// Returns VoteListResponse + #[returns(cw3::VoteListResponse)] ListVotes { proposal_id: u64, start_after: Option, limit: Option, }, - /// Returns VoterInfo + #[returns(cw3::VoterResponse)] Voter { address: String }, - /// Returns VoterListResponse + #[returns(cw3::VoterListResponse)] ListVoters { start_after: Option, limit: Option, diff --git a/contracts/cw3-fixed-multisig/src/state.rs b/contracts/cw3-fixed-multisig/src/state.rs index 11d49daf1..d0c7914b8 100644 --- a/contracts/cw3-fixed-multisig/src/state.rs +++ b/contracts/cw3-fixed-multisig/src/state.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, BlockInfo, CosmosMsg, Decimal, Empty, StdResult, Storage, Uint128}; use cw3::{Status, Vote}; @@ -11,14 +9,14 @@ use cw_utils::{Duration, Expiration, Threshold}; // Note: `10u128.pow(9)` fails as "u128::pow` is not yet stable as a const fn" const PRECISION_FACTOR: u128 = 1_000_000_000; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Config { pub threshold: Threshold, pub total_weight: u64, pub max_voting_period: Duration, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Proposal { pub title: String, pub description: String, @@ -126,7 +124,7 @@ impl Proposal { } // weight of votes for each option -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Votes { pub yes: u64, pub no: u64, @@ -170,7 +168,7 @@ fn votes_needed(weight: u64, percentage: Decimal) -> u64 { // we cast a ballot with our chosen vote and a given weight // stored under the key that voted -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Ballot { pub weight: u64, pub vote: Vote, diff --git a/contracts/cw3-flex-multisig/Cargo.toml b/contracts/cw3-flex-multisig/Cargo.toml index 2db50dd24..9eb2303ac 100644 --- a/contracts/cw3-flex-multisig/Cargo.toml +++ b/contracts/cw3-flex-multisig/Cargo.toml @@ -18,14 +18,14 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } cw3 = { path = "../../packages/cw3", version = "0.14.0" } cw3-fixed-multisig = { path = "../cw3-fixed-multisig", version = "0.14.0", features = ["library"] } cw4 = { path = "../../packages/cw4", version = "0.14.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-std = { version = "1.1.0-rc.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw3-flex-multisig/src/bin/schema.rs b/contracts/cw3-flex-multisig/src/bin/schema.rs index dd4e52de2..e14159759 100644 --- a/contracts/cw3-flex-multisig/src/bin/schema.rs +++ b/contracts/cw3-flex-multisig/src/bin/schema.rs @@ -1,17 +1,11 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for}; +use cosmwasm_schema::write_api; use cw3_flex_multisig::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 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_with_title(&schema_for!(ExecuteMsg), &out_dir, "ExecuteMsg"); - export_schema_with_title(&schema_for!(QueryMsg), &out_dir, "QueryMsg"); + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } } diff --git a/contracts/cw3-flex-multisig/src/msg.rs b/contracts/cw3-flex-multisig/src/msg.rs index 99437b26b..f91e8abff 100644 --- a/contracts/cw3-flex-multisig/src/msg.rs +++ b/contracts/cw3-flex-multisig/src/msg.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{CosmosMsg, Empty}; use cw3::Vote; use cw4::MemberChangedHookMsg; @@ -8,7 +6,7 @@ use cw_utils::{Duration, Expiration, Threshold}; use crate::state::Executor; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct InstantiateMsg { // this is the group contract that contains the member list pub group_addr: String, @@ -20,8 +18,7 @@ pub struct InstantiateMsg { } // TODO: add some T variants? Maybe good enough as fixed Empty for now -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg { Propose { title: String, @@ -45,34 +42,34 @@ pub enum ExecuteMsg { } // We can also add this as a cw3 extension -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg { - /// Return ThresholdResponse + #[returns(cw_utils::ThresholdResponse)] Threshold {}, - /// Returns ProposalResponse + #[returns(cw3::ProposalResponse)] Proposal { proposal_id: u64 }, - /// Returns ProposalListResponse + #[returns(cw3::ProposalListResponse)] ListProposals { start_after: Option, limit: Option, }, - /// Returns ProposalListResponse + #[returns(cw3::ProposalListResponse)] ReverseProposals { start_before: Option, limit: Option, }, - /// Returns VoteResponse + #[returns(cw3::VoteResponse)] Vote { proposal_id: u64, voter: String }, - /// Returns VoteListResponse + #[returns(cw3::VoteListResponse)] ListVotes { proposal_id: u64, start_after: Option, limit: Option, }, - /// Returns VoterInfo + #[returns(cw3::VoterResponse)] Voter { address: String }, - /// Returns VoterListResponse + #[returns(cw3::VoterListResponse)] ListVoters { start_after: Option, limit: Option, diff --git a/contracts/cw3-flex-multisig/src/state.rs b/contracts/cw3-flex-multisig/src/state.rs index a1e388777..e6dc06bd8 100644 --- a/contracts/cw3-flex-multisig/src/state.rs +++ b/contracts/cw3-flex-multisig/src/state.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, QuerierWrapper}; use cw4::Cw4Contract; use cw_storage_plus::Item; @@ -9,7 +7,7 @@ use cw_utils::{Duration, Threshold}; use crate::error::ContractError; /// Defines who is able to execute proposals once passed -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub enum Executor { /// Any member of the voting group, even with 0 points Member, @@ -17,7 +15,7 @@ pub enum Executor { Only(Addr), } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Config { pub threshold: Threshold, pub max_voting_period: Duration, diff --git a/contracts/cw4-group/Cargo.toml b/contracts/cw4-group/Cargo.toml index 125e23477..a23768a9c 100644 --- a/contracts/cw4-group/Cargo.toml +++ b/contracts/cw4-group/Cargo.toml @@ -26,13 +26,13 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } cw4 = { path = "../../packages/cw4", version = "0.14.0" } cw-controllers = { path = "../../packages/controllers", version = "0.14.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-std = { version = "1.1.0-rc.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw4-group/src/bin/schema.rs b/contracts/cw4-group/src/bin/schema.rs index 01cdd1675..20fdf9b16 100644 --- a/contracts/cw4-group/src/bin/schema.rs +++ b/contracts/cw4-group/src/bin/schema.rs @@ -1,22 +1,12 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for}; +use cosmwasm_schema::write_api; pub use cw4::{AdminResponse, MemberListResponse, MemberResponse, TotalWeightResponse}; pub use cw4_group::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 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_with_title(&schema_for!(InstantiateMsg), &out_dir, "InstantiateMsg"); - export_schema_with_title(&schema_for!(ExecuteMsg), &out_dir, "ExecuteMsg"); - export_schema_with_title(&schema_for!(QueryMsg), &out_dir, "QueryMsg"); - export_schema(&schema_for!(AdminResponse), &out_dir); - export_schema(&schema_for!(MemberListResponse), &out_dir); - export_schema(&schema_for!(MemberResponse), &out_dir); - export_schema(&schema_for!(TotalWeightResponse), &out_dir); + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } } diff --git a/contracts/cw4-group/src/helpers.rs b/contracts/cw4-group/src/helpers.rs index add7451a4..b7719d90b 100644 --- a/contracts/cw4-group/src/helpers.rs +++ b/contracts/cw4-group/src/helpers.rs @@ -1,7 +1,6 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; use std::ops::Deref; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg}; use cw4::{Cw4Contract, Member}; @@ -11,7 +10,7 @@ use crate::msg::ExecuteMsg; /// for working with cw4-group contracts. /// /// It extends Cw4Contract to add the extra calls from cw4-group. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Cw4GroupContract(pub Cw4Contract); impl Deref for Cw4GroupContract { diff --git a/contracts/cw4-group/src/msg.rs b/contracts/cw4-group/src/msg.rs index e1759ac54..823359ed2 100644 --- a/contracts/cw4-group/src/msg.rs +++ b/contracts/cw4-group/src/msg.rs @@ -1,10 +1,7 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::{cw_serde, QueryResponses}; use cw4::Member; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub struct InstantiateMsg { /// The admin is the only account that can update the group state. /// Omit it to make the group immutable. @@ -12,8 +9,7 @@ pub struct InstantiateMsg { pub members: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg { /// Change the admin UpdateAdmin { admin: Option }, @@ -29,23 +25,24 @@ pub enum ExecuteMsg { RemoveHook { addr: String }, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg { - /// Return AdminResponse + #[returns(cw_controllers::AdminResponse)] Admin {}, - /// Return TotalWeightResponse + #[returns(cw4::TotalWeightResponse)] TotalWeight {}, - /// Returns MembersListResponse + #[returns(cw4::MemberListResponse)] ListMembers { start_after: Option, limit: Option, }, - /// Returns MemberResponse + #[returns(cw4::MemberResponse)] Member { addr: String, at_height: Option, }, - /// Shows all registered hooks. Returns HooksResponse. + /// Shows all registered hooks. + #[returns(cw_controllers::HooksResponse)] Hooks {}, } diff --git a/contracts/cw4-stake/Cargo.toml b/contracts/cw4-stake/Cargo.toml index 188d9cda6..e7ce93bde 100644 --- a/contracts/cw4-stake/Cargo.toml +++ b/contracts/cw4-stake/Cargo.toml @@ -26,14 +26,14 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-schema = { version = "1.0.0" } +cosmwasm-schema = { version = "1.1.0-rc.1" } cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw2 = { path = "../../packages/cw2", version = "0.14.0" } cw4 = { path = "../../packages/cw4", version = "0.14.0" } cw20 = { path = "../../packages/cw20", version = "0.14.0" } cw-controllers = { path = "../../packages/controllers", version = "0.14.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-std = { version = "1.1.0-rc.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.23" } diff --git a/contracts/cw4-stake/src/bin/schema.rs b/contracts/cw4-stake/src/bin/schema.rs index 891f94d7a..b6d3f29ba 100644 --- a/contracts/cw4-stake/src/bin/schema.rs +++ b/contracts/cw4-stake/src/bin/schema.rs @@ -1,7 +1,4 @@ -use std::env::current_dir; -use std::fs::create_dir_all; - -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; +use cosmwasm_schema::write_api; pub use cw4::{AdminResponse, MemberListResponse, MemberResponse, TotalWeightResponse}; pub use cw4_stake::msg::{ @@ -9,20 +6,9 @@ pub use cw4_stake::msg::{ }; 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!(QueryMsg), &out_dir); - export_schema(&schema_for!(ReceiveMsg), &out_dir); - - export_schema(&schema_for!(AdminResponse), &out_dir); - export_schema(&schema_for!(MemberListResponse), &out_dir); - export_schema(&schema_for!(MemberResponse), &out_dir); - export_schema(&schema_for!(TotalWeightResponse), &out_dir); - export_schema(&schema_for!(ClaimsResponse), &out_dir); - export_schema(&schema_for!(StakedResponse), &out_dir); + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } } diff --git a/contracts/cw4-stake/src/contract.rs b/contracts/cw4-stake/src/contract.rs index 6b51897b5..408f3265c 100644 --- a/contracts/cw4-stake/src/contract.rs +++ b/contracts/cw4-stake/src/contract.rs @@ -524,13 +524,13 @@ mod tests { // this tests the member queries fn assert_stake(deps: Deps, user1_stake: u128, user2_stake: u128, user3_stake: u128) { let stake1 = query_staked(deps, USER1.into()).unwrap(); - assert_eq!(stake1.stake, user1_stake.into()); + assert_eq!(stake1.stake, Uint128::from(user1_stake)); let stake2 = query_staked(deps, USER2.into()).unwrap(); - assert_eq!(stake2.stake, user2_stake.into()); + assert_eq!(stake2.stake, Uint128::from(user2_stake)); let stake3 = query_staked(deps, USER3.into()).unwrap(); - assert_eq!(stake3.stake, user3_stake.into()); + assert_eq!(stake3.stake, Uint128::from(user3_stake)); } #[test] diff --git a/contracts/cw4-stake/src/msg.rs b/contracts/cw4-stake/src/msg.rs index 29e81f595..e1bcc7a5a 100644 --- a/contracts/cw4-stake/src/msg.rs +++ b/contracts/cw4-stake/src/msg.rs @@ -1,12 +1,11 @@ +use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::Uint128; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; use cw20::{Cw20ReceiveMsg, Denom}; pub use cw_controllers::ClaimsResponse; use cw_utils::Duration; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct InstantiateMsg { /// denom of the token to stake pub denom: Denom, @@ -18,8 +17,7 @@ pub struct InstantiateMsg { pub admin: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg { /// Bond will bond all staking tokens sent with the message and update membership weight Bond {}, @@ -42,44 +40,42 @@ pub enum ExecuteMsg { Receive(Cw20ReceiveMsg), } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ReceiveMsg { /// Only valid cw20 message is to bond the tokens Bond {}, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg { /// Claims shows the tokens in process of unbonding for this address - Claims { - address: String, - }, + #[returns(cw_controllers::ClaimsResponse)] + Claims { address: String }, // Show the number of tokens currently staked by this address. - Staked { - address: String, - }, + #[returns(StakedResponse)] + Staked { address: String }, - /// Return AdminResponse + #[returns(cw_controllers::AdminResponse)] Admin {}, - /// Return TotalWeightResponse + #[returns(cw4::TotalWeightResponse)] TotalWeight {}, - /// Returns MembersListResponse + #[returns(cw4::MemberListResponse)] ListMembers { start_after: Option, limit: Option, }, - /// Returns MemberResponse + #[returns(cw4::MemberResponse)] Member { addr: String, at_height: Option, }, - /// Shows all registered hooks. Returns HooksResponse. + /// Shows all registered hooks. + #[returns(cw_controllers::HooksResponse)] Hooks {}, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct StakedResponse { pub stake: Uint128, pub denom: Denom, diff --git a/contracts/cw4-stake/src/state.rs b/contracts/cw4-stake/src/state.rs index d8c69f98b..b27f969eb 100644 --- a/contracts/cw4-stake/src/state.rs +++ b/contracts/cw4-stake/src/state.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Uint128}; use cw20::Denom; use cw4::TOTAL_KEY; @@ -10,7 +8,7 @@ use cw_utils::Duration; pub const CLAIMS: Claims = Claims::new("claims"); -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Config { /// denom of the token to stake pub denom: Denom, diff --git a/packages/controllers/Cargo.toml b/packages/controllers/Cargo.toml index 56759d389..03feddadd 100644 --- a/packages/controllers/Cargo.toml +++ b/packages/controllers/Cargo.toml @@ -11,7 +11,8 @@ homepage = "https://cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0" } +cosmwasm-schema = "1.1.0-rc.1" +cosmwasm-std = "1.1.0-rc.1" cw-utils = { path = "../utils", version = "0.14.0" } cw-storage-plus = { path = "../storage-plus", version = "0.14.0" } schemars = "0.8.1" diff --git a/packages/controllers/src/admin.rs b/packages/controllers/src/admin.rs index e503747a1..7586e5984 100644 --- a/packages/controllers/src/admin.rs +++ b/packages/controllers/src/admin.rs @@ -1,8 +1,8 @@ use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; use std::fmt; use thiserror::Error; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{ attr, Addr, CustomQuery, Deps, DepsMut, MessageInfo, Response, StdError, StdResult, }; @@ -10,7 +10,7 @@ use cw_storage_plus::Item; // TODO: should the return values end up in utils, so eg. cw4 can import them as well as this module? /// Returned from Admin.query_admin() -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct AdminResponse { pub admin: Option, } diff --git a/packages/controllers/src/claim.rs b/packages/controllers/src/claim.rs index 01083fecb..1c707e624 100644 --- a/packages/controllers/src/claim.rs +++ b/packages/controllers/src/claim.rs @@ -1,18 +1,16 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, BlockInfo, CustomQuery, Deps, StdResult, Storage, Uint128}; use cw_storage_plus::Map; use cw_utils::Expiration; // TODO: pull into utils? -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct ClaimsResponse { pub claims: Vec, } // TODO: pull into utils? -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Claim { pub amount: Uint128, pub release_at: Expiration, @@ -110,7 +108,7 @@ mod test { #[test] fn can_create_claim() { let claim = Claim::new(TEST_AMOUNT, TEST_EXPIRATION); - assert_eq!(claim.amount, TEST_AMOUNT.into()); + assert_eq!(claim.amount, Uint128::from(TEST_AMOUNT)); assert_eq!(claim.release_at, TEST_EXPIRATION); } @@ -150,7 +148,7 @@ mod test { .load(deps.as_mut().storage, &Addr::unchecked("addr")) .unwrap(); assert_eq!(saved_claims.len(), 1); - assert_eq!(saved_claims[0].amount, TEST_AMOUNT.into()); + assert_eq!(saved_claims[0].amount, Uint128::from(TEST_AMOUNT)); assert_eq!(saved_claims[0].release_at, TEST_EXPIRATION); // Adding another claim to same address, make sure that both claims are saved. @@ -169,9 +167,9 @@ mod test { .load(deps.as_mut().storage, &Addr::unchecked("addr")) .unwrap(); assert_eq!(saved_claims.len(), 2); - assert_eq!(saved_claims[0].amount, TEST_AMOUNT.into()); + assert_eq!(saved_claims[0].amount, Uint128::from(TEST_AMOUNT)); assert_eq!(saved_claims[0].release_at, TEST_EXPIRATION); - assert_eq!(saved_claims[1].amount, (TEST_AMOUNT + 100).into()); + assert_eq!(saved_claims[1].amount, Uint128::from(TEST_AMOUNT + 100)); assert_eq!(saved_claims[1].release_at, TEST_EXPIRATION); // Adding another claim to different address, make sure that other address only has one claim. @@ -262,9 +260,9 @@ mod test { assert_eq!(amount, Uint128::zero()); assert_eq!(saved_claims.len(), 2); - assert_eq!(saved_claims[0].amount, (TEST_AMOUNT + 100).into()); + assert_eq!(saved_claims[0].amount, Uint128::from(TEST_AMOUNT + 100)); assert_eq!(saved_claims[0].release_at, Expiration::AtHeight(10)); - assert_eq!(saved_claims[1].amount, (TEST_AMOUNT + 100).into()); + assert_eq!(saved_claims[1].amount, Uint128::from(TEST_AMOUNT + 100)); assert_eq!(saved_claims[1].release_at, Expiration::AtHeight(100)); } @@ -308,9 +306,9 @@ mod test { .load(deps.as_mut().storage, &Addr::unchecked("addr")) .unwrap(); - assert_eq!(amount, TEST_AMOUNT.into()); + assert_eq!(amount, Uint128::from(TEST_AMOUNT)); assert_eq!(saved_claims.len(), 1); - assert_eq!(saved_claims[0].amount, (TEST_AMOUNT + 100).into()); + assert_eq!(saved_claims[0].amount, Uint128::from(TEST_AMOUNT + 100)); assert_eq!(saved_claims[0].release_at, Expiration::AtHeight(100)); } @@ -354,7 +352,7 @@ mod test { .load(deps.as_mut().storage, &Addr::unchecked("addr")) .unwrap(); - assert_eq!(amount, (TEST_AMOUNT + TEST_AMOUNT + 100).into()); + assert_eq!(amount, Uint128::from(TEST_AMOUNT + TEST_AMOUNT + 100)); assert_eq!(saved_claims.len(), 0); } @@ -400,9 +398,9 @@ mod test { assert_eq!(amount, Uint128::zero()); assert_eq!(saved_claims.len(), 2); - assert_eq!(saved_claims[0].amount, (TEST_AMOUNT).into()); + assert_eq!(saved_claims[0].amount, Uint128::from(TEST_AMOUNT)); assert_eq!(saved_claims[0].release_at, Expiration::AtHeight(10)); - assert_eq!(saved_claims[1].amount, (TEST_AMOUNT + 100).into()); + assert_eq!(saved_claims[1].amount, Uint128::from(TEST_AMOUNT + 100)); assert_eq!(saved_claims[1].release_at, Expiration::AtHeight(100)); } @@ -446,7 +444,7 @@ mod test { .load(deps.as_mut().storage, &Addr::unchecked("addr")) .unwrap(); - assert_eq!(amount, (TEST_AMOUNT + TEST_AMOUNT + 100).into()); + assert_eq!(amount, Uint128::from(TEST_AMOUNT + TEST_AMOUNT + 100)); assert_eq!(saved_claims.len(), 0); } @@ -484,14 +482,14 @@ mod test { Some((TEST_AMOUNT + 50).into()), ) .unwrap(); - assert_eq!(amount, (TEST_AMOUNT).into()); + assert_eq!(amount, Uint128::from(TEST_AMOUNT)); let saved_claims = claims .0 .load(deps.as_mut().storage, &Addr::unchecked("addr")) .unwrap(); assert_eq!(saved_claims.len(), 1); - assert_eq!(saved_claims[0].amount, (TEST_AMOUNT + 100).into()); + assert_eq!(saved_claims[0].amount, Uint128::from(TEST_AMOUNT + 100)); assert_eq!(saved_claims[0].release_at, Expiration::AtHeight(10)); } @@ -536,9 +534,9 @@ mod test { .load(deps.as_mut().storage, &Addr::unchecked("addr")) .unwrap(); assert_eq!(saved_claims.len(), 2); - assert_eq!(saved_claims[0].amount, (TEST_AMOUNT + 100).into()); + assert_eq!(saved_claims[0].amount, Uint128::from(TEST_AMOUNT + 100)); assert_eq!(saved_claims[0].release_at, Expiration::AtHeight(10)); - assert_eq!(saved_claims[1].amount, (TEST_AMOUNT).into()); + assert_eq!(saved_claims[1].amount, Uint128::from(TEST_AMOUNT)); assert_eq!(saved_claims[1].release_at, Expiration::AtHeight(5)); } diff --git a/packages/controllers/src/hooks.rs b/packages/controllers/src/hooks.rs index e56985c25..fa7cf964c 100644 --- a/packages/controllers/src/hooks.rs +++ b/packages/controllers/src/hooks.rs @@ -1,8 +1,8 @@ use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; use std::fmt; use thiserror::Error; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{ attr, Addr, CustomQuery, Deps, DepsMut, MessageInfo, Response, StdError, StdResult, Storage, SubMsg, @@ -13,7 +13,7 @@ use crate::admin::{Admin, AdminError}; // this is copied from cw4 // TODO: pull into utils as common dep -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct HooksResponse { pub hooks: Vec, } diff --git a/packages/controllers/src/lib.rs b/packages/controllers/src/lib.rs index 303cf6a44..eb767b74f 100644 --- a/packages/controllers/src/lib.rs +++ b/packages/controllers/src/lib.rs @@ -4,4 +4,4 @@ mod hooks; pub use admin::{Admin, AdminError, AdminResponse}; pub use claim::{Claim, Claims, ClaimsResponse}; -pub use hooks::{HookError, Hooks}; +pub use hooks::{HookError, Hooks, HooksResponse}; diff --git a/packages/cw1/Cargo.toml b/packages/cw1/Cargo.toml index 217a478ed..6d839df43 100644 --- a/packages/cw1/Cargo.toml +++ b/packages/cw1/Cargo.toml @@ -9,9 +9,7 @@ repository = "https://github.com/CosmWasm/cw-plus" homepage = "https://cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0" } +cosmwasm-schema = "1.1.0-rc.1" +cosmwasm-std = "1.1.0-rc.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw1/src/helpers.rs b/packages/cw1/src/helpers.rs index 82b615f28..e46ecb5e2 100644 --- a/packages/cw1/src/helpers.rs +++ b/packages/cw1/src/helpers.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg}; use crate::msg::Cw1ExecuteMsg; @@ -9,7 +7,7 @@ use crate::msg::Cw1ExecuteMsg; /// for working with this. /// /// If you wish to persist this, convert to Cw1CanonicalContract via .canonical() -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Cw1Contract(pub Addr); impl Cw1Contract { diff --git a/packages/cw1/src/msg.rs b/packages/cw1/src/msg.rs index b6134e51f..62f65f4d2 100644 --- a/packages/cw1/src/msg.rs +++ b/packages/cw1/src/msg.rs @@ -1,11 +1,10 @@ use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; use std::fmt; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{CosmosMsg, Empty}; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Cw1ExecuteMsg where T: Clone + fmt::Debug + PartialEq + JsonSchema, diff --git a/packages/cw1/src/query.rs b/packages/cw1/src/query.rs index 749ab73f7..39b291705 100644 --- a/packages/cw1/src/query.rs +++ b/packages/cw1/src/query.rs @@ -1,11 +1,10 @@ use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; use std::fmt; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{CosmosMsg, Empty}; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Cw1QueryMsg where T: Clone + fmt::Debug + PartialEq + JsonSchema, @@ -16,7 +15,7 @@ where CanExecute { sender: String, msg: CosmosMsg }, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct CanExecuteResponse { pub can_execute: bool, } diff --git a/packages/cw1155/Cargo.toml b/packages/cw1155/Cargo.toml index 0ee87d3e8..55b3b1f27 100644 --- a/packages/cw1155/Cargo.toml +++ b/packages/cw1155/Cargo.toml @@ -10,9 +10,7 @@ homepage = "https://cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-schema = "1.1.0-rc.1" +cosmwasm-std = { version = "1.1.0-rc.1" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw1155/src/msg.rs b/packages/cw1155/src/msg.rs index ab087dd40..e8ddce34b 100644 --- a/packages/cw1155/src/msg.rs +++ b/packages/cw1155/src/msg.rs @@ -1,13 +1,11 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Binary, Uint128}; use cw_utils::Expiration; pub type TokenId = String; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum Cw1155ExecuteMsg { /// SendFrom is a base message to move tokens, /// if `env.sender` is the owner or has sufficient pre-approval. diff --git a/packages/cw1155/src/query.rs b/packages/cw1155/src/query.rs index 059d18899..b20076911 100644 --- a/packages/cw1155/src/query.rs +++ b/packages/cw1155/src/query.rs @@ -1,25 +1,23 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::Uint128; use cw_utils::Expiration; use crate::msg::TokenId; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum Cw1155QueryMsg { /// Returns the current balance of the given address, 0 if unset. - /// Return type: BalanceResponse. + #[returns(BalanceResponse)] Balance { owner: String, token_id: TokenId }, /// Returns the current balance of the given address for a batch of tokens, 0 if unset. - /// Return type: BatchBalanceResponse. + #[returns(BatchBalanceResponse)] BatchBalance { owner: String, token_ids: Vec, }, /// List all operators that can access all of the owner's tokens. - /// Return type: ApprovedForAllResponse. + #[returns(ApprovedForAllResponse)] ApprovedForAll { owner: String, /// unset or false will filter out expired approvals, you must set to true to see them @@ -28,17 +26,17 @@ pub enum Cw1155QueryMsg { limit: Option, }, /// Query approved status `owner` granted to `operator`. - /// Return type: IsApprovedForAllResponse + #[returns(IsApprovedForAllResponse)] IsApprovedForAll { owner: String, operator: String }, /// With MetaData Extension. /// Query metadata of token - /// Return type: TokenInfoResponse. + #[returns(TokenInfoResponse)] TokenInfo { token_id: TokenId }, /// With Enumerable extension. /// Returns all tokens owned by the given address, [] if unset. - /// Return type: TokensResponse. + #[returns(TokensResponse)] Tokens { owner: String, start_after: Option, @@ -46,24 +44,24 @@ pub enum Cw1155QueryMsg { }, /// With Enumerable extension. /// Requires pagination. Lists all token_ids controlled by the contract. - /// Return type: TokensResponse. + #[returns(TokensResponse)] AllTokens { start_after: Option, limit: Option, }, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct BalanceResponse { pub balance: Uint128, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct BatchBalanceResponse { pub balances: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Approval { /// Account that can transfer/send the token pub spender: String, @@ -71,23 +69,23 @@ pub struct Approval { pub expires: Expiration, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ApprovedForAllResponse { pub operators: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct IsApprovedForAllResponse { pub approved: bool, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct TokenInfoResponse { /// Should be a url point to a json file pub url: String, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct TokensResponse { /// Contains all token_ids in lexicographical ordering /// If there are more than `limit`, use `start_from` in future queries diff --git a/packages/cw1155/src/receiver.rs b/packages/cw1155/src/receiver.rs index 86649c93d..c56dab43a 100644 --- a/packages/cw1155/src/receiver.rs +++ b/packages/cw1155/src/receiver.rs @@ -1,13 +1,11 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Binary, CosmosMsg, StdResult, Uint128, WasmMsg}; use crate::msg::TokenId; /// Cw1155ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub struct Cw1155ReceiveMsg { /// The account that executed the send message pub operator: String, @@ -38,8 +36,8 @@ impl Cw1155ReceiveMsg { } /// Cw1155BatchReceiveMsg should be de/serialized under `BatchReceive()` variant in a ExecuteMsg -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub struct Cw1155BatchReceiveMsg { pub operator: String, pub from: Option, @@ -67,8 +65,8 @@ impl Cw1155BatchReceiveMsg { } // This is just a helper to properly serialize the above message -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + enum ReceiverExecuteMsg { Receive(Cw1155ReceiveMsg), BatchReceive(Cw1155BatchReceiveMsg), diff --git a/packages/cw2/Cargo.toml b/packages/cw2/Cargo.toml index 961ed3733..66b87431d 100644 --- a/packages/cw2/Cargo.toml +++ b/packages/cw2/Cargo.toml @@ -9,7 +9,8 @@ repository = "https://github.com/CosmWasm/cw-plus" homepage = "https://cosmwasm.com" [dependencies] -cosmwasm-std = { version = "1.0.0", default-features = false } +cosmwasm-schema = "1.1.0-rc.1" +cosmwasm-std = { version = "1.1.0-rc.1", default-features = false } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/cw2/src/lib.rs b/packages/cw2/src/lib.rs index 9ffc7dc62..f6c55ff79 100644 --- a/packages/cw2/src/lib.rs +++ b/packages/cw2/src/lib.rs @@ -1,12 +1,10 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Empty, Querier, QuerierWrapper, QueryRequest, StdResult, Storage, WasmQuery}; use cw_storage_plus::Item; pub const CONTRACT: Item = Item::new("contract_info"); -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ContractVersion { /// contract is the crate name of the implementing contract, eg. `crate:cw20-base` /// we will use other prefixes for other languages, and their standard global namespacing diff --git a/packages/cw20/Cargo.toml b/packages/cw20/Cargo.toml index e18423a89..feb0d9ffc 100644 --- a/packages/cw20/Cargo.toml +++ b/packages/cw20/Cargo.toml @@ -10,9 +10,7 @@ homepage = "https://cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-schema = "1.1.0-rc.1" +cosmwasm-std = "1.1.0-rc.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw20/src/balance.rs b/packages/cw20/src/balance.rs index e59c0b343..110de1b01 100644 --- a/packages/cw20/src/balance.rs +++ b/packages/cw20/src/balance.rs @@ -1,14 +1,14 @@ +use cosmwasm_schema::cw_serde; use cosmwasm_std::Coin; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; + use std::fmt; use cw_utils::NativeBalance; use crate::Cw20CoinVerified; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum Balance { Native(NativeBalance), Cw20(Cw20CoinVerified), diff --git a/packages/cw20/src/coin.rs b/packages/cw20/src/coin.rs index 54d4ff90a..09d461ec7 100644 --- a/packages/cw20/src/coin.rs +++ b/packages/cw20/src/coin.rs @@ -1,10 +1,8 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Uint128}; use std::fmt; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Cw20Coin { pub address: String, pub amount: Uint128, @@ -22,7 +20,7 @@ impl fmt::Display for Cw20Coin { } } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Cw20CoinVerified { pub address: Addr, pub amount: Uint128, diff --git a/packages/cw20/src/denom.rs b/packages/cw20/src/denom.rs index 1b4e001d2..f0351c665 100644 --- a/packages/cw20/src/denom.rs +++ b/packages/cw20/src/denom.rs @@ -1,9 +1,8 @@ +use cosmwasm_schema::cw_serde; use cosmwasm_std::Addr; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum Denom { Native(String), Cw20(Addr), diff --git a/packages/cw20/src/helpers.rs b/packages/cw20/src/helpers.rs index f1e3df19b..f38ef3386 100644 --- a/packages/cw20/src/helpers.rs +++ b/packages/cw20/src/helpers.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{ to_binary, Addr, CosmosMsg, CustomQuery, Querier, QuerierWrapper, StdResult, Uint128, WasmMsg, WasmQuery, @@ -15,7 +13,7 @@ use crate::{ /// for working with this. /// /// If you wish to persist this, convert to Cw20CanonicalContract via .canonical() -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Cw20Contract(pub Addr); impl Cw20Contract { diff --git a/packages/cw20/src/logo.rs b/packages/cw20/src/logo.rs index 6f5007068..4ed19a5e4 100644 --- a/packages/cw20/src/logo.rs +++ b/packages/cw20/src/logo.rs @@ -1,10 +1,9 @@ +use cosmwasm_schema::cw_serde; use cosmwasm_std::Binary; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; /// This is used for uploading logo data, or setting it in InstantiateData -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum Logo { /// A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL. Url(String), @@ -14,8 +13,8 @@ pub enum Logo { /// This is used to store the logo on the blockchain in an accepted format. /// Enforce maximum size of 5KB on all variants. -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum EmbeddedLogo { /// Store the Logo as an SVG file. The content must conform to the spec /// at https://en.wikipedia.org/wiki/Scalable_Vector_Graphics @@ -28,8 +27,8 @@ pub enum EmbeddedLogo { /// This is used to display logo info, provide a link or inform there is one /// that can be downloaded from the blockchain itself -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum LogoInfo { /// A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL. Url(String), diff --git a/packages/cw20/src/msg.rs b/packages/cw20/src/msg.rs index f2f9708c9..db807c2cf 100644 --- a/packages/cw20/src/msg.rs +++ b/packages/cw20/src/msg.rs @@ -1,12 +1,10 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - use crate::logo::Logo; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Binary, Uint128}; use cw_utils::Expiration; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum Cw20ExecuteMsg { /// Transfer is a base message to move tokens to another account without triggering actions Transfer { recipient: String, amount: Uint128 }, diff --git a/packages/cw20/src/query.rs b/packages/cw20/src/query.rs index 84ab604b1..425099bb4 100644 --- a/packages/cw20/src/query.rs +++ b/packages/cw20/src/query.rs @@ -1,13 +1,14 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Binary, Uint128}; use crate::logo::LogoInfo; use cw_utils::Expiration; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum Cw20QueryMsg { /// Returns the current balance of the given address, 0 if unset. /// Return type: BalanceResponse. @@ -50,12 +51,12 @@ pub enum Cw20QueryMsg { }, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct BalanceResponse { pub balance: Uint128, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct TokenInfoResponse { pub name: String, pub symbol: String, @@ -69,7 +70,7 @@ pub struct AllowanceResponse { pub expires: Expiration, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct MinterResponse { pub minter: String, /// cap is a hard cap on total supply that can be achieved by minting. @@ -92,13 +93,13 @@ pub struct MarketingInfoResponse { /// When we download an embedded logo, we get this response type. /// We expect a SPA to be able to accept this info and display it. -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct DownloadLogoResponse { pub mime_type: String, pub data: Binary, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct AllowanceInfo { pub spender: String, pub allowance: Uint128, @@ -110,7 +111,7 @@ pub struct AllAllowancesResponse { pub allowances: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct SpenderAllowanceInfo { pub owner: String, pub allowance: Uint128, @@ -122,7 +123,7 @@ pub struct AllSpenderAllowancesResponse { pub allowances: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)] pub struct AllAccountsResponse { pub accounts: Vec, } diff --git a/packages/cw20/src/receiver.rs b/packages/cw20/src/receiver.rs index dc8370b63..630746e6a 100644 --- a/packages/cw20/src/receiver.rs +++ b/packages/cw20/src/receiver.rs @@ -1,11 +1,9 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Binary, CosmosMsg, StdResult, Uint128, WasmMsg}; /// Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub struct Cw20ReceiveMsg { pub sender: String, pub amount: Uint128, @@ -32,8 +30,8 @@ impl Cw20ReceiveMsg { } // This is just a helper to properly serialize the above message -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + enum ReceiverExecuteMsg { Receive(Cw20ReceiveMsg), } diff --git a/packages/cw3/Cargo.toml b/packages/cw3/Cargo.toml index bb9532bc0..10b89cc6d 100644 --- a/packages/cw3/Cargo.toml +++ b/packages/cw3/Cargo.toml @@ -10,9 +10,7 @@ homepage = "https://cosmwasm.com" [dependencies] cw-utils = { path = "../../packages/utils", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-schema = "1.1.0-rc.1" +cosmwasm-std = "1.1.0-rc.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw3/src/helpers.rs b/packages/cw3/src/helpers.rs index 3bc56d10b..c360bab0f 100644 --- a/packages/cw3/src/helpers.rs +++ b/packages/cw3/src/helpers.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg}; use crate::msg::{Cw3ExecuteMsg, Vote}; @@ -13,7 +11,7 @@ use cw_utils::Expiration; /// /// FIXME: Cw3Contract currently only supports CosmosMsg. When we actually /// use this in some consuming code, we should make it generic over CosmosMsg. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Cw3Contract(pub Addr); impl Cw3Contract { diff --git a/packages/cw3/src/msg.rs b/packages/cw3/src/msg.rs index 0811690fb..32b9a95b8 100644 --- a/packages/cw3/src/msg.rs +++ b/packages/cw3/src/msg.rs @@ -2,11 +2,12 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{CosmosMsg, Empty}; use cw_utils::Expiration; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + pub enum Cw3ExecuteMsg where T: Clone + fmt::Debug + PartialEq + JsonSchema, @@ -30,7 +31,7 @@ where }, } -#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)] +#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, JsonSchema, Debug)] #[serde(rename_all = "lowercase")] pub enum Vote { /// Marks support for the proposal. diff --git a/packages/cw3/src/query.rs b/packages/cw3/src/query.rs index 27850d757..f1a5b9383 100644 --- a/packages/cw3/src/query.rs +++ b/packages/cw3/src/query.rs @@ -2,13 +2,13 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::fmt; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{CosmosMsg, Empty}; use cw_utils::{Expiration, ThresholdResponse}; use crate::msg::Vote; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Cw3QueryMsg { /// Returns the threshold rules that would be used for a new proposal that was /// opened right now. The threshold rules do not change often, but the `total_weight` @@ -52,7 +52,7 @@ pub enum Cw3QueryMsg { /// Note, if you are storing custom messages in the proposal, /// the querier needs to know what possible custom message types /// those are in order to parse the response -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ProposalResponse where T: Clone + fmt::Debug + PartialEq + JsonSchema, @@ -69,7 +69,7 @@ where pub threshold: ThresholdResponse, } -#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)] +#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, JsonSchema, Debug)] #[serde(rename_all = "lowercase")] #[repr(u8)] pub enum Status { @@ -85,19 +85,19 @@ pub enum Status { Executed = 5, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct ProposalListResponse { pub proposals: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct VoteListResponse { pub votes: Vec, } /// Returns the vote (opinion as well as weight counted) as well as /// the address of the voter who submitted it -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct VoteInfo { pub proposal_id: u64, pub voter: String, @@ -105,22 +105,22 @@ pub struct VoteInfo { pub weight: u64, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct VoteResponse { pub vote: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct VoterResponse { pub weight: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct VoterListResponse { pub voters: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct VoterDetail { pub addr: String, pub weight: u64, diff --git a/packages/cw4/Cargo.toml b/packages/cw4/Cargo.toml index 668899336..cc5d212c8 100644 --- a/packages/cw4/Cargo.toml +++ b/packages/cw4/Cargo.toml @@ -10,9 +10,7 @@ homepage = "https://cosmwasm.com" [dependencies] cw-storage-plus = { path = "../storage-plus", version = "0.14.0" } -cosmwasm-std = { version = "1.0.0" } +cosmwasm-schema = "1.1.0-rc.1" +cosmwasm-std = "1.1.0-rc.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } - -[dev-dependencies] -cosmwasm-schema = { version = "1.0.0" } diff --git a/packages/cw4/src/helpers.rs b/packages/cw4/src/helpers.rs index 0761e5c39..57dc4d069 100644 --- a/packages/cw4/src/helpers.rs +++ b/packages/cw4/src/helpers.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{ to_binary, Addr, CosmosMsg, CustomQuery, QuerierWrapper, QueryRequest, StdResult, WasmMsg, WasmQuery, @@ -17,7 +15,7 @@ use cw_storage_plus::{Item, Map}; /// for working with cw4 contracts /// /// If you wish to persist this, convert to Cw4CanonicalContract via .canonical() -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Cw4Contract(pub Addr); impl Cw4Contract { diff --git a/packages/cw4/src/hook.rs b/packages/cw4/src/hook.rs index e28fdb5c3..f3ce1bff2 100644 --- a/packages/cw4/src/hook.rs +++ b/packages/cw4/src/hook.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Binary, CosmosMsg, StdResult, WasmMsg}; /// MemberDiff shows the old and new states for a given cw4 member @@ -8,7 +6,7 @@ use cosmwasm_std::{to_binary, Binary, CosmosMsg, StdResult, WasmMsg}; /// old = None, new = Some -> Insert /// old = Some, new = Some -> Update /// old = Some, new = None -> Delete -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct MemberDiff { pub key: String, pub old: Option, @@ -27,8 +25,7 @@ impl MemberDiff { /// MemberChangedHookMsg should be de/serialized under `MemberChangedHook()` variant in a ExecuteMsg. /// This contains a list of all diffs on the given transaction. -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub struct MemberChangedHookMsg { pub diffs: Vec, } @@ -61,8 +58,8 @@ impl MemberChangedHookMsg { } // This is just a helper to properly serialize the above message -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] + enum MemberChangedExecuteMsg { MemberChangedHook(MemberChangedHookMsg), } diff --git a/packages/cw4/src/msg.rs b/packages/cw4/src/msg.rs index 291857ce7..ba7ded072 100644 --- a/packages/cw4/src/msg.rs +++ b/packages/cw4/src/msg.rs @@ -1,8 +1,6 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Cw4ExecuteMsg { /// Change the admin UpdateAdmin { admin: Option }, diff --git a/packages/cw4/src/query.rs b/packages/cw4/src/query.rs index d82734264..6745d6af1 100644 --- a/packages/cw4/src/query.rs +++ b/packages/cw4/src/query.rs @@ -1,8 +1,7 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; + +#[cw_serde] -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] pub enum Cw4QueryMsg { /// Return AdminResponse Admin {}, @@ -22,7 +21,7 @@ pub enum Cw4QueryMsg { Hooks {}, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct AdminResponse { pub admin: Option, } @@ -30,28 +29,28 @@ pub struct AdminResponse { /// A group member has a weight associated with them. /// This may all be equal, or may have meaning in the app that /// makes use of the group (eg. voting power) -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct Member { pub addr: String, pub weight: u64, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct MemberListResponse { pub members: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct MemberResponse { pub weight: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct TotalWeightResponse { pub weight: u64, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] +#[cw_serde] pub struct HooksResponse { pub hooks: Vec, } diff --git a/packages/multi-test/Cargo.toml b/packages/multi-test/Cargo.toml index bfc5c83cf..c1a07b88c 100644 --- a/packages/multi-test/Cargo.toml +++ b/packages/multi-test/Cargo.toml @@ -19,8 +19,8 @@ backtrace = ["anyhow/backtrace"] [dependencies] cw-utils = { path = "../../packages/utils", version = "0.14.0" } cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0"} -cosmwasm-std = { version = "1.0.0", features = ["staking"] } -cosmwasm-storage = { version = "1.0.0" } +cosmwasm-std = { version = "1.1.0-rc.1", features = ["staking"] } +cosmwasm-storage = "1.1.0-rc.1" itertools = "0.10.1" schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/multi-test/src/bank.rs b/packages/multi-test/src/bank.rs index 17cea14fa..71493d2c0 100644 --- a/packages/multi-test/src/bank.rs +++ b/packages/multi-test/src/bank.rs @@ -19,7 +19,7 @@ const BALANCES: Map<&Addr, NativeBalance> = Map::new("balances"); pub const NAMESPACE_BANK: &[u8] = b"bank"; // WIP -#[derive(Clone, std::fmt::Debug, PartialEq, JsonSchema)] +#[derive(Clone, std::fmt::Debug, PartialEq, Eq, JsonSchema)] pub enum BankSudo { Mint { to_address: String, diff --git a/packages/multi-test/src/error.rs b/packages/multi-test/src/error.rs index 8c4a6675e..f0bd0920d 100644 --- a/packages/multi-test/src/error.rs +++ b/packages/multi-test/src/error.rs @@ -1,7 +1,7 @@ use cosmwasm_std::{WasmMsg, WasmQuery}; use thiserror::Error; -#[derive(Debug, Error, PartialEq)] +#[derive(Debug, Error, PartialEq, Eq)] pub enum Error { #[error("Empty attribute key. Value: {value}")] EmptyAttributeKey { value: String }, diff --git a/packages/multi-test/src/staking.rs b/packages/multi-test/src/staking.rs index bf501caa9..20254a87e 100644 --- a/packages/multi-test/src/staking.rs +++ b/packages/multi-test/src/staking.rs @@ -5,7 +5,7 @@ use crate::module::FailingModule; use crate::Module; // We need to expand on this, but we will need this to properly test out staking -#[derive(Clone, std::fmt::Debug, PartialEq, JsonSchema)] +#[derive(Clone, std::fmt::Debug, PartialEq, Eq, JsonSchema)] pub enum StakingSudo { Slash { validator: String, diff --git a/packages/multi-test/src/test_helpers.rs b/packages/multi-test/src/test_helpers.rs index 7bbad2f76..cb551197b 100644 --- a/packages/multi-test/src/test_helpers.rs +++ b/packages/multi-test/src/test_helpers.rs @@ -10,7 +10,7 @@ pub mod contracts; pub struct EmptyMsg {} /// This is just a demo place so we can test custom message handling -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] #[serde(rename = "snake_case")] pub enum CustomMsg { SetName { name: String }, diff --git a/packages/multi-test/src/wasm.rs b/packages/multi-test/src/wasm.rs index cdbd06143..618e2739d 100644 --- a/packages/multi-test/src/wasm.rs +++ b/packages/multi-test/src/wasm.rs @@ -31,7 +31,7 @@ const CONTRACTS: Map<&Addr, ContractData> = Map::new("contracts"); pub const NAMESPACE_WASM: &[u8] = b"wasm"; const CONTRACT_ATTR: &str = "_contract_addr"; -#[derive(Clone, std::fmt::Debug, PartialEq, JsonSchema)] +#[derive(Clone, std::fmt::Debug, PartialEq, Eq, JsonSchema)] pub struct WasmSudo { pub contract_addr: Addr, pub msg: Binary, @@ -48,7 +48,7 @@ impl WasmSudo { /// Contract Data includes information about contract, equivalent of `ContractInfo` in wasmd /// interface. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct ContractData { /// Identifier of stored contract code pub code_id: usize, diff --git a/packages/storage-macro/Cargo.toml b/packages/storage-macro/Cargo.toml index 76e81f45e..ab18fc4af 100644 --- a/packages/storage-macro/Cargo.toml +++ b/packages/storage-macro/Cargo.toml @@ -17,5 +17,5 @@ syn = { version = "1.0.96", features = ["full"] } [dev-dependencies] cw-storage-plus = { version = "<=0.14.0, >=0.13.4", path = "../storage-plus" } -cosmwasm-std = { version = "1.0.0", default-features = false } +cosmwasm-std = { version = "1.1.0-rc.1", default-features = false } serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/storage-plus/Cargo.toml b/packages/storage-plus/Cargo.toml index 3d9b4a14e..8ec378573 100644 --- a/packages/storage-plus/Cargo.toml +++ b/packages/storage-plus/Cargo.toml @@ -18,7 +18,7 @@ macro = ["cw-storage-macro"] bench = false [dependencies] -cosmwasm-std = { version = "1.0.0", default-features = false } +cosmwasm-std = { version = "1.1.0-rc.1", default-features = false } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } cw-storage-macro = { version = "0.14.0", optional = true, path = "../storage-macro" } diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 67d243af0..4dcc5398b 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -582,7 +582,7 @@ mod test { // Manually add a broken key (invalid utf-8) store.set( - &*[ + &[ [0u8, PEOPLE_STR_KEY.len() as u8].as_slice(), PEOPLE_STR_KEY.as_bytes(), b"\xddim", diff --git a/packages/storage-plus/src/snapshot/mod.rs b/packages/storage-plus/src/snapshot/mod.rs index d992743b9..7fccfea7d 100644 --- a/packages/storage-plus/src/snapshot/mod.rs +++ b/packages/storage-plus/src/snapshot/mod.rs @@ -160,7 +160,7 @@ where } } -#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)] pub enum Strategy { EveryBlock, Never, @@ -172,7 +172,7 @@ pub enum Strategy { Selected, } -#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)] pub struct ChangeSet { pub old: Option, } diff --git a/packages/utils/Cargo.toml b/packages/utils/Cargo.toml index aec23b9d7..26817784d 100644 --- a/packages/utils/Cargo.toml +++ b/packages/utils/Cargo.toml @@ -11,12 +11,13 @@ homepage = "https://cosmwasm.com" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = { version = "1.0.0" } +cosmwasm-schema = "1.1.0-rc.1" +cosmwasm-std = "1.1.0-rc.1" cw2 = { path = "../../packages/cw2", version = "0.14.0" } schemars = "0.8.1" semver = "1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.21" } +thiserror = "1.0.21" [dev-dependencies] cw-storage-plus = { path = "../../packages/storage-plus", version = "0.14.0" } diff --git a/packages/utils/src/balance.rs b/packages/utils/src/balance.rs index f37b849fc..16a15d561 100644 --- a/packages/utils/src/balance.rs +++ b/packages/utils/src/balance.rs @@ -1,12 +1,12 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; use std::{fmt, ops}; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Coin, OverflowError, OverflowOperation, StdError, StdResult, Uint128}; // Balance wraps Vec and provides some nice helpers. It mutates the Vec and can be // unwrapped when done. -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)] +#[cw_serde] +#[derive(Default)] pub struct NativeBalance(pub Vec); impl NativeBalance { diff --git a/packages/utils/src/expiration.rs b/packages/utils/src/expiration.rs index 4cb53fc39..fe1d707dc 100644 --- a/packages/utils/src/expiration.rs +++ b/packages/utils/src/expiration.rs @@ -1,16 +1,14 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{BlockInfo, StdError, StdResult, Timestamp}; use std::cmp::Ordering; use std::fmt; use std::ops::{Add, Mul}; -#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] /// Expiration represents a point in time when some event happens. /// It can compare with a BlockInfo and will return is_expired() == true /// once the condition is hit (and for every block in the future) +#[cw_serde] +#[derive(Copy)] pub enum Expiration { /// AtHeight will expire when `env.block.height` >= height AtHeight(u64), @@ -88,8 +86,8 @@ pub const WEEK: Duration = Duration::Time(7 * 24 * 60 * 60); /// Duration is a delta of time. You can add it to a BlockInfo or Expiration to /// move that further in the future. Note that an height-based Duration and /// a time-based Expiration cannot be combined -#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(Copy)] pub enum Duration { Height(u64), /// Time in seconds diff --git a/packages/utils/src/parse_reply.rs b/packages/utils/src/parse_reply.rs index 468053de2..f52d18933 100644 --- a/packages/utils/src/parse_reply.rs +++ b/packages/utils/src/parse_reply.rs @@ -7,13 +7,13 @@ const WIRE_TYPE_LENGTH_DELIMITED: u8 = 2; // Up to 9 bytes of varints as a practical limit (https://github.com/multiformats/unsigned-varint#practical-maximum-of-9-bytes-for-security) const VARINT_MAX_BYTES: usize = 9; -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgInstantiateContractResponse { pub contract_address: String, pub data: Option, } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct MsgExecuteContractResponse { pub data: Option, } @@ -152,7 +152,7 @@ pub fn parse_execute_response_data( Ok(MsgExecuteContractResponse { data: inner_data }) } -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, Eq)] pub enum ParseReplyError { #[error("Failure response from sub-message: {0}")] SubMsgFailure(String), diff --git a/packages/utils/src/payment.rs b/packages/utils/src/payment.rs index 27e8a1063..f6ccdd201 100644 --- a/packages/utils/src/payment.rs +++ b/packages/utils/src/payment.rs @@ -52,7 +52,7 @@ pub fn may_pay(info: &MessageInfo, denom: &str) -> Result } } -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, Eq)] pub enum PaymentError { #[error("Must send reserve token '{0}'")] MissingDenom(String), diff --git a/packages/utils/src/scheduled.rs b/packages/utils/src/scheduled.rs index c8c6ca4bb..f96794cdb 100644 --- a/packages/utils/src/scheduled.rs +++ b/packages/utils/src/scheduled.rs @@ -1,17 +1,15 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - use crate::Duration; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{BlockInfo, StdError, StdResult, Timestamp}; use std::cmp::Ordering; use std::fmt; use std::ops::Add; -#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] /// Scheduled represents a point in time when an event happens. /// It can compare with a BlockInfo and will return is_triggered() == true /// once the condition is hit (and for every block in the future) +#[cw_serde] +#[derive(Copy)] pub enum Scheduled { /// AtHeight will schedule when `env.block.height` >= height AtHeight(u64), diff --git a/packages/utils/src/threshold.rs b/packages/utils/src/threshold.rs index b919f7a02..312a298e0 100644 --- a/packages/utils/src/threshold.rs +++ b/packages/utils/src/threshold.rs @@ -1,6 +1,4 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Decimal, StdError}; use thiserror::Error; @@ -11,8 +9,7 @@ use thiserror::Error; /// the block at which the proposal starts (this is likely the responsibility of a /// correct cw4 implementation). /// See also `ThresholdResponse` in the cw3 spec. -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum Threshold { /// Declares that a fixed weight of Yes votes is needed to pass. /// See `ThresholdResponse.AbsoluteCount` in the cw3 spec for details. @@ -107,8 +104,7 @@ fn valid_quorum(percent: &Decimal) -> Result<(), ThresholdError> { /// individual voter used in tallying should be snapshotted at the beginning of /// the block at which the proposal starts (this is likely the responsibility of a /// correct cw4 implementation). -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ThresholdResponse { /// Declares that a fixed weight of yes votes is needed to pass. /// It does not matter how many no votes are cast, or how many do not vote,