diff --git a/Cargo.lock b/Cargo.lock index a6d809b6fc..a163c6ce9a 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 = "Inflector" @@ -14,11 +14,11 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli 0.29.0", + "gimli 0.28.1", ] [[package]] @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" @@ -122,9 +122,18 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" + +[[package]] +name = "arbitrary" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] [[package]] name = "ark-bls12-381" @@ -150,7 +159,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -168,7 +177,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -247,6 +256,45 @@ dependencies = [ "rayon", ] +[[package]] +name = "askama" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28" +dependencies = [ + "askama_derive", + "askama_escape", +] + +[[package]] +name = "askama_derive" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83" +dependencies = [ + "askama_parser", + "mime", + "mime_guess", + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "askama_escape" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" + +[[package]] +name = "askama_parser" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0" +dependencies = [ + "nom", +] + [[package]] name = "assert_cmd" version = "2.0.14" @@ -270,9 +318,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -475,18 +523,19 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.7" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", + "clap_derive", ] [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -494,6 +543,18 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "clap_lex" version = "0.7.1" @@ -522,6 +583,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -615,7 +688,8 @@ version = "2.2.0-rc.1" dependencies = [ "anyhow", "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "semver", "serde", "serde_json", @@ -645,6 +719,7 @@ dependencies = [ "cosmwasm-derive", "cosmwasm-schema", "crc32fast", + "cw-schema", "derive_more", "hex", "hex-literal", @@ -652,7 +727,7 @@ dependencies = [ "proptest", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "serde_json", @@ -684,7 +759,7 @@ dependencies = [ "leb128", "rand", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -741,7 +816,7 @@ dependencies = [ "clap", "criterion-plot", "is-terminal", - "itertools", + "itertools 0.10.5", "num-traits", "once_cell", "oorandom", @@ -762,7 +837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -854,6 +929,58 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "insta", + "pretty_assertions", + "schemars 1.0.0-alpha.11", + "serde", + "serde_json", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-codegen" +version = "2.2.0-rc.1" +dependencies = [ + "anyhow", + "arbitrary", + "askama", + "clap", + "cosmwasm-schema", + "cw-schema", + "derive_arbitrary", + "either", + "frunk", + "frunk_core", + "heck", + "insta", + "log", + "mimalloc", + "rand", + "serde", + "serde_json", + "simple_logger", + "tempfile", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -874,6 +1001,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -932,6 +1060,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "derive_more" version = "1.0.0-beta.6" @@ -969,6 +1108,12 @@ dependencies = [ "thousands", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "difflib" version = "0.4.0" @@ -1064,9 +1209,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -1086,6 +1231,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "english-numbers" version = "0.3.3" @@ -1157,9 +1308,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "ff" @@ -1192,6 +1343,62 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "frunk" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874b6a17738fc273ec753618bac60ddaeac48cb1d7684c3e7bd472e57a28b817" +dependencies = [ + "frunk_core", + "frunk_derives", + "frunk_proc_macros", + "serde", +] + +[[package]] +name = "frunk_core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3529a07095650187788833d585c219761114005d5976185760cf794d265b6a5c" +dependencies = [ + "serde", +] + +[[package]] +name = "frunk_derives" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e99b8b3c28ae0e84b604c75f721c21dc77afb3706076af5e8216d15fd1deaae3" +dependencies = [ + "frunk_proc_macro_helpers", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "frunk_proc_macro_helpers" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05a956ef36c377977e512e227dcad20f68c2786ac7a54dacece3746046fea5ce" +dependencies = [ + "frunk_core", + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "frunk_proc_macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e86c2c9183662713fea27ea527aad20fb15fee635a71081ff91bf93df4dc51" +dependencies = [ + "frunk_core", + "frunk_proc_macro_helpers", + "quote", + "syn 2.0.77", +] + [[package]] name = "funty" version = "2.0.0" @@ -1235,9 +1442,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "glob" @@ -1254,7 +1461,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "indenter", - "schemars", + "schemars 0.8.21", ] [[package]] @@ -1366,14 +1573,27 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "insta" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6593a41c7a73841868772495db7dc1e8ecab43bb5c0b6da2059246c4b506ab60" +dependencies = [ + "console", + "lazy_static", + "linked-hash-map", + "serde", + "similar", +] + [[package]] name = "is-terminal" version = "0.4.12" @@ -1385,6 +1605,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -1400,6 +1626,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1450,9 +1685,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libm" @@ -1460,6 +1695,22 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libmimalloc-sys" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1478,9 +1729,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "mach2" @@ -1524,6 +1775,37 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mimalloc" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" +dependencies = [ + "libmimalloc-sys", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.3" @@ -1545,6 +1827,16 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -1586,11 +1878,20 @@ dependencies = [ "libm", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "object" -version = "0.36.0" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -1607,6 +1908,15 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1724,6 +2034,16 @@ dependencies = [ "termtree", ] +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "primeorder" version = "0.13.6" @@ -1898,6 +2218,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "regex" version = "1.10.5" @@ -2033,9 +2373,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.5.0", "errno", @@ -2072,7 +2412,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece152f3fb753f79c12387ad9f380b19acd4157e0fe9f000ae549007952d8421" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.11", "serde", "serde_json", ] @@ -2089,6 +2442,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3de97d3948e50ab84556c216fe814bde7c988d8ba29910482ff3414801a9c8cc" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -2128,9 +2493,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -2157,9 +2522,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -2179,15 +2544,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -2241,6 +2630,30 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "similar" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" + +[[package]] +name = "simple_logger" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c5dfa5e08767553704aa0ffd9d9794d527103c736aba9854773851fd7497eb" +dependencies = [ + "colored", + "log", + "time", + "windows-sys 0.48.0", +] + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -2267,9 +2680,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ "strum_macros", ] @@ -2293,6 +2706,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -2329,14 +2752,15 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2379,7 +2803,9 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -2470,6 +2896,15 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -2763,7 +3198,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] @@ -3014,6 +3449,12 @@ version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "927da81e25be1e1a2901d59b81b37dd2efd1fc9c9345a55007f09bf5a2d3ee03" +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "zerocopy" version = "0.7.34" diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index dea8631582..eca2b40a74 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -267,7 +267,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", ] @@ -382,7 +382,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -407,11 +408,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -435,7 +437,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -558,6 +560,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -578,6 +604,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -920,6 +947,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -953,14 +986,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -970,6 +1020,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1131,6 +1190,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1309,6 +1377,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1426,7 +1514,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1443,6 +1544,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1482,9 +1595,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1511,9 +1624,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1533,15 +1646,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1579,6 +1716,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1597,6 +1740,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.26.2" @@ -1625,6 +1774,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1969,7 +2128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/burner/schema/cw_schema/burner.json b/contracts/burner/schema/cw_schema/burner.json new file mode 100644 index 0000000000..9908bd3d69 --- /dev/null +++ b/contracts/burner/schema/cw_schema/burner.json @@ -0,0 +1,51 @@ +{ + "contract_name": "burner", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "description": "A placeholder where we don't take any input", + "type": "struct", + "properties": {} + } + ] + }, + "execute": null, + "query": null, + "migrate": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "MigrateMsg", + "type": "struct", + "properties": { + "delete": { + "description": "Optional amount of items to delete in this call.\nIf it is not provided, nothing will be deleted.\nYou can delete further items in a subsequent execute call.", + "value": 1 + }, + "payout": { + "description": "The address we send all remaining balance to", + "value": 0 + } + } + } + ] + }, + "sudo": null, + "responses": null +} diff --git a/contracts/burner/schema/cw_schema/raw/instantiate.json b/contracts/burner/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..3b9e7c218b --- /dev/null +++ b/contracts/burner/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,12 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "description": "A placeholder where we don't take any input", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/burner/schema/cw_schema/raw/migrate.json b/contracts/burner/schema/cw_schema/raw/migrate.json new file mode 100644 index 0000000000..279c708469 --- /dev/null +++ b/contracts/burner/schema/cw_schema/raw/migrate.json @@ -0,0 +1,30 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "MigrateMsg", + "type": "struct", + "properties": { + "delete": { + "description": "Optional amount of items to delete in this call.\nIf it is not provided, nothing will be deleted.\nYou can delete further items in a subsequent execute call.", + "value": 1 + }, + "payout": { + "description": "The address we send all remaining balance to", + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 64c00bba2c..5739f04856 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -377,7 +377,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -402,11 +403,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -430,7 +432,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -538,7 +540,7 @@ dependencies = [ "hex-literal", "p256", "rlp", - "schemars", + "schemars 0.8.21", "serde", "sha2", "sha3", @@ -571,6 +573,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -591,6 +617,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -935,6 +962,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -974,14 +1007,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -991,6 +1041,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1161,6 +1220,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1349,6 +1417,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1482,7 +1570,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1499,6 +1600,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1539,9 +1652,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1568,9 +1681,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1590,15 +1703,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1646,6 +1783,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1674,6 +1817,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.26.2" @@ -1702,6 +1851,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -2046,7 +2205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/crypto-verify/schema/cw_schema/crypto-verify.json b/contracts/crypto-verify/schema/cw_schema/crypto-verify.json new file mode 100644 index 0000000000..5600c53df6 --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/crypto-verify.json @@ -0,0 +1,468 @@ +{ + "contract_name": "crypto-verify", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "type": "struct", + "properties": {} + } + ] + }, + "execute": null, + "query": { + "type": "v1", + "root": 5, + "definitions": [ + { + "name": "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": "String", + "type": "string" + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "list_verification_schemes": { + "description": "Returns a list of supported verification schemes.\nNo pagination - this is a short list.", + "type": "named", + "properties": {} + }, + "verify_bls12_pairing_equality_g1": { + "description": "BLS12-381 pairing equality verification (where the key is an element of G1)", + "type": "named", + "properties": { + "dst": { + "description": "The `dst` component used to hash the message to the curve", + "value": 0 + }, + "msg": { + "description": "The message that should be verified", + "value": 0 + }, + "pubkey": { + "description": "The public key point in its compressed format (element of G1)", + "value": 0 + }, + "signature": { + "description": "The signature point in its compressed format (element of G2)", + "value": 0 + } + } + }, + "verify_bls12_pairing_equality_g2": { + "description": "BLS12-381 pairing equality verification (where the key is an element of G2)", + "type": "named", + "properties": { + "dst": { + "description": "The `dst` component used to hash the message to the curve", + "value": 0 + }, + "msg": { + "description": "The message that should be verified", + "value": 0 + }, + "pubkey": { + "description": "The public key point in its compressed format (element of G2)", + "value": 0 + }, + "signature": { + "description": "The signature point in its compressed format (element of G1)", + "value": 0 + } + } + }, + "verify_cosmos_signature": { + "description": "Cosmos format (secp256k1 verification scheme).", + "type": "named", + "properties": { + "message": { + "description": "Message to verify.", + "value": 0 + }, + "public_key": { + "description": "Serialized compressed (33 bytes) or uncompressed (65 bytes) public key.", + "value": 0 + }, + "signature": { + "description": "Serialized signature. Cosmos format (64 bytes).", + "value": 0 + } + } + }, + "verify_ethereum_text": { + "description": "Ethereum text verification (compatible to the eth_sign RPC/web3 endpoint).\nThis cannot be used to verify transaction.\n\nSee https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#sign", + "type": "named", + "properties": { + "message": { + "description": "Message to verify. This will be wrapped in the standard container\n`\"\\x19Ethereum Signed Message:\\n\" + len(message) + message` before verification.", + "value": 1 + }, + "signature": { + "description": "Serialized signature. Fixed length format (64 bytes `r` and `s` plus the one byte `v`).", + "value": 0 + }, + "signer_address": { + "description": "Signer address.\nThis is matched case insensitive, so you can provide check-summed and non-check-summed addresses. Checksums are not validated.", + "value": 1 + } + } + }, + "verify_ethereum_transaction": { + "type": "named", + "properties": { + "chain_id": { + "value": 2 + }, + "data": { + "value": 0 + }, + "from": { + "description": "Ethereum address in hex format (42 characters, starting with 0x)", + "value": 1 + }, + "gas_limit": { + "value": 3 + }, + "gas_price": { + "value": 3 + }, + "nonce": { + "value": 2 + }, + "r": { + "value": 0 + }, + "s": { + "value": 0 + }, + "to": { + "description": "Ethereum address in hex format (42 characters, starting with 0x)", + "value": 1 + }, + "v": { + "value": 2 + }, + "value": { + "value": 3 + } + } + }, + "verify_secp256_r1_signature": { + "description": "Cosmos format (secp256r1 verification scheme).", + "type": "named", + "properties": { + "message": { + "description": "Message to verify.", + "value": 0 + }, + "public_key": { + "description": "Serialized compressed (33 bytes) or uncompressed (65 bytes) public key.", + "value": 0 + }, + "signature": { + "description": "Serialized signature. Cosmos format (64 bytes).", + "value": 0 + } + } + }, + "verify_tendermint_batch": { + "description": "Tendermint format (batch ed25519 verification scheme).", + "type": "named", + "properties": { + "messages": { + "description": "Messages to verify.", + "value": 4 + }, + "public_keys": { + "description": "Serialized public keys. Tendermint format (32 bytes).", + "value": 4 + }, + "signatures": { + "description": "Serialized signatures. Tendermint format (64 bytes).", + "value": 4 + } + } + }, + "verify_tendermint_signature": { + "description": "Tendermint format (ed25519 verification scheme).", + "type": "named", + "properties": { + "message": { + "description": "Message to verify.", + "value": 0 + }, + "public_key": { + "description": "Serialized public key. Tendermint format (32 bytes).", + "value": 0 + }, + "signature": { + "description": "Serialized signature. Tendermint format (64 bytes).", + "value": 0 + } + } + }, + "verify_webauthn": { + "description": "Webauthn component verification", + "type": "named", + "properties": { + "authenticator_data": { + "description": "Authenticator data", + "value": 0 + }, + "challenge": { + "description": "Challenge value", + "value": 0 + }, + "client_data_json": { + "description": "Client data (JSON encoded)", + "value": 1 + }, + "r": { + "description": "r component of signature\n\nThe representation of this component is a big-endian encoded 256bit integer", + "value": 0 + }, + "s": { + "description": "s component of signature\n\nThe representation of this component is a big-endian encoded 256bit integer", + "value": 0 + }, + "x": { + "description": "X coordinate of public key point\n\nUntagged big-endian serialized byte sequence representing the X coordinate on the secp256r1 elliptic curve", + "value": 0 + }, + "y": { + "description": "Y coordinate of public key point\n\nUntagged big-endian serialized byte sequence representing the Y coordinate on the secp256r1 elliptic curve", + "value": 0 + } + } + } + } + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "list_verification_schemes": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "ListVerificationsResponse", + "type": "struct", + "properties": { + "verification_schemes": { + "value": 1 + } + } + } + ] + }, + "verify_bls12_pairing_equality_g1": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + }, + "verify_bls12_pairing_equality_g2": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + }, + "verify_cosmos_signature": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + }, + "verify_ethereum_text": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + }, + "verify_ethereum_transaction": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + }, + "verify_secp256_r1_signature": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + }, + "verify_tendermint_batch": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + }, + "verify_tendermint_signature": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + }, + "verify_webauthn": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] + } + } +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/instantiate.json b/contracts/crypto-verify/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..9fc37502e9 --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,11 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/query.json b/contracts/crypto-verify/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..4d73d46c37 --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/query.json @@ -0,0 +1,252 @@ +{ + "type": "v1", + "root": 5, + "definitions": [ + { + "name": "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": "String", + "type": "string" + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "list_verification_schemes": { + "description": "Returns a list of supported verification schemes.\nNo pagination - this is a short list.", + "type": "named", + "properties": {} + }, + "verify_bls12_pairing_equality_g1": { + "description": "BLS12-381 pairing equality verification (where the key is an element of G1)", + "type": "named", + "properties": { + "dst": { + "description": "The `dst` component used to hash the message to the curve", + "value": 0 + }, + "msg": { + "description": "The message that should be verified", + "value": 0 + }, + "pubkey": { + "description": "The public key point in its compressed format (element of G1)", + "value": 0 + }, + "signature": { + "description": "The signature point in its compressed format (element of G2)", + "value": 0 + } + } + }, + "verify_bls12_pairing_equality_g2": { + "description": "BLS12-381 pairing equality verification (where the key is an element of G2)", + "type": "named", + "properties": { + "dst": { + "description": "The `dst` component used to hash the message to the curve", + "value": 0 + }, + "msg": { + "description": "The message that should be verified", + "value": 0 + }, + "pubkey": { + "description": "The public key point in its compressed format (element of G2)", + "value": 0 + }, + "signature": { + "description": "The signature point in its compressed format (element of G1)", + "value": 0 + } + } + }, + "verify_cosmos_signature": { + "description": "Cosmos format (secp256k1 verification scheme).", + "type": "named", + "properties": { + "message": { + "description": "Message to verify.", + "value": 0 + }, + "public_key": { + "description": "Serialized compressed (33 bytes) or uncompressed (65 bytes) public key.", + "value": 0 + }, + "signature": { + "description": "Serialized signature. Cosmos format (64 bytes).", + "value": 0 + } + } + }, + "verify_ethereum_text": { + "description": "Ethereum text verification (compatible to the eth_sign RPC/web3 endpoint).\nThis cannot be used to verify transaction.\n\nSee https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#sign", + "type": "named", + "properties": { + "message": { + "description": "Message to verify. This will be wrapped in the standard container\n`\"\\x19Ethereum Signed Message:\\n\" + len(message) + message` before verification.", + "value": 1 + }, + "signature": { + "description": "Serialized signature. Fixed length format (64 bytes `r` and `s` plus the one byte `v`).", + "value": 0 + }, + "signer_address": { + "description": "Signer address.\nThis is matched case insensitive, so you can provide check-summed and non-check-summed addresses. Checksums are not validated.", + "value": 1 + } + } + }, + "verify_ethereum_transaction": { + "type": "named", + "properties": { + "chain_id": { + "value": 2 + }, + "data": { + "value": 0 + }, + "from": { + "description": "Ethereum address in hex format (42 characters, starting with 0x)", + "value": 1 + }, + "gas_limit": { + "value": 3 + }, + "gas_price": { + "value": 3 + }, + "nonce": { + "value": 2 + }, + "r": { + "value": 0 + }, + "s": { + "value": 0 + }, + "to": { + "description": "Ethereum address in hex format (42 characters, starting with 0x)", + "value": 1 + }, + "v": { + "value": 2 + }, + "value": { + "value": 3 + } + } + }, + "verify_secp256_r1_signature": { + "description": "Cosmos format (secp256r1 verification scheme).", + "type": "named", + "properties": { + "message": { + "description": "Message to verify.", + "value": 0 + }, + "public_key": { + "description": "Serialized compressed (33 bytes) or uncompressed (65 bytes) public key.", + "value": 0 + }, + "signature": { + "description": "Serialized signature. Cosmos format (64 bytes).", + "value": 0 + } + } + }, + "verify_tendermint_batch": { + "description": "Tendermint format (batch ed25519 verification scheme).", + "type": "named", + "properties": { + "messages": { + "description": "Messages to verify.", + "value": 4 + }, + "public_keys": { + "description": "Serialized public keys. Tendermint format (32 bytes).", + "value": 4 + }, + "signatures": { + "description": "Serialized signatures. Tendermint format (64 bytes).", + "value": 4 + } + } + }, + "verify_tendermint_signature": { + "description": "Tendermint format (ed25519 verification scheme).", + "type": "named", + "properties": { + "message": { + "description": "Message to verify.", + "value": 0 + }, + "public_key": { + "description": "Serialized public key. Tendermint format (32 bytes).", + "value": 0 + }, + "signature": { + "description": "Serialized signature. Tendermint format (64 bytes).", + "value": 0 + } + } + }, + "verify_webauthn": { + "description": "Webauthn component verification", + "type": "named", + "properties": { + "authenticator_data": { + "description": "Authenticator data", + "value": 0 + }, + "challenge": { + "description": "Challenge value", + "value": 0 + }, + "client_data_json": { + "description": "Client data (JSON encoded)", + "value": 1 + }, + "r": { + "description": "r component of signature\n\nThe representation of this component is a big-endian encoded 256bit integer", + "value": 0 + }, + "s": { + "description": "s component of signature\n\nThe representation of this component is a big-endian encoded 256bit integer", + "value": 0 + }, + "x": { + "description": "X coordinate of public key point\n\nUntagged big-endian serialized byte sequence representing the X coordinate on the secp256r1 elliptic curve", + "value": 0 + }, + "y": { + "description": "Y coordinate of public key point\n\nUntagged big-endian serialized byte sequence representing the Y coordinate on the secp256r1 elliptic curve", + "value": 0 + } + } + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_list_verification_schemes.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_list_verification_schemes.json new file mode 100644 index 0000000000..c9258f8afa --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_list_verification_schemes.json @@ -0,0 +1,24 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "ListVerificationsResponse", + "type": "struct", + "properties": { + "verification_schemes": { + "value": 1 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_bls12_pairing_equality_g1.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_bls12_pairing_equality_g1.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_bls12_pairing_equality_g1.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_bls12_pairing_equality_g2.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_bls12_pairing_equality_g2.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_bls12_pairing_equality_g2.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_cosmos_signature.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_cosmos_signature.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_cosmos_signature.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_ethereum_text.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_ethereum_text.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_ethereum_text.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_ethereum_transaction.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_ethereum_transaction.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_ethereum_transaction.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_secp256_r1_signature.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_secp256_r1_signature.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_secp256_r1_signature.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_tendermint_batch.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_tendermint_batch.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_tendermint_batch.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_tendermint_signature.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_tendermint_signature.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_tendermint_signature.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_webauthn.json b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_webauthn.json new file mode 100644 index 0000000000..fe49acd15c --- /dev/null +++ b/contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_webauthn.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "bool", + "type": "boolean" + }, + { + "name": "VerifyResponse", + "type": "struct", + "properties": { + "verifies": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 9e4f309318..a921a6c037 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -406,7 +406,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -431,11 +432,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -459,7 +461,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -582,6 +584,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "cyberpunk" version = "0.0.0" @@ -614,6 +640,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -972,6 +999,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -1005,14 +1038,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -1022,6 +1072,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1189,6 +1248,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1367,6 +1435,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1508,7 +1596,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1525,6 +1626,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1564,9 +1677,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1593,9 +1706,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1615,15 +1728,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1661,6 +1798,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1679,6 +1822,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.26.2" @@ -1707,6 +1856,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -2063,7 +2222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/cyberpunk/schema/cw_schema/cyberpunk.json b/contracts/cyberpunk/schema/cw_schema/cyberpunk.json new file mode 100644 index 0000000000..2922a43fb6 --- /dev/null +++ b/contracts/cyberpunk/schema/cw_schema/cyberpunk.json @@ -0,0 +1,382 @@ +{ + "contract_name": "cyberpunk", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] + }, + "execute": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "allocate_large_memory": { + "description": "Allocate large amounts of memory without consuming much gas", + "type": "named", + "properties": { + "pages": { + "value": 0 + } + } + }, + "argon2": { + "description": "Hashes some data. Uses CPU and memory, but no external calls.", + "type": "named", + "properties": { + "mem_cost": { + "description": "The amount of memory requested (KB).", + "value": 0 + }, + "time_cost": { + "description": "The number of passes.", + "value": 0 + } + } + }, + "cpu_loop": { + "description": "Infinite loop to burn cpu cycles (only run when metering is enabled)", + "type": "named", + "properties": {} + }, + "debug": { + "description": "Does a bit of work and calls debug", + "type": "named", + "properties": {} + }, + "memory_loop": { + "description": "Infinite loop reading and writing memory", + "type": "named", + "properties": {} + }, + "message_loop": { + "description": "Infinite loop sending message to itself", + "type": "named", + "properties": {} + }, + "mirror_env": { + "description": "Returns the env for testing", + "type": "named", + "properties": {} + }, + "noop": { + "description": "Does nothing. This can be used for baseline contract execution performance measurements.", + "type": "named", + "properties": {} + }, + "panic": { + "description": "Trigger a panic to ensure framework handles gracefully", + "type": "named", + "properties": {} + }, + "storage_loop": { + "description": "Infinite loop making storage calls (to test when their limit hits)", + "type": "named", + "properties": {} + }, + "unreachable": { + "description": "In contrast to Panic, this does not use the panic handler.\n\nFrom :\n\"Generates the unreachable instruction, which causes an unconditional trap.\"", + "type": "named", + "properties": {} + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "denom": { + "description": "Queries `DenomMetadata` from the bank module and returns the result", + "type": "named", + "properties": { + "denom": { + "value": 0 + } + } + }, + "denoms": { + "description": "Queries `AllDenomMetadata` from the bank module repeatedly and returns all entries", + "type": "named", + "properties": {} + }, + "mirror_env": { + "description": "Returns the env for testing", + "type": "named", + "properties": {} + } + } + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "denom": { + "type": "v1", + "root": 5, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "DenomUnit", + "description": "Replicates the cosmos-sdk bank module DenomUnit type", + "type": "struct", + "properties": { + "aliases": { + "value": 2 + }, + "denom": { + "value": 0 + }, + "exponent": { + "value": 1 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "DenomMetadata", + "description": "Replicates the cosmos-sdk bank module Metadata type", + "type": "struct", + "properties": { + "base": { + "value": 0 + }, + "denom_units": { + "value": 4 + }, + "description": { + "value": 0 + }, + "display": { + "value": 0 + }, + "name": { + "value": 0 + }, + "symbol": { + "value": 0 + }, + "uri": { + "value": 0 + }, + "uri_hash": { + "value": 0 + } + } + } + ] + }, + "denoms": { + "type": "v1", + "root": 6, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "DenomUnit", + "description": "Replicates the cosmos-sdk bank module DenomUnit type", + "type": "struct", + "properties": { + "aliases": { + "value": 2 + }, + "denom": { + "value": 0 + }, + "exponent": { + "value": 1 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "DenomMetadata", + "description": "Replicates the cosmos-sdk bank module Metadata type", + "type": "struct", + "properties": { + "base": { + "value": 0 + }, + "denom_units": { + "value": 4 + }, + "description": { + "value": 0 + }, + "display": { + "value": 0 + }, + "name": { + "value": 0 + }, + "symbol": { + "value": 0 + }, + "uri": { + "value": 0 + }, + "uri_hash": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 5 + } + ] + }, + "mirror_env": { + "type": "v1", + "root": 9, + "definitions": [ + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "String", + "type": "string" + }, + { + "name": "BlockInfo", + "type": "struct", + "properties": { + "chain_id": { + "value": 2 + }, + "height": { + "description": "The height of a block is the number of blocks preceding it in the blockchain.", + "value": 0 + }, + "time": { + "description": "Absolute time of the block creation in seconds since the UNIX epoch (00:00:00 on 1970-01-01 UTC).\n\nThe source of this is the [BFT Time in Tendermint](https://github.com/tendermint/tendermint/blob/58dc1726/spec/consensus/bft-time.md),\nwhich has the same nanosecond precision as the `Timestamp` type.\n\n# Examples\n\nUsing chrono:\n\n```\n# use cosmwasm_std::{Addr, BlockInfo, ContractInfo, Env, MessageInfo, Timestamp, TransactionInfo};\n# let env = Env {\n# block: BlockInfo {\n# height: 12_345,\n# time: Timestamp::from_nanos(1_571_797_419_879_305_533),\n# chain_id: \"cosmos-testnet-14002\".to_string(),\n# },\n# transaction: Some(TransactionInfo { index: 3 }),\n# contract: ContractInfo {\n# address: Addr::unchecked(\"contract\"),\n# },\n# };\n# extern crate chrono;\nuse chrono::NaiveDateTime;\nlet seconds = env.block.time.seconds();\nlet nsecs = env.block.time.subsec_nanos();\nlet dt = NaiveDateTime::from_timestamp(seconds as i64, nsecs as u32);\n```\n\nCreating a simple millisecond-precision timestamp (as used in JavaScript):\n\n```\n# use cosmwasm_std::{Addr, BlockInfo, ContractInfo, Env, MessageInfo, Timestamp, TransactionInfo};\n# let env = Env {\n# block: BlockInfo {\n# height: 12_345,\n# time: Timestamp::from_nanos(1_571_797_419_879_305_533),\n# chain_id: \"cosmos-testnet-14002\".to_string(),\n# },\n# transaction: Some(TransactionInfo { index: 3 }),\n# contract: ContractInfo {\n# address: Addr::unchecked(\"contract\"),\n# },\n# };\nlet millis = env.block.time.nanos() / 1_000_000;\n```", + "value": 1 + } + } + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "TransactionInfo", + "type": "struct", + "properties": { + "index": { + "description": "The position of this transaction in the block. The first\ntransaction has index 0.\n\nThis allows you to get a unique transaction identifier in this chain\nusing the pair (`env.block.height`, `env.transaction.index`).\n", + "value": 4 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 5 + }, + { + "name": "Addr", + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no\nassumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways\n1. Use `Addr::unchecked(input)`\n2. Use `let checked: Addr = deps.api.addr_validate(input)?`\n3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?`\n4. Deserialize from JSON. This must only be done from JSON that was validated before\nsuch as a contract's state. `Addr` must not be used in messages sent by the user\nbecause this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create\na mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String`\ninstance.", + "type": "address" + }, + { + "name": "ContractInfo", + "type": "struct", + "properties": { + "address": { + "value": 7 + } + } + }, + { + "name": "Env", + "type": "struct", + "properties": { + "block": { + "value": 3 + }, + "contract": { + "value": 8 + }, + "transaction": { + "description": "Information on the transaction this message was executed in.\nThe field is unset when the `MsgExecuteContract`/`MsgInstantiateContract`/`MsgMigrateContract`\nis not executed as part of a transaction.", + "value": 6 + } + } + } + ] + } + } +} diff --git a/contracts/cyberpunk/schema/cw_schema/raw/execute.json b/contracts/cyberpunk/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..fad79cda52 --- /dev/null +++ b/contracts/cyberpunk/schema/cw_schema/raw/execute.json @@ -0,0 +1,86 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "allocate_large_memory": { + "description": "Allocate large amounts of memory without consuming much gas", + "type": "named", + "properties": { + "pages": { + "value": 0 + } + } + }, + "argon2": { + "description": "Hashes some data. Uses CPU and memory, but no external calls.", + "type": "named", + "properties": { + "mem_cost": { + "description": "The amount of memory requested (KB).", + "value": 0 + }, + "time_cost": { + "description": "The number of passes.", + "value": 0 + } + } + }, + "cpu_loop": { + "description": "Infinite loop to burn cpu cycles (only run when metering is enabled)", + "type": "named", + "properties": {} + }, + "debug": { + "description": "Does a bit of work and calls debug", + "type": "named", + "properties": {} + }, + "memory_loop": { + "description": "Infinite loop reading and writing memory", + "type": "named", + "properties": {} + }, + "message_loop": { + "description": "Infinite loop sending message to itself", + "type": "named", + "properties": {} + }, + "mirror_env": { + "description": "Returns the env for testing", + "type": "named", + "properties": {} + }, + "noop": { + "description": "Does nothing. This can be used for baseline contract execution performance measurements.", + "type": "named", + "properties": {} + }, + "panic": { + "description": "Trigger a panic to ensure framework handles gracefully", + "type": "named", + "properties": {} + }, + "storage_loop": { + "description": "Infinite loop making storage calls (to test when their limit hits)", + "type": "named", + "properties": {} + }, + "unreachable": { + "description": "In contrast to Panic, this does not use the panic handler.\n\nFrom :\n\"Generates the unreachable instruction, which causes an unconditional trap.\"", + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/cyberpunk/schema/cw_schema/raw/instantiate.json b/contracts/cyberpunk/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..3935d14d40 --- /dev/null +++ b/contracts/cyberpunk/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,12 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/cyberpunk/schema/cw_schema/raw/query.json b/contracts/cyberpunk/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..b15ea6a34f --- /dev/null +++ b/contracts/cyberpunk/schema/cw_schema/raw/query.json @@ -0,0 +1,35 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "denom": { + "description": "Queries `DenomMetadata` from the bank module and returns the result", + "type": "named", + "properties": { + "denom": { + "value": 0 + } + } + }, + "denoms": { + "description": "Queries `AllDenomMetadata` from the bank module repeatedly and returns all entries", + "type": "named", + "properties": {} + }, + "mirror_env": { + "description": "Returns the env for testing", + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/cyberpunk/schema/cw_schema/raw/response_to_denom.json b/contracts/cyberpunk/schema/cw_schema/raw/response_to_denom.json new file mode 100644 index 0000000000..8b45ec4a7d --- /dev/null +++ b/contracts/cyberpunk/schema/cw_schema/raw/response_to_denom.json @@ -0,0 +1,73 @@ +{ + "type": "v1", + "root": 5, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "DenomUnit", + "description": "Replicates the cosmos-sdk bank module DenomUnit type", + "type": "struct", + "properties": { + "aliases": { + "value": 2 + }, + "denom": { + "value": 0 + }, + "exponent": { + "value": 1 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "DenomMetadata", + "description": "Replicates the cosmos-sdk bank module Metadata type", + "type": "struct", + "properties": { + "base": { + "value": 0 + }, + "denom_units": { + "value": 4 + }, + "description": { + "value": 0 + }, + "display": { + "value": 0 + }, + "name": { + "value": 0 + }, + "symbol": { + "value": 0 + }, + "uri": { + "value": 0 + }, + "uri_hash": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/cyberpunk/schema/cw_schema/raw/response_to_denoms.json b/contracts/cyberpunk/schema/cw_schema/raw/response_to_denoms.json new file mode 100644 index 0000000000..7fe51a29cc --- /dev/null +++ b/contracts/cyberpunk/schema/cw_schema/raw/response_to_denoms.json @@ -0,0 +1,78 @@ +{ + "type": "v1", + "root": 6, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "DenomUnit", + "description": "Replicates the cosmos-sdk bank module DenomUnit type", + "type": "struct", + "properties": { + "aliases": { + "value": 2 + }, + "denom": { + "value": 0 + }, + "exponent": { + "value": 1 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "DenomMetadata", + "description": "Replicates the cosmos-sdk bank module Metadata type", + "type": "struct", + "properties": { + "base": { + "value": 0 + }, + "denom_units": { + "value": 4 + }, + "description": { + "value": 0 + }, + "display": { + "value": 0 + }, + "name": { + "value": 0 + }, + "symbol": { + "value": 0 + }, + "uri": { + "value": 0 + }, + "uri_hash": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 5 + } + ] +} diff --git a/contracts/cyberpunk/schema/cw_schema/raw/response_to_mirror_env.json b/contracts/cyberpunk/schema/cw_schema/raw/response_to_mirror_env.json new file mode 100644 index 0000000000..203c69068c --- /dev/null +++ b/contracts/cyberpunk/schema/cw_schema/raw/response_to_mirror_env.json @@ -0,0 +1,89 @@ +{ + "type": "v1", + "root": 9, + "definitions": [ + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "String", + "type": "string" + }, + { + "name": "BlockInfo", + "type": "struct", + "properties": { + "chain_id": { + "value": 2 + }, + "height": { + "description": "The height of a block is the number of blocks preceding it in the blockchain.", + "value": 0 + }, + "time": { + "description": "Absolute time of the block creation in seconds since the UNIX epoch (00:00:00 on 1970-01-01 UTC).\n\nThe source of this is the [BFT Time in Tendermint](https://github.com/tendermint/tendermint/blob/58dc1726/spec/consensus/bft-time.md),\nwhich has the same nanosecond precision as the `Timestamp` type.\n\n# Examples\n\nUsing chrono:\n\n```\n# use cosmwasm_std::{Addr, BlockInfo, ContractInfo, Env, MessageInfo, Timestamp, TransactionInfo};\n# let env = Env {\n# block: BlockInfo {\n# height: 12_345,\n# time: Timestamp::from_nanos(1_571_797_419_879_305_533),\n# chain_id: \"cosmos-testnet-14002\".to_string(),\n# },\n# transaction: Some(TransactionInfo { index: 3 }),\n# contract: ContractInfo {\n# address: Addr::unchecked(\"contract\"),\n# },\n# };\n# extern crate chrono;\nuse chrono::NaiveDateTime;\nlet seconds = env.block.time.seconds();\nlet nsecs = env.block.time.subsec_nanos();\nlet dt = NaiveDateTime::from_timestamp(seconds as i64, nsecs as u32);\n```\n\nCreating a simple millisecond-precision timestamp (as used in JavaScript):\n\n```\n# use cosmwasm_std::{Addr, BlockInfo, ContractInfo, Env, MessageInfo, Timestamp, TransactionInfo};\n# let env = Env {\n# block: BlockInfo {\n# height: 12_345,\n# time: Timestamp::from_nanos(1_571_797_419_879_305_533),\n# chain_id: \"cosmos-testnet-14002\".to_string(),\n# },\n# transaction: Some(TransactionInfo { index: 3 }),\n# contract: ContractInfo {\n# address: Addr::unchecked(\"contract\"),\n# },\n# };\nlet millis = env.block.time.nanos() / 1_000_000;\n```", + "value": 1 + } + } + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "TransactionInfo", + "type": "struct", + "properties": { + "index": { + "description": "The position of this transaction in the block. The first\ntransaction has index 0.\n\nThis allows you to get a unique transaction identifier in this chain\nusing the pair (`env.block.height`, `env.transaction.index`).\n", + "value": 4 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 5 + }, + { + "name": "Addr", + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no\nassumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways\n1. Use `Addr::unchecked(input)`\n2. Use `let checked: Addr = deps.api.addr_validate(input)?`\n3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?`\n4. Deserialize from JSON. This must only be done from JSON that was validated before\nsuch as a contract's state. `Addr` must not be used in messages sent by the user\nbecause this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create\na mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String`\ninstance.", + "type": "address" + }, + { + "name": "ContractInfo", + "type": "struct", + "properties": { + "address": { + "value": 7 + } + } + }, + { + "name": "Env", + "type": "struct", + "properties": { + "block": { + "value": 3 + }, + "contract": { + "value": 8 + }, + "transaction": { + "description": "Information on the transaction this message was executed in.\nThe field is unset when the `MsgExecuteContract`/`MsgInstantiateContract`/`MsgMigrateContract`\nis not executed as part of a transaction.", + "value": 6 + } + } + } + ] +} diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 3e446fabbf..fa21f4f9c4 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -749,7 +776,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", ] [[package]] @@ -919,6 +946,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -952,14 +985,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -969,6 +1019,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1130,6 +1189,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1308,6 +1376,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1425,7 +1513,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1442,6 +1543,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1481,9 +1594,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1510,9 +1623,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1532,15 +1645,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1578,6 +1715,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1596,6 +1739,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.26.2" @@ -1624,6 +1773,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1968,7 +2127,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/empty/schema/cw_schema/empty.json b/contracts/empty/schema/cw_schema/empty.json new file mode 100644 index 0000000000..58d5e48c12 --- /dev/null +++ b/contracts/empty/schema/cw_schema/empty.json @@ -0,0 +1,11 @@ +{ + "contract_name": "empty", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": null, + "execute": null, + "query": null, + "migrate": null, + "sudo": null, + "responses": null +} diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 3d6f40994b..a42840329f 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -819,7 +846,7 @@ dependencies = [ "cosmwasm-std", "cosmwasm-vm", "rand_chacha", - "schemars", + "schemars 0.8.21", "serde", ] @@ -921,6 +948,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -954,14 +987,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -971,6 +1021,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1132,6 +1191,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1310,6 +1378,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1427,7 +1515,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1444,6 +1545,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1483,9 +1596,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1512,9 +1625,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1534,15 +1647,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1580,6 +1717,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1598,6 +1741,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.26.2" @@ -1626,6 +1775,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1970,7 +2129,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/floaty/schema/cw_schema/floaty.json b/contracts/floaty/schema/cw_schema/floaty.json new file mode 100644 index 0000000000..2741d1f860 --- /dev/null +++ b/contracts/floaty/schema/cw_schema/floaty.json @@ -0,0 +1,230 @@ +{ + "contract_name": "floaty", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] + }, + "execute": null, + "query": { + "type": "v1", + "root": 5, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "Value", + "type": "enum", + "cases": { + "f32": { + "type": "tuple", + "items": [ + 2 + ] + }, + "f64": { + "type": "tuple", + "items": [ + 1 + ] + }, + "u32": { + "type": "tuple", + "items": [ + 2 + ] + }, + "u64": { + "type": "tuple", + "items": [ + 1 + ] + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "instructions": { + "description": "Returns a list of all instructions", + "type": "named", + "properties": {} + }, + "random_args_for": { + "description": "Returns valid random arguments for the given instruction", + "type": "named", + "properties": { + "instruction": { + "value": 0 + }, + "seed": { + "value": 1 + } + } + }, + "run": { + "description": "Runs the given instruction with the given arguments and returns the result", + "type": "named", + "properties": { + "args": { + "value": 4 + }, + "instruction": { + "value": 0 + } + } + } + } + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "instructions": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + } + ] + }, + "random_args_for": { + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Value", + "type": "enum", + "cases": { + "f32": { + "type": "tuple", + "items": [ + 0 + ] + }, + "f64": { + "type": "tuple", + "items": [ + 1 + ] + }, + "u32": { + "type": "tuple", + "items": [ + 0 + ] + }, + "u64": { + "type": "tuple", + "items": [ + 1 + ] + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + } + ] + }, + "run": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Value", + "type": "enum", + "cases": { + "f32": { + "type": "tuple", + "items": [ + 0 + ] + }, + "f64": { + "type": "tuple", + "items": [ + 1 + ] + }, + "u32": { + "type": "tuple", + "items": [ + 0 + ] + }, + "u64": { + "type": "tuple", + "items": [ + 1 + ] + } + } + } + ] + } + } +} diff --git a/contracts/floaty/schema/cw_schema/raw/instantiate.json b/contracts/floaty/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..3935d14d40 --- /dev/null +++ b/contracts/floaty/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,12 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/floaty/schema/cw_schema/raw/query.json b/contracts/floaty/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..4831e8ed70 --- /dev/null +++ b/contracts/floaty/schema/cw_schema/raw/query.json @@ -0,0 +1,92 @@ +{ + "type": "v1", + "root": 5, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "Value", + "type": "enum", + "cases": { + "f32": { + "type": "tuple", + "items": [ + 2 + ] + }, + "f64": { + "type": "tuple", + "items": [ + 1 + ] + }, + "u32": { + "type": "tuple", + "items": [ + 2 + ] + }, + "u64": { + "type": "tuple", + "items": [ + 1 + ] + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "instructions": { + "description": "Returns a list of all instructions", + "type": "named", + "properties": {} + }, + "random_args_for": { + "description": "Returns valid random arguments for the given instruction", + "type": "named", + "properties": { + "instruction": { + "value": 0 + }, + "seed": { + "value": 1 + } + } + }, + "run": { + "description": "Runs the given instruction with the given arguments and returns the result", + "type": "named", + "properties": { + "args": { + "value": 4 + }, + "instruction": { + "value": 0 + } + } + } + } + } + ] +} diff --git a/contracts/floaty/schema/cw_schema/raw/response_to_instructions.json b/contracts/floaty/schema/cw_schema/raw/response_to_instructions.json new file mode 100644 index 0000000000..ba9dbee3df --- /dev/null +++ b/contracts/floaty/schema/cw_schema/raw/response_to_instructions.json @@ -0,0 +1,15 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + } + ] +} diff --git a/contracts/floaty/schema/cw_schema/raw/response_to_random_args_for.json b/contracts/floaty/schema/cw_schema/raw/response_to_random_args_for.json new file mode 100644 index 0000000000..8f8ae6b3ec --- /dev/null +++ b/contracts/floaty/schema/cw_schema/raw/response_to_random_args_for.json @@ -0,0 +1,53 @@ +{ + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Value", + "type": "enum", + "cases": { + "f32": { + "type": "tuple", + "items": [ + 0 + ] + }, + "f64": { + "type": "tuple", + "items": [ + 1 + ] + }, + "u32": { + "type": "tuple", + "items": [ + 0 + ] + }, + "u64": { + "type": "tuple", + "items": [ + 1 + ] + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + } + ] +} diff --git a/contracts/floaty/schema/cw_schema/raw/response_to_run.json b/contracts/floaty/schema/cw_schema/raw/response_to_run.json new file mode 100644 index 0000000000..9c16225637 --- /dev/null +++ b/contracts/floaty/schema/cw_schema/raw/response_to_run.json @@ -0,0 +1,48 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Value", + "type": "enum", + "cases": { + "f32": { + "type": "tuple", + "items": [ + 0 + ] + }, + "f64": { + "type": "tuple", + "items": [ + 1 + ] + }, + "u32": { + "type": "tuple", + "items": [ + 0 + ] + }, + "u64": { + "type": "tuple", + "items": [ + 1 + ] + } + } + } + ] +} diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 1f63fa5c77..dba240589d 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -882,7 +909,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", "sha2", "thiserror", @@ -922,6 +949,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -955,14 +988,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -972,6 +1022,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1133,6 +1192,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1311,6 +1379,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1428,7 +1516,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1445,6 +1546,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1484,9 +1597,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1513,9 +1626,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1535,15 +1648,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1581,6 +1718,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1599,6 +1742,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.26.2" @@ -1627,6 +1776,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1971,7 +2130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/hackatom/schema/cw_schema/hackatom.json b/contracts/hackatom/schema/cw_schema/hackatom.json new file mode 100644 index 0000000000..b42657aefa --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/hackatom.json @@ -0,0 +1,321 @@ +{ + "contract_name": "hackatom", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "InstantiateMsg", + "type": "struct", + "properties": { + "beneficiary": { + "value": 0 + }, + "verifier": { + "value": 0 + } + } + } + ] + }, + "execute": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "allocate_large_memory": { + "description": "Allocate large amounts of memory without consuming much gas", + "type": "named", + "properties": { + "pages": { + "value": 0 + } + } + }, + "cpu_loop": { + "description": "Infinite loop to burn cpu cycles (only run when metering is enabled)", + "type": "named", + "properties": {} + }, + "memory_loop": { + "description": "Infinite loop reading and writing memory", + "type": "named", + "properties": {} + }, + "message_loop": { + "description": "Infinite loop sending message to itself", + "type": "named", + "properties": {} + }, + "panic": { + "description": "Trigger a panic to ensure framework handles gracefully", + "type": "named", + "properties": {} + }, + "release": { + "description": "Releasing all funds in the contract to the beneficiary. This is the only \"proper\" action of this demo contract.", + "type": "named", + "properties": {} + }, + "storage_loop": { + "description": "Infinite loop making storage calls (to test when their limit hits)", + "type": "named", + "properties": {} + }, + "user_errors_in_api_calls": { + "description": "Starting with CosmWasm 0.10, some API calls return user errors back to the contract.\nThis triggers such user errors, ensuring the transaction does not fail in the backend.", + "type": "named", + "properties": {} + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "get_int": { + "description": "GetInt returns a hardcoded u32 value", + "type": "named", + "properties": {} + }, + "other_balance": { + "description": "This returns cosmwasm_std::AllBalanceResponse to demo use of the querier", + "type": "named", + "properties": { + "address": { + "value": 0 + } + } + }, + "recurse": { + "description": "Recurse will execute a query into itself up to depth-times and return\nEach step of the recursion may perform some extra work to test gas metering\n(`work` rounds of sha256 on contract).\nNow that we have Env, we can auto-calculate the address to recurse into", + "type": "named", + "properties": { + "depth": { + "value": 1 + }, + "work": { + "value": 1 + } + } + }, + "verifier": { + "description": "returns a human-readable representation of the verifier\nuse to ensure query path works in integration tests", + "type": "named", + "properties": {} + } + } + } + ] + }, + "migrate": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "MigrateMsg", + "description": "MigrateMsg allows a privileged contract administrator to run\na migration on the contract. In this (demo) case it is just migrating\nfrom one hackatom code to the same code, but taking advantage of the\nmigration step to set a new validator.\n\nNote that the contract doesn't enforce permissions here, this is done\nby blockchain logic (in the future by blockchain governance)", + "type": "struct", + "properties": { + "verifier": { + "value": 0 + } + } + } + ] + }, + "sudo": { + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 1 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + }, + { + "name": "SudoMsg", + "description": "SudoMsg is only exposed for internal Cosmos SDK modules to call.\nThis is showing how we can expose \"admin\" functionality than can not be called by\nexternal users or contracts, but only trusted (native/Go) code in the blockchain", + "type": "enum", + "cases": { + "steal_funds": { + "type": "named", + "properties": { + "amount": { + "value": 3 + }, + "recipient": { + "value": 0 + } + } + } + } + } + ] + }, + "responses": { + "get_int": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "IntResponse", + "type": "struct", + "properties": { + "int": { + "value": 0 + } + } + } + ] + }, + "other_balance": { + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 1 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + }, + { + "name": "AllBalanceResponse", + "type": "struct", + "properties": { + "amount": { + "description": "Returns all non-zero coins held by this account.", + "value": 3 + } + } + } + ] + }, + "recurse": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "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": "RecurseResponse", + "type": "struct", + "properties": { + "hashed": { + "description": "hashed is the result of running sha256 \"work+1\" times on the contract's human address", + "value": 0 + } + } + } + ] + }, + "verifier": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "VerifierResponse", + "type": "struct", + "properties": { + "verifier": { + "value": 0 + } + } + } + ] + } + } +} diff --git a/contracts/hackatom/schema/cw_schema/raw/execute.json b/contracts/hackatom/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..743a9c485f --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/execute.json @@ -0,0 +1,62 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "allocate_large_memory": { + "description": "Allocate large amounts of memory without consuming much gas", + "type": "named", + "properties": { + "pages": { + "value": 0 + } + } + }, + "cpu_loop": { + "description": "Infinite loop to burn cpu cycles (only run when metering is enabled)", + "type": "named", + "properties": {} + }, + "memory_loop": { + "description": "Infinite loop reading and writing memory", + "type": "named", + "properties": {} + }, + "message_loop": { + "description": "Infinite loop sending message to itself", + "type": "named", + "properties": {} + }, + "panic": { + "description": "Trigger a panic to ensure framework handles gracefully", + "type": "named", + "properties": {} + }, + "release": { + "description": "Releasing all funds in the contract to the beneficiary. This is the only \"proper\" action of this demo contract.", + "type": "named", + "properties": {} + }, + "storage_loop": { + "description": "Infinite loop making storage calls (to test when their limit hits)", + "type": "named", + "properties": {} + }, + "user_errors_in_api_calls": { + "description": "Starting with CosmWasm 0.10, some API calls return user errors back to the contract.\nThis triggers such user errors, ensuring the transaction does not fail in the backend.", + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/hackatom/schema/cw_schema/raw/instantiate.json b/contracts/hackatom/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..d1d688c142 --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,22 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "InstantiateMsg", + "type": "struct", + "properties": { + "beneficiary": { + "value": 0 + }, + "verifier": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/hackatom/schema/cw_schema/raw/migrate.json b/contracts/hackatom/schema/cw_schema/raw/migrate.json new file mode 100644 index 0000000000..b3bc287ac9 --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/migrate.json @@ -0,0 +1,20 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "MigrateMsg", + "description": "MigrateMsg allows a privileged contract administrator to run\na migration on the contract. In this (demo) case it is just migrating\nfrom one hackatom code to the same code, but taking advantage of the\nmigration step to set a new validator.\n\nNote that the contract doesn't enforce permissions here, this is done\nby blockchain logic (in the future by blockchain governance)", + "type": "struct", + "properties": { + "verifier": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/hackatom/schema/cw_schema/raw/query.json b/contracts/hackatom/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..5d61892dd1 --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/query.json @@ -0,0 +1,53 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "get_int": { + "description": "GetInt returns a hardcoded u32 value", + "type": "named", + "properties": {} + }, + "other_balance": { + "description": "This returns cosmwasm_std::AllBalanceResponse to demo use of the querier", + "type": "named", + "properties": { + "address": { + "value": 0 + } + } + }, + "recurse": { + "description": "Recurse will execute a query into itself up to depth-times and return\nEach step of the recursion may perform some extra work to test gas metering\n(`work` rounds of sha256 on contract).\nNow that we have Env, we can auto-calculate the address to recurse into", + "type": "named", + "properties": { + "depth": { + "value": 1 + }, + "work": { + "value": 1 + } + } + }, + "verifier": { + "description": "returns a human-readable representation of the verifier\nuse to ensure query path works in integration tests", + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/hackatom/schema/cw_schema/raw/response_to_get_int.json b/contracts/hackatom/schema/cw_schema/raw/response_to_get_int.json new file mode 100644 index 0000000000..db7f166d6b --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/response_to_get_int.json @@ -0,0 +1,21 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "IntResponse", + "type": "struct", + "properties": { + "int": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/hackatom/schema/cw_schema/raw/response_to_other_balance.json b/contracts/hackatom/schema/cw_schema/raw/response_to_other_balance.json new file mode 100644 index 0000000000..05dd5b3c1a --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/response_to_other_balance.json @@ -0,0 +1,44 @@ +{ + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 1 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + }, + { + "name": "AllBalanceResponse", + "type": "struct", + "properties": { + "amount": { + "description": "Returns all non-zero coins held by this account.", + "value": 3 + } + } + } + ] +} diff --git a/contracts/hackatom/schema/cw_schema/raw/response_to_recurse.json b/contracts/hackatom/schema/cw_schema/raw/response_to_recurse.json new file mode 100644 index 0000000000..c524ecf67a --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/response_to_recurse.json @@ -0,0 +1,21 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "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": "RecurseResponse", + "type": "struct", + "properties": { + "hashed": { + "description": "hashed is the result of running sha256 \"work+1\" times on the contract's human address", + "value": 0 + } + } + } + ] +} diff --git a/contracts/hackatom/schema/cw_schema/raw/response_to_verifier.json b/contracts/hackatom/schema/cw_schema/raw/response_to_verifier.json new file mode 100644 index 0000000000..10f33f2e89 --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/response_to_verifier.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "VerifierResponse", + "type": "struct", + "properties": { + "verifier": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/hackatom/schema/cw_schema/raw/sudo.json b/contracts/hackatom/schema/cw_schema/raw/sudo.json new file mode 100644 index 0000000000..b822821385 --- /dev/null +++ b/contracts/hackatom/schema/cw_schema/raw/sudo.json @@ -0,0 +1,52 @@ +{ + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 1 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + }, + { + "name": "SudoMsg", + "description": "SudoMsg is only exposed for internal Cosmos SDK modules to call.\nThis is showing how we can expose \"admin\" functionality than can not be called by\nexternal users or contracts, but only trusted (native/Go) code in the blockchain", + "type": "enum", + "cases": { + "steal_funds": { + "type": "named", + "properties": { + "amount": { + "value": 3 + }, + "recipient": { + "value": 0 + } + } + } + } + } + ] +} diff --git a/contracts/ibc-callbacks/Cargo.lock b/contracts/ibc-callbacks/Cargo.lock index b0ac1ccbf8..0492433a13 100644 --- a/contracts/ibc-callbacks/Cargo.lock +++ b/contracts/ibc-callbacks/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.20", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.20", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.20", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck 0.5.0", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -909,6 +936,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.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -931,7 +970,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.20", "serde", ] @@ -953,14 +992,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -970,6 +1026,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1131,6 +1196,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1309,6 +1383,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1426,7 +1520,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0218ceea14babe24a4a5836f86ade86c1effbc198164e619194cb5069187e29" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.20", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1443,6 +1550,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1482,9 +1601,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.202" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1511,9 +1630,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1533,15 +1652,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1579,6 +1722,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1597,6 +1746,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.26.2" @@ -1612,7 +1767,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -1625,6 +1780,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1969,7 +2134,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/ibc-callbacks/schema/cw_schema/ibc-callbacks.json b/contracts/ibc-callbacks/schema/cw_schema/ibc-callbacks.json new file mode 100644 index 0000000000..5025001bca --- /dev/null +++ b/contracts/ibc-callbacks/schema/cw_schema/ibc-callbacks.json @@ -0,0 +1,285 @@ +{ + "contract_name": "ibc-callbacks", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] + }, + "execute": { + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "CallbackType", + "type": "enum", + "cases": { + "both": { + "description": "Both the source contract and the destination address should receive callbacks", + "type": "unit" + }, + "dst": { + "description": "Only the destination address should receive callbacks", + "type": "unit" + }, + "src": { + "description": "Only this contract on the source chain should receive callbacks", + "type": "unit" + } + } + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "transfer": { + "type": "named", + "properties": { + "callback_type": { + "description": "Who should receive callbacks for the message", + "value": 2 + }, + "channel_id": { + "description": "The channel to send the packet through", + "value": 0 + }, + "timeout_seconds": { + "description": "The amount of seconds from now the transfer should timeout at", + "value": 1 + }, + "to_address": { + "description": "Address on the destination chain", + "value": 0 + } + } + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "callback_stats": { + "description": "Returns stats about what callbacks have been received", + "type": "named", + "properties": {} + } + } + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "callback_stats": { + "type": "v1", + "root": 18, + "definitions": [ + { + "name": "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": "IbcAcknowledgement", + "type": "struct", + "properties": { + "data": { + "value": 0 + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "IbcEndpoint", + "type": "struct", + "properties": { + "channel_id": { + "value": 2 + }, + "port_id": { + "value": 2 + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "IbcTimeoutBlock", + "description": "IBCTimeoutHeight Height is a monotonically increasing data type\nthat can be compared against another Height for the purposes of updating and\nfreezing clients.\nOrdering is (revision_number, timeout_height)", + "type": "struct", + "properties": { + "height": { + "description": "block height after which the packet times out.\nthe height within the given revision", + "value": 4 + }, + "revision": { + "description": "the version that the client is currently on\n(e.g. after resetting the chain this could increment 1 as height drops to 0)", + "value": 4 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 5 + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 7 + }, + { + "name": "IbcTimeout", + "description": "In IBC each package must set at least one type of timeout:\nthe timestamp or the block height. Using this rather complex enum instead of\ntwo timeout fields we ensure that at least one timeout is set.", + "type": "struct", + "properties": { + "block": { + "value": 6 + }, + "timestamp": { + "value": 8 + } + } + }, + { + "name": "IbcPacket", + "type": "struct", + "properties": { + "data": { + "description": "The raw data sent from the other side in the packet", + "value": 0 + }, + "dest": { + "description": "identifies the channel and port on the receiving chain.", + "value": 3 + }, + "sequence": { + "description": "The sequence number of the packet on the given channel", + "value": 4 + }, + "src": { + "description": "identifies the channel and port on the sending chain.", + "value": 3 + }, + "timeout": { + "value": 9 + } + } + }, + { + "name": "Addr", + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no\nassumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways\n1. Use `Addr::unchecked(input)`\n2. Use `let checked: Addr = deps.api.addr_validate(input)?`\n3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?`\n4. Deserialize from JSON. This must only be done from JSON that was validated before\nsuch as a contract's state. `Addr` must not be used in messages sent by the user\nbecause this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create\na mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String`\ninstance.", + "type": "address" + }, + { + "name": "IbcAckCallbackMsg", + "type": "struct", + "properties": { + "acknowledgement": { + "value": 1 + }, + "original_packet": { + "value": 10 + }, + "relayer": { + "value": 11 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 12 + }, + { + "name": "IbcTimeoutCallbackMsg", + "type": "struct", + "properties": { + "packet": { + "value": 10 + }, + "relayer": { + "value": 11 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 14 + }, + { + "name": "IbcDestinationCallbackMsg", + "description": "The message type of the IBC destination callback.\n\nThe IBC destination callback is needed for cases where someone triggers the sending of an\nIBC packet through some other message (i.e. not through [`crate::IbcMsg::SendPacket`]) and\nyour contract needs to know that it received this.\nA prominent example is the [`crate::IbcMsg::Transfer`] message. Without callbacks, you cannot know\nthat someone sent you IBC coins.\n\nIt is important to validate that the packet and acknowledgement are what you expect them to be.\nFor example for a transfer message, the receiver is not necessarily the contract itself.\n\nThe callback is called when the packet is being acknowledged on the destination chain.\nThis happens for both synchronous and asynchronous acknowledgements.\n\nNote that there are some prerequisites that need to be fulfilled to receive destination callbacks:\n- The contract must implement the `ibc_destination_callback` entrypoint.\n- The IBC application in the destination chain must have support for the callbacks middleware.\n- You have to add serialized [`IbcCallbackRequest`] to a specific field of the message.\nFor `IbcMsg::Transfer`, this is the `memo` field and it needs to be json-encoded.", + "type": "struct", + "properties": { + "ack": { + "value": 1 + }, + "packet": { + "value": 10 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 16 + }, + { + "name": "CallbackStats", + "description": "A counter for the number of times the respective callback has been called", + "type": "struct", + "properties": { + "ibc_ack_callbacks": { + "value": 13 + }, + "ibc_destination_callbacks": { + "value": 17 + }, + "ibc_timeout_callbacks": { + "value": 15 + } + } + } + ] + } + } +} diff --git a/contracts/ibc-callbacks/schema/cw_schema/raw/execute.json b/contracts/ibc-callbacks/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..108630e719 --- /dev/null +++ b/contracts/ibc-callbacks/schema/cw_schema/raw/execute.json @@ -0,0 +1,61 @@ +{ + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "CallbackType", + "type": "enum", + "cases": { + "both": { + "description": "Both the source contract and the destination address should receive callbacks", + "type": "unit" + }, + "dst": { + "description": "Only the destination address should receive callbacks", + "type": "unit" + }, + "src": { + "description": "Only this contract on the source chain should receive callbacks", + "type": "unit" + } + } + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "transfer": { + "type": "named", + "properties": { + "callback_type": { + "description": "Who should receive callbacks for the message", + "value": 2 + }, + "channel_id": { + "description": "The channel to send the packet through", + "value": 0 + }, + "timeout_seconds": { + "description": "The amount of seconds from now the transfer should timeout at", + "value": 1 + }, + "to_address": { + "description": "Address on the destination chain", + "value": 0 + } + } + } + } + } + ] +} diff --git a/contracts/ibc-callbacks/schema/cw_schema/raw/instantiate.json b/contracts/ibc-callbacks/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..3935d14d40 --- /dev/null +++ b/contracts/ibc-callbacks/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,12 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/ibc-callbacks/schema/cw_schema/raw/query.json b/contracts/ibc-callbacks/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..ca7367066d --- /dev/null +++ b/contracts/ibc-callbacks/schema/cw_schema/raw/query.json @@ -0,0 +1,17 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "callback_stats": { + "description": "Returns stats about what callbacks have been received", + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/ibc-callbacks/schema/cw_schema/raw/response_to_callback_stats.json b/contracts/ibc-callbacks/schema/cw_schema/raw/response_to_callback_stats.json new file mode 100644 index 0000000000..bb57c3a814 --- /dev/null +++ b/contracts/ibc-callbacks/schema/cw_schema/raw/response_to_callback_stats.json @@ -0,0 +1,186 @@ +{ + "type": "v1", + "root": 18, + "definitions": [ + { + "name": "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": "IbcAcknowledgement", + "type": "struct", + "properties": { + "data": { + "value": 0 + } + } + }, + { + "name": "String", + "type": "string" + }, + { + "name": "IbcEndpoint", + "type": "struct", + "properties": { + "channel_id": { + "value": 2 + }, + "port_id": { + "value": 2 + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "IbcTimeoutBlock", + "description": "IBCTimeoutHeight Height is a monotonically increasing data type\nthat can be compared against another Height for the purposes of updating and\nfreezing clients.\nOrdering is (revision_number, timeout_height)", + "type": "struct", + "properties": { + "height": { + "description": "block height after which the packet times out.\nthe height within the given revision", + "value": 4 + }, + "revision": { + "description": "the version that the client is currently on\n(e.g. after resetting the chain this could increment 1 as height drops to 0)", + "value": 4 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 5 + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 7 + }, + { + "name": "IbcTimeout", + "description": "In IBC each package must set at least one type of timeout:\nthe timestamp or the block height. Using this rather complex enum instead of\ntwo timeout fields we ensure that at least one timeout is set.", + "type": "struct", + "properties": { + "block": { + "value": 6 + }, + "timestamp": { + "value": 8 + } + } + }, + { + "name": "IbcPacket", + "type": "struct", + "properties": { + "data": { + "description": "The raw data sent from the other side in the packet", + "value": 0 + }, + "dest": { + "description": "identifies the channel and port on the receiving chain.", + "value": 3 + }, + "sequence": { + "description": "The sequence number of the packet on the given channel", + "value": 4 + }, + "src": { + "description": "identifies the channel and port on the sending chain.", + "value": 3 + }, + "timeout": { + "value": 9 + } + } + }, + { + "name": "Addr", + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no\nassumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways\n1. Use `Addr::unchecked(input)`\n2. Use `let checked: Addr = deps.api.addr_validate(input)?`\n3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?`\n4. Deserialize from JSON. This must only be done from JSON that was validated before\nsuch as a contract's state. `Addr` must not be used in messages sent by the user\nbecause this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create\na mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String`\ninstance.", + "type": "address" + }, + { + "name": "IbcAckCallbackMsg", + "type": "struct", + "properties": { + "acknowledgement": { + "value": 1 + }, + "original_packet": { + "value": 10 + }, + "relayer": { + "value": 11 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 12 + }, + { + "name": "IbcTimeoutCallbackMsg", + "type": "struct", + "properties": { + "packet": { + "value": 10 + }, + "relayer": { + "value": 11 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 14 + }, + { + "name": "IbcDestinationCallbackMsg", + "description": "The message type of the IBC destination callback.\n\nThe IBC destination callback is needed for cases where someone triggers the sending of an\nIBC packet through some other message (i.e. not through [`crate::IbcMsg::SendPacket`]) and\nyour contract needs to know that it received this.\nA prominent example is the [`crate::IbcMsg::Transfer`] message. Without callbacks, you cannot know\nthat someone sent you IBC coins.\n\nIt is important to validate that the packet and acknowledgement are what you expect them to be.\nFor example for a transfer message, the receiver is not necessarily the contract itself.\n\nThe callback is called when the packet is being acknowledged on the destination chain.\nThis happens for both synchronous and asynchronous acknowledgements.\n\nNote that there are some prerequisites that need to be fulfilled to receive destination callbacks:\n- The contract must implement the `ibc_destination_callback` entrypoint.\n- The IBC application in the destination chain must have support for the callbacks middleware.\n- You have to add serialized [`IbcCallbackRequest`] to a specific field of the message.\nFor `IbcMsg::Transfer`, this is the `memo` field and it needs to be json-encoded.", + "type": "struct", + "properties": { + "ack": { + "value": 1 + }, + "packet": { + "value": 10 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 16 + }, + { + "name": "CallbackStats", + "description": "A counter for the number of times the respective callback has been called", + "type": "struct", + "properties": { + "ibc_ack_callbacks": { + "value": 13 + }, + "ibc_destination_callbacks": { + "value": 17 + }, + "ibc_timeout_callbacks": { + "value": 15 + } + } + } + ] +} diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index 76cce5ccd3..774e8a6dc7 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -909,6 +936,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -931,7 +964,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", ] @@ -953,14 +986,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -970,6 +1020,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1131,6 +1190,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1309,6 +1377,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1426,7 +1514,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1443,6 +1544,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1482,9 +1595,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1511,9 +1624,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1533,15 +1646,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1579,6 +1716,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1597,6 +1740,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.26.2" @@ -1625,6 +1774,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1969,7 +2128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/ibc-reflect-send/schema/cw_schema/ibc-reflect-send.json b/contracts/ibc-reflect-send/schema/cw_schema/ibc-reflect-send.json new file mode 100644 index 0000000000..ec7416ee32 --- /dev/null +++ b/contracts/ibc-reflect-send/schema/cw_schema/ibc-reflect-send.json @@ -0,0 +1,707 @@ +{ + "contract_name": "ibc-reflect-send", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "description": "This needs no info. Owner of the contract is whoever signed the InstantiateMsg.", + "type": "struct", + "properties": {} + } + ] + }, + "execute": { + "type": "v1", + "root": 22, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 1 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + }, + { + "name": "BankMsg", + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "type": "enum", + "cases": { + "burn": { + "description": "This will burn the given coins from the contract's account.\nThere is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper.\nImportant if a contract controls significant token supply that must be retired.", + "type": "named", + "properties": { + "amount": { + "value": 3 + } + } + }, + "send": { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28).\n`from_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 3 + }, + "to_address": { + "value": 0 + } + } + } + } + }, + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + }, + { + "name": "StakingMsg", + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "type": "enum", + "cases": { + "delegate": { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "validator": { + "value": 0 + } + } + }, + "redelegate": { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "dst_validator": { + "value": 0 + }, + "src_validator": { + "value": 0 + } + } + }, + "undelegate": { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "validator": { + "value": 0 + } + } + } + } + }, + { + "name": "DistributionMsg", + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "type": "enum", + "cases": { + "set_withdraw_address": { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "address": { + "description": "The `withdraw_address`", + "value": 0 + } + } + }, + "withdraw_delegator_reward": { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "validator": { + "description": "The `validator_address`", + "value": 0 + } + } + } + } + }, + { + "name": "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": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "IbcTimeoutBlock", + "description": "IBCTimeoutHeight Height is a monotonically increasing data type\nthat can be compared against another Height for the purposes of updating and\nfreezing clients.\nOrdering is (revision_number, timeout_height)", + "type": "struct", + "properties": { + "height": { + "description": "block height after which the packet times out.\nthe height within the given revision", + "value": 9 + }, + "revision": { + "description": "the version that the client is currently on\n(e.g. after resetting the chain this could increment 1 as height drops to 0)", + "value": 9 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 10 + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 12 + }, + { + "name": "IbcTimeout", + "description": "In IBC each package must set at least one type of timeout:\nthe timestamp or the block height. Using this rather complex enum instead of\ntwo timeout fields we ensure that at least one timeout is set.", + "type": "struct", + "properties": { + "block": { + "value": 11 + }, + "timestamp": { + "value": 13 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "IbcMsg", + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts\n(contracts that directly speak the IBC protocol via 6 entry points)", + "type": "enum", + "cases": { + "close_channel": { + "description": "This will close an existing channel that is owned by this contract.\nPort is auto-assigned to the contract's IBC port", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "send_packet": { + "description": "Sends an IBC packet with given data over the existing channel.\nData should be encoded in a format defined by the channel version,\nand the module on the other side should know how to parse this.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "data": { + "value": 8 + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "value": 14 + } + } + }, + "transfer": { + "description": "Sends bank tokens owned by the contract to the given address on another chain.\nThe channel must already be established between the ibctransfer module on this chain\nand a matching module on the remote chain.\nWe cannot select the port_id, this is whatever the local chain has bound the ibctransfer\nmodule to.", + "type": "named", + "properties": { + "amount": { + "description": "packet data only supports one coin\nhttps://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "value": 2 + }, + "channel_id": { + "description": "existing channel to send the tokens over", + "value": 0 + }, + "memo": { + "description": "An optional memo. See the blog post\n[\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b)\nfor more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently\nignored on older chains.\nIf you need support for both 1.x and 2.x chain with the same codebase,\nit is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer\nprotobuf encoder instead.", + "value": 15 + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "value": 14 + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "value": 0 + } + } + } + } + }, + { + "name": "WasmMsg", + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "type": "enum", + "cases": { + "clear_admin": { + "description": "Clears the admin on the given contract, so no more migration possible.\nFails if this contract is not currently admin of the target contract.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + } + } + }, + "execute": { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "funds": { + "value": 3 + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "value": 8 + } + } + }, + "instantiate": { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThe contract address is non-predictable. But it is guaranteed that\nwhen emitting the same Instantiate message multiple times,\nmultiple instances on different addresses will be generated. See also\nInstantiate2.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L53-L71).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "admin": { + "value": 15 + }, + "code_id": { + "value": 9 + }, + "funds": { + "value": 3 + }, + "label": { + "description": "A human-readable label for the contract.\n\nValid values should:\n- not be empty\n- not be bigger than 128 bytes (or some chain-specific limit)\n- not start / end with whitespace", + "value": 0 + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "value": 8 + } + } + }, + "migrate": { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to\ncustomize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "value": 8 + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "value": 9 + } + } + }, + "update_admin": { + "description": "Sets a new admin (for migrate) on the given contract.\nFails if this contract is not currently admin of the target contract.", + "type": "named", + "properties": { + "admin": { + "value": 0 + }, + "contract_addr": { + "value": 0 + } + } + } + } + }, + { + "name": "VoteOption", + "type": "enum", + "cases": { + "abstain": { + "type": "unit" + }, + "no": { + "type": "unit" + }, + "no_with_veto": { + "type": "unit" + }, + "yes": { + "type": "unit" + } + } + }, + { + "name": "GovMsg", + "description": "This message type allows the contract interact with the [x/gov] module in order\nto cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n```\n# use cosmwasm_std::{\n# HexBinary,\n# Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,\n# Response, QueryResponse,\n# };\n# type ExecuteMsg = ();\nuse cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point]\npub fn execute(\ndeps: DepsMut,\nenv: Env,\ninfo: MessageInfo,\nmsg: ExecuteMsg,\n) -> Result {\n// ...\nOk(Response::new().add_message(GovMsg::Vote {\nproposal_id: 4,\noption: VoteOption::Yes,\n}))\n}\n```\n\nCast a weighted vote:\n\n```\n# use cosmwasm_std::{\n# HexBinary,\n# Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,\n# Response, QueryResponse,\n# };\n# type ExecuteMsg = ();\n# #[cfg(feature = \"cosmwasm_1_2\")]\nuse cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption};\n\n# #[cfg(feature = \"cosmwasm_1_2\")]\n#[entry_point]\npub fn execute(\ndeps: DepsMut,\nenv: Env,\ninfo: MessageInfo,\nmsg: ExecuteMsg,\n) -> Result {\n// ...\nOk(Response::new().add_message(GovMsg::VoteWeighted {\nproposal_id: 4,\noptions: vec![\nWeightedVoteOption {\noption: VoteOption::Yes,\nweight: Decimal::percent(65),\n},\nWeightedVoteOption {\noption: VoteOption::Abstain,\nweight: Decimal::percent(35),\n},\n],\n}))\n}\n```", + "type": "enum", + "cases": { + "vote": { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "named", + "properties": { + "option": { + "description": "The vote option.\n\nThis used to be called \"vote\", but was changed for consistency with Cosmos SDK.", + "value": 18 + }, + "proposal_id": { + "value": 9 + } + } + } + } + }, + { + "name": "CosmosMsg", + "type": "enum", + "cases": { + "bank": { + "type": "tuple", + "items": [ + 4 + ] + }, + "custom": { + "type": "tuple", + "items": [ + 5 + ] + }, + "distribution": { + "type": "tuple", + "items": [ + 7 + ] + }, + "gov": { + "type": "tuple", + "items": [ + 19 + ] + }, + "ibc": { + "type": "tuple", + "items": [ + 16 + ] + }, + "staking": { + "type": "tuple", + "items": [ + 6 + ] + }, + "stargate": { + "description": "This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "named", + "properties": { + "type_url": { + "value": 0 + }, + "value": { + "value": 8 + } + } + }, + "wasm": { + "type": "tuple", + "items": [ + 17 + ] + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 20 + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "check_remote_balance": { + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "send_funds": { + "description": "If you sent funds to this contract, it will attempt to ibc transfer them\nto the account on the remote side of this channel.\nIf we don't have the address yet, this fails.", + "type": "named", + "properties": { + "reflect_channel_id": { + "description": "The channel id we use above to talk with the reflect contract", + "value": 0 + }, + "transfer_channel_id": { + "description": "The channel to use for ibctransfer. This is bound to a different\nport and handled by a different module.\nIt should connect to the same chain as the reflect_channel_id does", + "value": 0 + } + } + }, + "send_msgs": { + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "msgs": { + "value": 21 + } + } + }, + "update_admin": { + "description": "Changes the admin", + "type": "named", + "properties": { + "admin": { + "value": 0 + } + } + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "account": { + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "admin": { + "type": "named", + "properties": {} + }, + "list_accounts": { + "type": "named", + "properties": {} + } + } + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "account": { + "type": "v1", + "root": 6, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 3 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 4 + }, + { + "name": "AccountInfo", + "type": "struct", + "properties": { + "channel_id": { + "value": 0 + }, + "last_update_time": { + "description": "last block balance was updated (0 is never)", + "value": 1 + }, + "remote_addr": { + "description": "in normal cases, it should be set, but there is a delay between binding\nthe channel and making a query and in that time it is empty", + "value": 2 + }, + "remote_balance": { + "value": 5 + } + } + } + ] + }, + "admin": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "AdminResponse", + "type": "struct", + "properties": { + "admin": { + "value": 0 + } + } + } + ] + }, + "list_accounts": { + "type": "v1", + "root": 8, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 3 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 4 + }, + { + "name": "AccountInfo", + "type": "struct", + "properties": { + "channel_id": { + "value": 0 + }, + "last_update_time": { + "description": "last block balance was updated (0 is never)", + "value": 1 + }, + "remote_addr": { + "description": "in normal cases, it should be set, but there is a delay between binding\nthe channel and making a query and in that time it is empty", + "value": 2 + }, + "remote_balance": { + "value": 5 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 6 + }, + { + "name": "ListAccountsResponse", + "type": "struct", + "properties": { + "accounts": { + "value": 7 + } + } + } + ] + } + } +} diff --git a/contracts/ibc-reflect-send/schema/cw_schema/raw/execute.json b/contracts/ibc-reflect-send/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..1083c19050 --- /dev/null +++ b/contracts/ibc-reflect-send/schema/cw_schema/raw/execute.json @@ -0,0 +1,493 @@ +{ + "type": "v1", + "root": 22, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 1 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + }, + { + "name": "BankMsg", + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "type": "enum", + "cases": { + "burn": { + "description": "This will burn the given coins from the contract's account.\nThere is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper.\nImportant if a contract controls significant token supply that must be retired.", + "type": "named", + "properties": { + "amount": { + "value": 3 + } + } + }, + "send": { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28).\n`from_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 3 + }, + "to_address": { + "value": 0 + } + } + } + } + }, + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + }, + { + "name": "StakingMsg", + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "type": "enum", + "cases": { + "delegate": { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "validator": { + "value": 0 + } + } + }, + "redelegate": { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "dst_validator": { + "value": 0 + }, + "src_validator": { + "value": 0 + } + } + }, + "undelegate": { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "validator": { + "value": 0 + } + } + } + } + }, + { + "name": "DistributionMsg", + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "type": "enum", + "cases": { + "set_withdraw_address": { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "address": { + "description": "The `withdraw_address`", + "value": 0 + } + } + }, + "withdraw_delegator_reward": { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "validator": { + "description": "The `validator_address`", + "value": 0 + } + } + } + } + }, + { + "name": "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": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "IbcTimeoutBlock", + "description": "IBCTimeoutHeight Height is a monotonically increasing data type\nthat can be compared against another Height for the purposes of updating and\nfreezing clients.\nOrdering is (revision_number, timeout_height)", + "type": "struct", + "properties": { + "height": { + "description": "block height after which the packet times out.\nthe height within the given revision", + "value": 9 + }, + "revision": { + "description": "the version that the client is currently on\n(e.g. after resetting the chain this could increment 1 as height drops to 0)", + "value": 9 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 10 + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 12 + }, + { + "name": "IbcTimeout", + "description": "In IBC each package must set at least one type of timeout:\nthe timestamp or the block height. Using this rather complex enum instead of\ntwo timeout fields we ensure that at least one timeout is set.", + "type": "struct", + "properties": { + "block": { + "value": 11 + }, + "timestamp": { + "value": 13 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "IbcMsg", + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts\n(contracts that directly speak the IBC protocol via 6 entry points)", + "type": "enum", + "cases": { + "close_channel": { + "description": "This will close an existing channel that is owned by this contract.\nPort is auto-assigned to the contract's IBC port", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "send_packet": { + "description": "Sends an IBC packet with given data over the existing channel.\nData should be encoded in a format defined by the channel version,\nand the module on the other side should know how to parse this.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "data": { + "value": 8 + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "value": 14 + } + } + }, + "transfer": { + "description": "Sends bank tokens owned by the contract to the given address on another chain.\nThe channel must already be established between the ibctransfer module on this chain\nand a matching module on the remote chain.\nWe cannot select the port_id, this is whatever the local chain has bound the ibctransfer\nmodule to.", + "type": "named", + "properties": { + "amount": { + "description": "packet data only supports one coin\nhttps://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "value": 2 + }, + "channel_id": { + "description": "existing channel to send the tokens over", + "value": 0 + }, + "memo": { + "description": "An optional memo. See the blog post\n[\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b)\nfor more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently\nignored on older chains.\nIf you need support for both 1.x and 2.x chain with the same codebase,\nit is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer\nprotobuf encoder instead.", + "value": 15 + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "value": 14 + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "value": 0 + } + } + } + } + }, + { + "name": "WasmMsg", + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "type": "enum", + "cases": { + "clear_admin": { + "description": "Clears the admin on the given contract, so no more migration possible.\nFails if this contract is not currently admin of the target contract.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + } + } + }, + "execute": { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "funds": { + "value": 3 + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "value": 8 + } + } + }, + "instantiate": { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThe contract address is non-predictable. But it is guaranteed that\nwhen emitting the same Instantiate message multiple times,\nmultiple instances on different addresses will be generated. See also\nInstantiate2.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L53-L71).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "admin": { + "value": 15 + }, + "code_id": { + "value": 9 + }, + "funds": { + "value": 3 + }, + "label": { + "description": "A human-readable label for the contract.\n\nValid values should:\n- not be empty\n- not be bigger than 128 bytes (or some chain-specific limit)\n- not start / end with whitespace", + "value": 0 + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "value": 8 + } + } + }, + "migrate": { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to\ncustomize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "value": 8 + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "value": 9 + } + } + }, + "update_admin": { + "description": "Sets a new admin (for migrate) on the given contract.\nFails if this contract is not currently admin of the target contract.", + "type": "named", + "properties": { + "admin": { + "value": 0 + }, + "contract_addr": { + "value": 0 + } + } + } + } + }, + { + "name": "VoteOption", + "type": "enum", + "cases": { + "abstain": { + "type": "unit" + }, + "no": { + "type": "unit" + }, + "no_with_veto": { + "type": "unit" + }, + "yes": { + "type": "unit" + } + } + }, + { + "name": "GovMsg", + "description": "This message type allows the contract interact with the [x/gov] module in order\nto cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n```\n# use cosmwasm_std::{\n# HexBinary,\n# Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,\n# Response, QueryResponse,\n# };\n# type ExecuteMsg = ();\nuse cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point]\npub fn execute(\ndeps: DepsMut,\nenv: Env,\ninfo: MessageInfo,\nmsg: ExecuteMsg,\n) -> Result {\n// ...\nOk(Response::new().add_message(GovMsg::Vote {\nproposal_id: 4,\noption: VoteOption::Yes,\n}))\n}\n```\n\nCast a weighted vote:\n\n```\n# use cosmwasm_std::{\n# HexBinary,\n# Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,\n# Response, QueryResponse,\n# };\n# type ExecuteMsg = ();\n# #[cfg(feature = \"cosmwasm_1_2\")]\nuse cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption};\n\n# #[cfg(feature = \"cosmwasm_1_2\")]\n#[entry_point]\npub fn execute(\ndeps: DepsMut,\nenv: Env,\ninfo: MessageInfo,\nmsg: ExecuteMsg,\n) -> Result {\n// ...\nOk(Response::new().add_message(GovMsg::VoteWeighted {\nproposal_id: 4,\noptions: vec![\nWeightedVoteOption {\noption: VoteOption::Yes,\nweight: Decimal::percent(65),\n},\nWeightedVoteOption {\noption: VoteOption::Abstain,\nweight: Decimal::percent(35),\n},\n],\n}))\n}\n```", + "type": "enum", + "cases": { + "vote": { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "named", + "properties": { + "option": { + "description": "The vote option.\n\nThis used to be called \"vote\", but was changed for consistency with Cosmos SDK.", + "value": 18 + }, + "proposal_id": { + "value": 9 + } + } + } + } + }, + { + "name": "CosmosMsg", + "type": "enum", + "cases": { + "bank": { + "type": "tuple", + "items": [ + 4 + ] + }, + "custom": { + "type": "tuple", + "items": [ + 5 + ] + }, + "distribution": { + "type": "tuple", + "items": [ + 7 + ] + }, + "gov": { + "type": "tuple", + "items": [ + 19 + ] + }, + "ibc": { + "type": "tuple", + "items": [ + 16 + ] + }, + "staking": { + "type": "tuple", + "items": [ + 6 + ] + }, + "stargate": { + "description": "This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "named", + "properties": { + "type_url": { + "value": 0 + }, + "value": { + "value": 8 + } + } + }, + "wasm": { + "type": "tuple", + "items": [ + 17 + ] + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 20 + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "check_remote_balance": { + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "send_funds": { + "description": "If you sent funds to this contract, it will attempt to ibc transfer them\nto the account on the remote side of this channel.\nIf we don't have the address yet, this fails.", + "type": "named", + "properties": { + "reflect_channel_id": { + "description": "The channel id we use above to talk with the reflect contract", + "value": 0 + }, + "transfer_channel_id": { + "description": "The channel to use for ibctransfer. This is bound to a different\nport and handled by a different module.\nIt should connect to the same chain as the reflect_channel_id does", + "value": 0 + } + } + }, + "send_msgs": { + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "msgs": { + "value": 21 + } + } + }, + "update_admin": { + "description": "Changes the admin", + "type": "named", + "properties": { + "admin": { + "value": 0 + } + } + } + } + } + ] +} diff --git a/contracts/ibc-reflect-send/schema/cw_schema/raw/instantiate.json b/contracts/ibc-reflect-send/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..96978ebf22 --- /dev/null +++ b/contracts/ibc-reflect-send/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,12 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "description": "This needs no info. Owner of the contract is whoever signed the InstantiateMsg.", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/ibc-reflect-send/schema/cw_schema/raw/query.json b/contracts/ibc-reflect-send/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..a0e19f323a --- /dev/null +++ b/contracts/ibc-reflect-send/schema/cw_schema/raw/query.json @@ -0,0 +1,32 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "account": { + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "admin": { + "type": "named", + "properties": {} + }, + "list_accounts": { + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_account.json b/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_account.json new file mode 100644 index 0000000000..6ec05f3cd5 --- /dev/null +++ b/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_account.json @@ -0,0 +1,64 @@ +{ + "type": "v1", + "root": 6, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 3 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 4 + }, + { + "name": "AccountInfo", + "type": "struct", + "properties": { + "channel_id": { + "value": 0 + }, + "last_update_time": { + "description": "last block balance was updated (0 is never)", + "value": 1 + }, + "remote_addr": { + "description": "in normal cases, it should be set, but there is a delay between binding\nthe channel and making a query and in that time it is empty", + "value": 2 + }, + "remote_balance": { + "value": 5 + } + } + } + ] +} diff --git a/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_admin.json b/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_admin.json new file mode 100644 index 0000000000..4f151112d3 --- /dev/null +++ b/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_admin.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "AdminResponse", + "type": "struct", + "properties": { + "admin": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_list_accounts.json b/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_list_accounts.json new file mode 100644 index 0000000000..d5cbb4a66f --- /dev/null +++ b/contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_list_accounts.json @@ -0,0 +1,78 @@ +{ + "type": "v1", + "root": 8, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 3 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 4 + }, + { + "name": "AccountInfo", + "type": "struct", + "properties": { + "channel_id": { + "value": 0 + }, + "last_update_time": { + "description": "last block balance was updated (0 is never)", + "value": 1 + }, + "remote_addr": { + "description": "in normal cases, it should be set, but there is a delay between binding\nthe channel and making a query and in that time it is empty", + "value": 2 + }, + "remote_balance": { + "value": 5 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 6 + }, + { + "name": "ListAccountsResponse", + "type": "struct", + "properties": { + "accounts": { + "value": 7 + } + } + } + ] +} diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index 6fb821cb7b..62b5b58635 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -909,6 +936,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -931,7 +964,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", ] @@ -953,14 +986,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -970,6 +1020,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1131,6 +1190,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1309,6 +1377,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1426,7 +1514,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1443,6 +1544,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1482,9 +1595,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1511,9 +1624,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1533,15 +1646,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1579,6 +1716,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1597,6 +1740,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.26.2" @@ -1625,6 +1774,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1969,7 +2128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/ibc-reflect/schema/cw_schema/ibc-reflect.json b/contracts/ibc-reflect/schema/cw_schema/ibc-reflect.json new file mode 100644 index 0000000000..785c5a1297 --- /dev/null +++ b/contracts/ibc-reflect/schema/cw_schema/ibc-reflect.json @@ -0,0 +1,186 @@ +{ + "contract_name": "ibc-reflect", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "InstantiateMsg", + "description": "Just needs to know the code_id of a reflect contract to spawn sub-accounts", + "type": "struct", + "properties": { + "reflect_code_id": { + "value": 0 + } + } + } + ] + }, + "execute": { + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint64", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding,\nsuch that the full u64 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n```\n# use cosmwasm_std::Uint64;\nlet a = Uint64::from(42u64);\nassert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32);\nassert_eq!(b.u64(), 70);\n```", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "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": "IbcAcknowledgement", + "type": "struct", + "properties": { + "data": { + "value": 2 + } + } + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "async_ack": { + "type": "named", + "properties": { + "ack": { + "description": "The acknowledgement to send back", + "value": 3 + }, + "channel_id": { + "description": "Existing channel where the packet was received", + "value": 0 + }, + "packet_sequence": { + "description": "Sequence number of the packet that was received", + "value": 1 + } + } + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "account": { + "description": "Returns (reflect) account that is attached to this channel,\nor none.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "list_accounts": { + "description": "Returns all (channel, reflect_account) pairs.\nNo pagination - this is a test contract", + "type": "named", + "properties": {} + } + } + } + ] + }, + "migrate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] + }, + "sudo": null, + "responses": { + "account": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "AccountResponse", + "type": "struct", + "properties": { + "account": { + "value": 1 + } + } + } + ] + }, + "list_accounts": { + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "AccountInfo", + "type": "struct", + "properties": { + "account": { + "value": 0 + }, + "channel_id": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 1 + }, + { + "name": "ListAccountsResponse", + "type": "struct", + "properties": { + "accounts": { + "value": 2 + } + } + } + ] + } + } +} diff --git a/contracts/ibc-reflect/schema/cw_schema/raw/execute.json b/contracts/ibc-reflect/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..ad07d2b974 --- /dev/null +++ b/contracts/ibc-reflect/schema/cw_schema/raw/execute.json @@ -0,0 +1,54 @@ +{ + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint64", + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding,\nsuch that the full u64 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n```\n# use cosmwasm_std::Uint64;\nlet a = Uint64::from(42u64);\nassert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32);\nassert_eq!(b.u64(), 70);\n```", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "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": "IbcAcknowledgement", + "type": "struct", + "properties": { + "data": { + "value": 2 + } + } + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "async_ack": { + "type": "named", + "properties": { + "ack": { + "description": "The acknowledgement to send back", + "value": 3 + }, + "channel_id": { + "description": "Existing channel where the packet was received", + "value": 0 + }, + "packet_sequence": { + "description": "Sequence number of the packet that was received", + "value": 1 + } + } + } + } + } + ] +} diff --git a/contracts/ibc-reflect/schema/cw_schema/raw/instantiate.json b/contracts/ibc-reflect/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..61787c384d --- /dev/null +++ b/contracts/ibc-reflect/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,22 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "InstantiateMsg", + "description": "Just needs to know the code_id of a reflect contract to spawn sub-accounts", + "type": "struct", + "properties": { + "reflect_code_id": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/ibc-reflect/schema/cw_schema/raw/migrate.json b/contracts/ibc-reflect/schema/cw_schema/raw/migrate.json new file mode 100644 index 0000000000..3935d14d40 --- /dev/null +++ b/contracts/ibc-reflect/schema/cw_schema/raw/migrate.json @@ -0,0 +1,12 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/ibc-reflect/schema/cw_schema/raw/query.json b/contracts/ibc-reflect/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..3721b32600 --- /dev/null +++ b/contracts/ibc-reflect/schema/cw_schema/raw/query.json @@ -0,0 +1,30 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "account": { + "description": "Returns (reflect) account that is attached to this channel,\nor none.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "list_accounts": { + "description": "Returns all (channel, reflect_account) pairs.\nNo pagination - this is a test contract", + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/ibc-reflect/schema/cw_schema/raw/response_to_account.json b/contracts/ibc-reflect/schema/cw_schema/raw/response_to_account.json new file mode 100644 index 0000000000..f768e471f6 --- /dev/null +++ b/contracts/ibc-reflect/schema/cw_schema/raw/response_to_account.json @@ -0,0 +1,24 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "AccountResponse", + "type": "struct", + "properties": { + "account": { + "value": 1 + } + } + } + ] +} diff --git a/contracts/ibc-reflect/schema/cw_schema/raw/response_to_list_accounts.json b/contracts/ibc-reflect/schema/cw_schema/raw/response_to_list_accounts.json new file mode 100644 index 0000000000..5eaed341f9 --- /dev/null +++ b/contracts/ibc-reflect/schema/cw_schema/raw/response_to_list_accounts.json @@ -0,0 +1,36 @@ +{ + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "AccountInfo", + "type": "struct", + "properties": { + "account": { + "value": 0 + }, + "channel_id": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 1 + }, + { + "name": "ListAccountsResponse", + "type": "struct", + "properties": { + "accounts": { + "value": 2 + } + } + } + ] +} diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index e386207992..f58613a3eb 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -909,6 +936,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -942,14 +975,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -959,6 +1009,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1120,6 +1179,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1232,7 +1300,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", ] @@ -1309,6 +1377,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1426,7 +1514,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1443,6 +1544,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1482,9 +1595,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1511,9 +1624,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1533,15 +1646,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1579,6 +1716,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1597,6 +1740,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.26.2" @@ -1625,6 +1774,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1969,7 +2128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/queue/schema/cw_schema/queue.json b/contracts/queue/schema/cw_schema/queue.json new file mode 100644 index 0000000000..1031124733 --- /dev/null +++ b/contracts/queue/schema/cw_schema/queue.json @@ -0,0 +1,226 @@ +{ + "contract_name": "queue", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "type": "struct", + "properties": {} + } + ] + }, + "execute": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "i32", + "type": "integer", + "precision": 32, + "signed": true + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "dequeue": { + "type": "named", + "properties": {} + }, + "enqueue": { + "type": "named", + "properties": { + "value": { + "value": 0 + } + } + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "count": { + "type": "named", + "properties": {} + }, + "list": { + "type": "named", + "properties": {} + }, + "open_iterators": { + "description": "Opens the given number of iterators for no reason other than testing.\nReturns and `Empty` response.", + "type": "named", + "properties": { + "count": { + "value": 0 + } + } + }, + "reducer": { + "type": "named", + "properties": {} + }, + "sum": { + "type": "named", + "properties": {} + } + } + } + ] + }, + "migrate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "MigrateMsg", + "type": "struct", + "properties": {} + } + ] + }, + "sudo": null, + "responses": { + "count": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "CountResponse", + "type": "struct", + "properties": { + "count": { + "value": 0 + } + } + } + ] + }, + "list": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "ListResponse", + "type": "struct", + "properties": { + "early": { + "description": "List all IDs lower than 0x20", + "value": 1 + }, + "empty": { + "description": "List an empty range, both bounded", + "value": 1 + }, + "late": { + "description": "List all IDs starting from 0x20", + "value": 1 + } + } + } + ] + }, + "open_iterators": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] + }, + "reducer": { + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "i32", + "type": "integer", + "precision": 32, + "signed": true + }, + { + "name": "(i32, i32)", + "type": "tuple", + "items": [ + 0, + 0 + ] + }, + { + "name": "alloc::vec::Vec<(i32, i32)>", + "type": "array", + "items": 1 + }, + { + "name": "ReducerResponse", + "type": "struct", + "properties": { + "counters": { + "value": 2 + } + } + } + ] + }, + "sum": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "i32", + "type": "integer", + "precision": 32, + "signed": true + }, + { + "name": "SumResponse", + "type": "struct", + "properties": { + "sum": { + "value": 0 + } + } + } + ] + } + } +} diff --git a/contracts/queue/schema/cw_schema/raw/execute.json b/contracts/queue/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..3ec08d4bd5 --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/execute.json @@ -0,0 +1,30 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "i32", + "type": "integer", + "precision": 32, + "signed": true + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "dequeue": { + "type": "named", + "properties": {} + }, + "enqueue": { + "type": "named", + "properties": { + "value": { + "value": 0 + } + } + } + } + } + ] +} diff --git a/contracts/queue/schema/cw_schema/raw/instantiate.json b/contracts/queue/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..9fc37502e9 --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,11 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/queue/schema/cw_schema/raw/migrate.json b/contracts/queue/schema/cw_schema/raw/migrate.json new file mode 100644 index 0000000000..8e750fe84e --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/migrate.json @@ -0,0 +1,11 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "MigrateMsg", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/queue/schema/cw_schema/raw/query.json b/contracts/queue/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..deb71025a9 --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/query.json @@ -0,0 +1,43 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "count": { + "type": "named", + "properties": {} + }, + "list": { + "type": "named", + "properties": {} + }, + "open_iterators": { + "description": "Opens the given number of iterators for no reason other than testing.\nReturns and `Empty` response.", + "type": "named", + "properties": { + "count": { + "value": 0 + } + } + }, + "reducer": { + "type": "named", + "properties": {} + }, + "sum": { + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/queue/schema/cw_schema/raw/response_to_count.json b/contracts/queue/schema/cw_schema/raw/response_to_count.json new file mode 100644 index 0000000000..a1b3d6f806 --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/response_to_count.json @@ -0,0 +1,21 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "CountResponse", + "type": "struct", + "properties": { + "count": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/queue/schema/cw_schema/raw/response_to_list.json b/contracts/queue/schema/cw_schema/raw/response_to_list.json new file mode 100644 index 0000000000..410dd47870 --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/response_to_list.json @@ -0,0 +1,35 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "ListResponse", + "type": "struct", + "properties": { + "early": { + "description": "List all IDs lower than 0x20", + "value": 1 + }, + "empty": { + "description": "List an empty range, both bounded", + "value": 1 + }, + "late": { + "description": "List all IDs starting from 0x20", + "value": 1 + } + } + } + ] +} diff --git a/contracts/queue/schema/cw_schema/raw/response_to_open_iterators.json b/contracts/queue/schema/cw_schema/raw/response_to_open_iterators.json new file mode 100644 index 0000000000..3935d14d40 --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/response_to_open_iterators.json @@ -0,0 +1,12 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "Empty", + "description": "An empty struct that serves as a placeholder in different places,\nsuch as contracts that don't set a custom message.\n\nIt is designed to be expressible in correct JSON and JSON Schema but\ncontains no meaningful data. Previously we used enums without cases,\nbut those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/queue/schema/cw_schema/raw/response_to_reducer.json b/contracts/queue/schema/cw_schema/raw/response_to_reducer.json new file mode 100644 index 0000000000..2cddf6d4cd --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/response_to_reducer.json @@ -0,0 +1,34 @@ +{ + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "i32", + "type": "integer", + "precision": 32, + "signed": true + }, + { + "name": "(i32, i32)", + "type": "tuple", + "items": [ + 0, + 0 + ] + }, + { + "name": "alloc::vec::Vec<(i32, i32)>", + "type": "array", + "items": 1 + }, + { + "name": "ReducerResponse", + "type": "struct", + "properties": { + "counters": { + "value": 2 + } + } + } + ] +} diff --git a/contracts/queue/schema/cw_schema/raw/response_to_sum.json b/contracts/queue/schema/cw_schema/raw/response_to_sum.json new file mode 100644 index 0000000000..645e15e15e --- /dev/null +++ b/contracts/queue/schema/cw_schema/raw/response_to_sum.json @@ -0,0 +1,21 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "i32", + "type": "integer", + "precision": 32, + "signed": true + }, + { + "name": "SumResponse", + "type": "struct", + "properties": { + "sum": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 939275d00c..2af6135c14 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -909,6 +936,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -942,14 +975,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -959,6 +1009,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1120,6 +1179,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1291,13 +1359,33 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "reflect" version = "0.0.0" @@ -1305,7 +1393,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", "thiserror", ] @@ -1427,7 +1515,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1444,6 +1545,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1483,9 +1596,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1512,9 +1625,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1534,15 +1647,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1580,6 +1717,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1598,6 +1741,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.26.2" @@ -1626,6 +1775,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1970,7 +2129,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/reflect/schema/cw_schema/raw/execute.json b/contracts/reflect/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..ff31ffa3aa --- /dev/null +++ b/contracts/reflect/schema/cw_schema/raw/execute.json @@ -0,0 +1,731 @@ +{ + "type": "v1", + "root": 33, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 1 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + }, + { + "name": "BankMsg", + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "type": "enum", + "cases": { + "burn": { + "description": "This will burn the given coins from the contract's account.\nThere is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper.\nImportant if a contract controls significant token supply that must be retired.", + "type": "named", + "properties": { + "amount": { + "value": 3 + } + } + }, + "send": { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28).\n`from_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 3 + }, + "to_address": { + "value": 0 + } + } + } + } + }, + { + "name": "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": "CustomMsg", + "description": "CustomMsg is an override of CosmosMsg::Custom to show this works and can be extended in the contract", + "type": "enum", + "cases": { + "debug": { + "type": "tuple", + "items": [ + 0 + ] + }, + "raw": { + "type": "tuple", + "items": [ + 5 + ] + } + } + }, + { + "name": "StakingMsg", + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "type": "enum", + "cases": { + "delegate": { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "validator": { + "value": 0 + } + } + }, + "redelegate": { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "dst_validator": { + "value": 0 + }, + "src_validator": { + "value": 0 + } + } + }, + "undelegate": { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "validator": { + "value": 0 + } + } + } + } + }, + { + "name": "DistributionMsg", + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "type": "enum", + "cases": { + "fund_community_pool": { + "description": "This is translated to a [[MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2).\n`depositor` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "description": "The amount to spend", + "value": 3 + } + } + }, + "set_withdraw_address": { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "address": { + "description": "The `withdraw_address`", + "value": 0 + } + } + }, + "withdraw_delegator_reward": { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "validator": { + "description": "The `validator_address`", + "value": 0 + } + } + } + } + }, + { + "name": "AnyMsg", + "description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto).\nThis is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "struct", + "properties": { + "type_url": { + "value": 0 + }, + "value": { + "value": 5 + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "IbcTimeoutBlock", + "description": "IBCTimeoutHeight Height is a monotonically increasing data type\nthat can be compared against another Height for the purposes of updating and\nfreezing clients.\nOrdering is (revision_number, timeout_height)", + "type": "struct", + "properties": { + "height": { + "description": "block height after which the packet times out.\nthe height within the given revision", + "value": 10 + }, + "revision": { + "description": "the version that the client is currently on\n(e.g. after resetting the chain this could increment 1 as height drops to 0)", + "value": 10 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 11 + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 13 + }, + { + "name": "IbcTimeout", + "description": "In IBC each package must set at least one type of timeout:\nthe timestamp or the block height. Using this rather complex enum instead of\ntwo timeout fields we ensure that at least one timeout is set.", + "type": "struct", + "properties": { + "block": { + "value": 12 + }, + "timestamp": { + "value": 14 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "IbcAcknowledgement", + "type": "struct", + "properties": { + "data": { + "value": 5 + } + } + }, + { + "name": "IbcFee", + "type": "struct", + "properties": { + "ack_fee": { + "value": 3 + }, + "receive_fee": { + "value": 3 + }, + "timeout_fee": { + "value": 3 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "IbcMsg", + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts\n(contracts that directly speak the IBC protocol via 6 entry points)", + "type": "enum", + "cases": { + "close_channel": { + "description": "This will close an existing channel that is owned by this contract.\nPort is auto-assigned to the contract's IBC port", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "pay_packet_fee": { + "description": "Incentivizes the next IBC packet sent after this message with a fee.\nNote that this does not necessarily have to be a packet sent by this contract.\nThe fees are taken from the contract's balance immediately and locked until the packet is handled.\n\n# Example\n\nMost commonly, you will attach this message to a response right before sending a packet using\n[`IbcMsg::SendPacket`] or [`IbcMsg::Transfer`].\n\n```rust\n# use cosmwasm_std::{IbcMsg, IbcEndpoint, IbcFee, IbcTimeout, Coin, coins, CosmosMsg, Response, Timestamp};\n\nlet incentivize = IbcMsg::PayPacketFee {\nport_id: \"transfer\".to_string(),\nchannel_id: \"source-channel\".to_string(),\nfee: IbcFee {\nreceive_fee: coins(100, \"token\"),\nack_fee: coins(201, \"token\"),\ntimeout_fee: coins(200, \"token\"),\n},\nrelayers: vec![],\n};\nlet transfer = IbcMsg::Transfer {\nchannel_id: \"source-channel\".to_string(),\nto_address: \"receiver\".to_string(),\namount: Coin::new(100u32, \"token\"),\ntimeout: IbcTimeout::with_timestamp(Timestamp::from_nanos(0)),\nmemo: None,\n};\n\n# #[cfg(feature = \"stargate\")]\nlet _: Response = Response::new()\n.add_message(CosmosMsg::Ibc(incentivize))\n.add_message(CosmosMsg::Ibc(transfer));\n```", + "type": "named", + "properties": { + "channel_id": { + "description": "The channel id on the chain where the packet is sent from (this chain).", + "value": 0 + }, + "fee": { + "value": 18 + }, + "port_id": { + "description": "The port id on the chain where the packet is sent from (this chain).", + "value": 0 + }, + "relayers": { + "description": "Allowlist of relayer addresses that can receive the fee.\nAn empty list means that any relayer can receive the fee.\n\nThis is currently not implemented and *must* be empty.", + "value": 19 + } + } + }, + "pay_packet_fee_async": { + "description": "Incentivizes the existing IBC packet with the given port, channel and sequence with a fee.\nNote that this does not necessarily have to be a packet sent by this contract.\nThe fees are taken from the contract's balance immediately and locked until the packet is handled.\nThey are added to the existing fees on the packet.", + "type": "named", + "properties": { + "channel_id": { + "description": "The channel id on the chain where the packet is sent from (this chain).", + "value": 0 + }, + "fee": { + "value": 18 + }, + "port_id": { + "description": "The port id on the chain where the packet is sent from (this chain).", + "value": 0 + }, + "relayers": { + "description": "Allowlist of relayer addresses that can receive the fee.\nAn empty list means that any relayer can receive the fee.\n\nThis is currently not implemented and *must* be empty.", + "value": 19 + }, + "sequence": { + "description": "The sequence number of the packet that should be incentivized.", + "value": 10 + } + } + }, + "send_packet": { + "description": "Sends an IBC packet with given data over the existing channel.\nData should be encoded in a format defined by the channel version,\nand the module on the other side should know how to parse this.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "data": { + "value": 5 + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "value": 15 + } + } + }, + "transfer": { + "description": "Sends bank tokens owned by the contract to the given address on another chain.\nThe channel must already be established between the ibctransfer module on this chain\nand a matching module on the remote chain.\nWe cannot select the port_id, this is whatever the local chain has bound the ibctransfer\nmodule to.", + "type": "named", + "properties": { + "amount": { + "description": "packet data only supports one coin\nhttps://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "value": 2 + }, + "channel_id": { + "description": "existing channel to send the tokens over", + "value": 0 + }, + "memo": { + "description": "An optional memo. See the blog post\n[\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b)\nfor more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently\nignored on older chains.\nIf you need support for both 1.x and 2.x chain with the same codebase,\nit is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer\nprotobuf encoder instead.", + "value": 16 + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "value": 15 + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "value": 0 + } + } + }, + "write_acknowledgement": { + "description": "Acknowledges a packet that this contract received over IBC.\nThis allows acknowledging a packet that was not acknowledged yet in the `ibc_packet_receive` call.", + "type": "named", + "properties": { + "ack": { + "description": "The acknowledgement to send back", + "value": 17 + }, + "channel_id": { + "description": "Existing channel where the packet was received", + "value": 0 + }, + "packet_sequence": { + "description": "Sequence number of the packet that was received", + "value": 10 + } + } + } + } + }, + { + "name": "WasmMsg", + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "type": "enum", + "cases": { + "clear_admin": { + "description": "Clears the admin on the given contract, so no more migration possible.\nFails if this contract is not currently admin of the target contract.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + } + } + }, + "execute": { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "funds": { + "value": 3 + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "value": 5 + } + } + }, + "instantiate": { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThe contract address is non-predictable. But it is guaranteed that\nwhen emitting the same Instantiate message multiple times,\nmultiple instances on different addresses will be generated. See also\nInstantiate2.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L53-L71).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "admin": { + "value": 16 + }, + "code_id": { + "value": 10 + }, + "funds": { + "value": 3 + }, + "label": { + "description": "A human-readable label for the contract.\n\nValid values should:\n- not be empty\n- not be bigger than 128 bytes (or some chain-specific limit)\n- not start / end with whitespace", + "value": 0 + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "value": 5 + } + } + }, + "instantiate2": { + "description": "Instantiates a new contracts from previously uploaded Wasm code\nusing a predictable address derivation algorithm implemented in\n[`cosmwasm_std::instantiate2_address`].\n\nThis is translated to a [MsgInstantiateContract2](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L73-L96).\n`sender` is automatically filled with the current contract's address.\n`fix_msg` is automatically set to false.", + "type": "named", + "properties": { + "admin": { + "value": 16 + }, + "code_id": { + "value": 10 + }, + "funds": { + "value": 3 + }, + "label": { + "description": "A human-readable label for the contract.\n\nValid values should:\n- not be empty\n- not be bigger than 128 bytes (or some chain-specific limit)\n- not start / end with whitespace", + "value": 0 + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "value": 5 + }, + "salt": { + "value": 5 + } + } + }, + "migrate": { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to\ncustomize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "value": 5 + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "value": 10 + } + } + }, + "update_admin": { + "description": "Sets a new admin (for migrate) on the given contract.\nFails if this contract is not currently admin of the target contract.", + "type": "named", + "properties": { + "admin": { + "value": 0 + }, + "contract_addr": { + "value": 0 + } + } + } + } + }, + { + "name": "VoteOption", + "type": "enum", + "cases": { + "abstain": { + "type": "unit" + }, + "no": { + "type": "unit" + }, + "no_with_veto": { + "type": "unit" + }, + "yes": { + "type": "unit" + } + } + }, + { + "name": "Decimal", + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "decimal", + "precision": 128, + "signed": false + }, + { + "name": "WeightedVoteOption", + "type": "struct", + "properties": { + "option": { + "value": 22 + }, + "weight": { + "value": 23 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 24 + }, + { + "name": "GovMsg", + "description": "This message type allows the contract interact with the [x/gov] module in order\nto cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n```\n# use cosmwasm_std::{\n# HexBinary,\n# Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,\n# Response, QueryResponse,\n# };\n# type ExecuteMsg = ();\nuse cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point]\npub fn execute(\ndeps: DepsMut,\nenv: Env,\ninfo: MessageInfo,\nmsg: ExecuteMsg,\n) -> Result {\n// ...\nOk(Response::new().add_message(GovMsg::Vote {\nproposal_id: 4,\noption: VoteOption::Yes,\n}))\n}\n```\n\nCast a weighted vote:\n\n```\n# use cosmwasm_std::{\n# HexBinary,\n# Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,\n# Response, QueryResponse,\n# };\n# type ExecuteMsg = ();\n# #[cfg(feature = \"cosmwasm_1_2\")]\nuse cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption};\n\n# #[cfg(feature = \"cosmwasm_1_2\")]\n#[entry_point]\npub fn execute(\ndeps: DepsMut,\nenv: Env,\ninfo: MessageInfo,\nmsg: ExecuteMsg,\n) -> Result {\n// ...\nOk(Response::new().add_message(GovMsg::VoteWeighted {\nproposal_id: 4,\noptions: vec![\nWeightedVoteOption {\noption: VoteOption::Yes,\nweight: Decimal::percent(65),\n},\nWeightedVoteOption {\noption: VoteOption::Abstain,\nweight: Decimal::percent(35),\n},\n],\n}))\n}\n```", + "type": "enum", + "cases": { + "vote": { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "named", + "properties": { + "option": { + "description": "The vote option.\n\nThis used to be called \"vote\", but was changed for consistency with Cosmos SDK.", + "value": 22 + }, + "proposal_id": { + "value": 10 + } + } + }, + "vote_weighted": { + "description": "This maps directly to [MsgVoteWeighted](https://github.com/cosmos/cosmos-sdk/blob/v0.45.8/proto/cosmos/gov/v1beta1/tx.proto#L66-L78) in the Cosmos SDK with voter set to the contract address.", + "type": "named", + "properties": { + "options": { + "value": 25 + }, + "proposal_id": { + "value": 10 + } + } + } + } + }, + { + "name": "CosmosMsg", + "type": "enum", + "cases": { + "any": { + "description": "`CosmosMsg::Any` is the replaces the \"stargate message\" – a message wrapped\nin a [protobuf Any](https://protobuf.dev/programming-guides/proto3/#any)\nthat is supported by the chain. It behaves the same as\n`CosmosMsg::Stargate` but has a better name and slightly improved syntax.\n\nThis is feature-gated at compile time with `cosmwasm_2_0` because\na chain running CosmWasm < 2.0 cannot process this.", + "type": "tuple", + "items": [ + 9 + ] + }, + "bank": { + "type": "tuple", + "items": [ + 4 + ] + }, + "custom": { + "type": "tuple", + "items": [ + 6 + ] + }, + "distribution": { + "type": "tuple", + "items": [ + 8 + ] + }, + "gov": { + "type": "tuple", + "items": [ + 26 + ] + }, + "ibc": { + "type": "tuple", + "items": [ + 20 + ] + }, + "staking": { + "type": "tuple", + "items": [ + 7 + ] + }, + "stargate": { + "description": "This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "named", + "properties": { + "type_url": { + "value": 0 + }, + "value": { + "value": 5 + } + } + }, + "wasm": { + "type": "tuple", + "items": [ + 21 + ] + } + } + }, + { + "name": "alloc::vec::Vec>", + "type": "array", + "items": 27 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 10 + }, + { + "name": "ReplyOn", + "description": "Use this to define when the contract gets a response callback.\nIf you only need it for errors or success you can select just those in order\nto save gas.", + "type": "enum", + "cases": { + "always": { + "description": "Always perform a callback after SubMsg is processed", + "type": "unit" + }, + "error": { + "description": "Only callback if SubMsg returned an error, no callback on success case", + "type": "unit" + }, + "never": { + "description": "Never make a callback - this is like the original CosmosMsg semantics", + "type": "unit" + }, + "success": { + "description": "Only callback if SubMsg was successful, no callback on error case", + "type": "unit" + } + } + }, + { + "name": "SubMsg", + "description": "A submessage that will guarantee a `reply` call on success or error, depending on\nthe `reply_on` setting. If you do not need to process the result, use regular messages instead.\n\nNote: On error the submessage execution will revert any partial state changes due to this message,\nbut not revert any state changes in the calling contract. If this is required, it must be done\nmanually in the `reply` entry point.", + "type": "struct", + "properties": { + "gas_limit": { + "description": "Gas limit measured in [Cosmos SDK gas](https://github.com/CosmWasm/cosmwasm/blob/main/docs/GAS.md).\n\nSetting this to `None` means unlimited. Then the submessage execution can consume all gas of the\ncurrent execution context.", + "value": 29 + }, + "id": { + "description": "An arbitrary ID chosen by the contract.\nThis is typically used to match `Reply`s in the `reply` entry point to the submessage.", + "value": 10 + }, + "msg": { + "value": 27 + }, + "payload": { + "description": "Some arbitrary data that the contract can set in an application specific way.\nThis is just passed into the `reply` entry point and is not stored to state.\nAny encoding can be used. If `id` is used to identify a particular action,\nthe encoding can also be different for each of those actions since you can match `id`\nfirst and then start processing the `payload`.\n\nThe environment restricts the length of this field in order to avoid abuse. The limit\nis environment specific and can change over time. The initial default is 128 KiB.\n\nUnset/nil/null cannot be differentiated from empty data.\n\nOn chains running CosmWasm 1.x this field will be ignored.", + "value": 5 + }, + "reply_on": { + "value": 30 + } + } + }, + { + "name": "alloc::vec::Vec>", + "type": "array", + "items": 31 + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "change_owner": { + "type": "named", + "properties": { + "owner": { + "value": 0 + } + } + }, + "reflect_msg": { + "type": "named", + "properties": { + "msgs": { + "value": 28 + } + } + }, + "reflect_sub_msg": { + "type": "named", + "properties": { + "msgs": { + "value": 32 + } + } + } + } + } + ] +} diff --git a/contracts/reflect/schema/cw_schema/raw/instantiate.json b/contracts/reflect/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..9fc37502e9 --- /dev/null +++ b/contracts/reflect/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,11 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/reflect/schema/cw_schema/raw/query.json b/contracts/reflect/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..51f19f0484 --- /dev/null +++ b/contracts/reflect/schema/cw_schema/raw/query.json @@ -0,0 +1,448 @@ +{ + "type": "v1", + "root": 17, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "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": "core::option::Option", + "type": "optional", + "inner": 1 + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "bool", + "type": "boolean" + }, + { + "name": "PageRequest", + "description": "Simplified version of the PageRequest type for pagination from the cosmos-sdk", + "type": "struct", + "properties": { + "key": { + "value": 2 + }, + "limit": { + "value": 3 + }, + "reverse": { + "value": 4 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 5 + }, + { + "name": "BankQuery", + "type": "enum", + "cases": { + "all_balances": { + "description": "This calls into the native bank module for all denominations.\nNote that this may be much more expensive than Balance and should be avoided if possible.\nReturn value is AllBalanceResponse.", + "type": "named", + "properties": { + "address": { + "value": 0 + } + } + }, + "all_denom_metadata": { + "description": "This calls into the native bank module for querying metadata for all bank tokens that have a metadata entry.\nReturn value is AllDenomMetadataResponse", + "type": "named", + "properties": { + "pagination": { + "value": 6 + } + } + }, + "balance": { + "description": "This calls into the native bank module for one denomination\nReturn value is BalanceResponse", + "type": "named", + "properties": { + "address": { + "value": 0 + }, + "denom": { + "value": 0 + } + } + }, + "denom_metadata": { + "description": "This calls into the native bank module for querying metadata for a specific bank token.\nReturn value is DenomMetadataResponse", + "type": "named", + "properties": { + "denom": { + "value": 0 + } + } + }, + "supply": { + "description": "This calls into the native bank module for querying the total supply of one denomination.\nIt does the same as the SupplyOf call in Cosmos SDK's RPC API.\nReturn value is of type SupplyResponse.", + "type": "named", + "properties": { + "denom": { + "value": 0 + } + } + } + } + }, + { + "name": "SpecialQuery", + "description": "An implementation of QueryRequest::Custom to show this works and can be extended in the contract", + "type": "enum", + "cases": { + "capitalized": { + "type": "named", + "properties": { + "text": { + "value": 0 + } + } + }, + "ping": { + "type": "named", + "properties": {} + } + } + }, + { + "name": "StakingQuery", + "type": "enum", + "cases": { + "all_delegations": { + "description": "AllDelegations will return all delegations by the delegator", + "type": "named", + "properties": { + "delegator": { + "value": 0 + } + } + }, + "all_validators": { + "description": "Returns all validators in the currently active validator set.\n\nThe query response type is `AllValidatorsResponse`.", + "type": "named", + "properties": {} + }, + "bonded_denom": { + "description": "Returns the denomination that can be bonded (if there are multiple native tokens on the chain)", + "type": "named", + "properties": {} + }, + "delegation": { + "description": "Delegation will return more detailed info on a particular\ndelegation, defined by delegator/validator pair", + "type": "named", + "properties": { + "delegator": { + "value": 0 + }, + "validator": { + "value": 0 + } + } + }, + "validator": { + "description": "Returns the validator at the given address. Returns None if the validator is\nnot part of the currently active validator set.\n\nThe query response type is `ValidatorResponse`.", + "type": "named", + "properties": { + "address": { + "description": "The validator's address (e.g. (e.g. cosmosvaloper1...))", + "value": 0 + } + } + } + } + }, + { + "name": "DistributionQuery", + "type": "enum", + "cases": { + "delegation_rewards": { + "description": "See ", + "type": "named", + "properties": { + "delegator_address": { + "value": 0 + }, + "validator_address": { + "value": 0 + } + } + }, + "delegation_total_rewards": { + "description": "See ", + "type": "named", + "properties": { + "delegator_address": { + "value": 0 + } + } + }, + "delegator_validators": { + "description": "See ", + "type": "named", + "properties": { + "delegator_address": { + "value": 0 + } + } + }, + "delegator_withdraw_address": { + "description": "See ", + "type": "named", + "properties": { + "delegator_address": { + "value": 0 + } + } + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "IbcQuery", + "description": "These are queries to the various IBC modules to see the state of the contract's\nIBC connection.\nMost of these will return errors if the contract is not \"ibc enabled\".", + "type": "enum", + "cases": { + "channel": { + "description": "Lists all information for a (portID, channelID) pair.\nIf port_id is omitted, it will default to the contract's own channel.\n(To save a PortId{} call)\n\nReturns a `ChannelResponse`.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "port_id": { + "value": 11 + } + } + }, + "fee_enabled_channel": { + "description": "Queries whether the given channel supports IBC fees.\nIf port_id is omitted, it will default to the contract's own channel.\n(To save a PortId{} call)\n\nReturns a `FeeEnabledChannelResponse`.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "port_id": { + "value": 11 + } + } + }, + "list_channels": { + "description": "Lists all channels that are bound to a given port.\nIf `port_id` is omitted, this list all channels bound to the contract's port.\n\nReturns a `ListChannelsResponse`.", + "type": "named", + "properties": { + "port_id": { + "value": 11 + } + } + }, + "port_id": { + "description": "Gets the Port ID the current contract is bound to.\n\nReturns a `PortIdResponse`.", + "type": "named", + "properties": {} + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "WasmQuery", + "type": "enum", + "cases": { + "code_info": { + "description": "Returns a [`CodeInfoResponse`] with metadata of the code", + "type": "named", + "properties": { + "code_id": { + "value": 13 + } + } + }, + "contract_info": { + "description": "Returns a [`ContractInfoResponse`] with metadata on the contract from the runtime", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + } + } + }, + "raw": { + "description": "this queries the raw kv-store of the contract.\nreturns the raw, unparsed data stored at that key, which may be an empty vector if not present", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "key": { + "description": "Key is the raw key used in the contracts Storage", + "value": 1 + } + } + }, + "smart": { + "description": "this queries the public API of another contract at a known address (with known ABI)\nReturn value is whatever the contract returns (caller should know), wrapped in a\nContractResult that is JSON encoded.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "msg": { + "description": "msg is the json-encoded QueryMsg struct", + "value": 1 + } + } + } + } + }, + { + "name": "GrpcQuery", + "description": "Queries the chain using a grpc query.\nThis allows to query information that is not exposed in our API.\nThe chain needs to allowlist the supported queries.\nThe drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.\nBecause of this, using it with the [`query`](crate::QuerierWrapper::query) function will result\nin a deserialization error.\nUse [`raw_query`](crate::Querier::raw_query) or [`query_grpc`](crate::QuerierWrapper::query_grpc)\ninstead.\n\nTo find the path, as well as the request and response types,\nyou can query the chain's gRPC endpoint using a tool like\n[grpcurl](https://github.com/fullstorydev/grpcurl).", + "type": "struct", + "properties": { + "data": { + "description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded", + "value": 1 + }, + "path": { + "description": "The fully qualified endpoint path used for routing.\nIt follows the format `/service_path/method_name`,\neg. \"/cosmos.authz.v1beta1.Query/Grants\"", + "value": 0 + } + } + }, + { + "name": "QueryRequest", + "type": "enum", + "cases": { + "bank": { + "type": "tuple", + "items": [ + 7 + ] + }, + "custom": { + "type": "tuple", + "items": [ + 8 + ] + }, + "distribution": { + "type": "tuple", + "items": [ + 10 + ] + }, + "grpc": { + "type": "tuple", + "items": [ + 15 + ] + }, + "ibc": { + "type": "tuple", + "items": [ + 12 + ] + }, + "staking": { + "type": "tuple", + "items": [ + 9 + ] + }, + "stargate": { + "description": "A Stargate query is encoded the same way as abci_query, with path and protobuf encoded request data.\nThe format is defined in [ADR-21](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-021-protobuf-query-encoding.md).\nThe response is protobuf encoded data directly without a JSON response wrapper.\nThe caller is responsible for compiling the proper protobuf definitions for both requests and responses.", + "type": "named", + "properties": { + "data": { + "description": "this is the expected protobuf message type (not any), binary encoded", + "value": 1 + }, + "path": { + "description": "this is the fully qualified service path used for routing,\neg. \"/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", + "value": 0 + } + } + }, + "wasm": { + "type": "tuple", + "items": [ + 14 + ] + } + } + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "capitalized": { + "description": "This will call out to SpecialQuery::Capitalized", + "type": "named", + "properties": { + "text": { + "value": 0 + } + } + }, + "chain": { + "description": "Queries the blockchain and returns the result untouched", + "type": "named", + "properties": { + "request": { + "value": 16 + } + } + }, + "owner": { + "type": "named", + "properties": {} + }, + "raw": { + "description": "Queries another contract and returns the data", + "type": "named", + "properties": { + "contract": { + "value": 0 + }, + "key": { + "value": 1 + } + } + }, + "sub_msg_result": { + "description": "If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply", + "type": "named", + "properties": { + "id": { + "value": 13 + } + } + } + } + } + ] +} diff --git a/contracts/reflect/schema/cw_schema/raw/response_to_capitalized.json b/contracts/reflect/schema/cw_schema/raw/response_to_capitalized.json new file mode 100644 index 0000000000..f64eb61313 --- /dev/null +++ b/contracts/reflect/schema/cw_schema/raw/response_to_capitalized.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "CapitalizedResponse", + "type": "struct", + "properties": { + "text": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/reflect/schema/cw_schema/raw/response_to_chain.json b/contracts/reflect/schema/cw_schema/raw/response_to_chain.json new file mode 100644 index 0000000000..200298854d --- /dev/null +++ b/contracts/reflect/schema/cw_schema/raw/response_to_chain.json @@ -0,0 +1,20 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "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": "ChainResponse", + "type": "struct", + "properties": { + "data": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/reflect/schema/cw_schema/raw/response_to_owner.json b/contracts/reflect/schema/cw_schema/raw/response_to_owner.json new file mode 100644 index 0000000000..3d65874a98 --- /dev/null +++ b/contracts/reflect/schema/cw_schema/raw/response_to_owner.json @@ -0,0 +1,19 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "OwnerResponse", + "type": "struct", + "properties": { + "owner": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/reflect/schema/cw_schema/raw/response_to_raw.json b/contracts/reflect/schema/cw_schema/raw/response_to_raw.json new file mode 100644 index 0000000000..604939fa41 --- /dev/null +++ b/contracts/reflect/schema/cw_schema/raw/response_to_raw.json @@ -0,0 +1,21 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "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": "RawResponse", + "type": "struct", + "properties": { + "data": { + "description": "The returned value of the raw query. Empty data can be the\nresult of a non-existent key or an empty value. We cannot\ndifferentiate those two cases in cross contract queries.", + "value": 0 + } + } + } + ] +} diff --git a/contracts/reflect/schema/cw_schema/raw/response_to_sub_msg_result.json b/contracts/reflect/schema/cw_schema/raw/response_to_sub_msg_result.json new file mode 100644 index 0000000000..2983f79ff7 --- /dev/null +++ b/contracts/reflect/schema/cw_schema/raw/response_to_sub_msg_result.json @@ -0,0 +1,140 @@ +{ + "type": "v1", + "root": 12, + "definitions": [ + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "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": "String", + "type": "string" + }, + { + "name": "Attribute", + "description": "An key value pair that is used in the context of event attributes in logs", + "type": "struct", + "properties": { + "key": { + "value": 2 + }, + "value": { + "value": 2 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "Event", + "description": "A full [*Cosmos SDK* event].\n\nThis version uses string attributes (similar to [*Cosmos SDK* StringEvent]),\nwhich then get magically converted to bytes for Tendermint somewhere between\nthe Rust-Go interface, JSON deserialization and the `NewEvent` call in Cosmos SDK.\n\n[*Cosmos SDK* event]: https://docs.cosmos.network/main/learn/advanced/events\n[*Cosmos SDK* StringEvent]: https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/base/abci/v1beta1/abci.proto#L56-L70", + "type": "struct", + "properties": { + "attributes": { + "description": "The attributes to be included in the event.\n\nYou can learn more about these from [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/main/learn/advanced/events", + "value": 4 + }, + "type": { + "description": "The event type. This is renamed to \"ty\" because \"type\" is reserved in Rust. This sucks, we know.", + "value": 2 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 5 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 1 + }, + { + "name": "MsgResponse", + "type": "struct", + "properties": { + "type_url": { + "value": 2 + }, + "value": { + "value": 1 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 8 + }, + { + "name": "SubMsgResponse", + "description": "The information we get back from a successful sub message execution,\nwith full Cosmos SDK events.", + "type": "struct", + "properties": { + "data": { + "value": 7 + }, + "events": { + "value": 6 + }, + "msg_responses": { + "description": "The responses from the messages emitted by the submessage.\nIn most cases, this is equivalent to the Cosmos SDK's [MsgResponses], which usually contains a [single message].\nHowever, wasmd allows chains to translate a single contract message into multiple SDK messages.\nIn that case all the MsgResponses from each are concatenated into this flattened `Vec`.\n\n[MsgResponses]: https://github.com/cosmos/cosmos-sdk/blob/316750cc8cd8b3296fa233f4da2e39cbcdc34517/proto/cosmos/base/abci/v1beta1/abci.proto#L106-L109\n[single message]: https://github.com/cosmos/cosmos-sdk/blob/v0.50.4/baseapp/baseapp.go#L1020-L1023", + "value": 9 + } + } + }, + { + "name": "SubMsgResult", + "description": "This is the result type that is returned from a sub message execution.\n\nWe use a custom type here instead of Rust's Result because we want to be able to\ndefine the serialization, which is a public interface. Every language that compiles\nto Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\nUntil version 1.0.0-beta5, `ContractResult` was used instead\nof this type. Once serialized, the two types are the same. However, in the Rust type\nsystem we want different types for clarity and documentation reasons.\n\n# Examples\n\nSuccess:\n\n```\n# use cosmwasm_std::{to_json_string, Binary, Event, SubMsgResponse, SubMsgResult};\n#[allow(deprecated)]\nlet response = SubMsgResponse {\ndata: Some(Binary::from_base64(\"MTIzCg==\").unwrap()),\nevents: vec![Event::new(\"wasm\").add_attribute(\"foo\", \"bar\")],\nmsg_responses: vec![],\n};\nlet result: SubMsgResult = SubMsgResult::Ok(response);\nassert_eq!(\nto_json_string(&result).unwrap(),\nr#\"{\"ok\":{\"events\":[{\"type\":\"wasm\",\"attributes\":[{\"key\":\"foo\",\"value\":\"bar\"}]}],\"data\":\"MTIzCg==\",\"msg_responses\":[]}}\"#,\n);\n```\n\nFailure:\n\n```\n# use cosmwasm_std::{to_json_string, SubMsgResult, Response};\nlet error_msg = String::from(\"Something went wrong\");\nlet result = SubMsgResult::Err(error_msg);\nassert_eq!(to_json_string(&result).unwrap(), r#\"{\"error\":\"Something went wrong\"}\"#);\n```", + "type": "enum", + "cases": { + "error": { + "description": "An error type that every custom error created by contract developers can be converted to.\nThis could potentially have more structure, but String is the easiest.", + "type": "tuple", + "items": [ + 2 + ] + }, + "ok": { + "type": "tuple", + "items": [ + 10 + ] + } + } + }, + { + "name": "Reply", + "description": "The result object returned to `reply`. We always get the ID from the submessage\nback and then must handle success and error cases ourselves.", + "type": "struct", + "properties": { + "gas_used": { + "description": "The amount of gas used by the submessage,\nmeasured in [Cosmos SDK gas](https://github.com/CosmWasm/cosmwasm/blob/main/docs/GAS.md).\n\nThis only contains a useful value on chains running CosmWasm 2.0 or higher.\nOn older chains, this field is always 0.", + "value": 0 + }, + "id": { + "description": "The ID that the contract set when emitting the `SubMsg`.\nUse this to identify which submessage triggered the `reply`.", + "value": 0 + }, + "payload": { + "description": "Some arbitrary data that the contract set when emitting the `SubMsg`.\nThis is just passed into the `reply` entry point and is not stored to state.\n\nUnset/nil/null cannot be differentiated from empty data.\n\nOn chains running CosmWasm 1.x this field is never filled.", + "value": 1 + }, + "result": { + "value": 11 + } + } + } + ] +} diff --git a/contracts/reflect/schema/cw_schema/reflect.json b/contracts/reflect/schema/cw_schema/reflect.json new file mode 100644 index 0000000000..c592ebe036 --- /dev/null +++ b/contracts/reflect/schema/cw_schema/reflect.json @@ -0,0 +1,1418 @@ +{ + "contract_name": "reflect", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "type": "struct", + "properties": {} + } + ] + }, + "execute": { + "type": "v1", + "root": 33, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 1 + }, + "denom": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 2 + }, + { + "name": "BankMsg", + "description": "The message types of the bank module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto", + "type": "enum", + "cases": { + "burn": { + "description": "This will burn the given coins from the contract's account.\nThere is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper.\nImportant if a contract controls significant token supply that must be retired.", + "type": "named", + "properties": { + "amount": { + "value": 3 + } + } + }, + "send": { + "description": "Sends native tokens from the contract to the given address.\n\nThis is translated to a [MsgSend](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto#L19-L28).\n`from_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 3 + }, + "to_address": { + "value": 0 + } + } + } + } + }, + { + "name": "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": "CustomMsg", + "description": "CustomMsg is an override of CosmosMsg::Custom to show this works and can be extended in the contract", + "type": "enum", + "cases": { + "debug": { + "type": "tuple", + "items": [ + 0 + ] + }, + "raw": { + "type": "tuple", + "items": [ + 5 + ] + } + } + }, + { + "name": "StakingMsg", + "description": "The message types of the staking module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto", + "type": "enum", + "cases": { + "delegate": { + "description": "This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "validator": { + "value": 0 + } + } + }, + "redelegate": { + "description": "This is translated to a [MsgBeginRedelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L95-L105).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "dst_validator": { + "value": 0 + }, + "src_validator": { + "value": 0 + } + } + }, + "undelegate": { + "description": "This is translated to a [MsgUndelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L112-L121).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "value": 2 + }, + "validator": { + "value": 0 + } + } + } + } + }, + { + "name": "DistributionMsg", + "description": "The message types of the distribution module.\n\nSee https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto", + "type": "enum", + "cases": { + "fund_community_pool": { + "description": "This is translated to a [[MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2).\n`depositor` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "amount": { + "description": "The amount to spend", + "value": 3 + } + } + }, + "set_withdraw_address": { + "description": "This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "address": { + "description": "The `withdraw_address`", + "value": 0 + } + } + }, + "withdraw_delegator_reward": { + "description": "This is translated to a [[MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50).\n`delegator_address` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "validator": { + "description": "The `validator_address`", + "value": 0 + } + } + } + } + }, + { + "name": "AnyMsg", + "description": "A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto).\nThis is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "struct", + "properties": { + "type_url": { + "value": 0 + }, + "value": { + "value": 5 + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "IbcTimeoutBlock", + "description": "IBCTimeoutHeight Height is a monotonically increasing data type\nthat can be compared against another Height for the purposes of updating and\nfreezing clients.\nOrdering is (revision_number, timeout_height)", + "type": "struct", + "properties": { + "height": { + "description": "block height after which the packet times out.\nthe height within the given revision", + "value": 10 + }, + "revision": { + "description": "the version that the client is currently on\n(e.g. after resetting the chain this could increment 1 as height drops to 0)", + "value": 10 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 11 + }, + { + "name": "Timestamp", + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n```\n# use cosmwasm_std::Timestamp;\nlet ts = Timestamp::from_nanos(1_000_000_202);\nassert_eq!(ts.nanos(), 1_000_000_202);\nassert_eq!(ts.seconds(), 1);\nassert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2);\nassert_eq!(ts.nanos(), 3_000_000_202);\nassert_eq!(ts.seconds(), 3);\nassert_eq!(ts.subsec_nanos(), 202);\n```", + "type": "timestamp" + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 13 + }, + { + "name": "IbcTimeout", + "description": "In IBC each package must set at least one type of timeout:\nthe timestamp or the block height. Using this rather complex enum instead of\ntwo timeout fields we ensure that at least one timeout is set.", + "type": "struct", + "properties": { + "block": { + "value": 12 + }, + "timestamp": { + "value": 14 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "IbcAcknowledgement", + "type": "struct", + "properties": { + "data": { + "value": 5 + } + } + }, + { + "name": "IbcFee", + "type": "struct", + "properties": { + "ack_fee": { + "value": 3 + }, + "receive_fee": { + "value": 3 + }, + "timeout_fee": { + "value": 3 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 0 + }, + { + "name": "IbcMsg", + "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts\n(contracts that directly speak the IBC protocol via 6 entry points)", + "type": "enum", + "cases": { + "close_channel": { + "description": "This will close an existing channel that is owned by this contract.\nPort is auto-assigned to the contract's IBC port", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + } + } + }, + "pay_packet_fee": { + "description": "Incentivizes the next IBC packet sent after this message with a fee.\nNote that this does not necessarily have to be a packet sent by this contract.\nThe fees are taken from the contract's balance immediately and locked until the packet is handled.\n\n# Example\n\nMost commonly, you will attach this message to a response right before sending a packet using\n[`IbcMsg::SendPacket`] or [`IbcMsg::Transfer`].\n\n```rust\n# use cosmwasm_std::{IbcMsg, IbcEndpoint, IbcFee, IbcTimeout, Coin, coins, CosmosMsg, Response, Timestamp};\n\nlet incentivize = IbcMsg::PayPacketFee {\nport_id: \"transfer\".to_string(),\nchannel_id: \"source-channel\".to_string(),\nfee: IbcFee {\nreceive_fee: coins(100, \"token\"),\nack_fee: coins(201, \"token\"),\ntimeout_fee: coins(200, \"token\"),\n},\nrelayers: vec![],\n};\nlet transfer = IbcMsg::Transfer {\nchannel_id: \"source-channel\".to_string(),\nto_address: \"receiver\".to_string(),\namount: Coin::new(100u32, \"token\"),\ntimeout: IbcTimeout::with_timestamp(Timestamp::from_nanos(0)),\nmemo: None,\n};\n\n# #[cfg(feature = \"stargate\")]\nlet _: Response = Response::new()\n.add_message(CosmosMsg::Ibc(incentivize))\n.add_message(CosmosMsg::Ibc(transfer));\n```", + "type": "named", + "properties": { + "channel_id": { + "description": "The channel id on the chain where the packet is sent from (this chain).", + "value": 0 + }, + "fee": { + "value": 18 + }, + "port_id": { + "description": "The port id on the chain where the packet is sent from (this chain).", + "value": 0 + }, + "relayers": { + "description": "Allowlist of relayer addresses that can receive the fee.\nAn empty list means that any relayer can receive the fee.\n\nThis is currently not implemented and *must* be empty.", + "value": 19 + } + } + }, + "pay_packet_fee_async": { + "description": "Incentivizes the existing IBC packet with the given port, channel and sequence with a fee.\nNote that this does not necessarily have to be a packet sent by this contract.\nThe fees are taken from the contract's balance immediately and locked until the packet is handled.\nThey are added to the existing fees on the packet.", + "type": "named", + "properties": { + "channel_id": { + "description": "The channel id on the chain where the packet is sent from (this chain).", + "value": 0 + }, + "fee": { + "value": 18 + }, + "port_id": { + "description": "The port id on the chain where the packet is sent from (this chain).", + "value": 0 + }, + "relayers": { + "description": "Allowlist of relayer addresses that can receive the fee.\nAn empty list means that any relayer can receive the fee.\n\nThis is currently not implemented and *must* be empty.", + "value": 19 + }, + "sequence": { + "description": "The sequence number of the packet that should be incentivized.", + "value": 10 + } + } + }, + "send_packet": { + "description": "Sends an IBC packet with given data over the existing channel.\nData should be encoded in a format defined by the channel version,\nand the module on the other side should know how to parse this.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "data": { + "value": 5 + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "value": 15 + } + } + }, + "transfer": { + "description": "Sends bank tokens owned by the contract to the given address on another chain.\nThe channel must already be established between the ibctransfer module on this chain\nand a matching module on the remote chain.\nWe cannot select the port_id, this is whatever the local chain has bound the ibctransfer\nmodule to.", + "type": "named", + "properties": { + "amount": { + "description": "packet data only supports one coin\nhttps://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/applications/transfer/v1/transfer.proto#L11-L20", + "value": 2 + }, + "channel_id": { + "description": "existing channel to send the tokens over", + "value": 0 + }, + "memo": { + "description": "An optional memo. See the blog post\n[\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b)\nfor more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently\nignored on older chains.\nIf you need support for both 1.x and 2.x chain with the same codebase,\nit is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer\nprotobuf encoder instead.", + "value": 16 + }, + "timeout": { + "description": "when packet times out, measured on remote chain", + "value": 15 + }, + "to_address": { + "description": "address on the remote chain to receive these tokens", + "value": 0 + } + } + }, + "write_acknowledgement": { + "description": "Acknowledges a packet that this contract received over IBC.\nThis allows acknowledging a packet that was not acknowledged yet in the `ibc_packet_receive` call.", + "type": "named", + "properties": { + "ack": { + "description": "The acknowledgement to send back", + "value": 17 + }, + "channel_id": { + "description": "Existing channel where the packet was received", + "value": 0 + }, + "packet_sequence": { + "description": "Sequence number of the packet that was received", + "value": 10 + } + } + } + } + }, + { + "name": "WasmMsg", + "description": "The message types of the wasm module.\n\nSee https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto", + "type": "enum", + "cases": { + "clear_admin": { + "description": "Clears the admin on the given contract, so no more migration possible.\nFails if this contract is not currently admin of the target contract.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + } + } + }, + "execute": { + "description": "Dispatches a call to another contract at a known address (with known ABI).\n\nThis is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "funds": { + "value": 3 + }, + "msg": { + "description": "msg is the json-encoded ExecuteMsg struct (as raw Binary)", + "value": 5 + } + } + }, + "instantiate": { + "description": "Instantiates a new contracts from previously uploaded Wasm code.\n\nThe contract address is non-predictable. But it is guaranteed that\nwhen emitting the same Instantiate message multiple times,\nmultiple instances on different addresses will be generated. See also\nInstantiate2.\n\nThis is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L53-L71).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "admin": { + "value": 16 + }, + "code_id": { + "value": 10 + }, + "funds": { + "value": 3 + }, + "label": { + "description": "A human-readable label for the contract.\n\nValid values should:\n- not be empty\n- not be bigger than 128 bytes (or some chain-specific limit)\n- not start / end with whitespace", + "value": 0 + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "value": 5 + } + } + }, + "instantiate2": { + "description": "Instantiates a new contracts from previously uploaded Wasm code\nusing a predictable address derivation algorithm implemented in\n[`cosmwasm_std::instantiate2_address`].\n\nThis is translated to a [MsgInstantiateContract2](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L73-L96).\n`sender` is automatically filled with the current contract's address.\n`fix_msg` is automatically set to false.", + "type": "named", + "properties": { + "admin": { + "value": 16 + }, + "code_id": { + "value": 10 + }, + "funds": { + "value": 3 + }, + "label": { + "description": "A human-readable label for the contract.\n\nValid values should:\n- not be empty\n- not be bigger than 128 bytes (or some chain-specific limit)\n- not start / end with whitespace", + "value": 0 + }, + "msg": { + "description": "msg is the JSON-encoded InstantiateMsg struct (as raw Binary)", + "value": 5 + }, + "salt": { + "value": 5 + } + } + }, + "migrate": { + "description": "Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to\ncustomize behavior.\n\nOnly the contract admin (as defined in wasmd), if any, is able to make this call.\n\nThis is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96).\n`sender` is automatically filled with the current contract's address.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "msg": { + "description": "msg is the json-encoded MigrateMsg struct that will be passed to the new code", + "value": 5 + }, + "new_code_id": { + "description": "the code_id of the new logic to place in the given contract", + "value": 10 + } + } + }, + "update_admin": { + "description": "Sets a new admin (for migrate) on the given contract.\nFails if this contract is not currently admin of the target contract.", + "type": "named", + "properties": { + "admin": { + "value": 0 + }, + "contract_addr": { + "value": 0 + } + } + } + } + }, + { + "name": "VoteOption", + "type": "enum", + "cases": { + "abstain": { + "type": "unit" + }, + "no": { + "type": "unit" + }, + "no_with_veto": { + "type": "unit" + }, + "yes": { + "type": "unit" + } + } + }, + { + "name": "Decimal", + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "decimal", + "precision": 128, + "signed": false + }, + { + "name": "WeightedVoteOption", + "type": "struct", + "properties": { + "option": { + "value": 22 + }, + "weight": { + "value": 23 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 24 + }, + { + "name": "GovMsg", + "description": "This message type allows the contract interact with the [x/gov] module in order\nto cast votes.\n\n[x/gov]: https://github.com/cosmos/cosmos-sdk/tree/v0.45.12/x/gov\n\n## Examples\n\nCast a simple vote:\n\n```\n# use cosmwasm_std::{\n# HexBinary,\n# Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,\n# Response, QueryResponse,\n# };\n# type ExecuteMsg = ();\nuse cosmwasm_std::{GovMsg, VoteOption};\n\n#[entry_point]\npub fn execute(\ndeps: DepsMut,\nenv: Env,\ninfo: MessageInfo,\nmsg: ExecuteMsg,\n) -> Result {\n// ...\nOk(Response::new().add_message(GovMsg::Vote {\nproposal_id: 4,\noption: VoteOption::Yes,\n}))\n}\n```\n\nCast a weighted vote:\n\n```\n# use cosmwasm_std::{\n# HexBinary,\n# Storage, Api, Querier, DepsMut, Deps, entry_point, Env, StdError, MessageInfo,\n# Response, QueryResponse,\n# };\n# type ExecuteMsg = ();\n# #[cfg(feature = \"cosmwasm_1_2\")]\nuse cosmwasm_std::{Decimal, GovMsg, VoteOption, WeightedVoteOption};\n\n# #[cfg(feature = \"cosmwasm_1_2\")]\n#[entry_point]\npub fn execute(\ndeps: DepsMut,\nenv: Env,\ninfo: MessageInfo,\nmsg: ExecuteMsg,\n) -> Result {\n// ...\nOk(Response::new().add_message(GovMsg::VoteWeighted {\nproposal_id: 4,\noptions: vec![\nWeightedVoteOption {\noption: VoteOption::Yes,\nweight: Decimal::percent(65),\n},\nWeightedVoteOption {\noption: VoteOption::Abstain,\nweight: Decimal::percent(35),\n},\n],\n}))\n}\n```", + "type": "enum", + "cases": { + "vote": { + "description": "This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.", + "type": "named", + "properties": { + "option": { + "description": "The vote option.\n\nThis used to be called \"vote\", but was changed for consistency with Cosmos SDK.", + "value": 22 + }, + "proposal_id": { + "value": 10 + } + } + }, + "vote_weighted": { + "description": "This maps directly to [MsgVoteWeighted](https://github.com/cosmos/cosmos-sdk/blob/v0.45.8/proto/cosmos/gov/v1beta1/tx.proto#L66-L78) in the Cosmos SDK with voter set to the contract address.", + "type": "named", + "properties": { + "options": { + "value": 25 + }, + "proposal_id": { + "value": 10 + } + } + } + } + }, + { + "name": "CosmosMsg", + "type": "enum", + "cases": { + "any": { + "description": "`CosmosMsg::Any` is the replaces the \"stargate message\" – a message wrapped\nin a [protobuf Any](https://protobuf.dev/programming-guides/proto3/#any)\nthat is supported by the chain. It behaves the same as\n`CosmosMsg::Stargate` but has a better name and slightly improved syntax.\n\nThis is feature-gated at compile time with `cosmwasm_2_0` because\na chain running CosmWasm < 2.0 cannot process this.", + "type": "tuple", + "items": [ + 9 + ] + }, + "bank": { + "type": "tuple", + "items": [ + 4 + ] + }, + "custom": { + "type": "tuple", + "items": [ + 6 + ] + }, + "distribution": { + "type": "tuple", + "items": [ + 8 + ] + }, + "gov": { + "type": "tuple", + "items": [ + 26 + ] + }, + "ibc": { + "type": "tuple", + "items": [ + 20 + ] + }, + "staking": { + "type": "tuple", + "items": [ + 7 + ] + }, + "stargate": { + "description": "This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)", + "type": "named", + "properties": { + "type_url": { + "value": 0 + }, + "value": { + "value": 5 + } + } + }, + "wasm": { + "type": "tuple", + "items": [ + 21 + ] + } + } + }, + { + "name": "alloc::vec::Vec>", + "type": "array", + "items": 27 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 10 + }, + { + "name": "ReplyOn", + "description": "Use this to define when the contract gets a response callback.\nIf you only need it for errors or success you can select just those in order\nto save gas.", + "type": "enum", + "cases": { + "always": { + "description": "Always perform a callback after SubMsg is processed", + "type": "unit" + }, + "error": { + "description": "Only callback if SubMsg returned an error, no callback on success case", + "type": "unit" + }, + "never": { + "description": "Never make a callback - this is like the original CosmosMsg semantics", + "type": "unit" + }, + "success": { + "description": "Only callback if SubMsg was successful, no callback on error case", + "type": "unit" + } + } + }, + { + "name": "SubMsg", + "description": "A submessage that will guarantee a `reply` call on success or error, depending on\nthe `reply_on` setting. If you do not need to process the result, use regular messages instead.\n\nNote: On error the submessage execution will revert any partial state changes due to this message,\nbut not revert any state changes in the calling contract. If this is required, it must be done\nmanually in the `reply` entry point.", + "type": "struct", + "properties": { + "gas_limit": { + "description": "Gas limit measured in [Cosmos SDK gas](https://github.com/CosmWasm/cosmwasm/blob/main/docs/GAS.md).\n\nSetting this to `None` means unlimited. Then the submessage execution can consume all gas of the\ncurrent execution context.", + "value": 29 + }, + "id": { + "description": "An arbitrary ID chosen by the contract.\nThis is typically used to match `Reply`s in the `reply` entry point to the submessage.", + "value": 10 + }, + "msg": { + "value": 27 + }, + "payload": { + "description": "Some arbitrary data that the contract can set in an application specific way.\nThis is just passed into the `reply` entry point and is not stored to state.\nAny encoding can be used. If `id` is used to identify a particular action,\nthe encoding can also be different for each of those actions since you can match `id`\nfirst and then start processing the `payload`.\n\nThe environment restricts the length of this field in order to avoid abuse. The limit\nis environment specific and can change over time. The initial default is 128 KiB.\n\nUnset/nil/null cannot be differentiated from empty data.\n\nOn chains running CosmWasm 1.x this field will be ignored.", + "value": 5 + }, + "reply_on": { + "value": 30 + } + } + }, + { + "name": "alloc::vec::Vec>", + "type": "array", + "items": 31 + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "change_owner": { + "type": "named", + "properties": { + "owner": { + "value": 0 + } + } + }, + "reflect_msg": { + "type": "named", + "properties": { + "msgs": { + "value": 28 + } + } + }, + "reflect_sub_msg": { + "type": "named", + "properties": { + "msgs": { + "value": 32 + } + } + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 17, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "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": "core::option::Option", + "type": "optional", + "inner": 1 + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "bool", + "type": "boolean" + }, + { + "name": "PageRequest", + "description": "Simplified version of the PageRequest type for pagination from the cosmos-sdk", + "type": "struct", + "properties": { + "key": { + "value": 2 + }, + "limit": { + "value": 3 + }, + "reverse": { + "value": 4 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 5 + }, + { + "name": "BankQuery", + "type": "enum", + "cases": { + "all_balances": { + "description": "This calls into the native bank module for all denominations.\nNote that this may be much more expensive than Balance and should be avoided if possible.\nReturn value is AllBalanceResponse.", + "type": "named", + "properties": { + "address": { + "value": 0 + } + } + }, + "all_denom_metadata": { + "description": "This calls into the native bank module for querying metadata for all bank tokens that have a metadata entry.\nReturn value is AllDenomMetadataResponse", + "type": "named", + "properties": { + "pagination": { + "value": 6 + } + } + }, + "balance": { + "description": "This calls into the native bank module for one denomination\nReturn value is BalanceResponse", + "type": "named", + "properties": { + "address": { + "value": 0 + }, + "denom": { + "value": 0 + } + } + }, + "denom_metadata": { + "description": "This calls into the native bank module for querying metadata for a specific bank token.\nReturn value is DenomMetadataResponse", + "type": "named", + "properties": { + "denom": { + "value": 0 + } + } + }, + "supply": { + "description": "This calls into the native bank module for querying the total supply of one denomination.\nIt does the same as the SupplyOf call in Cosmos SDK's RPC API.\nReturn value is of type SupplyResponse.", + "type": "named", + "properties": { + "denom": { + "value": 0 + } + } + } + } + }, + { + "name": "SpecialQuery", + "description": "An implementation of QueryRequest::Custom to show this works and can be extended in the contract", + "type": "enum", + "cases": { + "capitalized": { + "type": "named", + "properties": { + "text": { + "value": 0 + } + } + }, + "ping": { + "type": "named", + "properties": {} + } + } + }, + { + "name": "StakingQuery", + "type": "enum", + "cases": { + "all_delegations": { + "description": "AllDelegations will return all delegations by the delegator", + "type": "named", + "properties": { + "delegator": { + "value": 0 + } + } + }, + "all_validators": { + "description": "Returns all validators in the currently active validator set.\n\nThe query response type is `AllValidatorsResponse`.", + "type": "named", + "properties": {} + }, + "bonded_denom": { + "description": "Returns the denomination that can be bonded (if there are multiple native tokens on the chain)", + "type": "named", + "properties": {} + }, + "delegation": { + "description": "Delegation will return more detailed info on a particular\ndelegation, defined by delegator/validator pair", + "type": "named", + "properties": { + "delegator": { + "value": 0 + }, + "validator": { + "value": 0 + } + } + }, + "validator": { + "description": "Returns the validator at the given address. Returns None if the validator is\nnot part of the currently active validator set.\n\nThe query response type is `ValidatorResponse`.", + "type": "named", + "properties": { + "address": { + "description": "The validator's address (e.g. (e.g. cosmosvaloper1...))", + "value": 0 + } + } + } + } + }, + { + "name": "DistributionQuery", + "type": "enum", + "cases": { + "delegation_rewards": { + "description": "See ", + "type": "named", + "properties": { + "delegator_address": { + "value": 0 + }, + "validator_address": { + "value": 0 + } + } + }, + "delegation_total_rewards": { + "description": "See ", + "type": "named", + "properties": { + "delegator_address": { + "value": 0 + } + } + }, + "delegator_validators": { + "description": "See ", + "type": "named", + "properties": { + "delegator_address": { + "value": 0 + } + } + }, + "delegator_withdraw_address": { + "description": "See ", + "type": "named", + "properties": { + "delegator_address": { + "value": 0 + } + } + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 0 + }, + { + "name": "IbcQuery", + "description": "These are queries to the various IBC modules to see the state of the contract's\nIBC connection.\nMost of these will return errors if the contract is not \"ibc enabled\".", + "type": "enum", + "cases": { + "channel": { + "description": "Lists all information for a (portID, channelID) pair.\nIf port_id is omitted, it will default to the contract's own channel.\n(To save a PortId{} call)\n\nReturns a `ChannelResponse`.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "port_id": { + "value": 11 + } + } + }, + "fee_enabled_channel": { + "description": "Queries whether the given channel supports IBC fees.\nIf port_id is omitted, it will default to the contract's own channel.\n(To save a PortId{} call)\n\nReturns a `FeeEnabledChannelResponse`.", + "type": "named", + "properties": { + "channel_id": { + "value": 0 + }, + "port_id": { + "value": 11 + } + } + }, + "list_channels": { + "description": "Lists all channels that are bound to a given port.\nIf `port_id` is omitted, this list all channels bound to the contract's port.\n\nReturns a `ListChannelsResponse`.", + "type": "named", + "properties": { + "port_id": { + "value": 11 + } + } + }, + "port_id": { + "description": "Gets the Port ID the current contract is bound to.\n\nReturns a `PortIdResponse`.", + "type": "named", + "properties": {} + } + } + }, + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "WasmQuery", + "type": "enum", + "cases": { + "code_info": { + "description": "Returns a [`CodeInfoResponse`] with metadata of the code", + "type": "named", + "properties": { + "code_id": { + "value": 13 + } + } + }, + "contract_info": { + "description": "Returns a [`ContractInfoResponse`] with metadata on the contract from the runtime", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + } + } + }, + "raw": { + "description": "this queries the raw kv-store of the contract.\nreturns the raw, unparsed data stored at that key, which may be an empty vector if not present", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "key": { + "description": "Key is the raw key used in the contracts Storage", + "value": 1 + } + } + }, + "smart": { + "description": "this queries the public API of another contract at a known address (with known ABI)\nReturn value is whatever the contract returns (caller should know), wrapped in a\nContractResult that is JSON encoded.", + "type": "named", + "properties": { + "contract_addr": { + "value": 0 + }, + "msg": { + "description": "msg is the json-encoded QueryMsg struct", + "value": 1 + } + } + } + } + }, + { + "name": "GrpcQuery", + "description": "Queries the chain using a grpc query.\nThis allows to query information that is not exposed in our API.\nThe chain needs to allowlist the supported queries.\nThe drawback of this query is that you have to handle the protobuf encoding and decoding yourself.\n\nThe returned data is protobuf encoded. The protobuf type depends on the query.\nBecause of this, using it with the [`query`](crate::QuerierWrapper::query) function will result\nin a deserialization error.\nUse [`raw_query`](crate::Querier::raw_query) or [`query_grpc`](crate::QuerierWrapper::query_grpc)\ninstead.\n\nTo find the path, as well as the request and response types,\nyou can query the chain's gRPC endpoint using a tool like\n[grpcurl](https://github.com/fullstorydev/grpcurl).", + "type": "struct", + "properties": { + "data": { + "description": "The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded", + "value": 1 + }, + "path": { + "description": "The fully qualified endpoint path used for routing.\nIt follows the format `/service_path/method_name`,\neg. \"/cosmos.authz.v1beta1.Query/Grants\"", + "value": 0 + } + } + }, + { + "name": "QueryRequest", + "type": "enum", + "cases": { + "bank": { + "type": "tuple", + "items": [ + 7 + ] + }, + "custom": { + "type": "tuple", + "items": [ + 8 + ] + }, + "distribution": { + "type": "tuple", + "items": [ + 10 + ] + }, + "grpc": { + "type": "tuple", + "items": [ + 15 + ] + }, + "ibc": { + "type": "tuple", + "items": [ + 12 + ] + }, + "staking": { + "type": "tuple", + "items": [ + 9 + ] + }, + "stargate": { + "description": "A Stargate query is encoded the same way as abci_query, with path and protobuf encoded request data.\nThe format is defined in [ADR-21](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-021-protobuf-query-encoding.md).\nThe response is protobuf encoded data directly without a JSON response wrapper.\nThe caller is responsible for compiling the proper protobuf definitions for both requests and responses.", + "type": "named", + "properties": { + "data": { + "description": "this is the expected protobuf message type (not any), binary encoded", + "value": 1 + }, + "path": { + "description": "this is the fully qualified service path used for routing,\neg. \"/cosmos_sdk.x.bank.v1.Query/QueryBalance\"", + "value": 0 + } + } + }, + "wasm": { + "type": "tuple", + "items": [ + 14 + ] + } + } + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "capitalized": { + "description": "This will call out to SpecialQuery::Capitalized", + "type": "named", + "properties": { + "text": { + "value": 0 + } + } + }, + "chain": { + "description": "Queries the blockchain and returns the result untouched", + "type": "named", + "properties": { + "request": { + "value": 16 + } + } + }, + "owner": { + "type": "named", + "properties": {} + }, + "raw": { + "description": "Queries another contract and returns the data", + "type": "named", + "properties": { + "contract": { + "value": 0 + }, + "key": { + "value": 1 + } + } + }, + "sub_msg_result": { + "description": "If there was a previous ReflectSubMsg with this ID, returns cosmwasm_std::Reply", + "type": "named", + "properties": { + "id": { + "value": 13 + } + } + } + } + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "capitalized": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "CapitalizedResponse", + "type": "struct", + "properties": { + "text": { + "value": 0 + } + } + } + ] + }, + "chain": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "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": "ChainResponse", + "type": "struct", + "properties": { + "data": { + "value": 0 + } + } + } + ] + }, + "owner": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "OwnerResponse", + "type": "struct", + "properties": { + "owner": { + "value": 0 + } + } + } + ] + }, + "raw": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "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": "RawResponse", + "type": "struct", + "properties": { + "data": { + "description": "The returned value of the raw query. Empty data can be the\nresult of a non-existent key or an empty value. We cannot\ndifferentiate those two cases in cross contract queries.", + "value": 0 + } + } + } + ] + }, + "sub_msg_result": { + "type": "v1", + "root": 12, + "definitions": [ + { + "name": "u64", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "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": "String", + "type": "string" + }, + { + "name": "Attribute", + "description": "An key value pair that is used in the context of event attributes in logs", + "type": "struct", + "properties": { + "key": { + "value": 2 + }, + "value": { + "value": 2 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 3 + }, + { + "name": "Event", + "description": "A full [*Cosmos SDK* event].\n\nThis version uses string attributes (similar to [*Cosmos SDK* StringEvent]),\nwhich then get magically converted to bytes for Tendermint somewhere between\nthe Rust-Go interface, JSON deserialization and the `NewEvent` call in Cosmos SDK.\n\n[*Cosmos SDK* event]: https://docs.cosmos.network/main/learn/advanced/events\n[*Cosmos SDK* StringEvent]: https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/base/abci/v1beta1/abci.proto#L56-L70", + "type": "struct", + "properties": { + "attributes": { + "description": "The attributes to be included in the event.\n\nYou can learn more about these from [*Cosmos SDK* docs].\n\n[*Cosmos SDK* docs]: https://docs.cosmos.network/main/learn/advanced/events", + "value": 4 + }, + "type": { + "description": "The event type. This is renamed to \"ty\" because \"type\" is reserved in Rust. This sucks, we know.", + "value": 2 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 5 + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 1 + }, + { + "name": "MsgResponse", + "type": "struct", + "properties": { + "type_url": { + "value": 2 + }, + "value": { + "value": 1 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 8 + }, + { + "name": "SubMsgResponse", + "description": "The information we get back from a successful sub message execution,\nwith full Cosmos SDK events.", + "type": "struct", + "properties": { + "data": { + "value": 7 + }, + "events": { + "value": 6 + }, + "msg_responses": { + "description": "The responses from the messages emitted by the submessage.\nIn most cases, this is equivalent to the Cosmos SDK's [MsgResponses], which usually contains a [single message].\nHowever, wasmd allows chains to translate a single contract message into multiple SDK messages.\nIn that case all the MsgResponses from each are concatenated into this flattened `Vec`.\n\n[MsgResponses]: https://github.com/cosmos/cosmos-sdk/blob/316750cc8cd8b3296fa233f4da2e39cbcdc34517/proto/cosmos/base/abci/v1beta1/abci.proto#L106-L109\n[single message]: https://github.com/cosmos/cosmos-sdk/blob/v0.50.4/baseapp/baseapp.go#L1020-L1023", + "value": 9 + } + } + }, + { + "name": "SubMsgResult", + "description": "This is the result type that is returned from a sub message execution.\n\nWe use a custom type here instead of Rust's Result because we want to be able to\ndefine the serialization, which is a public interface. Every language that compiles\nto Wasm and runs in the ComsWasm VM needs to create the same JSON representation.\n\nUntil version 1.0.0-beta5, `ContractResult` was used instead\nof this type. Once serialized, the two types are the same. However, in the Rust type\nsystem we want different types for clarity and documentation reasons.\n\n# Examples\n\nSuccess:\n\n```\n# use cosmwasm_std::{to_json_string, Binary, Event, SubMsgResponse, SubMsgResult};\n#[allow(deprecated)]\nlet response = SubMsgResponse {\ndata: Some(Binary::from_base64(\"MTIzCg==\").unwrap()),\nevents: vec![Event::new(\"wasm\").add_attribute(\"foo\", \"bar\")],\nmsg_responses: vec![],\n};\nlet result: SubMsgResult = SubMsgResult::Ok(response);\nassert_eq!(\nto_json_string(&result).unwrap(),\nr#\"{\"ok\":{\"events\":[{\"type\":\"wasm\",\"attributes\":[{\"key\":\"foo\",\"value\":\"bar\"}]}],\"data\":\"MTIzCg==\",\"msg_responses\":[]}}\"#,\n);\n```\n\nFailure:\n\n```\n# use cosmwasm_std::{to_json_string, SubMsgResult, Response};\nlet error_msg = String::from(\"Something went wrong\");\nlet result = SubMsgResult::Err(error_msg);\nassert_eq!(to_json_string(&result).unwrap(), r#\"{\"error\":\"Something went wrong\"}\"#);\n```", + "type": "enum", + "cases": { + "error": { + "description": "An error type that every custom error created by contract developers can be converted to.\nThis could potentially have more structure, but String is the easiest.", + "type": "tuple", + "items": [ + 2 + ] + }, + "ok": { + "type": "tuple", + "items": [ + 10 + ] + } + } + }, + { + "name": "Reply", + "description": "The result object returned to `reply`. We always get the ID from the submessage\nback and then must handle success and error cases ourselves.", + "type": "struct", + "properties": { + "gas_used": { + "description": "The amount of gas used by the submessage,\nmeasured in [Cosmos SDK gas](https://github.com/CosmWasm/cosmwasm/blob/main/docs/GAS.md).\n\nThis only contains a useful value on chains running CosmWasm 2.0 or higher.\nOn older chains, this field is always 0.", + "value": 0 + }, + "id": { + "description": "The ID that the contract set when emitting the `SubMsg`.\nUse this to identify which submessage triggered the `reply`.", + "value": 0 + }, + "payload": { + "description": "Some arbitrary data that the contract set when emitting the `SubMsg`.\nThis is just passed into the `reply` entry point and is not stored to state.\n\nUnset/nil/null cannot be differentiated from empty data.\n\nOn chains running CosmWasm 1.x this field is never filled.", + "value": 1 + }, + "result": { + "value": 11 + } + } + } + ] + } + } +} diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 411282c26a..5901a74626 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -909,6 +936,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -942,14 +975,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -959,6 +1009,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1120,6 +1179,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1298,6 +1366,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1415,7 +1503,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1432,6 +1533,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1471,9 +1584,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1500,9 +1613,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1522,15 +1635,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1568,6 +1705,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1608,7 +1751,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", "snafu", ] @@ -1619,6 +1762,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.26.2" @@ -1647,6 +1796,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1991,7 +2150,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/staking/schema/cw_schema/raw/execute.json b/contracts/staking/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..dbaa0513d5 --- /dev/null +++ b/contracts/staking/schema/cw_schema/raw/execute.json @@ -0,0 +1,64 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "bond": { + "description": "Bond will bond all staking tokens sent with the message and release derivative tokens", + "type": "named", + "properties": {} + }, + "bond_all_tokens": { + "description": "_BondAllTokens can only be called by the contract itself, after all rewards have been\nwithdrawn. This is an example of using \"callbacks\" in message flows.\nThis can only be invoked by the contract itself as a return from Reinvest", + "type": "named", + "properties": {} + }, + "claim": { + "description": "Claim is used to claim your native tokens that you previously \"unbonded\"\nafter the chain-defined waiting period (eg. 3 weeks)", + "type": "named", + "properties": {} + }, + "reinvest": { + "description": "Reinvest will check for all accumulated rewards, withdraw them, and\nre-bond them to the same validator. Anyone can call this, which updates\nthe value of the token (how much under custody).", + "type": "named", + "properties": {} + }, + "transfer": { + "description": "Transfer moves the derivative token", + "type": "named", + "properties": { + "amount": { + "value": 1 + }, + "recipient": { + "value": 0 + } + } + }, + "unbond": { + "description": "Unbond will \"burn\" the given amount of derivative tokens and send the unbonded\nstaking tokens to the message sender (after exit tax is deducted)", + "type": "named", + "properties": { + "amount": { + "value": 1 + } + } + } + } + } + ] +} diff --git a/contracts/staking/schema/cw_schema/raw/instantiate.json b/contracts/staking/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..a6291334a4 --- /dev/null +++ b/contracts/staking/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,60 @@ +{ + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u8", + "type": "integer", + "precision": 8, + "signed": false + }, + { + "name": "Decimal", + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "decimal", + "precision": 128, + "signed": false + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "InstantiateMsg", + "type": "struct", + "properties": { + "decimals": { + "description": "decimal places of the derivative token (for UI)\nTODO: does this make sense? Do we need to normalize on this?\nWe don't even know the decimals of the native token", + "value": 1 + }, + "exit_tax": { + "description": "this is how much the owner takes as a cut when someone unbonds\nTODO", + "value": 2 + }, + "min_withdrawal": { + "description": "This is the minimum amount we will pull out to reinvest, as well as a minimum\nthat can be unbonded (to avoid needless staking tx)", + "value": 3 + }, + "name": { + "description": "name of the derivative token (FIXME: auto-generate?)", + "value": 0 + }, + "symbol": { + "description": "symbol / ticker of the derivative token", + "value": 0 + }, + "validator": { + "description": "This is the validator that all tokens will be bonded to", + "value": 0 + } + } + } + ] +} diff --git a/contracts/staking/schema/cw_schema/raw/query.json b/contracts/staking/schema/cw_schema/raw/query.json new file mode 100644 index 0000000000..094dbd1f1c --- /dev/null +++ b/contracts/staking/schema/cw_schema/raw/query.json @@ -0,0 +1,44 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "balance": { + "description": "Balance shows the number of staking derivatives", + "type": "named", + "properties": { + "address": { + "value": 0 + } + } + }, + "claims": { + "description": "Claims shows the number of tokens this address can access when they are done unbonding", + "type": "named", + "properties": { + "address": { + "value": 0 + } + } + }, + "investment": { + "description": "Investment shows info on total staking tokens under custody,\nwith which validator, as well as how many derivative tokens are lists.\nIt also shows with the exit tax.", + "type": "named", + "properties": {} + }, + "token_info": { + "description": "TokenInfo shows the metadata of the token for UIs", + "type": "named", + "properties": {} + } + } + } + ] +} diff --git a/contracts/staking/schema/cw_schema/raw/response_to_balance.json b/contracts/staking/schema/cw_schema/raw/response_to_balance.json new file mode 100644 index 0000000000..0c34009369 --- /dev/null +++ b/contracts/staking/schema/cw_schema/raw/response_to_balance.json @@ -0,0 +1,22 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "BalanceResponse", + "type": "struct", + "properties": { + "balance": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/staking/schema/cw_schema/raw/response_to_claims.json b/contracts/staking/schema/cw_schema/raw/response_to_claims.json new file mode 100644 index 0000000000..1dc799f0f3 --- /dev/null +++ b/contracts/staking/schema/cw_schema/raw/response_to_claims.json @@ -0,0 +1,22 @@ +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "ClaimsResponse", + "type": "struct", + "properties": { + "claims": { + "value": 0 + } + } + } + ] +} diff --git a/contracts/staking/schema/cw_schema/raw/response_to_investment.json b/contracts/staking/schema/cw_schema/raw/response_to_investment.json new file mode 100644 index 0000000000..7b5dcf5b07 --- /dev/null +++ b/contracts/staking/schema/cw_schema/raw/response_to_investment.json @@ -0,0 +1,67 @@ +{ + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "String", + "type": "string" + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 0 + }, + "denom": { + "value": 1 + } + } + }, + { + "name": "Decimal", + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "decimal", + "precision": 128, + "signed": false + }, + { + "name": "InvestmentResponse", + "type": "struct", + "properties": { + "exit_tax": { + "description": "this is how much the owner takes as a cut when someone unbonds", + "value": 3 + }, + "min_withdrawal": { + "description": "This is the minimum amount we will pull out to reinvest, as well as a minimum\nthat can be unbonded (to avoid needless staking tx)", + "value": 0 + }, + "nominal_value": { + "value": 3 + }, + "owner": { + "description": "owner created the contract and takes a cut", + "value": 1 + }, + "staked_tokens": { + "value": 2 + }, + "token_supply": { + "value": 0 + }, + "validator": { + "description": "All tokens are bonded to this validator", + "value": 1 + } + } + } + ] +} diff --git a/contracts/staking/schema/cw_schema/raw/response_to_token_info.json b/contracts/staking/schema/cw_schema/raw/response_to_token_info.json new file mode 100644 index 0000000000..a37b8edf8d --- /dev/null +++ b/contracts/staking/schema/cw_schema/raw/response_to_token_info.json @@ -0,0 +1,35 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u8", + "type": "integer", + "precision": 8, + "signed": false + }, + { + "name": "TokenInfoResponse", + "description": "TokenInfoResponse is info to display the derivative token in a UI", + "type": "struct", + "properties": { + "decimals": { + "description": "decimal places of the derivative token (for UI)", + "value": 1 + }, + "name": { + "description": "name of the derivative token", + "value": 0 + }, + "symbol": { + "description": "symbol / ticker of the derivative token", + "value": 0 + } + } + } + ] +} diff --git a/contracts/staking/schema/cw_schema/staking.json b/contracts/staking/schema/cw_schema/staking.json new file mode 100644 index 0000000000..8e78206085 --- /dev/null +++ b/contracts/staking/schema/cw_schema/staking.json @@ -0,0 +1,323 @@ +{ + "contract_name": "staking", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u8", + "type": "integer", + "precision": 8, + "signed": false + }, + { + "name": "Decimal", + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "decimal", + "precision": 128, + "signed": false + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "InstantiateMsg", + "type": "struct", + "properties": { + "decimals": { + "description": "decimal places of the derivative token (for UI)\nTODO: does this make sense? Do we need to normalize on this?\nWe don't even know the decimals of the native token", + "value": 1 + }, + "exit_tax": { + "description": "this is how much the owner takes as a cut when someone unbonds\nTODO", + "value": 2 + }, + "min_withdrawal": { + "description": "This is the minimum amount we will pull out to reinvest, as well as a minimum\nthat can be unbonded (to avoid needless staking tx)", + "value": 3 + }, + "name": { + "description": "name of the derivative token (FIXME: auto-generate?)", + "value": 0 + }, + "symbol": { + "description": "symbol / ticker of the derivative token", + "value": 0 + }, + "validator": { + "description": "This is the validator that all tokens will be bonded to", + "value": 0 + } + } + } + ] + }, + "execute": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "bond": { + "description": "Bond will bond all staking tokens sent with the message and release derivative tokens", + "type": "named", + "properties": {} + }, + "bond_all_tokens": { + "description": "_BondAllTokens can only be called by the contract itself, after all rewards have been\nwithdrawn. This is an example of using \"callbacks\" in message flows.\nThis can only be invoked by the contract itself as a return from Reinvest", + "type": "named", + "properties": {} + }, + "claim": { + "description": "Claim is used to claim your native tokens that you previously \"unbonded\"\nafter the chain-defined waiting period (eg. 3 weeks)", + "type": "named", + "properties": {} + }, + "reinvest": { + "description": "Reinvest will check for all accumulated rewards, withdraw them, and\nre-bond them to the same validator. Anyone can call this, which updates\nthe value of the token (how much under custody).", + "type": "named", + "properties": {} + }, + "transfer": { + "description": "Transfer moves the derivative token", + "type": "named", + "properties": { + "amount": { + "value": 1 + }, + "recipient": { + "value": 0 + } + } + }, + "unbond": { + "description": "Unbond will \"burn\" the given amount of derivative tokens and send the unbonded\nstaking tokens to the message sender (after exit tax is deducted)", + "type": "named", + "properties": { + "amount": { + "value": 1 + } + } + } + } + } + ] + }, + "query": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "QueryMsg", + "type": "enum", + "cases": { + "balance": { + "description": "Balance shows the number of staking derivatives", + "type": "named", + "properties": { + "address": { + "value": 0 + } + } + }, + "claims": { + "description": "Claims shows the number of tokens this address can access when they are done unbonding", + "type": "named", + "properties": { + "address": { + "value": 0 + } + } + }, + "investment": { + "description": "Investment shows info on total staking tokens under custody,\nwith which validator, as well as how many derivative tokens are lists.\nIt also shows with the exit tax.", + "type": "named", + "properties": {} + }, + "token_info": { + "description": "TokenInfo shows the metadata of the token for UIs", + "type": "named", + "properties": {} + } + } + } + ] + }, + "migrate": null, + "sudo": null, + "responses": { + "balance": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "BalanceResponse", + "type": "struct", + "properties": { + "balance": { + "value": 0 + } + } + } + ] + }, + "claims": { + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "ClaimsResponse", + "type": "struct", + "properties": { + "claims": { + "value": 0 + } + } + } + ] + }, + "investment": { + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "Uint128", + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding,\nsuch that the full u128 range can be used for clients that convert JSON numbers to floats,\nlike JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n```\n# use cosmwasm_std::Uint128;\nlet a = Uint128::from(123u128);\nassert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64);\nassert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32);\nassert_eq!(c.u128(), 70);\n```", + "type": "integer", + "precision": 128, + "signed": false + }, + { + "name": "String", + "type": "string" + }, + { + "name": "Coin", + "type": "struct", + "properties": { + "amount": { + "value": 0 + }, + "denom": { + "value": 1 + } + } + }, + { + "name": "Decimal", + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "decimal", + "precision": 128, + "signed": false + }, + { + "name": "InvestmentResponse", + "type": "struct", + "properties": { + "exit_tax": { + "description": "this is how much the owner takes as a cut when someone unbonds", + "value": 3 + }, + "min_withdrawal": { + "description": "This is the minimum amount we will pull out to reinvest, as well as a minimum\nthat can be unbonded (to avoid needless staking tx)", + "value": 0 + }, + "nominal_value": { + "value": 3 + }, + "owner": { + "description": "owner created the contract and takes a cut", + "value": 1 + }, + "staked_tokens": { + "value": 2 + }, + "token_supply": { + "value": 0 + }, + "validator": { + "description": "All tokens are bonded to this validator", + "value": 1 + } + } + } + ] + }, + "token_info": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u8", + "type": "integer", + "precision": 8, + "signed": false + }, + { + "name": "TokenInfoResponse", + "description": "TokenInfoResponse is info to display the derivative token in a UI", + "type": "struct", + "properties": { + "decimals": { + "description": "decimal places of the derivative token (for UI)", + "value": 1 + }, + "name": { + "description": "name of the derivative token", + "value": 0 + }, + "symbol": { + "description": "symbol / ticker of the derivative token", + "value": 0 + } + } + } + ] + } + } +} diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 35710351f9..ffc86f390c 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -88,7 +88,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -371,7 +371,8 @@ name = "cosmwasm-schema" version = "2.2.0-rc.1" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -396,11 +397,12 @@ dependencies = [ "cosmwasm-core", "cosmwasm-crypto", "cosmwasm-derive", + "cw-schema", "derive_more", "hex", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "sha2", @@ -424,7 +426,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -547,6 +549,30 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.15", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "darling" version = "0.20.9" @@ -567,6 +593,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -909,6 +936,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -942,14 +975,31 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", ] +[[package]] +name = "is-terminal" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + +[[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" @@ -959,6 +1009,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -1120,6 +1179,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +dependencies = [ + "supports-color", +] + [[package]] name = "p256" version = "0.13.2" @@ -1298,6 +1366,26 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "region" version = "3.0.2" @@ -1415,7 +1503,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ "dyn-clone", - "schemars_derive", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848710f31190edab07d4dfee50b89cb4429a789c4aa9aa07356fbe59c59af52" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.15", "serde", "serde_json", ] @@ -1432,6 +1533,18 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09196e95ccdbafef196a660dc9380e322a222c73341162b611f0a8f32cc02375" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.77", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1471,9 +1584,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] @@ -1500,9 +1613,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1522,15 +1635,39 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1568,6 +1705,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "smallvec" version = "1.13.2" @@ -1586,6 +1729,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.26.2" @@ -1614,6 +1763,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -1751,7 +1910,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", "thiserror", ] @@ -1970,7 +2129,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.5.0", - "indexmap 2.2.6", + "indexmap 2.4.0", "semver", ] diff --git a/contracts/virus/schema/cw_schema/raw/execute.json b/contracts/virus/schema/cw_schema/raw/execute.json new file mode 100644 index 0000000000..08077a028b --- /dev/null +++ b/contracts/virus/schema/cw_schema/raw/execute.json @@ -0,0 +1,35 @@ +{ + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "spread": { + "type": "named", + "properties": { + "levels": { + "description": "The number of levels of spreading. When set to 0, the contract performs a no-op.", + "value": 1 + }, + "parent_path": { + "description": "A slash separated path to the instance creating this one.\nThe root is the empty string.", + "value": 0 + } + } + } + } + } + ] +} diff --git a/contracts/virus/schema/cw_schema/raw/instantiate.json b/contracts/virus/schema/cw_schema/raw/instantiate.json new file mode 100644 index 0000000000..9fc37502e9 --- /dev/null +++ b/contracts/virus/schema/cw_schema/raw/instantiate.json @@ -0,0 +1,11 @@ +{ + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "type": "struct", + "properties": {} + } + ] +} diff --git a/contracts/virus/schema/cw_schema/virus.json b/contracts/virus/schema/cw_schema/virus.json new file mode 100644 index 0000000000..eca0408d09 --- /dev/null +++ b/contracts/virus/schema/cw_schema/virus.json @@ -0,0 +1,55 @@ +{ + "contract_name": "virus", + "contract_version": "0.0.0", + "idl_version": "1.0.0", + "instantiate": { + "type": "v1", + "root": 0, + "definitions": [ + { + "name": "InstantiateMsg", + "type": "struct", + "properties": {} + } + ] + }, + "execute": { + "type": "v1", + "root": 2, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "ExecuteMsg", + "type": "enum", + "cases": { + "spread": { + "type": "named", + "properties": { + "levels": { + "description": "The number of levels of spreading. When set to 0, the contract performs a no-op.", + "value": 1 + }, + "parent_path": { + "description": "A slash separated path to the instance creating this one.\nThe root is the empty string.", + "value": 0 + } + } + } + } + } + ] + }, + "query": null, + "migrate": null, + "sudo": null, + "responses": null +} diff --git a/devtools/generate_schemas.sh b/devtools/generate_schemas.sh new file mode 100755 index 0000000000..f5f8c083e3 --- /dev/null +++ b/devtools/generate_schemas.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck >/dev/null && shellcheck "$0" + +for contract_dir in contracts/*/; do + ( + cd "$contract_dir" + cargo schema + ) +done diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml new file mode 100644 index 0000000000..581468a6e3 --- /dev/null +++ b/packages/cw-schema-codegen/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "cw-schema-codegen" +authors = ["Aumetra Weisman "] +edition = "2021" +version.workspace = true +publish = false +build = "build.rs" + +[dependencies] +anyhow = "1.0.89" +askama = { version = "0.12.1", default-features = false } +clap = { version = "4.5.18", features = ["derive"] } +cosmwasm-schema = { version = "=2.2.0-rc.1", path = "../schema" } +cw-schema = { version = "=2.2.0-rc.1", path = "../cw-schema" } +either = "1.13.0" +frunk = "0.4.3" +frunk_core = "0.4.3" +heck = "0.5.0" +log = "0.4.22" +mimalloc = "0.1.43" +serde_json = "1.0.128" +simple_logger = { version = "5.0.0", features = ["stderr"] } + +[dev-dependencies] +arbitrary = { version = "=1.3.2", features = ["derive"] } +derive_arbitrary = "=1.3.2" +insta = "1.40.0" +rand = { version = "0.8.5", features = ["min_const_gen"] } +serde = { workspace = true, features = ["derive"] } +serde_json = "1.0.128" +tempfile = "3.14.0" diff --git a/packages/cw-schema-codegen/build.rs b/packages/cw-schema-codegen/build.rs new file mode 100644 index 0000000000..73f98cda43 --- /dev/null +++ b/packages/cw-schema-codegen/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rerun-if-changed=templates"); +} diff --git a/packages/cw-schema-codegen/src/go/mod.rs b/packages/cw-schema-codegen/src/go/mod.rs new file mode 100644 index 0000000000..c7f129b94d --- /dev/null +++ b/packages/cw-schema-codegen/src/go/mod.rs @@ -0,0 +1,160 @@ +use self::template::{ + EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, +}; +use heck::ToPascalCase; +use std::{borrow::Cow, io}; + +pub mod template; + +fn expand_node_name<'a>( + schema: &'a cw_schema::SchemaV1, + node: &'a cw_schema::Node, +) -> Cow<'a, str> { + match node.value { + cw_schema::NodeType::Array { items } => { + let items = &schema.definitions[items]; + format!("[]{}", expand_node_name(schema, items)).into() + } + cw_schema::NodeType::Float => "float32".into(), + cw_schema::NodeType::Double => "float64".into(), + cw_schema::NodeType::Boolean => "bool".into(), + cw_schema::NodeType::String => "string".into(), + cw_schema::NodeType::Integer { signed, precision } => { + let ty = if signed { "int" } else { "uint" }; + format!("{ty}{precision}").into() + } + cw_schema::NodeType::Binary => "[]byte".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("{}", expand_node_name(schema, inner)).into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { items: _ } => { + /*let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("({})", items).into()*/ + "[]interface{}".into() + } + cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + + cw_schema::NodeType::Decimal { + precision: _, + signed: _, + } => { + // ToDo: Actually use a decimal type here + "string".into() + } + cw_schema::NodeType::Address => "Address".into(), + cw_schema::NodeType::Checksum => "string".into(), + cw_schema::NodeType::HexBinary => { + // ToDo: Actually use a hex-encoded binary type here + "string".into() + } + cw_schema::NodeType::Timestamp => "string".into(), + cw_schema::NodeType::Unit => "struct{}".into(), + } +} + +fn prepare_docs(desc: Option<&str>) -> Cow<'_, [Cow<'_, str>]> { + desc.map(|desc| { + desc.lines() + .map(|line| line.replace('"', "\\\"").into()) + .collect() + }) + .unwrap_or(Cow::Borrowed(&[])) +} + +pub fn process_node( + output: &mut O, + schema: &cw_schema::SchemaV1, + node: &cw_schema::Node, + add_package: bool, +) -> io::Result<()> +where + O: io::Write, +{ + match node.value { + cw_schema::NodeType::Struct(ref sty) => { + let structt = StructTemplate { + add_package, + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + ty: match sty { + cw_schema::StructType::Unit => TypeTemplate::Unit, + cw_schema::StructType::Named { ref properties } => TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Owned(name.to_pascal_case()), + rename: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name(schema, &schema.definitions[prop.value]), + }) + .collect(), + }, + cw_schema::StructType::Tuple { ref items } => TypeTemplate::Tuple( + items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect(), + ), + }, + }; + + writeln!(output, "{structt}")?; + } + cw_schema::NodeType::Enum { ref cases, .. } => { + let enumm = EnumTemplate { + add_package, + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + variants: cases + .iter() + .map(|(name, case)| EnumVariantTemplate { + name: name.to_pascal_case().into(), + rename: Cow::Borrowed(name), + docs: prepare_docs(case.description.as_deref()), + ty: match case.value { + cw_schema::EnumValue::Unit => TypeTemplate::Unit, + cw_schema::EnumValue::Tuple { ref items } => { + let items = items + .iter() + .map(|item| { + expand_node_name(schema, &schema.definitions[*item]) + }) + .collect(); + + TypeTemplate::Tuple(items) + } + cw_schema::EnumValue::Named { ref properties, .. } => { + TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Owned(name.to_pascal_case()), + rename: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name( + schema, + &schema.definitions[prop.value], + ), + }) + .collect(), + } + } + }, + }) + .collect(), + }; + + writeln!(output, "{enumm}")?; + } + _ => (), + } + + Ok(()) +} diff --git a/packages/cw-schema-codegen/src/go/template.rs b/packages/cw-schema-codegen/src/go/template.rs new file mode 100644 index 0000000000..cfdf50a457 --- /dev/null +++ b/packages/cw-schema-codegen/src/go/template.rs @@ -0,0 +1,45 @@ +use askama::Template; +use std::borrow::Cow; + +#[derive(Clone)] +pub struct EnumVariantTemplate<'a> { + pub name: Cow<'a, str>, + pub rename: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: TypeTemplate<'a>, +} + +#[derive(Template)] +#[template(escape = "none", path = "go/enum.tpl.go")] +pub struct EnumTemplate<'a> { + pub add_package: bool, + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub variants: Cow<'a, [EnumVariantTemplate<'a>]>, +} + +#[derive(Clone)] +pub struct FieldTemplate<'a> { + pub name: Cow<'a, str>, + pub rename: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: Cow<'a, str>, +} + +#[derive(Clone)] +pub enum TypeTemplate<'a> { + Unit, + Tuple(Cow<'a, [Cow<'a, str>]>), + Named { + fields: Cow<'a, [FieldTemplate<'a>]>, + }, +} + +#[derive(Template)] +#[template(escape = "none", path = "go/struct.tpl.go")] +pub struct StructTemplate<'a> { + pub add_package: bool, + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: TypeTemplate<'a>, +} diff --git a/packages/cw-schema-codegen/src/lib.rs b/packages/cw-schema-codegen/src/lib.rs new file mode 100644 index 0000000000..224f90fb84 --- /dev/null +++ b/packages/cw-schema-codegen/src/lib.rs @@ -0,0 +1,4 @@ +pub mod go; +pub mod python; +pub mod rust; +pub mod typescript; diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs new file mode 100644 index 0000000000..2677ea7173 --- /dev/null +++ b/packages/cw-schema-codegen/src/main.rs @@ -0,0 +1,144 @@ +#[macro_use] +extern crate anyhow; + +#[macro_use] +extern crate log; + +use clap::{Parser, ValueEnum}; +use std::{ + collections::HashSet, + fs::{self, File}, + io::{self, Write}, + path::PathBuf, +}; + +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + +#[derive(Clone, Copy, Debug, Default, PartialEq, ValueEnum)] +pub enum Language { + #[default] + Rust, + Go, + Python, + Typescript, +} + +#[derive(Parser)] +#[clap(about, author, version)] +/// Official CosmWasm codegen tool +struct Opts { + #[clap(default_value_t, long, short, value_enum)] + /// Programming language to generate code for + language: Language, + + #[clap(long, short)] + /// Path to the schema file + file: PathBuf, + + #[clap(long, short)] + /// Path to the output file + output: Option, +} + +impl Opts { + fn output(&self) -> anyhow::Result { + let io_out = if let Some(ref path) = self.output { + either::Left(File::create(path)?) + } else { + either::Right(io::stdout().lock()) + }; + + Ok(io_out) + } +} + +fn generate_defs( + output: &mut W, + language: Language, + schema: &cw_schema::Schema, + add_imports_or_package: bool, +) -> anyhow::Result<()> +where + W: io::Write, +{ + let cw_schema::Schema::V1(schema) = schema else { + bail!("Only schema version 1 is supported") + }; + + schema.definitions.iter().try_for_each(|node| { + debug!("Processing node: {node:?}"); + + match language { + Language::Rust => cw_schema_codegen::rust::process_node(output, schema, node), + Language::Typescript => { + cw_schema_codegen::typescript::process_node(output, schema, node, add_imports_or_package) + } + Language::Python => cw_schema_codegen::python::process_node(output, schema, node), + Language::Go => cw_schema_codegen::go::process_node(output, schema, node, add_imports_or_package), + } + })?; + + Ok(()) +} + +fn main() -> anyhow::Result<()> { + simple_logger::SimpleLogger::new() + .without_timestamps() + .with_level(log::LevelFilter::Info) + .env() + .init()?; + + let opts: Opts = Opts::parse(); + info!( + "Generating code for {:?} from {:?}", + opts.language, opts.file + ); + + ensure!(opts.file.exists(), "Schema file does not exist"); + ensure!( + matches!( + opts.language, + Language::Rust | Language::Go | Language::Typescript + ), + "Only Rust, TypeScript, and Go code generation is supported at the moment" + ); + + let schema = fs::read_to_string(&opts.file)?; + let schema: cosmwasm_schema::JsonCwApi = serde_json::from_str(&schema)?; + + let mut output = opts.output()?; + + if let Some(ref instantiate) = schema.instantiate { + generate_defs(&mut output, opts.language, instantiate, true)?; + } + + if let Some(ref execute) = schema.execute { + generate_defs(&mut output, opts.language, execute, false)?; + } + + if let Some(ref query) = schema.query { + generate_defs(&mut output, opts.language, query, false)?; + } + + if let Some(ref migrate) = schema.migrate { + generate_defs(&mut output, opts.language, migrate, false)?; + } + + if let Some(ref sudo) = schema.sudo { + generate_defs(&mut output, opts.language, sudo, false)?; + } + + if let Some(ref responses) = schema.responses { + let responses = responses + .iter() + .map(|(_name, response)| response) + .collect::>(); + + for response in responses { + generate_defs(&mut output, opts.language, response, false)?; + } + } + + Ok(()) +} diff --git a/packages/cw-schema-codegen/src/python/mod.rs b/packages/cw-schema-codegen/src/python/mod.rs new file mode 100644 index 0000000000..07ac50a31a --- /dev/null +++ b/packages/cw-schema-codegen/src/python/mod.rs @@ -0,0 +1,136 @@ +use self::template::{ + EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, +}; +use std::{borrow::Cow, io}; + +pub mod template; + +fn expand_node_name<'a>( + schema: &'a cw_schema::SchemaV1, + node: &'a cw_schema::Node, +) -> Cow<'a, str> { + match node.value { + cw_schema::NodeType::Array { items } => { + let items = &schema.definitions[items]; + format!("{}[]", expand_node_name(schema, items)).into() + } + cw_schema::NodeType::Float => "float".into(), + cw_schema::NodeType::Double => "float".into(), + cw_schema::NodeType::Boolean => "bool".into(), + cw_schema::NodeType::String => "str".into(), + cw_schema::NodeType::Integer { .. } => "int".into(), + cw_schema::NodeType::Binary => "bytes".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("typing.Optional[{}]", expand_node_name(schema, inner)).into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { ref items } => { + let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("[{}]", items).into() + } + cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + + cw_schema::NodeType::Decimal { .. } => "decimal.Decimal".into(), + cw_schema::NodeType::Address => "str".into(), + cw_schema::NodeType::Checksum => todo!(), + cw_schema::NodeType::HexBinary => todo!(), + cw_schema::NodeType::Timestamp => todo!(), + cw_schema::NodeType::Unit => "None".into(), + } +} + +fn prepare_docs(desc: Option<&str>) -> Cow<'_, [Cow<'_, str>]> { + desc.map(|desc| desc.lines().map(Into::into).collect()) + .unwrap_or(Cow::Borrowed(&[])) +} + +pub fn process_node( + output: &mut O, + schema: &cw_schema::SchemaV1, + node: &cw_schema::Node, +) -> io::Result<()> +where + O: io::Write, +{ + match node.value { + cw_schema::NodeType::Struct(ref sty) => { + let structt = StructTemplate { + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + ty: match sty { + cw_schema::StructType::Unit => TypeTemplate::Unit, + cw_schema::StructType::Named { ref properties } => TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name(schema, &schema.definitions[prop.value]), + }) + .collect(), + }, + cw_schema::StructType::Tuple { ref items } => TypeTemplate::Tuple( + items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect(), + ), + }, + }; + + writeln!(output, "{structt}")?; + } + cw_schema::NodeType::Enum { ref cases, .. } => { + let enumm = EnumTemplate { + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + variants: cases + .iter() + .map(|(name, case)| EnumVariantTemplate { + name: name.clone(), + docs: prepare_docs(case.description.as_deref()), + ty: match case.value { + cw_schema::EnumValue::Unit => TypeTemplate::Unit, + cw_schema::EnumValue::Tuple { ref items } => { + let items = items + .iter() + .map(|item| { + expand_node_name(schema, &schema.definitions[*item]) + }) + .collect(); + + TypeTemplate::Tuple(items) + } + cw_schema::EnumValue::Named { ref properties, .. } => { + TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name( + schema, + &schema.definitions[prop.value], + ), + }) + .collect(), + } + } + }, + }) + .collect(), + }; + + writeln!(output, "{enumm}")?; + } + _ => (), + } + + Ok(()) +} diff --git a/packages/cw-schema-codegen/src/python/template.rs b/packages/cw-schema-codegen/src/python/template.rs new file mode 100644 index 0000000000..11b860ed92 --- /dev/null +++ b/packages/cw-schema-codegen/src/python/template.rs @@ -0,0 +1,41 @@ +use askama::Template; +use std::borrow::Cow; + +#[derive(Clone)] +pub struct EnumVariantTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: TypeTemplate<'a>, +} + +#[derive(Template)] +#[template(escape = "none", path = "python/enum.tpl.py")] +pub struct EnumTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub variants: Cow<'a, [EnumVariantTemplate<'a>]>, +} + +#[derive(Clone)] +pub struct FieldTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: Cow<'a, str>, +} + +#[derive(Clone)] +pub enum TypeTemplate<'a> { + Unit, + Tuple(Cow<'a, [Cow<'a, str>]>), + Named { + fields: Cow<'a, [FieldTemplate<'a>]>, + }, +} + +#[derive(Template)] +#[template(escape = "none", path = "python/struct.tpl.py")] +pub struct StructTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: TypeTemplate<'a>, +} diff --git a/packages/cw-schema-codegen/src/rust/mod.rs b/packages/cw-schema-codegen/src/rust/mod.rs new file mode 100644 index 0000000000..d651b0e512 --- /dev/null +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -0,0 +1,154 @@ +use self::template::{ + EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, +}; +use heck::ToPascalCase; +use std::{borrow::Cow, io}; + +pub mod template; + +fn expand_node_name<'a>( + schema: &'a cw_schema::SchemaV1, + node: &'a cw_schema::Node, +) -> Cow<'a, str> { + match node.value { + cw_schema::NodeType::Array { items } => { + let items = &schema.definitions[items]; + format!("Vec<{}>", expand_node_name(schema, items)).into() + } + cw_schema::NodeType::Float => "f32".into(), + cw_schema::NodeType::Double => "f64".into(), + cw_schema::NodeType::Boolean => "bool".into(), + cw_schema::NodeType::String => "String".into(), + cw_schema::NodeType::Integer { signed, precision } => { + let ty = if signed { "i" } else { "u" }; + format!("{ty}{precision}").into() + } + cw_schema::NodeType::Binary => "Vec".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("Option<{}>", expand_node_name(schema, inner)).into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { ref items } => { + let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("({})", items).into() + } + cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + + cw_schema::NodeType::Decimal { + precision: _, + signed: _, + } => { + // ToDo: Actually use a decimal type here + "String".into() + } + cw_schema::NodeType::Address => "cosmrs::AccountId".into(), + cw_schema::NodeType::Checksum => "cosmrs::tendermint::Hash".into(), + cw_schema::NodeType::HexBinary => { + // ToDo: Actually use a hex-encoded binary type here + "String".into() + } + cw_schema::NodeType::Timestamp => "cosmrs::tendermint::Time".into(), + cw_schema::NodeType::Unit => "()".into(), + } +} + +fn prepare_docs(desc: Option<&str>) -> Cow<'_, [Cow<'_, str>]> { + desc.map(|desc| { + desc.lines() + .map(|line| line.replace('"', "\\\"").into()) + .collect() + }) + .unwrap_or(Cow::Borrowed(&[])) +} + +pub fn process_node( + output: &mut O, + schema: &cw_schema::SchemaV1, + node: &cw_schema::Node, +) -> io::Result<()> +where + O: io::Write, +{ + match node.value { + cw_schema::NodeType::Struct(ref sty) => { + let structt = StructTemplate { + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + ty: match sty { + cw_schema::StructType::Unit => TypeTemplate::Unit, + cw_schema::StructType::Named { ref properties } => TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name(schema, &schema.definitions[prop.value]), + }) + .collect(), + }, + cw_schema::StructType::Tuple { ref items } => TypeTemplate::Tuple( + items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect(), + ), + }, + }; + + writeln!(output, "{structt}")?; + } + cw_schema::NodeType::Enum { ref cases, .. } => { + let enumm = EnumTemplate { + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + variants: cases + .iter() + .map(|(name, case)| EnumVariantTemplate { + name: name.to_pascal_case().into(), + docs: prepare_docs(case.description.as_deref()), + serde_rename: Some(name.clone()), + ty: match case.value { + cw_schema::EnumValue::Unit => TypeTemplate::Unit, + cw_schema::EnumValue::Tuple { ref items } => { + let items = items + .iter() + .map(|item| { + expand_node_name(schema, &schema.definitions[*item]) + }) + .collect(); + + TypeTemplate::Tuple(items) + } + cw_schema::EnumValue::Named { ref properties, .. } => { + TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name( + schema, + &schema.definitions[prop.value], + ), + }) + .collect(), + } + } + }, + }) + .collect(), + }; + + writeln!(output, "{enumm}")?; + } + _ => (), + } + + Ok(()) +} diff --git a/packages/cw-schema-codegen/src/rust/template.rs b/packages/cw-schema-codegen/src/rust/template.rs new file mode 100644 index 0000000000..987165c7fe --- /dev/null +++ b/packages/cw-schema-codegen/src/rust/template.rs @@ -0,0 +1,42 @@ +use askama::Template; +use std::borrow::Cow; + +#[derive(Clone)] +pub struct EnumVariantTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub serde_rename: Option>, + pub ty: TypeTemplate<'a>, +} + +#[derive(Template)] +#[template(escape = "none", path = "rust/enum.tpl.rs")] +pub struct EnumTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub variants: Cow<'a, [EnumVariantTemplate<'a>]>, +} + +#[derive(Clone)] +pub struct FieldTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: Cow<'a, str>, +} + +#[derive(Clone)] +pub enum TypeTemplate<'a> { + Unit, + Tuple(Cow<'a, [Cow<'a, str>]>), + Named { + fields: Cow<'a, [FieldTemplate<'a>]>, + }, +} + +#[derive(Template)] +#[template(escape = "none", path = "rust/struct.tpl.rs")] +pub struct StructTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: TypeTemplate<'a>, +} diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs new file mode 100644 index 0000000000..91608f5dac --- /dev/null +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -0,0 +1,149 @@ +use self::template::{ + EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, +}; +use std::{borrow::Cow, io}; + +pub mod template; + +fn expand_node_name<'a>( + schema: &'a cw_schema::SchemaV1, + node: &'a cw_schema::Node, +) -> Cow<'a, str> { + match node.value { + cw_schema::NodeType::Array { items } => { + let items = &schema.definitions[items]; + format!("z.array({})", expand_node_name(schema, items)).into() + } + cw_schema::NodeType::Float => "z.number()".into(), + cw_schema::NodeType::Double => "z.number()".into(), + cw_schema::NodeType::Boolean => "z.boolean()".into(), + cw_schema::NodeType::String => "z.string()".into(), + cw_schema::NodeType::Integer { .. } => "z.string().or(z.number())".into(), + cw_schema::NodeType::Binary => "z.instanceof(Uint8Array)".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("{}.optional()", expand_node_name(schema, inner)).into() + } + + cw_schema::NodeType::Struct(..) => format!("{}Schema", node.name).into(), + cw_schema::NodeType::Tuple { ref items } => { + let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("[{}]", items).into() + } + cw_schema::NodeType::Enum { .. } => format!("{}Schema", node.name).into(), + + cw_schema::NodeType::Decimal { .. } => "z.string()".into(), + cw_schema::NodeType::Address => "z.string()".into(), + cw_schema::NodeType::Checksum => { + // ToDo: Use actual checksum types + "z.string()".into() + } + cw_schema::NodeType::HexBinary => { + // ToDo: Actually use a binary decoding hex type + "z.string()".into() + } + cw_schema::NodeType::Timestamp => { + // ToDo: Replace with better type + "z.string()".into() + } + cw_schema::NodeType::Unit => "z.void()".into(), + } +} + +fn prepare_docs(desc: Option<&str>) -> Cow<'_, [Cow<'_, str>]> { + desc.map(|desc| desc.lines().map(Into::into).collect()) + .unwrap_or(Cow::Borrowed(&[])) +} + +pub fn process_node( + output: &mut O, + schema: &cw_schema::SchemaV1, + node: &cw_schema::Node, + add_imports: bool, +) -> io::Result<()> +where + O: io::Write, +{ + match node.value { + cw_schema::NodeType::Struct(ref sty) => { + let structt = StructTemplate { + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + ty: match sty { + cw_schema::StructType::Unit => TypeTemplate::Unit, + cw_schema::StructType::Named { ref properties } => TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name(schema, &schema.definitions[prop.value]), + }) + .collect(), + }, + cw_schema::StructType::Tuple { ref items } => TypeTemplate::Tuple( + items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect(), + ), + }, + add_imports, + }; + + writeln!(output, "{structt}")?; + } + cw_schema::NodeType::Enum { ref cases, .. } => { + let enumm = EnumTemplate { + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + variants: cases + .iter() + .map(|(name, case)| EnumVariantTemplate { + name: name.clone(), + docs: prepare_docs(case.description.as_deref()), + ty: match case.value { + cw_schema::EnumValue::Unit => TypeTemplate::Unit, + cw_schema::EnumValue::Tuple { ref items } => { + let items = items + .iter() + .map(|item| { + expand_node_name(schema, &schema.definitions[*item]) + }) + .collect(); + + TypeTemplate::Tuple(items) + } + cw_schema::EnumValue::Named { ref properties, .. } => { + TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name( + schema, + &schema.definitions[prop.value], + ), + }) + .collect(), + } + } + }, + }) + .collect(), + add_imports, + }; + + writeln!(output, "{enumm}")?; + } + _ => (), + } + + Ok(()) +} diff --git a/packages/cw-schema-codegen/src/typescript/template.rs b/packages/cw-schema-codegen/src/typescript/template.rs new file mode 100644 index 0000000000..89af73e396 --- /dev/null +++ b/packages/cw-schema-codegen/src/typescript/template.rs @@ -0,0 +1,43 @@ +use askama::Template; +use std::borrow::Cow; + +#[derive(Clone)] +pub struct EnumVariantTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: TypeTemplate<'a>, +} + +#[derive(Template)] +#[template(escape = "none", path = "typescript/enum.tpl.ts")] +pub struct EnumTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub variants: Cow<'a, [EnumVariantTemplate<'a>]>, + pub add_imports: bool, +} + +#[derive(Clone)] +pub struct FieldTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: Cow<'a, str>, +} + +#[derive(Clone)] +pub enum TypeTemplate<'a> { + Unit, + Tuple(Cow<'a, [Cow<'a, str>]>), + Named { + fields: Cow<'a, [FieldTemplate<'a>]>, + }, +} + +#[derive(Template)] +#[template(escape = "none", path = "typescript/struct.tpl.ts")] +pub struct StructTemplate<'a> { + pub name: Cow<'a, str>, + pub docs: Cow<'a, [Cow<'a, str>]>, + pub ty: TypeTemplate<'a>, + pub add_imports: bool, +} diff --git a/packages/cw-schema-codegen/templates/go/enum.tpl.go b/packages/cw-schema-codegen/templates/go/enum.tpl.go new file mode 100644 index 0000000000..ac8df8c3f6 --- /dev/null +++ b/packages/cw-schema-codegen/templates/go/enum.tpl.go @@ -0,0 +1,39 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +{% if add_package %} +package cwcodegen + +import ( + "github.com/cosmos/cosmos-sdk/types/address" +) +{% endif %} + +{% for variant in variants %} +{% match variant.ty %} +{% when TypeTemplate::Unit %} +type {{ name }}{{ variant.name }} struct{} +{% when TypeTemplate::Tuple(types) %} +type {{ name }}{{ variant.name }} []interface{} +{% when TypeTemplate::Named { fields } %} +type {{ name }}{{ variant.name }} struct { + {% for field in fields %} + {% for doc in docs %} + // {{ doc }} + {% endfor %} + {{ field.name }} {{ field.ty }} `json:"{{ field.rename }}"` + {% endfor %} +} +{% endmatch %} +{% endfor %} + +{% for doc in docs %} + // {{ doc }} +{% endfor %} +type {{ name }} struct { +{% for variant in variants %} +{% for doc in docs %} + // {{ doc }} +{% endfor %} + {{ variant.name}} {{ name }}{{ variant.name }} `json:"{{ variant.rename }}"` +{% endfor %} +} diff --git a/packages/cw-schema-codegen/templates/go/struct.tpl.go b/packages/cw-schema-codegen/templates/go/struct.tpl.go new file mode 100644 index 0000000000..0a405140e6 --- /dev/null +++ b/packages/cw-schema-codegen/templates/go/struct.tpl.go @@ -0,0 +1,28 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +{% if add_package %} +package cwcodegen + +import ( + "github.com/cosmos/cosmos-sdk/types" +) +{% endif %} + +{% for doc in docs %} + // {{ doc }} +{% endfor %} +{% match ty %} +{% when TypeTemplate::Unit %} +type {{ name }} struct{} +{% when TypeTemplate::Tuple with (types) %} +type {{ name }} []interface{} /* todo: replace with true tuples if i can think of it */ +{% when TypeTemplate::Named with { fields } %} +type {{ name }} struct { +{% for field in fields %} +{% for doc in docs %} + // {{ doc }} +{% endfor %} + {{ field.name }} {{ field.ty }} `json:"{{ field.rename }}"` +{% endfor %} +} +{% endmatch %} diff --git a/packages/cw-schema-codegen/templates/python/enum.tpl.py b/packages/cw-schema-codegen/templates/python/enum.tpl.py new file mode 100644 index 0000000000..5f647687ef --- /dev/null +++ b/packages/cw-schema-codegen/templates/python/enum.tpl.py @@ -0,0 +1,41 @@ +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + +class {{ name }}(RootModel): + """{% for doc in docs %} + {{ doc }} + {% endfor %}""" + +{% for variant in variants %} +{% match variant.ty %} +{% when TypeTemplate::Unit %} + class {{ variant.name }}(RootModel): + """{% for doc in variant.docs %} + {{ doc }} + {% endfor %}""" + root: typing.Literal['{{ variant.name }}'] +{% when TypeTemplate::Tuple with (types) %} + class {{ variant.name }}(BaseModel): + """{% for doc in variant.docs %} + {{ doc }} + {% endfor %}""" + {{ variant.name }}: typing.Tuple[{{ types|join(", ") }}] +{% when TypeTemplate::Named with { fields } %} + class {{ variant.name }}(BaseModel): + class __Inner(BaseModel): + """{% for doc in variant.docs %} + {{ doc }} + {% endfor %}""" + {% for field in fields %} + {{ field.name }}: {{ field.ty }} + """{% for doc in field.docs %} + {{ doc }} + {% endfor %}""" + {% endfor %} + {{ variant.name }}: __Inner +{% endmatch %} +{% endfor %} + root: typing.Union[ {% for variant in variants %} {{ variant.name }}, {% endfor %} ] \ No newline at end of file diff --git a/packages/cw-schema-codegen/templates/python/struct.tpl.py b/packages/cw-schema-codegen/templates/python/struct.tpl.py new file mode 100644 index 0000000000..c565beda4a --- /dev/null +++ b/packages/cw-schema-codegen/templates/python/struct.tpl.py @@ -0,0 +1,32 @@ +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + + +{% match ty %} +{% when TypeTemplate::Unit %} +class {{ name }}(RootModel): + '''{% for doc in docs %} + {{ doc }} + {% endfor %}''' + root: None +{% when TypeTemplate::Tuple with (types) %} +class {{ name }}(RootModel): + '''{% for doc in docs %} + {{ doc }} + {% endfor %}''' + root: typing.Tuple[{{ types|join(", ") }}] +{% when TypeTemplate::Named with { fields } %} +class {{ name }}(BaseModel): + '''{% for doc in docs %} + {{ doc }} + {% endfor %}''' + {% for field in fields %} + {{ field.name }}: {{ field.ty }} + '''{% for doc in field.docs %} + # {{ doc }} + {% endfor %}''' + {% endfor %} +{% endmatch %} diff --git a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs new file mode 100644 index 0000000000..9f3d66dc98 --- /dev/null +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -0,0 +1,39 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +{% for doc in docs %} + #[doc = "{{ doc }}"] +{% endfor %} + +#[cosmwasm_schema::cw_serde] +pub enum {{ name }} { +{% for variant in variants %} +{% for doc in variant.docs %} + #[doc = "{{ doc }}"] +{% endfor %} + +{% match variant.serde_rename %} +{% when Some with (rename) %} + #[serde(rename = "{{ rename }}")] +{% when None %} +{% endmatch %} + + {{ variant.name }} +{% match variant.ty %} +{% when TypeTemplate::Unit %} +{% when TypeTemplate::Tuple with (types) %} + ( + {{ types|join(", ") }} + ) +{% when TypeTemplate::Named with { fields } %} + { + {% for field in fields %} + {% for doc in field.docs %} + #[doc = "{{ doc }}"] + {% endfor %} + {{ field.name }}: {{ field.ty }}, + {% endfor %} + } +{% endmatch %} + , +{% endfor %} +} \ No newline at end of file diff --git a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs new file mode 100644 index 0000000000..e256157394 --- /dev/null +++ b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs @@ -0,0 +1,27 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +{% for doc in docs %} +#[doc = "{{ doc }}"] +{% endfor %} + +#[cosmwasm_schema::cw_serde] +pub struct {{ name }} + +{% match ty %} +{% when TypeTemplate::Unit %} +; +{% when TypeTemplate::Tuple with (types) %} +( + {{ types|join(", ") }} +); +{% when TypeTemplate::Named with { fields } %} +{ +{% for field in fields %} +{% for doc in field.docs %} + #[doc = "{{ doc }}"] +{% endfor %} + + {{ field.name }}: {{ field.ty }}, +{% endfor %} +} +{% endmatch %} diff --git a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts new file mode 100644 index 0000000000..8d794509ac --- /dev/null +++ b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts @@ -0,0 +1,48 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +{% if add_imports %} +import { z } from 'zod'; +{% endif %} + +/** +{% for doc in docs %} + * {{ doc }} +{% endfor %} + */ + +const {{ name }}Schema = z.union([ +{% for variant in variants %} + /** + {% for doc in variant.docs %} + * {{ doc }} + {% endfor %} + */ + +{% match variant.ty %} +{% when TypeTemplate::Unit %} + z.object({ "{{ variant.name }}": z.null() }).or(z.literal("{{ variant.name }}")), +{% when TypeTemplate::Tuple with (types) %} + z.object({ "{{ variant.name }}": z.tuple([{{ types|join(", ") }}]) }), +{% when TypeTemplate::Named with { fields } %} + z.object({ "{{ variant.name }}": z.object({ +{% for field in fields %} + /** + {% for doc in field.docs %} + * {{ doc }} + {% endfor %} + */ + + {{ field.name }}: {{ field.ty }}, +{% endfor %} +}) }), +{% endmatch %} +{% endfor %} + +{% if variants.len() == 0 %} +never; +{% endif %} +]); + +type {{ name }} = z.infer; + +export { {{ name }}, {{ name }}Schema }; diff --git a/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts new file mode 100644 index 0000000000..a6bd159cbe --- /dev/null +++ b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts @@ -0,0 +1,36 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +{% if add_imports %} +import { z } from 'zod'; +{% endif %} + +/** +{% for doc in docs %} + * {{ doc }} +{% endfor %} + */ + +const {{ name }}Schema = +{% match ty %} +{% when TypeTemplate::Unit %} + z.null() +{% when TypeTemplate::Tuple with (types) %} + z.tuple([{{ types|join(", ") }}]) +{% when TypeTemplate::Named with { fields } %} + z.object({ +{% for field in fields %} + /** + {% for doc in field.docs %} + * {{ doc }} + {% endfor %} + */ + + {{ field.name }}: {{ field.ty }}, +{% endfor %} +}) +{% endmatch %} +; + +type {{ name }} = z.infer; + +export { {{ name }}, {{ name }}Schema }; diff --git a/packages/cw-schema-codegen/tests/python_tpl.rs b/packages/cw-schema-codegen/tests/python_tpl.rs new file mode 100644 index 0000000000..60764c8cad --- /dev/null +++ b/packages/cw-schema-codegen/tests/python_tpl.rs @@ -0,0 +1,156 @@ +use cw_schema::Schemaifier; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +#[derive(Schemaifier, Serialize, Deserialize)] +pub enum SomeEnum { + Field1, + Field2(u32, u32), + Field3 { a: String, b: u32 }, + // Field4(Box), // TODO tkulik: Do we want to support Box ? + // Field5 { a: Box }, +} + +#[derive(Schemaifier, Serialize, Deserialize)] +pub struct UnitStructure; + +#[derive(Schemaifier, Serialize, Deserialize)] +pub struct TupleStructure(u32, String, u128); + +#[derive(Schemaifier, Serialize, Deserialize)] +pub struct NamedStructure { + a: String, + b: u8, + c: SomeEnum, +} + +#[test] +fn simple_enum() { + // generate the schemas for each of the above types + let schemas = [ + cw_schema::schema_of::(), + cw_schema::schema_of::(), + cw_schema::schema_of::(), + cw_schema::schema_of::(), + ]; + + // run the codegen to typescript + for schema in schemas { + let cw_schema::Schema::V1(schema) = schema else { + panic!(); + }; + + let output = schema + .definitions + .iter() + .map(|node| { + let mut buf = Vec::new(); + cw_schema_codegen::python::process_node(&mut buf, &schema, node).unwrap(); + String::from_utf8(buf).unwrap() + }) + .collect::(); + + insta::assert_snapshot!(output); + } +} + +macro_rules! validator { + ($typ:ty) => {{ + let a: Box = Box::new(|output| { + serde_json::from_str::<$typ>(output).unwrap(); + }); + a + }}; +} + +#[test] +fn assert_validity() { + let schemas = [ + ( + "SomeEnum", + cw_schema::schema_of::(), + serde_json::to_string(&SomeEnum::Field1).unwrap(), + validator!(SomeEnum), + ), + ( + "SomeEnum", + cw_schema::schema_of::(), + serde_json::to_string(&SomeEnum::Field2(10, 23)).unwrap(), + validator!(SomeEnum), + ), + ( + "SomeEnum", + cw_schema::schema_of::(), + serde_json::to_string(&SomeEnum::Field3 { + a: "sdf".to_string(), + b: 12, + }) + .unwrap(), + validator!(SomeEnum), + ), + ( + "UnitStructure", + cw_schema::schema_of::(), + serde_json::to_string(&UnitStructure {}).unwrap(), + validator!(UnitStructure), + ), + ( + "TupleStructure", + cw_schema::schema_of::(), + serde_json::to_string(&TupleStructure(10, "aasdf".to_string(), 2)).unwrap(), + validator!(TupleStructure), + ), + ( + "NamedStructure", + cw_schema::schema_of::(), + serde_json::to_string(&NamedStructure { + a: "awer".to_string(), + b: 4, + c: SomeEnum::Field1, + }) + .unwrap(), + validator!(NamedStructure), + ), + ]; + + for (type_name, schema, example, validator) in schemas { + let cw_schema::Schema::V1(schema) = schema else { + unreachable!(); + }; + + let schema_output = schema + .definitions + .iter() + .map(|node| { + let mut buf = Vec::new(); + cw_schema_codegen::python::process_node(&mut buf, &schema, node).unwrap(); + String::from_utf8(buf).unwrap() + }) + .collect::(); + + let mut file = tempfile::NamedTempFile::with_suffix(".py").unwrap(); + file.write_all(schema_output.as_bytes()).unwrap(); + file.write_all( + format!( + "import sys; print({type_name}.model_validate_json('{example}').model_dump_json())" + ) + .as_bytes(), + ) + .unwrap(); + file.flush().unwrap(); + + let output = std::process::Command::new("python") + .arg(file.path()) + .output() + .unwrap(); + + assert!( + output.status.success(), + "stdout: {stdout}, stderr: {stderr}\n\n schema:\n {schema_output}", + stdout = String::from_utf8_lossy(&output.stdout), + stderr = String::from_utf8_lossy(&output.stderr), + ); + + validator(&String::from_utf8_lossy(&output.stdout)) + } +} diff --git a/packages/cw-schema-codegen/tests/rust_tpl.rs b/packages/cw-schema-codegen/tests/rust_tpl.rs new file mode 100644 index 0000000000..3fdbf90c46 --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust_tpl.rs @@ -0,0 +1,133 @@ +use std::borrow::Cow; + +use askama::Template; +use cw_schema_codegen::rust::template::{ + EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, +}; + +#[test] +fn simple_enum() { + let tpl = EnumTemplate { + name: Cow::Borrowed("Simple"), + docs: Cow::Borrowed(&[Cow::Borrowed("Simple enum")]), + variants: Cow::Borrowed(&[ + EnumVariantTemplate { + name: Cow::Borrowed("One"), + docs: Cow::Borrowed(&[Cow::Borrowed("One variant")]), + serde_rename: None, + ty: TypeTemplate::Unit, + }, + EnumVariantTemplate { + name: Cow::Borrowed("Two"), + docs: Cow::Borrowed(&[Cow::Borrowed("Two variant")]), + serde_rename: None, + ty: TypeTemplate::Unit, + }, + ]), + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn complex_enum() { + let tpl = EnumTemplate { + name: Cow::Borrowed("Complex"), + docs: Cow::Borrowed(&[Cow::Borrowed("Complex enum")]), + variants: Cow::Borrowed(&[ + EnumVariantTemplate { + name: Cow::Borrowed("One"), + docs: Cow::Borrowed(&[Cow::Borrowed("One variant")]), + serde_rename: None, + ty: TypeTemplate::Tuple(Cow::Borrowed(&[Cow::Borrowed("u64")])), + }, + EnumVariantTemplate { + name: Cow::Borrowed("Two"), + docs: Cow::Borrowed(&[Cow::Borrowed("Two variant")]), + serde_rename: None, + ty: TypeTemplate::Named { + fields: Cow::Borrowed(&[ + FieldTemplate { + name: Cow::Borrowed("a"), + docs: Cow::Borrowed(&[Cow::Borrowed("Field a")]), + ty: Cow::Borrowed("u64"), + }, + FieldTemplate { + name: Cow::Borrowed("b"), + docs: Cow::Borrowed(&[Cow::Borrowed("Field b")]), + ty: Cow::Borrowed("String"), + }, + ]), + }, + }, + ]), + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn empty_enum() { + let tpl = EnumTemplate { + name: Cow::Borrowed("Empty"), + docs: Cow::Borrowed(&[Cow::Borrowed("Empty enum")]), + variants: Cow::Borrowed(&[]), + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn empty_struct() { + let tpl = StructTemplate { + name: Cow::Borrowed("Empty"), + docs: Cow::Borrowed(&[Cow::Borrowed("Empty struct")]), + ty: TypeTemplate::Unit, + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn tuple_struct() { + let tpl = StructTemplate { + name: Cow::Borrowed("Tuple"), + docs: Cow::Borrowed(&[Cow::Borrowed("Tuple struct")]), + ty: TypeTemplate::Tuple(Cow::Borrowed(&[ + Cow::Borrowed("u64"), + Cow::Borrowed("String"), + ])), + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn named_struct() { + let tpl = StructTemplate { + name: Cow::Borrowed("Named"), + docs: Cow::Borrowed(&[Cow::Borrowed("Named struct")]), + ty: TypeTemplate::Named { + fields: Cow::Borrowed(&[ + FieldTemplate { + name: Cow::Borrowed("a"), + docs: Cow::Borrowed(&[Cow::Borrowed("Field a")]), + ty: Cow::Borrowed("u64"), + }, + FieldTemplate { + name: Cow::Borrowed("b"), + docs: Cow::Borrowed(&[Cow::Borrowed("Field b")]), + ty: Cow::Borrowed("String"), + }, + ]), + }, + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} diff --git a/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap new file mode 100644 index 0000000000..a8a9224d14 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap @@ -0,0 +1,42 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: output +snapshot_kind: text +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + +class SomeEnum(RootModel): + """""" + + + + class Field1(RootModel): + """""" + root: typing.Literal['Field1'] + + + + class Field2(BaseModel): + """""" + Field2: typing.Tuple[int, int] + + + + class Field3(BaseModel): + class __Inner(BaseModel): + """""" + + a: str + """""" + + b: int + """""" + + Field3: __Inner + + + root: typing.Union[ Field1, Field2, Field3, ] diff --git a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap new file mode 100644 index 0000000000..e1c4a97580 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -0,0 +1,57 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +snapshot_kind: text +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + + #[doc = "Complex enum"] + + +#[cosmwasm_schema::cw_serde] +pub enum Complex { + + + #[doc = "One variant"] + + + + + + One + + ( + u64 + ) + + , + + + #[doc = "Two variant"] + + + + + + Two + + { + + + #[doc = "Field a"] + + + a: u64, + + + #[doc = "Field b"] + + + b: String, + + } + + , + +} diff --git a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap new file mode 100644 index 0000000000..cb79d17534 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap @@ -0,0 +1,15 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +snapshot_kind: text +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + + #[doc = "Empty enum"] + + +#[cosmwasm_schema::cw_serde] +pub enum Empty { + +} diff --git a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap new file mode 100644 index 0000000000..3103d42b2a --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap @@ -0,0 +1,16 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +snapshot_kind: text +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + + #[doc = "Empty struct"] + + +#[cosmwasm_schema::cw_serde] +pub struct Empty + + + ; diff --git a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap new file mode 100644 index 0000000000..dd3525ae08 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap @@ -0,0 +1,30 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +snapshot_kind: text +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + + #[doc = "Named struct"] + + +#[cosmwasm_schema::cw_serde] +pub struct Named + + + { + + + #[doc = "Field a"] + + + a: u64, + + + #[doc = "Field b"] + + + b: String, + + } diff --git a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap new file mode 100644 index 0000000000..e7ed6b8cf8 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -0,0 +1,39 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +snapshot_kind: text +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + + #[doc = "Simple enum"] + + +#[cosmwasm_schema::cw_serde] +pub enum Simple { + + + #[doc = "One variant"] + + + + + + One + + + , + + + #[doc = "Two variant"] + + + + + + Two + + + , + +} diff --git a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap new file mode 100644 index 0000000000..3586935564 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap @@ -0,0 +1,18 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +snapshot_kind: text +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + + #[doc = "Tuple struct"] + + +#[cosmwasm_schema::cw_serde] +pub struct Tuple + + + ( + u64, String + ); diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap new file mode 100644 index 0000000000..da104338bd --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap @@ -0,0 +1,23 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + +import { z } from 'zod'; + + +/** + + */ + +const UwuSchema = + + z.tuple([z.string(), z.string().or(z.number())]) + +; + +type Uwu = z.infer; + +export { Uwu, UwuSchema }; diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap new file mode 100644 index 0000000000..167853d6e5 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap @@ -0,0 +1,23 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + +import { z } from 'zod'; + + +/** + + */ + +const ÒwóSchema = + + z.null() + +; + +type Òwó = z.infer; + +export { Òwó, ÒwóSchema }; diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap new file mode 100644 index 0000000000..994b84dede --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap @@ -0,0 +1,25 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + +import { z } from 'zod'; + + +/** + + */ + +const EmptySchema = z.union([ + + + + never; + +]); + +type Empty = z.infer; + +export { Empty, EmptySchema }; diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap new file mode 100644 index 0000000000..4b30b45a2b --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap @@ -0,0 +1,55 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + +import { z } from 'zod'; + + +/** + + */ + +const HeheheSchema = z.union([ + + /** + + */ + + + z.object({ "A": z.null() }).or(z.literal("A")), + + + /** + + */ + + + z.object({ "B": z.tuple([z.string().or(z.number())]) }), + + + /** + + */ + + + z.object({ "C": z.object({ + + /** + + */ + + field: z.string(), + + }) }), + + + + +]); + +type Hehehe = z.infer; + +export { Hehehe, HeheheSchema }; diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap new file mode 100644 index 0000000000..83e4dae1e5 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap @@ -0,0 +1,37 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + +import { z } from 'zod'; + + +/** + + */ + +const OwoSchema = + + z.object({ + + /** + + */ + + field_1: z.string().or(z.number()), + + /** + + */ + + field_2: z.string(), + + }) + +; + +type Owo = z.infer; + +export { Owo, OwoSchema }; diff --git a/packages/cw-schema-codegen/tests/ts-e2e/.gitignore b/packages/cw-schema-codegen/tests/ts-e2e/.gitignore new file mode 100644 index 0000000000..83595e5566 --- /dev/null +++ b/packages/cw-schema-codegen/tests/ts-e2e/.gitignore @@ -0,0 +1,2 @@ +/node_modules +/src/gen.ts \ No newline at end of file diff --git a/packages/cw-schema-codegen/tests/ts-e2e/package-lock.json b/packages/cw-schema-codegen/tests/ts-e2e/package-lock.json new file mode 100644 index 0000000000..ffdeb6df5b --- /dev/null +++ b/packages/cw-schema-codegen/tests/ts-e2e/package-lock.json @@ -0,0 +1,575 @@ +{ + "name": "ts-e2e", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ts-e2e", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "zod": "^3.23.8" + }, + "devDependencies": { + "@types/node": "^22.9.3", + "tslib": "^2.8.1", + "tsx": "^4.19.2", + "typescript": "^5.7.2" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", + "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", + "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", + "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", + "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", + "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", + "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", + "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", + "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", + "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", + "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", + "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", + "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", + "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", + "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", + "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", + "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", + "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", + "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", + "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", + "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", + "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", + "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", + "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", + "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@types/node": { + "version": "22.9.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.3.tgz", + "integrity": "sha512-F3u1fs/fce3FFk+DAxbxc78DF8x0cY09RRL8GnXLmkJ1jvx3TtPdWoTT5/NiYfI5ASqXBmfqJi9dZ3gxMx4lzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.8" + } + }, + "node_modules/esbuild": { + "version": "0.23.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", + "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.23.1", + "@esbuild/android-arm": "0.23.1", + "@esbuild/android-arm64": "0.23.1", + "@esbuild/android-x64": "0.23.1", + "@esbuild/darwin-arm64": "0.23.1", + "@esbuild/darwin-x64": "0.23.1", + "@esbuild/freebsd-arm64": "0.23.1", + "@esbuild/freebsd-x64": "0.23.1", + "@esbuild/linux-arm": "0.23.1", + "@esbuild/linux-arm64": "0.23.1", + "@esbuild/linux-ia32": "0.23.1", + "@esbuild/linux-loong64": "0.23.1", + "@esbuild/linux-mips64el": "0.23.1", + "@esbuild/linux-ppc64": "0.23.1", + "@esbuild/linux-riscv64": "0.23.1", + "@esbuild/linux-s390x": "0.23.1", + "@esbuild/linux-x64": "0.23.1", + "@esbuild/netbsd-x64": "0.23.1", + "@esbuild/openbsd-arm64": "0.23.1", + "@esbuild/openbsd-x64": "0.23.1", + "@esbuild/sunos-x64": "0.23.1", + "@esbuild/win32-arm64": "0.23.1", + "@esbuild/win32-ia32": "0.23.1", + "@esbuild/win32-x64": "0.23.1" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-tsconfig": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.1.tgz", + "integrity": "sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, + "node_modules/tsx": { + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.2.tgz", + "integrity": "sha512-pOUl6Vo2LUq/bSa8S5q7b91cgNSjctn9ugq/+Mvow99qW6x/UZYwzxy/3NmqoT66eHYfCVvFvACC58UBPFf28g==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.23.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true, + "license": "MIT" + }, + "node_modules/zod": { + "version": "3.23.8", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", + "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/packages/cw-schema-codegen/tests/ts-e2e/package.json b/packages/cw-schema-codegen/tests/ts-e2e/package.json new file mode 100644 index 0000000000..9a6c923500 --- /dev/null +++ b/packages/cw-schema-codegen/tests/ts-e2e/package.json @@ -0,0 +1,22 @@ +{ + "name": "ts-e2e", + "version": "0.1.0", + "type": "module", + "main": "index.ts", + "private": true, + "scripts": { + "test": "tsx src/index.ts" + }, + "author": "", + "license": "MIT", + "description": "", + "devDependencies": { + "@types/node": "^22.9.3", + "tslib": "^2.8.1", + "tsx": "^4.19.2", + "typescript": "^5.7.2" + }, + "dependencies": { + "zod": "^3.23.8" + } +} diff --git a/packages/cw-schema-codegen/tests/ts-e2e/src/index.ts b/packages/cw-schema-codegen/tests/ts-e2e/src/index.ts new file mode 100644 index 0000000000..00ecd472c9 --- /dev/null +++ b/packages/cw-schema-codegen/tests/ts-e2e/src/index.ts @@ -0,0 +1,22 @@ +import * as gen from './gen'; +import process from 'node:process'; + +async function read(stream: NodeJS.ReadStream): Promise { + const chunks: any[] = []; + for await (const chunk of stream) chunks.push(chunk); + return Buffer.concat(chunks).toString('utf8'); +} + +const stdinString = await read(process.stdin); + +// Match based on the argument, then attempt to deserialize and validate. Then re-serialize and emit. +const typeName = process.argv[2]; +const deserialized = JSON.parse(stdinString); + +let validated = gen[typeName].parse(deserialized); +console.error(stdinString); +console.error(deserialized); +console.error(validated); + +const outputStream = process.stdout; +outputStream.write(JSON.stringify(validated)); diff --git a/packages/cw-schema-codegen/tests/ts-e2e/tsconfig.json b/packages/cw-schema-codegen/tests/ts-e2e/tsconfig.json new file mode 100644 index 0000000000..5910b38c60 --- /dev/null +++ b/packages/cw-schema-codegen/tests/ts-e2e/tsconfig.json @@ -0,0 +1,111 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "Es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "ES2022", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + "noImplicitAny": false, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/packages/cw-schema-codegen/tests/typescript.rs b/packages/cw-schema-codegen/tests/typescript.rs new file mode 100644 index 0000000000..1057f2db21 --- /dev/null +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -0,0 +1,194 @@ +use arbitrary::Arbitrary; +use core::str; +use cw_schema::Schemaifier; +use serde::{Deserialize, Serialize}; +use std::{ + fs::File, + io::Write, + process::{Command, Stdio}, +}; + +#[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] +struct Owo { + field_1: u32, + field_2: String, +} + +#[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] +struct Uwu(String, u32); + +#[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] +struct Òwó; + +#[derive(Schemaifier, Debug, Deserialize, PartialEq, Serialize)] +pub enum Empty {} + +#[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] +enum Hehehe { + A, + B(u32), + C { field: String }, +} + +#[derive(Debug, Deserialize, PartialEq, Serialize)] +#[serde(untagged)] +enum Combined { + Owo(Owo), + Uwu(Uwu), + Òwó(Òwó), + Empty(Empty), + Hehehe(Hehehe), +} + +macro_rules! impl_from { + ($ty:ident) => { + impl From<$ty> for Combined { + fn from(ty: $ty) -> Combined { + Combined::$ty(ty) + } + } + }; +} + +impl_from!(Owo); +impl_from!(Uwu); +impl_from!(Òwó); +impl_from!(Empty); +impl_from!(Hehehe); + +#[test] +fn codegen_snap() { + // generate the schemas for each of the above types + let schemas = [ + cw_schema::schema_of::(), + cw_schema::schema_of::(), + cw_schema::schema_of::<Òwó>(), + cw_schema::schema_of::(), + cw_schema::schema_of::(), + ]; + + // run the codegen to typescript + for schema in schemas { + let cw_schema::Schema::V1(schema) = schema else { + panic!(); + }; + + let output = schema + .definitions + .iter() + .map(|node| { + let mut buf = Vec::new(); + cw_schema_codegen::typescript::process_node(&mut buf, &schema, node, true).unwrap(); + String::from_utf8(buf).unwrap() + }) + .collect::(); + + insta::assert_snapshot!(output); + } +} + +fn wrap Arbitrary<'a> + Into>( + stuff: &mut arbitrary::Unstructured, +) -> Combined { + T::arbitrary(stuff).unwrap().into() +} + +fn type_name() -> String { + let name = std::any::type_name::().split(':').last().unwrap(); + format!("{name}Schema") +} + +#[test] +fn assert_validity() { + #[allow(clippy::type_complexity)] + let schemas: &[(_, fn(&mut arbitrary::Unstructured) -> Combined, _)] = &[ + ( + cw_schema::schema_of::(), + wrap::, + type_name::(), + ), + ( + cw_schema::schema_of::(), + wrap::, + type_name::(), + ), + ( + cw_schema::schema_of::<Òwó>(), + wrap::<Òwó>, + type_name::<Òwó>(), + ), + // `Empty` is a non-constructable type + /*( + cw_schema::schema_of::(), + wrap::, + type_name::(), + ),*/ + ( + cw_schema::schema_of::(), + wrap::, + type_name::(), + ), + ]; + + let e2e_dir = format!("{}/tests/ts-e2e", env!("CARGO_MANIFEST_DIR")); + let gen_file_path = format!("{}/src/gen.ts", e2e_dir); + + // make sure the dependencies are installed + let install_status = Command::new("npm") + .arg("i") + .current_dir(&e2e_dir) + .status() + .unwrap(); + assert!(install_status.success()); + + let random_data: [u8; 255] = rand::random(); + let mut unstructured = arbitrary::Unstructured::new(&random_data); + for (schema, arbitrary_gen, type_name) in schemas { + let cw_schema::Schema::V1(schema) = schema else { + unreachable!(); + }; + + let output = schema + .definitions + .iter() + .map(|node| { + let mut buf = Vec::new(); + cw_schema_codegen::typescript::process_node(&mut buf, schema, node, true).unwrap(); + String::from_utf8(buf).unwrap() + }) + .collect::(); + + let mut gen_file = File::create(&gen_file_path).unwrap(); + gen_file.write_all(output.as_bytes()).unwrap(); + + let data = arbitrary_gen(&mut unstructured); + let serialized = serde_json::to_string(&data).unwrap(); + + let mut child = Command::new("npm") + .args(["test", type_name]) + .current_dir(&e2e_dir) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + + { + let mut stdin = child.stdin.take().unwrap(); + stdin.write_all(serialized.as_bytes()).unwrap(); + } + + let proc_output = child.wait_with_output().unwrap(); + assert!( + proc_output.status.success(), + "failed with object: {data:#?}; json: {serialized}; schema: {output}" + ); + + let stdout = str::from_utf8(&proc_output.stdout).unwrap(); + let stdout = stdout.lines().last().unwrap(); + let deserialized: Combined = serde_json::from_str(stdout).unwrap_or_else(|err| { + panic!("{err:?}; input: {serialized}, output: {stdout}"); + }); + + assert_eq!(data, deserialized); + } +} diff --git a/packages/cw-schema-derive/Cargo.toml b/packages/cw-schema-derive/Cargo.toml new file mode 100644 index 0000000000..17b3f57736 --- /dev/null +++ b/packages/cw-schema-derive/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "cw-schema-derive" +version.workspace = true +edition = "2021" + +[lib] +proc-macro = true + +[dependencies] +heck = "0.5.0" +itertools = { version = "0.13.0", default-features = false } +owo-colors = { version = "4.0.0", features = ["supports-colors"] } +proc-macro2 = "1.0.86" +quote = "1.0.36" +syn = { version = "2.0.72", features = ["full"] } diff --git a/packages/cw-schema-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs new file mode 100644 index 0000000000..e724797fb5 --- /dev/null +++ b/packages/cw-schema-derive/src/expand.rs @@ -0,0 +1,503 @@ +// TODO: CLEAN ALL THIS SHIT UP WHAT THE FUCK IS THIS + +use crate::bail; +use owo_colors::{OwoColorize, Style}; +use proc_macro2::TokenStream; +use quote::{format_ident, quote}; +use std::{ + borrow::Cow, + env, + fmt::Display, + io::{self, Write as _}, +}; +use syn::{DataEnum, DataStruct, DataUnion, DeriveInput, Lit}; + +const DISABLE_WARNINGS_VAR: &str = "SHUT_UP_CW_SCHEMA_DERIVE"; + +fn print_warning(title: impl Display, content: impl Display) -> io::Result<()> { + if let Ok("1") = env::var(DISABLE_WARNINGS_VAR).as_deref() { + return Ok(()); + } + + let mut sink = io::stderr(); + + let bold_yellow = Style::new().bold().yellow(); + let bold = Style::new().bold(); + let blue = Style::new().blue(); + + write!(sink, "{}", "warning".style(bold_yellow))?; + writeln!( + sink, + "{}", + format_args!("({}): {title}", env!("CARGO_PKG_NAME")).style(bold) + )?; + + writeln!(sink, "{}", " | ".style(blue))?; + write!(sink, "{}", " | ".style(blue))?; + writeln!(sink, "{content}")?; + + writeln!(sink, "{}", " | ".style(blue))?; + writeln!(sink, "{}", " | ".style(blue))?; + + write!(sink, "{}", " = ".style(blue))?; + write!(sink, "{}", "note: ".style(bold))?; + writeln!( + sink, + "set `{DISABLE_WARNINGS_VAR}=1` to silence this warning" + )?; + + Ok(()) +} + +type Converter = fn(&str) -> String; + +fn case_converter(case: &syn::LitStr) -> syn::Result { + macro_rules! define_converter { + (match $value:expr => { + $( $case:pat => $converter:expr, )* + }) => { + match $value { + $( $case => |txt: &str| $converter(txt).to_string(), )* + _ => return Err(syn::Error::new_spanned(case, "unsupported case style")), + } + }; + } + + let case = case.value(); + let converter = define_converter!(match case.as_str() => { + "camelCase" => heck::AsLowerCamelCase, + "snake_case" => heck::AsSnakeCase, + "kebab-case" => heck::AsKebabCase, + "SCREAMING_SNAKE_CASE" => heck::AsShoutySnakeCase, + "SCREAMING-KEBAB-CASE" => heck::AsShoutyKebabCase, + }); + + Ok(converter) +} + +#[inline] +fn maybe_case_converter(case: Option<&syn::LitStr>) -> syn::Result { + case.map(case_converter) + .unwrap_or_else(|| Ok(|txt: &str| txt.to_string())) +} + +#[inline] +fn ident_adapter(converter: Converter) -> impl Fn(&syn::Ident) -> syn::Ident { + move |ident: &syn::Ident| format_ident!("{}", converter(&ident.to_string())) +} + +struct SerdeContainerOptions { + rename_all: Option, + untagged: bool, +} + +impl SerdeContainerOptions { + fn parse(attributes: &[syn::Attribute]) -> syn::Result { + let mut options = SerdeContainerOptions { + rename_all: None, + untagged: false, + }; + + for attribute in attributes + .iter() + .filter(|attr| attr.path().is_ident("serde")) + { + attribute.parse_nested_meta(|meta| { + if meta.path.is_ident("rename_all") { + options.rename_all = Some(meta.value()?.parse()?); + } else if meta.path.is_ident("untagged") { + options.untagged = true; + } else { + print_warning( + "unknown serde attribute", + format!( + "unknown attribute \"{}\"", + meta.path + .get_ident() + .map(|ident| ident.to_string()) + .unwrap_or_else(|| "[error]".into()) + ), + ) + .unwrap(); + + // TODO: support other serde attributes + // + // For now we simply clear the buffer to avoid errors + let _ = meta + .value() + .map(|val| val.parse::().unwrap()) + .unwrap_or_else(|_| meta.input.cursor().token_stream()); + } + + Ok(()) + })?; + } + + Ok(options) + } +} + +struct ContainerOptions { + r#as: Option, + r#type: Option, + crate_path: syn::Path, +} + +impl ContainerOptions { + fn parse(attributes: &[syn::Attribute]) -> syn::Result { + let mut options = ContainerOptions { + r#as: None, + r#type: None, + crate_path: syn::parse_str("::cw_schema")?, + }; + + for attribute in attributes + .iter() + .filter(|attr| attr.path().is_ident("schemaifier")) + { + attribute.parse_nested_meta(|meta| { + if meta.path.is_ident("crate") { + let stringified: syn::LitStr = meta.value()?.parse()?; + options.crate_path = stringified.parse()?; + } else if meta.path.is_ident("as") { + options.r#as = Some(meta.value()?.parse()?); + } else if meta.path.is_ident("type") { + options.r#type = Some(meta.value()?.parse()?); + } else { + bail!(meta.path, "unknown attribute"); + } + + Ok(()) + })?; + } + + Ok(options) + } +} + +struct SerdeFieldOptions { + rename: Option, +} + +impl SerdeFieldOptions { + fn parse(attributes: &[syn::Attribute]) -> syn::Result { + let mut options = SerdeFieldOptions { rename: None }; + + for attribute in attributes + .iter() + .filter(|attr| attr.path().is_ident("serde")) + { + attribute.parse_nested_meta(|meta| { + if meta.path.is_ident("rename") { + options.rename = Some(meta.value()?.parse()?); + } else { + print_warning( + "unknown serde attribute", + format!( + "unknown attribute \"{}\"", + meta.path + .get_ident() + .map(|ident| ident.to_string()) + .unwrap_or_else(|| "[error]".into()) + ), + ) + .unwrap(); + + // TODO: support other serde attributes + // + // For now we simply clear the buffer to avoid errors + let _ = meta + .value() + .map(|val| val.parse::().unwrap()) + .unwrap_or_else(|_| meta.input.cursor().token_stream()); + } + + Ok(()) + })?; + } + + Ok(options) + } +} + +#[inline] +fn normalize_option(value: Option) -> TokenStream { + match value { + Some(value) => quote! { Some(#value.into()) }, + None => quote! { None }, + } +} + +fn extract_documentation(attributes: &[syn::Attribute]) -> syn::Result> { + let docs_iter = attributes + .iter() + .filter(|attribute| attribute.path().is_ident("doc")) + .map(|doc_attribute| { + let name_value = doc_attribute.meta.require_name_value()?; + + let syn::Expr::Lit(syn::ExprLit { + lit: Lit::Str(ref text), + .. + }) = name_value.value + else { + bail!(name_value, "expected string literal"); + }; + + Ok(Cow::Owned(text.value().trim().to_string())) + }); + + let docs = itertools::intersperse(docs_iter, Ok(Cow::Borrowed("\n"))) + .collect::>()?; + + if docs.is_empty() { + return Ok(None); + } + + Ok(Some(docs)) +} + +fn patch_type_params<'a, I>(options: &ContainerOptions, type_params: I) +where + I: Iterator, +{ + let crate_path = &options.crate_path; + + for param in type_params { + param.bounds.push(syn::TypeParamBound::Verbatim( + quote! { #crate_path::Schemaifier }, + )); + } +} + +pub struct ContainerMeta { + name: syn::Ident, + description: Option, + generics: syn::Generics, + options: ContainerOptions, + serde_options: SerdeContainerOptions, +} + +fn collect_struct_fields<'a, C>( + converter: &'a C, + crate_path: &'a syn::Path, + fields: &'a syn::FieldsNamed, +) -> impl Iterator> + 'a +where + C: Fn(&syn::Ident) -> syn::Ident, +{ + fields.named.iter().map(move |field| { + let field_options = SerdeFieldOptions::parse(&field.attrs)?; + + let name = field_options + .rename + .map(|lit_str| format_ident!("{}", lit_str.value())) + .unwrap_or_else(|| converter(field.ident.as_ref().unwrap())); + let description = normalize_option(extract_documentation(&field.attrs)?); + let field_ty = &field.ty; + + let expanded = quote! { + ( + stringify!(#name).into(), + #crate_path::StructProperty { + description: #description, + value: <#field_ty as #crate_path::Schemaifier>::visit_schema(visitor), + } + ) + }; + + Ok(expanded) + }) +} + +fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result { + let crate_path = &meta.options.crate_path; + let converter = ident_adapter(maybe_case_converter( + meta.serde_options.rename_all.as_ref(), + )?); + + let mut cases = Vec::new(); + for variant in input.variants.iter() { + let value = match variant.fields { + syn::Fields::Named(ref fields) => { + let items = collect_struct_fields(&converter, crate_path, fields) + .collect::>>()?; + + quote! { + #crate_path::EnumValue::Named { + properties: #crate_path::reexport::BTreeMap::from([ + #( #items, )* + ]) + } + } + } + syn::Fields::Unnamed(ref fields) => { + let types = fields.unnamed.iter().map(|field| &field.ty); + + quote! { + #crate_path::EnumValue::Tuple { + items: vec![ + #( <#types as #crate_path::Schemaifier>::visit_schema(visitor), )* + ] + } + } + } + syn::Fields::Unit => quote! { #crate_path::EnumValue::Unit }, + }; + + let field_options = SerdeFieldOptions::parse(&variant.attrs)?; + + let variant_name = field_options + .rename + .map(|lit_str| format_ident!("{}", lit_str.value())) + .unwrap_or_else(|| converter(&variant.ident)); + let description = normalize_option(extract_documentation(&variant.attrs)?); + + let expanded = quote! { + #crate_path::EnumCase { + description: #description, + value: #value, + } + }; + + cases.push(quote! { + ( + stringify!(#variant_name).into(), + #expanded, + ) + }); + } + + let name = &meta.name; + let description = normalize_option(meta.description.as_ref()); + let crate_path = &meta.options.crate_path; + + patch_type_params(&meta.options, meta.generics.type_params_mut()); + let (impl_generics, ty_generics, where_clause) = meta.generics.split_for_impl(); + + Ok(quote! { + #[automatically_derived] + impl #impl_generics #crate_path::Schemaifier for #name #ty_generics #where_clause { + fn visit_schema(visitor: &mut #crate_path::SchemaVisitor) -> #crate_path::DefinitionReference { + let node = #crate_path::Node { + name: stringify!(#name).into(), + description: #description, + value: #crate_path::NodeType::Enum { + discriminator: None, + cases: #crate_path::reexport::BTreeMap::from([ + #( #cases, )* + ]), + }, + }; + + visitor.insert(Self::id(), node) + } + } + }) +} + +fn expand_struct(mut meta: ContainerMeta, input: DataStruct) -> syn::Result { + let converter = ident_adapter(maybe_case_converter( + meta.serde_options.rename_all.as_ref(), + )?); + + let name = &meta.name; + let description = normalize_option(meta.description.as_ref()); + let crate_path = &meta.options.crate_path; + + let node = if let Some(ref r#as) = meta.options.r#as { + quote! { + let definition_resource = #crate_path::Schemaifier::visit_schema(visitor); + visitor.get_schema::<#r#as>().unwrap().clone() + } + } else { + let node_ty = if let Some(ref r#type) = meta.options.r#type { + quote! { + #r#type + } + } else { + let node_ty = match input.fields { + syn::Fields::Named(ref named) => { + let items = collect_struct_fields(&converter, crate_path, named) + .collect::>>()?; + + quote! { + #crate_path::StructType::Named { + properties: #crate_path::reexport::BTreeMap::from([ + #( #items, )* + ]) + } + } + } + syn::Fields::Unnamed(fields) => { + let type_names = fields.unnamed.iter().map(|field| &field.ty); + + quote! { + #crate_path::StructType::Tuple { + items: vec![ + #( + <#type_names as #crate_path::Schemaifier>::visit_schema(visitor), + )* + ], + } + } + } + syn::Fields::Unit => quote! { #crate_path::StructType::Unit }, + }; + + quote! { + #crate_path::NodeType::Struct(#node_ty) + } + }; + + quote! { + #crate_path::Node { + name: stringify!(#name).into(), + description: #description, + value: #node_ty, + } + } + }; + + patch_type_params(&meta.options, meta.generics.type_params_mut()); + let (impl_generics, ty_generics, where_clause) = meta.generics.split_for_impl(); + + Ok(quote! { + #[automatically_derived] + impl #impl_generics #crate_path::Schemaifier for #name #ty_generics #where_clause { + fn visit_schema(visitor: &mut #crate_path::SchemaVisitor) -> #crate_path::DefinitionReference { + let node = { + #node + }; + + visitor.insert(Self::id(), node) + } + } + }) +} + +fn expand_union(_meta: ContainerMeta, input: DataUnion) -> syn::Result { + Err(syn::Error::new_spanned( + input.union_token, + "Unions are not supported (yet)", + )) +} + +pub fn expand(input: DeriveInput) -> syn::Result { + let options = ContainerOptions::parse(&input.attrs)?; + let serde_options = SerdeContainerOptions::parse(&input.attrs)?; + let description = extract_documentation(&input.attrs)?; + + let meta = ContainerMeta { + name: input.ident, + description, + generics: input.generics, + options, + serde_options, + }; + + match input.data { + syn::Data::Enum(input) => expand_enum(meta, input), + syn::Data::Struct(input) => expand_struct(meta, input), + syn::Data::Union(input) => expand_union(meta, input), + } +} diff --git a/packages/cw-schema-derive/src/lib.rs b/packages/cw-schema-derive/src/lib.rs new file mode 100644 index 0000000000..13f3cf46f4 --- /dev/null +++ b/packages/cw-schema-derive/src/lib.rs @@ -0,0 +1,25 @@ +mod expand; + +macro_rules! bail { + ($span_src:expr, $msg:literal) => {{ + return Err($crate::error_message!($span_src, $msg)); + }}; +} + +macro_rules! error_message { + ($span_src:expr, $msg:literal) => {{ + ::syn::Error::new(::syn::spanned::Spanned::span(&{ $span_src }), $msg) + }}; +} +// Needed so we can import macros. Rust, why? +use {bail, error_message}; + +#[proc_macro_derive(Schemaifier, attributes(schemaifier, serde))] +pub fn schemaifier(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let input = syn::parse_macro_input!(input as syn::DeriveInput); + + match expand::expand(input) { + Ok(output) => output.into(), + Err(err) => err.to_compile_error().into(), + } +} diff --git a/packages/cw-schema/.gitignore b/packages/cw-schema/.gitignore new file mode 100644 index 0000000000..ea8c4bf7f3 --- /dev/null +++ b/packages/cw-schema/.gitignore @@ -0,0 +1 @@ +/target diff --git a/packages/cw-schema/Cargo.toml b/packages/cw-schema/Cargo.toml new file mode 100644 index 0000000000..c24391f8ad --- /dev/null +++ b/packages/cw-schema/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "cw-schema" +version.workspace = true +edition = "2021" + +[dependencies] +cw-schema-derive = { version = "=2.2.0-rc.1", path = "../cw-schema-derive" } +indexmap = { version = "2.3.0", default-features = false } +schemars = { version = "1.0.0-alpha.2", optional = true } +serde = { version = "1.0.204", features = ["derive"] } +serde_with = { version = "3.9.0", default-features = false, features = [ + "macros", +] } +siphasher = { version = "1.0.1", default-features = false } + +[dev-dependencies] +insta = { version = "1.39.0", features = ["json"] } +pretty_assertions = "1.4.0" +serde_json = "1.0.120" + +[features] +default = ["std"] +std = ["dep:schemars"] diff --git a/packages/cw-schema/src/default_impls.rs b/packages/cw-schema/src/default_impls.rs new file mode 100644 index 0000000000..298b80c1b9 --- /dev/null +++ b/packages/cw-schema/src/default_impls.rs @@ -0,0 +1,201 @@ +use crate::{Node, NodeType, Schemaifier}; +use alloc::{ + borrow::{Cow, ToOwned}, + string::String, + vec, + vec::Vec, +}; + +impl Schemaifier for () { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("Unit"), + description: None, + value: NodeType::Unit, + }, + ) + } +} + +impl Schemaifier for str { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("str"), + description: None, + value: NodeType::String, + }, + ) + } +} + +impl Schemaifier for String { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("String"), + description: None, + value: NodeType::String, + }, + ) + } +} + +macro_rules! impl_integer { + ($($t:ty),+) => { + $( + impl Schemaifier for $t { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert(Self::id(), Node { + name: Cow::Borrowed(stringify!($t)), + description: None, + value: NodeType::Integer { + signed: <$t>::MIN != 0, + precision: <$t>::BITS as u64, + }, + }) + } + } + )+ + }; +} + +impl_integer!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, usize, isize); + +impl Schemaifier for f32 { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("f32"), + description: None, + value: NodeType::Float, + }, + ) + } +} + +impl Schemaifier for f64 { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("f64"), + description: None, + value: NodeType::Double, + }, + ) + } +} + +impl Schemaifier for bool { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("bool"), + description: None, + value: NodeType::Boolean, + }, + ) + } +} + +impl Schemaifier for Vec +where + T: Schemaifier, +{ + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + let node = Node { + name: Cow::Borrowed(std::any::type_name::()), + description: None, + value: NodeType::Array { + items: T::visit_schema(visitor), + }, + }; + + visitor.insert(Self::id(), node) + } +} + +macro_rules! all_the_tuples { + ($($($n:ident),+);+$(;)?) => { + $( + impl<$($n: Schemaifier),+> Schemaifier for ($($n,)+) { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + let node = Node { + name: Cow::Borrowed(std::any::type_name::()), + description: None, + value: NodeType::Tuple { + items: vec![ + $(<$n as Schemaifier>::visit_schema(visitor)),+ + ], + }, + }; + + visitor.insert(Self::id(), node) + } + } + )+ + }; +} + +// Implement for tuples up to 16 elements. +// Good enough. If someone needs more, PR it. +all_the_tuples! { + A; + A, B; + A, B, C; + A, B, C, D; + A, B, C, D, E; + A, B, C, D, E, F; + A, B, C, D, E, F, G; + A, B, C, D, E, F, G, H; + A, B, C, D, E, F, G, H, I; + A, B, C, D, E, F, G, H, I, J; + A, B, C, D, E, F, G, H, I, J, K; + A, B, C, D, E, F, G, H, I, J, K, L; + A, B, C, D, E, F, G, H, I, J, K, L, M; + A, B, C, D, E, F, G, H, I, J, K, L, M, N; + A, B, C, D, E, F, G, H, I, J, K, L, M, N, O; + A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P; +} + +impl Schemaifier for Option +where + T: Schemaifier, +{ + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + let node = Node { + name: Cow::Borrowed(std::any::type_name::()), + description: None, + value: NodeType::Optional { + inner: T::visit_schema(visitor), + }, + }; + + visitor.insert(Self::id(), node) + } +} + +impl Schemaifier for &T +where + T: Schemaifier + ?Sized, +{ + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + T::visit_schema(visitor) + } +} + +impl Schemaifier for Cow<'_, T> +where + T: Schemaifier + ToOwned + ?Sized, +{ + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + T::visit_schema(visitor) + } +} diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs new file mode 100644 index 0000000000..0e1c2c3396 --- /dev/null +++ b/packages/cw-schema/src/lib.rs @@ -0,0 +1,224 @@ +#![no_std] + +extern crate alloc; + +#[cfg(feature = "std")] +extern crate std; + +use alloc::{borrow::Cow, collections::BTreeMap, vec::Vec}; +use core::{any::TypeId, hash::BuildHasherDefault, marker::PhantomData}; +use indexmap::IndexMap; +use serde::{Deserialize, Serialize}; +use serde_with::skip_serializing_none; +use siphasher::sip::SipHasher; + +pub use cw_schema_derive::Schemaifier; + +pub type DefinitionReference = usize; + +mod default_impls; + +#[skip_serializing_none] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct StructProperty { + pub description: Option>, + pub value: DefinitionReference, +} + +#[skip_serializing_none] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase", untagged)] +pub enum StructType { + Unit, + Named { + properties: BTreeMap, StructProperty>, + }, + Tuple { + items: Vec, + }, +} + +#[skip_serializing_none] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct EnumCase { + pub description: Option>, + #[serde(flatten)] + pub value: EnumValue, +} + +#[skip_serializing_none] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase", tag = "type")] +pub enum EnumValue { + Unit, + Named { + properties: BTreeMap, StructProperty>, + }, + Tuple { + items: Vec, + }, +} + +#[skip_serializing_none] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase", tag = "type")] +pub enum NodeType { + // Floating point numbers + Float, + Double, + + // Decimal numbers + Decimal { + precision: u64, + signed: bool, + }, + + // Integer numbers + Integer { + precision: u64, + signed: bool, + }, + + Address, + Binary, + Checksum, + HexBinary, + Timestamp, + + String, + Boolean, + Array { + items: DefinitionReference, + }, + Struct(StructType), + Tuple { + items: Vec, + }, + Enum { + discriminator: Option>, + cases: BTreeMap, EnumCase>, + }, + + Optional { + inner: DefinitionReference, + }, + Unit, +} + +#[skip_serializing_none] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct Node { + pub name: Cow<'static, str>, + pub description: Option>, + #[serde(flatten)] + pub value: NodeType, +} + +#[skip_serializing_none] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +pub struct SchemaV1 { + pub root: DefinitionReference, + pub definitions: Vec, +} + +#[skip_serializing_none] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase", tag = "type")] +#[non_exhaustive] +pub enum Schema { + V1(SchemaV1), +} + +#[derive(Hash, PartialEq, Eq)] +pub struct Identifier(TypeId); + +impl Identifier { + pub fn of() -> Self + where + T: ?Sized, + { + // Taken from : https://github.com/sagebind/castaway/blob/a7baeab32d75d0f105d1415210a2867d213f8818/src/utils.rs#L36 + // + // Seems more robust than the previous implementation. + trait NonStaticAny { + fn get_type_id(&self) -> TypeId + where + Self: 'static; + } + + impl NonStaticAny for PhantomData { + fn get_type_id(&self) -> TypeId + where + Self: 'static, + { + TypeId::of::() + } + } + + let phantom = PhantomData::; + let ty_id = NonStaticAny::get_type_id(unsafe { + core::mem::transmute::<&dyn NonStaticAny, &(dyn NonStaticAny + 'static)>(&phantom) + }); + + Identifier(ty_id) + } +} + +#[derive(Default)] +pub struct SchemaVisitor { + schemas: IndexMap>, +} + +impl SchemaVisitor { + pub fn get_reference(&self) -> Option { + self.schemas.get_index_of(&T::id()) + } + + pub fn get_schema(&self) -> Option<&Node> { + self.schemas.get(&T::id()) + } + + pub fn insert(&mut self, id: Identifier, node: Node) -> DefinitionReference { + let (id, _) = self.schemas.insert_full(id, node); + id + } + + /// Transform this visitor into a vector where the `DefinitionReference` can be used as an index + /// to access the schema of the particular node. + pub fn into_vec(self) -> Vec { + self.schemas.into_values().collect() + } +} + +pub trait Schemaifier { + fn id() -> Identifier { + Identifier::of::() + } + + fn visit_schema(visitor: &mut SchemaVisitor) -> DefinitionReference; +} + +pub fn schema_of() -> Schema { + let mut visitor = SchemaVisitor::default(); + Schema::V1(SchemaV1 { + root: T::visit_schema(&mut visitor), + definitions: visitor.into_vec(), + }) +} + +#[doc(hidden)] +pub mod reexport { + pub use alloc::collections::BTreeMap; +} diff --git a/packages/cw-schema/tests/basic.rs b/packages/cw-schema/tests/basic.rs new file mode 100644 index 0000000000..3aeb1b66a0 --- /dev/null +++ b/packages/cw-schema/tests/basic.rs @@ -0,0 +1,13 @@ +use cw_schema::Schema; + +#[test] +fn can_decode_example() { + let example = include_str!("example.json"); + let _: Schema = serde_json::from_str(example).unwrap(); +} + +#[test] +fn snapshot_jsonschema() { + let schema = schemars::schema_for!(Schema); + insta::assert_json_snapshot!(schema); +} diff --git a/packages/cw-schema/tests/derive.rs b/packages/cw-schema/tests/derive.rs new file mode 100644 index 0000000000..dc636e27eb --- /dev/null +++ b/packages/cw-schema/tests/derive.rs @@ -0,0 +1,57 @@ +#![allow(dead_code)] // We never construct these types. Introspection is done at compile time. + +use cw_schema::Schemaifier; + +#[derive(Schemaifier)] +/// Hello world struct! +struct HelloWorld { + /// Name field! + name: String, + + /// Foo field! + foo: Option, + + /// Baz field! + baz: Baz, + + /// Quux field! + quux: Quux, + + /// Tuple field! + tuple: (u32, u32), +} + +#[derive(Schemaifier)] +/// Bar struct! +struct Bar { + /// Bar field! + baz: u32, +} + +#[derive(Schemaifier)] +/// Baz enum! +enum Baz { + /// A variant! + A, + /// B variant! + B { + /// C field! + c: u32, + }, + /// D variant! + D(u32, u32), +} + +#[derive(Schemaifier)] +#[serde(rename_all = "camelCase", thingy = "lmao")] +/// Quux struct! +pub struct Quux { + /// Quux field! + quux_field: u32, +} + +#[test] +fn snapshot_schema() { + let schema = cw_schema::schema_of::(); + insta::assert_json_snapshot!(schema); +} diff --git a/packages/cw-schema/tests/example.json b/packages/cw-schema/tests/example.json new file mode 100644 index 0000000000..996ab250da --- /dev/null +++ b/packages/cw-schema/tests/example.json @@ -0,0 +1,92 @@ +{ + "type": "v1", + "root": 6, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "derive::Bar", + "description": "Bar struct!", + "type": "struct", + "properties": { + "baz": { + "description": "Bar field!", + "value": 1 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 2 + }, + { + "name": "derive::Baz", + "description": "Baz enum!", + "type": "enum", + "cases": { + "A": { + "description": "A variant!", + "type": "unit" + }, + "B": { + "description": "B variant!", + "type": "named", + "properties": { + "c": { + "description": "C field!", + "value": 1 + } + } + }, + "D": { + "description": "D variant!", + "type": "tuple", + "items": [ + 1, + 1 + ] + } + } + }, + { + "name": "(u32, u32)", + "type": "tuple", + "items": [ + 1, + 1 + ] + }, + { + "name": "derive::HelloWorld", + "description": "Hello world struct!", + "type": "struct", + "properties": { + "baz": { + "description": "Baz field!", + "value": 4 + }, + "foo": { + "description": "Foo field!", + "value": 3 + }, + "name": { + "description": "Name field!", + "value": 0 + }, + "tuple": { + "description": "Tuple field!", + "value": 5 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/cw-schema/tests/non_static.rs b/packages/cw-schema/tests/non_static.rs new file mode 100644 index 0000000000..da31724b53 --- /dev/null +++ b/packages/cw-schema/tests/non_static.rs @@ -0,0 +1,18 @@ +#![allow(dead_code)] + +use cw_schema::Schemaifier; +use std::borrow::Cow; + +#[derive(Schemaifier)] +struct NonStatic<'a> { + test1: &'a str, + test2: Cow<'a, str>, + test3: Cow<'static, str>, + test4: &'static str, +} + +#[test] +fn non_static_schema() { + let schema = cw_schema::schema_of::>(); + insta::assert_json_snapshot!(schema); +} diff --git a/packages/cw-schema/tests/same_name.rs b/packages/cw-schema/tests/same_name.rs new file mode 100644 index 0000000000..3d47b0f049 --- /dev/null +++ b/packages/cw-schema/tests/same_name.rs @@ -0,0 +1,27 @@ +#![allow(dead_code)] + +mod module1 { + #[derive(cw_schema::Schemaifier)] + pub struct Test { + foo: usize, + } +} + +mod module2 { + #[derive(cw_schema::Schemaifier)] + pub struct Test { + bar: f32, + } +} + +#[derive(cw_schema::Schemaifier)] +struct Combined { + module1: module1::Test, + module2: module2::Test, +} + +#[test] +fn can_handle_same_name_in_different_modules() { + let schema = cw_schema::schema_of::(); + insta::assert_json_snapshot!(schema); +} diff --git a/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap b/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap new file mode 100644 index 0000000000..1a89b800d1 --- /dev/null +++ b/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap @@ -0,0 +1,433 @@ +--- +source: packages/cw-schema/tests/basic.rs +expression: schema +--- +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Schema", + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "v1" + }, + "root": { + "type": "integer", + "format": "uint", + "minimum": 0 + }, + "definitions": { + "type": "array", + "items": { + "$ref": "#/$defs/Node" + } + } + }, + "required": [ + "type", + "root", + "definitions" + ] + } + ], + "$defs": { + "EnumCase": { + "type": "object", + "properties": { + "description": { + "type": [ + "string", + "null" + ] + } + }, + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "unit" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "named" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/StructProperty" + } + } + }, + "required": [ + "type", + "properties" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "tuple" + }, + "items": { + "type": "array", + "items": { + "type": "integer", + "format": "uint", + "minimum": 0 + } + } + }, + "required": [ + "type", + "items" + ] + } + ] + }, + "Node": { + "type": "object", + "properties": { + "description": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": "string" + } + }, + "oneOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "float" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "double" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "decimal" + }, + "precision": { + "type": "integer", + "format": "uint64", + "minimum": 0 + }, + "signed": { + "type": "boolean" + } + }, + "required": [ + "type", + "precision", + "signed" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "integer" + }, + "precision": { + "type": "integer", + "format": "uint64", + "minimum": 0 + }, + "signed": { + "type": "boolean" + } + }, + "required": [ + "type", + "precision", + "signed" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "address" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "binary" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "checksum" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "hexBinary" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "timestamp" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "string" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "boolean" + } + }, + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "array" + }, + "items": { + "type": "integer", + "format": "uint", + "minimum": 0 + } + }, + "required": [ + "type", + "items" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "struct" + } + }, + "anyOf": [ + { + "type": "null" + }, + { + "type": "object", + "properties": { + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/StructProperty" + } + } + }, + "required": [ + "properties" + ] + }, + { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "integer", + "format": "uint", + "minimum": 0 + } + } + }, + "required": [ + "items" + ] + } + ], + "required": [ + "type" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "tuple" + }, + "items": { + "type": "array", + "items": { + "type": "integer", + "format": "uint", + "minimum": 0 + } + } + }, + "required": [ + "type", + "items" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "enum" + }, + "cases": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/EnumCase" + } + }, + "discriminator": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "type", + "cases" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "optional" + }, + "inner": { + "type": "integer", + "format": "uint", + "minimum": 0 + } + }, + "required": [ + "type", + "inner" + ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "unit" + } + }, + "required": [ + "type" + ] + } + ], + "required": [ + "name" + ] + }, + "StructProperty": { + "type": "object", + "properties": { + "description": { + "type": [ + "string", + "null" + ] + }, + "value": { + "type": "integer", + "format": "uint", + "minimum": 0 + } + }, + "required": [ + "value" + ] + } + } +} diff --git a/packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap b/packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap new file mode 100644 index 0000000000..1202993dcd --- /dev/null +++ b/packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap @@ -0,0 +1,111 @@ +--- +source: packages/cw-schema/tests/derive.rs +expression: schema +--- +{ + "type": "v1", + "root": 7, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "u32", + "type": "integer", + "precision": 32, + "signed": false + }, + { + "name": "Bar", + "description": "Bar struct!", + "type": "struct", + "properties": { + "baz": { + "description": "Bar field!", + "value": 1 + } + } + }, + { + "name": "core::option::Option", + "type": "optional", + "inner": 2 + }, + { + "name": "Baz", + "description": "Baz enum!", + "type": "enum", + "cases": { + "A": { + "description": "A variant!", + "type": "unit" + }, + "B": { + "description": "B variant!", + "type": "named", + "properties": { + "c": { + "description": "C field!", + "value": 1 + } + } + }, + "D": { + "description": "D variant!", + "type": "tuple", + "items": [ + 1, + 1 + ] + } + } + }, + { + "name": "Quux", + "description": "Quux struct!", + "type": "struct", + "properties": { + "quuxField": { + "description": "Quux field!", + "value": 1 + } + } + }, + { + "name": "(u32, u32)", + "type": "tuple", + "items": [ + 1, + 1 + ] + }, + { + "name": "HelloWorld", + "description": "Hello world struct!", + "type": "struct", + "properties": { + "baz": { + "description": "Baz field!", + "value": 4 + }, + "foo": { + "description": "Foo field!", + "value": 3 + }, + "name": { + "description": "Name field!", + "value": 0 + }, + "quux": { + "description": "Quux field!", + "value": 5 + }, + "tuple": { + "description": "Tuple field!", + "value": 6 + } + } + } + ] +} diff --git a/packages/cw-schema/tests/snapshots/non_static__non_static_schema.snap b/packages/cw-schema/tests/snapshots/non_static__non_static_schema.snap new file mode 100644 index 0000000000..b320f38286 --- /dev/null +++ b/packages/cw-schema/tests/snapshots/non_static__non_static_schema.snap @@ -0,0 +1,32 @@ +--- +source: packages/cw-schema/tests/non_static.rs +expression: schema +--- +{ + "type": "v1", + "root": 1, + "definitions": [ + { + "name": "str", + "type": "string" + }, + { + "name": "NonStatic", + "type": "struct", + "properties": { + "test1": { + "value": 0 + }, + "test2": { + "value": 0 + }, + "test3": { + "value": 0 + }, + "test4": { + "value": 0 + } + } + } + ] +} diff --git a/packages/cw-schema/tests/snapshots/same_name__can_handle_same_name_in_different_modules.snap b/packages/cw-schema/tests/snapshots/same_name__can_handle_same_name_in_different_modules.snap new file mode 100644 index 0000000000..1a8ecbac7a --- /dev/null +++ b/packages/cw-schema/tests/snapshots/same_name__can_handle_same_name_in_different_modules.snap @@ -0,0 +1,50 @@ +--- +source: packages/cw-schema/tests/same_name.rs +expression: schema +--- +{ + "type": "v1", + "root": 4, + "definitions": [ + { + "name": "usize", + "type": "integer", + "precision": 64, + "signed": false + }, + { + "name": "Test", + "type": "struct", + "properties": { + "foo": { + "value": 0 + } + } + }, + { + "name": "f32", + "type": "float" + }, + { + "name": "Test", + "type": "struct", + "properties": { + "bar": { + "value": 2 + } + } + }, + { + "name": "Combined", + "type": "struct", + "properties": { + "module1": { + "value": 1 + }, + "module2": { + "value": 3 + } + } + } + ] +} diff --git a/packages/schema-derive/src/cw_serde.rs b/packages/schema-derive/src/cw_serde.rs index be35fd3415..4de9fcaf64 100644 --- a/packages/schema-derive/src/cw_serde.rs +++ b/packages/schema-derive/src/cw_serde.rs @@ -39,6 +39,8 @@ impl Parse for Options { pub fn cw_serde_impl(options: Options, input: DeriveInput) -> syn::Result { let crate_path = &options.crate_path; let crate_path_displayable = crate_path.to_token_stream(); + + let cw_schema_path = format!("{crate_path_displayable}::cw_schema"); let serde_path = format!("{crate_path_displayable}::serde"); let schemars_path = format!("{crate_path_displayable}::schemars"); @@ -49,10 +51,12 @@ pub fn cw_serde_impl(options: Options, input: DeriveInput) -> syn::Result TokenStream { + quote! {{ + let api = #api_object.render(); + let path = out_dir.join(concat!(#name, ".json")); + + let json = api.to_string().unwrap(); + write(&path, json + "\n").unwrap(); + println!("Exported the full API as {}", path.to_str().unwrap()); + + let raw_dir = out_dir.join("raw"); + create_dir_all(&raw_dir).unwrap(); + + for (filename, json) in api.to_schema_files().unwrap() { + let path = raw_dir.join(filename); + + write(&path, json + "\n").unwrap(); + println!("Exported {}", path.to_str().unwrap()); + } + }} +} + pub fn write_api_impl(input: Options) -> Block { - let api_object = generate_api_impl(&input); + let cw_api_object = generate_api_impl(SchemaBackend::CwSchema, &input); + let json_schema_api_object = generate_api_impl(SchemaBackend::JsonSchema, &input); + let crate_name = input.crate_name; let name = input.name; + let cw_api_write = generate_api_write(cw_api_object, &name); + let json_schema_api_write = generate_api_write(json_schema_api_object, &name); + parse_quote! { { #[cfg(target_arch = "wasm32")] @@ -20,50 +47,46 @@ pub fn write_api_impl(input: Options) -> Block { use ::std::env; use ::std::fs::{create_dir_all, write}; - use #crate_name::{remove_schemas, Api, QueryResponses}; + use #crate_name::{remove_schemas, CwApi, Api, QueryResponses}; let mut out_dir = env::current_dir().unwrap(); out_dir.push("schema"); create_dir_all(&out_dir).unwrap(); remove_schemas(&out_dir).unwrap(); - let api = #api_object.render(); - - - let path = out_dir.join(concat!(#name, ".json")); + #json_schema_api_write - let json = api.to_string().unwrap(); - write(&path, json + "\n").unwrap(); - println!("Exported the full API as {}", path.to_str().unwrap()); - - let raw_dir = out_dir.join("raw"); - create_dir_all(&raw_dir).unwrap(); - - for (filename, json) in api.to_schema_files().unwrap() { - let path = raw_dir.join(filename); + out_dir.push("cw_schema"); + create_dir_all(&out_dir).unwrap(); + remove_schemas(&out_dir).unwrap(); - write(&path, json + "\n").unwrap(); - println!("Exported {}", path.to_str().unwrap()); - } + #cw_api_write } } } -pub fn generate_api_impl(input: &Options) -> ExprStruct { +pub fn generate_api_impl(backend: SchemaBackend, input: &Options) -> ExprStruct { let Options { crate_name, name, version, - instantiate, - execute, - query, - migrate, - sudo, - responses, + .. } = input; + let instantiate = input.instantiate(backend); + let execute = input.execute(backend); + let query = input.query(backend); + let migrate = input.migrate(backend); + let sudo = input.sudo(backend); + let responses = input.responses(backend); + + let api_path = match backend { + SchemaBackend::CwSchema => quote! { #crate_name::CwApi }, + SchemaBackend::JsonSchema => quote! { #crate_name::Api }, + }; + parse_quote! { - #crate_name::Api { + #api_path { contract_name: #name.to_string(), contract_version: #version.to_string(), instantiate: #instantiate, @@ -121,17 +144,75 @@ impl Parse for Pair { } } +macro_rules! option_dispatch { + ($opt:expr, $closure:expr) => {{ + match $opt { + Some(ref ty) => { + #[allow(clippy::redundant_closure_call)] + let tokens = $closure(ty); + quote! { Some(#tokens) } + } + None => quote! { None }, + } + }}; +} + +macro_rules! backend_dispatch { + ($fn_name:ident, $ty_field:ident) => { + pub fn $fn_name(&self, backend: SchemaBackend) -> TokenStream { + let crate_name = &self.crate_name; + + option_dispatch!(self.$ty_field, |ty| { + match backend { + SchemaBackend::CwSchema => { + quote! { #crate_name::cw_schema::schema_of::<#ty>() } + } + SchemaBackend::JsonSchema => quote! { #crate_name::schema_for!(#ty) }, + } + }) + } + }; +} + #[derive(Debug)] pub struct Options { - crate_name: TokenStream, + crate_name: syn::Path, name: TokenStream, version: TokenStream, - instantiate: TokenStream, - execute: TokenStream, - query: TokenStream, - migrate: TokenStream, - sudo: TokenStream, - responses: TokenStream, + instantiate_ty: Option, + execute_ty: Option, + query_ty: Option, + migrate_ty: Option, + sudo_ty: Option, + + schema_backend: SchemaBackend, +} + +impl Options { + backend_dispatch!(instantiate, instantiate_ty); + backend_dispatch!(execute, execute_ty); + backend_dispatch!(query, query_ty); + backend_dispatch!(migrate, migrate_ty); + backend_dispatch!(sudo, sudo_ty); + + pub fn responses(&self, backend: SchemaBackend) -> TokenStream { + let crate_name = &self.crate_name; + + option_dispatch!(self.query_ty, |ty| { + match backend { + SchemaBackend::CwSchema => { + quote! { <#ty as #crate_name::QueryResponses>::response_schemas_cw().unwrap() } + } + SchemaBackend::JsonSchema => { + quote! { <#ty as #crate_name::QueryResponses>::response_schemas().unwrap() } + } + } + }) + } + + pub fn schema_backend(&self) -> SchemaBackend { + self.schema_backend + } } impl Parse for Options { @@ -140,10 +221,9 @@ impl Parse for Options { let mut map: BTreeMap<_, _> = pairs.into_iter().map(|p| p.0).collect(); let crate_name = if let Some(crate_name_override) = map.remove(&parse_quote!(crate_name)) { - let crate_name_override = crate_name_override.get_type()?; - quote! { #crate_name_override } + crate_name_override.get_type()? } else { - quote! { ::cosmwasm_schema } + parse_quote! { ::cosmwasm_schema } }; let name = if let Some(name_override) = map.remove(&parse_quote!(name)) { @@ -168,47 +248,36 @@ impl Parse for Options { } }; - let instantiate = match map.remove(&parse_quote!(instantiate)) { - Some(ty) => { - let ty = ty.get_type()?; - quote! {Some(#crate_name::schema_for!(#ty))} - } - None => quote! { None }, - }; - - let execute = match map.remove(&parse_quote!(execute)) { - Some(ty) => { - let ty = ty.get_type()?; - quote! {Some(#crate_name::schema_for!(#ty))} - } - None => quote! { None }, - }; - - let (query, responses) = match map.remove(&parse_quote!(query)) { - Some(ty) => { - let ty = ty.get_type()?; - ( - quote! {Some(#crate_name::schema_for!(#ty))}, - quote! { Some(<#ty as #crate_name::QueryResponses>::response_schemas().unwrap()) }, - ) - } - None => (quote! { None }, quote! { None }), - }; - - let migrate = match map.remove(&parse_quote!(migrate)) { - Some(ty) => { - let ty = ty.get_type()?; - quote! {Some(#crate_name::schema_for!(#ty))} - } - None => quote! { None }, - }; - - let sudo = match map.remove(&parse_quote!(sudo)) { - Some(ty) => { - let ty = ty.get_type()?; - quote! {Some(#crate_name::schema_for!(#ty))} - } - None => quote! { None }, + let instantiate_ty = map + .remove(&parse_quote!(instantiate)) + .map(|ty| ty.get_type()) + .transpose()?; + + let execute_ty = map + .remove(&parse_quote!(execute)) + .map(|ty| ty.get_type()) + .transpose()?; + + let query_ty = map + .remove(&parse_quote!(query)) + .map(|ty| ty.get_type()) + .transpose()?; + + let migrate_ty = map + .remove(&parse_quote!(migrate)) + .map(|ty| ty.get_type()) + .transpose()?; + + let sudo_ty = map + .remove(&parse_quote!(sudo)) + .map(|ty| ty.get_type()) + .transpose()?; + + let schema_backend = if let Some(backend) = map.remove(&parse_quote!(schema_backend)) { + let backend = backend.get_str()?; + parse_quote! { #backend } + } else { + SchemaBackend::JsonSchema }; if let Some((invalid_option, _)) = map.into_iter().next() { @@ -216,15 +285,15 @@ impl Parse for Options { } Ok(Self { + schema_backend, crate_name, name, version, - instantiate, - execute, - query, - migrate, - sudo, - responses, + instantiate_ty, + execute_ty, + query_ty, + migrate_ty, + sudo_ty, }) } } @@ -236,14 +305,17 @@ mod tests { #[test] fn crate_rename() { assert_eq!( - generate_api_impl(&parse_quote! { - crate_name: ::my_crate::cw_schema, - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - migrate: MigrateMsg, - sudo: SudoMsg, - }), + generate_api_impl( + SchemaBackend::JsonSchema, + &parse_quote! { + crate_name: ::my_crate::cw_schema, + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + migrate: MigrateMsg, + sudo: SudoMsg, + } + ), parse_quote! { ::my_crate::cw_schema::Api { contract_name: ::std::env!("CARGO_PKG_NAME").to_string(), @@ -262,7 +334,7 @@ mod tests { #[test] fn api_object_minimal() { assert_eq!( - generate_api_impl(&parse_quote! {}), + generate_api_impl(SchemaBackend::JsonSchema, &parse_quote! {}), parse_quote! { ::cosmwasm_schema::Api { contract_name: ::std::env!("CARGO_PKG_NAME").to_string(), @@ -281,9 +353,12 @@ mod tests { #[test] fn api_object_instantiate_only() { assert_eq!( - generate_api_impl(&parse_quote! { - instantiate: InstantiateMsg, - }), + generate_api_impl( + SchemaBackend::JsonSchema, + &parse_quote! { + instantiate: InstantiateMsg, + } + ), parse_quote! { ::cosmwasm_schema::Api { contract_name: ::std::env!("CARGO_PKG_NAME").to_string(), @@ -302,11 +377,14 @@ mod tests { #[test] fn api_object_name_version_override() { assert_eq!( - generate_api_impl(&parse_quote! { - name: "foo", - version: "bar", - instantiate: InstantiateMsg, - }), + generate_api_impl( + SchemaBackend::JsonSchema, + &parse_quote! { + name: "foo", + version: "bar", + instantiate: InstantiateMsg, + } + ), parse_quote! { ::cosmwasm_schema::Api { contract_name: "foo".to_string(), @@ -325,13 +403,16 @@ mod tests { #[test] fn api_object_all_msgs() { assert_eq!( - generate_api_impl(&parse_quote! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - migrate: MigrateMsg, - sudo: SudoMsg, - }), + generate_api_impl( + SchemaBackend::JsonSchema, + &parse_quote! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + migrate: MigrateMsg, + sudo: SudoMsg, + } + ), parse_quote! { ::cosmwasm_schema::Api { contract_name: ::std::env!("CARGO_PKG_NAME").to_string(), diff --git a/packages/schema-derive/src/lib.rs b/packages/schema-derive/src/lib.rs index 5159d75b81..187a67cac3 100644 --- a/packages/schema-derive/src/lib.rs +++ b/packages/schema-derive/src/lib.rs @@ -7,6 +7,23 @@ use self::error::fallible_macro; use quote::ToTokens; use syn::parse_macro_input; +#[derive(Clone, Copy, Debug)] +enum SchemaBackend { + CwSchema, + JsonSchema, +} + +impl syn::parse::Parse for SchemaBackend { + fn parse(input: syn::parse::ParseStream) -> syn::Result { + let ident: syn::LitStr = input.parse()?; + match ident.value().as_str() { + "cw_schema" => Ok(SchemaBackend::CwSchema), + "json_schema" => Ok(SchemaBackend::JsonSchema), + _ => Err(syn::Error::new(ident.span(), "Unknown schema backend")), + } + } +} + fallible_macro! { #[proc_macro_derive(QueryResponses, attributes(returns, query_responses))] pub fn query_responses_derive( @@ -30,7 +47,8 @@ pub fn write_api(input: proc_macro::TokenStream) -> proc_macro::TokenStream { #[proc_macro] pub fn generate_api(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as generate_api::Options); - let expanded = generate_api::generate_api_impl(&input).into_token_stream(); + let expanded = + generate_api::generate_api_impl(input.schema_backend(), &input).into_token_stream(); proc_macro::TokenStream::from(expanded) } diff --git a/packages/schema-derive/src/query_responses.rs b/packages/schema-derive/src/query_responses.rs index 7d89761cbe..d117cb345b 100644 --- a/packages/schema-derive/src/query_responses.rs +++ b/packages/schema-derive/src/query_responses.rs @@ -1,5 +1,6 @@ mod context; +use super::SchemaBackend; use crate::error::{bail, error_message}; use syn::{ parse_quote, Expr, ExprTuple, Generics, ItemEnum, ItemImpl, Type, TypeParamBound, Variant, @@ -15,8 +16,14 @@ pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { let ident = input.ident; let subquery_calls = input .variants - .into_iter() - .map(|variant| parse_subquery(&ctx, variant)) + .iter() + .map(|variant| parse_subquery(&ctx, variant, SchemaBackend::JsonSchema)) + .collect::>>()?; + + let subquery_calls_cw = input + .variants + .iter() + .map(|variant| parse_subquery(&ctx, variant, SchemaBackend::CwSchema)) .collect::>>()?; // Handle generics if the type has any @@ -36,7 +43,14 @@ pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { let subqueries = [ #( #subquery_calls, )* ]; - #crate_name::combine_subqueries::<#subquery_len, #ident #type_generics>(subqueries) + #crate_name::combine_subqueries::<#subquery_len, #ident #type_generics, _>(subqueries) + } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + let subqueries = [ + #( #subquery_calls_cw, )* + ]; + #crate_name::combine_subqueries::<#subquery_len, #ident #type_generics, _>(subqueries) } } } @@ -45,14 +59,20 @@ pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { let ident = input.ident; let mappings = input .variants - .into_iter() - .map(|variant| parse_query(&ctx, variant)) + .iter() + .map(|variant| parse_query(&ctx, variant, SchemaBackend::JsonSchema)) .collect::>>()?; - let mut queries: Vec<_> = mappings.clone().into_iter().map(|(q, _)| q).collect(); - queries.sort(); let mappings = mappings.into_iter().map(parse_tuple); + let cw_mappings = input + .variants + .iter() + .map(|variant| parse_query(&ctx, variant, SchemaBackend::CwSchema)) + .collect::>>()?; + + let cw_mappings = cw_mappings.into_iter().map(parse_tuple); + // Handle generics if the type has any let (_, type_generics, where_clause) = input.generics.split_for_impl(); let impl_generics = impl_generics(&ctx, &input.generics, &[]); @@ -66,6 +86,12 @@ pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { #( #mappings, )* ]) } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + ::std::collections::BTreeMap::from([ + #( #cw_mappings, )* + ]) + } } } }; @@ -87,6 +113,9 @@ fn impl_generics(ctx: &Context, generics: &Generics, bounds: &[TypeParamBound]) param .bounds .push(parse_quote! {#crate_name::schemars::JsonSchema}); + param + .bounds + .push(parse_quote! { #crate_name::cw_schema::Schemaifier }); param.bounds.extend(bounds.to_owned()); } @@ -96,7 +125,11 @@ fn impl_generics(ctx: &Context, generics: &Generics, bounds: &[TypeParamBound]) } /// Extract the query -> response mapping out of an enum variant. -fn parse_query(ctx: &Context, v: Variant) -> syn::Result<(String, Expr)> { +fn parse_query( + ctx: &Context, + v: &Variant, + schema_backend: SchemaBackend, +) -> syn::Result<(String, Expr)> { let crate_name = &ctx.crate_name; let query = to_snake_case(&v.ident.to_string()); let response_ty: Type = v @@ -107,25 +140,41 @@ fn parse_query(ctx: &Context, v: Variant) -> syn::Result<(String, Expr)> { .parse_args() .map_err(|e| error_message!(e.span(), "return must be a type"))?; - Ok((query, parse_quote!(#crate_name::schema_for!(#response_ty)))) + let return_val = match schema_backend { + SchemaBackend::CwSchema => { + parse_quote!(#crate_name::cw_schema::schema_of::<#response_ty>()) + } + SchemaBackend::JsonSchema => parse_quote!(#crate_name::schema_for!(#response_ty)), + }; + + Ok((query, return_val)) } /// Extract the nested query -> response mapping out of an enum variant. -fn parse_subquery(ctx: &Context, v: Variant) -> syn::Result { +fn parse_subquery(ctx: &Context, v: &Variant, schema_backend: SchemaBackend) -> syn::Result { let crate_name = &ctx.crate_name; let submsg = match v.fields { syn::Fields::Named(_) => bail!(v, "a struct variant is not a valid subquery"), - syn::Fields::Unnamed(fields) => { + syn::Fields::Unnamed(ref fields) => { if fields.unnamed.len() != 1 { bail!(fields, "invalid number of subquery parameters"); } - fields.unnamed[0].ty.clone() + &fields.unnamed[0].ty } syn::Fields::Unit => bail!(v, "a unit variant is not a valid subquery"), }; - Ok(parse_quote!(<#submsg as #crate_name::QueryResponses>::response_schemas_impl())) + let return_val = match schema_backend { + SchemaBackend::CwSchema => { + parse_quote!(<#submsg as #crate_name::QueryResponses>::response_schemas_cw_impl()) + } + SchemaBackend::JsonSchema => { + parse_quote!(<#submsg as #crate_name::QueryResponses>::response_schemas_impl()) + } + }; + + Ok(return_val) } fn parse_tuple((q, r): (String, Expr)) -> ExprTuple { @@ -188,6 +237,13 @@ mod tests { ("balance".to_string(), ::my_crate::cw_schema::schema_for!(SomeType)), ]) } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + ::std::collections::BTreeMap::from([ + ("supply".to_string(), ::my_crate::cw_schema::cw_schema::schema_of::()), + ("balance".to_string(), ::my_crate::cw_schema::cw_schema::schema_of::()), + ]) + } } } ); @@ -218,7 +274,16 @@ mod tests { ::response_schemas_impl(), ::response_schemas_impl(), ]; - ::my_crate::cw_schema::combine_subqueries::<3usize, ContractQueryMsg>(subqueries) + ::my_crate::cw_schema::combine_subqueries::<3usize, ContractQueryMsg, _>(subqueries) + } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + let subqueries = [ + ::response_schemas_cw_impl(), + ::response_schemas_cw_impl(), + ::response_schemas_cw_impl(), + ]; + ::my_crate::cw_schema::combine_subqueries::<3usize, ContractQueryMsg, _>(subqueries) } } } @@ -250,6 +315,13 @@ mod tests { ("balance".to_string(), ::cosmwasm_schema::schema_for!(SomeType)), ]) } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + ::std::collections::BTreeMap::from([ + ("supply".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()), + ("balance".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()), + ]) + } } } ); @@ -272,6 +344,10 @@ mod tests { fn response_schemas_impl() -> ::std::collections::BTreeMap { ::std::collections::BTreeMap::from([]) } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + ::std::collections::BTreeMap::from([]) + } } } ); @@ -321,13 +397,20 @@ mod tests { parse_quote! { #[automatically_derived] #[cfg(not(target_arch = "wasm32"))] - impl ::cosmwasm_schema::QueryResponses for QueryMsg { + impl ::cosmwasm_schema::QueryResponses for QueryMsg { fn response_schemas_impl() -> ::std::collections::BTreeMap { ::std::collections::BTreeMap::from([ ("foo".to_string(), ::cosmwasm_schema::schema_for!(bool)), ("bar".to_string(), ::cosmwasm_schema::schema_for!(u32)), ]) } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + ::std::collections::BTreeMap::from([ + ("foo".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()), + ("bar".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()), + ]) + } } } ); @@ -336,13 +419,20 @@ mod tests { parse_quote! { #[automatically_derived] #[cfg(not(target_arch = "wasm32"))] - impl ::cosmwasm_schema::QueryResponses for QueryMsg { + impl ::cosmwasm_schema::QueryResponses for QueryMsg { fn response_schemas_impl() -> ::std::collections::BTreeMap { ::std::collections::BTreeMap::from([ ("foo".to_string(), ::cosmwasm_schema::schema_for!(bool)), ("bar".to_string(), ::cosmwasm_schema::schema_for!(u32)), ]) } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + ::std::collections::BTreeMap::from([ + ("foo".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()), + ("bar".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()), + ]) + } } } ); @@ -352,7 +442,7 @@ mod tests { parse_quote! { #[automatically_derived] #[cfg(not(target_arch = "wasm32"))] - impl ::cosmwasm_schema::QueryResponses for QueryMsg + impl ::cosmwasm_schema::QueryResponses for QueryMsg where T: std::fmt::Debug + SomeTrait, { fn response_schemas_impl() -> ::std::collections::BTreeMap { @@ -361,6 +451,13 @@ mod tests { ("bar".to_string(), ::cosmwasm_schema::schema_for!(u32)), ]) } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + ::std::collections::BTreeMap::from([ + ("foo".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()), + ("bar".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()), + ]) + } } } ); @@ -407,11 +504,17 @@ mod tests { }; assert_eq!( - parse_tuple(parse_query(&test_context(), variant).unwrap()), + parse_tuple(parse_query(&test_context(), &variant, SchemaBackend::JsonSchema).unwrap()), parse_quote! { ("get_foo".to_string(), ::cosmwasm_schema::schema_for!(Foo)) } ); + assert_eq!( + parse_tuple(parse_query(&test_context(), &variant, SchemaBackend::CwSchema).unwrap()), + parse_quote! { + ("get_foo".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()) + } + ); let variant = parse_quote! { #[returns(some_crate::Foo)] @@ -419,9 +522,13 @@ mod tests { }; assert_eq!( - parse_tuple(parse_query(&test_context(), variant).unwrap()), + parse_tuple(parse_query(&test_context(), &variant, SchemaBackend::JsonSchema).unwrap()), parse_quote! { ("get_foo".to_string(), ::cosmwasm_schema::schema_for!(some_crate::Foo)) } ); + assert_eq!( + parse_tuple(parse_query(&test_context(), &variant, SchemaBackend::CwSchema).unwrap()), + parse_quote! { ("get_foo".to_string(), ::cosmwasm_schema::cw_schema::schema_of::()) } + ); } #[test] @@ -455,7 +562,16 @@ mod tests { ::response_schemas_impl(), ::response_schemas_impl(), ]; - ::cosmwasm_schema::combine_subqueries::<3usize, ContractQueryMsg>(subqueries) + ::cosmwasm_schema::combine_subqueries::<3usize, ContractQueryMsg, _>(subqueries) + } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + let subqueries = [ + ::response_schemas_cw_impl(), + ::response_schemas_cw_impl(), + ::response_schemas_cw_impl(), + ]; + ::cosmwasm_schema::combine_subqueries::<3usize, ContractQueryMsg, _>(subqueries) } } } @@ -479,7 +595,12 @@ mod tests { impl ::cosmwasm_schema::QueryResponses for EmptyMsg { fn response_schemas_impl() -> ::std::collections::BTreeMap { let subqueries = []; - ::cosmwasm_schema::combine_subqueries::<0usize, EmptyMsg>(subqueries) + ::cosmwasm_schema::combine_subqueries::<0usize, EmptyMsg, _>(subqueries) + } + + fn response_schemas_cw_impl() -> ::std::collections::BTreeMap { + let subqueries = []; + ::cosmwasm_schema::combine_subqueries::<0usize, EmptyMsg, _>(subqueries) } } } diff --git a/packages/schema/Cargo.toml b/packages/schema/Cargo.toml index 0ea8618e7b..d1cb371421 100644 --- a/packages/schema/Cargo.toml +++ b/packages/schema/Cargo.toml @@ -12,6 +12,7 @@ license = "Apache-2.0" [dependencies] cosmwasm-schema-derive = { version = "=2.2.0-rc.1", path = "../schema-derive" } +cw-schema = { version = "=2.2.0-rc.1", path = "../cw-schema" } schemars = { workspace = true } serde = { workspace = true } serde_json = "1.0.40" diff --git a/packages/schema/src/idl.rs b/packages/schema/src/idl.rs index dc47b239ec..6177636d61 100644 --- a/packages/schema/src/idl.rs +++ b/packages/schema/src/idl.rs @@ -11,6 +11,35 @@ use thiserror::Error; // To determine if a change is breaking, assume consumers allow unknown fields and bump accordingly. pub const IDL_VERSION: &str = "1.0.0"; +/// Rust representation of a contract's API. +pub struct CwApi { + pub contract_name: String, + pub contract_version: String, + pub instantiate: Option, + pub execute: Option, + pub query: Option, + pub migrate: Option, + pub sudo: Option, + /// A mapping of query variants to response types + pub responses: Option>, +} + +impl CwApi { + pub fn render(self) -> JsonCwApi { + JsonCwApi { + contract_name: self.contract_name, + contract_version: self.contract_version, + idl_version: IDL_VERSION.to_string(), + instantiate: self.instantiate, + execute: self.execute, + query: self.query, + migrate: self.migrate, + sudo: self.sudo, + responses: self.responses, + } + } +} + /// Rust representation of a contract's API. pub struct Api { pub contract_name: String, @@ -68,6 +97,76 @@ impl Api { } } +/// A JSON representation of a contract's API. +#[derive(serde::Deserialize, serde::Serialize)] +pub struct JsonCwApi { + pub contract_name: String, + pub contract_version: String, + pub idl_version: String, + pub instantiate: Option, + pub execute: Option, + pub query: Option, + pub migrate: Option, + pub sudo: Option, + pub responses: Option>, +} + +impl JsonCwApi { + pub fn to_string(&self) -> Result { + serde_json::to_string_pretty(&self).map_err(Into::into) + } + + pub fn to_schema_files(&self) -> Result, EncodeError> { + let mut result = Vec::new(); + + if let Some(instantiate) = &self.instantiate { + result.push(( + "instantiate.json".to_string(), + serde_json::to_string_pretty(&instantiate)?, + )); + } + + if let Some(execute) = &self.execute { + result.push(( + "execute.json".to_string(), + serde_json::to_string_pretty(&execute)?, + )); + } + if let Some(query) = &self.query { + result.push(( + "query.json".to_string(), + serde_json::to_string_pretty(&query)?, + )); + } + if let Some(migrate) = &self.migrate { + result.push(( + "migrate.json".to_string(), + serde_json::to_string_pretty(&migrate)?, + )); + } + if let Some(sudo) = &self.sudo { + result.push(( + "sudo.json".to_string(), + serde_json::to_string_pretty(&sudo)?, + )); + } + if let Some(responses) = &self.responses { + for (name, response) in responses { + result.push(( + format!("response_to_{name}.json"), + serde_json::to_string_pretty(&response)?, + )); + } + } + + Ok(result) + } + + pub fn to_writer(&self, writer: impl std::io::Write) -> Result<(), EncodeError> { + serde_json::to_writer_pretty(writer, self).map_err(Into::into) + } +} + /// A JSON representation of a contract's API. #[derive(serde::Serialize)] pub struct JsonApi { diff --git a/packages/schema/src/lib.rs b/packages/schema/src/lib.rs index 2abc7fe8f8..628eb1ed30 100644 --- a/packages/schema/src/lib.rs +++ b/packages/schema/src/lib.rs @@ -6,7 +6,7 @@ mod remove; mod schema_for; pub use export::{export_schema, export_schema_with_title}; -pub use idl::{Api, IDL_VERSION}; +pub use idl::{Api, CwApi, IDL_VERSION}; pub use query_response::{combine_subqueries, IntegrityError, QueryResponses}; pub use remove::remove_schemas; @@ -94,5 +94,9 @@ pub use cosmwasm_schema_derive::generate_api; pub use cosmwasm_schema_derive::write_api; // For use in macro expansions +pub use cw_schema; pub use schemars; pub use serde; + +#[doc(hidden)] +pub use self::idl::JsonCwApi; diff --git a/packages/schema/src/query_response.rs b/packages/schema/src/query_response.rs index 85ecc7f3b2..fac902a35f 100644 --- a/packages/schema/src/query_response.rs +++ b/packages/schema/src/query_response.rs @@ -13,14 +13,15 @@ pub use cosmwasm_schema_derive::QueryResponses; /// # Examples /// ``` /// use cosmwasm_schema::QueryResponses; +/// use cw_schema::Schemaifier; /// use schemars::JsonSchema; /// -/// #[derive(JsonSchema)] +/// #[derive(JsonSchema, Schemaifier)] /// struct AccountInfo { /// IcqHandle: String, /// } /// -/// #[derive(JsonSchema, QueryResponses)] +/// #[derive(JsonSchema, Schemaifier, QueryResponses)] /// enum QueryMsg { /// #[returns(Vec)] /// Denoms {}, @@ -37,7 +38,8 @@ pub use cosmwasm_schema_derive::QueryResponses; /// ``` /// # use cosmwasm_schema::QueryResponses; /// # use schemars::JsonSchema; -/// #[derive(JsonSchema, QueryResponses)] +/// # use cw_schema::Schemaifier; +/// #[derive(JsonSchema, Schemaifier, QueryResponses)] /// #[query_responses(nested)] /// #[serde(untagged)] /// enum QueryMsg { @@ -45,19 +47,19 @@ pub use cosmwasm_schema_derive::QueryResponses; /// MsgB(QueryB), /// } /// -/// #[derive(JsonSchema, QueryResponses)] +/// #[derive(JsonSchema, Schemaifier, QueryResponses)] /// enum QueryA { /// #[returns(Vec)] /// Denoms {}, /// } /// -/// #[derive(JsonSchema, QueryResponses)] +/// #[derive(JsonSchema, Schemaifier, QueryResponses)] /// enum QueryB { /// #[returns(AccountInfo)] /// AccountInfo { account: String }, /// } /// -/// # #[derive(JsonSchema)] +/// # #[derive(JsonSchema, Schemaifier)] /// # struct AccountInfo { /// # IcqHandle: String, /// # } @@ -70,13 +72,21 @@ pub trait QueryResponses: JsonSchema { } fn response_schemas_impl() -> BTreeMap; + + fn response_schemas_cw() -> Result, IntegrityError> { + let response_schemas = Self::response_schemas_cw_impl(); + + Ok(response_schemas) + } + + fn response_schemas_cw_impl() -> BTreeMap; } /// Combines multiple response schemas into one. Panics if there are name collisions. /// Used internally in the implementation of [`QueryResponses`] when using `#[query_responses(nested)]` -pub fn combine_subqueries( - subqueries: [BTreeMap; N], -) -> BTreeMap { +pub fn combine_subqueries( + subqueries: [BTreeMap; N], +) -> BTreeMap { let sub_count = subqueries.iter().flatten().count(); let map: BTreeMap<_, _> = subqueries.into_iter().flatten().collect(); if map.len() != sub_count { @@ -105,6 +115,7 @@ pub enum IntegrityError { #[cfg(test)] mod tests { + use cw_schema::schema_of; use schemars::schema_for; use super::*; @@ -130,6 +141,16 @@ mod tests { ("account_count".to_string(), schema_for!(u128)), ]) } + + fn response_schemas_cw_impl() -> BTreeMap { + BTreeMap::from([ + ("balance_for".to_string(), schema_of::()), + ("account_id_for".to_string(), schema_of::()), + ("supply".to_string(), schema_of::()), + ("liquidity".to_string(), schema_of::()), + ("account_count".to_string(), schema_of::()), + ]) + } } #[test] @@ -156,6 +177,10 @@ mod tests { fn response_schemas_impl() -> BTreeMap { BTreeMap::from([]) } + + fn response_schemas_cw_impl() -> BTreeMap { + BTreeMap::from([]) + } } #[test] @@ -175,6 +200,10 @@ mod tests { fn response_schemas_impl() -> BTreeMap { BTreeMap::from([("balance_for".to_string(), schema_for!(u128))]) } + + fn response_schemas_cw_impl() -> BTreeMap { + BTreeMap::from([("balance_for".to_string(), schema_of::())]) + } } #[derive(Debug, JsonSchema)] @@ -204,6 +233,17 @@ mod tests { ("extension".to_string(), schema_for!(())), ]) } + + fn response_schemas_cw_impl() -> BTreeMap { + BTreeMap::from([ + ("balance_for".to_string(), schema_of::()), + ("account_id_for".to_string(), schema_of::()), + ("supply".to_string(), schema_of::()), + ("liquidity".to_string(), schema_of::()), + ("account_count".to_string(), schema_of::()), + ("extension".to_string(), schema_of::<()>()), + ]) + } } #[test] diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 408ea72fbb..0207f911fc 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -57,6 +57,7 @@ base64 = "0.22.0" bnum = "0.11.0" cosmwasm-core = { version = "2.2.0-rc.1", path = "../core" } cosmwasm-derive = { version = "2.2.0-rc.1", path = "../derive" } +cw-schema = { version = "2.2.0-rc.1", path = "../cw-schema" } derive_more = { version = "1.0.0-beta.6", default-features = false, features = [ "debug", ] } diff --git a/packages/std/src/addresses.rs b/packages/std/src/addresses.rs index d23c5b1aa3..96faffa827 100644 --- a/packages/std/src/addresses.rs +++ b/packages/std/src/addresses.rs @@ -27,8 +27,19 @@ use crate::{HexBinary, __internal::forward_ref_partial_eq}; /// a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` /// instance. #[derive( - Serialize, Deserialize, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, schemars::JsonSchema, + Serialize, + Deserialize, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + schemars::JsonSchema, + cw_schema::Schemaifier, )] +#[schemaifier(type = cw_schema::NodeType::Address)] pub struct Addr(String); forward_ref_partial_eq!(Addr, Addr); diff --git a/packages/std/src/binary.rs b/packages/std/src/binary.rs index 441a6770c1..c3834a47c2 100644 --- a/packages/std/src/binary.rs +++ b/packages/std/src/binary.rs @@ -14,7 +14,18 @@ use crate::{ /// /// This is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. /// See also . -#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Clone, + Default, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Binary)] pub struct Binary(#[schemars(with = "String")] Vec); impl Binary { diff --git a/packages/std/src/checksum.rs b/packages/std/src/checksum.rs index 5a5c26a00e..d67c7ebf67 100644 --- a/packages/std/src/checksum.rs +++ b/packages/std/src/checksum.rs @@ -13,7 +13,8 @@ use crate::{StdError, StdResult}; /// /// This is often referred to as "code ID" in go-cosmwasm, even if code ID /// usually refers to an auto-incrementing number. -#[derive(JsonSchema, Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(JsonSchema, Debug, Copy, Clone, PartialEq, Eq, Hash, cw_schema::Schemaifier)] +#[schemaifier(type = cw_schema::NodeType::Checksum)] pub struct Checksum(#[schemars(with = "String")] [u8; 32]); impl Checksum { diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index c0c055b37d..9cdb80bad0 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -6,7 +6,9 @@ use crate::prelude::*; use crate::CoinFromStrError; use crate::Uint128; -#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Default, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct Coin { pub denom: String, pub amount: Uint128, diff --git a/packages/std/src/errors/system_error.rs b/packages/std/src/errors/system_error.rs index ea9052e4d7..1206a921f6 100644 --- a/packages/std/src/errors/system_error.rs +++ b/packages/std/src/errors/system_error.rs @@ -13,7 +13,15 @@ use crate::Binary; /// Such errors are only created by the VM. The error type is defined in the standard library, to ensure /// the contract understands the error format without creating a dependency on cosmwasm-vm. #[derive( - Serialize, Deserialize, Clone, Debug, PartialEq, Eq, schemars::JsonSchema, thiserror::Error, + Serialize, + Deserialize, + Clone, + Debug, + PartialEq, + Eq, + schemars::JsonSchema, + thiserror::Error, + cw_schema::Schemaifier, )] #[serde(rename_all = "snake_case")] #[non_exhaustive] diff --git a/packages/std/src/hex_binary.rs b/packages/std/src/hex_binary.rs index 723db38505..025067400d 100644 --- a/packages/std/src/hex_binary.rs +++ b/packages/std/src/hex_binary.rs @@ -14,7 +14,18 @@ use crate::{ /// /// This is similar to `cosmwasm_std::Binary` but uses hex. /// See also . -#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Clone, + Default, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::HexBinary)] pub struct HexBinary(#[schemars(with = "String")] Vec); impl HexBinary { diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 5612cf5ebb..5551ec729b 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -21,7 +21,9 @@ pub use transfer_msg_builder::*; /// These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts /// (contracts that directly speak the IBC protocol via 6 entry points) #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum IbcMsg { /// Sends bank tokens owned by the contract to the given address on another chain. @@ -144,7 +146,9 @@ pub enum IbcMsg { }, } -#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Default, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct IbcFee { // the packet receive fee pub receive_fee: Vec, @@ -154,7 +158,9 @@ pub struct IbcFee { pub timeout_fee: Vec, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct IbcEndpoint { pub port_id: String, pub channel_id: String, @@ -163,7 +169,9 @@ pub struct IbcEndpoint { /// In IBC each package must set at least one type of timeout: /// the timestamp or the block height. Using this rather complex enum instead of /// two timeout fields we ensure that at least one timeout is set. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub struct IbcTimeout { // use private fields to enforce the use of constructors, which ensure that at least one is set @@ -218,7 +226,9 @@ impl From for IbcTimeout { /// IbcChannel defines all information on a channel. /// This is generally used in the hand-shake process, but can be queried directly. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcChannel { pub endpoint: IbcEndpoint, @@ -253,7 +263,9 @@ impl IbcChannel { /// IbcOrder defines if a channel is ORDERED or UNORDERED /// Values come from https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/ibc/core/channel/v1/channel.proto#L69-L80 /// Naming comes from the protobuf files and go translations. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub enum IbcOrder { #[serde(rename = "ORDER_UNORDERED")] Unordered, @@ -265,7 +277,9 @@ pub enum IbcOrder { /// that can be compared against another Height for the purposes of updating and /// freezing clients. /// Ordering is (revision_number, timeout_height) -#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct IbcTimeoutBlock { /// the version that the client is currently on /// (e.g. after resetting the chain this could increment 1 as height drops to 0) @@ -296,7 +310,9 @@ impl Ord for IbcTimeoutBlock { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcPacket { /// The raw data sent from the other side in the packet @@ -329,7 +345,9 @@ impl IbcPacket { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcAcknowledgement { pub data: Binary, @@ -350,7 +368,9 @@ impl IbcAcknowledgement { } /// The message that is passed into `ibc_channel_open` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum IbcChannelOpenMsg { /// The ChanOpenInit step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management @@ -406,14 +426,18 @@ impl From for IbcChannel { /// If `null` is provided instead, the incoming channel version is accepted. pub type IbcChannelOpenResponse = Option; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct Ibc3ChannelOpenResponse { /// We can set the channel version to a different one than we were called with pub version: String, } /// The message that is passed into `ibc_channel_connect` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum IbcChannelConnectMsg { /// The ChanOpenAck step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management @@ -465,7 +489,9 @@ impl From for IbcChannel { } /// The message that is passed into `ibc_channel_close` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum IbcChannelCloseMsg { /// The ChanCloseInit step from https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#channel-lifecycle-management @@ -501,7 +527,9 @@ impl From for IbcChannel { } /// The message that is passed into `ibc_packet_receive` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcPacketReceiveMsg { pub packet: IbcPacket, @@ -515,7 +543,9 @@ impl IbcPacketReceiveMsg { } /// The message that is passed into `ibc_packet_ack` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcPacketAckMsg { pub acknowledgement: IbcAcknowledgement, @@ -538,7 +568,9 @@ impl IbcPacketAckMsg { } /// The message that is passed into `ibc_packet_timeout` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcPacketTimeoutMsg { pub packet: IbcPacket, @@ -558,7 +590,9 @@ impl IbcPacketTimeoutMsg { /// Callbacks that have return values (like receive_packet) /// or that cannot redispatch messages (like the handshake callbacks) /// will use other Response types -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcBasicResponse { /// Optional list of messages to pass. These will be executed in order. @@ -700,7 +734,9 @@ impl IbcBasicResponse { /// Where the acknowledgement bytes contain an encoded error message to be returned to /// the calling chain. (Returning ContractResult::Err will abort processing of this packet /// and not inform the calling chain). -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcReceiveResponse { /// The bytes we return to the contract that sent the packet. diff --git a/packages/std/src/ibc/callbacks.rs b/packages/std/src/ibc/callbacks.rs index 56ab5f4114..468d3ae3ad 100644 --- a/packages/std/src/ibc/callbacks.rs +++ b/packages/std/src/ibc/callbacks.rs @@ -57,7 +57,9 @@ use crate::{Addr, IbcAcknowledgement, IbcPacket, Uint64}; /// })).unwrap()), /// }; /// ``` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct IbcCallbackRequest { // using private fields to force use of the constructors #[serde(skip_serializing_if = "Option::is_none")] @@ -92,7 +94,9 @@ impl IbcCallbackRequest { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct IbcSrcCallback { /// The source chain address that should receive the callback. /// For CosmWasm contracts, this *must* be `env.contract.address`. @@ -103,7 +107,9 @@ pub struct IbcSrcCallback { pub gas_limit: Option, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct IbcDstCallback { /// The destination chain address that should receive the callback. pub address: String, @@ -126,14 +132,18 @@ pub struct IbcDstCallback { /// - You have to add serialized [`IbcCallbackRequest`] to a specific field of the message. /// For `IbcMsg::Transfer`, this is the `memo` field and it needs to be json-encoded. /// - The receiver of the callback must also be the sender of the message. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum IbcSourceCallbackMsg { Acknowledgement(IbcAckCallbackMsg), Timeout(IbcTimeoutCallbackMsg), } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcAckCallbackMsg { pub acknowledgement: IbcAcknowledgement, @@ -155,7 +165,9 @@ impl IbcAckCallbackMsg { } } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct IbcTimeoutCallbackMsg { pub packet: IbcPacket, @@ -187,7 +199,9 @@ impl IbcTimeoutCallbackMsg { /// - The IBC application in the destination chain must have support for the callbacks middleware. /// - You have to add serialized [`IbcCallbackRequest`] to a specific field of the message. /// For `IbcMsg::Transfer`, this is the `memo` field and it needs to be json-encoded. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct IbcDestinationCallbackMsg { pub packet: IbcPacket, pub ack: IbcAcknowledgement, diff --git a/packages/std/src/iterator.rs b/packages/std/src/iterator.rs index 41f043a093..e33773df82 100644 --- a/packages/std/src/iterator.rs +++ b/packages/std/src/iterator.rs @@ -8,7 +8,9 @@ use serde::{Deserialize, Serialize}; /// allows contracts to reuse the type when deserializing database records. pub type Record> = (Vec, V); -#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] // We assign these to integers to provide a stable API for passing over FFI (to wasm and Go) pub enum Order { diff --git a/packages/std/src/math/decimal.rs b/packages/std/src/math/decimal.rs index 19b1c0a293..266c752b19 100644 --- a/packages/std/src/math/decimal.rs +++ b/packages/std/src/math/decimal.rs @@ -19,7 +19,18 @@ use super::{Uint128, Uint256}; /// A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0 /// /// The greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18) -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Decimal { precision: 128, signed: false })] pub struct Decimal(#[schemars(with = "String")] Uint128); forward_ref_partial_eq!(Decimal, Decimal); diff --git a/packages/std/src/math/decimal256.rs b/packages/std/src/math/decimal256.rs index a37a0ffeec..4c6fc4c458 100644 --- a/packages/std/src/math/decimal256.rs +++ b/packages/std/src/math/decimal256.rs @@ -23,7 +23,18 @@ use super::Uint256; /// The greatest possible value that can be represented is /// 115792089237316195423570985008687907853269984665640564039457.584007913129639935 /// (which is (2^256 - 1) / 10^18) -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Decimal { precision: 256, signed: false })] pub struct Decimal256(#[schemars(with = "String")] Uint256); forward_ref_partial_eq!(Decimal256, Decimal256); diff --git a/packages/std/src/math/int128.rs b/packages/std/src/math/int128.rs index 9f0f35d59d..77b8a62a69 100644 --- a/packages/std/src/math/int128.rs +++ b/packages/std/src/math/int128.rs @@ -30,7 +30,19 @@ use super::num_consts::NumConsts; /// let a = Int128::from(258i128); /// assert_eq!(a.i128(), 258); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 128, signed: true })] pub struct Int128(#[schemars(with = "String")] pub(crate) i128); impl_int_serde!(Int128); diff --git a/packages/std/src/math/int256.rs b/packages/std/src/math/int256.rs index e12b1d0319..27629a3208 100644 --- a/packages/std/src/math/int256.rs +++ b/packages/std/src/math/int256.rs @@ -41,7 +41,19 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 256, signed: true })] pub struct Int256(#[schemars(with = "String")] pub(crate) I256); impl_int_serde!(Int256); diff --git a/packages/std/src/math/int512.rs b/packages/std/src/math/int512.rs index c51351ae7a..a9e2f0475a 100644 --- a/packages/std/src/math/int512.rs +++ b/packages/std/src/math/int512.rs @@ -44,7 +44,19 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 512, signed: true })] pub struct Int512(#[schemars(with = "String")] pub(crate) I512); impl_int_serde!(Int512); diff --git a/packages/std/src/math/int64.rs b/packages/std/src/math/int64.rs index 3a3594fe42..de80ffd822 100644 --- a/packages/std/src/math/int64.rs +++ b/packages/std/src/math/int64.rs @@ -30,7 +30,19 @@ use super::num_consts::NumConsts; /// let a = Int64::from(258i64); /// assert_eq!(a.i64(), 258); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 64, signed: true })] pub struct Int64(#[schemars(with = "String")] pub(crate) i64); impl_int_serde!(Int64); diff --git a/packages/std/src/math/signed_decimal.rs b/packages/std/src/math/signed_decimal.rs index 5dd82b10e1..249f5de155 100644 --- a/packages/std/src/math/signed_decimal.rs +++ b/packages/std/src/math/signed_decimal.rs @@ -21,7 +21,18 @@ use super::Int128; /// /// The greatest possible value that can be represented is 170141183460469231731.687303715884105727 (which is (2^127 - 1) / 10^18) /// and the smallest is -170141183460469231731.687303715884105728 (which is -2^127 / 10^18). -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Decimal { precision: 128, signed: true })] pub struct SignedDecimal(#[schemars(with = "String")] Int128); forward_ref_partial_eq!(SignedDecimal, SignedDecimal); diff --git a/packages/std/src/math/signed_decimal_256.rs b/packages/std/src/math/signed_decimal_256.rs index e994bd7bac..6f5439bdd0 100644 --- a/packages/std/src/math/signed_decimal_256.rs +++ b/packages/std/src/math/signed_decimal_256.rs @@ -26,7 +26,18 @@ use super::Int256; /// and the smallest is /// -57896044618658097711785492504343953926634992332820282019728.792003956564819968 /// (which is -2^255 / 10^18). -#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Decimal { precision: 256, signed: true })] pub struct SignedDecimal256(#[schemars(with = "String")] Int256); forward_ref_partial_eq!(SignedDecimal256, SignedDecimal256); diff --git a/packages/std/src/math/uint128.rs b/packages/std/src/math/uint128.rs index 1511deca7c..e4a702ca2a 100644 --- a/packages/std/src/math/uint128.rs +++ b/packages/std/src/math/uint128.rs @@ -39,7 +39,19 @@ use super::num_consts::NumConsts; /// let c = Uint128::from(70u32); /// assert_eq!(c.u128(), 70); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 128, signed: false })] pub struct Uint128(#[schemars(with = "String")] pub(crate) u128); impl_int_serde!(Uint128); diff --git a/packages/std/src/math/uint256.rs b/packages/std/src/math/uint256.rs index 88d3108719..605e55b69a 100644 --- a/packages/std/src/math/uint256.rs +++ b/packages/std/src/math/uint256.rs @@ -44,7 +44,19 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 256, signed: false })] pub struct Uint256(#[schemars(with = "String")] pub(crate) U256); impl_int_serde!(Uint256); diff --git a/packages/std/src/math/uint512.rs b/packages/std/src/math/uint512.rs index 0332808df8..475db792b5 100644 --- a/packages/std/src/math/uint512.rs +++ b/packages/std/src/math/uint512.rs @@ -46,7 +46,19 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 512, signed: false })] pub struct Uint512(#[schemars(with = "String")] pub(crate) U512); impl_int_serde!(Uint512); diff --git a/packages/std/src/math/uint64.rs b/packages/std/src/math/uint64.rs index 9fecc24953..ea9c1e3b57 100644 --- a/packages/std/src/math/uint64.rs +++ b/packages/std/src/math/uint64.rs @@ -35,7 +35,19 @@ use super::num_consts::NumConsts; /// let b = Uint64::from(70u32); /// assert_eq!(b.u64(), 70); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 64, signed: false })] pub struct Uint64(#[schemars(with = "String")] pub(crate) u64); impl_int_serde!(Uint64); diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index b741f32099..1f9f458067 100644 --- a/packages/std/src/metadata.rs +++ b/packages/std/src/metadata.rs @@ -4,7 +4,9 @@ use serde::{Deserialize, Serialize}; use crate::prelude::*; /// Replicates the cosmos-sdk bank module Metadata type -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct DenomMetadata { pub description: String, pub denom_units: Vec, @@ -17,7 +19,9 @@ pub struct DenomMetadata { } /// Replicates the cosmos-sdk bank module DenomUnit type -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct DenomUnit { pub denom: String, pub exponent: u32, diff --git a/packages/std/src/never.rs b/packages/std/src/never.rs index 51173892f5..f63eadac01 100644 --- a/packages/std/src/never.rs +++ b/packages/std/src/never.rs @@ -25,6 +25,7 @@ /// let res: Result = Ok(5); /// assert_eq!(safe_unwrap(res), 5); /// ``` +#[derive(cw_schema::Schemaifier)] pub enum Never {} // The Debug implementation is needed to allow the use of `Result::unwrap`. diff --git a/packages/std/src/pagination.rs b/packages/std/src/pagination.rs index d9d1d8ef96..1b402d6169 100644 --- a/packages/std/src/pagination.rs +++ b/packages/std/src/pagination.rs @@ -4,7 +4,9 @@ use serde::{Deserialize, Serialize}; use crate::Binary; /// Simplified version of the PageRequest type for pagination from the cosmos-sdk -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct PageRequest { pub key: Option, pub limit: u32, diff --git a/packages/std/src/query/bank.rs b/packages/std/src/query/bank.rs index 7bd4f62e97..caab565d9d 100644 --- a/packages/std/src/query/bank.rs +++ b/packages/std/src/query/bank.rs @@ -11,7 +11,9 @@ use crate::{Binary, DenomMetadata}; use super::query_response::QueryResponseType; #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum BankQuery { /// This calls into the native bank module for querying the total supply of one denomination. @@ -37,7 +39,9 @@ pub enum BankQuery { AllDenomMetadata { pagination: Option }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct SupplyResponse { @@ -50,7 +54,9 @@ impl_response_constructor!(SupplyResponse, amount: Coin); impl QueryResponseType for SupplyResponse {} -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct BalanceResponse { @@ -63,7 +69,9 @@ impl_response_constructor!(BalanceResponse, amount: Coin); impl QueryResponseType for BalanceResponse {} -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct AllBalanceResponse { @@ -75,7 +83,9 @@ impl_response_constructor!(AllBalanceResponse, amount: Vec); impl QueryResponseType for AllBalanceResponse {} -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct DenomMetadataResponse { @@ -87,7 +97,9 @@ impl_response_constructor!(DenomMetadataResponse, metadata: DenomMetadata); impl QueryResponseType for DenomMetadataResponse {} -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct AllDenomMetadataResponse { diff --git a/packages/std/src/query/distribution.rs b/packages/std/src/query/distribution.rs index 3e840b74ba..3623f6b17f 100644 --- a/packages/std/src/query/distribution.rs +++ b/packages/std/src/query/distribution.rs @@ -7,7 +7,9 @@ use crate::{Addr, Decimal256}; use super::query_response::QueryResponseType; #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum DistributionQuery { /// See @@ -27,7 +29,9 @@ pub enum DistributionQuery { } /// See -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct DelegatorWithdrawAddressResponse { @@ -38,7 +42,9 @@ impl_response_constructor!(DelegatorWithdrawAddressResponse, withdraw_address: A impl QueryResponseType for DelegatorWithdrawAddressResponse {} /// See -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct DelegationRewardsResponse { @@ -57,7 +63,9 @@ impl QueryResponseType for DelegationRewardsResponse {} /// wasmd needs to truncate the decimal places to 18. /// /// [DecCoin]: (https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/proto/cosmos/base/v1beta1/coin.proto#L28-L38) -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub struct DecCoin { pub denom: String, @@ -78,7 +86,9 @@ impl DecCoin { } /// See -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct DelegationTotalRewardsResponse { pub rewards: Vec, @@ -92,7 +102,9 @@ impl_response_constructor!( ); impl QueryResponseType for DelegationTotalRewardsResponse {} -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct DelegatorReward { pub validator_address: String, @@ -105,7 +117,9 @@ impl_response_constructor!( ); /// See -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct DelegatorValidatorsResponse { pub validators: Vec, diff --git a/packages/std/src/query/ibc.rs b/packages/std/src/query/ibc.rs index 123156ea24..e297682e96 100644 --- a/packages/std/src/query/ibc.rs +++ b/packages/std/src/query/ibc.rs @@ -8,7 +8,9 @@ use crate::prelude::*; /// IBC connection. /// Most of these will return errors if the contract is not "ibc enabled". #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum IbcQuery { /// Gets the Port ID the current contract is bound to. @@ -42,7 +44,9 @@ pub enum IbcQuery { }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct PortIdResponse { pub port_id: String, @@ -50,7 +54,9 @@ pub struct PortIdResponse { impl_response_constructor!(PortIdResponse, port_id: String); -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct ListChannelsResponse { pub channels: Vec, @@ -58,7 +64,9 @@ pub struct ListChannelsResponse { impl_response_constructor!(ListChannelsResponse, channels: Vec); -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct ChannelResponse { pub channel: Option, @@ -66,7 +74,9 @@ pub struct ChannelResponse { impl_response_constructor!(ChannelResponse, channel: Option); -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct FeeEnabledChannelResponse { pub fee_enabled: bool, diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index 27e622592d..e188aeddf8 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -41,7 +41,9 @@ pub use staking::*; pub use wasm::*; #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum QueryRequest { Bank(BankQuery), @@ -84,7 +86,9 @@ pub enum QueryRequest { /// To find the path, as well as the request and response types, /// you can query the chain's gRPC endpoint using a tool like /// [grpcurl](https://github.com/fullstorydev/grpcurl). -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct GrpcQuery { /// The fully qualified endpoint path used for routing. /// It follows the format `/service_path/method_name`, @@ -104,7 +108,7 @@ pub struct GrpcQuery { /// # use cosmwasm_std::CustomQuery; /// # use schemars::JsonSchema; /// # use serde::{Deserialize, Serialize}; -/// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +/// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, cw_schema::Schemaifier)] /// #[serde(rename_all = "snake_case")] /// pub enum MyCustomQuery { /// Ping {}, diff --git a/packages/std/src/query/staking.rs b/packages/std/src/query/staking.rs index 3c5fd0ec2b..77fac97453 100644 --- a/packages/std/src/query/staking.rs +++ b/packages/std/src/query/staking.rs @@ -7,7 +7,9 @@ use crate::{Addr, Coin, Decimal}; use super::query_response::QueryResponseType; #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum StakingQuery { /// Returns the denomination that can be bonded (if there are multiple native tokens on the chain) @@ -35,7 +37,9 @@ pub enum StakingQuery { } /// BondedDenomResponse is data format returned from StakingRequest::BondedDenom query -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct BondedDenomResponse { @@ -47,7 +51,9 @@ impl QueryResponseType for BondedDenomResponse {} impl_response_constructor!(BondedDenomResponse, denom: String); /// DelegationsResponse is data format returned from StakingRequest::AllDelegations query -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct AllDelegationsResponse { @@ -61,7 +67,9 @@ impl_response_constructor!(AllDelegationsResponse, delegations: Vec) /// Delegation is basic (cheap to query) data about a delegation. /// /// Instances are created in the querier. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct Delegation { pub delegator: Addr, @@ -84,7 +92,9 @@ impl From for Delegation { } /// DelegationResponse is data format returned from StakingRequest::Delegation query -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] #[non_exhaustive] pub struct DelegationResponse { @@ -99,7 +109,9 @@ impl_response_constructor!(DelegationResponse, delegation: Option, @@ -158,7 +172,9 @@ impl QueryResponseType for AllValidatorsResponse {} impl_response_constructor!(AllValidatorsResponse, validators: Vec); /// The data format returned from StakingRequest::Validator query -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct ValidatorResponse { pub validator: Option, @@ -169,7 +185,9 @@ impl QueryResponseType for ValidatorResponse {} impl_response_constructor!(ValidatorResponse, validator: Option); /// Instances are created in the querier. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct Validator { /// The operator address of the validator (e.g. cosmosvaloper1...). diff --git a/packages/std/src/query/wasm.rs b/packages/std/src/query/wasm.rs index b05ba32d47..bfc5876884 100644 --- a/packages/std/src/query/wasm.rs +++ b/packages/std/src/query/wasm.rs @@ -7,7 +7,9 @@ use crate::{Addr, Binary, Checksum}; use super::query_response::QueryResponseType; #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum WasmQuery { /// this queries the public API of another contract at a known address (with known ABI) @@ -33,7 +35,9 @@ pub enum WasmQuery { } #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct ContractInfoResponse { pub code_id: u64, /// address that instantiated this contract @@ -65,7 +69,9 @@ impl_response_constructor!( /// [CodeInfo]: https://github.com/CosmWasm/wasmd/blob/v0.30.0/proto/cosmwasm/wasm/v1/types.proto#L62-L72 /// [CodeInfoResponse]: https://github.com/CosmWasm/wasmd/blob/v0.30.0/proto/cosmwasm/wasm/v1/query.proto#L184-L199 #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct CodeInfoResponse { pub code_id: u64, /// The address that initially stored the code diff --git a/packages/std/src/results/contract_result.rs b/packages/std/src/results/contract_result.rs index 82589f957c..4359e0969c 100644 --- a/packages/std/src/results/contract_result.rs +++ b/packages/std/src/results/contract_result.rs @@ -31,7 +31,9 @@ use crate::prelude::*; /// let result: ContractResult = ContractResult::Err(error_msg); /// assert_eq!(to_vec(&result).unwrap(), br#"{"error":"Something went wrong"}"#); /// ``` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum ContractResult { Ok(S), diff --git a/packages/std/src/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index 92af1d7b6f..d98c288cff 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -51,7 +51,9 @@ pub trait CustomMsg: Serialize + Clone + fmt::Debug + PartialEq + JsonSchema {} impl CustomMsg for Empty {} #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] // See https://github.com/serde-rs/serde/issues/1296 why we cannot add De-Serialize trait bounds to T pub enum CosmosMsg { @@ -116,7 +118,9 @@ impl CosmosMsg { /// /// See https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/bank/v1beta1/tx.proto #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum BankMsg { /// Sends native tokens from the contract to the given address. @@ -138,7 +142,9 @@ pub enum BankMsg { /// See https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto #[cfg(feature = "staking")] #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum StakingMsg { /// This is translated to a [MsgDelegate](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0/proto/cosmos/staking/v1beta1/tx.proto#L81-L90). @@ -161,7 +167,9 @@ pub enum StakingMsg { /// See https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto #[cfg(feature = "staking")] #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum DistributionMsg { /// This is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). @@ -187,7 +195,9 @@ pub enum DistributionMsg { /// A message encoded the same way as a protobuf [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). /// This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md) -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct AnyMsg { pub type_url: String, pub value: Binary, @@ -209,7 +219,9 @@ impl fmt::Display for BinaryToStringEncoder<'_> { /// /// See https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum WasmMsg { /// Dispatches a call to another contract at a known address (with known ABI). @@ -367,7 +379,9 @@ pub enum WasmMsg { /// } /// ``` #[cfg(feature = "stargate")] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum GovMsg { /// This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address. @@ -387,7 +401,9 @@ pub enum GovMsg { } #[cfg(feature = "stargate")] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum VoteOption { Yes, @@ -397,7 +413,9 @@ pub enum VoteOption { } #[cfg(all(feature = "stargate", feature = "cosmwasm_1_2"))] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct WeightedVoteOption { pub option: VoteOption, pub weight: Decimal, diff --git a/packages/std/src/results/empty.rs b/packages/std/src/results/empty.rs index 4c3b84db00..04c42b83f7 100644 --- a/packages/std/src/results/empty.rs +++ b/packages/std/src/results/empty.rs @@ -7,7 +7,9 @@ use serde::{Deserialize, Serialize}; /// It is designed to be expressible in correct JSON and JSON Schema but /// contains no meaningful data. Previously we used enums without cases, /// but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451) -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default, cw_schema::Schemaifier, +)] pub struct Empty {} #[cfg(test)] diff --git a/packages/std/src/results/events.rs b/packages/std/src/results/events.rs index 823a671a7c..fedc089567 100644 --- a/packages/std/src/results/events.rs +++ b/packages/std/src/results/events.rs @@ -12,7 +12,9 @@ use crate::prelude::*; /// /// [*Cosmos SDK* event]: https://docs.cosmos.network/main/learn/advanced/events /// [*Cosmos SDK* StringEvent]: https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/base/abci/v1beta1/abci.proto#L56-L70 -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct Event { /// The event type. This is renamed to "ty" because "type" is reserved in Rust. This sucks, we know. @@ -60,7 +62,9 @@ impl Event { } /// An key value pair that is used in the context of event attributes in logs -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct Attribute { pub key: String, pub value: String, diff --git a/packages/std/src/results/response.rs b/packages/std/src/results/response.rs index 11bfcc1484..edcc4da35b 100644 --- a/packages/std/src/results/response.rs +++ b/packages/std/src/results/response.rs @@ -60,7 +60,9 @@ use super::{Attribute, CosmosMsg, Empty, Event, SubMsg}; /// Ok(response) /// } /// ``` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[non_exhaustive] pub struct Response { /// Optional list of messages to pass. These will be executed in order. diff --git a/packages/std/src/results/submessages.rs b/packages/std/src/results/submessages.rs index d3b9175d79..637b882aa6 100644 --- a/packages/std/src/results/submessages.rs +++ b/packages/std/src/results/submessages.rs @@ -9,7 +9,9 @@ use super::{CosmosMsg, Empty, Event}; /// Use this to define when the contract gets a response callback. /// If you only need it for errors or success you can select just those in order /// to save gas. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum ReplyOn { /// Always perform a callback after SubMsg is processed @@ -28,7 +30,9 @@ pub enum ReplyOn { /// Note: On error the submessage execution will revert any partial state changes due to this message, /// but not revert any state changes in the calling contract. If this is required, it must be done /// manually in the `reply` entry point. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct SubMsg { /// An arbitrary ID chosen by the contract. /// This is typically used to match `Reply`s in the `reply` entry point to the submessage. @@ -166,7 +170,9 @@ impl SubMsg { /// The result object returned to `reply`. We always get the ID from the submessage /// back and then must handle success and error cases ourselves. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct Reply { /// The ID that the contract set when emitting the `SubMsg`. /// Use this to identify which submessage triggered the `reply`. @@ -226,7 +232,9 @@ pub struct Reply { /// let result = SubMsgResult::Err(error_msg); /// assert_eq!(to_json_string(&result).unwrap(), r#"{"error":"Something went wrong"}"#); /// ``` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum SubMsgResult { Ok(SubMsgResponse), @@ -282,7 +290,9 @@ impl From for Result { /// The information we get back from a successful sub message execution, /// with full Cosmos SDK events. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct SubMsgResponse { pub events: Vec, #[deprecated = "Deprecated in the Cosmos SDK in favor of msg_responses. If your chain is running on CosmWasm 2.0 or higher, msg_responses will be filled. For older versions, the data field is still needed since msg_responses is empty in those cases."] @@ -298,7 +308,9 @@ pub struct SubMsgResponse { pub msg_responses: Vec, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct MsgResponse { pub type_url: String, pub value: Binary, diff --git a/packages/std/src/results/system_result.rs b/packages/std/src/results/system_result.rs index 0623d08589..1ae1a03703 100644 --- a/packages/std/src/results/system_result.rs +++ b/packages/std/src/results/system_result.rs @@ -30,7 +30,9 @@ use crate::SystemError; /// let result: SystemResult = SystemResult::Err(error); /// assert_eq!(to_vec(&result).unwrap(), br#"{"error":{"unknown":{}}}"#); /// ``` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum SystemResult { Ok(S), diff --git a/packages/std/src/stdack.rs b/packages/std/src/stdack.rs index 229e44c0be..e3c8919901 100644 --- a/packages/std/src/stdack.rs +++ b/packages/std/src/stdack.rs @@ -34,7 +34,9 @@ use crate::Binary; /// let ack2 = StdAck::error("kaputt"); // Some free text error message /// assert!(ack2.is_error()); /// ``` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum StdAck { #[serde(rename = "result")] diff --git a/packages/std/src/timestamp.rs b/packages/std/src/timestamp.rs index 331304a03d..ee41cc27da 100644 --- a/packages/std/src/timestamp.rs +++ b/packages/std/src/timestamp.rs @@ -33,7 +33,9 @@ use crate::Uint64; PartialOrd, Ord, schemars::JsonSchema, + cw_schema::Schemaifier, )] +#[schemaifier(type = cw_schema::NodeType::Timestamp)] pub struct Timestamp(Uint64); impl Timestamp { diff --git a/packages/std/src/types.rs b/packages/std/src/types.rs index 180b745333..57bce01df7 100644 --- a/packages/std/src/types.rs +++ b/packages/std/src/types.rs @@ -5,7 +5,9 @@ use crate::coin::Coin; use crate::prelude::*; use crate::{Addr, Timestamp}; -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct Env { pub block: BlockInfo, /// Information on the transaction this message was executed in. @@ -15,7 +17,9 @@ pub struct Env { pub contract: ContractInfo, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct TransactionInfo { /// The position of this transaction in the block. The first /// transaction has index 0. @@ -26,7 +30,9 @@ pub struct TransactionInfo { pub index: u32, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct BlockInfo { /// The height of a block is the number of blocks preceding it in the blockchain. pub height: u64, @@ -87,7 +93,7 @@ pub struct BlockInfo { /// /// [MsgInstantiateContract]: https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L47-L61 /// [MsgExecuteContract]: https://github.com/CosmWasm/wasmd/blob/v0.15.0/x/wasm/internal/types/tx.proto#L68-L78 -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, cw_schema::Schemaifier)] pub struct MessageInfo { /// The `sender` field from `MsgInstantiateContract` and `MsgExecuteContract`. /// You can think of this as the address that initiated the action (i.e. the message). What that @@ -105,7 +111,9 @@ pub struct MessageInfo { pub funds: Vec, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct ContractInfo { pub address: Addr, }