diff --git a/Cargo.lock b/Cargo.lock index f2212c5721..87092ff8a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" @@ -627,8 +688,9 @@ version = "2.2.0-rc.1" dependencies = [ "anyhow", "cosmwasm-schema-derive", + "cw-schema", "insta", - "schemars", + "schemars 0.8.21", "semver", "serde", "serde_json", @@ -658,6 +720,7 @@ dependencies = [ "cosmwasm-derive", "cosmwasm-schema", "crc32fast", + "cw-schema", "derive_more", "hex", "hex-literal", @@ -665,7 +728,7 @@ dependencies = [ "proptest", "rand_core", "rmp-serde", - "schemars", + "schemars 0.8.21", "serde", "serde-json-wasm", "serde_json", @@ -697,7 +760,7 @@ dependencies = [ "leb128", "rand", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -754,7 +817,7 @@ dependencies = [ "clap", "criterion-plot", "is-terminal", - "itertools", + "itertools 0.10.5", "num-traits", "once_cell", "oorandom", @@ -775,7 +838,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -867,6 +930,57 @@ 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", + "cosmwasm-std", + "cw-schema", + "derive_arbitrary", + "either", + "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" @@ -887,6 +1001,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim", "syn 2.0.77", ] @@ -945,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" @@ -982,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" @@ -1077,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" @@ -1176,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" @@ -1254,9 +1386,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" @@ -1273,7 +1405,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "indenter", - "schemars", + "schemars 0.8.21", ] [[package]] @@ -1385,9 +1517,9 @@ 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", @@ -1417,6 +1549,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" @@ -1432,6 +1570,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" @@ -1482,9 +1629,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" @@ -1492,6 +1639,16 @@ 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" @@ -1516,9 +1673,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" @@ -1562,6 +1719,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" @@ -1583,6 +1771,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" @@ -1624,11 +1822,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", ] @@ -1645,6 +1852,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" @@ -1762,6 +1978,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" @@ -1936,6 +2162,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" @@ -2071,9 +2317,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", @@ -2110,7 +2356,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", ] @@ -2127,6 +2386,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" @@ -2166,9 +2437,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", ] @@ -2195,9 +2466,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", @@ -2217,15 +2488,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" @@ -2285,6 +2580,24 @@ 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" @@ -2311,9 +2624,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", ] @@ -2337,6 +2650,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" @@ -2373,14 +2696,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]] @@ -2423,7 +2747,9 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -2514,6 +2840,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" @@ -2807,7 +3142,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", ] @@ -3058,6 +3393,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/Cargo.toml b/Cargo.toml index c94fa10463..4e4c61c5aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = ["packages/*"] -exclude = ["contracts"] +exclude = ["contracts", "packages/cw-schema-codegen/tests/rust-e2e"] # Resolver has to be set explicitly in workspaces # due to https://github.com/rust-lang/cargo/issues/9956 diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index db478334f4..7c29760b7b 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 = [ "derive_more", "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 f078f22ab0..a341d16fd8 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 = [ "derive_more", "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 fcbc0a8a05..e3f09d02d9 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 = [ "derive_more", "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 0f67f168c1..1610a9ce5c 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 = [ "derive_more", "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 d1a02607cf..24ac28a342 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 = [ "derive_more", "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 e48e26da8c..3eb9f220f7 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 = [ "derive_more", "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 eda407d8c4..0c287e69e1 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 = [ "derive_more", "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 0db3107588..d31bf4a963 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 = [ "derive_more", "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 55f153d70a..c9a79e1526 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 = [ "derive_more", "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/nested-contracts/Cargo.lock b/contracts/nested-contracts/Cargo.lock index a109dc6831..9e91e26e2e 100644 --- a/contracts/nested-contracts/Cargo.lock +++ b/contracts/nested-contracts/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 = "ahash" @@ -212,15 +212,15 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "cosmwasm-core" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34c440d4d8e3ecec783d0f9c89d25565168b0f4cdb80a1f6a387cf2168c0740" +checksum = "de32156e4fd80c59be39ed6f4ebb596d59b0a4eaf01d6f146e27628ec7e8f8c1" [[package]] name = "cosmwasm-crypto" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134e765161d60228cc27635032d2a466542ca83fd6c87f3c87f4963c0bd51008" +checksum = "38fe1e6107ae3c9ba5e1f14178dd8bd52210535030d07f0609cf0d754c1f7de2" dependencies = [ "ark-bls12-381", "ark-ec", @@ -242,9 +242,9 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c94a4b93e722c91d2e58471cfe69480f4a656cfccacd8bfda5638f2a5d4512b" +checksum = "484926c9dc8b90c59a717946c86bb272182003cbaabb378560086648d4056656" dependencies = [ "proc-macro2", "quote", @@ -277,9 +277,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434e556b0aebff34bf082e75d175b5d7edbcf1d90d4cedb59623a1249fff567" +checksum = "c92be4747d9abe3a96a5a78af34d29947992b3f67f602987ff8a87142ce9c413" dependencies = [ "base64", "bech32", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index b1cee1d52a..96f3c49ebe 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 = [ "derive_more", "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 0949ad8ad7..a1abc8d319 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 = [ "derive_more", "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/replier/Cargo.lock b/contracts/replier/Cargo.lock index 1dd5907486..2575b7781a 100644 --- a/contracts/replier/Cargo.lock +++ b/contracts/replier/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 = "ahash" @@ -44,7 +44,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -62,7 +62,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -230,7 +230,7 @@ version = "2.2.0-rc.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -238,7 +238,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", @@ -250,7 +251,7 @@ version = "2.2.0-rc.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -263,11 +264,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", @@ -355,7 +357,66 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", +] + +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap", + "schemars 1.0.0-alpha.17", + "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.87", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", ] [[package]] @@ -396,7 +457,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", "unicode-xid", ] @@ -479,6 +540,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "ff" version = "0.13.0" @@ -495,6 +562,12 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "generic-array" version = "0.14.7" @@ -547,6 +620,24 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[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" @@ -562,6 +653,39 @@ dependencies = [ "digest", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +dependencies = [ + "equivalent", + "hashbrown 0.15.2", +] + +[[package]] +name = "is-terminal" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + [[package]] name = "itertools" version = "0.10.5" @@ -571,6 +695,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" @@ -595,6 +728,12 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + [[package]] name = "num-bigint" version = "0.4.5" @@ -629,6 +768,16 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "owo-colors" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" +dependencies = [ + "supports-color 2.1.0", + "supports-color 3.0.2", +] + [[package]] name = "p256" version = "0.13.2" @@ -729,13 +878,33 @@ dependencies = [ "crossbeam-utils", ] +[[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.87", +] + [[package]] name = "replier" version = "0.0.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "schemars", + "schemars 0.8.21", "serde", ] @@ -793,7 +962,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.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ef2a6523400a2228db974a8ddc9e1d3deaa04f51bddd7832ef8d7e531bafcc" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.17", "serde", "serde_json", ] @@ -807,7 +989,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.77", + "syn 2.0.87", +] + +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6d4e1945a3c9e58edaa708449b026519f7f4197185e1b5dbc689615c1ad724d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.87", ] [[package]] @@ -831,9 +1025,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -849,13 +1043,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -866,20 +1060,44 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "sha2" version = "0.10.8" @@ -901,18 +1119,49 @@ dependencies = [ "rand_core", ] +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.5.0" 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 = "supports-color" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" +dependencies = [ + "is_ci", +] + [[package]] name = "syn" version = "1.0.109" @@ -926,9 +1175,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -952,7 +1201,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -985,6 +1234,79 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "zerocopy" version = "0.7.34" @@ -1002,7 +1324,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1022,5 +1344,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index d32439d34a..e68f007827 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 = [ "derive_more", "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 fb91b0e6bf..9c0b042779 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 = [ "derive_more", "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..1dc8c19adb --- /dev/null +++ b/packages/cw-schema-codegen/Cargo.toml @@ -0,0 +1,32 @@ +[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" +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" +cosmwasm-std = { version = "2.2.0-rc.1", path = "../std", default-features = false, features = [ + "std", +] } 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..ebba81f4ce --- /dev/null +++ b/packages/cw-schema-codegen/src/go/mod.rs @@ -0,0 +1,163 @@ +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::Map { key, value, .. } => { + let key = expand_node_name(schema, &schema.definitions[key]); + let value = expand_node_name(schema, &schema.definitions[value]); + + format!("map[{key}]{value}").into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { ref items } => if items.len() == 1 { + "interface{}" + } else { + "[]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..a99fe90051 --- /dev/null +++ b/packages/cw-schema-codegen/src/main.rs @@ -0,0 +1,149 @@ +#[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..a44b7b266f --- /dev/null +++ b/packages/cw-schema-codegen/src/python/mod.rs @@ -0,0 +1,142 @@ +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!("typing.List[{}]", 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::Map { key, value, .. } => { + let key = expand_node_name(schema, &schema.definitions[key]); + let value = expand_node_name(schema, &schema.definitions[value]); + + format!("typing.Dict[{key}, {value}]").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 => "str".into(), + cw_schema::NodeType::HexBinary => "str".into(), + cw_schema::NodeType::Timestamp => "str".into(), + 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..ec9ebb0dd0 --- /dev/null +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -0,0 +1,171 @@ +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::Map { + ref kind, + key, + value, + } => { + let key = expand_node_name(schema, &schema.definitions[key]); + let value = expand_node_name(schema, &schema.definitions[value]); + + match kind { + cw_schema::MapKind::BTree => { + format!("alloc::collections::BTreeMap<{key}, {value}>") + } + cw_schema::MapKind::Hash => format!("std::collections::HashMap<{key}, {value}>"), + _ => unimplemented!(), + } + .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..a836e801b5 --- /dev/null +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -0,0 +1,155 @@ +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::Map { key, value, .. } => { + let key = expand_node_name(schema, &schema.definitions[key]); + let value = expand_node_name(schema, &schema.definitions[value]); + + format!("Record<{key}, {value}>").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..6acc079d58 --- /dev/null +++ b/packages/cw-schema-codegen/templates/go/enum.tpl.go @@ -0,0 +1,37 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +{% if add_package %} +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 }} {% if types.len() > 1 %} [] {% endif %} 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 }},omitempty"` +{% 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..ea8ad79b8a --- /dev/null +++ b/packages/cw-schema-codegen/templates/go/struct.tpl.go @@ -0,0 +1,26 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +{% if add_package %} +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..cdf184242b --- /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..496acaeaf1 --- /dev/null +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -0,0 +1,41 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + +{% 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..cf8c3580d1 --- /dev/null +++ b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs @@ -0,0 +1,29 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + +{% 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/go-e2e/.gitignore b/packages/cw-schema-codegen/tests/go-e2e/.gitignore new file mode 100644 index 0000000000..ea1bc79da0 --- /dev/null +++ b/packages/cw-schema-codegen/tests/go-e2e/.gitignore @@ -0,0 +1 @@ +gen.go \ No newline at end of file diff --git a/packages/cw-schema-codegen/tests/go-e2e/go.mod b/packages/cw-schema-codegen/tests/go-e2e/go.mod new file mode 100644 index 0000000000..2d2cee40e8 --- /dev/null +++ b/packages/cw-schema-codegen/tests/go-e2e/go.mod @@ -0,0 +1,93 @@ +module cosmwasm.com/cosmwasm-codegen/e2e + +go 1.23.4 + +require github.com/cosmos/cosmos-sdk v0.50.11 + +require ( + cosmossdk.io/api v0.7.6 // indirect + cosmossdk.io/collections v0.4.0 // indirect + cosmossdk.io/core v0.11.0 // indirect + cosmossdk.io/depinject v1.1.0 // indirect + cosmossdk.io/errors v1.0.1 // indirect + cosmossdk.io/log v1.4.1 // indirect + cosmossdk.io/math v1.4.0 // indirect + cosmossdk.io/store v1.1.1 // indirect + cosmossdk.io/x/tx v0.13.7 // indirect + github.com/DataDog/zstd v1.5.5 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect + github.com/cespare/xxhash v1.1.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.3 // indirect + github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v1.1.2 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cometbft/cometbft v0.38.12 // indirect + github.com/cometbft/cometbft-db v0.11.0 // indirect + github.com/cosmos/btcutil v1.0.5 // indirect + github.com/cosmos/cosmos-db v1.1.0 // indirect + github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect + github.com/cosmos/gogoproto v1.7.0 // indirect + github.com/cosmos/ics23/go v0.11.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/dgraph-io/badger/v2 v2.2007.4 // indirect + github.com/dgraph-io/ristretto v0.1.1 // indirect + github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect + github.com/go-kit/kit v0.12.0 // indirect + github.com/go-kit/log v0.2.1 // indirect + github.com/go-logfmt/logfmt v0.6.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.2.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.1.3 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/go-metrics v0.5.3 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/iancoleman/strcase v0.3.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jmhodges/levigo v1.0.0 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/linxGnu/grocksdb v1.8.14 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect + github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_golang v1.20.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/rs/zerolog v1.33.0 // indirect + github.com/sasha-s/go-deadlock v0.3.1 // indirect + github.com/spf13/cast v1.7.0 // indirect + github.com/spf13/cobra v1.8.1 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/stretchr/testify v1.9.0 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect + github.com/tendermint/go-amino v0.16.0 // indirect + go.etcd.io/bbolt v1.3.10 // indirect + golang.org/x/crypto v0.27.0 // indirect + golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect + google.golang.org/grpc v1.67.1 // indirect + google.golang.org/protobuf v1.35.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect +) diff --git a/packages/cw-schema-codegen/tests/go-e2e/go.sum b/packages/cw-schema-codegen/tests/go-e2e/go.sum new file mode 100644 index 0000000000..290fe98b71 --- /dev/null +++ b/packages/cw-schema-codegen/tests/go-e2e/go.sum @@ -0,0 +1,407 @@ +cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY= +cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= +cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= +cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= +cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E= +cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI= +cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= +cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= +cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU= +cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= +cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= +cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y= +cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= +cosmossdk.io/x/tx v0.13.7 h1:8WSk6B/OHJLYjiZeMKhq7DK7lHDMyK0UfDbBMxVmeOI= +cosmossdk.io/x/tx v0.13.7/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= +github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= +github.com/cometbft/cometbft v0.38.12 h1:OWsLZN2KcSSFe8bet9xCn07VwhBnavPea3VyPnNq1bg= +github.com/cometbft/cometbft v0.38.12/go.mod h1:GPHp3/pehPqgX1930HmK1BpBLZPxB75v/dZg8Viwy+o= +github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEyf7jej8= +github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= +github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= +github.com/cosmos/cosmos-db v1.1.0 h1:KLHNVQ73h7vawXTpj9UJ7ZR2IXv51tsEHkQJJ9EBDzI= +github.com/cosmos/cosmos-db v1.1.0/go.mod h1:t7c4A6cfGdpUwwVxrQ0gQLeRQqGUBJu0yvE4F/26REg= +github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= +github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= +github.com/cosmos/cosmos-sdk v0.50.11 h1:LxR1aAc8kixdrs3itO+3a44sFoc+vjxVAOyPFx22yjk= +github.com/cosmos/cosmos-sdk v0.50.11/go.mod h1:gt14Meok2IDCjbDtjwkbUcgVNEpUBDN/4hg9cCUtLgw= +github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro= +github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= +github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= +github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= +github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= +github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= +github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= +github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= +github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= +github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= +github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE= +github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= +github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= +github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q= +github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= +github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 h1:jik8PHtAIsPlCRJjJzl4udgEf7hawInF9texMeO2jrU= +github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= +github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= +github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= +github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= +github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= +github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= +go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:cUMEy+8oS78BWIH9OWazBkzbr090Od9tWBNtZHkOhf0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/packages/cw-schema-codegen/tests/go-e2e/main.go b/packages/cw-schema-codegen/tests/go-e2e/main.go new file mode 100644 index 0000000000..6f6e1ff0f8 --- /dev/null +++ b/packages/cw-schema-codegen/tests/go-e2e/main.go @@ -0,0 +1,34 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "os" +) + +func main() { + var buffer bytes.Buffer + + _, err := io.Copy(&buffer, os.Stdin) + if err != nil { + panic(err) + } + + data := buffer.Bytes() + + var out *TestType + if err := json.Unmarshal(data, &out); err != nil { + panic(err) + } + + fmt.Fprintln(os.Stderr, out) + + marshalled, err := json.Marshal(out) + if err != nil { + panic(err) + } + + os.Stdout.Write(marshalled) +} diff --git a/packages/cw-schema-codegen/tests/go.rs b/packages/cw-schema-codegen/tests/go.rs new file mode 100644 index 0000000000..cce081a0d0 --- /dev/null +++ b/packages/cw-schema-codegen/tests/go.rs @@ -0,0 +1,169 @@ +use arbitrary::Arbitrary; +use cw_schema::Schemaifier; +use serde::{Deserialize, Serialize}; +use std::{ + fs::File, + io::Write, + process::{Command, Stdio}, + str, +}; + +#[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); + +fn wrap Arbitrary<'a> + Into>( + stuff: &mut arbitrary::Unstructured, +) -> Combined { + T::arbitrary(stuff).unwrap().into() +} + +fn type_name() -> String { + std::any::type_name::() + .replace("::", "_") + .replace(['<', '>'], "_") +} + +#[test] +fn e2e() { + #[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/go-e2e", env!("CARGO_MANIFEST_DIR")); + let gen_file_path = format!("{e2e_dir}/gen.go"); + + // make sure the dependencies are installed + let install_status = Command::new("go") + .args(["get"]) + .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::go::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(b"package main\n").unwrap(); + gen_file.write_all(output.as_bytes()).unwrap(); + gen_file + .write_all(format!("type TestType {type_name}").as_bytes()) + .unwrap(); + + let data = arbitrary_gen(&mut unstructured); + let serialized = serde_json::to_string(&data).unwrap(); + + let mut child = Command::new("go") + .args(["run", "main.go", "gen.go"]) + .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-codegen/tests/python_tpl.rs b/packages/cw-schema-codegen/tests/python_tpl.rs new file mode 100644 index 0000000000..57a3c85ac4 --- /dev/null +++ b/packages/cw-schema-codegen/tests/python_tpl.rs @@ -0,0 +1,195 @@ +use cw_schema::Schemaifier; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// This is a struct level documentation for enum type +#[derive(Schemaifier, Serialize, Deserialize, PartialEq, Debug)] +pub enum SomeEnum { + /// Field1 docs + Field1, + + /// Field2 docs + Field2(u32, u32), + + /// Field3 docs + Field3 { + /// `a` field docs + a: String, + + /// `b` field docs + b: u32, + }, +} + +/// This is a struct level documentation for unit struct +#[derive(Schemaifier, Serialize, Deserialize, PartialEq, Debug)] +pub struct UnitStructure; + +/// This is a struct level documentation for tuple +#[derive(Schemaifier, Serialize, Deserialize, PartialEq, Debug)] +pub struct TupleStructure(u32, String, u128); + +/// This is a struct level documentation for named structure +#[derive(Schemaifier, Serialize, Deserialize, PartialEq, Debug)] +pub struct NamedStructure { + /// `a` field docs + a: String, + + /// `b` field docs + b: u8, + + /// `c` field docs + c: SomeEnum, +} + +#[derive(Schemaifier, Serialize, Deserialize, PartialEq, Debug)] +pub struct AllSimpleTypesAndDocs { + array_field: Vec, + float_field: f32, + double_field: f64, + bool_field: bool, + string_field: String, + int_field: i64, + bytes_field: cosmwasm_std::Binary, + opt_field: Option, + byte_field: u8, + decimal_field: cosmwasm_std::Decimal, + address_field: cosmwasm_std::Addr, + checksum_field: cosmwasm_std::Checksum, + hexbinary_field: cosmwasm_std::HexBinary, + timestamp_field: cosmwasm_std::Timestamp, + unit_field: (), +} + +#[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, $example:expr) => {{ + ( + stringify!($typ), + cw_schema::schema_of::<$typ>(), + serde_json::to_string(&$example).unwrap(), + { + let a: Box = Box::new(|output| { + let result = serde_json::from_str::<$typ>(output).unwrap(); + assert_eq!(result, $example); + }); + a + }, + ) + }}; +} + +#[test] +fn assert_validity() { + let schemas = [ + validator!(SomeEnum, SomeEnum::Field1), + validator!(SomeEnum, SomeEnum::Field2(10, 23)), + validator!( + SomeEnum, + SomeEnum::Field3 { + a: "sdf".to_string(), + b: 12, + } + ), + validator!(UnitStructure, UnitStructure {}), + validator!(TupleStructure, TupleStructure(10, "aasdf".to_string(), 2)), + validator!( + NamedStructure, + NamedStructure { + a: "awer".to_string(), + b: 4, + c: SomeEnum::Field1, + } + ), + validator!( + AllSimpleTypesAndDocs, + AllSimpleTypesAndDocs { + array_field: vec!["abc".to_string(), "def".to_string()], + float_field: 10.2, + double_field: 10.232323, + bool_field: true, + string_field: "sdfsdf".to_string(), + int_field: -10, + bytes_field: cosmwasm_std::Binary::new(vec![0x1, 0x2, 0x3]), + opt_field: Some("sdfsdfwer".to_string()), + byte_field: 9, + decimal_field: cosmwasm_std::Decimal::one(), + address_field: cosmwasm_std::Addr::unchecked("some_address"), + checksum_field: cosmwasm_std::Checksum::generate(&[0x10]), + hexbinary_field: cosmwasm_std::HexBinary::from_hex("FAFAFA").unwrap(), + timestamp_field: cosmwasm_std::Timestamp::from_seconds(100), + unit_field: (), + } + ), + ]; + + 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-e2e/Cargo.lock b/packages/cw-schema-codegen/tests/rust-e2e/Cargo.lock new file mode 100644 index 0000000000..61c92e6cd7 --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust-e2e/Cargo.lock @@ -0,0 +1,503 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cosmwasm-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cosmwasm-schema-derive", + "cw-schema", + "schemars 0.8.21", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cw-schema" +version = "2.2.0-rc.1" +dependencies = [ + "cw-schema-derive", + "indexmap", + "schemars 1.0.0-alpha.17", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.2.0-rc.1" +dependencies = [ + "heck", + "itertools", + "owo-colors", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[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 = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[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", +] + +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "owo-colors" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" +dependencies = [ + "supports-color 2.1.0", + "supports-color 3.0.2", +] + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[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", +] + +[[package]] +name = "rust-e2e" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "serde_json", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive 0.8.21", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ef2a6523400a2228db974a8ddc9e1d3deaa04f51bddd7832ef8d7e531bafcc" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.17", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6d4e1945a3c9e58edaa708449b026519f7f4197185e1b5dbc689615c1ad724d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "serde" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" +dependencies = [ + "serde", + "serde_derive", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "supports-color" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +dependencies = [ + "is-terminal", + "is_ci", +] + +[[package]] +name = "supports-color" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" +dependencies = [ + "is_ci", +] + +[[package]] +name = "syn" +version = "2.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/packages/cw-schema-codegen/tests/rust-e2e/Cargo.toml b/packages/cw-schema-codegen/tests/rust-e2e/Cargo.toml new file mode 100644 index 0000000000..fb23801572 --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust-e2e/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rust-e2e" +version = "0.1.0" +edition = "2024" + +[dependencies] +cosmwasm-schema = { version = "2.2.0-rc.1", path = "../../../schema" } +serde_json = "1.0.137" diff --git a/packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs b/packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs new file mode 100644 index 0000000000..a90ddd927e --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs @@ -0,0 +1,53 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + + + +#[cosmwasm_schema::cw_serde] +pub enum rust_Hehehe { + + + + + #[serde(rename = "A")] + + + A + + + , + + + + + #[serde(rename = "B")] + + + B + + ( + u32 + ) + + , + + + + + #[serde(rename = "C")] + + + C + + { + + + field: String, + + } + + , + +} +pub type TestType = rust_Hehehe; \ No newline at end of file diff --git a/packages/cw-schema-codegen/tests/rust-e2e/src/main.rs b/packages/cw-schema-codegen/tests/rust-e2e/src/main.rs new file mode 100644 index 0000000000..248c26dcea --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust-e2e/src/main.rs @@ -0,0 +1,6 @@ +mod r#gen; + +fn main() { + let value: r#gen::TestType = serde_json::from_reader(std::io::stdin()).unwrap(); + serde_json::to_writer(std::io::stdout(), &value).unwrap(); +} diff --git a/packages/cw-schema-codegen/tests/rust.rs b/packages/cw-schema-codegen/tests/rust.rs new file mode 100644 index 0000000000..eaca0e367a --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust.rs @@ -0,0 +1,159 @@ +use arbitrary::Arbitrary; +use cw_schema::Schemaifier; +use serde::{Deserialize, Serialize}; +use std::{ + fs::File, + io::Write, + process::{Command, Stdio}, + str, +}; + +#[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); + +fn wrap Arbitrary<'a> + Into>( + stuff: &mut arbitrary::Unstructured, +) -> Combined { + T::arbitrary(stuff).unwrap().into() +} + +fn type_name() -> String { + std::any::type_name::() + .replace("::", "_") + .replace(['<', '>'], "_") +} + +#[test] +fn e2e() { + #[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/rust-e2e", env!("CARGO_MANIFEST_DIR")); + let gen_file_path = format!("{e2e_dir}/src/gen.rs"); + + 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::rust::process_node(&mut buf, schema, node).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(); + gen_file + .write_all(format!("pub type TestType = {type_name};").as_bytes()) + .unwrap(); + + let data = arbitrary_gen(&mut unstructured); + let serialized = serde_json::to_string(&data).unwrap(); + + let mut child = Command::new("cargo") + .args(["run"]) + .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-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-2.snap b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-2.snap new file mode 100644 index 0000000000..d534a7cb65 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-2.snap @@ -0,0 +1,17 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: output +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + + + +class python_tpl_UnitStructure(RootModel): + """ + This is a struct level documentation for unit struct + """ + root: None diff --git a/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-3.snap b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-3.snap new file mode 100644 index 0000000000..c85540432d --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-3.snap @@ -0,0 +1,17 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: output +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + + + +class python_tpl_TupleStructure(RootModel): + """ + This is a struct level documentation for tuple + """ + root: typing.Tuple[int, str, int] diff --git a/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-4.snap b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-4.snap new file mode 100644 index 0000000000..6f33a3b354 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-4.snap @@ -0,0 +1,80 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: output +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + +class python_tpl_SomeEnum(RootModel): + """ + This is a struct level documentation for enum type + """ + + + + class Field1(RootModel): + """ + Field1 docs + """ + root: typing.Literal['Field1'] + + + + class Field2(BaseModel): + """ + Field2 docs + """ + Field2: typing.Tuple[int, int] + + + + class Field3(BaseModel): + class __Inner(BaseModel): + """ + Field3 docs + """ + + a: str + """ + `a` field docs + """ + + b: int + """ + `b` field docs + """ + + Field3: __Inner + + + root: typing.Union[ Field1, Field2, Field3, ] +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + + + +class python_tpl_NamedStructure(BaseModel): + """ + This is a struct level documentation for named structure + """ + + a: str + """ + # `a` field docs + """ + + b: int + """ + # `b` field docs + """ + + c: python_tpl_SomeEnum + """ + # `c` field docs + """ 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..b2e7ebb937 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap @@ -0,0 +1,53 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: output +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + +class python_tpl_SomeEnum(RootModel): + """ + This is a struct level documentation for enum type + """ + + + + class Field1(RootModel): + """ + Field1 docs + """ + root: typing.Literal['Field1'] + + + + class Field2(BaseModel): + """ + Field2 docs + """ + Field2: typing.Tuple[int, int] + + + + class Field3(BaseModel): + class __Inner(BaseModel): + """ + Field3 docs + """ + + a: str + """ + `a` field docs + """ + + b: int + """ + `b` field docs + """ + + 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..80aa043ae6 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -0,0 +1,56 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + + + #[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..865b9faea4 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap @@ -0,0 +1,16 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + + + #[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..3444f88fa3 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap @@ -0,0 +1,17 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + + +#[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..bba7ead544 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap @@ -0,0 +1,31 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + + +#[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..db289a16b6 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -0,0 +1,40 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + + + #[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..87a2426e67 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap @@ -0,0 +1,19 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +#![allow(non_camel_case_types)] + + +#[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..982133608c --- /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 typescript_UwuSchema = + + z.tuple([z.string(), z.string().or(z.number())]) + +; + +type typescript_Uwu = z.infer; + +export { typescript_Uwu, typescript_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..e6b697a9d4 --- /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 typescript_ÒwóSchema = + + z.null() + +; + +type typescript_Òwó = z.infer; + +export { typescript_Òwó, typescript_Ò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..c2811eefeb --- /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 typescript_EmptySchema = z.union([ + + + +never; + +]); + +type typescript_Empty = z.infer; + +export { typescript_Empty, typescript_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..143b652e55 --- /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 typescript_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 typescript_Hehehe = z.infer; + +export { typescript_Hehehe, typescript_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..7d2abff640 --- /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 typescript_OwoSchema = + + z.object({ + + /** + + */ + + field_1: z.string().or(z.number()), + + /** + + */ + + field_2: z.string(), + +}) + +; + +type typescript_Owo = z.infer; + +export { typescript_Owo, typescript_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..e0334a035c --- /dev/null +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -0,0 +1,197 @@ +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::() + .replace("::", "_") + .replace(['<', '>'], "_"); + + 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..843d3c283a --- /dev/null +++ b/packages/cw-schema-derive/src/expand.rs @@ -0,0 +1,517 @@ +// 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()); + } + + if meta.path.is_ident("untagged") || meta.path.is_ident("tag") { + print_warning( + "unsupported tag type", + meta.error("unsupported tag type").to_string(), + ) + .unwrap(); + } + + 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: std::any::type_name::() + .replace("::", "_") + .replace(['<', '>'], "_") + .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: std::any::type_name::() + .replace("::", "_") + .replace(['<', '>'], "_") + .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..630472ca06 --- /dev/null +++ b/packages/cw-schema/src/default_impls.rs @@ -0,0 +1,257 @@ +use crate::{MapKind, Node, NodeType, Schemaifier}; +use alloc::{ + borrow::{Cow, ToOwned}, + collections::BTreeMap, + string::String, + vec, + vec::Vec, +}; + +impl Schemaifier for () { + #[inline] + 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 { + #[inline] + 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 { + #[inline] + 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 { + #[inline] + 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 { + #[inline] + 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 { + #[inline] + 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 { + #[inline] + 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, +{ + #[inline] + 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,)+) { + #[inline] + 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, +{ + #[inline] + 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 BTreeMap +where + K: Schemaifier, + V: Schemaifier, +{ + #[inline] + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + let node = Node { + name: Cow::Borrowed(std::any::type_name::()), + description: None, + value: NodeType::Map { + kind: MapKind::BTree, + key: K::visit_schema(visitor), + value: V::visit_schema(visitor), + }, + }; + + visitor.insert(Self::id(), node) + } +} + +#[cfg(feature = "std")] +impl Schemaifier for std::collections::HashMap +where + K: Schemaifier, + V: Schemaifier, +{ + #[inline] + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + let node = Node { + name: Cow::Borrowed(std::any::type_name::()), + description: None, + value: NodeType::Map { + kind: MapKind::Hash, + key: K::visit_schema(visitor), + value: V::visit_schema(visitor), + }, + }; + + visitor.insert(Self::id(), node) + } +} + +impl Schemaifier for &T +where + T: Schemaifier + ?Sized, +{ + #[inline] + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + T::visit_schema(visitor) + } +} + +impl Schemaifier for Cow<'_, T> +where + T: Schemaifier + ToOwned + ?Sized, +{ + #[inline] + 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..54d32378cc --- /dev/null +++ b/packages/cw-schema/src/lib.rs @@ -0,0 +1,239 @@ +#![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, + }, +} + +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +pub enum MapKind { + BTree, + Hash, +} + +#[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>, + }, + + Map { + kind: MapKind, + key: DefinitionReference, + value: DefinitionReference, + }, + + 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 54844b3c45..de67341c20 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 d357b01d0e..dde3379473 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -61,6 +61,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 3b751e5c7e..fb861914cf 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 4fd3e01472..cbd2fb8122 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 400cc3a3a0..c1d8cfb0a2 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/eureka.rs b/packages/std/src/eureka.rs index 14c1e916e3..629570edce 100644 --- a/packages/std/src/eureka.rs +++ b/packages/std/src/eureka.rs @@ -6,7 +6,9 @@ use crate::{Binary, Timestamp}; /// Payload value should be encoded in a format defined by the channel version, /// and the module on the other side should know how to parse this. #[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 struct EurekaPayload { /// The port id on the chain where the packet is sent to (external chain). @@ -21,7 +23,9 @@ pub struct EurekaPayload { /// These are messages in the IBC lifecycle using the new Eureka approach. Only usable by IBC-enabled contracts #[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 EurekaMsg { /// Sends an IBC packet with given payloads over the existing channel. diff --git a/packages/std/src/hex_binary.rs b/packages/std/src/hex_binary.rs index d957af7a9e..b28eb35fd8 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 1f1e07ccb8..80e97471dd 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 a2aa08d0a9..fdcf3b0361 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 659b3367d6..982e8dfa5b 100644 --- a/packages/std/src/math/int128.rs +++ b/packages/std/src/math/int128.rs @@ -33,7 +33,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 e0d4f19e78..b9b26c4c5f 100644 --- a/packages/std/src/math/int256.rs +++ b/packages/std/src/math/int256.rs @@ -43,7 +43,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 7b512b3827..f4c782f04e 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 dae40f92fc..da023ce457 100644 --- a/packages/std/src/math/int64.rs +++ b/packages/std/src/math/int64.rs @@ -33,7 +33,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 9b70ce334a..56f6822b4b 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 a7e838bb81..78f5949c82 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 1c06c98389..192a43f054 100644 --- a/packages/std/src/math/uint128.rs +++ b/packages/std/src/math/uint128.rs @@ -41,7 +41,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 1f41327a7b..0041a4c472 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 834e9097a9..7e366365c9 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 35ae7175d1..5e87f3ff68 100644 --- a/packages/std/src/math/uint64.rs +++ b/packages/std/src/math/uint64.rs @@ -37,7 +37,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 b6ea3b116f..957a2689db 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -48,12 +48,17 @@ use super::Empty; /// /// impl CustomQuery for MyMsg {} /// ``` -pub trait CustomMsg: Serialize + Clone + fmt::Debug + PartialEq + JsonSchema {} +pub trait CustomMsg: Serialize + Clone + fmt::Debug + PartialEq + JsonSchema +//+ cw_schema::Schemaifier +{ +} 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 { @@ -122,7 +127,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. @@ -144,7 +151,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). @@ -167,7 +176,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). @@ -193,7 +204,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, @@ -215,7 +228,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). @@ -373,7 +388,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. @@ -393,7 +410,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, @@ -403,7 +422,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 8a1c5221c8..b97835b115 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), @@ -281,7 +289,9 @@ impl From for Result { } /// The information we get back from a successful sub message execution -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct SubMsgResponse { /// The Cosmos SDK events emitted by the submessage. /// @@ -304,7 +314,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..2ba18d4538 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, } @@ -115,7 +123,9 @@ pub struct ContractInfo { /// the contract's migrate version currently stored on the blockchain. /// The `old_migrate_version` is optional, since there is no guarantee /// that the currently stored contract's binary contains that information. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct MigrateInfo { /// Address of the sender. ///