From b0ba49a58826a0a5d2f92bd1fa986860ec2bb33c Mon Sep 17 00:00:00 2001 From: bwty Date: Tue, 23 Sep 2025 18:02:03 +0100 Subject: [PATCH 01/16] wip --- Cargo.lock | 488 +++++++++++++----- Cargo.toml | 16 +- contracts/anoncreds-verifier/Cargo.toml | 4 +- contracts/avida_example/Cargo.toml | 2 +- contracts/avida_example/src/contract.rs | 36 +- contracts/avida_example/src/error.rs | 8 +- contracts/sdjwt-verifier/Cargo.toml | 2 +- contracts/sdjwt-verifier/src/errors.rs | 8 +- .../sdjwt-verifier/src/tests/contract_test.rs | 10 +- .../src/tests/verifier_exp_test.rs | 12 +- .../src/tests/verifier_register_test.rs | 24 +- .../src/tests/verifier_update_test.rs | 8 +- .../src/tests/verifier_verify_test.rs | 8 +- contracts/sdjwt-verifier/src/types.rs | 5 +- contracts/sdjwt-verifier/src/verifier.rs | 102 ++-- packages/anoncreds/src/tests/types.rs | 8 +- packages/avida_test_utils/Cargo.toml | 2 +- packages/cheqd/src/ibc.rs | 16 +- 18 files changed, 508 insertions(+), 251 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9310585..243ab6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,9 +43,9 @@ checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "ark-bls12-381" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +checksum = "3df4dcc01ff89867cd86b0da835f23c3f02738353aaee7dde7495af71363b8d5" dependencies = [ "ark-ec", "ark-ff", @@ -55,17 +55,21 @@ dependencies = [ [[package]] name = "ark-ec" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce" dependencies = [ + "ahash", "ark-ff", "ark-poly", "ark-serialize", "ark-std", - "derivative", - "hashbrown 0.13.2", - "itertools 0.10.5", + "educe", + "fnv", + "hashbrown 0.15.2", + "itertools 0.13.0", + "num-bigint", + "num-integer", "num-traits", "rayon", "zeroize", @@ -73,95 +77,105 @@ dependencies = [ [[package]] name = "ark-ff" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70" dependencies = [ "ark-ff-asm", "ark-ff-macros", "ark-serialize", "ark-std", - "derivative", + "arrayvec", "digest", - "itertools 0.10.5", + "educe", + "itertools 0.13.0", "num-bigint", "num-traits", "paste", "rayon", - "rustc_version", "zeroize", ] [[package]] name = "ark-ff-asm" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" dependencies = [ "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "ark-ff-macros" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3" dependencies = [ "num-bigint", "num-traits", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "ark-poly" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27" dependencies = [ + "ahash", "ark-ff", "ark-serialize", "ark-std", - "derivative", - "hashbrown 0.13.2", + "educe", + "fnv", + "hashbrown 0.15.2", ] [[package]] name = "ark-serialize" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7" dependencies = [ "ark-serialize-derive", "ark-std", + "arrayvec", "digest", "num-bigint", + "rayon", ] [[package]] name = "ark-serialize-derive" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "ark-std" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +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.4.0" @@ -185,7 +199,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", - "schemars", + "schemars 0.8.22", "serde", "thiserror 1.0.69", ] @@ -205,7 +219,7 @@ dependencies = [ "cw2", "josekit", "jsonwebtoken 9.3.1", - "schemars", + "schemars 0.8.22", "sd-jwt-rs 0.7.1", "serde", "serde_json", @@ -227,7 +241,7 @@ dependencies = [ "cw2", "josekit", "jsonwebtoken 9.3.0", - "schemars", + "schemars 0.8.22", "sd-jwt-rs 0.7.0", "serde", "serde_json", @@ -344,15 +358,15 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "cosmwasm-core" -version = "2.2.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35b6dc17e7fd89d0a0a58f12ef33f0bbdf09a6a14c3dfb383eae665e5889250e" +checksum = "9b0a718b13ffe224e32a8c1f68527354868f47d6cc84afe8c66cb05fbb3ced6e" [[package]] name = "cosmwasm-crypto" -version = "2.2.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2f53285517db3e33d825b3e46301efe845135778527e1295154413b2f0469e" +checksum = "3c08dd7585b5c48fbcb947ada7a3fb49465fb735481ed295b54ca98add6dc17f" dependencies = [ "ark-bls12-381", "ark-ec", @@ -364,6 +378,7 @@ dependencies = [ "ecdsa", "ed25519-zebra", "k256", + "num-bigint", "num-traits", "p256", "rand_core", @@ -374,23 +389,24 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "2.2.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a782b93fae93e57ca8ad3e9e994e784583f5933aeaaa5c80a545c4b437be2047" +checksum = "5677eed823a61eeb615b1ad4915a42336b70b0fe3f87bf3da4b59f3dcf9034af" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] name = "cosmwasm-schema" -version = "2.2.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6984ab21b47a096e17ae4c73cea2123a704d4b6686c39421247ad67020d76f95" +checksum = "52d8808bf9fb8f4d5ee62e808b3e1dcdf6a116e9e1fe934507a4e0a4135ae941" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.22", "serde", "serde_json", "thiserror 1.0.69", @@ -398,20 +414,20 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "2.2.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01c9214319017f6ebd8e299036e1f717fa9bb6724e758f7d6fb2477599d1a29" +checksum = "9718a856ff5edb6537ac889ff695abc576304bc25cb7b16ef4c762e10a0149ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] name = "cosmwasm-std" -version = "2.2.2" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf82335c14bd94eeb4d3c461b7aa419ecd7ea13c2efe24b97cd972bdb8044e7d" +checksum = "d4881104f54871bcea6f30757bee13b7f09c0998d1b0de133cce5a52336a2ada" dependencies = [ "base64 0.22.1", "bech32", @@ -419,13 +435,14 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.22", "serde", - "serde-json-wasm", + "serde_json", "sha2", "static_assertions", "thiserror 1.0.69", @@ -520,16 +537,15 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] name = "cw-multi-test" -version = "2.3.2" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "533b31c94b9e10e77e2468a2b1559aa506505d18c4e52eb64cbfc624ca876ad2" +checksum = "cf9875e88f5b67dbaf729da99a7de4acd593d18d6d8ee83c8006e09dd865745e" dependencies = [ - "anyhow", "bech32", "cosmwasm-schema", "cosmwasm-std", @@ -537,49 +553,112 @@ dependencies = [ "cw-utils", "itertools 0.14.0", "prost", - "schemars", + "schemars 0.8.22", "serde", "sha2", - "thiserror 2.0.12", +] + +[[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.0.4", + "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 0.5.0", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "cw-storage-plus" -version = "2.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" +checksum = "75d840d773b4ffd60ff005375e5e15e4be4fda54620574e861bfbb61a074f353" dependencies = [ "cosmwasm-std", - "schemars", + "schemars 0.8.22", "serde", ] [[package]] name = "cw-utils" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" +checksum = "8667e96f2c65cf7f4c6c66bfd6ee46909c40827bc1caea0409234e34f03cf061" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "schemars", + "schemars 0.8.22", "serde", - "thiserror 1.0.69", + "thiserror 2.0.12", ] [[package]] name = "cw2" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" +checksum = "50582114ab739724c25a27cea1785351f2b5fea7968214302e0023ee2c0e8b39" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus", - "schemars", + "schemars 0.8.22", "semver", "serde", - "thiserror 1.0.69", + "thiserror 2.0.12", +] + +[[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]] @@ -601,35 +680,24 @@ dependencies = [ "powerfmt", ] -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "derive_more" -version = "1.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" dependencies = [ "derive_more-impl", ] [[package]] name = "derive_more-impl" -version = "1.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", "unicode-xid", ] @@ -703,6 +771,18 @@ dependencies = [ "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" @@ -727,6 +807,26 @@ dependencies = [ "zeroize", ] +[[package]] +name = "enum-ordinalize" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -759,6 +859,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "foreign-types" version = "0.3.2" @@ -809,15 +915,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.14.5" @@ -833,6 +930,9 @@ name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "allocator-api2", +] [[package]] name = "heck" @@ -840,6 +940,18 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[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" @@ -855,6 +967,12 @@ dependencies = [ "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.8.0" @@ -865,11 +983,28 @@ dependencies = [ "hashbrown 0.15.2", ] +[[package]] +name = "is-terminal" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" +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.10.5" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -1047,7 +1182,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -1062,6 +1197,16 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "owo-colors" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" +dependencies = [ + "supports-color 2.1.0", + "supports-color 3.0.2", +] + [[package]] name = "p256" version = "0.13.2" @@ -1141,9 +1286,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.5" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +checksum = "7231bd9b3d3d33c86b58adbac74b5ec0ad9f496b19d22801d773636feaa95f3d" dependencies = [ "bytes", "prost-derive", @@ -1151,15 +1296,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.5" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" dependencies = [ "anyhow", "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -1221,6 +1366,26 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "ref-cast" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.11.1" @@ -1324,7 +1489,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.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.4", "serde", "serde_json", ] @@ -1338,7 +1516,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.100", + "syn", +] + +[[package]] +name = "schemars_derive" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", ] [[package]] @@ -1402,15 +1592,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-json-wasm" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" version = "1.0.219" @@ -1419,7 +1600,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -1430,7 +1611,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -1446,11 +1627,34 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c522100790450cf78eeac1507263d0a350d4d5b30df0c8e1fe051a10c22b376e" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327ada00f7d64abaac1e55a6911e90cf665aa051b9a561c7006c157f4633135e" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sha2" -version = "0.10.8" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures", @@ -1485,6 +1689,12 @@ dependencies = [ "time", ] +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "spki" version = "0.7.3" @@ -1501,6 +1711,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 = "strum" version = "0.25.0" @@ -1516,11 +1732,11 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.100", + "syn", ] [[package]] @@ -1530,14 +1746,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[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]] @@ -1577,7 +1801,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -1588,7 +1812,7 @@ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -1622,6 +1846,12 @@ dependencies = [ "time-core", ] +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + [[package]] name = "typenum" version = "1.18.0" @@ -1685,7 +1915,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.100", + "syn", "wasm-bindgen-shared", ] @@ -1707,7 +1937,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1820,7 +2050,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -1831,7 +2061,7 @@ checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] [[package]] @@ -1851,5 +2081,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn", ] diff --git a/Cargo.toml b/Cargo.toml index 6403e59..d4621f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,15 +12,15 @@ keywords = [ "Vectis", "CosmWasm", "zkp", "verifiableCredential", "sd-jwt" ] anyhow = { version = "1.0.51"} -cosmwasm-schema = "2.1.0" -cosmwasm-std = { version = "2.1.0", features = [ - "cosmwasm_1_4", +cosmwasm-schema = "3.0.2" +cosmwasm-std = { version = "3.0.2", features = [ + "iterator", + "staking", "stargate", - # Enable this if you only deploy to chains that have CosmWasm 2.0 or higher - # "cosmwasm_2_0", + "cosmwasm_3_0", ] } -cw-storage-plus = "2.0.0" -cw2 = "2.0.0" +cw-storage-plus = "3.0.0" +cw2 = "3.0.0" schemars = "0.8.16" serde = { version = "1.0.197", default-features = false, features = ["derive"] } thiserror = { version = "1.0.58" } @@ -28,7 +28,7 @@ sd-jwt-rs = { git = "https://github.com/nymlab/sd-jwt-rust", rev = "de9ccce7858e jsonwebtoken = { git = "https://github.com/nymlab/jsonwebtoken", rev = "98763b38713c54f", default-features = false, features = ["no_rand"] } serde_json = {version = "1.0.116", default-features = false, features = ["alloc"]} -cw-utils = "2.0.0" +cw-utils = "3.0.0" [profile.release] codegen-units = 1 diff --git a/contracts/anoncreds-verifier/Cargo.toml b/contracts/anoncreds-verifier/Cargo.toml index 71f12aa..64542b9 100644 --- a/contracts/anoncreds-verifier/Cargo.toml +++ b/contracts/anoncreds-verifier/Cargo.toml @@ -10,8 +10,8 @@ keywords = { workspace = true } crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] +# backtraces feature removed in CosmWasm 3.0 +# for more explicit tests, cargo test --features=backtraces (no longer available) # use library feature to disable all instantiate/execute/query exports library = [] diff --git a/contracts/avida_example/Cargo.toml b/contracts/avida_example/Cargo.toml index 8aa3136..bbd93b9 100644 --- a/contracts/avida_example/Cargo.toml +++ b/contracts/avida_example/Cargo.toml @@ -35,5 +35,5 @@ josekit = "0.8.6" sd-jwt-rs = "0.7.0" jsonwebtoken = { version="9.3.0", features=["use_pem"]} avida-test-utils = { path = "../../packages/avida_test_utils/", features = ["sdjwt"]} -cw-multi-test = {version = "2", features = ["staking", "stargate", "cosmwasm_2_1"]} +cw-multi-test = {version = "3", features = ["staking", "stargate", "cosmwasm_3_0"]} serde = { workspace = true } diff --git a/contracts/avida_example/src/contract.rs b/contracts/avida_example/src/contract.rs index 48ecd0f..7b65161 100644 --- a/contracts/avida_example/src/contract.rs +++ b/contracts/avida_example/src/contract.rs @@ -35,23 +35,27 @@ pub fn reply(deps: DepsMut, _: Env, reply: Reply) -> Result Ok(Response::new() - .add_attribute("action", "give_me_some_drink") - .add_attribute( - "Drink kind", - PENDING_ORDER_SUBJECTS.load(deps.storage, rid)?, - )), - Ok(_) => Ok(Response::new() - .add_attribute("action", "give_me_some_food") - .add_attribute( - "Food kind", - PENDING_ORDER_SUBJECTS.load(deps.storage, rid)?, - )), - Err(err) => Err(ContractError::VerificationProcessError(format!( + if verify_result.success { + if rid == GIVE_ME_DRINK_ROUTE_ID { + Ok(Response::new() + .add_attribute("action", "give_me_some_drink") + .add_attribute( + "Drink kind", + PENDING_ORDER_SUBJECTS.load(deps.storage, rid)?, + )) + } else { + Ok(Response::new() + .add_attribute("action", "give_me_some_food") + .add_attribute( + "Food kind", + PENDING_ORDER_SUBJECTS.load(deps.storage, rid)?, + )) + } + } else { + Err(ContractError::VerificationProcessError(format!( "{:?}", - err - ))), + verify_result.error + ))) } } else { Err(ContractError::VerificationProcessError( diff --git a/contracts/avida_example/src/error.rs b/contracts/avida_example/src/error.rs index ca20358..f1fb2bd 100644 --- a/contracts/avida_example/src/error.rs +++ b/contracts/avida_example/src/error.rs @@ -1,7 +1,7 @@ use cosmwasm_std::StdError; use thiserror::Error; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug)] pub enum ContractError { #[error("{0}")] Std(#[from] StdError), @@ -24,9 +24,3 @@ pub enum ContractError { #[error("Invalid RouteId")] InvalidRouteId, } - -impl From for cosmwasm_std::StdError { - fn from(e: ContractError) -> cosmwasm_std::StdError { - cosmwasm_std::StdError::generic_err(format!("{}", e)) - } -} diff --git a/contracts/sdjwt-verifier/Cargo.toml b/contracts/sdjwt-verifier/Cargo.toml index 0d6ee2b..efbdd03 100644 --- a/contracts/sdjwt-verifier/Cargo.toml +++ b/contracts/sdjwt-verifier/Cargo.toml @@ -34,5 +34,5 @@ cw-utils = { workspace = true } [dev-dependencies] avida-test-utils = { path = "../../packages/avida_test_utils/", features = ["sdjwt"]} -cw-multi-test = {version = "2", features = ["staking", "stargate", "cosmwasm_2_1"]} +cw-multi-test = {version = "3", features = ["staking", "stargate", "cosmwasm_3_0"]} josekit = "0.8.6" diff --git a/contracts/sdjwt-verifier/src/errors.rs b/contracts/sdjwt-verifier/src/errors.rs index 0096941..404f3d1 100644 --- a/contracts/sdjwt-verifier/src/errors.rs +++ b/contracts/sdjwt-verifier/src/errors.rs @@ -40,6 +40,8 @@ pub enum SdjwtVerifierResultError { IdxRevoked(u64), #[error("Issuer not found in Payload")] IssuerNotFound, + #[error("verified claims to binary error: {0}")] + VerifiedClaimsToBinaryError(String), #[error("SdJwtRsError: {0}")] SdJwtRsError(String), } @@ -85,9 +87,3 @@ pub enum SdjwtVerifierError { #[error("Revocation List type")] RevocationListType, } - -impl From for StdError { - fn from(err: SdjwtVerifierError) -> StdError { - StdError::generic_err(err.to_string()) - } -} diff --git a/contracts/sdjwt-verifier/src/tests/contract_test.rs b/contracts/sdjwt-verifier/src/tests/contract_test.rs index 887599c..27f2f49 100644 --- a/contracts/sdjwt-verifier/src/tests/contract_test.rs +++ b/contracts/sdjwt-verifier/src/tests/contract_test.rs @@ -219,7 +219,8 @@ fn test_revoked_presentation_cannot_be_used() { ) .unwrap(); let verify_res: VerifyResult = from_json(res.data.unwrap()).unwrap(); - let err = verify_res.result.unwrap_err(); + assert!(!verify_res.success); + let err = verify_res.error.unwrap(); assert_eq!(err, SdjwtVerifierResultError::IdxRevoked(revoked_idx)); @@ -237,7 +238,7 @@ fn test_revoked_presentation_cannot_be_used() { ) .unwrap(); - assert!(res.result.is_ok()); + assert!(res.success); } #[test] @@ -283,7 +284,8 @@ fn test_addition_requirements_with_revocation_list() { .unwrap(), ) .unwrap(); - let err = res.result.unwrap_err(); + assert!(!res.success); + let err = res.error.unwrap(); assert_eq!(err, SdjwtVerifierResultError::IdxRevoked(revoked_idx)); // Additional requirements not present, revoked_claims is not checked and should ok @@ -306,5 +308,5 @@ fn test_addition_requirements_with_revocation_list() { ) .unwrap(); - assert!(res.result.is_ok()); + assert!(res.success); } diff --git a/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs b/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs index 3f83832..6dda83b 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs +++ b/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs @@ -52,7 +52,7 @@ fn verify_success_no_exp_validate_success() { ) .unwrap(); - assert!(res.result.is_ok()); + assert!(res.success); } #[test] @@ -117,7 +117,7 @@ fn verify_success_exp_validate_success() { ) .unwrap(); - assert!(res.result.is_ok()); + assert!(res.success); // Make a presentation with some claims with block height let valid_blockheigh_claims = claims( @@ -153,7 +153,7 @@ fn verify_success_exp_validate_success() { ) .unwrap(); - assert!(res.result.is_ok()); + assert!(res.success); } #[test] @@ -212,7 +212,7 @@ fn verify_failed_on_expired_claim() { .unwrap(); assert_eq!( - res.result.unwrap_err(), + res.error.unwrap(), SdjwtVerifierResultError::PresentationExpired(exp) ); @@ -244,7 +244,7 @@ fn verify_failed_on_expired_claim() { .unwrap(); assert_eq!( - res.result.unwrap_err(), + res.error.unwrap(), SdjwtVerifierResultError::PresentationExpired(exp) ); } @@ -304,5 +304,5 @@ fn verify_success_on_no_expiration_check_for_expired_claims() { ) .unwrap(); - assert!(res.result.is_ok()); + assert!(res.success); } diff --git a/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs b/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs index b4f9829..a54f470 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs +++ b/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs @@ -50,7 +50,7 @@ fn verify_route_not_registered() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::RouteNotRegistered )); } @@ -194,7 +194,7 @@ fn register_app_is_already_registered() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::AppAlreadyRegistered )); } @@ -232,7 +232,7 @@ fn register_serde_json_error() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::Std(_) )); } @@ -266,7 +266,7 @@ fn register_unsupported_key_type() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::UnsupportedKeyType )); } @@ -345,10 +345,16 @@ fn deregister_app_not_registered() { ) .unwrap_err(); - assert!(matches!( - err.downcast().unwrap(), - SdjwtVerifierError::AppIsNotRegistered - )); + let inner = *er + + match err.kind() { + cosmwasm_std::StdErrorKind::Other => { + assert!(err + .to_string() + .contains(SdjwtVerifierError::AppIsNotRegistered.to_string())); + } + _ => panic!("Unexpected error kind"), + } } #[test] @@ -389,7 +395,7 @@ fn deregister_unauthorized() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::Unauthorised )); } diff --git a/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs b/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs index 32c0e21..a984f17 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs +++ b/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs @@ -145,7 +145,7 @@ fn update_app_not_registered() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::AppIsNotRegistered )); } @@ -195,7 +195,7 @@ fn update_unauthorized() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::Unauthorised )); } @@ -247,7 +247,7 @@ fn update_serde_json_error() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::Std(_) )); } @@ -302,7 +302,7 @@ fn update_unsupported_key_type() { .unwrap_err(); assert!(matches!( - err.downcast().unwrap(), + err.downcast_ref().unwrap(), SdjwtVerifierError::UnsupportedKeyType )); } diff --git a/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs b/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs index 352361a..cc6dfc9 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs +++ b/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs @@ -52,7 +52,7 @@ fn verify_success_incorrect_claims_validate_fails() { .unwrap(); assert_eq!( - res.result.unwrap_err(), + res.error.unwrap(), SdjwtVerifierResultError::CriterionValueFailed("joined_at".to_string()) ); } @@ -90,7 +90,7 @@ fn verify_required_claims_not_satisfied() { .unwrap(); assert_eq!( - res.result.unwrap_err(), + res.error.unwrap(), SdjwtVerifierResultError::DisclosedClaimNotFound( "Expects claim to be: Number(NumberCriterion { value: 30, operator: EqualTo }) for attr: age".to_string() ) @@ -126,7 +126,7 @@ fn verify_without_sdjwt() { .unwrap(); assert_eq!( - res.result.unwrap_err(), + res.error.unwrap(), SdjwtVerifierResultError::SdJwtRsError( "invalid input: Invalid SD-JWT length: 1".to_string() ) @@ -172,7 +172,7 @@ fn verify_presentation_too_large() { .unwrap(); assert_eq!( - res.result.unwrap_err(), + res.error.unwrap(), SdjwtVerifierResultError::PresentationTooLarge ); } diff --git a/contracts/sdjwt-verifier/src/types.rs b/contracts/sdjwt-verifier/src/types.rs index 31fd70a..85098a6 100644 --- a/contracts/sdjwt-verifier/src/types.rs +++ b/contracts/sdjwt-verifier/src/types.rs @@ -5,7 +5,6 @@ use cosmwasm_std::{from_json, Binary, BlockInfo, SubMsg}; use cw_utils::Expiration; use jsonwebtoken::jwk::Jwk; use serde::{Deserialize, Serialize}; -use serde_json::Value; use std::collections::HashMap; /// This is the key to be used in claims that specifies expiration using `cw_util::Expiration` @@ -25,7 +24,9 @@ pub struct JwkInfo { #[cw_serde] pub struct VerifyResult { - pub result: Result, + pub success: bool, + pub value: Option, + pub error: Option, } #[cw_serde] diff --git a/contracts/sdjwt-verifier/src/verifier.rs b/contracts/sdjwt-verifier/src/verifier.rs index 8071110..436c3c1 100644 --- a/contracts/sdjwt-verifier/src/verifier.rs +++ b/contracts/sdjwt-verifier/src/verifier.rs @@ -109,10 +109,48 @@ pub fn handle_verify( route_id: RouteId, app_addr: Option, additional_requirements: Option, +) -> Result { + let app_addr = app_addr.unwrap_or_else(|| info.sender.to_string()); + + _handle_verify( + deps, + env, + app_addr, + route_id, + presentation, + additional_requirements, + ) +} + +// Sudo message handlers +pub fn handle_sudo_verify( + deps: DepsMut, + env: Env, + app_addr: String, + route_id: RouteId, + presentation: VerfiablePresentation, + additional_requirements: Option, +) -> Result { + _handle_verify( + deps, + env, + app_addr, + route_id, + presentation, + additional_requirements, + ) +} + +pub fn _handle_verify( + deps: DepsMut, + env: Env, + app_addr: String, + route_id: RouteId, + presentation: VerfiablePresentation, + additional_requirements: Option, ) -> Result { let additional_requirements: Option = additional_requirements.map(from_json).transpose()?; - let app_addr = app_addr.unwrap_or_else(|| info.sender.to_string()); let requirements = APP_ROUTES_REQUIREMENTS .load(deps.storage, (app_addr, route_id)) @@ -128,8 +166,7 @@ pub fn handle_verify( additional_requirements, ); - let data = to_json_binary(&VerifyResult { result: res })?; - Ok(Response::default().set_data(data)) + create_verify_response(res) } pub fn handle_update( @@ -182,38 +219,6 @@ pub fn handle_deregister( _deregister(deps.storage, app_addr.as_str()) } - -// Sudo message handlers -pub fn handle_sudo_verify( - deps: DepsMut, - env: Env, - app_addr: String, - route_id: RouteId, - presentation: VerfiablePresentation, - additional_requirements: Option, -) -> Result { - let additional_requirements: Option = - additional_requirements.map(from_json).transpose()?; - - let requirements = APP_ROUTES_REQUIREMENTS - .load(deps.storage, (app_addr, route_id)) - .map_err(|_| SdjwtVerifierError::RouteNotRegistered)? - .clone(); - let max_len = MAX_PRESENTATION_LENGTH.load(deps.storage)?; - - let res = _verify( - presentation, - requirements, - max_len, - &env.block, - additional_requirements, - ) - .map(|res| to_json_binary(&VerifyResult { result: Ok(res) })) - .map_err(SdjwtVerifierError::SdjwtVerifierResultError)??; - - Ok(Response::default().set_data(res)) -} - pub fn handle_sudo_update( deps: DepsMut, env: Env, @@ -267,6 +272,32 @@ pub fn query_route_requirements( Ok(req) } +fn create_verify_response( + res: Result, +) -> Result { + let verify_result = match res { + Ok(value) => { + let binary_value = Binary::from(serde_json::to_vec(&value).map_err(|e| { + SdjwtVerifierError::SdjwtVerifierResultError( + SdjwtVerifierResultError::VerifiedClaimsToBinaryError(e.to_string()), + ) + })?); + VerifyResult { + success: true, + value: Some(binary_value), + error: None, + } + } + Err(error) => VerifyResult { + success: false, + value: None, + error: Some(error), + }, + }; + let data = to_json_binary(&verify_result)?; + Ok(Response::default().set_data(data)) +} + /// Verify the provided presentation within the context of the given route pub fn _verify( presentation: VerfiablePresentation, @@ -332,6 +363,7 @@ pub fn _verify( sdjwt_verifier.verified_claims.clone(), block_info, )?; + Ok(sdjwt_verifier.verified_claims) } // If the issuer is not in the requirements, we return an error diff --git a/packages/anoncreds/src/tests/types.rs b/packages/anoncreds/src/tests/types.rs index 36b80dc..aa968cd 100644 --- a/packages/anoncreds/src/tests/types.rs +++ b/packages/anoncreds/src/tests/types.rs @@ -1,5 +1,5 @@ use crate::types::{ResourceReceivePacket, ResourceReqPacket, StdAck}; -use cosmwasm_std::{from_binary, to_binary, Binary}; +use cosmwasm_std::{from_json, to_json_binary, Binary}; #[test] fn it_serde_json_correctly() { @@ -9,7 +9,7 @@ fn it_serde_json_correctly() { collection_id: "collection_id".into(), }; - let bin = to_binary(&req).unwrap(); + let bin = to_json_binary(&req).unwrap(); let string = String::from_utf8(bin.0).unwrap(); let expected = "{\"resourceId\":\"resuorce_id\",\"collectionId\":\"collection_id\"}"; @@ -61,6 +61,6 @@ fn it_de_resource_ack_correctly() { 61, 34, 125, ]); - let ack: StdAck = from_binary(&binary).unwrap(); - from_binary::(&ack.unwrap()).unwrap(); + let ack: StdAck = from_json(&binary).unwrap(); + from_json::(&ack.unwrap()).unwrap(); } diff --git a/packages/avida_test_utils/Cargo.toml b/packages/avida_test_utils/Cargo.toml index 5d6bc45..e0f6cef 100644 --- a/packages/avida_test_utils/Cargo.toml +++ b/packages/avida_test_utils/Cargo.toml @@ -16,7 +16,7 @@ avida-common = { path = "../../packages/common/"} cosmwasm-schema = { workspace = true } cosmwasm-std = { workspace = true } cw-storage-plus = { workspace = true } -cw-multi-test = {version = "2", features = ["stargate", "cosmwasm_1_4"]} +cw-multi-test = {version = "3", features = ["stargate", "cosmwasm_3_0"]} cw-utils = { workspace = true } serde = { workspace = true } diff --git a/packages/cheqd/src/ibc.rs b/packages/cheqd/src/ibc.rs index d8f2f9d..4ad444e 100644 --- a/packages/cheqd/src/ibc.rs +++ b/packages/cheqd/src/ibc.rs @@ -24,12 +24,6 @@ pub enum ChannelError { InvalidPort, } -impl From for StdError { - fn from(err: ChannelError) -> StdError { - StdError::generic_err(err.to_string()) - } -} - pub fn check_order(order: &IbcOrder) -> Result<(), ChannelError> { if order != &APP_ORDER { Err(ChannelError::InvalidChannelOrder) @@ -84,7 +78,7 @@ pub fn ibc_channel_open_handler(msg: IbcChannelOpenMsg) -> StdResult StdResult { - Err(StdError::generic_err("Closing is not supported")) + Err(StdError::msg("Closing is not supported")) } /// Checks ack resource matching requested resource @@ -98,17 +92,15 @@ pub fn ibc_packet_ack_resource_extractor( let original_packet: ResourceReqPacket = from_json(&msg.original_packet.data)?; if original_packet.resource_id != resource.linked_resource_metadata.resource_id { - Err(StdError::generic_err("Ack Returned Unmatched resource_id")) + Err(StdError::msg("Ack Returned Unmatched resource_id")) } else if original_packet.collection_id != resource.linked_resource_metadata.resource_collection_id { - Err(StdError::generic_err( - "Ack Returned Unmatched collection_id", - )) + Err(StdError::msg("Ack Returned Unmatched collection_id")) } else { Ok((original_packet, resource)) } } - StdAck::Error(err) => Err(StdError::generic_err(format!("Ack Returned Err: {}", err))), + StdAck::Error(err) => Err(StdError::msg(format!("Ack Returned Err: {}", err))), } } From cc6d0686278e325ff5c23d4e41f3da0b558d8207 Mon Sep 17 00:00:00 2001 From: bwty Date: Wed, 24 Sep 2025 07:24:04 +0100 Subject: [PATCH 02/16] tests: remove downcast in tests --- .../src/tests/verifier_register_test.rs | 46 +++++++------------ .../src/tests/verifier_update_test.rs | 26 ++++------- 2 files changed, 26 insertions(+), 46 deletions(-) diff --git a/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs b/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs index a54f470..537cabf 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs +++ b/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs @@ -49,10 +49,9 @@ fn verify_route_not_registered() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::RouteNotRegistered - )); + assert!(err + .to_string() + .contains(&SdjwtVerifierError::RouteNotRegistered.to_string())); } #[test] @@ -193,10 +192,9 @@ fn register_app_is_already_registered() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::AppAlreadyRegistered - )); + assert!(err + .to_string() + .contains(&SdjwtVerifierError::AppAlreadyRegistered.to_string())); } #[test] @@ -231,10 +229,7 @@ fn register_serde_json_error() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::Std(_) - )); + assert!(err.to_string().contains("Serialization")); } #[test] @@ -265,10 +260,9 @@ fn register_unsupported_key_type() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::UnsupportedKeyType - )); + assert!(err + .to_string() + .contains(&SdjwtVerifierError::UnsupportedKeyType.to_string())); } #[test] @@ -345,16 +339,9 @@ fn deregister_app_not_registered() { ) .unwrap_err(); - let inner = *er - - match err.kind() { - cosmwasm_std::StdErrorKind::Other => { - assert!(err - .to_string() - .contains(SdjwtVerifierError::AppIsNotRegistered.to_string())); - } - _ => panic!("Unexpected error kind"), - } + assert!(err + .to_string() + .contains(&SdjwtVerifierError::AppIsNotRegistered.to_string())); } #[test] @@ -394,8 +381,7 @@ fn deregister_unauthorized() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::Unauthorised - )); + assert!(err + .to_string() + .contains(&SdjwtVerifierError::Unauthorised.to_string())); } diff --git a/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs b/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs index a984f17..ff9e2f3 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs +++ b/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs @@ -144,10 +144,9 @@ fn update_app_not_registered() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::AppIsNotRegistered - )); + assert!(err + .to_string() + .contains(&SdjwtVerifierError::AppIsNotRegistered.to_string())); } #[test] @@ -194,10 +193,9 @@ fn update_unauthorized() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::Unauthorised - )); + assert!(err + .to_string() + .contains(&SdjwtVerifierError::Unauthorised.to_string())); } #[test] @@ -246,10 +244,7 @@ fn update_serde_json_error() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::Std(_) - )); + assert!(err.to_string().contains("Serialization")); } #[test] @@ -301,10 +296,9 @@ fn update_unsupported_key_type() { ) .unwrap_err(); - assert!(matches!( - err.downcast_ref().unwrap(), - SdjwtVerifierError::UnsupportedKeyType - )); + assert!(err + .to_string() + .contains(&SdjwtVerifierError::UnsupportedKeyType.to_string())); } #[test] From 7ecac52cf064f14eff59d0e4ae3da0fa157559fb Mon Sep 17 00:00:00 2001 From: bwty Date: Wed, 24 Sep 2025 15:32:17 +0100 Subject: [PATCH 03/16] feat: update schema and serde_json --- .../schema/cw_schema/avida-example.json | 194 +++++++ .../schema/cw_schema/raw/execute.json | 141 +++++ .../schema/cw_schema/raw/instantiate.json | 19 + .../schema/cw_schema/raw/query.json | 15 + .../raw/response_to_get_verifier_address.json | 10 + .../cw_schema/avida-sdjwt-verifier.json | 498 ++++++++++++++++++ .../schema/cw_schema/raw/execute.json | 191 +++++++ .../schema/cw_schema/raw/instantiate.json | 131 +++++ .../schema/cw_schema/raw/query.json | 60 +++ .../raw/response_to_get_app_admin.json | 10 + .../response_to_get_route_requirements.json | 65 +++ ...esponse_to_get_route_verification_key.json | 15 + .../cw_schema/raw/response_to_get_routes.json | 17 + packages/anoncreds/src/tests/types.rs | 2 +- 14 files changed, 1367 insertions(+), 1 deletion(-) create mode 100644 contracts/avida_example/schema/cw_schema/avida-example.json create mode 100644 contracts/avida_example/schema/cw_schema/raw/execute.json create mode 100644 contracts/avida_example/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/avida_example/schema/cw_schema/raw/query.json create mode 100644 contracts/avida_example/schema/cw_schema/raw/response_to_get_verifier_address.json create mode 100644 contracts/sdjwt-verifier/schema/cw_schema/avida-sdjwt-verifier.json create mode 100644 contracts/sdjwt-verifier/schema/cw_schema/raw/execute.json create mode 100644 contracts/sdjwt-verifier/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/sdjwt-verifier/schema/cw_schema/raw/query.json create mode 100644 contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_app_admin.json create mode 100644 contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_route_requirements.json create mode 100644 contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_route_verification_key.json create mode 100644 contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_routes.json diff --git a/contracts/avida_example/schema/cw_schema/avida-example.json b/contracts/avida_example/schema/cw_schema/avida-example.json new file mode 100644 index 0000000..a59a150 --- /dev/null +++ b/contracts/avida_example/schema/cw_schema/avida-example.json @@ -0,0 +1,194 @@ +{ + "contract_name": "avida-example", + "contract_version": "0.1.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_example_msg_InstantiateMsg", + "type": "struct", + "properties": { + "verifier": { + "value": 1 + } + } + }, + { + "name": "String", + "type": "string" + } + ] + }, + "execute": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_example_msg_ExecuteMsg", + "type": "enum", + "cases": { + "give_me_some_drink": { + "type": "tuple", + "items": [ + 9 + ] + }, + "give_me_some_food": { + "type": "tuple", + "items": [ + 11 + ] + }, + "register_requirement": { + "type": "named", + "properties": { + "requirements": { + "value": 1 + } + } + } + } + }, + { + "name": "avida_example_types_RegisterRequirement", + "type": "enum", + "cases": { + "drink": { + "type": "named", + "properties": { + "requirements": { + "value": 2 + } + } + }, + "food": { + "type": "named", + "properties": { + "requirements": { + "value": 2 + } + } + } + } + }, + { + "name": "avida_common_types_RouteVerificationRequirements", + "description": "Specific verification requirements for the route, by `route_id`", + "type": "struct", + "properties": { + "issuer_source_or_data": { + "description": "This defines where the source data for verification is", + "value": 7 + }, + "presentation_required": { + "description": "The presentation request is the criteria required for the presentation,\nfor example required certains claims to be disclosed\nThis value is stored as `VerificationRequirements.presentation_required` on sdjwtVerifier", + "value": 8 + } + } + }, + { + "name": "avida_common_types_IssuerSourceOrData", + "description": "Location to obtain the verification data from", + "type": "struct", + "properties": { + "data_or_location": { + "description": "The data or location of the verification data at the trust registry\nFor TrustRegistry::Cheqd, it is the `ResourceReqPacket` in avida-cheqd\nFor data, the contracts should have the expected type\nIn Sdjwt-Verifier, this is expected to be the JwkInfo struct", + "value": 6 + }, + "source": { + "description": "If `None`, this means data is directly provided", + "value": 5 + } + } + }, + { + "name": "avida_common_types_TrustRegistry", + "type": "enum", + "cases": { + "cheqd": { + "type": "unit" + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 4 + }, + { + "name": "cosmwasm_std_binary_Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization\nwith serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec.\nSee also .", + "type": "binary" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 6 + }, + { + "name": "avida_example_types_GiveMeSomeDrink", + "type": "struct", + "properties": { + "kind": { + "value": 10 + }, + "proof": { + "value": 6 + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "avida_example_types_GiveMeSomeFood", + "type": "struct", + "properties": { + "kind": { + "value": 10 + }, + "proof": { + "value": 6 + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_example_msg_QueryMsg", + "type": "enum", + "cases": { + "get_verifier_address": { + "type": "unit" + } + } + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "get_verifier_address": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "String", + "type": "string" + } + ] + } + } +} diff --git a/contracts/avida_example/schema/cw_schema/raw/execute.json b/contracts/avida_example/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000..5a9eff1 --- /dev/null +++ b/contracts/avida_example/schema/cw_schema/raw/execute.json @@ -0,0 +1,141 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_example_msg_ExecuteMsg", + "type": "enum", + "cases": { + "give_me_some_drink": { + "type": "tuple", + "items": [ + 9 + ] + }, + "give_me_some_food": { + "type": "tuple", + "items": [ + 11 + ] + }, + "register_requirement": { + "type": "named", + "properties": { + "requirements": { + "value": 1 + } + } + } + } + }, + { + "name": "avida_example_types_RegisterRequirement", + "type": "enum", + "cases": { + "drink": { + "type": "named", + "properties": { + "requirements": { + "value": 2 + } + } + }, + "food": { + "type": "named", + "properties": { + "requirements": { + "value": 2 + } + } + } + } + }, + { + "name": "avida_common_types_RouteVerificationRequirements", + "description": "Specific verification requirements for the route, by `route_id`", + "type": "struct", + "properties": { + "issuer_source_or_data": { + "description": "This defines where the source data for verification is", + "value": 7 + }, + "presentation_required": { + "description": "The presentation request is the criteria required for the presentation,\nfor example required certains claims to be disclosed\nThis value is stored as `VerificationRequirements.presentation_required` on sdjwtVerifier", + "value": 8 + } + } + }, + { + "name": "avida_common_types_IssuerSourceOrData", + "description": "Location to obtain the verification data from", + "type": "struct", + "properties": { + "data_or_location": { + "description": "The data or location of the verification data at the trust registry\nFor TrustRegistry::Cheqd, it is the `ResourceReqPacket` in avida-cheqd\nFor data, the contracts should have the expected type\nIn Sdjwt-Verifier, this is expected to be the JwkInfo struct", + "value": 6 + }, + "source": { + "description": "If `None`, this means data is directly provided", + "value": 5 + } + } + }, + { + "name": "avida_common_types_TrustRegistry", + "type": "enum", + "cases": { + "cheqd": { + "type": "unit" + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 4 + }, + { + "name": "cosmwasm_std_binary_Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization\nwith serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec.\nSee also .", + "type": "binary" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 6 + }, + { + "name": "avida_example_types_GiveMeSomeDrink", + "type": "struct", + "properties": { + "kind": { + "value": 10 + }, + "proof": { + "value": 6 + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "avida_example_types_GiveMeSomeFood", + "type": "struct", + "properties": { + "kind": { + "value": 10 + }, + "proof": { + "value": 6 + } + } + } + ] +} diff --git a/contracts/avida_example/schema/cw_schema/raw/instantiate.json b/contracts/avida_example/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000..cb002ec --- /dev/null +++ b/contracts/avida_example/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_example_msg_InstantiateMsg", + "type": "struct", + "properties": { + "verifier": { + "value": 1 + } + } + }, + { + "name": "String", + "type": "string" + } + ] +} diff --git a/contracts/avida_example/schema/cw_schema/raw/query.json b/contracts/avida_example/schema/cw_schema/raw/query.json new file mode 100644 index 0000000..64f7b89 --- /dev/null +++ b/contracts/avida_example/schema/cw_schema/raw/query.json @@ -0,0 +1,15 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_example_msg_QueryMsg", + "type": "enum", + "cases": { + "get_verifier_address": { + "type": "unit" + } + } + } + ] +} diff --git a/contracts/avida_example/schema/cw_schema/raw/response_to_get_verifier_address.json b/contracts/avida_example/schema/cw_schema/raw/response_to_get_verifier_address.json new file mode 100644 index 0000000..f27d584 --- /dev/null +++ b/contracts/avida_example/schema/cw_schema/raw/response_to_get_verifier_address.json @@ -0,0 +1,10 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "String", + "type": "string" + } + ] +} diff --git a/contracts/sdjwt-verifier/schema/cw_schema/avida-sdjwt-verifier.json b/contracts/sdjwt-verifier/schema/cw_schema/avida-sdjwt-verifier.json new file mode 100644 index 0000000..98f9fc6 --- /dev/null +++ b/contracts/sdjwt-verifier/schema/cw_schema/avida-sdjwt-verifier.json @@ -0,0 +1,498 @@ +{ + "contract_name": "avida-sdjwt-verifier", + "contract_version": "0.1.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_sdjwt_verifier_msg_InstantiateMsg", + "type": "struct", + "properties": { + "init_registrations": { + "value": 14 + }, + "max_presentation_len": { + "value": 1 + } + } + }, + { + "name": "usize", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "avida_sdjwt_verifier_types_InitRegistration", + "type": "struct", + "properties": { + "app_addr": { + "value": 3 + }, + "app_admin": { + "value": 3 + }, + "routes": { + "value": 13 + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "avida_common_types_RegisterRouteRequest", + "description": "Routes Requiments used in Registration (and Initiation)", + "type": "struct", + "properties": { + "requirements": { + "value": 6 + }, + "route_id": { + "value": 5 + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "avida_common_types_RouteVerificationRequirements", + "description": "Specific verification requirements for the route, by `route_id`", + "type": "struct", + "properties": { + "issuer_source_or_data": { + "description": "This defines where the source data for verification is", + "value": 11 + }, + "presentation_required": { + "description": "The presentation request is the criteria required for the presentation,\nfor example required certains claims to be disclosed\nThis value is stored as `VerificationRequirements.presentation_required` on sdjwtVerifier", + "value": 12 + } + } + }, + { + "name": "avida_common_types_IssuerSourceOrData", + "description": "Location to obtain the verification data from", + "type": "struct", + "properties": { + "data_or_location": { + "description": "The data or location of the verification data at the trust registry\nFor TrustRegistry::Cheqd, it is the `ResourceReqPacket` in avida-cheqd\nFor data, the contracts should have the expected type\nIn Sdjwt-Verifier, this is expected to be the JwkInfo struct", + "value": 10 + }, + "source": { + "description": "If `None`, this means data is directly provided", + "value": 9 + } + } + }, + { + "name": "avida_common_types_TrustRegistry", + "type": "enum", + "cases": { + "cheqd": { + "type": "unit" + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 8 + }, + { + "name": "cosmwasm_std_binary_Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization\nwith serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec.\nSee also .", + "type": "binary" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 7 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 10 + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 4 + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + } + ] + }, + "execute": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_common_types_AvidaVerifierExecuteMsg", + "type": "enum", + "cases": { + "deregister": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + } + } + }, + "register": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "requests": { + "value": 13 + } + } + }, + "update": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "route_criteria": { + "value": 15 + }, + "route_id": { + "value": 3 + } + } + }, + "update_revocation_list": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "request": { + "value": 2 + } + } + }, + "verify": { + "type": "named", + "properties": { + "additional_requirements": { + "value": 12 + }, + "app_addr": { + "value": 14 + }, + "presentation": { + "value": 10 + }, + "route_id": { + "value": 3 + } + } + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "avida_common_types_UpdateRevocationListRequest", + "description": "A Sd-jwt specific requirement for revocation list update\nusing Criterion::NotContainedIn", + "type": "struct", + "properties": { + "revoke": { + "value": 4 + }, + "route_id": { + "value": 3 + }, + "unrevoke": { + "value": 4 + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "avida_common_types_RegisterRouteRequest", + "description": "Routes Requiments used in Registration (and Initiation)", + "type": "struct", + "properties": { + "requirements": { + "value": 6 + }, + "route_id": { + "value": 3 + } + } + }, + { + "name": "avida_common_types_RouteVerificationRequirements", + "description": "Specific verification requirements for the route, by `route_id`", + "type": "struct", + "properties": { + "issuer_source_or_data": { + "description": "This defines where the source data for verification is", + "value": 11 + }, + "presentation_required": { + "description": "The presentation request is the criteria required for the presentation,\nfor example required certains claims to be disclosed\nThis value is stored as `VerificationRequirements.presentation_required` on sdjwtVerifier", + "value": 12 + } + } + }, + { + "name": "avida_common_types_IssuerSourceOrData", + "description": "Location to obtain the verification data from", + "type": "struct", + "properties": { + "data_or_location": { + "description": "The data or location of the verification data at the trust registry\nFor TrustRegistry::Cheqd, it is the `ResourceReqPacket` in avida-cheqd\nFor data, the contracts should have the expected type\nIn Sdjwt-Verifier, this is expected to be the JwkInfo struct", + "value": 10 + }, + "source": { + "description": "If `None`, this means data is directly provided", + "value": 9 + } + } + }, + { + "name": "avida_common_types_TrustRegistry", + "type": "enum", + "cases": { + "cheqd": { + "type": "unit" + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 8 + }, + { + "name": "cosmwasm_std_binary_Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization\nwith serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec.\nSee also .", + "type": "binary" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 7 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 10 + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 5 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 1 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 6 + } + ] + }, + "query": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_sdjwt_verifier_msg_QueryMsg", + "type": "enum", + "cases": { + "get_app_admin": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + } + } + }, + "get_route_requirements": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "route_id": { + "value": 2 + } + } + }, + "get_route_verification_key": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "route_id": { + "value": 2 + } + } + }, + "get_routes": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + } + } + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "get_app_admin": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "String", + "type": "string" + } + ] + }, + "get_route_requirements": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_common_types_RouteVerificationRequirements", + "description": "Specific verification requirements for the route, by `route_id`", + "type": "struct", + "properties": { + "issuer_source_or_data": { + "description": "This defines where the source data for verification is", + "value": 5 + }, + "presentation_required": { + "description": "The presentation request is the criteria required for the presentation,\nfor example required certains claims to be disclosed\nThis value is stored as `VerificationRequirements.presentation_required` on sdjwtVerifier", + "value": 6 + } + } + }, + { + "name": "avida_common_types_IssuerSourceOrData", + "description": "Location to obtain the verification data from", + "type": "struct", + "properties": { + "data_or_location": { + "description": "The data or location of the verification data at the trust registry\nFor TrustRegistry::Cheqd, it is the `ResourceReqPacket` in avida-cheqd\nFor data, the contracts should have the expected type\nIn Sdjwt-Verifier, this is expected to be the JwkInfo struct", + "value": 4 + }, + "source": { + "description": "If `None`, this means data is directly provided", + "value": 3 + } + } + }, + { + "name": "avida_common_types_TrustRegistry", + "type": "enum", + "cases": { + "cheqd": { + "type": "unit" + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 2 + }, + { + "name": "cosmwasm_std_binary_Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization\nwith serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec.\nSee also .", + "type": "binary" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 1 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 4 + } + ] + }, + "get_route_verification_key": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + } + ] + }, + "get_routes": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + } + ] + } + } +} diff --git a/contracts/sdjwt-verifier/schema/cw_schema/raw/execute.json b/contracts/sdjwt-verifier/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000..374578e --- /dev/null +++ b/contracts/sdjwt-verifier/schema/cw_schema/raw/execute.json @@ -0,0 +1,191 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_common_types_AvidaVerifierExecuteMsg", + "type": "enum", + "cases": { + "deregister": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + } + } + }, + "register": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "requests": { + "value": 13 + } + } + }, + "update": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "route_criteria": { + "value": 15 + }, + "route_id": { + "value": 3 + } + } + }, + "update_revocation_list": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "request": { + "value": 2 + } + } + }, + "verify": { + "type": "named", + "properties": { + "additional_requirements": { + "value": 12 + }, + "app_addr": { + "value": 14 + }, + "presentation": { + "value": 10 + }, + "route_id": { + "value": 3 + } + } + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "avida_common_types_UpdateRevocationListRequest", + "description": "A Sd-jwt specific requirement for revocation list update\nusing Criterion::NotContainedIn", + "type": "struct", + "properties": { + "revoke": { + "value": 4 + }, + "route_id": { + "value": 3 + }, + "unrevoke": { + "value": 4 + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "avida_common_types_RegisterRouteRequest", + "description": "Routes Requiments used in Registration (and Initiation)", + "type": "struct", + "properties": { + "requirements": { + "value": 6 + }, + "route_id": { + "value": 3 + } + } + }, + { + "name": "avida_common_types_RouteVerificationRequirements", + "description": "Specific verification requirements for the route, by `route_id`", + "type": "struct", + "properties": { + "issuer_source_or_data": { + "description": "This defines where the source data for verification is", + "value": 11 + }, + "presentation_required": { + "description": "The presentation request is the criteria required for the presentation,\nfor example required certains claims to be disclosed\nThis value is stored as `VerificationRequirements.presentation_required` on sdjwtVerifier", + "value": 12 + } + } + }, + { + "name": "avida_common_types_IssuerSourceOrData", + "description": "Location to obtain the verification data from", + "type": "struct", + "properties": { + "data_or_location": { + "description": "The data or location of the verification data at the trust registry\nFor TrustRegistry::Cheqd, it is the `ResourceReqPacket` in avida-cheqd\nFor data, the contracts should have the expected type\nIn Sdjwt-Verifier, this is expected to be the JwkInfo struct", + "value": 10 + }, + "source": { + "description": "If `None`, this means data is directly provided", + "value": 9 + } + } + }, + { + "name": "avida_common_types_TrustRegistry", + "type": "enum", + "cases": { + "cheqd": { + "type": "unit" + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 8 + }, + { + "name": "cosmwasm_std_binary_Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization\nwith serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec.\nSee also .", + "type": "binary" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 7 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 10 + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 5 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 1 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 6 + } + ] +} diff --git a/contracts/sdjwt-verifier/schema/cw_schema/raw/instantiate.json b/contracts/sdjwt-verifier/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000..fff5023 --- /dev/null +++ b/contracts/sdjwt-verifier/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,131 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_sdjwt_verifier_msg_InstantiateMsg", + "type": "struct", + "properties": { + "init_registrations": { + "value": 14 + }, + "max_presentation_len": { + "value": 1 + } + } + }, + { + "name": "usize", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "avida_sdjwt_verifier_types_InitRegistration", + "type": "struct", + "properties": { + "app_addr": { + "value": 3 + }, + "app_admin": { + "value": 3 + }, + "routes": { + "value": 13 + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "avida_common_types_RegisterRouteRequest", + "description": "Routes Requiments used in Registration (and Initiation)", + "type": "struct", + "properties": { + "requirements": { + "value": 6 + }, + "route_id": { + "value": 5 + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "avida_common_types_RouteVerificationRequirements", + "description": "Specific verification requirements for the route, by `route_id`", + "type": "struct", + "properties": { + "issuer_source_or_data": { + "description": "This defines where the source data for verification is", + "value": 11 + }, + "presentation_required": { + "description": "The presentation request is the criteria required for the presentation,\nfor example required certains claims to be disclosed\nThis value is stored as `VerificationRequirements.presentation_required` on sdjwtVerifier", + "value": 12 + } + } + }, + { + "name": "avida_common_types_IssuerSourceOrData", + "description": "Location to obtain the verification data from", + "type": "struct", + "properties": { + "data_or_location": { + "description": "The data or location of the verification data at the trust registry\nFor TrustRegistry::Cheqd, it is the `ResourceReqPacket` in avida-cheqd\nFor data, the contracts should have the expected type\nIn Sdjwt-Verifier, this is expected to be the JwkInfo struct", + "value": 10 + }, + "source": { + "description": "If `None`, this means data is directly provided", + "value": 9 + } + } + }, + { + "name": "avida_common_types_TrustRegistry", + "type": "enum", + "cases": { + "cheqd": { + "type": "unit" + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 8 + }, + { + "name": "cosmwasm_std_binary_Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization\nwith serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec.\nSee also .", + "type": "binary" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 7 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 10 + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 4 + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + } + ] +} diff --git a/contracts/sdjwt-verifier/schema/cw_schema/raw/query.json b/contracts/sdjwt-verifier/schema/cw_schema/raw/query.json new file mode 100644 index 0000000..6fb0c89 --- /dev/null +++ b/contracts/sdjwt-verifier/schema/cw_schema/raw/query.json @@ -0,0 +1,60 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_sdjwt_verifier_msg_QueryMsg", + "type": "enum", + "cases": { + "get_app_admin": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + } + } + }, + "get_route_requirements": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "route_id": { + "value": 2 + } + } + }, + "get_route_verification_key": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + }, + "route_id": { + "value": 2 + } + } + }, + "get_routes": { + "type": "named", + "properties": { + "app_addr": { + "value": 1 + } + } + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + } + ] +} diff --git a/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_app_admin.json b/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_app_admin.json new file mode 100644 index 0000000..f27d584 --- /dev/null +++ b/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_app_admin.json @@ -0,0 +1,10 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "String", + "type": "string" + } + ] +} diff --git a/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_route_requirements.json b/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_route_requirements.json new file mode 100644 index 0000000..3091813 --- /dev/null +++ b/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_route_requirements.json @@ -0,0 +1,65 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "avida_common_types_RouteVerificationRequirements", + "description": "Specific verification requirements for the route, by `route_id`", + "type": "struct", + "properties": { + "issuer_source_or_data": { + "description": "This defines where the source data for verification is", + "value": 5 + }, + "presentation_required": { + "description": "The presentation request is the criteria required for the presentation,\nfor example required certains claims to be disclosed\nThis value is stored as `VerificationRequirements.presentation_required` on sdjwtVerifier", + "value": 6 + } + } + }, + { + "name": "avida_common_types_IssuerSourceOrData", + "description": "Location to obtain the verification data from", + "type": "struct", + "properties": { + "data_or_location": { + "description": "The data or location of the verification data at the trust registry\nFor TrustRegistry::Cheqd, it is the `ResourceReqPacket` in avida-cheqd\nFor data, the contracts should have the expected type\nIn Sdjwt-Verifier, this is expected to be the JwkInfo struct", + "value": 4 + }, + "source": { + "description": "If `None`, this means data is directly provided", + "value": 3 + } + } + }, + { + "name": "avida_common_types_TrustRegistry", + "type": "enum", + "cases": { + "cheqd": { + "type": "unit" + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 2 + }, + { + "name": "cosmwasm_std_binary_Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization\nwith serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec.\nSee also .", + "type": "binary" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 1 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 4 + } + ] +} diff --git a/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_route_verification_key.json b/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_route_verification_key.json new file mode 100644 index 0000000..de24a74 --- /dev/null +++ b/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_route_verification_key.json @@ -0,0 +1,15 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + } + ] +} diff --git a/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_routes.json b/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_routes.json new file mode 100644 index 0000000..282aab8 --- /dev/null +++ b/contracts/sdjwt-verifier/schema/cw_schema/raw/response_to_get_routes.json @@ -0,0 +1,17 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + } + ] +} diff --git a/packages/anoncreds/src/tests/types.rs b/packages/anoncreds/src/tests/types.rs index aa968cd..b74ba66 100644 --- a/packages/anoncreds/src/tests/types.rs +++ b/packages/anoncreds/src/tests/types.rs @@ -14,7 +14,7 @@ fn it_serde_json_correctly() { let string = String::from_utf8(bin.0).unwrap(); let expected = "{\"resourceId\":\"resuorce_id\",\"collectionId\":\"collection_id\"}"; - let req_de = serde_json_wasm::from_str(expected).unwrap(); + let req_de = serde_json::from_str(expected).unwrap(); assert_eq!(&string, expected); assert_eq!(req, req_de) } From e0ae37c310b032421ab3cf724cc096b1b8e27d8f Mon Sep 17 00:00:00 2001 From: bwty Date: Thu, 25 Sep 2025 15:51:01 +0100 Subject: [PATCH 04/16] feat: upgrade cosmwasm with tests --- .cargo/config.toml | 2 +- Cargo.lock | 22 ------ Cargo.toml | 6 +- Makefile | 11 ++- contracts/sdjwt-verifier/src/errors.rs | 2 + .../sdjwt-verifier/src/tests/contract_test.rs | 10 ++- .../src/tests/verifier_exp_test.rs | 4 +- .../src/tests/verifier_verify_test.rs | 7 +- contracts/sdjwt-verifier/src/types.rs | 2 +- contracts/sdjwt-verifier/src/verifier.rs | 72 ++++++++++--------- scripts/{build.sh => build-optimise.sh} | 0 scripts/schemas.sh | 2 +- 12 files changed, 71 insertions(+), 69 deletions(-) rename scripts/{build.sh => build-optimise.sh} (100%) diff --git a/.cargo/config.toml b/.cargo/config.toml index 45c7f3f..de5cf9e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ [alias] -cw-wasm = "build --lib --release --target wasm32-unknown-unknown --workspace --exclude avida-test-utils" +wasm = "build --lib --release --target wasm32-unknown-unknown --workspace --exclude avida-test-utils" diff --git a/Cargo.lock b/Cargo.lock index 243ab6f..58f85a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -204,28 +204,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "avida-example" -version = "0.1.0" -dependencies = [ - "avida-common", - "avida-sdjwt-verifier", - "avida-test-utils", - "cosmwasm-schema", - "cosmwasm-std", - "cw-multi-test", - "cw-storage-plus", - "cw-utils", - "cw2", - "josekit", - "jsonwebtoken 9.3.1", - "schemars 0.8.22", - "sd-jwt-rs 0.7.1", - "serde", - "serde_json", - "thiserror 1.0.69", -] - [[package]] name = "avida-sdjwt-verifier" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index d4621f4..fd2df80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,13 @@ [workspace] -members = ["packages/cheqd", "packages/common", "contracts/sdjwt-verifier", "contracts/avida_example", "packages/avida_test_utils"] +members = ["packages/cheqd", "packages/common", "contracts/sdjwt-verifier", "packages/avida_test_utils"] +excludes = ["contracts/avida_example", "contracts/anoncreds-verifier" ] resolver = "2" [workspace.package] version = "0.1.0" edition = "2021" repository = "https://github.com/nymlab/avida" -keywords = [ "Vectis", "CosmWasm", "zkp", "verifiableCredential", "sd-jwt" ] +keywords = [ "Vectis", "CosmWasm", "zkp", "verifiableCredential", "sd-jwt", "PlatformD" ] [workspace.dependencies] @@ -25,7 +26,6 @@ schemars = "0.8.16" serde = { version = "1.0.197", default-features = false, features = ["derive"] } thiserror = { version = "1.0.58" } sd-jwt-rs = { git = "https://github.com/nymlab/sd-jwt-rust", rev = "de9ccce7858e6e86f6a6e2f4dd23bcb4dc534421", default-features = false, features = ["no_rand"]} - jsonwebtoken = { git = "https://github.com/nymlab/jsonwebtoken", rev = "98763b38713c54f", default-features = false, features = ["no_rand"] } serde_json = {version = "1.0.116", default-features = false, features = ["alloc"]} cw-utils = "3.0.0" diff --git a/Makefile b/Makefile index 286233e..8bcd2ed 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,14 @@ +.PHONY: build-optimise build schemas + +# Use the optimizer to build contracts +build-optimise: + - ./scripts/build-optimise.sh + +# Building the contracts with target wasm32-unknown-unknown build: - - ./scripts/build.sh + cargo wasm + +# Create or update the JSON schemas for the contracts schemas: - ./scripts/schemas.sh diff --git a/contracts/sdjwt-verifier/src/errors.rs b/contracts/sdjwt-verifier/src/errors.rs index 404f3d1..e2d04b5 100644 --- a/contracts/sdjwt-verifier/src/errors.rs +++ b/contracts/sdjwt-verifier/src/errors.rs @@ -56,6 +56,8 @@ impl From for SdjwtVerifierResultError { pub enum SdjwtVerifierError { #[error("Verifier Result Error {0}")] SdjwtVerifierResultError(SdjwtVerifierResultError), + #[error("Verifier Result Error {0}")] + VerifyResultError(String), #[error("SudoValidationFailed")] SudoValidationFailed, #[error("IBC returned resource format unexpected {0}")] diff --git a/contracts/sdjwt-verifier/src/tests/contract_test.rs b/contracts/sdjwt-verifier/src/tests/contract_test.rs index 27f2f49..c97ea18 100644 --- a/contracts/sdjwt-verifier/src/tests/contract_test.rs +++ b/contracts/sdjwt-verifier/src/tests/contract_test.rs @@ -222,7 +222,10 @@ fn test_revoked_presentation_cannot_be_used() { assert!(!verify_res.success); let err = verify_res.error.unwrap(); - assert_eq!(err, SdjwtVerifierResultError::IdxRevoked(revoked_idx)); + assert_eq!( + err, + SdjwtVerifierResultError::IdxRevoked(revoked_idx).to_string() + ); let verify_msg = AvidaVerifierExecuteMsg::Verify { presentation: Binary::from(valid_presentation.as_bytes()), @@ -286,7 +289,10 @@ fn test_addition_requirements_with_revocation_list() { .unwrap(); assert!(!res.success); let err = res.error.unwrap(); - assert_eq!(err, SdjwtVerifierResultError::IdxRevoked(revoked_idx)); + assert_eq!( + err, + SdjwtVerifierResultError::IdxRevoked(revoked_idx).to_string() + ); // Additional requirements not present, revoked_claims is not checked and should ok let verify_msg = AvidaVerifierExecuteMsg::Verify { diff --git a/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs b/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs index 6dda83b..c2d1eff 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs +++ b/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs @@ -213,7 +213,7 @@ fn verify_failed_on_expired_claim() { assert_eq!( res.error.unwrap(), - SdjwtVerifierResultError::PresentationExpired(exp) + SdjwtVerifierResultError::PresentationExpired(exp).to_string() ); // Make a presentation with some claims that has expired @@ -245,7 +245,7 @@ fn verify_failed_on_expired_claim() { assert_eq!( res.error.unwrap(), - SdjwtVerifierResultError::PresentationExpired(exp) + SdjwtVerifierResultError::PresentationExpired(exp).to_string() ); } diff --git a/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs b/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs index cc6dfc9..97b3f67 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs +++ b/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs @@ -53,7 +53,7 @@ fn verify_success_incorrect_claims_validate_fails() { assert_eq!( res.error.unwrap(), - SdjwtVerifierResultError::CriterionValueFailed("joined_at".to_string()) + SdjwtVerifierResultError::CriterionValueFailed("joined_at".to_string()).to_string() ); } @@ -93,7 +93,7 @@ fn verify_required_claims_not_satisfied() { res.error.unwrap(), SdjwtVerifierResultError::DisclosedClaimNotFound( "Expects claim to be: Number(NumberCriterion { value: 30, operator: EqualTo }) for attr: age".to_string() - ) + ).to_string() ); } @@ -130,6 +130,7 @@ fn verify_without_sdjwt() { SdjwtVerifierResultError::SdJwtRsError( "invalid input: Invalid SD-JWT length: 1".to_string() ) + .to_string() ); } @@ -173,6 +174,6 @@ fn verify_presentation_too_large() { assert_eq!( res.error.unwrap(), - SdjwtVerifierResultError::PresentationTooLarge + SdjwtVerifierResultError::PresentationTooLarge.to_string() ); } diff --git a/contracts/sdjwt-verifier/src/types.rs b/contracts/sdjwt-verifier/src/types.rs index 85098a6..2c7d32e 100644 --- a/contracts/sdjwt-verifier/src/types.rs +++ b/contracts/sdjwt-verifier/src/types.rs @@ -26,7 +26,7 @@ pub struct JwkInfo { pub struct VerifyResult { pub success: bool, pub value: Option, - pub error: Option, + pub error: Option, } #[cw_serde] diff --git a/contracts/sdjwt-verifier/src/verifier.rs b/contracts/sdjwt-verifier/src/verifier.rs index 436c3c1..43d1dbd 100644 --- a/contracts/sdjwt-verifier/src/verifier.rs +++ b/contracts/sdjwt-verifier/src/verifier.rs @@ -101,6 +101,7 @@ pub fn handle_register( ) } +/// Exec message handlers returns Response as data for verification pub fn handle_verify( deps: DepsMut, env: Env, @@ -112,17 +113,19 @@ pub fn handle_verify( ) -> Result { let app_addr = app_addr.unwrap_or_else(|| info.sender.to_string()); - _handle_verify( + let res = _handle_verify( deps, env, app_addr, route_id, presentation, additional_requirements, - ) + )?; + + Ok(Response::new().set_data(to_json_binary(&res)?)) } -// Sudo message handlers +/// Sudo message handlers returns error if verification fails pub fn handle_sudo_verify( deps: DepsMut, env: Env, @@ -131,14 +134,23 @@ pub fn handle_sudo_verify( presentation: VerfiablePresentation, additional_requirements: Option, ) -> Result { - _handle_verify( + let res = _handle_verify( deps, env, app_addr, route_id, presentation, additional_requirements, - ) + )?; + + if res.success { + Ok(Response::new() + .add_attribute("action", "sudo_verify") + .add_attribute("success", "true") + .set_data(res.value.unwrap_or_default())) + } else { + Err(SdjwtVerifierError::VerifyResultError(res.error.unwrap())) + } } pub fn _handle_verify( @@ -148,7 +160,7 @@ pub fn _handle_verify( route_id: RouteId, presentation: VerfiablePresentation, additional_requirements: Option, -) -> Result { +) -> Result { let additional_requirements: Option = additional_requirements.map(from_json).transpose()?; @@ -166,7 +178,27 @@ pub fn _handle_verify( additional_requirements, ); - create_verify_response(res) + let verify_result = match res { + Ok(value) => { + let binary_value = Binary::from(serde_json::to_vec(&value).map_err(|e| { + SdjwtVerifierError::SdjwtVerifierResultError( + SdjwtVerifierResultError::VerifiedClaimsToBinaryError(e.to_string()), + ) + })?); + + VerifyResult { + success: true, + value: Some(binary_value), + error: None, + } + } + Err(error) => VerifyResult { + success: false, + value: None, + error: Some(error.to_string()), + }, + }; + Ok(verify_result) } pub fn handle_update( @@ -272,32 +304,6 @@ pub fn query_route_requirements( Ok(req) } -fn create_verify_response( - res: Result, -) -> Result { - let verify_result = match res { - Ok(value) => { - let binary_value = Binary::from(serde_json::to_vec(&value).map_err(|e| { - SdjwtVerifierError::SdjwtVerifierResultError( - SdjwtVerifierResultError::VerifiedClaimsToBinaryError(e.to_string()), - ) - })?); - VerifyResult { - success: true, - value: Some(binary_value), - error: None, - } - } - Err(error) => VerifyResult { - success: false, - value: None, - error: Some(error), - }, - }; - let data = to_json_binary(&verify_result)?; - Ok(Response::default().set_data(data)) -} - /// Verify the provided presentation within the context of the given route pub fn _verify( presentation: VerfiablePresentation, diff --git a/scripts/build.sh b/scripts/build-optimise.sh similarity index 100% rename from scripts/build.sh rename to scripts/build-optimise.sh diff --git a/scripts/schemas.sh b/scripts/schemas.sh index f48784c..12b4990 100755 --- a/scripts/schemas.sh +++ b/scripts/schemas.sh @@ -1,6 +1,6 @@ for dir in $PWD/contracts/sdjwt-verifier/ $PWD/contracts/avida_example; do cd $dir - cargo run + cargo schema cd - done From 6c2de4c39bd346b7b571e1bc24519ef9e28723d9 Mon Sep 17 00:00:00 2001 From: bwty Date: Thu, 25 Sep 2025 15:52:56 +0100 Subject: [PATCH 05/16] fix: Cargo.toml misspell --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fd2df80..ea61f72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = ["packages/cheqd", "packages/common", "contracts/sdjwt-verifier", "packages/avida_test_utils"] -excludes = ["contracts/avida_example", "contracts/anoncreds-verifier" ] +exclude = ["contracts/avida_example", "contracts/anoncreds-verifier" ] resolver = "2" [workspace.package] From c002434183d28fe2eb7f3f4896261d7e968e6855 Mon Sep 17 00:00:00 2001 From: bwty Date: Thu, 25 Sep 2025 18:39:24 +0100 Subject: [PATCH 06/16] fix: clippy --- .cargo/config.toml | 10 +++++++++- Cargo.lock | 2 +- contracts/sdjwt-verifier/src/verifier.rs | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index de5cf9e..2da26cd 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,10 @@ +[net] +git-fetch-with-cli = true + +[url."https://github.com/"] +insteadOf = "git@github.com:" + [alias] -wasm = "build --lib --release --target wasm32-unknown-unknown --workspace --exclude avida-test-utils" +wasm = "build --target wasm32-unknown-unknown --release --lib" +wasm-debug = "build --target wasm32-unknown-unknown --lib" +schema = "run schema" diff --git a/Cargo.lock b/Cargo.lock index 58f85a6..e24b1e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" diff --git a/contracts/sdjwt-verifier/src/verifier.rs b/contracts/sdjwt-verifier/src/verifier.rs index 43d1dbd..10e80c0 100644 --- a/contracts/sdjwt-verifier/src/verifier.rs +++ b/contracts/sdjwt-verifier/src/verifier.rs @@ -272,8 +272,8 @@ pub fn query_route_verification_keys( .map_err(|_| SdjwtVerifierError::RouteNotRegistered)?; let keys = route_req.issuer_pubkeys.as_ref().map(|jwks| { - jwks.iter() - .map(|(_, jwk)| serde_json::to_string(jwk).unwrap()) + jwks.values() + .map(|jwk| serde_json::to_string(jwk).unwrap()) .collect() }); From cd7c312a1a75ed3f237dfb5477a716a110761011 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 06:41:47 +0100 Subject: [PATCH 07/16] fix: compile and build by moving tests --- Cargo.lock | 5 +---- Cargo.toml | 2 +- contracts/sdjwt-verifier/Cargo.toml | 5 ----- contracts/sdjwt-verifier/src/lib.rs | 3 --- contracts/sdjwt-verifier/src/msg.rs | 4 ++-- packages/avida_test_utils/src/lib.rs | 2 -- packages/avida_test_utils/src/sdjwt/mod.rs | 1 - .../Cargo.toml | 6 +++--- .../fixtures/test_ed25519_private.pem | 0 .../fixtures/test_ed25519_public.pem | 0 .../fixtures/test_rsa_private.pem | 0 .../fixtures/test_rsa_public.pem | 0 packages/avida_tests/src/lib.rs | 2 ++ .../src/sdjwt/fixtures.rs | 0 packages/avida_tests/src/sdjwt/mod.rs | 3 +++ .../src/sdjwt}/tests/contract_test.rs | 12 +++++------ .../avida_tests/src/sdjwt}/tests/fixtures.rs | 12 +++++------ .../avida_tests/src/sdjwt}/tests/mod.rs | 1 + .../avida_tests/src/sdjwt}/tests/types.rs | 2 +- .../src/sdjwt}/tests/verifier_exp_test.rs | 8 ++++---- .../sdjwt}/tests/verifier_register_test.rs | 14 +++++++------ .../src/sdjwt}/tests/verifier_test.rs | 6 +++--- .../src/sdjwt}/tests/verifier_update_test.rs | 20 +++++++++---------- .../src/sdjwt}/tests/verifier_verify_test.rs | 8 ++++---- 24 files changed, 55 insertions(+), 61 deletions(-) delete mode 100644 packages/avida_test_utils/src/lib.rs delete mode 100644 packages/avida_test_utils/src/sdjwt/mod.rs rename packages/{avida_test_utils => avida_tests}/Cargo.toml (85%) rename packages/{avida_test_utils => avida_tests}/fixtures/test_ed25519_private.pem (100%) rename packages/{avida_test_utils => avida_tests}/fixtures/test_ed25519_public.pem (100%) rename packages/{avida_test_utils => avida_tests}/fixtures/test_rsa_private.pem (100%) rename packages/{avida_test_utils => avida_tests}/fixtures/test_rsa_public.pem (100%) create mode 100644 packages/avida_tests/src/lib.rs rename packages/{avida_test_utils => avida_tests}/src/sdjwt/fixtures.rs (100%) create mode 100644 packages/avida_tests/src/sdjwt/mod.rs rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/contract_test.rs (97%) rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/fixtures.rs (87%) rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/mod.rs (92%) rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/types.rs (81%) rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/verifier_exp_test.rs (98%) rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/verifier_register_test.rs (97%) rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/verifier_test.rs (90%) rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/verifier_update_test.rs (96%) rename {contracts/sdjwt-verifier/src => packages/avida_tests/src/sdjwt}/tests/verifier_verify_test.rs (97%) diff --git a/Cargo.lock b/Cargo.lock index e24b1e8..8048fb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,14 +210,11 @@ version = "0.1.0" dependencies = [ "avida-cheqd", "avida-common", - "avida-test-utils", "cosmwasm-schema", "cosmwasm-std", - "cw-multi-test", "cw-storage-plus", "cw-utils", "cw2", - "josekit", "jsonwebtoken 9.3.0", "schemars 0.8.22", "sd-jwt-rs 0.7.0", @@ -227,7 +224,7 @@ dependencies = [ ] [[package]] -name = "avida-test-utils" +name = "avida-tests" version = "0.1.0" dependencies = [ "avida-common", diff --git a/Cargo.toml b/Cargo.toml index ea61f72..ce0d856 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["packages/cheqd", "packages/common", "contracts/sdjwt-verifier", "packages/avida_test_utils"] +members = ["packages/cheqd", "packages/common", "contracts/sdjwt-verifier", "packages/avida_tests"] exclude = ["contracts/avida_example", "contracts/anoncreds-verifier" ] resolver = "2" diff --git a/contracts/sdjwt-verifier/Cargo.toml b/contracts/sdjwt-verifier/Cargo.toml index efbdd03..01b7015 100644 --- a/contracts/sdjwt-verifier/Cargo.toml +++ b/contracts/sdjwt-verifier/Cargo.toml @@ -31,8 +31,3 @@ sd-jwt-rs = { workspace = true } jsonwebtoken = { workspace = true } serde_json = { workspace = true, default-features = false, features = ["alloc"]} cw-utils = { workspace = true } - -[dev-dependencies] -avida-test-utils = { path = "../../packages/avida_test_utils/", features = ["sdjwt"]} -cw-multi-test = {version = "3", features = ["staking", "stargate", "cosmwasm_3_0"]} -josekit = "0.8.6" diff --git a/contracts/sdjwt-verifier/src/lib.rs b/contracts/sdjwt-verifier/src/lib.rs index fba2929..8b86b0d 100644 --- a/contracts/sdjwt-verifier/src/lib.rs +++ b/contracts/sdjwt-verifier/src/lib.rs @@ -4,6 +4,3 @@ pub mod msg; mod state; pub mod types; mod verifier; - -#[cfg(test)] -mod tests; diff --git a/contracts/sdjwt-verifier/src/msg.rs b/contracts/sdjwt-verifier/src/msg.rs index 0de7f0e..07e3cdd 100644 --- a/contracts/sdjwt-verifier/src/msg.rs +++ b/contracts/sdjwt-verifier/src/msg.rs @@ -1,4 +1,4 @@ -use avida_common::types::{RouteId, RouteVerificationRequirements}; +use avida_common::types::RouteId; use cosmwasm_schema::QueryResponses; use crate::types::InitRegistration; @@ -20,6 +20,6 @@ pub enum QueryMsg { GetAppAdmin { app_addr: String }, #[returns(Vec)] GetRoutes { app_addr: String }, - #[returns(RouteVerificationRequirements)] + #[returns(avida_common::types::RouteVerificationRequirements)] GetRouteRequirements { app_addr: String, route_id: RouteId }, } diff --git a/packages/avida_test_utils/src/lib.rs b/packages/avida_test_utils/src/lib.rs deleted file mode 100644 index 7178a26..0000000 --- a/packages/avida_test_utils/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[cfg(feature = "sdjwt")] -pub mod sdjwt; diff --git a/packages/avida_test_utils/src/sdjwt/mod.rs b/packages/avida_test_utils/src/sdjwt/mod.rs deleted file mode 100644 index d066349..0000000 --- a/packages/avida_test_utils/src/sdjwt/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod fixtures; diff --git a/packages/avida_test_utils/Cargo.toml b/packages/avida_tests/Cargo.toml similarity index 85% rename from packages/avida_test_utils/Cargo.toml rename to packages/avida_tests/Cargo.toml index e0f6cef..ba3d035 100644 --- a/packages/avida_test_utils/Cargo.toml +++ b/packages/avida_tests/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "avida-test-utils" -description = "Useful library for test suites for DApp interactions" +name = "avida-tests" +description = "Tests and useful library for test suites for DApp interactions" edition = "2021" version = { workspace = true } repository = { workspace = true } @@ -9,7 +9,7 @@ keywords = { workspace = true } [features] sdjwt = [] -[dependencies] +[dev-dependencies] # sd-jwt verifier contract avida-sdjwt-verifier = { path = "../../contracts/sdjwt-verifier/", features = ["library"]} avida-common = { path = "../../packages/common/"} diff --git a/packages/avida_test_utils/fixtures/test_ed25519_private.pem b/packages/avida_tests/fixtures/test_ed25519_private.pem similarity index 100% rename from packages/avida_test_utils/fixtures/test_ed25519_private.pem rename to packages/avida_tests/fixtures/test_ed25519_private.pem diff --git a/packages/avida_test_utils/fixtures/test_ed25519_public.pem b/packages/avida_tests/fixtures/test_ed25519_public.pem similarity index 100% rename from packages/avida_test_utils/fixtures/test_ed25519_public.pem rename to packages/avida_tests/fixtures/test_ed25519_public.pem diff --git a/packages/avida_test_utils/fixtures/test_rsa_private.pem b/packages/avida_tests/fixtures/test_rsa_private.pem similarity index 100% rename from packages/avida_test_utils/fixtures/test_rsa_private.pem rename to packages/avida_tests/fixtures/test_rsa_private.pem diff --git a/packages/avida_test_utils/fixtures/test_rsa_public.pem b/packages/avida_tests/fixtures/test_rsa_public.pem similarity index 100% rename from packages/avida_test_utils/fixtures/test_rsa_public.pem rename to packages/avida_tests/fixtures/test_rsa_public.pem diff --git a/packages/avida_tests/src/lib.rs b/packages/avida_tests/src/lib.rs new file mode 100644 index 0000000..c844f60 --- /dev/null +++ b/packages/avida_tests/src/lib.rs @@ -0,0 +1,2 @@ +#![cfg(test)] +pub mod sdjwt; diff --git a/packages/avida_test_utils/src/sdjwt/fixtures.rs b/packages/avida_tests/src/sdjwt/fixtures.rs similarity index 100% rename from packages/avida_test_utils/src/sdjwt/fixtures.rs rename to packages/avida_tests/src/sdjwt/fixtures.rs diff --git a/packages/avida_tests/src/sdjwt/mod.rs b/packages/avida_tests/src/sdjwt/mod.rs new file mode 100644 index 0000000..d2dbe49 --- /dev/null +++ b/packages/avida_tests/src/sdjwt/mod.rs @@ -0,0 +1,3 @@ +#![cfg(test)] +pub mod fixtures; +mod tests; diff --git a/contracts/sdjwt-verifier/src/tests/contract_test.rs b/packages/avida_tests/src/sdjwt/tests/contract_test.rs similarity index 97% rename from contracts/sdjwt-verifier/src/tests/contract_test.rs rename to packages/avida_tests/src/sdjwt/tests/contract_test.rs index c97ea18..4ccb12a 100644 --- a/contracts/sdjwt-verifier/src/tests/contract_test.rs +++ b/packages/avida_tests/src/sdjwt/tests/contract_test.rs @@ -1,18 +1,18 @@ use cosmwasm_std::{from_json, to_json_binary, Binary}; use cw_multi_test::{App, Executor}; -use crate::errors::SdjwtVerifierResultError; -use crate::types::{Criterion, ReqAttr, VerificationRequirements, VerifyResult}; +use avida_sdjwt_verifier::errors::SdjwtVerifierResultError; +use avida_sdjwt_verifier::types::{Criterion, ReqAttr, VerificationRequirements, VerifyResult}; use serde::{Deserialize, Serialize}; use super::fixtures::default_instantiate_verifier_contract; -use crate::msg::QueryMsg; -use avida_common::types::AvidaVerifierExecuteMsg; -use avida_common::types::UpdateRevocationListRequest; -use avida_test_utils::sdjwt::fixtures::{ +use crate::sdjwt::fixtures::{ claims_with_revocation_idx, get_route_requirement_with_empty_revocation_list, make_presentation, PresentationVerificationType, FIRST_CALLER_APP_ADDR, FIRST_ROUTE_ID, }; +use avida_common::types::AvidaVerifierExecuteMsg; +use avida_common::types::UpdateRevocationListRequest; +use avida_sdjwt_verifier::msg::QueryMsg; #[derive(Debug, Serialize, Deserialize)] pub struct Claims { diff --git a/contracts/sdjwt-verifier/src/tests/fixtures.rs b/packages/avida_tests/src/sdjwt/tests/fixtures.rs similarity index 87% rename from contracts/sdjwt-verifier/src/tests/fixtures.rs rename to packages/avida_tests/src/sdjwt/tests/fixtures.rs index 9753ab5..630d30c 100644 --- a/contracts/sdjwt-verifier/src/tests/fixtures.rs +++ b/packages/avida_tests/src/sdjwt/tests/fixtures.rs @@ -1,4 +1,4 @@ -use avida_test_utils::sdjwt::fixtures::{ +use crate::sdjwt::fixtures::{ get_default_presentation_required, make_route_verification_requirements, ExpirationCheck, KeyType, FIRST_CALLER_APP_ADDR, FIRST_ROUTE_ID, MAX_PRESENTATION_LEN, OWNER_ADDR, VERIFIER_CONTRACT_LABEL, @@ -9,11 +9,11 @@ use avida_common::types::{RegisterRouteRequest, RouteVerificationRequirements}; use cosmwasm_std::{Addr, Empty}; use cw_multi_test::{App as MtApp, Contract, ContractWrapper, Executor}; -use crate::contract; -use crate::msg::InstantiateMsg; -use crate::types::InitRegistration; +use avida_sdjwt_verifier::contract; +use avida_sdjwt_verifier::msg::InstantiateMsg; +use avida_sdjwt_verifier::types::InitRegistration; -fn notarised_odp_contract() -> Box> { +fn verifier_contract() -> Box> { Box::new(ContractWrapper::new_with_empty( contract::execute, contract::instantiate, @@ -30,7 +30,7 @@ pub fn default_instantiate_verifier_contract( let fx_route_verification_req = make_route_verification_requirements(presentation_required, KeyType::Ed25519); - let contract = notarised_odp_contract(); + let contract = verifier_contract(); let code_id = app.store_code(contract); let first_caller_app_addr = app.api().addr_make(FIRST_CALLER_APP_ADDR); let init_registrations = vec![InitRegistration { diff --git a/contracts/sdjwt-verifier/src/tests/mod.rs b/packages/avida_tests/src/sdjwt/tests/mod.rs similarity index 92% rename from contracts/sdjwt-verifier/src/tests/mod.rs rename to packages/avida_tests/src/sdjwt/tests/mod.rs index 49d359d..a92b86c 100644 --- a/contracts/sdjwt-verifier/src/tests/mod.rs +++ b/packages/avida_tests/src/sdjwt/tests/mod.rs @@ -1,3 +1,4 @@ +#![cfg(test)] mod contract_test; mod fixtures; mod types; diff --git a/contracts/sdjwt-verifier/src/tests/types.rs b/packages/avida_tests/src/sdjwt/tests/types.rs similarity index 81% rename from contracts/sdjwt-verifier/src/tests/types.rs rename to packages/avida_tests/src/sdjwt/tests/types.rs index f2fde9f..dd2bac7 100644 --- a/contracts/sdjwt-verifier/src/tests/types.rs +++ b/packages/avida_tests/src/sdjwt/tests/types.rs @@ -14,6 +14,6 @@ fn test_presentation_req_from_json() { ]"# .as_bytes(); - let e = serde_json::from_slice::>(data); + let e = serde_json::from_slice::>(data); assert!(e.is_ok()); } diff --git a/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs b/packages/avida_tests/src/sdjwt/tests/verifier_exp_test.rs similarity index 98% rename from contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs rename to packages/avida_tests/src/sdjwt/tests/verifier_exp_test.rs index c2d1eff..4d62be4 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_exp_test.rs +++ b/packages/avida_tests/src/sdjwt/tests/verifier_exp_test.rs @@ -1,18 +1,18 @@ use cosmwasm_std::{from_json, Binary}; use cw_multi_test::{App, Executor}; -use crate::errors::SdjwtVerifierResultError; -use crate::types::VerifyResult; use avida_common::types::RegisterRouteRequest; +use avida_sdjwt_verifier::errors::SdjwtVerifierResultError; +use avida_sdjwt_verifier::types::VerifyResult; use serde::{Deserialize, Serialize}; use super::fixtures::default_instantiate_verifier_contract; -use avida_common::types::AvidaVerifierExecuteMsg; -use avida_test_utils::sdjwt::fixtures::{ +use crate::sdjwt::fixtures::{ claims, get_default_block_info, get_default_presentation_required, make_presentation, make_route_verification_requirements, ExpirationCheck, KeyType, PresentationVerificationType, FIRST_CALLER_APP_ADDR, FIRST_ROUTE_ID, OWNER_ADDR, SECOND_CALLER_APP_ADDR, SECOND_ROUTE_ID, }; +use avida_common::types::AvidaVerifierExecuteMsg; #[derive(Debug, Serialize, Deserialize)] pub struct Claims { diff --git a/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs b/packages/avida_tests/src/sdjwt/tests/verifier_register_test.rs similarity index 97% rename from contracts/sdjwt-verifier/src/tests/verifier_register_test.rs rename to packages/avida_tests/src/sdjwt/tests/verifier_register_test.rs index 537cabf..103319c 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_register_test.rs +++ b/packages/avida_tests/src/sdjwt/tests/verifier_register_test.rs @@ -1,19 +1,21 @@ use cosmwasm_std::Binary; use cw_multi_test::{App, Executor}; -use crate::errors::SdjwtVerifierError; +use avida_sdjwt_verifier::{ + errors::SdjwtVerifierError, msg::QueryMsg, types::VerificationRequirements, +}; + use serde::{Deserialize, Serialize}; use josekit::{self}; use super::fixtures::default_instantiate_verifier_contract; -use crate::msg::QueryMsg; -use avida_common::types::AvidaVerifierExecuteMsg; -use avida_test_utils::sdjwt::fixtures::{ +use crate::sdjwt::fixtures::{ claims, get_input_route_requirement, get_two_input_routes_requirements, issuer_jwk, make_presentation, KeyType, PresentationVerificationType, FIRST_CALLER_APP_ADDR, OWNER_ADDR, SECOND_CALLER_APP_ADDR, SECOND_ROUTE_ID, THIRD_ROUTE_ID, }; +use avida_common::types::AvidaVerifierExecuteMsg; #[derive(Debug, Serialize, Deserialize)] pub struct Claims { @@ -95,7 +97,7 @@ fn register_success() { // Query the route requirements let second_registered_req = app .wrap() - .query_wasm_smart::( + .query_wasm_smart::( contract_addr.clone(), &QueryMsg::GetRouteRequirements { app_addr: second_caller_app_addr.to_string(), @@ -125,7 +127,7 @@ fn register_success() { let third_registered_req = app .wrap() - .query_wasm_smart::( + .query_wasm_smart::( contract_addr.clone(), &QueryMsg::GetRouteRequirements { app_addr: second_caller_app_addr.to_string(), diff --git a/contracts/sdjwt-verifier/src/tests/verifier_test.rs b/packages/avida_tests/src/sdjwt/tests/verifier_test.rs similarity index 90% rename from contracts/sdjwt-verifier/src/tests/verifier_test.rs rename to packages/avida_tests/src/sdjwt/tests/verifier_test.rs index 62f9bbe..c68e8b2 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_test.rs +++ b/packages/avida_tests/src/sdjwt/tests/verifier_test.rs @@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize}; use josekit::{self}; use super::fixtures::default_instantiate_verifier_contract; -use crate::msg::QueryMsg; -use avida_test_utils::sdjwt::fixtures::{issuer_jwk, FIRST_CALLER_APP_ADDR, FIRST_ROUTE_ID}; +use crate::sdjwt::fixtures::{issuer_jwk, FIRST_CALLER_APP_ADDR, FIRST_ROUTE_ID}; +use avida_sdjwt_verifier::{msg::QueryMsg, types::VerificationRequirements}; #[derive(Debug, Serialize, Deserialize)] pub struct Claims { @@ -39,7 +39,7 @@ fn instantiate_success() { let registered_req = app .wrap() - .query_wasm_smart::( + .query_wasm_smart::( contract_addr.clone(), &QueryMsg::GetRouteRequirements { app_addr: first_caller_app_addr.to_string(), diff --git a/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs b/packages/avida_tests/src/sdjwt/tests/verifier_update_test.rs similarity index 96% rename from contracts/sdjwt-verifier/src/tests/verifier_update_test.rs rename to packages/avida_tests/src/sdjwt/tests/verifier_update_test.rs index ff9e2f3..c1684ec 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_update_test.rs +++ b/packages/avida_tests/src/sdjwt/tests/verifier_update_test.rs @@ -1,19 +1,19 @@ use cosmwasm_std::{to_json_binary, Binary}; use cw_multi_test::{App, Executor}; -use crate::{ - errors::SdjwtVerifierError, - types::{Criterion, JwkInfo, ReqAttr, CW_EXPIRATION}, -}; use avida_common::types::{ AvidaVerifierExecuteMsg, IssuerSourceOrData, RegisterRouteRequest, RouteVerificationRequirements, }; +use avida_sdjwt_verifier::{ + errors::SdjwtVerifierError, + msg::QueryMsg, + types::{Criterion, JwkInfo, ReqAttr, VerificationRequirements, CW_EXPIRATION}, +}; use serde::{Deserialize, Serialize}; use super::fixtures::default_instantiate_verifier_contract; -use crate::msg::QueryMsg; -use avida_test_utils::sdjwt::fixtures::{ +use crate::sdjwt::fixtures::{ get_default_presentation_required, get_input_route_requirement, get_two_input_routes_requirements, issuer_jwk, make_route_verification_requirements, ExpirationCheck, KeyType, FIRST_CALLER_APP_ADDR, FIRST_ROUTE_ID, OWNER_ADDR, @@ -39,7 +39,7 @@ fn update_adding_new_jwk() { // Get existing route pubkeys let existing_registered_req = app .wrap() - .query_wasm_smart::( + .query_wasm_smart::( contract_addr.clone(), &QueryMsg::GetRouteRequirements { app_addr: app_admin.to_string(), @@ -100,7 +100,7 @@ fn update_adding_new_jwk() { // Ensure that the route verification requirements are updated let updated_registered_req = app .wrap() - .query_wasm_smart::( + .query_wasm_smart::( contract_addr.clone(), &QueryMsg::GetRouteRequirements { app_addr: app_admin.to_string(), @@ -347,7 +347,7 @@ fn update_adding_and_remove_extra_route() { // Ensure that the route verification requirements are updated let updated_registered_req = app .wrap() - .query_wasm_smart::( + .query_wasm_smart::( contract_addr.clone(), &QueryMsg::GetRouteRequirements { app_addr: second_caller_app_addr.to_string(), @@ -385,7 +385,7 @@ fn update_adding_and_remove_extra_route() { // Verify route requirements are removed assert!(app .wrap() - .query_wasm_smart::( + .query_wasm_smart::( contract_addr, &QueryMsg::GetRouteRequirements { app_addr: second_caller_app_addr.to_string(), diff --git a/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs b/packages/avida_tests/src/sdjwt/tests/verifier_verify_test.rs similarity index 97% rename from contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs rename to packages/avida_tests/src/sdjwt/tests/verifier_verify_test.rs index 97b3f67..58e19d9 100644 --- a/contracts/sdjwt-verifier/src/tests/verifier_verify_test.rs +++ b/packages/avida_tests/src/sdjwt/tests/verifier_verify_test.rs @@ -1,16 +1,16 @@ use cosmwasm_std::{from_json, Binary}; use cw_multi_test::{App, Executor}; -use crate::errors::SdjwtVerifierResultError; -use crate::types::VerifyResult; +use avida_sdjwt_verifier::errors::SdjwtVerifierResultError; +use avida_sdjwt_verifier::types::VerifyResult; use serde::{Deserialize, Serialize}; use super::fixtures::default_instantiate_verifier_contract; -use avida_common::types::AvidaVerifierExecuteMsg; -use avida_test_utils::sdjwt::fixtures::{ +use crate::sdjwt::fixtures::{ claims, make_presentation, PresentationVerificationType, FIRST_CALLER_APP_ADDR, FIRST_ROUTE_ID, MAX_PRESENTATION_LEN, }; +use avida_common::types::AvidaVerifierExecuteMsg; #[derive(Debug, Serialize, Deserialize)] pub struct Claims { From 7f0cfcc61fb01cd15a3c5f1de1c59f8328e47913 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 06:55:56 +0100 Subject: [PATCH 08/16] chore: add toolchain --- rust-toolchain.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..552d6d6 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.85.0" \ No newline at end of file From d8064a9d733d8617064457898e408acb1a831555 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 06:57:11 +0100 Subject: [PATCH 09/16] chore: add toolchain --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 552d6d6..c1bc0a6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.85.0" \ No newline at end of file +channel = "1.85.0" From 05d148686f6df98b872ccb7506defe40d5603849 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 07:01:21 +0100 Subject: [PATCH 10/16] feat: gha not override --- .github/workflows/tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1ca6551..f8a1c15 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,7 +24,6 @@ jobs: profile: minimal toolchain: stable target: wasm32-unknown-unknown - override: true - name: Run contract unit tests run: cargo test @@ -45,7 +44,6 @@ jobs: profile: minimal toolchain: stable target: wasm32-unknown-unknown - override: true - name: Compile WASM contract run: make build @@ -64,7 +62,6 @@ jobs: with: profile: minimal toolchain: stable - override: true components: rustfmt, clippy - name: Run cargo fmt From fd0e659a910efbd70171ec1c52d04d92438cc488 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 07:11:00 +0100 Subject: [PATCH 11/16] chore: fix gha --- .github/workflows/tests.yml | 6 +++--- rust-toolchain.toml | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f8a1c15..efd89d6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,7 @@ jobs: submodules: recursive - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: profile: minimal toolchain: stable @@ -39,7 +39,7 @@ jobs: submodules: recursive - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: profile: minimal toolchain: stable @@ -58,7 +58,7 @@ jobs: submodules: recursive - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: profile: minimal toolchain: stable diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c1bc0a6..bcb3be2 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,4 @@ [toolchain] channel = "1.85.0" +components = ["rustfmt", "clippy"] +targets = ["wasm32-unknown-unknown"] From 67b8af593047361efb1a99dad3c453ea3826b306 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 07:27:26 +0100 Subject: [PATCH 12/16] fix: try fix test error --- contracts/sdjwt-verifier/src/errors.rs | 4 ++-- contracts/sdjwt-verifier/src/verifier.rs | 6 +++--- .../avida_tests/src/sdjwt/tests/verifier_register_test.rs | 2 +- .../avida_tests/src/sdjwt/tests/verifier_update_test.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/sdjwt-verifier/src/errors.rs b/contracts/sdjwt-verifier/src/errors.rs index e2d04b5..3a03894 100644 --- a/contracts/sdjwt-verifier/src/errors.rs +++ b/contracts/sdjwt-verifier/src/errors.rs @@ -76,8 +76,8 @@ pub enum SdjwtVerifierError { AppAlreadyRegistered, #[error("App Is Not Registered")] AppIsNotRegistered, - #[error("Unauthorised")] - Unauthorised, + #[error("Unauthorised Caller")] + UnauthorisedCaller, #[error("Unsupported Key Type")] UnsupportedKeyType, #[error("Route Not Registered")] diff --git a/contracts/sdjwt-verifier/src/verifier.rs b/contracts/sdjwt-verifier/src/verifier.rs index 10e80c0..7fed58c 100644 --- a/contracts/sdjwt-verifier/src/verifier.rs +++ b/contracts/sdjwt-verifier/src/verifier.rs @@ -54,7 +54,7 @@ pub fn handle_update_revocation_list( .map_err(|_| SdjwtVerifierError::AppIsNotRegistered)?; if app_admin != info.sender { - return Err(SdjwtVerifierError::Unauthorised); + return Err(SdjwtVerifierError::UnauthorisedCaller); } route_requirements @@ -216,7 +216,7 @@ pub fn handle_update( .map_err(|_| SdjwtVerifierError::AppIsNotRegistered)?; if app_admin != info.sender { - return Err(SdjwtVerifierError::Unauthorised); + return Err(SdjwtVerifierError::UnauthorisedCaller); } _update( @@ -246,7 +246,7 @@ pub fn handle_deregister( let app_admin = APP_ADMINS.load(deps.storage, app_addr.as_str())?; if app_admin != info.sender { - return Err(SdjwtVerifierError::Unauthorised); + return Err(SdjwtVerifierError::UnauthorisedCaller); } _deregister(deps.storage, app_addr.as_str()) diff --git a/packages/avida_tests/src/sdjwt/tests/verifier_register_test.rs b/packages/avida_tests/src/sdjwt/tests/verifier_register_test.rs index 103319c..b0f959c 100644 --- a/packages/avida_tests/src/sdjwt/tests/verifier_register_test.rs +++ b/packages/avida_tests/src/sdjwt/tests/verifier_register_test.rs @@ -385,5 +385,5 @@ fn deregister_unauthorized() { assert!(err .to_string() - .contains(&SdjwtVerifierError::Unauthorised.to_string())); + .contains(&SdjwtVerifierError::UnauthorisedCaller.to_string())); } diff --git a/packages/avida_tests/src/sdjwt/tests/verifier_update_test.rs b/packages/avida_tests/src/sdjwt/tests/verifier_update_test.rs index c1684ec..6409960 100644 --- a/packages/avida_tests/src/sdjwt/tests/verifier_update_test.rs +++ b/packages/avida_tests/src/sdjwt/tests/verifier_update_test.rs @@ -195,7 +195,7 @@ fn update_unauthorized() { assert!(err .to_string() - .contains(&SdjwtVerifierError::Unauthorised.to_string())); + .contains(&SdjwtVerifierError::UnauthorisedCaller.to_string())); } #[test] From d3d0789987aa1a4862b5bd0798a718f0aeab4469 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 10:23:01 +0100 Subject: [PATCH 13/16] fix: match versions --- rust-toolchain.toml | 2 +- scripts/build-optimise.sh | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index bcb3be2..91e04e8 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.85.0" +channel = "1.86.0" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/scripts/build-optimise.sh b/scripts/build-optimise.sh index 81e4874..b509191 100755 --- a/scripts/build-optimise.sh +++ b/scripts/build-optimise.sh @@ -5,9 +5,9 @@ OS="`uname -m`" echo "Building for arch = $OS" if [ $OS = 'arm64' ]; then - OPTIMIZER="ghcr.io/nymlab/optimizer-arm64:0.15.1-clang" + OPTIMIZER="ghcr.io/nymlab/optimizer-arm64:0.17.0-clang" elif [ $OS = 'x86_64' ]; then - OPTIMIZER="ghcr.io/nymlab/rust-optimizer:39077c998b881011f3db2cb5c1dbe9904e6be8f1" + OPTIMIZER="cosmwasm/optimizer:0.17.0" else return 1 fi @@ -18,8 +18,8 @@ docker run --rm -v "$(pwd)":/code \ $OPTIMIZER -for file in ./artifacts/*; do - BASENAME=$(basename "$file") - NEWNAME=$(echo "$BASENAME" | sed 's/-aarch64//') - mv "$file" "./artifacts/$NEWNAME" -done +# for file in ./artifacts/*; do +# BASENAME=$(basename "$file") +# NEWNAME=$(echo "$BASENAME" | sed 's/-aarch64//') +# mv "$file" "./artifacts/$NEWNAME" +# done From 31b3611f1c4e450658c81a2712e47e0e5b535575 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 10:47:42 +0100 Subject: [PATCH 14/16] update optimizer --- scripts/build-optimise.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/build-optimise.sh b/scripts/build-optimise.sh index b509191..e2328c9 100755 --- a/scripts/build-optimise.sh +++ b/scripts/build-optimise.sh @@ -7,7 +7,8 @@ echo "Building for arch = $OS" if [ $OS = 'arm64' ]; then OPTIMIZER="ghcr.io/nymlab/optimizer-arm64:0.17.0-clang" elif [ $OS = 'x86_64' ]; then - OPTIMIZER="cosmwasm/optimizer:0.17.0" + # This will need to be updated + OPTIMIZER="ghcr.io/nymlab/rust-optimizer:39077c998b881011f3db2cb5c1dbe9904e6be8f1" else return 1 fi @@ -16,10 +17,3 @@ docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ $OPTIMIZER - - -# for file in ./artifacts/*; do -# BASENAME=$(basename "$file") -# NEWNAME=$(echo "$BASENAME" | sed 's/-aarch64//') -# mv "$file" "./artifacts/$NEWNAME" -# done From c27c487c991c1afcec8c2ada0ab8a5c2d4eea6b9 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 12:58:19 +0100 Subject: [PATCH 15/16] fix: avoid wrapped err --- contracts/sdjwt-verifier/src/verifier.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/contracts/sdjwt-verifier/src/verifier.rs b/contracts/sdjwt-verifier/src/verifier.rs index 7fed58c..e51ff1f 100644 --- a/contracts/sdjwt-verifier/src/verifier.rs +++ b/contracts/sdjwt-verifier/src/verifier.rs @@ -180,11 +180,10 @@ pub fn _handle_verify( let verify_result = match res { Ok(value) => { - let binary_value = Binary::from(serde_json::to_vec(&value).map_err(|e| { - SdjwtVerifierError::SdjwtVerifierResultError( - SdjwtVerifierResultError::VerifiedClaimsToBinaryError(e.to_string()), - ) - })?); + let binary_value = Binary::from( + serde_json::to_vec(&value) + .map_err(|e| SdjwtVerifierError::VerifyResultError(e.to_string()))?, + ); VerifyResult { success: true, From 67f576cf02929eb5c99b9c553b361a8cd8316521 Mon Sep 17 00:00:00 2001 From: bwty Date: Fri, 26 Sep 2025 14:26:04 +0100 Subject: [PATCH 16/16] fix: redundunt ser --- contracts/avida_example/Cargo.toml | 2 +- contracts/sdjwt-verifier/src/verifier.rs | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/contracts/avida_example/Cargo.toml b/contracts/avida_example/Cargo.toml index bbd93b9..5835d76 100644 --- a/contracts/avida_example/Cargo.toml +++ b/contracts/avida_example/Cargo.toml @@ -34,6 +34,6 @@ serde_json = { workspace = true } josekit = "0.8.6" sd-jwt-rs = "0.7.0" jsonwebtoken = { version="9.3.0", features=["use_pem"]} -avida-test-utils = { path = "../../packages/avida_test_utils/", features = ["sdjwt"]} +avida-tests = { path = "../../packages/avida_tests/", features = ["sdjwt"]} cw-multi-test = {version = "3", features = ["staking", "stargate", "cosmwasm_3_0"]} serde = { workspace = true } diff --git a/contracts/sdjwt-verifier/src/verifier.rs b/contracts/sdjwt-verifier/src/verifier.rs index e51ff1f..c28b26e 100644 --- a/contracts/sdjwt-verifier/src/verifier.rs +++ b/contracts/sdjwt-verifier/src/verifier.rs @@ -179,18 +179,11 @@ pub fn _handle_verify( ); let verify_result = match res { - Ok(value) => { - let binary_value = Binary::from( - serde_json::to_vec(&value) - .map_err(|e| SdjwtVerifierError::VerifyResultError(e.to_string()))?, - ); - - VerifyResult { - success: true, - value: Some(binary_value), - error: None, - } - } + Ok(value) => VerifyResult { + success: true, + value: Some(to_json_binary(&value)?), + error: None, + }, Err(error) => VerifyResult { success: false, value: None,