From 2d8c958e933e1adc02469bb521156ed38a405060 Mon Sep 17 00:00:00 2001 From: Keyne Date: Thu, 21 Sep 2023 14:08:18 +0100 Subject: [PATCH] Add wasm queries for burnt nfts (#657) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description # Reviewers checklist: - [ ] Try to write more meaningful comments with clear actions to be taken. - [ ] Nit-picking should be unblocking. Focus on core issues. # Authors checklist - [x] Provide a concise and meaningful description - [x] Review the code yourself first, before making the PR. - [x] Annotate your PR in places that require explanation. - [x] Think and try to split the PR to smaller PR if it is big. - - - This change is [Reviewable](https://reviewable.io/reviews/CoreumFoundation/coreum/657) --- integration-tests/contracts/modules/nft.go | 9 + .../contracts/modules/nft/Cargo.lock | 357 ++++++++++++------ .../contracts/modules/nft/Cargo.toml | 2 +- .../contracts/modules/nft/src/contract.rs | 46 ++- .../contracts/modules/nft/src/msg.rs | 2 + integration-tests/modules/wasm_test.go | 28 +- x/wasm/handler/query.go | 14 + 7 files changed, 344 insertions(+), 114 deletions(-) diff --git a/integration-tests/contracts/modules/nft.go b/integration-tests/contracts/modules/nft.go index f6f45c107..cc58ecef6 100644 --- a/integration-tests/contracts/modules/nft.go +++ b/integration-tests/contracts/modules/nft.go @@ -35,6 +35,13 @@ type NftIDRequest struct { ID string `json:"id"` } +// BurntNftIDRequest is used to query burnt nfts with nft_id. +// +//nolint:tagliatelle +type BurntNftIDRequest struct { + NftID string `json:"nft_id"` +} + // NftIssuerRequest is used to query NFT with issuer. type NftIssuerRequest struct { Issuer string `json:"issuer"` @@ -77,6 +84,8 @@ const ( NftMethodFrozen NftMethod = "frozen" NftMethodWhitelisted NftMethod = "whitelisted" NftMethodWhitelistedAccountsForNft NftMethod = "whitelisted_accounts_for_nft" + NftMethodBurntNft NftMethod = "burnt_nft" + NftMethodBurntNftInClass NftMethod = "burnt_nfts_in_class" NftMethodBalance NftMethod = "balance" NftMethodOwner NftMethod = "owner" NftMethodSupply NftMethod = "supply" diff --git a/integration-tests/contracts/modules/nft/Cargo.lock b/integration-tests/contracts/modules/nft/Cargo.lock index 8f6b338ef..55dc67ef5 100644 --- a/integration-tests/contracts/modules/nft/Cargo.lock +++ b/integration-tests/contracts/modules/nft/Cargo.lock @@ -13,17 +13,29 @@ dependencies = [ "version_check", ] +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + [[package]] name = "base16ct" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" -version = "0.13.1" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" @@ -49,41 +61,67 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bnum" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" + [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "num-traits", +] + [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "coreum-wasm-sdk" -version = "0.1.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e2dde879a9eb95331315156449a5b9e4e4dee642fe2c357ae3ac0f164b2bc6" +checksum = "be523a53d7cd0efa94c790bcda6f3e960f816c5db9272e008e9b2fa58ee4f9ad" dependencies = [ + "chrono", "cosmwasm-schema", "cosmwasm-std", + "osmosis-std-derive", + "prost 0.11.9", + "prost-types 0.12.1", "schemars", "serde", + "serde-cw-value", ] [[package]] name = "cosmwasm-crypto" -version = "1.2.7" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb64554a91d6a9231127f4355d351130a0b94e663d5d9dc8b3a54ca17d83de49" +checksum = "1ca101fbf2f76723711a30ea3771ef312ec3ec254ad021b237871ed802f9f175" dependencies = [ "digest 0.10.7", "ed25519-zebra", @@ -94,18 +132,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.7" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0fb2ce09f41a3dae1a234d56a9988f9aff4c76441cd50ef1ee9a4f20415b028" +checksum = "c73d2dd292f60e42849d2b07c03d809cf31e128a4299a805abd6d24553bcaaf5" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.2.7" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "230e5d1cefae5331db8934763c81b9c871db6a2cd899056a5694fa71d292c815" +checksum = "6ce34a08020433989af5cc470104f6bd22134320fe0221bd8aeb919fd5ec92d5" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -116,9 +154,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.7" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43dadf7c23406cb28079d69e6cb922c9c29b9157b0fe887e3b79c783b7d4bcb8" +checksum = "96694ec781a7dd6dea1f968a2529ade009c21ad999c88b5f53d6cc495b3b96f7" dependencies = [ "proc-macro2", "quote", @@ -127,11 +165,12 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.2.7" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4337eef8dfaf8572fe6b6b415d6ec25f9308c7bb09f2da63789209fb131363be" +checksum = "2a44d3f9c25b2f864737c6605a98f2e4675d53fd8bbc7cf4d7c02475661a793d" dependencies = [ "base64", + "bnum", "cosmwasm-crypto", "cosmwasm-derive", "derivative", @@ -142,14 +181,13 @@ dependencies = [ "serde-json-wasm", "sha2 0.10.7", "thiserror", - "uint", ] [[package]] name = "cosmwasm-storage" -version = "1.2.7" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8601d284db8776e39fe99b3416516c5636ca73cef14666b7bb9648ca32c4b89" +checksum = "ab544dfcad7c9e971933d522d99ec75cc8ddfa338854bb992b092e11bcd7e818" dependencies = [ "cosmwasm-std", "serde", @@ -157,24 +195,18 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "crypto-bigint" -version = "0.4.9" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array", "rand_core 0.6.4", @@ -282,9 +314,9 @@ dependencies = [ [[package]] name = "der" -version = "0.6.1" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", "zeroize", @@ -317,26 +349,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" [[package]] name = "ecdsa" -version = "0.14.8" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ "der", + "digest 0.10.7", "elliptic-curve", "rfc6979", "signature", + "spki", ] [[package]] @@ -354,15 +389,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + [[package]] name = "elliptic-curve" -version = "0.12.3" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" dependencies = [ "base16ct", "crypto-bigint", - "der", "digest 0.10.7", "ff", "generic-array", @@ -376,9 +416,9 @@ dependencies = [ [[package]] name = "ff" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", "subtle", @@ -398,6 +438,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -413,9 +454,9 @@ dependencies = [ [[package]] name = "group" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core 0.6.4", @@ -446,29 +487,49 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "k256" -version = "0.11.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "once_cell", "sha2 0.10.7", + "signature", ] [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "nft" @@ -484,6 +545,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "num-traits" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.18.0" @@ -496,11 +566,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "osmosis-std-derive" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f47f0b2f22adb341bb59e5a3a1b464dde033181954bd055b9ae86d6511ba465b" +dependencies = [ + "itertools 0.10.5", + "proc-macro2", + "prost-types 0.11.9", + "quote", + "syn 1.0.109", +] + [[package]] name = "pkcs8" -version = "0.9.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ "der", "spki", @@ -508,18 +591,82 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" +dependencies = [ + "bytes", + "prost-derive 0.12.1", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "prost-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" +dependencies = [ + "anyhow", + "itertools 0.11.0", + "proc-macro2", + "quote", + "syn 2.0.37", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost 0.11.9", +] + +[[package]] +name = "prost-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf" +dependencies = [ + "prost 0.12.1", +] + [[package]] name = "quote" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -541,26 +688,25 @@ dependencies = [ [[package]] name = "rfc6979" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "crypto-bigint", "hmac", - "zeroize", + "subtle", ] [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" dependencies = [ "dyn-clone", "schemars_derive", @@ -570,9 +716,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" dependencies = [ "proc-macro2", "quote", @@ -582,9 +728,9 @@ dependencies = [ [[package]] name = "sec1" -version = "0.3.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", "der", @@ -596,19 +742,28 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-cw-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75d32da6b8ed758b7d850b6c3c08f1d7df51a4df3cb201296e63e34a78e99d4" +dependencies = [ + "serde", +] + [[package]] name = "serde-json-wasm" version = "0.5.1" @@ -620,13 +775,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.37", ] [[package]] @@ -642,9 +797,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.99" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -677,9 +832,9 @@ dependencies = [ [[package]] name = "signature" -version = "1.6.4" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.7", "rand_core 0.6.4", @@ -687,20 +842,14 @@ dependencies = [ [[package]] name = "spki" -version = "0.6.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", "der", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "subtle" version = "2.5.0" @@ -720,9 +869,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.22" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -731,47 +880,35 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.37", ] [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "version_check" diff --git a/integration-tests/contracts/modules/nft/Cargo.toml b/integration-tests/contracts/modules/nft/Cargo.toml index 45c72089a..04e980e14 100644 --- a/integration-tests/contracts/modules/nft/Cargo.toml +++ b/integration-tests/contracts/modules/nft/Cargo.toml @@ -33,6 +33,6 @@ cosmwasm-storage = "1.2.5" cw-storage-plus = "1.0.1" cw2 = "1.0.1" thiserror = { version = "1.0.40" } -coreum-wasm-sdk = "0.1.3" +coreum-wasm-sdk = "0.2.0" cosmwasm-schema = "1.2.6" cw-ownable = "0.5.1" diff --git a/integration-tests/contracts/modules/nft/src/contract.rs b/integration-tests/contracts/modules/nft/src/contract.rs index 49a0e04d7..d3ca7ec5e 100644 --- a/integration-tests/contracts/modules/nft/src/contract.rs +++ b/integration-tests/contracts/modules/nft/src/contract.rs @@ -1,6 +1,6 @@ use coreum_wasm_sdk::assetnft::{ - self, ClassResponse, ClassesResponse, FrozenResponse, ParamsResponse, - WhitelistedAccountsForNFTResponse, WhitelistedResponse, + self, BurntNFTResponse, BurntNFTsInClassResponse, ClassResponse, ClassesResponse, + FrozenResponse, ParamsResponse, WhitelistedAccountsForNFTResponse, WhitelistedResponse, }; use coreum_wasm_sdk::core::{CoreumMsg, CoreumQueries, CoreumResult}; use coreum_wasm_sdk::nft; @@ -241,6 +241,8 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult to_binary(&query_nfts(deps, owner)?), QueryMsg::ClassNft {} => to_binary(&query_nft_class(deps)?), QueryMsg::ClassesNft {} => to_binary(&query_nft_classes(deps)?), + QueryMsg::BurntNft { nft_id } => to_binary(&query_burnt_nft(deps, nft_id)?), + QueryMsg::BurntNftsInClass {} => to_binary(&query_burnt_nfts_in_class(deps)?), } } @@ -351,6 +353,46 @@ fn query_whitelisted_accounts_for_nft( Ok(res) } +fn query_burnt_nft(deps: Deps, nft_id: String) -> StdResult { + let class_id = CLASS_ID.load(deps.storage)?; + let request: QueryRequest = + CoreumQueries::AssetNFT(assetnft::Query::BurntNFT { class_id, nft_id }).into(); + let res = deps.querier.query(&request)?; + Ok(res) +} + +fn query_burnt_nfts_in_class(deps: Deps) -> StdResult { + let class_id = CLASS_ID.load(deps.storage)?; + let mut pagination = None; + let mut nft_ids = vec![]; + let mut res: BurntNFTsInClassResponse; + loop { + let request = CoreumQueries::AssetNFT(assetnft::Query::BurntNFTsInClass { + pagination, + class_id: class_id.clone(), + }) + .into(); + res = deps.querier.query(&request)?; + nft_ids.append(&mut res.nft_ids); + if res.pagination.next_key.is_none() { + break; + } else { + pagination = Some(PageRequest { + key: res.pagination.next_key, + offset: None, + limit: None, + count_total: None, + reverse: None, + }) + } + } + let res = BurntNFTsInClassResponse { + pagination: res.pagination, + nft_ids, + }; + Ok(res) +} + // ********** NFT ********** fn query_balance(deps: Deps, owner: String) -> StdResult { diff --git a/integration-tests/contracts/modules/nft/src/msg.rs b/integration-tests/contracts/modules/nft/src/msg.rs index 91e5f5241..5d1f4cb47 100644 --- a/integration-tests/contracts/modules/nft/src/msg.rs +++ b/integration-tests/contracts/modules/nft/src/msg.rs @@ -59,4 +59,6 @@ pub enum QueryMsg { Nfts { owner: Option }, // we use Nfts not NFTs since NFTs is decoded as n_f_ts ClassNft {}, // we use ClassNft instead of Class because there is already a Class query being used ClassesNft {}, // we use ClassesNft instead of Class because there is already a Classes query being used + BurntNft { nft_id: String }, + BurntNftsInClass {}, } diff --git a/integration-tests/modules/wasm_test.go b/integration-tests/modules/wasm_test.go index 535ddb994..1841ba995 100644 --- a/integration-tests/modules/wasm_test.go +++ b/integration-tests/modules/wasm_test.go @@ -1368,7 +1368,6 @@ func TestWASMNonFungibleTokenInContract(t *testing.T) { requireT.NoError(json.Unmarshal(queryOut, &classQueryRes)) requireT.Equal( moduleswasm.AssetnftClass{ - // TODO Artem: compare it with Class[0]. ID: expectedClass.Id, Issuer: expectedClass.Issuer, Name: expectedClass.Name, @@ -1473,6 +1472,33 @@ func TestWASMNonFungibleTokenInContract(t *testing.T) { requireT.NoError(json.Unmarshal(queryOut, &whitelistedAccountsForNFTQueryRes)) requireT.Equal(whitelistedAccountsForNFTQueryRes.Accounts[0], recipient.String()) + // ********** BurntNFT ********** + + burntNFTPayload, err := json.Marshal(map[moduleswasm.NftMethod]moduleswasm.BurntNftIDRequest{ + moduleswasm.NftMethodBurntNft: { + NftID: "id-1", + }, + }) + requireT.NoError(err) + queryOut, err = chain.Wasm.QueryWASMContract(ctx, contractAddr, burntNFTPayload) + requireT.NoError(err) + var burntNFTQueryRes assetnfttypes.QueryBurntNFTResponse + requireT.NoError(json.Unmarshal(queryOut, &burntNFTQueryRes)) + requireT.Equal(burntNFTQueryRes.Burnt, true) + + // ********** BurntNFTsInClass ********** + + burntNFTsInClassPayload, err := json.Marshal(map[moduleswasm.NftMethod]struct{}{ + moduleswasm.NftMethodBurntNftInClass: {}, + }) + + requireT.NoError(err) + queryOut, err = chain.Wasm.QueryWASMContract(ctx, contractAddr, burntNFTsInClassPayload) + requireT.NoError(err) + var burntNFTsInClassQueryRes assetnfttypes.QueryBurntNFTsInClassResponse + requireT.NoError(json.Unmarshal(queryOut, &burntNFTsInClassQueryRes)) + requireT.Equal(burntNFTsInClassQueryRes.NftIds, []string{"id-1"}) + // ********** Balance ********** balancePayload, err := json.Marshal(map[moduleswasm.NftMethod]moduleswasm.NftOwnerRequest{ diff --git a/x/wasm/handler/query.go b/x/wasm/handler/query.go index e71766bc5..cdf4804d9 100644 --- a/x/wasm/handler/query.go +++ b/x/wasm/handler/query.go @@ -75,6 +75,8 @@ type assetNFTQuery struct { Frozen *assetnfttypes.QueryFrozenRequest `json:"Frozen"` Whitelisted *assetnfttypes.QueryWhitelistedRequest `json:"Whitelisted"` WhitelistedAccountsforNFT *assetnfttypes.QueryWhitelistedAccountsForNFTRequest `json:"WhitelistedAccountsforNft"` + BurntNFT *assetnfttypes.QueryBurntNFTRequest `json:"BurntNft"` + BurntNFTsInClass *assetnfttypes.QueryBurntNFTsInClassRequest `json:"BurntNftsInClass"` } // nft is the nft with string data. @@ -328,6 +330,18 @@ func processAssetNFTQuery(ctx sdk.Context, assetNFTQuery *assetNFTQuery, assetNF }) } + if assetNFTQuery.BurntNFT != nil { + return executeQuery(ctx, assetNFTQuery.BurntNFT, func(ctx context.Context, req *assetnfttypes.QueryBurntNFTRequest) (*assetnfttypes.QueryBurntNFTResponse, error) { + return assetNFTQueryServer.BurntNFT(ctx, req) + }) + } + + if assetNFTQuery.BurntNFTsInClass != nil { + return executeQuery(ctx, assetNFTQuery.BurntNFTsInClass, func(ctx context.Context, req *assetnfttypes.QueryBurntNFTsInClassRequest) (*assetnfttypes.QueryBurntNFTsInClassResponse, error) { + return assetNFTQueryServer.BurntNFTsInClass(ctx, req) + }) + } + return nil, nil }