From 375a23abb29ada7151c2ed08628a429050716c36 Mon Sep 17 00:00:00 2001 From: Jiri Date: Mon, 15 Dec 2025 14:19:03 +0100 Subject: [PATCH 1/4] Updated cosmwasm-std to v3.0.2 --- Cargo.lock | 959 ++++++++++++++++++---- Cargo.toml | 9 +- src/access_control/access_control_impl.rs | 15 +- src/access_control/error.rs | 4 +- src/balance/helpers.rs | 130 +-- src/crypto/encoding.rs | 4 +- src/crypto/ethereum.rs | 9 +- src/crypto/secp256k1.rs | 2 +- src/pausing/errors.rs | 2 +- src/permissions/private.rs | 2 +- src/permissions/superadmin.rs | 2 +- src/testing/helpers.rs | 35 +- 12 files changed, 925 insertions(+), 248 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c44877..f1dcf1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,18 +1,166 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ahash" -version = "0.7.8" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ - "getrandom", + "cfg-if", "once_cell", "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "ark-bls12-381" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df4dcc01ff89867cd86b0da835f23c3f02738353aaee7dde7495af71363b8d5" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce" +dependencies = [ + "ahash", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "educe", + "fnv", + "hashbrown 0.15.5", + "itertools", + "num-bigint", + "num-integer", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "arrayvec", + "digest", + "educe", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" +dependencies = [ + "quote", + "syn", ] +[[package]] +name = "ark-ff-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ark-poly" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27" +dependencies = [ + "ahash", + "ark-ff", + "ark-serialize", + "ark-std", + "educe", + "fnv", + "hashbrown 0.15.5", +] + +[[package]] +name = "ark-serialize" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "arrayvec", + "digest", + "num-bigint", + "rayon", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ark-std" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a" +dependencies = [ + "num-traits", + "rand", + "rayon", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + [[package]] name = "base16ct" version = "0.2.0" @@ -26,10 +174,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] -name = "base64ct" -version = "1.6.0" +name = "base64" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bech32" @@ -38,13 +186,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" [[package]] -name = "block-buffer" -version = "0.9.0" +name = "bech32" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] +checksum = "32637268377fc7b10a8c6d51de3e7fba1ce5dd371a96e342b34e6078db558e7f" [[package]] name = "block-buffer" @@ -57,9 +202,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" +checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" [[package]] name = "byteorder" @@ -79,37 +224,57 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "cosmwasm-core" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b0a718b13ffe224e32a8c1f68527354868f47d6cc84afe8c66cb05fbb3ced6e" + [[package]] name = "cosmwasm-crypto" -version = "1.5.3" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9934c79e58d9676edfd592557dee765d2a6ef54c09d5aa2edb06156b00148966" +checksum = "3c08dd7585b5c48fbcb947ada7a3fb49465fb735481ed295b54ca98add6dc17f" dependencies = [ - "digest 0.10.7", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "cosmwasm-core", + "curve25519-dalek", + "digest", "ecdsa", "ed25519-zebra", "k256", - "rand_core 0.6.4", + "num-bigint", + "num-traits", + "p256", + "rand_core", + "rayon", + "sha2", "thiserror", ] [[package]] name = "cosmwasm-derive" -version = "1.5.3" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5e72e330bd3bdab11c52b5ecbdeb6a8697a004c57964caeb5d876f0b088b3c" +checksum = "5677eed823a61eeb615b1ad4915a42336b70b0fe3f87bf3da4b59f3dcf9034af" dependencies = [ - "syn 1.0.109", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "cosmwasm-schema" -version = "1.5.5" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7879036156092ad1c22fe0d7316efc5a5eceec2bc3906462a2560215f2a2f929" +checksum = "52d8808bf9fb8f4d5ee62e808b3e1dcdf6a116e9e1fe934507a4e0a4135ae941" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.22", "serde", "serde_json", "thiserror", @@ -117,33 +282,36 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.5" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb57855fbfc83327f8445ae0d413b1a05ac0d68c396ab4d122b2abd7bb82cb6" +checksum = "9718a856ff5edb6537ac889ff695abc576304bc25cb7b16ef4c762e10a0149ba" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "cosmwasm-std" -version = "1.5.3" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8666e572a3a2519010dde88c04d16e9339ae751b56b2bb35081fe3f7d6be74" +checksum = "d4881104f54871bcea6f30757bee13b7f09c0998d1b0de133cce5a52336a2ada" dependencies = [ - "base64", - "bech32", + "base64 0.22.1", + "bech32 0.11.1", "bnum", + "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", - "derivative", - "forward_ref", + "cw-schema", + "derive_more", "hex", - "schemars", + "rand_core", + "rmp-serde", + "schemars 0.8.22", "serde", - "serde-json-wasm", - "sha2 0.10.8", + "serde_json", + "sha2", "static_assertions", "thiserror", ] @@ -157,6 +325,31 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + [[package]] name = "crunchy" version = "0.2.2" @@ -170,7 +363,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -187,23 +380,37 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "cw-fetch-std" version = "0.2.0" dependencies = [ - "base64", - "bech32", + "base64 0.21.7", + "bech32 0.9.1", "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", @@ -211,21 +418,86 @@ dependencies = [ "query-responses-hybrid-derive", "ripemd", "serde", - "sha2 0.10.8", + "serde_json", + "sha2", "tiny-keccak", ] +[[package]] +name = "cw-schema" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8f335d3f51e10260f4dfb0840f0526c1d25c6b42a9489c04ce41ed9aa54dd6d" +dependencies = [ + "cw-schema-derive", + "indexmap", + "schemars 1.1.0", + "serde", + "serde_with", + "siphasher", + "typeid", +] + +[[package]] +name = "cw-schema-derive" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aba2eb93f854caeacc5eda13d15663b7605395514fd378bfba8e7532f1fc5865" +dependencies = [ + "heck", + "itertools", + "owo-colors", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "cw-storage-plus" -version = "1.2.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" +checksum = "75d840d773b4ffd60ff005375e5e15e4be4fda54620574e861bfbb61a074f353" dependencies = [ "cosmwasm-std", - "schemars", + "schemars 0.8.22", "serde", ] +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "der" version = "0.7.8" @@ -237,23 +509,25 @@ dependencies = [ ] [[package]] -name = "derivative" -version = "2.2.0" +name = "derive_more" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +checksum = "10b768e943bed7bf2cab53df09f4bc34bfd217cdb57d971e769874c9a6710618" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "derive_more-impl", ] [[package]] -name = "digest" -version = "0.9.0" +name = "derive_more-impl" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "6d286bfdaf75e988b4a78e013ecd79c581e06399ab53fbacd2d916c2f904f30b" dependencies = [ - "generic-array", + "proc-macro2", + "quote", + "rustc_version", + "syn", + "unicode-xid", ] [[package]] @@ -262,7 +536,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "const-oid", "crypto-common", "subtle", @@ -281,28 +555,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", - "digest 0.10.7", + "digest", "elliptic-curve", "rfc6979", "signature", - "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", ] [[package]] name = "ed25519-zebra" -version = "3.1.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek", - "hashbrown", + "ed25519", + "hashbrown 0.14.5", "hex", - "rand_core 0.6.4", - "serde", - "sha2 0.9.9", + "rand_core", + "sha2", "zeroize", ] +[[package]] +name = "educe" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + [[package]] name = "elliptic-curve" version = "0.13.8" @@ -311,32 +611,63 @@ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", - "digest 0.10.7", + "digest", "ff", "generic-array", "group", - "pkcs8", - "rand_core 0.6.4", + "rand_core", "sec1", "subtle", "zeroize", ] +[[package]] +name = "enum-ordinalize" +version = "4.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a1091a7bb1f8f2c4b28f1fe2cef4980ca2d410a3d727d67ecc3178c9b0800f0" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca9601fb2d62598ee17836250842873a413586e5d7ed88b356e38ddbb0ec631" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + [[package]] name = "ff" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] [[package]] -name = "forward_ref" -version = "1.0.0" +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" @@ -367,19 +698,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core 0.6.4", + "rand_core", "subtle", ] [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", + "allocator-api2", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + [[package]] name = "hex" version = "0.4.3" @@ -392,7 +751,49 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.7", + "digest", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", +] + +[[package]] +name = "is-terminal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", ] [[package]] @@ -403,16 +804,14 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "k256" -version = "0.13.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", - "sha2 0.10.8", - "signature", + "sha2", ] [[package]] @@ -421,6 +820,40 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -428,26 +861,56 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "opaque-debug" -version = "0.3.0" +name = "owo-colors" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" +dependencies = [ + "supports-color 2.1.0", + "supports-color 3.0.2", +] [[package]] -name = "pkcs8" -version = "0.10.2" +name = "p256" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" dependencies = [ - "der", - "spki", + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", ] [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] @@ -457,23 +920,37 @@ name = "query-responses-hybrid-derive" version = "0.1.0" dependencies = [ "quote", - "syn 2.0.52", + "syn", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] [[package]] -name = "rand_core" -version = "0.5.1" +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] [[package]] name = "rand_core" @@ -484,6 +961,46 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -500,7 +1017,38 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" dependencies = [ - "digest 0.10.7", + "digest", +] + +[[package]] +name = "rmp" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", ] [[package]] @@ -511,26 +1059,51 @@ checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "schemars" -version = "0.8.16" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.22", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.1.0", "serde", "serde_json", ] [[package]] name = "schemars_derive" -version = "0.8.16" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 1.0.109", + "syn", +] + +[[package]] +name = "schemars_derive" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301858a4023d78debd2353c7426dc486001bddc91ae31a76fb1f55132f7e2633" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", ] [[package]] @@ -542,73 +1115,90 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + [[package]] name = "serde" -version = "1.0.197" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ + "serde_core", "serde_derive", ] [[package]] -name = "serde-json-wasm" -version = "0.5.2" +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ - "serde", + "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn", ] [[package]] name = "serde_derive_internals" -version = "0.26.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", + "memchr", "ryu", "serde", + "serde_core", ] [[package]] -name = "sha2" -version = "0.9.9" +name = "serde_with" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "4fa237f2807440d238e0364a218270b98f767a00d3dada77b1c53ae88940e2e7" dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", + "serde_core", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a8e3ca0ca629121f70ab50f95249e5a6f925cc0f6ffe8256c45b728875706c" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -619,7 +1209,7 @@ checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -628,19 +1218,15 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", + "digest", + "rand_core", ] [[package]] -name = "spki" -version = "0.7.3" +name = "siphasher" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "static_assertions" @@ -648,6 +1234,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.5.0" @@ -655,21 +1247,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] -name = "syn" -version = "1.0.109" +name = "supports-color" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "is-terminal", + "is_ci", +] + +[[package]] +name = "supports-color" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" +dependencies = [ + "is_ci", ] [[package]] name = "syn" -version = "2.0.52" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -693,7 +1293,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn", ] [[package]] @@ -705,6 +1305,12 @@ dependencies = [ "crunchy", ] +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + [[package]] name = "typenum" version = "1.17.0" @@ -717,6 +1323,12 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "version_check" version = "0.9.4" @@ -729,8 +1341,57 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "zerocopy" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 773abee..7657bf2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,9 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cosmwasm-std = "1.5.3" -cosmwasm-schema = "1.5.3" -cw-storage-plus = "1.2.0" +cosmwasm-std = "3.0.2" +cosmwasm-schema = "3.0.2" +cw-storage-plus = "3.0.1" bech32 = "0.9.1" sha2 = "0.10.6" ripemd = "0.1.3" @@ -16,4 +16,5 @@ serde = { version = "1.0.145", default-features = false, features = ["derive"] } tiny-keccak = { version = "2.0.2", features = ["keccak"] } hex = "0.4.3" base64 = "0.21.7" -query-responses-hybrid-derive = { path = "query-responses-hybrid-derive" } \ No newline at end of file +query-responses-hybrid-derive = { path = "query-responses-hybrid-derive" } +serde_json = "1.0.145" \ No newline at end of file diff --git a/src/access_control/access_control_impl.rs b/src/access_control/access_control_impl.rs index ca34409..ba03647 100644 --- a/src/access_control/access_control_impl.rs +++ b/src/access_control/access_control_impl.rs @@ -333,8 +333,9 @@ mod tests { &DEFAULT_ADMIN_ROLE, &creator ) - .unwrap_err(), - sender_is_not_role_admin_error(&DEFAULT_ADMIN_ROLE) + .unwrap_err() + .to_string(), + sender_is_not_role_admin_error(&DEFAULT_ADMIN_ROLE).to_string() ); assert!(AccessControl::revoke_role( deps.as_mut().storage, @@ -400,8 +401,9 @@ mod tests { DEFAULT_ADMIN_ROLE, &creator ) - .unwrap_err(), - sender_is_not_role_admin_error(&DEFAULT_ADMIN_ROLE) + .unwrap_err() + .to_string(), + sender_is_not_role_admin_error(&DEFAULT_ADMIN_ROLE).to_string() ); assert!(AccessControl::renounce_role( @@ -420,8 +422,9 @@ mod tests { DEFAULT_ADMIN_ROLE, &user2 ) - .unwrap_err(), - sender_is_not_role_admin_error(&DEFAULT_ADMIN_ROLE) + .unwrap_err() + .to_string(), + sender_is_not_role_admin_error(&DEFAULT_ADMIN_ROLE).to_string() ); assert!(AccessControl::revoke_role( diff --git a/src/access_control/error.rs b/src/access_control/error.rs index d418098..f5fdcb4 100644 --- a/src/access_control/error.rs +++ b/src/access_control/error.rs @@ -2,12 +2,12 @@ use cosmwasm_std::{Addr, StdError}; pub fn no_role_error(address: &Addr, role: Option<&str>) -> StdError { let role_str = role.map(|role| format!(" '{}'", role)).unwrap_or_default(); - StdError::generic_err(format!( + StdError::msg(format!( "Address {} does not have required role{}", address, role_str )) } pub fn sender_is_not_role_admin_error(role: &str) -> StdError { - StdError::generic_err(format!("Sender is not admin of the '{}' role", role)) + StdError::msg(format!("Sender is not admin of the '{}' role", role)) } diff --git a/src/balance/helpers.rs b/src/balance/helpers.rs index 731de87..eeeed6f 100644 --- a/src/balance/helpers.rs +++ b/src/balance/helpers.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{Coin, StdError, StdResult, Uint128}; +use cosmwasm_std::{Coin, StdError, StdResult, Uint256}; use std::collections::btree_map::Entry; use std::collections::btree_map::OccupiedEntry; use std::collections::BTreeMap; @@ -7,13 +7,13 @@ pub trait BTreeMapCoinHelpers { fn into_vec(self) -> Vec; fn inplace_sub<'a, I>(&mut self, balance: I) -> StdResult<()> where - I: IntoIterator; + I: IntoIterator; fn inplace_add<'a, I>(&mut self, balance: I) -> StdResult<()> where - I: IntoIterator; + I: IntoIterator; } -impl BTreeMapCoinHelpers for BTreeMap { +impl BTreeMapCoinHelpers for BTreeMap { fn into_vec(self) -> Vec { self.into_iter() .map(|(denom, amount)| Coin { denom, amount }) @@ -22,24 +22,24 @@ impl BTreeMapCoinHelpers for BTreeMap { fn inplace_sub<'a, I>(&mut self, balance: I) -> StdResult<()> where - I: IntoIterator, + I: IntoIterator, { // Decrease total remaining supply for (denom, amount) in balance { if let Some(r) = self.get_mut(denom) { if amount > r { - return Err(StdError::generic_err(format!( + return Err(StdError::msg(format!( "Subtract overflow for denom: {}", denom ))); } *r -= amount; } else { - return Err(StdError::generic_err(format!("Unknown denom {}", denom))); + return Err(StdError::msg(format!("Unknown denom {}", denom))); } // Remove denom if balance is now 0 - if self.get(denom) == Some(&Uint128::zero()) { + if self.get(denom) == Some(&Uint256::zero()) { self.remove(denom); } } @@ -48,12 +48,12 @@ impl BTreeMapCoinHelpers for BTreeMap { fn inplace_add<'a, I>(&mut self, balance: I) -> StdResult<()> where - I: IntoIterator, + I: IntoIterator, { for (denom, amount) in balance { if let Some(counter) = self.get_mut(denom) { *counter = counter.checked_add(*amount).map_err(|_| { - StdError::generic_err(format!("Addition overflow for denom: {}", denom)) + StdError::msg(format!("Addition overflow for denom: {}", denom)) })?; } else { self.insert(denom.clone(), *amount); @@ -64,28 +64,28 @@ impl BTreeMapCoinHelpers for BTreeMap { } pub trait VecCoinConversions { - fn to_tuple_iterator<'a>(&'a self) -> Box + 'a>; + fn to_tuple_iterator<'a>(&'a self) -> Box + 'a>; fn into_map_with_duplicities( self, handle_duplicate: F, - ) -> StdResult> + ) -> StdResult> where - F: Fn(OccupiedEntry, Uint128) -> StdResult<()>; - fn into_map(self) -> StdResult>; + F: Fn(OccupiedEntry, Uint256) -> StdResult<()>; + fn into_map(self) -> StdResult>; fn to_formatted_string(&self) -> String; } impl VecCoinConversions for Vec { - fn to_tuple_iterator<'a>(&'a self) -> Box + 'a> { + fn to_tuple_iterator<'a>(&'a self) -> Box + 'a> { Box::new(self.iter().map(|coin| (&coin.denom, &coin.amount))) } fn into_map_with_duplicities( self, handle_duplicate: F, - ) -> StdResult> + ) -> StdResult> where - F: Fn(OccupiedEntry, Uint128) -> StdResult<()>, + F: Fn(OccupiedEntry, Uint256) -> StdResult<()>, { let mut denom_map = BTreeMap::new(); @@ -103,12 +103,9 @@ impl VecCoinConversions for Vec { Ok(denom_map) } - fn into_map(self) -> StdResult> { + fn into_map(self) -> StdResult> { self.into_map_with_duplicities(|e, _| { - Err(StdError::generic_err(format!( - "Duplicate denom found: {}", - e.key() - ))) + Err(StdError::msg(format!("Duplicate denom found: {}", e.key()))) }) } @@ -123,14 +120,14 @@ impl VecCoinConversions for Vec { #[cfg(test)] mod tests { use super::*; - use cosmwasm_std::{coin, Uint128}; + use cosmwasm_std::coin; use std::collections::BTreeMap; #[test] fn test_into_vec() { let mut map = BTreeMap::new(); - map.insert("atom".to_string(), Uint128::new(100)); - map.insert("btc".to_string(), Uint128::new(50)); + map.insert("atom".to_string(), Uint256::new(100)); + map.insert("btc".to_string(), Uint256::new(50)); let vec = map.into_vec(); assert_eq!(vec, vec![coin(100, "atom"), coin(50, "btc")]); @@ -139,50 +136,50 @@ mod tests { #[test] fn test_inplace_sub() { let mut map = BTreeMap::new(); - map.insert("atom".to_string(), Uint128::new(100)); - map.insert("btc".to_string(), Uint128::new(50)); + map.insert("atom".to_string(), Uint256::new(100)); + map.insert("btc".to_string(), Uint256::new(50)); let balance = vec![ - ("atom".to_string(), Uint128::new(30)), - ("btc".to_string(), Uint128::new(20)), + ("atom".to_string(), Uint256::new(30)), + ("btc".to_string(), Uint256::new(20)), ]; map.inplace_sub(balance.iter().map(|(d, a)| (d, a))) .unwrap(); - assert_eq!(map.get("atom"), Some(&Uint128::new(70))); - assert_eq!(map.get("btc"), Some(&Uint128::new(30))); + assert_eq!(map.get("atom"), Some(&Uint256::new(70))); + assert_eq!(map.get("btc"), Some(&Uint256::new(30))); } #[test] fn test_inplace_sub_overflow() { let mut map = BTreeMap::new(); - map.insert("atom".to_string(), Uint128::new(100)); + map.insert("atom".to_string(), Uint256::new(100)); - let balance = vec![("atom".to_string(), Uint128::new(150))]; + let balance = vec![("atom".to_string(), Uint256::new(150))]; let result = map.inplace_sub(balance.iter().map(|(d, a)| (d, a))); assert_eq!( - result.err(), - Some(StdError::generic_err("Subtract overflow for denom: atom")) + result.err().unwrap().to_string(), + StdError::msg("Subtract overflow for denom: atom").to_string() ); } #[test] fn test_inplace_add() { let mut map = BTreeMap::new(); - map.insert("atom".to_string(), Uint128::new(100)); - map.insert("btc".to_string(), Uint128::new(50)); + map.insert("atom".to_string(), Uint256::new(100)); + map.insert("btc".to_string(), Uint256::new(50)); let balance = vec![ - ("atom".to_string(), Uint128::new(30)), - ("btc".to_string(), Uint128::new(20)), - ("eth".to_string(), Uint128::new(10)), + ("atom".to_string(), Uint256::new(30)), + ("btc".to_string(), Uint256::new(20)), + ("eth".to_string(), Uint256::new(10)), ]; assert!(map.inplace_add(balance.iter().map(|(d, a)| (d, a))).is_ok()); - assert_eq!(map.get("atom"), Some(&Uint128::new(130))); - assert_eq!(map.get("btc"), Some(&Uint128::new(70))); - assert_eq!(map.get("eth"), Some(&Uint128::new(10))); + assert_eq!(map.get("atom"), Some(&Uint256::new(130))); + assert_eq!(map.get("btc"), Some(&Uint256::new(70))); + assert_eq!(map.get("eth"), Some(&Uint256::new(10))); } #[test] @@ -190,8 +187,8 @@ mod tests { let vec = vec![coin(100, "atom"), coin(50, "btc")]; let mut iter = vec.to_tuple_iterator(); - assert_eq!(iter.next(), Some((&"atom".to_string(), &Uint128::new(100)))); - assert_eq!(iter.next(), Some((&"btc".to_string(), &Uint128::new(50)))); + assert_eq!(iter.next(), Some((&"atom".to_string(), &Uint256::new(100)))); + assert_eq!(iter.next(), Some((&"btc".to_string(), &Uint256::new(50)))); assert_eq!(iter.next(), None); } @@ -202,8 +199,8 @@ mod tests { .into_map_with_duplicities(|mut e, new_value| Ok(*e.get_mut() += new_value)) .unwrap(); - assert_eq!(map.get("atom"), Some(&Uint128::new(100))); - assert_eq!(map.get("btc"), Some(&Uint128::new(100))); + assert_eq!(map.get("atom"), Some(&Uint256::new(100))); + assert_eq!(map.get("btc"), Some(&Uint256::new(100))); } #[test] @@ -221,9 +218,9 @@ mod tests { let balance = vec![coin(30, "atom"), coin(20, "btc"), coin(10, "eth")]; assert!(map.inplace_add(balance.to_tuple_iterator()).is_ok()); - assert_eq!(map.get("atom"), Some(&Uint128::new(30))); - assert_eq!(map.get("btc"), Some(&Uint128::new(20))); - assert_eq!(map.get("eth"), Some(&Uint128::new(10))); + assert_eq!(map.get("atom"), Some(&Uint256::new(30))); + assert_eq!(map.get("btc"), Some(&Uint256::new(20))); + assert_eq!(map.get("eth"), Some(&Uint256::new(10))); assert!(map.inplace_sub(balance.to_tuple_iterator()).is_ok()); @@ -232,32 +229,32 @@ mod tests { #[test] fn test_subtracting_nonexistent_denom() { let mut map = BTreeMap::new(); - map.insert("atom".to_string(), Uint128::new(100)); + map.insert("atom".to_string(), Uint256::new(100)); - let balance = vec![("btc".to_string(), Uint128::new(50))]; + let balance = vec![("btc".to_string(), Uint256::new(50))]; let result = map.inplace_sub(balance.iter().map(|(d, a)| (d, a))); assert!(result.is_err()); assert_eq!( - result.err(), - Some(StdError::generic_err("Unknown denom btc")) + result.err().unwrap().to_string(), + StdError::msg("Unknown denom btc").to_string() ); } #[test] fn test_addition_with_overflow() { let mut map = BTreeMap::new(); - map.insert("atom".to_string(), Uint128::new(u128::MAX)); + map.insert("atom".to_string(), Uint256::MAX); - let balance = vec![("atom".to_string(), Uint128::new(1))]; + let balance = vec![("atom".to_string(), Uint256::new(1))]; let result = map.inplace_add(balance.iter().map(|(d, a)| (d, a))); assert_eq!( - result.err(), - Some(StdError::generic_err("Addition overflow for denom: atom")) + result.err().unwrap().to_string(), + StdError::msg("Addition overflow for denom: atom").to_string() ); - assert_eq!(map.get("atom"), Some(&Uint128::new(u128::MAX))); + assert_eq!(map.get("atom"), Some(&Uint256::MAX)); } #[test] @@ -325,11 +322,11 @@ mod tests { ] ); - assert_eq!(map.get("atom"), Some(&Uint128::new(100))); - assert_eq!(map.get("btc"), Some(&Uint128::new(50))); - assert_eq!(map.get("eth"), Some(&Uint128::new(200))); - assert_eq!(map.get("usd"), Some(&Uint128::new(150))); - assert_eq!(map.get("eur"), Some(&Uint128::new(75))); + assert_eq!(map.get("atom"), Some(&Uint256::new(100))); + assert_eq!(map.get("btc"), Some(&Uint256::new(50))); + assert_eq!(map.get("eth"), Some(&Uint256::new(200))); + assert_eq!(map.get("usd"), Some(&Uint256::new(150))); + assert_eq!(map.get("eur"), Some(&Uint256::new(75))); } #[test] @@ -346,7 +343,10 @@ mod tests { assert!(result.is_err()); if let Err(err) = result { - assert_eq!(err, StdError::generic_err("Duplicate denom found: btc")); + assert_eq!( + err.to_string(), + StdError::msg("Duplicate denom found: btc").to_string() + ); } } diff --git a/src/crypto/encoding.rs b/src/crypto/encoding.rs index df91d6f..ea78f03 100644 --- a/src/crypto/encoding.rs +++ b/src/crypto/encoding.rs @@ -34,12 +34,12 @@ pub fn encode_bech32(prefix: &str, data: &[u8]) -> Result { // Errors pub fn prefix_error(expected: &str, actual: &str) -> StdError { - StdError::generic_err(format!( + StdError::msg(format!( "Wrong prefix. Expected {}, got {}.", expected, actual )) } pub fn base32_parsing_error(err: &T) -> StdError { - StdError::generic_err(format!("Base32 parsing failed: {}", err)) + StdError::msg(format!("Base32 parsing failed: {}", err)) } diff --git a/src/crypto/ethereum.rs b/src/crypto/ethereum.rs index 7933e68..d1d1545 100644 --- a/src/crypto/ethereum.rs +++ b/src/crypto/ethereum.rs @@ -164,11 +164,11 @@ pub fn recover_pubkey_secp256k1( // Errors pub fn signature_error(err: &T) -> StdError { - StdError::generic_err(format!("Eth signature error {}", err)) + StdError::msg(format!("Eth signature error {}", err)) } pub fn addresses_error(err: &T) -> StdError { - StdError::generic_err(format!("Eth address error {}", err)) + StdError::msg(format!("Eth address error {}", err)) } #[cfg(test)] @@ -296,7 +296,10 @@ mod tests { let fetch_address = cosmos_address_from_pubkey_secp256k1(&compressed_pubkey, "fetch").unwrap(); - assert_eq!(fetch_address, expected_fetch_address); + assert_eq!( + fetch_address.to_string(), + expected_fetch_address.to_string() + ); } #[test] diff --git a/src/crypto/secp256k1.rs b/src/crypto/secp256k1.rs index 1238396..b58336c 100644 --- a/src/crypto/secp256k1.rs +++ b/src/crypto/secp256k1.rs @@ -37,5 +37,5 @@ pub fn to_compressed_key(pubkey: &[u8]) -> StdResult { // Error pub fn pubkey_error(err: &T) -> StdError { - StdError::generic_err(format!("Secp256k1 pubkey error {}", err)) + StdError::msg(format!("Secp256k1 pubkey error {}", err)) } diff --git a/src/pausing/errors.rs b/src/pausing/errors.rs index c20611a..2c8fe97 100644 --- a/src/pausing/errors.rs +++ b/src/pausing/errors.rs @@ -4,5 +4,5 @@ use cosmwasm_std::StdError; const ERR_CONTRACT_PAUSED: &str = "[FET_ERR_CONTRACT_PAUSED] Contract is paused"; pub fn contract_paused_error() -> StdError { - StdError::generic_err(ERR_CONTRACT_PAUSED) + StdError::msg(ERR_CONTRACT_PAUSED) } diff --git a/src/permissions/private.rs b/src/permissions/private.rs index 644cfa4..e2f7ad3 100644 --- a/src/permissions/private.rs +++ b/src/permissions/private.rs @@ -12,5 +12,5 @@ pub fn ensure_private(env: &Env, address: &Addr) -> StdResult<()> { } pub fn not_self_contract_error() -> StdError { - StdError::generic_err(ERR_NOT_SELF_CONTRACT) + StdError::msg(ERR_NOT_SELF_CONTRACT) } diff --git a/src/permissions/superadmin.rs b/src/permissions/superadmin.rs index a4e00de..a7316e0 100644 --- a/src/permissions/superadmin.rs +++ b/src/permissions/superadmin.rs @@ -25,5 +25,5 @@ pub fn ensure_super_admin(deps: &Deps, env: &Env, address: &Addr) -> StdResult<( } pub fn not_super_admin_error() -> StdError { - StdError::generic_err(ERR_NOT_SUPER_ADMIN) + StdError::msg(ERR_NOT_SUPER_ADMIN) } diff --git a/src/testing/helpers.rs b/src/testing/helpers.rs index 29ffd94..b32aa16 100644 --- a/src/testing/helpers.rs +++ b/src/testing/helpers.rs @@ -1,9 +1,8 @@ use cosmwasm_std::testing::{mock_dependencies, mock_env, MockApi, MockQuerier, MockStorage}; use cosmwasm_std::{ - to_json_binary, Addr, ContractInfoResponse, Empty, Env, OwnedDeps, SystemError, SystemResult, - WasmQuery, + to_json_binary, Addr, Empty, Env, OwnedDeps, SystemError, SystemResult, Uint256, WasmQuery, }; -use cosmwasm_std::{BankMsg, Coin, ContractResult as StdContractResult, Response, SubMsg, Uint128}; +use cosmwasm_std::{BankMsg, Coin, ContractResult as StdContractResult, Response, SubMsg}; pub fn deps_with_creator( creator: Addr, @@ -11,27 +10,37 @@ pub fn deps_with_creator( ) -> OwnedDeps { let mut deps = mock_dependencies(); let mut querier = MockQuerier::default(); + + // clone values into the closure + let creator_for_closure = creator.clone(); + let contract_address_for_closure = contract_address.clone(); + querier.update_wasm(move |request| match request { WasmQuery::ContractInfo { contract_addr } => { - if contract_addr == contract_address.as_str() { - let mut response = ContractInfoResponse::default(); - response.admin = Some(creator.to_string()); - SystemResult::Ok(StdContractResult::Ok(to_json_binary(&response).unwrap())) + if contract_addr == contract_address_for_closure.as_str() { + // Return JSON directly instead of constructing ContractInfoResponse (non_exhaustive) + let payload = serde_json::json!({ + "code_id": 0u64, + "creator": creator_for_closure.as_str(), + "admin": creator_for_closure.as_str(), + "pinned": false, + "ibc_port": null, + "ibc2_port": null + }); + + SystemResult::Ok(StdContractResult::Ok(to_json_binary(&payload).unwrap())) } else { SystemResult::Err(SystemError::NoSuchContract { addr: contract_addr.clone(), }) } } - - _ => { - panic!() - } + _ => panic!("unexpected wasm query: {request:?}"), }); + deps.querier = querier; deps } - pub fn assert_err(result: &Result, error: &E) { // Check if result contains specific error match result { @@ -45,7 +54,7 @@ pub fn assert_transfer(res: &Response, address: &Addr, amount: &u128, denom: &st to_address: address.to_string(), amount: vec![Coin { denom: denom.to_string(), - amount: Uint128::new(*amount), + amount: Uint256::new(*amount), }], }); From 7ff2d20e7e1988432b498175d268f390042bbf66 Mon Sep 17 00:00:00 2001 From: Jiri Date: Mon, 15 Dec 2025 14:30:18 +0100 Subject: [PATCH 2/4] Update query hybrid derive --- query-responses-hybrid-derive/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query-responses-hybrid-derive/Cargo.toml b/query-responses-hybrid-derive/Cargo.toml index 12052d9..8089e89 100644 --- a/query-responses-hybrid-derive/Cargo.toml +++ b/query-responses-hybrid-derive/Cargo.toml @@ -12,4 +12,4 @@ quote = "1.0" [dev-dependencies] schemars = "0.8.10" -cosmwasm-schema = "1.5.3" \ No newline at end of file +cosmwasm-schema = "3.0.2" \ No newline at end of file From f4593adcdd8547dd5cb440fb827f8e20596e69e5 Mon Sep 17 00:00:00 2001 From: Jiri Date: Mon, 15 Dec 2025 14:43:09 +0100 Subject: [PATCH 3/4] hybrid response fix --- query-responses-hybrid-derive/.gitignore | 17 + query-responses-hybrid-derive/Cargo.lock | 350 ++++++++++++++++-- query-responses-hybrid-derive/src/lib.rs | 237 ++++++++---- .../tests/integration.rs | 2 +- 4 files changed, 507 insertions(+), 99 deletions(-) create mode 100644 query-responses-hybrid-derive/.gitignore diff --git a/query-responses-hybrid-derive/.gitignore b/query-responses-hybrid-derive/.gitignore new file mode 100644 index 0000000..21a3a58 --- /dev/null +++ b/query-responses-hybrid-derive/.gitignore @@ -0,0 +1,17 @@ +# Build results +/target +/schema +/artifacts + +# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327) +.cargo-ok + +# Text file backups +**/*.rs.bk + +# macOS +.DS_Store + +# IDEs +*.iml +.idea diff --git a/query-responses-hybrid-derive/Cargo.lock b/query-responses-hybrid-derive/Cargo.lock index 2e30adf..5df9a50 100644 --- a/query-responses-hybrid-derive/Cargo.lock +++ b/query-responses-hybrid-derive/Cargo.lock @@ -1,15 +1,16 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "cosmwasm-schema" -version = "1.5.11" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5526ea839acb47bbf8fff031ed9aad86e74d43f77b089255417328c3664367d5" +checksum = "52d8808bf9fb8f4d5ee62e808b3e1dcdf6a116e9e1fe934507a4e0a4135ae941" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.22", "serde", "serde_json", "thiserror", @@ -17,20 +18,162 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.11" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f41b99f41f840765d02ae858956bb52af910755976312082e90493c67db512" +checksum = "9718a856ff5edb6537ac889ff695abc576304bc25cb7b16ef4c762e10a0149ba" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", +] + +[[package]] +name = "cw-schema" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8f335d3f51e10260f4dfb0840f0526c1d25c6b42a9489c04ce41ed9aa54dd6d" +dependencies = [ + "cw-schema-derive", + "indexmap", + "schemars 1.1.0", + "serde", + "serde_with", + "siphasher", + "typeid", +] + +[[package]] +name = "cw-schema-derive" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aba2eb93f854caeacc5eda13d15663b7605395514fd378bfba8e7532f1fc5865" +dependencies = [ + "heck", + "itertools", + "owo-colors", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "darling" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" +dependencies = [ + "darling_core", + "quote", + "syn", ] [[package]] name = "dyn-clone" -version = "1.0.19" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "equivalent" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "is-terminal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] [[package]] name = "itoa" @@ -38,17 +181,33 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "libc" +version = "0.2.178" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" + [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "owo-colors" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" +dependencies = [ + "supports-color 2.1.0", + "supports-color 3.0.2", +] [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] @@ -59,19 +218,39 @@ version = "0.1.0" dependencies = [ "cosmwasm-schema", "quote", - "schemars", - "syn 2.0.100", + "schemars 0.8.22", + "syn", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "ryu" version = "1.0.20" @@ -85,7 +264,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.22", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.1.0", "serde", "serde_json", ] @@ -99,27 +291,49 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.100", + "syn", +] + +[[package]] +name = "schemars_derive" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301858a4023d78debd2353c7426dc486001bddc91ae31a76fb1f55132f7e2633" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", ] [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -130,37 +344,80 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] -name = "syn" -version = "1.0.109" +name = "serde_with" +version = "3.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fa237f2807440d238e0364a218270b98f767a00d3dada77b1c53ae88940e2e7" +dependencies = [ + "serde_core", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "52a8e3ca0ca629121f70ab50f95249e5a6f925cc0f6ffe8256c45b728875706c" dependencies = [ + "darling", "proc-macro2", "quote", - "unicode-ident", + "syn", +] + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + +[[package]] +name = "supports-color" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" +dependencies = [ + "is_ci", ] [[package]] name = "syn" -version = "2.0.100" +version = "2.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" dependencies = [ "proc-macro2", "quote", @@ -184,11 +441,32 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] diff --git a/query-responses-hybrid-derive/src/lib.rs b/query-responses-hybrid-derive/src/lib.rs index 8f885e6..27154b7 100644 --- a/query-responses-hybrid-derive/src/lib.rs +++ b/query-responses-hybrid-derive/src/lib.rs @@ -1,13 +1,16 @@ use proc_macro::TokenStream; use quote::quote; -use syn::{parse_macro_input, Data, DeriveInput, Fields}; - -// This code is based on https://github.com/CosmWasm/cosmwasm/blob/v1.5.3/packages/schema-derive/src/query_responses.rs +use syn::{ + parse_macro_input, parse_quote, Data, DeriveInput, Expr, Fields, Generics, Type, + TypeParamBound, Variant, +}; #[proc_macro_derive(QueryResponsesHybrid, attributes(returns, nested))] pub fn derive_query_responses_hybrid(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - let enum_name = input.ident; + + let enum_name = input.ident.clone(); + let generics = input.generics.clone(); let Data::Enum(data_enum) = input.data else { return syn::Error::new_spanned( @@ -18,67 +21,58 @@ pub fn derive_query_responses_hybrid(input: TokenStream) -> TokenStream { .into(); }; - let mut variant_handlers = Vec::new(); - - for variant in data_enum.variants { - let variant_name = variant.ident; - let variant_str = to_snake_case(&variant_name.to_string()); - - let returns_attr = variant.attrs.iter().find(|a| a.path().is_ident("returns")); - let is_nested = variant.attrs.iter().any(|a| a.path().is_ident("nested")); - - if let Some(attr) = returns_attr { - // #[returns(Type)] - let meta = attr - .parse_args::() - .expect("Failed to parse #[returns(Type)]"); - variant_handlers.push(quote! { - map.insert(#variant_str.to_string(), ::cosmwasm_schema::schema_for!(#meta)); - }); - } else if is_nested { - let Fields::Unnamed(fields) = variant.fields else { - return syn::Error::new_spanned( - variant_name, - "#[nested] variant must be tuple-like", - ) - .to_compile_error() - .into(); - }; - if fields.unnamed.len() != 1 { - return syn::Error::new_spanned( - variant_name, - "#[nested] variant must have exactly one field", - ) - .to_compile_error() - .into(); - } - let nested_type = &fields.unnamed.first().unwrap().ty; + // hardcoded like your old macro; if you want it configurable, swap this to a parsed Path + let crate_name: syn::Path = parse_quote!(::cosmwasm_schema); - variant_handlers.push(quote! { - for (k, v) in <#nested_type as ::cosmwasm_schema::QueryResponses>::response_schemas_impl() { - if map.insert(k.clone(), v).is_some() { - panic!("duplicate query name '{}'", k); - } - } - }); - } else { - return syn::Error::new_spanned( - variant_name, - "Missing #[returns(...)] or #[nested] attribute", - ) - .to_compile_error() - .into(); - } - } + // For hybrid enums we always "combine subqueries", even for #[returns(...)]. + // That allows mixing #[returns] and #[nested] variants in the same enum. + let subquery_calls_json: Vec = match data_enum + .variants + .iter() + .map(|v| parse_hybrid_variant(&crate_name, v, SchemaBackend::JsonSchema)) + .collect::>>() + { + Ok(v) => v, + Err(e) => return e.to_compile_error().into(), + }; + + let subquery_calls_cw: Vec = match data_enum + .variants + .iter() + .map(|v| parse_hybrid_variant(&crate_name, v, SchemaBackend::CwSchema)) + .collect::>>() + { + Ok(v) => v, + Err(e) => return e.to_compile_error().into(), + }; + + // Generics handling: match cosmwasm-schema 3.x style + let (_, type_generics, where_clause) = generics.split_for_impl(); + let impl_generics = impl_generics( + &crate_name, + &generics, + &[parse_quote! { #crate_name::QueryResponses }], + &[], + ); + + let subquery_len = subquery_calls_json.len(); let expanded = quote! { #[automatically_derived] #[cfg(not(target_arch = "wasm32"))] - impl ::cosmwasm_schema::QueryResponses for #enum_name { - fn response_schemas_impl() -> ::std::collections::BTreeMap { - let mut map = ::std::collections::BTreeMap::new(); - #(#variant_handlers)* - map + impl #impl_generics #crate_name::QueryResponses for #enum_name #type_generics #where_clause { + fn response_schemas() -> ::std::collections::BTreeMap { + let subqueries = [ + #( #subquery_calls_json, )* + ]; + #crate_name::combine_subqueries::<#subquery_len, #enum_name #type_generics, _>(subqueries) + } + + fn response_schemas_cw() -> ::std::collections::BTreeMap { + let subqueries = [ + #( #subquery_calls_cw, )* + ]; + #crate_name::combine_subqueries::<#subquery_len, #enum_name #type_generics, _>(subqueries) } } }; @@ -86,9 +80,128 @@ pub fn derive_query_responses_hybrid(input: TokenStream) -> TokenStream { TokenStream::from(expanded) } -/// Converts a variant name into the specified casing +#[derive(Copy, Clone)] +enum SchemaBackend { + JsonSchema, + CwSchema, +} + +/// Hybrid variant parser: +/// - #[returns(T)] => returns a single-entry BTreeMap +/// - #[nested] (SubQueryType) => returns SubQueryType::response_schemas*() +fn parse_hybrid_variant( + crate_name: &syn::Path, + v: &Variant, + schema_backend: SchemaBackend, +) -> syn::Result { + let query = to_snake_case(&v.ident.to_string()); + + let returns_attr = v.attrs.iter().find(|a| a.path().is_ident("returns")); + let is_nested = v.attrs.iter().any(|a| a.path().is_ident("nested")); + + match (returns_attr, is_nested) { + (Some(attr), false) => { + let response_ty: Type = attr + .parse_args() + .map_err(|e| syn::Error::new(e.span(), "return must be a type"))?; + + let schema_expr: Expr = match schema_backend { + SchemaBackend::JsonSchema => parse_quote!(#crate_name::schema_for!(#response_ty)), + SchemaBackend::CwSchema => { + parse_quote!(#crate_name::cw_schema::schema_of::<#response_ty>()) + } + }; + + // Return a map with single entry for this query + Ok(parse_quote!({ + let mut m = ::std::collections::BTreeMap::new(); + m.insert(#query.to_string(), #schema_expr); + m + })) + } + + (None, true) => { + let sub_ty = match &v.fields { + Fields::Unnamed(fields) if fields.unnamed.len() == 1 => &fields.unnamed[0].ty, + Fields::Unnamed(fields) => { + return Err(syn::Error::new_spanned( + fields, + "#[nested] variant must have exactly one field", + )); + } + Fields::Named(_) => { + return Err(syn::Error::new_spanned( + v, + "a struct variant is not a valid subquery", + )); + } + Fields::Unit => { + return Err(syn::Error::new_spanned( + v, + "a unit variant is not a valid subquery", + )); + } + }; + + let call: Expr = match schema_backend { + SchemaBackend::JsonSchema => { + parse_quote!(<#sub_ty as #crate_name::QueryResponses>::response_schemas()) + } + SchemaBackend::CwSchema => { + parse_quote!(<#sub_ty as #crate_name::QueryResponses>::response_schemas_cw()) + } + }; + + Ok(call) + } + + (Some(_), true) => Err(syn::Error::new_spanned( + v, + "variant cannot have both #[returns(...)] and #[nested]", + )), + + (None, false) => Err(syn::Error::new_spanned( + v, + "missing #[returns(...)] or #[nested] attribute", + )), + } +} + +/// Takes generics from the type definition and produces generics for the expanded `impl`, +/// adding bounds similarly to cosmwasm-schema 3.x. +/// +/// `extra_bounds_on_type_params` are appended to every type parameter unless excluded. +/// (Here we default to none; adapt if you want `#[no_bounds_for(T)]` support.) +fn impl_generics( + crate_name: &syn::Path, + generics: &Generics, + extra_bounds_on_type_params: &[TypeParamBound], + no_bounds_for: &[syn::Ident], +) -> Generics { + let mut impl_generics = generics.to_owned(); + + for param in impl_generics.type_params_mut() { + param.default = None; + + if no_bounds_for.iter().any(|id| id == ¶m.ident) { + continue; + } + + param + .bounds + .push(parse_quote!(#crate_name::schemars::JsonSchema)); + param + .bounds + .push(parse_quote!(#crate_name::cw_schema::Schemaifier)); + param + .bounds + .extend(extra_bounds_on_type_params.iter().cloned()); + } + + impl_generics +} + fn to_snake_case(input: &str) -> String { - // this was stolen from serde for consistent behavior let mut snake = String::new(); for (i, ch) in input.char_indices() { if i > 0 && ch.is_uppercase() { diff --git a/query-responses-hybrid-derive/tests/integration.rs b/query-responses-hybrid-derive/tests/integration.rs index d10e7d4..5a2c829 100644 --- a/query-responses-hybrid-derive/tests/integration.rs +++ b/query-responses-hybrid-derive/tests/integration.rs @@ -39,7 +39,7 @@ struct MyResponse { #[test] fn hybrid_derive_works_and_respects_snake_case() { - let map: BTreeMap = ::response_schemas_impl(); + let map: BTreeMap = ::response_schemas(); let keys: Vec = map.keys().cloned().collect(); assert!(keys.contains(&"my_field".to_string())); From 562cd7b7264ee4bdb10820fa02b03aa3b30d4438 Mon Sep 17 00:00:00 2001 From: Jiri Date: Mon, 15 Dec 2025 16:11:07 +0100 Subject: [PATCH 4/4] Error backtraces fix --- src/testing/helpers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/testing/helpers.rs b/src/testing/helpers.rs index b32aa16..6b69ff1 100644 --- a/src/testing/helpers.rs +++ b/src/testing/helpers.rs @@ -41,11 +41,11 @@ pub fn deps_with_creator( deps.querier = querier; deps } -pub fn assert_err(result: &Result, error: &E) { +pub fn assert_err(result: &Result, error: &E) { // Check if result contains specific error match result { Ok(_) => panic!("Expected Err, got Ok"), - Err(res_error) => assert_eq!(format!("{:?}", res_error), format!("{:?}", error)), + Err(res_error) => assert_eq!(res_error.to_string(), error.to_string()), } }