From 3cdf3b260c080564403a1de877cb133e7931686d Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 12 Aug 2024 16:53:08 +0200 Subject: [PATCH 01/60] New schema format --- packages/cw-schema-derive/Cargo.toml | 14 + packages/cw-schema-derive/src/expand.rs | 325 ++++++++++++++ packages/cw-schema-derive/src/lib.rs | 25 ++ packages/cw-schema/.gitignore | 1 + packages/cw-schema/Cargo.lock | 414 +++++++++++++++++ packages/cw-schema/Cargo.toml | 21 + packages/cw-schema/src/default_impls.rs | 152 +++++++ packages/cw-schema/src/lib.rs | 213 +++++++++ packages/cw-schema/tests/basic.rs | 129 ++++++ packages/cw-schema/tests/derive.rs | 44 ++ packages/cw-schema/tests/example.json | 92 ++++ .../snapshots/basic__snapshot_jsonschema.snap | 421 ++++++++++++++++++ .../snapshots/derive__snapshot_schema.snap | 96 ++++ 13 files changed, 1947 insertions(+) create mode 100644 packages/cw-schema-derive/Cargo.toml create mode 100644 packages/cw-schema-derive/src/expand.rs create mode 100644 packages/cw-schema-derive/src/lib.rs create mode 100644 packages/cw-schema/.gitignore create mode 100644 packages/cw-schema/Cargo.lock create mode 100644 packages/cw-schema/Cargo.toml create mode 100644 packages/cw-schema/src/default_impls.rs create mode 100644 packages/cw-schema/src/lib.rs create mode 100644 packages/cw-schema/tests/basic.rs create mode 100644 packages/cw-schema/tests/derive.rs create mode 100644 packages/cw-schema/tests/example.json create mode 100644 packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap create mode 100644 packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap diff --git a/packages/cw-schema-derive/Cargo.toml b/packages/cw-schema-derive/Cargo.toml new file mode 100644 index 000000000..8fe5336d1 --- /dev/null +++ b/packages/cw-schema-derive/Cargo.toml @@ -0,0 +1,14 @@ +[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 } +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 000000000..0daad8ae7 --- /dev/null +++ b/packages/cw-schema-derive/src/expand.rs @@ -0,0 +1,325 @@ +use std::borrow::Cow; + +use crate::bail; +use proc_macro2::TokenStream; +use quote::quote; +use syn::{punctuated::Punctuated, DataEnum, DataStruct, DataUnion, DeriveInput, Lit}; + +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 { + // TODO: support other serde attributes + // + // For now we simply clear the buffer to avoid errors + let _ = meta + .value() + .map(|val| val.parse::().unwrap()) + .unwrap_or_else(|_| meta.input.cursor().token_stream()); + } + + Ok(()) + })?; + } + + Ok(options) + } +} + +struct ContainerOptions { + crate_path: syn::Path, +} + +impl ContainerOptions { + fn parse(attributes: &[syn::Attribute]) -> syn::Result { + let mut options = ContainerOptions { + 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 { + bail!(meta.path, "unknown attribute"); + } + + 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>( + options: &ContainerOptions, + type_params: impl 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 expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result { + let crate_path = &meta.options.crate_path; + + let mut cases = Vec::new(); + for variant in input.variants.iter() { + let value = match variant.fields { + syn::Fields::Named(ref fields) => { + let items = fields.named.iter().map(|field| { + let name = 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) + }).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 variant_name = &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! { + 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::().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 name = &meta.name; + let description = normalize_option(meta.description.as_ref()); + let crate_path = &meta.options.crate_path; + + let node_ty = match input.fields { + syn::Fields::Named(named) => { + let items = named.named.iter().map(|field| { + let name = 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) + }).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 }, + }; + + let node = quote! { + #crate_path::Node { + name: std::any::type_name::().into(), + description: #description, + value: #crate_path::NodeType::Struct(#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! { + 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 000000000..13f3cf46f --- /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 000000000..ea8c4bf7f --- /dev/null +++ b/packages/cw-schema/.gitignore @@ -0,0 +1 @@ +/target diff --git a/packages/cw-schema/Cargo.lock b/packages/cw-schema/Cargo.lock new file mode 100644 index 000000000..2c1676ee9 --- /dev/null +++ b/packages/cw-schema/Cargo.lock @@ -0,0 +1,414 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "windows-sys", +] + +[[package]] +name = "cw-schema" +version = "0.1.0" +dependencies = [ + "cw-schema-derive", + "insta", + "pretty_assertions", + "schemars", + "serde", + "serde_json", + "serde_with", +] + +[[package]] +name = "cw-schema-derive" +version = "0.1.0" +dependencies = [ + "heck", + "itertools", + "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 = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[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 = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "insta" +version = "1.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "810ae6042d48e2c9e9215043563a58a80b877bc863228a74cf10c49d4620a6f5" +dependencies = [ + "console", + "lazy_static", + "linked-hash-map", + "serde", + "similar", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[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 = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +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 = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schemars" +version = "1.0.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec9b1e7918a904d86cb6de7147ff4da21f12ac1462c8049e12b30a8846f4699e" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2730d5d2dbaf504ab238832cad00b0bdd727436583c7b05f9328e65fee2b475" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +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.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "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", +] + +[[package]] +name = "similar" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[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" + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" diff --git a/packages/cw-schema/Cargo.toml b/packages/cw-schema/Cargo.toml new file mode 100644 index 000000000..c8701fc7f --- /dev/null +++ b/packages/cw-schema/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "cw-schema" +version.workspace = true +edition = "2021" + +[dependencies] +cw-schema-derive = { version = "=2.1.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 000000000..3375d6256 --- /dev/null +++ b/packages/cw-schema/src/default_impls.rs @@ -0,0 +1,152 @@ +use crate::{Node, NodeType, Schemaifier}; +use alloc::{borrow::Cow, string::String, vec, vec::Vec}; + +impl Schemaifier for String { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("String"), + description: None, + value: NodeType::String, + }, + ) + } +} + +macro_rules! impl_integer { + ($($t:ty),+) => { + $( + impl Schemaifier for $t { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert(Self::id(), Node { + name: Cow::Borrowed(stringify!($t)), + description: None, + value: NodeType::Integer { + signed: <$t>::MIN != 0, + precision: <$t>::BITS as u64, + }, + }) + } + } + )+ + }; +} + +impl_integer!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128); + +impl Schemaifier for f32 { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("f32"), + description: None, + value: NodeType::Float, + }, + ) + } +} + +impl Schemaifier for f64 { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("f64"), + description: None, + value: NodeType::Double, + }, + ) + } +} + +impl Schemaifier for bool { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("bool"), + description: None, + value: NodeType::Boolean, + }, + ) + } +} + +impl Schemaifier for Vec +where + T: Schemaifier, +{ + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + let node = Node { + name: Cow::Borrowed(std::any::type_name::()), + description: None, + value: NodeType::Array { + items: T::visit_schema(visitor), + }, + }; + + visitor.insert(Self::id(), node) + } +} + +macro_rules! all_the_tuples { + ($($($n:ident),+);+$(;)?) => { + $( + impl<$($n: Schemaifier),+> Schemaifier for ($($n,)+) { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + let node = Node { + name: Cow::Borrowed(std::any::type_name::()), + description: None, + value: NodeType::Tuple { + items: vec![ + $(<$n as Schemaifier>::visit_schema(visitor)),+ + ], + }, + }; + + visitor.insert(Self::id(), node) + } + } + )+ + }; +} + +// Implement for tuples up to 16 elements. +// Good enough. If someone needs more, PR it. +all_the_tuples! { + A; + A, B; + A, B, C; + A, B, C, D; + A, B, C, D, E; + A, B, C, D, E, F; + A, B, C, D, E, F, G; + A, B, C, D, E, F, G, H; + A, B, C, D, E, F, G, H, I; + A, B, C, D, E, F, G, H, I, J; + A, B, C, D, E, F, G, H, I, J, K; + A, B, C, D, E, F, G, H, I, J, K, L; + A, B, C, D, E, F, G, H, I, J, K, L, M; + A, B, C, D, E, F, G, H, I, J, K, L, M, N; + A, B, C, D, E, F, G, H, I, J, K, L, M, N, O; + A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P; +} + +impl Schemaifier for Option +where + T: Schemaifier, +{ + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + let node = Node { + name: Cow::Borrowed(std::any::type_name::()), + description: None, + value: NodeType::Optional { + inner: T::visit_schema(visitor), + }, + }; + + visitor.insert(Self::id(), node) + } +} diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs new file mode 100644 index 000000000..9c87ed55e --- /dev/null +++ b/packages/cw-schema/src/lib.rs @@ -0,0 +1,213 @@ +#![no_std] + +extern crate alloc; + +#[cfg(feature = "std")] +extern crate std; + +use alloc::{ + borrow::{Cow, ToOwned}, + collections::BTreeMap, + vec::Vec, +}; +use core::hash::BuildHasherDefault; +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(Debug, 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(Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase", untagged)] +#[non_exhaustive] +pub enum StructType { + Unit, + Named { + properties: BTreeMap, StructProperty>, + }, + Tuple { + items: Vec, + }, +} + +#[skip_serializing_none] +#[derive(Debug, 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(Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase", tag = "type")] +#[non_exhaustive] +pub enum EnumValue { + Unit, + Named { + properties: BTreeMap, StructProperty>, + }, + Tuple { + items: Vec, + }, +} + +#[skip_serializing_none] +#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] +#[serde(rename_all = "camelCase", tag = "type")] +#[non_exhaustive] +pub enum NodeType { + // Floating point numbers + Float, + Double, + + // Decimal numbers + Decimal { + precision: u64, + signed: bool, + }, + + // Integer numbers + Integer { + precision: u64, + signed: bool, + }, + + Address, + Binary, + Checksum, + HexBinary, + Timestamp, + + String, + Boolean, + Array { + items: DefinitionReference, + }, + Struct(StructType), + Tuple { + items: Vec, + }, + Enum { + discriminator: Option>, + cases: BTreeMap, EnumCase>, + }, + + Optional { + inner: DefinitionReference, + }, +} + +#[skip_serializing_none] +#[derive(Debug, 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(Debug, 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(Debug, 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(&'static str); + +impl Identifier { + pub fn of() -> Self + where + T: ?Sized, + { + Self(core::any::type_name::()) + } +} + +impl Serialize for Identifier { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + self.0.serialize(serializer) + } +} + +#[derive(Default)] +pub struct SchemaVisitor { + schemas: IndexMap>, +} + +impl SchemaVisitor { + pub fn get_reference(&self) -> Option { + self.schemas.get_index_of(&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 { + #[doc(hidden)] + 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 000000000..e6c5a910e --- /dev/null +++ b/packages/cw-schema/tests/basic.rs @@ -0,0 +1,129 @@ +use cw_schema::{EnumCase, Node, NodeType, Schema, SchemaV1, StructProperty}; + +#[test] +fn roundtrip() { + /* + let schema_struct = Schema::V1(SchemaV1 { + root: Node { + name: Some("root".into()), + description: Some("root node".into()), + optional: false, + value: NodeContent::Concrete(NodeType::Object { + properties: vec![ + StructProperty { + name: "foo".into(), + description: Some("foo property".into()), + value: Node { + name: None, + description: None, + optional: false, + value: NodeContent::Concrete(NodeType::String), + }, + }, + StructProperty { + name: "bar".into(), + description: Some("bar property".into()), + value: Node { + name: None, + description: None, + optional: false, + value: NodeContent::Concrete(NodeType::Integer { + signed: false, + precision: 64, + }), + }, + }, + StructProperty { + name: "union".into(), + description: Some("union property".into()), + value: Node { + name: None, + description: None, + optional: false, + value: NodeContent::OneOf { + one_of: vec![ + Node { + name: None, + description: None, + optional: true, + value: NodeContent::Concrete(NodeType::String), + }, + Node { + name: None, + description: None, + optional: false, + value: NodeContent::Concrete(NodeType::Integer { + signed: true, + precision: 128, + }), + }, + ], + }, + }, + }, + StructProperty { + name: "tagged_union".into(), + description: Some("tagged union property".into()), + value: Node { + name: None, + description: None, + optional: false, + value: NodeContent::Concrete(NodeType::Enum { + discriminator: Some("type".into()), + cases: vec![ + EnumCase { + name: "string".into(), + description: Some("string case".into()), + discriminator_value: None, + value: Some(Node { + name: None, + description: None, + optional: true, + value: NodeContent::Concrete(NodeType::String), + }), + }, + EnumCase { + name: "number".into(), + description: Some("number case".into()), + discriminator_value: None, + value: Some(Node { + name: None, + description: None, + optional: false, + value: NodeContent::Concrete(NodeType::Integer { + signed: false, + precision: 8, + }), + }), + }, + ], + }), + }, + }, + ], + }), + }, + }); + + let schema = serde_json::to_string(&schema_struct).unwrap(); + + pretty_assertions::assert_eq!( + schema_struct, + serde_json::from_str::(&schema).unwrap() + ); + */ +} + +#[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 000000000..9ef13cf8d --- /dev/null +++ b/packages/cw-schema/tests/derive.rs @@ -0,0 +1,44 @@ +use cw_schema::Schemaifier; + +#[derive(Schemaifier)] +/// Hello world struct! +struct HelloWorld { + /// Name field! + name: String, + + /// Foo field! + foo: Option, + + /// Baz field! + baz: Baz, + + /// 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), +} + +#[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 000000000..996ab250d --- /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/snapshots/basic__snapshot_jsonschema.snap b/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap new file mode 100644 index 000000000..8bea1145b --- /dev/null +++ b/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap @@ -0,0 +1,421 @@ +--- +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" + ] + } + ], + "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 000000000..42dc7f4ed --- /dev/null +++ b/packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap @@ -0,0 +1,96 @@ +--- +source: packages/cw-schema/tests/derive.rs +expression: schema +--- +{ + "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 + } + } + } + ] +} From e4fba7f5b1e9bf02e50ed514542e25e662f03aae Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 19 Aug 2024 14:35:30 +0200 Subject: [PATCH 02/60] Extend proc-macro functionality, add derives to std --- Cargo.lock | 283 ++++++++++--- packages/cw-schema-derive/src/expand.rs | 116 +++--- packages/cw-schema/Cargo.lock | 414 -------------------- packages/cw-schema/src/lib.rs | 26 +- packages/std/Cargo.toml | 1 + packages/std/src/addresses.rs | 13 +- packages/std/src/binary.rs | 13 +- packages/std/src/checksum.rs | 3 +- packages/std/src/coin.rs | 4 +- packages/std/src/errors/system_error.rs | 10 +- packages/std/src/hex_binary.rs | 13 +- packages/std/src/ibc.rs | 68 +++- packages/std/src/iterator.rs | 4 +- packages/std/src/math/decimal.rs | 13 +- packages/std/src/math/decimal256.rs | 13 +- packages/std/src/math/int128.rs | 14 +- packages/std/src/math/int256.rs | 14 +- packages/std/src/math/int512.rs | 14 +- packages/std/src/math/int64.rs | 14 +- packages/std/src/math/signed_decimal.rs | 13 +- packages/std/src/math/signed_decimal_256.rs | 13 +- packages/std/src/math/uint128.rs | 14 +- packages/std/src/math/uint256.rs | 14 +- packages/std/src/math/uint512.rs | 14 +- packages/std/src/math/uint64.rs | 14 +- packages/std/src/metadata.rs | 8 +- packages/std/src/never.rs | 1 + packages/std/src/pagination.rs | 4 +- packages/std/src/query/bank.rs | 24 +- packages/std/src/query/distribution.rs | 28 +- packages/std/src/query/ibc.rs | 16 +- packages/std/src/query/mod.rs | 8 +- packages/std/src/query/staking.rs | 36 +- packages/std/src/query/wasm.rs | 12 +- packages/std/src/results/contract_result.rs | 4 +- packages/std/src/results/cosmos_msg.rs | 36 +- packages/std/src/results/empty.rs | 4 +- packages/std/src/results/events.rs | 8 +- packages/std/src/results/response.rs | 4 +- packages/std/src/results/submessages.rs | 24 +- packages/std/src/results/system_result.rs | 4 +- packages/std/src/stdack.rs | 4 +- packages/std/src/timestamp.rs | 2 + packages/std/src/types.rs | 18 +- 44 files changed, 760 insertions(+), 617 deletions(-) delete mode 100644 packages/cw-schema/Cargo.lock diff --git a/Cargo.lock b/Cargo.lock index 6221f7c46..186217fc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,7 +150,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -168,7 +168,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -497,7 +497,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.10.0", ] [[package]] @@ -528,6 +528,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -602,7 +614,7 @@ dependencies = [ "cosmwasm-std", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -611,7 +623,7 @@ version = "2.1.1" dependencies = [ "anyhow", "cosmwasm-schema-derive", - "schemars", + "schemars 0.8.20", "semver", "serde", "serde_json", @@ -625,7 +637,7 @@ version = "2.1.1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -641,11 +653,12 @@ dependencies = [ "cosmwasm-derive", "cosmwasm-schema", "crc32fast", + "cw-schema", "derive_more", "hex", "hex-literal", "rand_core", - "schemars", + "schemars 0.8.20", "serde", "serde-json-wasm", "serde_json", @@ -675,7 +688,7 @@ dependencies = [ "leb128", "rand", "rand_core", - "schemars", + "schemars 0.8.20", "serde", "serde_json", "sha2", @@ -804,7 +817,7 @@ dependencies = [ "clap", "criterion-plot", "is-terminal", - "itertools", + "itertools 0.10.5", "num-traits", "once_cell", "oorandom", @@ -825,7 +838,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -914,7 +927,33 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", +] + +[[package]] +name = "cw-schema" +version = "2.1.1" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "insta", + "pretty_assertions", + "schemars 1.0.0-alpha.6", + "serde", + "serde_json", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.1" +dependencies = [ + "heck 0.5.0", + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.75", ] [[package]] @@ -947,7 +986,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -961,7 +1000,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.65", + "strsim 0.11.1", + "syn 2.0.75", ] [[package]] @@ -983,7 +1023,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -1077,7 +1117,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", "unicode-xid", ] @@ -1097,6 +1137,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" @@ -1223,6 +1269,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "english-numbers" version = "0.3.3" @@ -1267,7 +1319,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -1431,7 +1483,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "indenter", - "schemars", + "schemars 0.8.20", ] [[package]] @@ -1495,6 +1547,12 @@ 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.3.9" @@ -1560,15 +1618,28 @@ 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", "serde", ] +[[package]] +name = "insta" +version = "1.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "810ae6042d48e2c9e9215043563a58a80b877bc863228a74cf10c49d4620a6f5" +dependencies = [ + "console", + "lazy_static", + "linked-hash-map", + "serde", + "similar", +] + [[package]] name = "is-terminal" version = "0.4.12" @@ -1595,6 +1666,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" @@ -1649,6 +1729,12 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1924,6 +2010,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" @@ -1959,9 +2055,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -2069,6 +2165,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.75", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -2233,12 +2349,25 @@ 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", "url", ] +[[package]] +name = "schemars" +version = "1.0.0-alpha.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01e8b761be0b60066bf31ef0d74034654c72a2a670e6391ac1ea2767d2f34c5c" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive 1.0.0-alpha.6", + "serde", + "serde_json", +] + [[package]] name = "schemars_derive" version = "0.8.20" @@ -2248,7 +2377,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.65", + "syn 2.0.75", +] + +[[package]] +name = "schemars_derive" +version = "1.0.0-alpha.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deaac8174f8db9fa1bd1d0cea80e12f41ba034dcee6a0c1cae53e14065a4b24d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.75", ] [[package]] @@ -2293,9 +2434,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.202" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] @@ -2332,13 +2473,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -2349,16 +2490,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -2372,13 +2514,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.75", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2432,6 +2597,18 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" +[[package]] +name = "similar" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + [[package]] name = "slice-group-by" version = "0.3.1" @@ -2462,6 +2639,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2477,11 +2660,11 @@ 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", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -2503,9 +2686,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.65" +version = "2.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" dependencies = [ "proc-macro2", "quote", @@ -2570,7 +2753,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -2674,7 +2857,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2687,7 +2870,7 @@ version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2713,7 +2896,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -2846,7 +3029,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", "wasm-bindgen-shared", ] @@ -2868,7 +3051,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3003,8 +3186,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.20", "semver", "serde", "serde_cbor", @@ -3094,7 +3277,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", ] @@ -3416,6 +3599,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" @@ -3433,7 +3622,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] [[package]] @@ -3453,5 +3642,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.75", ] diff --git a/packages/cw-schema-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs index 0daad8ae7..cb10a7337 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -1,9 +1,8 @@ -use std::borrow::Cow; - use crate::bail; use proc_macro2::TokenStream; use quote::quote; -use syn::{punctuated::Punctuated, DataEnum, DataStruct, DataUnion, DeriveInput, Lit}; +use std::borrow::Cow; +use syn::{DataEnum, DataStruct, DataUnion, DeriveInput, Lit}; struct SerdeContainerOptions { rename_all: Option, @@ -45,12 +44,16 @@ impl SerdeContainerOptions { } 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")?, }; @@ -62,6 +65,10 @@ impl ContainerOptions { 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"); } @@ -228,55 +235,72 @@ fn expand_struct(mut meta: ContainerMeta, input: DataStruct) -> syn::Result { - let items = named.named.iter().map(|field| { - let name = 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) - }).collect::>>()?; - + 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! { - #crate_path::StructType::Named { - properties: #crate_path::reexport::BTreeMap::from([ - #( #items, )* - ]) - } + #r#type } - } - syn::Fields::Unnamed(fields) => { - let type_names = fields.unnamed.iter().map(|field| &field.ty); + } else { + let node_ty = match input.fields { + syn::Fields::Named(named) => { + let items = named.named.iter().map(|field| { + let name = 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) + }).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::StructType::Tuple { - items: vec![ - #( - <#type_names as #crate_path::Schemaifier>::visit_schema(visitor), - )* - ], - } + #crate_path::NodeType::Struct(#node_ty) } - } - syn::Fields::Unit => quote! { #crate_path::StructType::Unit }, - }; + }; - let node = quote! { - #crate_path::Node { - name: std::any::type_name::().into(), - description: #description, - value: #crate_path::NodeType::Struct(#node_ty), + quote! { + #crate_path::Node { + name: std::any::type_name::().into(), + description: #description, + value: #node_ty, + } } }; diff --git a/packages/cw-schema/Cargo.lock b/packages/cw-schema/Cargo.lock deleted file mode 100644 index 2c1676ee9..000000000 --- a/packages/cw-schema/Cargo.lock +++ /dev/null @@ -1,414 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "console" -version = "0.15.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "windows-sys", -] - -[[package]] -name = "cw-schema" -version = "0.1.0" -dependencies = [ - "cw-schema-derive", - "insta", - "pretty_assertions", - "schemars", - "serde", - "serde_json", - "serde_with", -] - -[[package]] -name = "cw-schema-derive" -version = "0.1.0" -dependencies = [ - "heck", - "itertools", - "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 = "diff" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" - -[[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 = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "insta" -version = "1.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "810ae6042d48e2c9e9215043563a58a80b877bc863228a74cf10c49d4620a6f5" -dependencies = [ - "console", - "lazy_static", - "linked-hash-map", - "serde", - "similar", -] - -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[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 = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -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 = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "schemars" -version = "1.0.0-alpha.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec9b1e7918a904d86cb6de7147ff4da21f12ac1462c8049e12b30a8846f4699e" -dependencies = [ - "dyn-clone", - "ref-cast", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "1.0.0-alpha.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2730d5d2dbaf504ab238832cad00b0bdd727436583c7b05f9328e65fee2b475" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn", -] - -[[package]] -name = "serde" -version = "1.0.204" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.204" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" -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.120" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" -dependencies = [ - "itoa", - "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", -] - -[[package]] -name = "similar" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "syn" -version = "2.0.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[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" - -[[package]] -name = "yansi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index 9c87ed55e..e900e8104 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -5,11 +5,7 @@ extern crate alloc; #[cfg(feature = "std")] extern crate std; -use alloc::{ - borrow::{Cow, ToOwned}, - collections::BTreeMap, - vec::Vec, -}; +use alloc::{borrow::Cow, collections::BTreeMap, vec::Vec}; use core::hash::BuildHasherDefault; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; @@ -23,7 +19,7 @@ pub type DefinitionReference = usize; mod default_impls; #[skip_serializing_none] -#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct StructProperty { @@ -32,7 +28,7 @@ pub struct StructProperty { } #[skip_serializing_none] -#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", untagged)] #[non_exhaustive] @@ -47,7 +43,7 @@ pub enum StructType { } #[skip_serializing_none] -#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct EnumCase { @@ -57,7 +53,7 @@ pub struct EnumCase { } #[skip_serializing_none] -#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", tag = "type")] #[non_exhaustive] @@ -72,7 +68,7 @@ pub enum EnumValue { } #[skip_serializing_none] -#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", tag = "type")] #[non_exhaustive] @@ -119,7 +115,7 @@ pub enum NodeType { } #[skip_serializing_none] -#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct Node { @@ -130,7 +126,7 @@ pub struct Node { } #[skip_serializing_none] -#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct SchemaV1 { @@ -139,7 +135,7 @@ pub struct SchemaV1 { } #[skip_serializing_none] -#[derive(Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", tag = "type")] #[non_exhaustive] @@ -178,6 +174,10 @@ impl SchemaVisitor { 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 diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 4b276c218..756a2283d 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -54,6 +54,7 @@ base64 = "0.22.0" bnum = "0.11.0" cosmwasm-core = { version = "2.1.1", path = "../core" } cosmwasm-derive = { version = "2.1.1", path = "../derive" } +cw-schema = { version = "2.1.1", path = "../cw-schema" } derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["debug"] } hex = "0.4" schemars = { workspace = true } diff --git a/packages/std/src/addresses.rs b/packages/std/src/addresses.rs index d23c5b1aa..96faffa82 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 72dfd6cc6..5e6606edc 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 b2b1a79e9..9a4c2baa5 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 54d41e085..5842ea1b9 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 ea9052e4d..1206a921f 100644 --- a/packages/std/src/errors/system_error.rs +++ b/packages/std/src/errors/system_error.rs @@ -13,7 +13,15 @@ use crate::Binary; /// Such errors are only created by the VM. The error type is defined in the standard library, to ensure /// the contract understands the error format without creating a dependency on cosmwasm-vm. #[derive( - Serialize, Deserialize, Clone, Debug, PartialEq, Eq, schemars::JsonSchema, thiserror::Error, + Serialize, + Deserialize, + Clone, + Debug, + PartialEq, + Eq, + schemars::JsonSchema, + thiserror::Error, + cw_schema::Schemaifier, )] #[serde(rename_all = "snake_case")] #[non_exhaustive] diff --git a/packages/std/src/hex_binary.rs b/packages/std/src/hex_binary.rs index e2168942c..3eac10cd3 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 02da72e40..ec34d52c3 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. @@ -77,7 +79,9 @@ pub enum IbcMsg { CloseChannel { channel_id: String }, } -#[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, @@ -86,7 +90,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 @@ -141,7 +147,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, @@ -176,7 +184,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, @@ -188,7 +198,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) @@ -219,7 +231,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 @@ -252,7 +266,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, @@ -273,7 +289,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 @@ -329,14 +347,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 @@ -388,7 +410,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 @@ -424,7 +448,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, @@ -438,7 +464,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, @@ -461,7 +489,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, @@ -481,7 +511,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. @@ -623,7 +655,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/iterator.rs b/packages/std/src/iterator.rs index 41f043a09..e33773df8 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 19b1c0a29..266c752b1 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 a37a0ffee..4c6fc4c45 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 6d240f285..9f245315d 100644 --- a/packages/std/src/math/int128.rs +++ b/packages/std/src/math/int128.rs @@ -30,7 +30,19 @@ use super::num_consts::NumConsts; /// let a = Int128::from(258i128); /// assert_eq!(a.i128(), 258); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 128, signed: true })] pub struct Int128(#[schemars(with = "String")] pub(crate) i128); forward_ref_partial_eq!(Int128, Int128); diff --git a/packages/std/src/math/int256.rs b/packages/std/src/math/int256.rs index 4b236bed1..9419f96f9 100644 --- a/packages/std/src/math/int256.rs +++ b/packages/std/src/math/int256.rs @@ -41,7 +41,19 @@ use super::num_consts::NumConsts; /// ]); /// assert_eq!(a, b); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 256, signed: true })] pub struct Int256(#[schemars(with = "String")] pub(crate) I256); forward_ref_partial_eq!(Int256, Int256); diff --git a/packages/std/src/math/int512.rs b/packages/std/src/math/int512.rs index edbfaa2a4..820b609d7 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); forward_ref_partial_eq!(Int512, Int512); diff --git a/packages/std/src/math/int64.rs b/packages/std/src/math/int64.rs index ccabc9ef3..704b1a2dd 100644 --- a/packages/std/src/math/int64.rs +++ b/packages/std/src/math/int64.rs @@ -30,7 +30,19 @@ use super::num_consts::NumConsts; /// let a = Int64::from(258i64); /// assert_eq!(a.i64(), 258); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 64, signed: true })] pub struct Int64(#[schemars(with = "String")] pub(crate) i64); forward_ref_partial_eq!(Int64, Int64); diff --git a/packages/std/src/math/signed_decimal.rs b/packages/std/src/math/signed_decimal.rs index 5dd82b10e..249f5de15 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 e994bd7ba..6f5439bdd 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 b209f2800..255fb8fc1 100644 --- a/packages/std/src/math/uint128.rs +++ b/packages/std/src/math/uint128.rs @@ -40,7 +40,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); forward_ref_partial_eq!(Uint128, Uint128); diff --git a/packages/std/src/math/uint256.rs b/packages/std/src/math/uint256.rs index 815cf3400..2a6b773c5 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); forward_ref_partial_eq!(Uint256, Uint256); diff --git a/packages/std/src/math/uint512.rs b/packages/std/src/math/uint512.rs index cd96353c6..bbc98c645 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); forward_ref_partial_eq!(Uint512, Uint512); diff --git a/packages/std/src/math/uint64.rs b/packages/std/src/math/uint64.rs index 707cd9e31..3a07be73b 100644 --- a/packages/std/src/math/uint64.rs +++ b/packages/std/src/math/uint64.rs @@ -35,7 +35,19 @@ use super::num_consts::NumConsts; /// let b = Uint64::from(70u32); /// assert_eq!(b.u64(), 70); /// ``` -#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive( + Copy, + Clone, + Default, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + schemars::JsonSchema, + cw_schema::Schemaifier, +)] +#[schemaifier(type = cw_schema::NodeType::Integer { precision: 64, signed: false })] pub struct Uint64(#[schemars(with = "String")] pub(crate) u64); forward_ref_partial_eq!(Uint64, Uint64); diff --git a/packages/std/src/metadata.rs b/packages/std/src/metadata.rs index b741f3209..1f9f45806 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 51173892f..f63eadac0 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 d9d1d8ef9..1b402d616 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 4ae51883e..8a1484073 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. @@ -36,7 +38,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 { @@ -49,7 +53,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 { @@ -62,7 +68,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 { @@ -74,7 +82,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 { @@ -86,7 +96,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 0abc33f19..57224c330 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 739e9ac35..e91c349ff 100644 --- a/packages/std/src/query/ibc.rs +++ b/packages/std/src/query/ibc.rs @@ -7,7 +7,9 @@ use crate::prelude::*; /// These are queries to the various IBC modules to see the state of the contract's /// IBC connection. 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. @@ -31,7 +33,9 @@ pub enum IbcQuery { // TODO: Add more } -#[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, @@ -39,7 +43,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, @@ -47,7 +53,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, diff --git a/packages/std/src/query/mod.rs b/packages/std/src/query/mod.rs index 27e622592..f215385fe 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`, diff --git a/packages/std/src/query/staking.rs b/packages/std/src/query/staking.rs index 3c5fd0ec2..77fac9745 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 b05ba32d4..bfc587688 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 e887c7450..d1478eb95 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 f35c79fae..6be613f28 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -23,7 +23,9 @@ pub trait CustomMsg: Serialize + Clone + fmt::Debug + PartialEq + JsonSchema {} impl CustomMsg for Empty {} #[non_exhaustive] -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] // See https://github.com/serde-rs/serde/issues/1296 why we cannot add De-Serialize trait bounds to T pub enum CosmosMsg { @@ -88,7 +90,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. @@ -110,7 +114,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). @@ -133,7 +139,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). @@ -159,7 +167,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, @@ -181,7 +191,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). @@ -339,7 +351,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. @@ -359,7 +373,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, @@ -369,7 +385,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 c3d3771d2..eec5ff17f 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 expressable 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 823a671a7..fedc08956 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 11bfcc148..edcc4da35 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 ac36fd0f7..1b32307c1 100644 --- a/packages/std/src/results/submessages.rs +++ b/packages/std/src/results/submessages.rs @@ -9,7 +9,9 @@ use super::{CosmosMsg, Empty, Event}; /// Use this to define when the contract gets a response callback. /// If you only need it for errors or success you can select just those in order /// to save gas. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum ReplyOn { /// Always perform a callback after SubMsg is processed @@ -28,7 +30,9 @@ pub enum ReplyOn { /// Note: On error the submessage execution will revert any partial state changes due to this message, /// but not revert any state changes in the calling contract. If this is required, it must be done /// manually in the `reply` entry point. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct SubMsg { /// An arbitrary ID chosen by the contract. /// This is typically used to match `Reply`s in the `reply` entry point to the submessage. @@ -166,7 +170,9 @@ impl SubMsg { /// The result object returned to `reply`. We always get the ID from the submessage /// back and then must handle success and error cases ourselves. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct Reply { /// The ID that the contract set when emitting the `SubMsg`. /// Use this to identify which submessage triggered the `reply`. @@ -226,7 +232,9 @@ pub struct Reply { /// let result = SubMsgResult::Err(error_msg); /// assert_eq!(to_json_string(&result).unwrap(), r#"{"error":"Something went wrong"}"#); /// ``` -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] #[serde(rename_all = "snake_case")] pub enum SubMsgResult { Ok(SubMsgResponse), @@ -282,7 +290,9 @@ impl From for Result { /// The information we get back from a successful sub message execution, /// with full Cosmos SDK events. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct SubMsgResponse { pub events: Vec, #[deprecated = "Deprecated in the Cosmos SDK in favor of msg_responses. If your chain is running on CosmWasm 2.0 or higher, msg_responses will be filled. For older versions, the data field is still needed since msg_responses is empty in those cases."] @@ -298,7 +308,9 @@ pub struct SubMsgResponse { pub msg_responses: Vec, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[derive( + Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier, +)] pub struct MsgResponse { pub type_url: String, pub value: Binary, diff --git a/packages/std/src/results/system_result.rs b/packages/std/src/results/system_result.rs index 0623d0858..1ae1a0370 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 953ea8099..d5bd127cc 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 331304a03..ee41cc27d 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 f85d42e8a..371fae8c4 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, } From abaed019cde1feec5e20cf0e88ef59d6bc1180d9 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 19 Aug 2024 15:38:40 +0200 Subject: [PATCH 03/60] Add rename_all support --- packages/cw-schema-derive/src/expand.rs | 58 +++++++++++++++++-- packages/cw-schema/tests/derive.rs | 11 ++++ .../snapshots/derive__snapshot_schema.snap | 25 ++++++-- 3 files changed, 83 insertions(+), 11 deletions(-) diff --git a/packages/cw-schema-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs index cb10a7337..f51479a82 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -1,9 +1,40 @@ use crate::bail; use proc_macro2::TokenStream; -use quote::quote; +use quote::{format_ident, quote}; use std::borrow::Cow; use syn::{DataEnum, DataStruct, DataUnion, DeriveInput, Lit}; +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) +} + +fn ident_adapter(converter: Converter) -> impl Fn(&syn::Ident) -> syn::Ident { + let adapter = move |ident: &syn::Ident| format_ident!("{}", converter(&ident.to_string())); + Box::new(adapter) +} + struct SerdeContainerOptions { rename_all: Option, untagged: bool, @@ -140,13 +171,20 @@ pub struct ContainerMeta { fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result { let crate_path = &meta.options.crate_path; + let converter = ident_adapter( + meta.serde_options + .rename_all + .as_ref() + .map(case_converter) + .unwrap_or_else(|| Ok(|txt: &str| txt.to_string()))?, + ); let mut cases = Vec::new(); for variant in input.variants.iter() { let value = match variant.fields { syn::Fields::Named(ref fields) => { let items = fields.named.iter().map(|field| { - let name = field.ident.as_ref().unwrap(); + let name = converter(field.ident.as_ref().unwrap()); let description = normalize_option(extract_documentation(&field.attrs)?); let field_ty = &field.ty; @@ -185,7 +223,7 @@ fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result quote! { #crate_path::EnumValue::Unit }, }; - let variant_name = &variant.ident; + let variant_name = converter(&variant.ident); let description = normalize_option(extract_documentation(&variant.attrs)?); let expanded = quote! { @@ -214,7 +252,7 @@ fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result #crate_path::DefinitionReference { let node = #crate_path::Node { - name: std::any::type_name::().into(), + name: stringify!(#name).into(), description: #description, value: #crate_path::NodeType::Enum { discriminator: None, @@ -231,6 +269,14 @@ fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result syn::Result { + let converter = ident_adapter( + meta.serde_options + .rename_all + .as_ref() + .map(case_converter) + .unwrap_or_else(|| Ok(|txt: &str| txt.to_string()))?, + ); + let name = &meta.name; let description = normalize_option(meta.description.as_ref()); let crate_path = &meta.options.crate_path; @@ -249,7 +295,7 @@ fn expand_struct(mut meta: ContainerMeta, input: DataStruct) -> syn::Result { let items = named.named.iter().map(|field| { - let name = field.ident.as_ref().unwrap(); + let name = converter(field.ident.as_ref().unwrap()); let description = normalize_option(extract_documentation(&field.attrs)?); let field_ty = &field.ty; @@ -297,7 +343,7 @@ fn expand_struct(mut meta: ContainerMeta, input: DataStruct) -> syn::Result().into(), + name: stringify!(#name).into(), description: #description, value: #node_ty, } diff --git a/packages/cw-schema/tests/derive.rs b/packages/cw-schema/tests/derive.rs index 9ef13cf8d..05aa87a64 100644 --- a/packages/cw-schema/tests/derive.rs +++ b/packages/cw-schema/tests/derive.rs @@ -12,6 +12,9 @@ struct HelloWorld { /// Baz field! baz: Baz, + /// Quux field! + quux: Quux, + /// Tuple field! tuple: (u32, u32), } @@ -37,6 +40,14 @@ enum Baz { D(u32, u32), } +#[derive(Schemaifier)] +#[serde(rename_all = "camelCase")] +/// Quux struct! +pub struct Quux { + /// Quux field! + quux_field: u32, +} + #[test] fn snapshot_schema() { let schema = cw_schema::schema_of::(); diff --git a/packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap b/packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap index 42dc7f4ed..1202993dc 100644 --- a/packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap +++ b/packages/cw-schema/tests/snapshots/derive__snapshot_schema.snap @@ -4,7 +4,7 @@ expression: schema --- { "type": "v1", - "root": 6, + "root": 7, "definitions": [ { "name": "String", @@ -17,7 +17,7 @@ expression: schema "signed": false }, { - "name": "derive::Bar", + "name": "Bar", "description": "Bar struct!", "type": "struct", "properties": { @@ -33,7 +33,7 @@ expression: schema "inner": 2 }, { - "name": "derive::Baz", + "name": "Baz", "description": "Baz enum!", "type": "enum", "cases": { @@ -61,6 +61,17 @@ expression: schema } } }, + { + "name": "Quux", + "description": "Quux struct!", + "type": "struct", + "properties": { + "quuxField": { + "description": "Quux field!", + "value": 1 + } + } + }, { "name": "(u32, u32)", "type": "tuple", @@ -70,7 +81,7 @@ expression: schema ] }, { - "name": "derive::HelloWorld", + "name": "HelloWorld", "description": "Hello world struct!", "type": "struct", "properties": { @@ -86,9 +97,13 @@ expression: schema "description": "Name field!", "value": 0 }, + "quux": { + "description": "Quux field!", + "value": 5 + }, "tuple": { "description": "Tuple field!", - "value": 5 + "value": 6 } } } From f34ab2210ca4f49de45c16b386296fb18e6f15d4 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 20 Aug 2024 11:32:25 +0200 Subject: [PATCH 04/60] Deduplicate a little --- packages/cw-schema-derive/src/expand.rs | 97 ++++++++++++------------- packages/cw-schema/tests/basic.rs | 2 - packages/cw-schema/tests/derive.rs | 2 + 3 files changed, 48 insertions(+), 53 deletions(-) diff --git a/packages/cw-schema-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs index f51479a82..9b0f97b0a 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -1,3 +1,5 @@ +// TODO: CLEAN ALL THIS SHIT UP WHAT THE FUCK IS THIS + use crate::bail; use proc_macro2::TokenStream; use quote::{format_ident, quote}; @@ -30,9 +32,13 @@ fn case_converter(case: &syn::LitStr) -> syn::Result { Ok(converter) } +fn maybe_case_converter(case: Option<&syn::LitStr>) -> syn::Result { + case.map(case_converter) + .unwrap_or_else(|| Ok(|txt: &str| txt.to_string())) +} + fn ident_adapter(converter: Converter) -> impl Fn(&syn::Ident) -> syn::Ident { - let adapter = move |ident: &syn::Ident| format_ident!("{}", converter(&ident.to_string())); - Box::new(adapter) + move |ident: &syn::Ident| format_ident!("{}", converter(&ident.to_string())) } struct SerdeContainerOptions { @@ -169,37 +175,45 @@ pub struct ContainerMeta { 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 name = 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( - meta.serde_options - .rename_all - .as_ref() - .map(case_converter) - .unwrap_or_else(|| Ok(|txt: &str| txt.to_string()))?, - ); + 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 = fields.named.iter().map(|field| { - let name = 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) - }).collect::>>()?; + let items = collect_struct_fields(&converter, crate_path, fields) + .collect::>>()?; quote! { #crate_path::EnumValue::Named { @@ -269,13 +283,9 @@ fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result syn::Result { - let converter = ident_adapter( - meta.serde_options - .rename_all - .as_ref() - .map(case_converter) - .unwrap_or_else(|| Ok(|txt: &str| txt.to_string()))?, - ); + 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()); @@ -293,24 +303,9 @@ fn expand_struct(mut meta: ContainerMeta, input: DataStruct) -> syn::Result { - let items = named.named.iter().map(|field| { - let name = 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) - }).collect::>>()?; + syn::Fields::Named(ref named) => { + let items = collect_struct_fields(&converter, crate_path, named) + .collect::>>()?; quote! { #crate_path::StructType::Named { diff --git a/packages/cw-schema/tests/basic.rs b/packages/cw-schema/tests/basic.rs index e6c5a910e..2e0579918 100644 --- a/packages/cw-schema/tests/basic.rs +++ b/packages/cw-schema/tests/basic.rs @@ -116,10 +116,8 @@ fn roundtrip() { #[test] fn can_decode_example() { - /* let example = include_str!("example.json"); let _: Schema = serde_json::from_str(example).unwrap(); - */ } #[test] diff --git a/packages/cw-schema/tests/derive.rs b/packages/cw-schema/tests/derive.rs index 05aa87a64..ffae4712d 100644 --- a/packages/cw-schema/tests/derive.rs +++ b/packages/cw-schema/tests/derive.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] // We never construct these types. Introspection is done at compile time. + use cw_schema::Schemaifier; #[derive(Schemaifier)] From 00865e02009fc9b0a1f4d02c26daf5ecd2962bcc Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 20 Aug 2024 15:08:00 +0200 Subject: [PATCH 05/60] Add warnings for unknown serde attributes --- Cargo.lock | 26 +++++++ packages/cw-schema-derive/Cargo.toml | 1 + packages/cw-schema-derive/src/expand.rs | 99 +++++++++++++++++++++++-- packages/cw-schema/tests/derive.rs | 2 +- 4 files changed, 121 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 186217fc3..a1da3bd14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -951,6 +951,7 @@ version = "2.1.1" dependencies = [ "heck 0.5.0", "itertools 0.13.0", + "owo-colors", "proc-macro2", "quote", "syn 2.0.75", @@ -1651,6 +1652,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" @@ -1887,6 +1894,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" @@ -2673,6 +2689,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" diff --git a/packages/cw-schema-derive/Cargo.toml b/packages/cw-schema-derive/Cargo.toml index 8fe5336d1..17b3f5773 100644 --- a/packages/cw-schema-derive/Cargo.toml +++ b/packages/cw-schema-derive/Cargo.toml @@ -9,6 +9,7 @@ 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 index 9b0f97b0a..7fa63fc17 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -1,11 +1,40 @@ // TODO: CLEAN ALL THIS SHIT UP WHAT THE FUCK IS THIS use crate::bail; +use owo_colors::{OwoColorize, Stream, Style}; use proc_macro2::TokenStream; use quote::{format_ident, quote}; -use std::borrow::Cow; +use std::{ + borrow::Cow, + fmt::Display, + io::{self, Write as _}, +}; use syn::{DataEnum, DataStruct, DataUnion, DeriveInput, Lit}; +fn print_warning(title: impl Display, content: impl Display) -> io::Result<()> { + let mut sink = io::stderr(); + + macro_rules! apply_style { + ($style:ident => $content:expr) => {{ + //$content.if_supports_color(Stream::Stderr, |txt| txt.style($style)) + $content.style($style) + }}; + } + + let bold_yellow = Style::new().bold().yellow(); + let bold = Style::new().bold(); + let blue = Style::new().blue(); + + write!(sink, "{}", apply_style!(bold_yellow => "warning"))?; + writeln!(sink, "{}", apply_style!(bold => format_args!(": {title}")))?; + + writeln!(sink, "{}", apply_style!(blue => " | "))?; + write!(sink, "{}", apply_style!(blue => " | "))?; + writeln!(sink, "{content}")?; + + Ok(()) +} + type Converter = fn(&str) -> String; fn case_converter(case: &syn::LitStr) -> syn::Result { @@ -32,11 +61,13 @@ fn case_converter(case: &syn::LitStr) -> syn::Result { 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())) } @@ -63,6 +94,18 @@ impl SerdeContainerOptions { } 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 @@ -118,6 +161,51 @@ impl ContainerOptions { } } +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 { @@ -154,10 +242,10 @@ fn extract_documentation(attributes: &[syn::Attribute]) -> syn::Result( - options: &ContainerOptions, - type_params: impl Iterator, -) { +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 { @@ -371,7 +459,6 @@ fn expand_union(_meta: ContainerMeta, input: DataUnion) -> syn::Result syn::Result { let options = ContainerOptions::parse(&input.attrs)?; let serde_options = SerdeContainerOptions::parse(&input.attrs)?; - let description = extract_documentation(&input.attrs)?; let meta = ContainerMeta { diff --git a/packages/cw-schema/tests/derive.rs b/packages/cw-schema/tests/derive.rs index ffae4712d..dc636e27e 100644 --- a/packages/cw-schema/tests/derive.rs +++ b/packages/cw-schema/tests/derive.rs @@ -43,7 +43,7 @@ enum Baz { } #[derive(Schemaifier)] -#[serde(rename_all = "camelCase")] +#[serde(rename_all = "camelCase", thingy = "lmao")] /// Quux struct! pub struct Quux { /// Quux field! From 9e971d61dd827a3b8a39daf56201c33cece33974 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 21 Aug 2024 12:48:26 +0200 Subject: [PATCH 06/60] Add rename option and option to mute warnings --- packages/cw-schema-derive/src/expand.rs | 52 +++++++---- packages/cw-schema/tests/basic.rs | 116 +----------------------- 2 files changed, 36 insertions(+), 132 deletions(-) diff --git a/packages/cw-schema-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs index 7fa63fc17..439888150 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -1,37 +1,45 @@ // TODO: CLEAN ALL THIS SHIT UP WHAT THE FUCK IS THIS use crate::bail; -use owo_colors::{OwoColorize, Stream, Style}; +use owo_colors::{OwoColorize, Style}; use proc_macro2::TokenStream; use quote::{format_ident, quote}; use std::{ - borrow::Cow, - fmt::Display, - io::{self, Write as _}, + borrow::Cow, env, fmt::Display, io::{self, Write as _} }; use syn::{DataEnum, DataStruct, DataUnion, DeriveInput, Lit}; -fn print_warning(title: impl Display, content: impl Display) -> io::Result<()> { - let mut sink = io::stderr(); +const DISABLE_WARNINGS_VAR: &str = "SHUT_UP_CW_SCHEMA_DERIVE"; - macro_rules! apply_style { - ($style:ident => $content:expr) => {{ - //$content.if_supports_color(Stream::Stderr, |txt| txt.style($style)) - $content.style($style) - }}; +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, "{}", apply_style!(bold_yellow => "warning"))?; - writeln!(sink, "{}", apply_style!(bold => format_args!(": {title}")))?; + write!(sink, "{}", "warning".style(bold_yellow))?; + writeln!( + sink, + "{}", + format_args!("({}): {title}", env!("CARGO_PKG_NAME")).style(bold) + )?; - writeln!(sink, "{}", apply_style!(blue => " | "))?; - write!(sink, "{}", apply_style!(blue => " | "))?; + 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(()) } @@ -272,7 +280,12 @@ where C: Fn(&syn::Ident) -> syn::Ident, { fields.named.iter().map(move |field| { - let name = converter(field.ident.as_ref().unwrap()); + 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; @@ -325,7 +338,12 @@ fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result quote! { #crate_path::EnumValue::Unit }, }; - let variant_name = converter(&variant.ident); + 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! { diff --git a/packages/cw-schema/tests/basic.rs b/packages/cw-schema/tests/basic.rs index 2e0579918..3aeb1b66a 100644 --- a/packages/cw-schema/tests/basic.rs +++ b/packages/cw-schema/tests/basic.rs @@ -1,118 +1,4 @@ -use cw_schema::{EnumCase, Node, NodeType, Schema, SchemaV1, StructProperty}; - -#[test] -fn roundtrip() { - /* - let schema_struct = Schema::V1(SchemaV1 { - root: Node { - name: Some("root".into()), - description: Some("root node".into()), - optional: false, - value: NodeContent::Concrete(NodeType::Object { - properties: vec![ - StructProperty { - name: "foo".into(), - description: Some("foo property".into()), - value: Node { - name: None, - description: None, - optional: false, - value: NodeContent::Concrete(NodeType::String), - }, - }, - StructProperty { - name: "bar".into(), - description: Some("bar property".into()), - value: Node { - name: None, - description: None, - optional: false, - value: NodeContent::Concrete(NodeType::Integer { - signed: false, - precision: 64, - }), - }, - }, - StructProperty { - name: "union".into(), - description: Some("union property".into()), - value: Node { - name: None, - description: None, - optional: false, - value: NodeContent::OneOf { - one_of: vec![ - Node { - name: None, - description: None, - optional: true, - value: NodeContent::Concrete(NodeType::String), - }, - Node { - name: None, - description: None, - optional: false, - value: NodeContent::Concrete(NodeType::Integer { - signed: true, - precision: 128, - }), - }, - ], - }, - }, - }, - StructProperty { - name: "tagged_union".into(), - description: Some("tagged union property".into()), - value: Node { - name: None, - description: None, - optional: false, - value: NodeContent::Concrete(NodeType::Enum { - discriminator: Some("type".into()), - cases: vec![ - EnumCase { - name: "string".into(), - description: Some("string case".into()), - discriminator_value: None, - value: Some(Node { - name: None, - description: None, - optional: true, - value: NodeContent::Concrete(NodeType::String), - }), - }, - EnumCase { - name: "number".into(), - description: Some("number case".into()), - discriminator_value: None, - value: Some(Node { - name: None, - description: None, - optional: false, - value: NodeContent::Concrete(NodeType::Integer { - signed: false, - precision: 8, - }), - }), - }, - ], - }), - }, - }, - ], - }), - }, - }); - - let schema = serde_json::to_string(&schema_struct).unwrap(); - - pretty_assertions::assert_eq!( - schema_struct, - serde_json::from_str::(&schema).unwrap() - ); - */ -} +use cw_schema::Schema; #[test] fn can_decode_example() { From c4aa695a90ff046b39340e51a5344a5fc5ef2eb4 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 21 Aug 2024 13:39:00 +0200 Subject: [PATCH 07/60] Add to `cw_serde` --- Cargo.lock | 1 + packages/schema-derive/src/cw_serde.rs | 22 +++++++++++++++++----- packages/schema/Cargo.toml | 1 + packages/schema/src/lib.rs | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1da3bd14..5c9b73599 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -623,6 +623,7 @@ version = "2.1.1" dependencies = [ "anyhow", "cosmwasm-schema-derive", + "cw-schema", "schemars 0.8.20", "semver", "serde", diff --git a/packages/schema-derive/src/cw_serde.rs b/packages/schema-derive/src/cw_serde.rs index be35fd341..4de9fcaf6 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 Date: Mon, 26 Aug 2024 14:30:20 +0200 Subject: [PATCH 08/60] Add codegen for cw_schema --- Cargo.lock | 19 +- packages/cw-schema-derive/src/expand.rs | 10 +- packages/cw-schema/src/default_impls.rs | 13 ++ packages/cw-schema/src/lib.rs | 1 + packages/schema-derive/Cargo.toml | 1 + packages/schema-derive/src/query_responses.rs | 163 ++++++++++++++++-- packages/schema/src/query_response.rs | 44 ++++- 7 files changed, 218 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c9b73599..32d27c826 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -638,6 +638,7 @@ version = "2.1.1" dependencies = [ "proc-macro2", "quote", + "strum", "syn 2.0.75", ] @@ -950,7 +951,7 @@ dependencies = [ name = "cw-schema-derive" version = "2.1.1" dependencies = [ - "heck 0.5.0", + "heck", "itertools 0.13.0", "owo-colors", "proc-macro2", @@ -1543,12 +1544,6 @@ dependencies = [ "allocator-api2", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -2664,20 +2659,20 @@ 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", ] [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "quote", "rustversion", diff --git a/packages/cw-schema-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs index 439888150..a06646138 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -5,7 +5,10 @@ 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 _} + borrow::Cow, + env, + fmt::Display, + io::{self, Write as _}, }; use syn::{DataEnum, DataStruct, DataUnion, DeriveInput, Lit}; @@ -38,7 +41,10 @@ fn print_warning(title: impl Display, content: impl Display) -> io::Result<()> { write!(sink, "{}", " = ".style(blue))?; write!(sink, "{}", "note: ".style(bold))?; - writeln!(sink, "set `{DISABLE_WARNINGS_VAR}=1` to silence this warning")?; + writeln!( + sink, + "set `{DISABLE_WARNINGS_VAR}=1` to silence this warning" + )?; Ok(()) } diff --git a/packages/cw-schema/src/default_impls.rs b/packages/cw-schema/src/default_impls.rs index 3375d6256..1f7066312 100644 --- a/packages/cw-schema/src/default_impls.rs +++ b/packages/cw-schema/src/default_impls.rs @@ -1,6 +1,19 @@ use crate::{Node, NodeType, Schemaifier}; use alloc::{borrow::Cow, string::String, vec, vec::Vec}; +impl Schemaifier for () { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("Unit"), + description: None, + value: NodeType::Unit, + }, + ) + } +} + impl Schemaifier for String { fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { visitor.insert( diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index e900e8104..81c3945f5 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -112,6 +112,7 @@ pub enum NodeType { Optional { inner: DefinitionReference, }, + Unit, } #[skip_serializing_none] diff --git a/packages/schema-derive/Cargo.toml b/packages/schema-derive/Cargo.toml index 9617a5401..99d458077 100644 --- a/packages/schema-derive/Cargo.toml +++ b/packages/schema-derive/Cargo.toml @@ -10,6 +10,7 @@ license = "Apache-2.0" [dependencies] proc-macro2 = "1" quote = "1" +strum = { version = "0.26.3", features = ["derive"] } syn = { version = "2", features = ["extra-traits", "full", "printing"] } [lib] diff --git a/packages/schema-derive/src/query_responses.rs b/packages/schema-derive/src/query_responses.rs index 7d89761cb..48cd918c1 100644 --- a/packages/schema-derive/src/query_responses.rs +++ b/packages/schema-derive/src/query_responses.rs @@ -1,12 +1,19 @@ mod context; use crate::error::{bail, error_message}; +use strum::EnumIter; use syn::{ parse_quote, Expr, ExprTuple, Generics, ItemEnum, ItemImpl, Type, TypeParamBound, Variant, }; use self::context::Context; +#[derive(EnumIter)] +enum SchemaBackend { + CwSchema, + JsonSchema, +} + pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { let ctx = context::get_context(&input)?; @@ -14,9 +21,15 @@ pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { let crate_name = &ctx.crate_name; let ident = input.ident; let subquery_calls = input + .variants + .iter() + .map(|variant| parse_subquery(&ctx, variant.clone(), SchemaBackend::JsonSchema)) + .collect::>>()?; + + let subquery_calls_cw = input .variants .into_iter() - .map(|variant| parse_subquery(&ctx, variant)) + .map(|variant| parse_subquery(&ctx, variant, SchemaBackend::CwSchema)) .collect::>>()?; // Handle generics if the type has any @@ -36,7 +49,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 +65,24 @@ 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 mut cw_queries: Vec<_> = cw_mappings.clone().into_iter().map(|(q, _)| q).collect(); + cw_queries.sort(); + 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 +96,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 +123,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 +135,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,11 +150,18 @@ 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"), @@ -125,7 +175,16 @@ fn parse_subquery(ctx: &Context, v: Variant) -> syn::Result { 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 +247,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 +284,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 +325,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 +354,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 +407,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 +429,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 +452,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 +461,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 +514,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 +532,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 +572,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 +605,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/src/query_response.rs b/packages/schema/src/query_response.rs index 85ecc7f3b..c05c24129 100644 --- a/packages/schema/src/query_response.rs +++ b/packages/schema/src/query_response.rs @@ -70,13 +70,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 +113,7 @@ pub enum IntegrityError { #[cfg(test)] mod tests { + use cw_schema::schema_of; use schemars::schema_for; use super::*; @@ -130,6 +139,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 +175,10 @@ mod tests { fn response_schemas_impl() -> BTreeMap { BTreeMap::from([]) } + + fn response_schemas_cw_impl() -> BTreeMap { + BTreeMap::from([]) + } } #[test] @@ -175,6 +198,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 +231,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] From d392b72c2425c954afa31821f75a906d1b6757bc Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 26 Aug 2024 14:31:08 +0200 Subject: [PATCH 09/60] Remove unused dependency --- Cargo.lock | 1 - packages/schema-derive/Cargo.toml | 1 - packages/schema-derive/src/query_responses.rs | 2 -- 3 files changed, 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32d27c826..08db5875a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -638,7 +638,6 @@ version = "2.1.1" dependencies = [ "proc-macro2", "quote", - "strum", "syn 2.0.75", ] diff --git a/packages/schema-derive/Cargo.toml b/packages/schema-derive/Cargo.toml index 99d458077..9617a5401 100644 --- a/packages/schema-derive/Cargo.toml +++ b/packages/schema-derive/Cargo.toml @@ -10,7 +10,6 @@ license = "Apache-2.0" [dependencies] proc-macro2 = "1" quote = "1" -strum = { version = "0.26.3", features = ["derive"] } syn = { version = "2", features = ["extra-traits", "full", "printing"] } [lib] diff --git a/packages/schema-derive/src/query_responses.rs b/packages/schema-derive/src/query_responses.rs index 48cd918c1..1c2fd1c3f 100644 --- a/packages/schema-derive/src/query_responses.rs +++ b/packages/schema-derive/src/query_responses.rs @@ -1,14 +1,12 @@ mod context; use crate::error::{bail, error_message}; -use strum::EnumIter; use syn::{ parse_quote, Expr, ExprTuple, Generics, ItemEnum, ItemImpl, Type, TypeParamBound, Variant, }; use self::context::Context; -#[derive(EnumIter)] enum SchemaBackend { CwSchema, JsonSchema, From 9dacb7aace0c5e4a42b1768c6869425847e494d4 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 26 Aug 2024 14:35:27 +0200 Subject: [PATCH 10/60] Update lockfiles --- contracts/burner/Cargo.lock | 257 ++++++++++++++++++++----- contracts/crypto-verify/Cargo.lock | 257 ++++++++++++++++++++----- contracts/cyberpunk/Cargo.lock | 255 ++++++++++++++++++++----- contracts/empty/Cargo.lock | 257 ++++++++++++++++++++----- contracts/floaty/Cargo.lock | 257 ++++++++++++++++++++----- contracts/hackatom/Cargo.lock | 257 ++++++++++++++++++++----- contracts/ibc-callbacks/Cargo.lock | 253 ++++++++++++++++++++----- contracts/ibc-reflect-send/Cargo.lock | 257 ++++++++++++++++++++----- contracts/ibc-reflect/Cargo.lock | 257 ++++++++++++++++++++----- contracts/queue/Cargo.lock | 257 ++++++++++++++++++++----- contracts/reflect/Cargo.lock | 257 ++++++++++++++++++++----- contracts/staking/Cargo.lock | 259 +++++++++++++++++++++----- contracts/virus/Cargo.lock | 257 ++++++++++++++++++++----- 13 files changed, 2705 insertions(+), 632 deletions(-) diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 09f57ca51..55bbcd113 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -276,7 +276,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", ] @@ -395,7 +395,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -403,7 +403,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -415,7 +416,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -428,11 +429,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", @@ -454,7 +456,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -646,7 +648,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -679,7 +705,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -693,7 +719,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -715,7 +742,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -800,7 +827,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -824,7 +851,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -967,7 +994,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1158,6 +1185,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" @@ -1288,7 +1321,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1322,15 +1355,32 @@ 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", "serde", ] +[[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" @@ -1340,6 +1390,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" @@ -1519,6 +1578,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" @@ -1603,9 +1671,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1712,6 +1780,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1854,12 +1942,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1869,7 +1970,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1914,9 +2027,9 @@ dependencies = [ [[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", ] @@ -1953,13 +2066,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1970,16 +2083,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1993,13 +2107,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2043,6 +2180,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 = "slice-group-by" version = "0.3.1" @@ -2073,6 +2216,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2092,7 +2241,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2101,6 +2250,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" @@ -2114,9 +2273,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2131,7 +2290,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2186,7 +2345,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2253,7 +2412,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2266,7 +2425,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2292,7 +2451,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2391,7 +2550,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2413,7 +2572,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2530,8 +2689,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2621,7 +2780,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", ] @@ -2868,7 +3027,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2889,7 +3048,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2909,7 +3068,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2930,7 +3089,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2952,5 +3111,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 1df972c82..c1ce7c850 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -390,7 +390,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -398,7 +398,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -410,7 +411,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -423,11 +424,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", @@ -449,7 +451,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -629,7 +631,7 @@ dependencies = [ "hex-literal", "p256", "rlp", - "schemars", + "schemars 0.8.21", "serde", "sha2", "sha3", @@ -659,7 +661,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -692,7 +718,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -706,7 +732,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -728,7 +755,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -813,7 +840,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -837,7 +864,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -982,7 +1009,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1173,6 +1200,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" @@ -1309,7 +1342,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1343,15 +1376,32 @@ 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", "serde", ] +[[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" @@ -1361,6 +1411,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" @@ -1549,6 +1608,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" @@ -1643,9 +1711,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1752,6 +1820,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1910,12 +1998,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1925,7 +2026,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1971,9 +2084,9 @@ dependencies = [ [[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", ] @@ -2010,13 +2123,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2027,16 +2140,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -2050,13 +2164,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2110,6 +2247,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 = "slice-group-by" version = "0.3.1" @@ -2150,6 +2293,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2169,7 +2318,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2178,6 +2327,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" @@ -2191,9 +2350,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2208,7 +2367,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2263,7 +2422,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2330,7 +2489,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2343,7 +2502,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2369,7 +2528,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2468,7 +2627,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2490,7 +2649,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2607,8 +2766,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2698,7 +2857,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", ] @@ -2945,7 +3104,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2966,7 +3125,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2986,7 +3145,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -3007,7 +3166,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -3029,5 +3188,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index 4209c3033..eb561ed1b 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -407,7 +407,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -415,7 +415,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -427,7 +428,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -440,11 +441,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", @@ -466,7 +468,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -658,7 +660,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -703,7 +729,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -717,7 +743,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -739,7 +766,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -824,7 +851,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -848,7 +875,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -991,7 +1018,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1182,6 +1209,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" @@ -1312,7 +1345,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1346,15 +1379,32 @@ 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", "serde", ] +[[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" @@ -1364,6 +1414,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" @@ -1543,6 +1602,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" @@ -1627,9 +1695,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1736,6 +1804,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1889,12 +1977,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1904,7 +2005,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1949,9 +2062,9 @@ dependencies = [ [[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", ] @@ -1988,13 +2101,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2005,16 +2118,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -2028,13 +2142,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2078,6 +2215,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 = "slice-group-by" version = "0.3.1" @@ -2108,6 +2251,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2127,7 +2276,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2136,6 +2285,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" @@ -2149,9 +2308,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2166,7 +2325,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2221,7 +2380,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2288,7 +2447,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2301,7 +2460,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2327,7 +2486,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2426,7 +2585,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2448,7 +2607,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2565,8 +2724,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2656,7 +2815,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", ] @@ -2903,7 +3062,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2924,7 +3083,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2944,7 +3103,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2965,7 +3124,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2987,5 +3146,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 3d9309cc6..126dd14d5 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -925,7 +952,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", ] [[package]] @@ -966,7 +993,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1157,6 +1184,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" @@ -1287,7 +1320,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1321,15 +1354,32 @@ 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", "serde", ] +[[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" @@ -1339,6 +1389,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" @@ -1518,6 +1577,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" @@ -1602,9 +1670,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1711,6 +1779,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1853,12 +1941,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1868,7 +1969,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1913,9 +2026,9 @@ dependencies = [ [[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", ] @@ -1952,13 +2065,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1969,16 +2082,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1992,13 +2106,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2042,6 +2179,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 = "slice-group-by" version = "0.3.1" @@ -2072,6 +2215,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2091,7 +2240,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2100,6 +2249,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" @@ -2113,9 +2272,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2130,7 +2289,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2185,7 +2344,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2252,7 +2411,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2265,7 +2424,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2291,7 +2450,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2390,7 +2549,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2412,7 +2571,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2529,8 +2688,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2620,7 +2779,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", ] @@ -2867,7 +3026,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2888,7 +3047,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2908,7 +3067,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2929,7 +3088,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2951,5 +3110,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index d22337d78..1b4de0d00 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -956,7 +983,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1033,7 +1060,7 @@ dependencies = [ "cosmwasm-std", "cosmwasm-vm", "rand_chacha", - "schemars", + "schemars 0.8.21", "serde", ] @@ -1159,6 +1186,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" @@ -1289,7 +1322,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1323,15 +1356,32 @@ 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", "serde", ] +[[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" @@ -1341,6 +1391,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" @@ -1520,6 +1579,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" @@ -1604,9 +1672,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1713,6 +1781,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1855,12 +1943,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1870,7 +1971,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1915,9 +2028,9 @@ dependencies = [ [[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", ] @@ -1954,13 +2067,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1971,16 +2084,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1994,13 +2108,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2044,6 +2181,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 = "slice-group-by" version = "0.3.1" @@ -2074,6 +2217,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2093,7 +2242,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2102,6 +2251,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" @@ -2115,9 +2274,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2132,7 +2291,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2187,7 +2346,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2254,7 +2413,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2267,7 +2426,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2293,7 +2452,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2392,7 +2551,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2414,7 +2573,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2531,8 +2690,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2622,7 +2781,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", ] @@ -2869,7 +3028,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2890,7 +3049,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2910,7 +3069,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2931,7 +3090,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2953,5 +3112,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 8a6271bc3..d17282c97 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -956,7 +983,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1114,7 +1141,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", "sha2", "thiserror", @@ -1160,6 +1187,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" @@ -1290,7 +1323,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1324,15 +1357,32 @@ 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", "serde", ] +[[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" @@ -1342,6 +1392,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" @@ -1521,6 +1580,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" @@ -1605,9 +1673,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1714,6 +1782,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1856,12 +1944,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1871,7 +1972,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1916,9 +2029,9 @@ dependencies = [ [[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", ] @@ -1955,13 +2068,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1972,16 +2085,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1995,13 +2109,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2045,6 +2182,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 = "slice-group-by" version = "0.3.1" @@ -2075,6 +2218,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2094,7 +2243,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2103,6 +2252,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" @@ -2116,9 +2275,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2133,7 +2292,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2188,7 +2347,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2255,7 +2414,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2268,7 +2427,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2294,7 +2453,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2393,7 +2552,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2415,7 +2574,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2532,8 +2691,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2623,7 +2782,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", ] @@ -2870,7 +3029,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2891,7 +3050,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2911,7 +3070,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2932,7 +3091,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2954,5 +3113,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/ibc-callbacks/Cargo.lock b/contracts/ibc-callbacks/Cargo.lock index 4809e5f7c..30589d7ec 100644 --- a/contracts/ibc-callbacks/Cargo.lock +++ b/contracts/ibc-callbacks/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.20", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.20", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck 0.5.0", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.65", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", "unicode-xid", ] @@ -945,7 +972,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -1136,6 +1163,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" @@ -1158,7 +1197,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.20", "serde", ] @@ -1191,15 +1230,32 @@ 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", "serde", ] +[[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" @@ -1209,6 +1265,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" @@ -1382,6 +1447,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" @@ -1466,9 +1540,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1575,6 +1649,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1717,12 +1811,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.20" @@ -1732,7 +1839,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.65", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1777,9 +1896,9 @@ dependencies = [ [[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", ] @@ -1816,13 +1935,13 @@ 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", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -1833,16 +1952,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", ] [[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", ] @@ -1856,13 +1976,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -1906,6 +2049,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 = "slice-group-by" version = "0.3.1" @@ -1936,6 +2085,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -1951,11 +2106,11 @@ 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", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -1964,6 +2119,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" @@ -1977,9 +2142,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.65" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2038,7 +2203,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -2095,7 +2260,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2108,7 +2273,7 @@ version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2134,7 +2299,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -2236,7 +2401,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2258,7 +2423,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2375,8 +2540,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.20", "semver", "serde", "serde_cbor", @@ -2466,7 +2631,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", ] @@ -2698,7 +2863,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", ] [[package]] @@ -2718,5 +2883,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.65", + "syn 2.0.76", ] diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index e1d7eef29..52560ee28 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -956,7 +983,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1147,6 +1174,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" @@ -1169,7 +1202,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", ] @@ -1288,7 +1321,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1322,15 +1355,32 @@ 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", "serde", ] +[[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" @@ -1340,6 +1390,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" @@ -1519,6 +1578,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" @@ -1603,9 +1671,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1712,6 +1780,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1854,12 +1942,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1869,7 +1970,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1914,9 +2027,9 @@ dependencies = [ [[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", ] @@ -1953,13 +2066,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1970,16 +2083,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1993,13 +2107,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2043,6 +2180,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 = "slice-group-by" version = "0.3.1" @@ -2073,6 +2216,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2092,7 +2241,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2101,6 +2250,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" @@ -2114,9 +2273,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2131,7 +2290,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2186,7 +2345,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2253,7 +2412,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2266,7 +2425,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2292,7 +2451,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2391,7 +2550,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2413,7 +2572,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2530,8 +2689,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2621,7 +2780,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", ] @@ -2868,7 +3027,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2889,7 +3048,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2909,7 +3068,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2930,7 +3089,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2952,5 +3111,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index e74d7fef0..84ad01965 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -956,7 +983,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1147,6 +1174,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" @@ -1169,7 +1202,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", ] @@ -1288,7 +1321,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1322,15 +1355,32 @@ 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", "serde", ] +[[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" @@ -1340,6 +1390,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" @@ -1519,6 +1578,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" @@ -1603,9 +1671,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1712,6 +1780,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1854,12 +1942,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1869,7 +1970,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1914,9 +2027,9 @@ dependencies = [ [[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", ] @@ -1953,13 +2066,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1970,16 +2083,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1993,13 +2107,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2043,6 +2180,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 = "slice-group-by" version = "0.3.1" @@ -2073,6 +2216,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2092,7 +2241,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2101,6 +2250,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" @@ -2114,9 +2273,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2131,7 +2290,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2186,7 +2345,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2253,7 +2412,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2266,7 +2425,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2292,7 +2451,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2391,7 +2550,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2413,7 +2572,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2530,8 +2689,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2621,7 +2780,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", ] @@ -2868,7 +3027,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2889,7 +3048,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2909,7 +3068,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2930,7 +3089,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2952,5 +3111,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index 2aa741f47..3ca86329d 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -956,7 +983,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1147,6 +1174,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" @@ -1277,7 +1310,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1311,15 +1344,32 @@ 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", "serde", ] +[[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" @@ -1329,6 +1379,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" @@ -1508,6 +1567,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" @@ -1592,9 +1660,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1626,7 +1694,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", ] @@ -1712,6 +1780,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1854,12 +1942,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1869,7 +1970,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1914,9 +2027,9 @@ dependencies = [ [[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", ] @@ -1953,13 +2066,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1970,16 +2083,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1993,13 +2107,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2043,6 +2180,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 = "slice-group-by" version = "0.3.1" @@ -2073,6 +2216,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2092,7 +2241,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2101,6 +2250,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" @@ -2114,9 +2273,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2131,7 +2290,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2186,7 +2345,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2253,7 +2412,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2266,7 +2425,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2292,7 +2451,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2391,7 +2550,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2413,7 +2572,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2530,8 +2689,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2621,7 +2780,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", ] @@ -2868,7 +3027,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2889,7 +3048,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2909,7 +3068,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2930,7 +3089,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2952,5 +3111,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 61f708507..227707093 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -956,7 +983,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1147,6 +1174,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" @@ -1277,7 +1310,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1311,15 +1344,32 @@ 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", "serde", ] +[[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" @@ -1329,6 +1379,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" @@ -1508,6 +1567,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" @@ -1592,9 +1660,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1701,6 +1769,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.76", +] + [[package]] name = "reflect" version = "0.0.0" @@ -1708,7 +1796,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", "thiserror", ] @@ -1855,12 +1943,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1870,7 +1971,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1915,9 +2028,9 @@ dependencies = [ [[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", ] @@ -1954,13 +2067,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1971,16 +2084,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1994,13 +2108,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2044,6 +2181,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 = "slice-group-by" version = "0.3.1" @@ -2074,6 +2217,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2093,7 +2242,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2102,6 +2251,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" @@ -2115,9 +2274,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2132,7 +2291,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2187,7 +2346,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2254,7 +2413,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2267,7 +2426,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2293,7 +2452,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2392,7 +2551,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2414,7 +2573,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2531,8 +2690,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2622,7 +2781,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", ] @@ -2869,7 +3028,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2890,7 +3049,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2910,7 +3069,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2931,7 +3090,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2953,5 +3112,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 4b4f13611..7485b9ba5 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -956,7 +983,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1147,6 +1174,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" @@ -1277,7 +1310,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1311,15 +1344,32 @@ 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", "serde", ] +[[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" @@ -1329,6 +1379,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" @@ -1508,6 +1567,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" @@ -1592,9 +1660,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1701,6 +1769,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1843,12 +1931,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1858,7 +1959,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1903,9 +2016,9 @@ dependencies = [ [[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", ] @@ -1942,13 +2055,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1959,16 +2072,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1982,13 +2096,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2032,6 +2169,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 = "slice-group-by" version = "0.3.1" @@ -2062,7 +2205,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2078,7 +2221,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", "snafu", ] @@ -2095,6 +2238,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2114,7 +2263,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2123,6 +2272,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" @@ -2136,9 +2295,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2153,7 +2312,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2208,7 +2367,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2275,7 +2434,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2288,7 +2447,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2314,7 +2473,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2413,7 +2572,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2435,7 +2594,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2552,8 +2711,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2643,7 +2802,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", ] @@ -2890,7 +3049,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2911,7 +3070,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2931,7 +3090,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2952,7 +3111,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2974,5 +3133,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index bfe6a8ac6..e222dcbb9 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "rayon", "zeroize", @@ -94,7 +94,7 @@ dependencies = [ "ark-std", "derivative", "digest", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -384,7 +384,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -392,7 +392,8 @@ name = "cosmwasm-schema" version = "2.1.3" dependencies = [ "cosmwasm-schema-derive", - "schemars", + "cw-schema", + "schemars 0.8.21", "serde", "serde_json", "thiserror", @@ -404,7 +405,7 @@ version = "2.1.3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -417,11 +418,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", @@ -443,7 +445,7 @@ dependencies = [ "derivative", "hex", "rand_core", - "schemars", + "schemars 0.8.21", "serde", "serde_json", "sha2", @@ -635,7 +637,31 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", +] + +[[package]] +name = "cw-schema" +version = "2.1.3" +dependencies = [ + "cw-schema-derive", + "indexmap 2.4.0", + "schemars 1.0.0-alpha.11", + "serde", + "serde_with", + "siphasher", +] + +[[package]] +name = "cw-schema-derive" +version = "2.1.3" +dependencies = [ + "heck", + "itertools 0.13.0", + "owo-colors", + "proc-macro2", + "quote", + "syn 2.0.76", ] [[package]] @@ -668,7 +694,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn 1.0.109", ] @@ -682,7 +708,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.66", + "strsim 0.11.1", + "syn 2.0.76", ] [[package]] @@ -704,7 +731,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -789,7 +816,7 @@ checksum = "2bba3e9872d7c58ce7ef0fcf1844fcc3e23ef2a58377b50df35dd98e42a5726e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "unicode-xid", ] @@ -813,7 +840,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -956,7 +983,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1147,6 +1174,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" @@ -1277,7 +1310,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1311,15 +1344,32 @@ 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", "serde", ] +[[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" @@ -1329,6 +1379,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" @@ -1508,6 +1567,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" @@ -1592,9 +1660,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1701,6 +1769,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.76", +] + [[package]] name = "regalloc2" version = "0.5.1" @@ -1843,12 +1931,25 @@ 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", "url", ] +[[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", +] + [[package]] name = "schemars_derive" version = "0.8.21" @@ -1858,7 +1959,19 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.66", + "syn 2.0.76", +] + +[[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.76", ] [[package]] @@ -1903,9 +2016,9 @@ dependencies = [ [[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", ] @@ -1942,13 +2055,13 @@ 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", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -1959,16 +2072,17 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[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", ] @@ -1982,13 +2096,36 @@ dependencies = [ "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 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.76", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -2032,6 +2169,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 = "slice-group-by" version = "0.3.1" @@ -2062,6 +2205,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[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" @@ -2081,7 +2230,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2090,6 +2239,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" @@ -2103,9 +2262,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -2120,7 +2279,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2175,7 +2334,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2242,7 +2401,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2255,7 +2414,7 @@ version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -2281,7 +2440,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2360,7 +2519,7 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-vm", - "schemars", + "schemars 0.8.21", "serde", "thiserror", ] @@ -2392,7 +2551,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -2414,7 +2573,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2531,8 +2690,8 @@ dependencies = [ "bytesize", "derive_builder", "hex", - "indexmap 2.2.6", - "schemars", + "indexmap 2.4.0", + "schemars 0.8.21", "semver", "serde", "serde_cbor", @@ -2622,7 +2781,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", ] @@ -2869,7 +3028,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2890,7 +3049,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2910,7 +3069,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", "synstructure", ] @@ -2931,7 +3090,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] [[package]] @@ -2953,5 +3112,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.76", ] From 125901710212955f3ac763c1952cac100f746daa Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 26 Aug 2024 14:38:26 +0200 Subject: [PATCH 11/60] Fix doctests --- packages/schema/src/query_response.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/schema/src/query_response.rs b/packages/schema/src/query_response.rs index c05c24129..fac902a35 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, /// # } From 59deef9e0d6f77f02d27d1202bc736e84759332b Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 26 Aug 2024 14:45:32 +0200 Subject: [PATCH 12/60] Add missing derives --- packages/std/src/ibc/callbacks.rs | 28 +++++++++++++++++++++------- packages/std/src/query/ibc.rs | 4 +++- packages/std/src/query/mod.rs | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/std/src/ibc/callbacks.rs b/packages/std/src/ibc/callbacks.rs index 56ab5f411..468d3ae3a 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/query/ibc.rs b/packages/std/src/query/ibc.rs index 363bf007e..72e027c8c 100644 --- a/packages/std/src/query/ibc.rs +++ b/packages/std/src/query/ibc.rs @@ -73,7 +73,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 f215385fe..e188aeddf 100644 --- a/packages/std/src/query/mod.rs +++ b/packages/std/src/query/mod.rs @@ -108,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 {}, From 244cea9a274d8d9af61b9e01ddab83ba6bf38c67 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 27 Aug 2024 11:58:52 +0200 Subject: [PATCH 13/60] Use `TypeId` internally --- packages/cw-schema/src/lib.rs | 17 ++++------------- .../snapshots/basic__snapshot_jsonschema.snap | 12 ++++++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index 81c3945f5..4fac246bd 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -145,23 +145,14 @@ pub enum Schema { } #[derive(Hash, PartialEq, Eq)] -pub struct Identifier(&'static str); +pub struct Identifier(core::any::TypeId); impl Identifier { pub fn of() -> Self where - T: ?Sized, + T: ?Sized + 'static, { - Self(core::any::type_name::()) - } -} - -impl Serialize for Identifier { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - self.0.serialize(serializer) + Self(core::any::TypeId::of::()) } } @@ -191,7 +182,7 @@ impl SchemaVisitor { } } -pub trait Schemaifier { +pub trait Schemaifier: 'static { #[doc(hidden)] fn id() -> Identifier { Identifier::of::() diff --git a/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap b/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap index 8bea1145b..1a89b800d 100644 --- a/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap +++ b/packages/cw-schema/tests/snapshots/basic__snapshot_jsonschema.snap @@ -392,6 +392,18 @@ expression: schema "type", "inner" ] + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "unit" + } + }, + "required": [ + "type" + ] } ], "required": [ From b960a0d7bef1a43694ce42004800a2f0dde296ef Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 27 Aug 2024 15:18:28 +0200 Subject: [PATCH 14/60] Allow non-static types to implement the schema --- packages/cw-schema/src/default_impls.rs | 22 +++++++++++++++++++ packages/cw-schema/src/lib.rs | 14 ++++++++---- packages/cw-schema/tests/non_static.rs | 8 +++++++ packages/schema-derive/src/query_responses.rs | 14 +++++------- 4 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 packages/cw-schema/tests/non_static.rs diff --git a/packages/cw-schema/src/default_impls.rs b/packages/cw-schema/src/default_impls.rs index 1f7066312..b6436955f 100644 --- a/packages/cw-schema/src/default_impls.rs +++ b/packages/cw-schema/src/default_impls.rs @@ -14,6 +14,19 @@ impl Schemaifier for () { } } +impl Schemaifier for str { + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + visitor.insert( + Self::id(), + Node { + name: Cow::Borrowed("str"), + description: None, + value: NodeType::String, + }, + ) + } +} + impl Schemaifier for String { fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { visitor.insert( @@ -163,3 +176,12 @@ where visitor.insert(Self::id(), node) } } + +impl Schemaifier for &T +where + T: Schemaifier + ?Sized, +{ + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + T::visit_schema(visitor) + } +} diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index 4fac246bd..6fb5ea679 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -145,14 +145,20 @@ pub enum Schema { } #[derive(Hash, PartialEq, Eq)] -pub struct Identifier(core::any::TypeId); +pub struct Identifier(usize); impl Identifier { pub fn of() -> Self where - T: ?Sized + 'static, + T: ?Sized, { - Self(core::any::TypeId::of::()) + // Don't do this at home. I'm a professional. + #[inline] + fn type_id_of() -> usize { + type_id_of:: as usize + } + + Self(type_id_of::()) } } @@ -182,7 +188,7 @@ impl SchemaVisitor { } } -pub trait Schemaifier: 'static { +pub trait Schemaifier { #[doc(hidden)] fn id() -> Identifier { Identifier::of::() diff --git a/packages/cw-schema/tests/non_static.rs b/packages/cw-schema/tests/non_static.rs new file mode 100644 index 000000000..02903ba85 --- /dev/null +++ b/packages/cw-schema/tests/non_static.rs @@ -0,0 +1,8 @@ +#![allow(dead_code)] + +use cw_schema::Schemaifier; + +#[derive(Schemaifier)] +struct NonStatic<'a> { + test: &'a str, +} diff --git a/packages/schema-derive/src/query_responses.rs b/packages/schema-derive/src/query_responses.rs index 1c2fd1c3f..488c1ea8a 100644 --- a/packages/schema-derive/src/query_responses.rs +++ b/packages/schema-derive/src/query_responses.rs @@ -21,12 +21,12 @@ pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { let subquery_calls = input .variants .iter() - .map(|variant| parse_subquery(&ctx, variant.clone(), SchemaBackend::JsonSchema)) + .map(|variant| parse_subquery(&ctx, variant, SchemaBackend::JsonSchema)) .collect::>>()?; let subquery_calls_cw = input .variants - .into_iter() + .iter() .map(|variant| parse_subquery(&ctx, variant, SchemaBackend::CwSchema)) .collect::>>()?; @@ -67,8 +67,6 @@ pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { .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 @@ -77,8 +75,6 @@ pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { .map(|variant| parse_query(&ctx, variant, SchemaBackend::CwSchema)) .collect::>>()?; - let mut cw_queries: Vec<_> = cw_mappings.clone().into_iter().map(|(q, _)| q).collect(); - cw_queries.sort(); let cw_mappings = cw_mappings.into_iter().map(parse_tuple); // Handle generics if the type has any @@ -159,16 +155,16 @@ fn parse_query( } /// Extract the nested query -> response mapping out of an enum variant. -fn parse_subquery(ctx: &Context, v: Variant, schema_backend: SchemaBackend) -> 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"), }; From 34e87ce45a82b077acf5a7663cf148338490c31d Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 27 Aug 2024 15:22:31 +0200 Subject: [PATCH 15/60] Add test for same name in different modules --- packages/cw-schema/src/default_impls.rs | 2 +- packages/cw-schema/tests/same_name.rs | 25 ++++++++++ ...handle_same_name_in_different_modules.snap | 50 +++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 packages/cw-schema/tests/same_name.rs create mode 100644 packages/cw-schema/tests/snapshots/same_name__can_handle_same_name_in_different_modules.snap diff --git a/packages/cw-schema/src/default_impls.rs b/packages/cw-schema/src/default_impls.rs index b6436955f..d0ded0962 100644 --- a/packages/cw-schema/src/default_impls.rs +++ b/packages/cw-schema/src/default_impls.rs @@ -59,7 +59,7 @@ macro_rules! impl_integer { }; } -impl_integer!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128); +impl_integer!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, usize, isize); impl Schemaifier for f32 { fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { diff --git a/packages/cw-schema/tests/same_name.rs b/packages/cw-schema/tests/same_name.rs new file mode 100644 index 000000000..626829023 --- /dev/null +++ b/packages/cw-schema/tests/same_name.rs @@ -0,0 +1,25 @@ +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/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 000000000..1a8ecbac7 --- /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 + } + } + } + ] +} From 1101aa8100d05e007f91b6bb07a198730d0bd2f8 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 27 Aug 2024 15:29:55 +0200 Subject: [PATCH 16/60] Add some debug assertions --- packages/cw-schema/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index 6fb5ea679..c1279807f 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -158,6 +158,9 @@ impl Identifier { type_id_of:: as usize } + debug_assert_eq!(type_id_of::(), type_id_of::()); + debug_assert_eq!(core::any::type_name::(), core::any::type_name::()); + Self(type_id_of::()) } } From 9a4bebe39c754544bf644122d5bbbeb5a9141db6 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 27 Aug 2024 15:59:22 +0200 Subject: [PATCH 17/60] Add non-static lifetime snapshot test --- packages/cw-schema/src/default_impls.rs | 16 +++++++++- packages/cw-schema/tests/non_static.rs | 12 ++++++- packages/cw-schema/tests/same_name.rs | 2 ++ .../non_static__non_static_schema.snap | 32 +++++++++++++++++++ 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 packages/cw-schema/tests/snapshots/non_static__non_static_schema.snap diff --git a/packages/cw-schema/src/default_impls.rs b/packages/cw-schema/src/default_impls.rs index d0ded0962..298b80c1b 100644 --- a/packages/cw-schema/src/default_impls.rs +++ b/packages/cw-schema/src/default_impls.rs @@ -1,5 +1,10 @@ use crate::{Node, NodeType, Schemaifier}; -use alloc::{borrow::Cow, string::String, vec, vec::Vec}; +use alloc::{ + borrow::{Cow, ToOwned}, + string::String, + vec, + vec::Vec, +}; impl Schemaifier for () { fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { @@ -185,3 +190,12 @@ where T::visit_schema(visitor) } } + +impl Schemaifier for Cow<'_, T> +where + T: Schemaifier + ToOwned + ?Sized, +{ + fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { + T::visit_schema(visitor) + } +} diff --git a/packages/cw-schema/tests/non_static.rs b/packages/cw-schema/tests/non_static.rs index 02903ba85..da31724b5 100644 --- a/packages/cw-schema/tests/non_static.rs +++ b/packages/cw-schema/tests/non_static.rs @@ -1,8 +1,18 @@ #![allow(dead_code)] use cw_schema::Schemaifier; +use std::borrow::Cow; #[derive(Schemaifier)] struct NonStatic<'a> { - test: &'a str, + 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 index 626829023..3d47b0f04 100644 --- a/packages/cw-schema/tests/same_name.rs +++ b/packages/cw-schema/tests/same_name.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + mod module1 { #[derive(cw_schema::Schemaifier)] pub struct Test { 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 000000000..b320f3828 --- /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 + } + } + } + ] +} From 4fbc80b7b25205f3e0e8d8ab7d6723bb84c5b7da Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 27 Aug 2024 16:02:31 +0200 Subject: [PATCH 18/60] Add explanation of the hack --- packages/cw-schema/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index c1279807f..565e001a6 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -153,13 +153,17 @@ impl Identifier { T: ?Sized, { // Don't do this at home. I'm a professional. + // + // This is a hack based on the assumption that each type has will produce a unique monomorphized function. + // Therefore each function has a distinct function pointer. + // + // The compiler _might_ break this assumption in the future. #[inline] fn type_id_of() -> usize { type_id_of:: as usize } debug_assert_eq!(type_id_of::(), type_id_of::()); - debug_assert_eq!(core::any::type_name::(), core::any::type_name::()); Self(type_id_of::()) } From 8b209cfe11ddfa2cc5907170851dfe41660b6780 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 2 Sep 2024 12:40:50 +0200 Subject: [PATCH 19/60] Add impl to write new schema format --- packages/cw-schema/src/lib.rs | 2 +- packages/schema-derive/src/generate_api.rs | 294 +++++++++++------- packages/schema-derive/src/lib.rs | 20 +- packages/schema-derive/src/query_responses.rs | 6 +- packages/schema/src/idl.rs | 99 ++++++ packages/schema/src/lib.rs | 2 +- 6 files changed, 308 insertions(+), 115 deletions(-) diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index 565e001a6..9280abfb3 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -204,7 +204,7 @@ pub trait Schemaifier { fn visit_schema(visitor: &mut SchemaVisitor) -> DefinitionReference; } -pub fn schema_of() -> Schema { +pub fn schema_of() -> Schema { let mut visitor = SchemaVisitor::default(); Schema::V1(SchemaV1 { root: T::visit_schema(&mut visitor), diff --git a/packages/schema-derive/src/generate_api.rs b/packages/schema-derive/src/generate_api.rs index 49b1b3e01..175dfe6ba 100644 --- a/packages/schema-derive/src/generate_api.rs +++ b/packages/schema-derive/src/generate_api.rs @@ -1,5 +1,6 @@ use std::collections::BTreeMap; +use super::SchemaBackend; use crate::error::bail; use proc_macro2::TokenStream; use quote::quote; @@ -8,11 +9,37 @@ use syn::{ parse_quote, Block, ExprStruct, Ident, Token, }; +fn generate_api_write(api_object: syn::ExprStruct, name: &TokenStream) -> 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,74 @@ impl Parse for Pair { } } +macro_rules! option_dispatch { + ($opt:expr, $closure:expr) => {{ + match $opt { + Some(ref ty) => { + 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 +220,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 +247,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 +284,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 +304,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 +333,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 +352,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 +376,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 +402,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 5159d75b8..187a67cac 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 488c1ea8a..d117cb345 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, @@ -7,11 +8,6 @@ use syn::{ use self::context::Context; -enum SchemaBackend { - CwSchema, - JsonSchema, -} - pub fn query_responses_derive_impl(input: ItemEnum) -> syn::Result { let ctx = context::get_context(&input)?; diff --git a/packages/schema/src/idl.rs b/packages/schema/src/idl.rs index dc47b239e..9f838fbcf 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::Serialize)] +pub struct JsonCwApi { + contract_name: String, + contract_version: String, + idl_version: String, + instantiate: Option, + execute: Option, + query: Option, + migrate: Option, + sudo: Option, + 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 106e4e071..9b5381d08 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; From 275784b1b236d0da2d19dbd9d9333ab7d9e05f2b Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 2 Sep 2024 12:47:16 +0200 Subject: [PATCH 20/60] Regenerate all schemas --- contracts/burner/schema/cw_schema/burner.json | 51 + .../schema/cw_schema/raw/instantiate.json | 12 + .../burner/schema/cw_schema/raw/migrate.json | 30 + .../schema/cw_schema/crypto-verify.json | 468 ++++++ .../schema/cw_schema/raw/instantiate.json | 11 + .../schema/cw_schema/raw/query.json | 252 +++ ...response_to_list_verification_schemes.json | 24 + ...e_to_verify_bls12_pairing_equality_g1.json | 19 + ...e_to_verify_bls12_pairing_equality_g2.json | 19 + .../response_to_verify_cosmos_signature.json | 19 + .../raw/response_to_verify_ethereum_text.json | 19 + ...sponse_to_verify_ethereum_transaction.json | 19 + ...sponse_to_verify_secp256_r1_signature.json | 19 + .../response_to_verify_tendermint_batch.json | 19 + ...sponse_to_verify_tendermint_signature.json | 19 + .../raw/response_to_verify_webauthn.json | 19 + .../cyberpunk/schema/cw_schema/cyberpunk.json | 382 +++++ .../schema/cw_schema/raw/execute.json | 86 + .../schema/cw_schema/raw/instantiate.json | 12 + .../cyberpunk/schema/cw_schema/raw/query.json | 35 + .../cw_schema/raw/response_to_denom.json | 73 + .../cw_schema/raw/response_to_denoms.json | 78 + .../cw_schema/raw/response_to_mirror_env.json | 89 ++ contracts/empty/schema/cw_schema/empty.json | 11 + contracts/floaty/schema/cw_schema/floaty.json | 230 +++ .../schema/cw_schema/raw/instantiate.json | 12 + .../floaty/schema/cw_schema/raw/query.json | 92 ++ .../raw/response_to_instructions.json | 15 + .../raw/response_to_random_args_for.json | 53 + .../schema/cw_schema/raw/response_to_run.json | 48 + .../hackatom/schema/cw_schema/hackatom.json | 321 ++++ .../schema/cw_schema/raw/execute.json | 62 + .../schema/cw_schema/raw/instantiate.json | 22 + .../schema/cw_schema/raw/migrate.json | 20 + .../hackatom/schema/cw_schema/raw/query.json | 53 + .../cw_schema/raw/response_to_get_int.json | 21 + .../raw/response_to_other_balance.json | 44 + .../cw_schema/raw/response_to_recurse.json | 21 + .../cw_schema/raw/response_to_verifier.json | 19 + .../hackatom/schema/cw_schema/raw/sudo.json | 52 + .../schema/cw_schema/ibc-callbacks.json | 285 ++++ .../schema/cw_schema/raw/execute.json | 61 + .../schema/cw_schema/raw/instantiate.json | 12 + .../schema/cw_schema/raw/query.json | 17 + .../raw/response_to_callback_stats.json | 186 +++ .../schema/cw_schema/ibc-reflect-send.json | 707 ++++++++ .../schema/cw_schema/raw/execute.json | 493 ++++++ .../schema/cw_schema/raw/instantiate.json | 12 + .../schema/cw_schema/raw/query.json | 32 + .../cw_schema/raw/response_to_account.json | 64 + .../cw_schema/raw/response_to_admin.json | 19 + .../raw/response_to_list_accounts.json | 78 + .../schema/cw_schema/ibc-reflect.json | 186 +++ .../schema/cw_schema/raw/execute.json | 54 + .../schema/cw_schema/raw/instantiate.json | 22 + .../schema/cw_schema/raw/migrate.json | 12 + .../schema/cw_schema/raw/query.json | 30 + .../cw_schema/raw/response_to_account.json | 24 + .../raw/response_to_list_accounts.json | 36 + contracts/queue/schema/cw_schema/queue.json | 226 +++ .../queue/schema/cw_schema/raw/execute.json | 30 + .../schema/cw_schema/raw/instantiate.json | 11 + .../queue/schema/cw_schema/raw/migrate.json | 11 + .../queue/schema/cw_schema/raw/query.json | 43 + .../cw_schema/raw/response_to_count.json | 21 + .../cw_schema/raw/response_to_list.json | 35 + .../raw/response_to_open_iterators.json | 12 + .../cw_schema/raw/response_to_reducer.json | 34 + .../schema/cw_schema/raw/response_to_sum.json | 21 + .../reflect/schema/cw_schema/raw/execute.json | 731 +++++++++ .../schema/cw_schema/raw/instantiate.json | 11 + .../reflect/schema/cw_schema/raw/query.json | 448 ++++++ .../raw/response_to_capitalized.json | 19 + .../cw_schema/raw/response_to_chain.json | 20 + .../cw_schema/raw/response_to_owner.json | 19 + .../schema/cw_schema/raw/response_to_raw.json | 21 + .../raw/response_to_sub_msg_result.json | 140 ++ .../reflect/schema/cw_schema/reflect.json | 1418 +++++++++++++++++ .../staking/schema/cw_schema/raw/execute.json | 64 + .../schema/cw_schema/raw/instantiate.json | 60 + .../staking/schema/cw_schema/raw/query.json | 44 + .../cw_schema/raw/response_to_balance.json | 22 + .../cw_schema/raw/response_to_claims.json | 22 + .../cw_schema/raw/response_to_investment.json | 67 + .../cw_schema/raw/response_to_token_info.json | 35 + .../staking/schema/cw_schema/staking.json | 323 ++++ .../virus/schema/cw_schema/raw/execute.json | 35 + .../schema/cw_schema/raw/instantiate.json | 11 + contracts/virus/schema/cw_schema/virus.json | 55 + devtools/generate_schemas.sh | 10 + 90 files changed, 9219 insertions(+) create mode 100644 contracts/burner/schema/cw_schema/burner.json create mode 100644 contracts/burner/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/burner/schema/cw_schema/raw/migrate.json create mode 100644 contracts/crypto-verify/schema/cw_schema/crypto-verify.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/query.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_list_verification_schemes.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_bls12_pairing_equality_g1.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_bls12_pairing_equality_g2.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_cosmos_signature.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_ethereum_text.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_ethereum_transaction.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_secp256_r1_signature.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_tendermint_batch.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_tendermint_signature.json create mode 100644 contracts/crypto-verify/schema/cw_schema/raw/response_to_verify_webauthn.json create mode 100644 contracts/cyberpunk/schema/cw_schema/cyberpunk.json create mode 100644 contracts/cyberpunk/schema/cw_schema/raw/execute.json create mode 100644 contracts/cyberpunk/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/cyberpunk/schema/cw_schema/raw/query.json create mode 100644 contracts/cyberpunk/schema/cw_schema/raw/response_to_denom.json create mode 100644 contracts/cyberpunk/schema/cw_schema/raw/response_to_denoms.json create mode 100644 contracts/cyberpunk/schema/cw_schema/raw/response_to_mirror_env.json create mode 100644 contracts/empty/schema/cw_schema/empty.json create mode 100644 contracts/floaty/schema/cw_schema/floaty.json create mode 100644 contracts/floaty/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/floaty/schema/cw_schema/raw/query.json create mode 100644 contracts/floaty/schema/cw_schema/raw/response_to_instructions.json create mode 100644 contracts/floaty/schema/cw_schema/raw/response_to_random_args_for.json create mode 100644 contracts/floaty/schema/cw_schema/raw/response_to_run.json create mode 100644 contracts/hackatom/schema/cw_schema/hackatom.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/execute.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/migrate.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/query.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/response_to_get_int.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/response_to_other_balance.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/response_to_recurse.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/response_to_verifier.json create mode 100644 contracts/hackatom/schema/cw_schema/raw/sudo.json create mode 100644 contracts/ibc-callbacks/schema/cw_schema/ibc-callbacks.json create mode 100644 contracts/ibc-callbacks/schema/cw_schema/raw/execute.json create mode 100644 contracts/ibc-callbacks/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/ibc-callbacks/schema/cw_schema/raw/query.json create mode 100644 contracts/ibc-callbacks/schema/cw_schema/raw/response_to_callback_stats.json create mode 100644 contracts/ibc-reflect-send/schema/cw_schema/ibc-reflect-send.json create mode 100644 contracts/ibc-reflect-send/schema/cw_schema/raw/execute.json create mode 100644 contracts/ibc-reflect-send/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/ibc-reflect-send/schema/cw_schema/raw/query.json create mode 100644 contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_account.json create mode 100644 contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_admin.json create mode 100644 contracts/ibc-reflect-send/schema/cw_schema/raw/response_to_list_accounts.json create mode 100644 contracts/ibc-reflect/schema/cw_schema/ibc-reflect.json create mode 100644 contracts/ibc-reflect/schema/cw_schema/raw/execute.json create mode 100644 contracts/ibc-reflect/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/ibc-reflect/schema/cw_schema/raw/migrate.json create mode 100644 contracts/ibc-reflect/schema/cw_schema/raw/query.json create mode 100644 contracts/ibc-reflect/schema/cw_schema/raw/response_to_account.json create mode 100644 contracts/ibc-reflect/schema/cw_schema/raw/response_to_list_accounts.json create mode 100644 contracts/queue/schema/cw_schema/queue.json create mode 100644 contracts/queue/schema/cw_schema/raw/execute.json create mode 100644 contracts/queue/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/queue/schema/cw_schema/raw/migrate.json create mode 100644 contracts/queue/schema/cw_schema/raw/query.json create mode 100644 contracts/queue/schema/cw_schema/raw/response_to_count.json create mode 100644 contracts/queue/schema/cw_schema/raw/response_to_list.json create mode 100644 contracts/queue/schema/cw_schema/raw/response_to_open_iterators.json create mode 100644 contracts/queue/schema/cw_schema/raw/response_to_reducer.json create mode 100644 contracts/queue/schema/cw_schema/raw/response_to_sum.json create mode 100644 contracts/reflect/schema/cw_schema/raw/execute.json create mode 100644 contracts/reflect/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/reflect/schema/cw_schema/raw/query.json create mode 100644 contracts/reflect/schema/cw_schema/raw/response_to_capitalized.json create mode 100644 contracts/reflect/schema/cw_schema/raw/response_to_chain.json create mode 100644 contracts/reflect/schema/cw_schema/raw/response_to_owner.json create mode 100644 contracts/reflect/schema/cw_schema/raw/response_to_raw.json create mode 100644 contracts/reflect/schema/cw_schema/raw/response_to_sub_msg_result.json create mode 100644 contracts/reflect/schema/cw_schema/reflect.json create mode 100644 contracts/staking/schema/cw_schema/raw/execute.json create mode 100644 contracts/staking/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/staking/schema/cw_schema/raw/query.json create mode 100644 contracts/staking/schema/cw_schema/raw/response_to_balance.json create mode 100644 contracts/staking/schema/cw_schema/raw/response_to_claims.json create mode 100644 contracts/staking/schema/cw_schema/raw/response_to_investment.json create mode 100644 contracts/staking/schema/cw_schema/raw/response_to_token_info.json create mode 100644 contracts/staking/schema/cw_schema/staking.json create mode 100644 contracts/virus/schema/cw_schema/raw/execute.json create mode 100644 contracts/virus/schema/cw_schema/raw/instantiate.json create mode 100644 contracts/virus/schema/cw_schema/virus.json create mode 100755 devtools/generate_schemas.sh diff --git a/contracts/burner/schema/cw_schema/burner.json b/contracts/burner/schema/cw_schema/burner.json new file mode 100644 index 000000000..9908bd3d6 --- /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 000000000..3b9e7c218 --- /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 000000000..279c70846 --- /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/schema/cw_schema/crypto-verify.json b/contracts/crypto-verify/schema/cw_schema/crypto-verify.json new file mode 100644 index 000000000..5600c53df --- /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 000000000..9fc37502e --- /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 000000000..4d73d46c3 --- /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 000000000..c9258f8af --- /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 000000000..fe49acd15 --- /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 000000000..fe49acd15 --- /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 000000000..fe49acd15 --- /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 000000000..fe49acd15 --- /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 000000000..fe49acd15 --- /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 000000000..fe49acd15 --- /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 000000000..fe49acd15 --- /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 000000000..fe49acd15 --- /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 000000000..fe49acd15 --- /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/schema/cw_schema/cyberpunk.json b/contracts/cyberpunk/schema/cw_schema/cyberpunk.json new file mode 100644 index 000000000..d5968b08d --- /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 expressable 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 indentifier 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 000000000..fad79cda5 --- /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 000000000..f0fcc334c --- /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 expressable 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 000000000..b15ea6a34 --- /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 000000000..8b45ec4a7 --- /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 000000000..7fe51a29c --- /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 000000000..0a1758573 --- /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 indentifier 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/schema/cw_schema/empty.json b/contracts/empty/schema/cw_schema/empty.json new file mode 100644 index 000000000..58d5e48c1 --- /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/schema/cw_schema/floaty.json b/contracts/floaty/schema/cw_schema/floaty.json new file mode 100644 index 000000000..e746ec0a6 --- /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 expressable 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 000000000..f0fcc334c --- /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 expressable 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 000000000..4831e8ed7 --- /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 000000000..ba9dbee3d --- /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 000000000..8f8ae6b3e --- /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 000000000..9c1622563 --- /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/schema/cw_schema/hackatom.json b/contracts/hackatom/schema/cw_schema/hackatom.json new file mode 100644 index 000000000..b42657aef --- /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 000000000..743a9c485 --- /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 000000000..d1d688c14 --- /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 000000000..b3bc287ac --- /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 000000000..5d61892dd --- /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 000000000..db7f166d6 --- /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 000000000..05dd5b3c1 --- /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 000000000..c524ecf67 --- /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 000000000..10f33f2e8 --- /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 000000000..b82282138 --- /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/schema/cw_schema/ibc-callbacks.json b/contracts/ibc-callbacks/schema/cw_schema/ibc-callbacks.json new file mode 100644 index 000000000..acc12977d --- /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 expressable 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 000000000..108630e71 --- /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 000000000..f0fcc334c --- /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 expressable 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 000000000..ca7367066 --- /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 000000000..bb57c3a81 --- /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/schema/cw_schema/ibc-reflect-send.json b/contracts/ibc-reflect-send/schema/cw_schema/ibc-reflect-send.json new file mode 100644 index 000000000..a5b702a47 --- /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 expressable 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 000000000..f14e253e7 --- /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 expressable 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 000000000..96978ebf2 --- /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 000000000..a0e19f323 --- /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 000000000..6ec05f3cd --- /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 000000000..4f151112d --- /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 000000000..d5cbb4a66 --- /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/schema/cw_schema/ibc-reflect.json b/contracts/ibc-reflect/schema/cw_schema/ibc-reflect.json new file mode 100644 index 000000000..1543148ef --- /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 expressable 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 000000000..ad07d2b97 --- /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 000000000..61787c384 --- /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 000000000..f0fcc334c --- /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 expressable 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 000000000..3721b3260 --- /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 000000000..f768e471f --- /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 000000000..5eaed341f --- /dev/null +++ b/contracts/ibc-reflect/schema/cw_schema/raw/response_to_list_accounts.json @@ -0,0 +1,36 @@ +{ + "type": "v1", + "root": 3, + "definitions": [ + { + "name": "String", + "type": "string" + }, + { + "name": "AccountInfo", + "type": "struct", + "properties": { + "account": { + "value": 0 + }, + "channel_id": { + "value": 0 + } + } + }, + { + "name": "alloc::vec::Vec", + "type": "array", + "items": 1 + }, + { + "name": "ListAccountsResponse", + "type": "struct", + "properties": { + "accounts": { + "value": 2 + } + } + } + ] +} diff --git a/contracts/queue/schema/cw_schema/queue.json b/contracts/queue/schema/cw_schema/queue.json new file mode 100644 index 000000000..cbd13fcca --- /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 expressable 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 000000000..3ec08d4bd --- /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 000000000..9fc37502e --- /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 000000000..8e750fe84 --- /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 000000000..deb71025a --- /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 000000000..a1b3d6f80 --- /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 000000000..410dd4787 --- /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 000000000..f0fcc334c --- /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 expressable 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 000000000..2cddf6d4c --- /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 000000000..645e15e15 --- /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/schema/cw_schema/raw/execute.json b/contracts/reflect/schema/cw_schema/raw/execute.json new file mode 100644 index 000000000..3d2e2ef50 --- /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 suppored 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 arbirary 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 000000000..9fc37502e --- /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 000000000..51f19f048 --- /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 000000000..f64eb6131 --- /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 000000000..200298854 --- /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 000000000..3d65874a9 --- /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 000000000..604939fa4 --- /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 000000000..c4a522450 --- /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 documenation 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(\"fo\", \"ba\")],\nmsg_responses: vec![],\n};\nlet result: SubMsgResult = SubMsgResult::Ok(response);\nassert_eq!(\nto_json_string(&result).unwrap(),\nr#\"{\"ok\":{\"events\":[{\"type\":\"wasm\",\"attributes\":[{\"key\":\"fo\",\"value\":\"ba\"}]}],\"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 potientially 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 arbirary 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 000000000..def09fdfb --- /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 suppored 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 arbirary 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 documenation 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(\"fo\", \"ba\")],\nmsg_responses: vec![],\n};\nlet result: SubMsgResult = SubMsgResult::Ok(response);\nassert_eq!(\nto_json_string(&result).unwrap(),\nr#\"{\"ok\":{\"events\":[{\"type\":\"wasm\",\"attributes\":[{\"key\":\"fo\",\"value\":\"ba\"}]}],\"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 potientially 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 arbirary data that the contract set when emitting the `SubMsg`.\nThis is just passed into the `reply` entry point and is not stored to state.\n\nUnset/nil/null cannot be differentiated from empty data.\n\nOn chains running CosmWasm 1.x this field is never filled.", + "value": 1 + }, + "result": { + "value": 11 + } + } + } + ] + } + } +} diff --git a/contracts/staking/schema/cw_schema/raw/execute.json b/contracts/staking/schema/cw_schema/raw/execute.json new file mode 100644 index 000000000..dbaa0513d --- /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 000000000..65e27db13 --- /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 minumum\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 000000000..094dbd1f1 --- /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 000000000..0c3400936 --- /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 000000000..1dc799f0f --- /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 000000000..cc2591b2e --- /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 minumum\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 000000000..a37b8edf8 --- /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 000000000..7337cfd3e --- /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 minumum\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 minumum\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/schema/cw_schema/raw/execute.json b/contracts/virus/schema/cw_schema/raw/execute.json new file mode 100644 index 000000000..08077a028 --- /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 000000000..9fc37502e --- /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 000000000..eca0408d0 --- /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 000000000..f5f8c083e --- /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 From b4b7b2ba0a961a4a391740bf49f2c54b3153b8a7 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 2 Sep 2024 12:58:06 +0200 Subject: [PATCH 21/60] Allow clippy lint --- packages/schema-derive/src/generate_api.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/schema-derive/src/generate_api.rs b/packages/schema-derive/src/generate_api.rs index 175dfe6ba..c2593538d 100644 --- a/packages/schema-derive/src/generate_api.rs +++ b/packages/schema-derive/src/generate_api.rs @@ -148,6 +148,7 @@ 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) } } From 286cabd50a85eaa6225c8ed2d35a12eb47cfe666 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 1 Oct 2024 14:31:38 +0200 Subject: [PATCH 22/60] Fix CI --- packages/cw-schema/Cargo.toml | 4 +++- packages/vm/src/environment.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cw-schema/Cargo.toml b/packages/cw-schema/Cargo.toml index 6fb523df2..02ef517dc 100644 --- a/packages/cw-schema/Cargo.toml +++ b/packages/cw-schema/Cargo.toml @@ -8,7 +8,9 @@ cw-schema-derive = { version = "=2.1.3", 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"] } +serde_with = { version = "3.9.0", default-features = false, features = [ + "macros", +] } siphasher = { version = "1.0.1", default-features = false } [dev-dependencies] diff --git a/packages/vm/src/environment.rs b/packages/vm/src/environment.rs index 696e5ff09..0da0d5c5c 100644 --- a/packages/vm/src/environment.rs +++ b/packages/vm/src/environment.rs @@ -167,7 +167,7 @@ pub struct DebugInfo<'a> { pub type DebugHandlerFn = dyn for<'a, 'b> FnMut(/* msg */ &'a str, DebugInfo<'b>); /// A environment that provides access to the ContextData. -/// The environment is clonable but clones access the same underlying data. +/// The environment is cloneable but clones access the same underlying data. pub struct Environment { pub memory: Option, pub api: A, From 1b337d61d24e04faf9e74e5e4c9c74b7203b644b Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 12:40:09 +0000 Subject: [PATCH 23/60] [autofix.ci] apply automated fixes --- contracts/cyberpunk/schema/cw_schema/cyberpunk.json | 4 ++-- .../cyberpunk/schema/cw_schema/raw/instantiate.json | 2 +- .../schema/cw_schema/raw/response_to_mirror_env.json | 2 +- contracts/floaty/schema/cw_schema/floaty.json | 2 +- contracts/floaty/schema/cw_schema/raw/instantiate.json | 2 +- .../ibc-callbacks/schema/cw_schema/ibc-callbacks.json | 2 +- .../schema/cw_schema/raw/instantiate.json | 2 +- .../schema/cw_schema/ibc-reflect-send.json | 2 +- .../ibc-reflect-send/schema/cw_schema/raw/execute.json | 2 +- .../ibc-reflect/schema/cw_schema/ibc-reflect.json | 2 +- .../ibc-reflect/schema/cw_schema/raw/migrate.json | 2 +- contracts/queue/schema/cw_schema/queue.json | 2 +- .../cw_schema/raw/response_to_open_iterators.json | 2 +- contracts/reflect/schema/cw_schema/raw/execute.json | 4 ++-- .../cw_schema/raw/response_to_sub_msg_result.json | 6 +++--- contracts/reflect/schema/cw_schema/reflect.json | 10 +++++----- .../staking/schema/cw_schema/raw/instantiate.json | 2 +- .../schema/cw_schema/raw/response_to_investment.json | 2 +- contracts/staking/schema/cw_schema/staking.json | 4 ++-- 19 files changed, 28 insertions(+), 28 deletions(-) diff --git a/contracts/cyberpunk/schema/cw_schema/cyberpunk.json b/contracts/cyberpunk/schema/cw_schema/cyberpunk.json index d5968b08d..2922a43fb 100644 --- a/contracts/cyberpunk/schema/cw_schema/cyberpunk.json +++ b/contracts/cyberpunk/schema/cw_schema/cyberpunk.json @@ -8,7 +8,7 @@ "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 expressable 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)", + "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": {} } @@ -336,7 +336,7 @@ "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 indentifier in this chain\nusing the pair (`env.block.height`, `env.transaction.index`).\n", + "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 } } diff --git a/contracts/cyberpunk/schema/cw_schema/raw/instantiate.json b/contracts/cyberpunk/schema/cw_schema/raw/instantiate.json index f0fcc334c..3935d14d4 100644 --- a/contracts/cyberpunk/schema/cw_schema/raw/instantiate.json +++ b/contracts/cyberpunk/schema/cw_schema/raw/instantiate.json @@ -4,7 +4,7 @@ "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 expressable 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)", + "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/response_to_mirror_env.json b/contracts/cyberpunk/schema/cw_schema/raw/response_to_mirror_env.json index 0a1758573..203c69068 100644 --- a/contracts/cyberpunk/schema/cw_schema/raw/response_to_mirror_env.json +++ b/contracts/cyberpunk/schema/cw_schema/raw/response_to_mirror_env.json @@ -45,7 +45,7 @@ "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 indentifier in this chain\nusing the pair (`env.block.height`, `env.transaction.index`).\n", + "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 } } diff --git a/contracts/floaty/schema/cw_schema/floaty.json b/contracts/floaty/schema/cw_schema/floaty.json index e746ec0a6..2741d1f86 100644 --- a/contracts/floaty/schema/cw_schema/floaty.json +++ b/contracts/floaty/schema/cw_schema/floaty.json @@ -8,7 +8,7 @@ "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 expressable 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)", + "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/instantiate.json b/contracts/floaty/schema/cw_schema/raw/instantiate.json index f0fcc334c..3935d14d4 100644 --- a/contracts/floaty/schema/cw_schema/raw/instantiate.json +++ b/contracts/floaty/schema/cw_schema/raw/instantiate.json @@ -4,7 +4,7 @@ "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 expressable 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)", + "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/ibc-callbacks.json b/contracts/ibc-callbacks/schema/cw_schema/ibc-callbacks.json index acc12977d..5025001bc 100644 --- a/contracts/ibc-callbacks/schema/cw_schema/ibc-callbacks.json +++ b/contracts/ibc-callbacks/schema/cw_schema/ibc-callbacks.json @@ -8,7 +8,7 @@ "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 expressable 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)", + "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/instantiate.json b/contracts/ibc-callbacks/schema/cw_schema/raw/instantiate.json index f0fcc334c..3935d14d4 100644 --- a/contracts/ibc-callbacks/schema/cw_schema/raw/instantiate.json +++ b/contracts/ibc-callbacks/schema/cw_schema/raw/instantiate.json @@ -4,7 +4,7 @@ "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 expressable 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)", + "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-send/schema/cw_schema/ibc-reflect-send.json b/contracts/ibc-reflect-send/schema/cw_schema/ibc-reflect-send.json index a5b702a47..ec7416ee3 100644 --- a/contracts/ibc-reflect-send/schema/cw_schema/ibc-reflect-send.json +++ b/contracts/ibc-reflect-send/schema/cw_schema/ibc-reflect-send.json @@ -76,7 +76,7 @@ }, { "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 expressable 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)", + "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-send/schema/cw_schema/raw/execute.json b/contracts/ibc-reflect-send/schema/cw_schema/raw/execute.json index f14e253e7..1083c1905 100644 --- a/contracts/ibc-reflect-send/schema/cw_schema/raw/execute.json +++ b/contracts/ibc-reflect-send/schema/cw_schema/raw/execute.json @@ -60,7 +60,7 @@ }, { "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 expressable 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)", + "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/ibc-reflect.json b/contracts/ibc-reflect/schema/cw_schema/ibc-reflect.json index 1543148ef..785c5a129 100644 --- a/contracts/ibc-reflect/schema/cw_schema/ibc-reflect.json +++ b/contracts/ibc-reflect/schema/cw_schema/ibc-reflect.json @@ -114,7 +114,7 @@ "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 expressable 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)", + "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/migrate.json b/contracts/ibc-reflect/schema/cw_schema/raw/migrate.json index f0fcc334c..3935d14d4 100644 --- a/contracts/ibc-reflect/schema/cw_schema/raw/migrate.json +++ b/contracts/ibc-reflect/schema/cw_schema/raw/migrate.json @@ -4,7 +4,7 @@ "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 expressable 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)", + "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/queue.json b/contracts/queue/schema/cw_schema/queue.json index cbd13fcca..103112473 100644 --- a/contracts/queue/schema/cw_schema/queue.json +++ b/contracts/queue/schema/cw_schema/queue.json @@ -161,7 +161,7 @@ "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 expressable 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)", + "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_open_iterators.json b/contracts/queue/schema/cw_schema/raw/response_to_open_iterators.json index f0fcc334c..3935d14d4 100644 --- a/contracts/queue/schema/cw_schema/raw/response_to_open_iterators.json +++ b/contracts/queue/schema/cw_schema/raw/response_to_open_iterators.json @@ -4,7 +4,7 @@ "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 expressable 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)", + "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/reflect/schema/cw_schema/raw/execute.json b/contracts/reflect/schema/cw_schema/raw/execute.json index 3d2e2ef50..ff31ffa3a 100644 --- a/contracts/reflect/schema/cw_schema/raw/execute.json +++ b/contracts/reflect/schema/cw_schema/raw/execute.json @@ -572,7 +572,7 @@ "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 suppored 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.", + "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 @@ -684,7 +684,7 @@ "value": 27 }, "payload": { - "description": "Some arbirary 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.", + "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": { 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 index c4a522450..2983f79ff 100644 --- 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 @@ -96,11 +96,11 @@ }, { "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 documenation 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(\"fo\", \"ba\")],\nmsg_responses: vec![],\n};\nlet result: SubMsgResult = SubMsgResult::Ok(response);\nassert_eq!(\nto_json_string(&result).unwrap(),\nr#\"{\"ok\":{\"events\":[{\"type\":\"wasm\",\"attributes\":[{\"key\":\"fo\",\"value\":\"ba\"}]}],\"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```", + "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 potientially have more structure, but String is the easiest.", + "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 @@ -128,7 +128,7 @@ "value": 0 }, "payload": { - "description": "Some arbirary 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.", + "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": { diff --git a/contracts/reflect/schema/cw_schema/reflect.json b/contracts/reflect/schema/cw_schema/reflect.json index def09fdfb..c592ebe03 100644 --- a/contracts/reflect/schema/cw_schema/reflect.json +++ b/contracts/reflect/schema/cw_schema/reflect.json @@ -587,7 +587,7 @@ "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 suppored 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.", + "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 @@ -699,7 +699,7 @@ "value": 27 }, "payload": { - "description": "Some arbirary 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.", + "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": { @@ -1372,11 +1372,11 @@ }, { "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 documenation 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(\"fo\", \"ba\")],\nmsg_responses: vec![],\n};\nlet result: SubMsgResult = SubMsgResult::Ok(response);\nassert_eq!(\nto_json_string(&result).unwrap(),\nr#\"{\"ok\":{\"events\":[{\"type\":\"wasm\",\"attributes\":[{\"key\":\"fo\",\"value\":\"ba\"}]}],\"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```", + "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 potientially have more structure, but String is the easiest.", + "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 @@ -1404,7 +1404,7 @@ "value": 0 }, "payload": { - "description": "Some arbirary 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.", + "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": { diff --git a/contracts/staking/schema/cw_schema/raw/instantiate.json b/contracts/staking/schema/cw_schema/raw/instantiate.json index 65e27db13..a6291334a 100644 --- a/contracts/staking/schema/cw_schema/raw/instantiate.json +++ b/contracts/staking/schema/cw_schema/raw/instantiate.json @@ -39,7 +39,7 @@ "value": 2 }, "min_withdrawal": { - "description": "This is the minimum amount we will pull out to reinvest, as well as a minumum\nthat can be unbonded (to avoid needless staking tx)", + "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": { diff --git a/contracts/staking/schema/cw_schema/raw/response_to_investment.json b/contracts/staking/schema/cw_schema/raw/response_to_investment.json index cc2591b2e..7b5dcf5b0 100644 --- a/contracts/staking/schema/cw_schema/raw/response_to_investment.json +++ b/contracts/staking/schema/cw_schema/raw/response_to_investment.json @@ -41,7 +41,7 @@ "value": 3 }, "min_withdrawal": { - "description": "This is the minimum amount we will pull out to reinvest, as well as a minumum\nthat can be unbonded (to avoid needless staking tx)", + "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": { diff --git a/contracts/staking/schema/cw_schema/staking.json b/contracts/staking/schema/cw_schema/staking.json index 7337cfd3e..8e7820608 100644 --- a/contracts/staking/schema/cw_schema/staking.json +++ b/contracts/staking/schema/cw_schema/staking.json @@ -43,7 +43,7 @@ "value": 2 }, "min_withdrawal": { - "description": "This is the minimum amount we will pull out to reinvest, as well as a minumum\nthat can be unbonded (to avoid needless staking tx)", + "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": { @@ -260,7 +260,7 @@ "value": 3 }, "min_withdrawal": { - "description": "This is the minimum amount we will pull out to reinvest, as well as a minumum\nthat can be unbonded (to avoid needless staking tx)", + "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": { From bf43ec3d3d805f882f171e3ee432140db5a6577b Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 7 Oct 2024 12:54:36 +0200 Subject: [PATCH 24/60] Initial codegen tool --- Cargo.lock | 236 ++++++++++++++++-- packages/cw-schema-codegen/Cargo.toml | 18 ++ packages/cw-schema-codegen/src/main.rs | 68 +++++ .../templates/rust/enum.tpl.rs | 0 .../templates/rust/struct.tpl.rs | 0 5 files changed, 298 insertions(+), 24 deletions(-) create mode 100644 packages/cw-schema-codegen/Cargo.toml create mode 100644 packages/cw-schema-codegen/src/main.rs create mode 100644 packages/cw-schema-codegen/templates/rust/enum.tpl.rs create mode 100644 packages/cw-schema-codegen/templates/rust/struct.tpl.rs diff --git a/Cargo.lock b/Cargo.lock index 6a7056cc0..6ca2c71e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -14,11 +14,11 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli 0.29.0", + "gimli 0.28.1", ] [[package]] @@ -88,9 +88,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" @@ -122,9 +122,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "ark-bls12-381" @@ -259,6 +259,45 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[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" @@ -282,9 +321,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", @@ -491,18 +530,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", @@ -510,6 +550,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" @@ -905,6 +957,22 @@ dependencies = [ "siphasher", ] +[[package]] +name = "cw-schema-codegen" +version = "2.1.3" +dependencies = [ + "anyhow", + "askama", + "clap", + "cw-schema", + "either", + "frunk", + "log", + "serde_json", + "simple_logger", + "strum", +] + [[package]] name = "cw-schema-derive" version = "2.1.3" @@ -1134,9 +1202,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" @@ -1268,6 +1336,62 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "frunk" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874b6a17738fc273ec753618bac60ddaeac48cb1d7684c3e7bd472e57a28b817" +dependencies = [ + "frunk_core", + "frunk_derives", + "frunk_proc_macros", + "serde", +] + +[[package]] +name = "frunk_core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3529a07095650187788833d585c219761114005d5976185760cf794d265b6a5c" +dependencies = [ + "serde", +] + +[[package]] +name = "frunk_derives" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e99b8b3c28ae0e84b604c75f721c21dc77afb3706076af5e8216d15fd1deaae3" +dependencies = [ + "frunk_proc_macro_helpers", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "frunk_proc_macro_helpers" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05a956ef36c377977e512e227dcad20f68c2786ac7a54dacece3746046fea5ce" +dependencies = [ + "frunk_core", + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "frunk_proc_macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e86c2c9183662713fea27ea527aad20fb15fee635a71081ff91bf93df4dc51" +dependencies = [ + "frunk_core", + "frunk_proc_macro_helpers", + "quote", + "syn 2.0.77", +] + [[package]] name = "funty" version = "2.0.0" @@ -1311,9 +1435,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" @@ -1588,9 +1712,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" @@ -1634,6 +1758,28 @@ dependencies = [ "autocfg", ] +[[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" @@ -1655,6 +1801,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" @@ -1696,11 +1852,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", ] @@ -2353,9 +2518,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -2445,6 +2610,18 @@ 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" @@ -2599,7 +2776,9 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -2690,6 +2869,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" diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml new file mode 100644 index 000000000..efdba0fd8 --- /dev/null +++ b/packages/cw-schema-codegen/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "cw-schema-codegen" +authors = ["Aumetra Weisman "] +edition = "2021" +version.workspace = true +publish = false + +[dependencies] +anyhow = "1.0.89" +askama = { version = "0.12.1", default-features = false } +clap = { version = "4.5.18", features = ["derive"] } +cw-schema = { version = "=2.1.3", path = "../cw-schema" } +either = "1.13.0" +frunk = "0.4.3" +log = "0.4.22" +serde_json = "1.0.128" +simple_logger = "5.0.0" +strum = { version = "0.26.3", default-features = false, features = ["derive"] } diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs new file mode 100644 index 000000000..fb19c91bb --- /dev/null +++ b/packages/cw-schema-codegen/src/main.rs @@ -0,0 +1,68 @@ +#[macro_use] +extern crate anyhow; + +#[macro_use] +extern crate log; + +use clap::{Parser, ValueEnum}; +use std::{ + fs::File, + io::{self, Write}, + path::PathBuf, +}; +use strum::Display; + +#[derive(Clone, Copy, Default, Display, ValueEnum)] +#[strum(serialize_all = "kebab-case")] +pub enum Language { + #[default] + Rust, + Go, + Typescript, +} + +#[derive(Parser)] +#[clap(about, author, version)] +/// Official CosmWasm codegen tool +struct Opts { + #[clap(default_value_t, long, short)] + /// 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 main() -> anyhow::Result<()> { + simple_logger::SimpleLogger::new() + .without_timestamps() + .init()?; + + let opts: Opts = Opts::parse(); + info!("Generating code for {} from {:?}", opts.language, opts.file); + + let schema = std::fs::read_to_string(&opts.file)?; + let schema: cw_schema::Schema = serde_json::from_str(&schema)?; + let cw_schema::Schema::V1(schema) = schema else { + bail!("Unsupported schema version"); + }; + + Ok(()) +} 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 000000000..e69de29bb 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 000000000..e69de29bb From 27d31adaded735883e825d7a61d8459e85c3c8ec Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 12:29:09 +0000 Subject: [PATCH 25/60] [autofix.ci] apply automated fixes --- contracts/burner/Cargo.lock | 4 ++-- contracts/crypto-verify/Cargo.lock | 4 ++-- contracts/cyberpunk/Cargo.lock | 4 ++-- contracts/empty/Cargo.lock | 4 ++-- contracts/floaty/Cargo.lock | 4 ++-- contracts/hackatom/Cargo.lock | 4 ++-- contracts/ibc-callbacks/Cargo.lock | 4 ++-- contracts/ibc-reflect-send/Cargo.lock | 4 ++-- contracts/ibc-reflect/Cargo.lock | 4 ++-- contracts/queue/Cargo.lock | 4 ++-- contracts/reflect/Cargo.lock | 4 ++-- contracts/staking/Cargo.lock | 4 ++-- contracts/virus/Cargo.lock | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/contracts/burner/Cargo.lock b/contracts/burner/Cargo.lock index 54ba8d07c..eca2b40a7 100644 --- a/contracts/burner/Cargo.lock +++ b/contracts/burner/Cargo.lock @@ -562,7 +562,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -574,7 +574,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/crypto-verify/Cargo.lock b/contracts/crypto-verify/Cargo.lock index 0dd3b0b97..5739f0485 100644 --- a/contracts/crypto-verify/Cargo.lock +++ b/contracts/crypto-verify/Cargo.lock @@ -575,7 +575,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -587,7 +587,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/cyberpunk/Cargo.lock b/contracts/cyberpunk/Cargo.lock index c8a449044..a921a6c03 100644 --- a/contracts/cyberpunk/Cargo.lock +++ b/contracts/cyberpunk/Cargo.lock @@ -586,7 +586,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -598,7 +598,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/empty/Cargo.lock b/contracts/empty/Cargo.lock index 8b94f85a2..fa21f4f9c 100644 --- a/contracts/empty/Cargo.lock +++ b/contracts/empty/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/floaty/Cargo.lock b/contracts/floaty/Cargo.lock index 03381aab9..a42840329 100644 --- a/contracts/floaty/Cargo.lock +++ b/contracts/floaty/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/hackatom/Cargo.lock b/contracts/hackatom/Cargo.lock index 301ffd8f8..dba240589 100644 --- a/contracts/hackatom/Cargo.lock +++ b/contracts/hackatom/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/ibc-callbacks/Cargo.lock b/contracts/ibc-callbacks/Cargo.lock index 5fe58ba6e..0492433a1 100644 --- a/contracts/ibc-callbacks/Cargo.lock +++ b/contracts/ibc-callbacks/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck 0.5.0", "itertools 0.13.0", diff --git a/contracts/ibc-reflect-send/Cargo.lock b/contracts/ibc-reflect-send/Cargo.lock index d73303212..774e8a6dc 100644 --- a/contracts/ibc-reflect-send/Cargo.lock +++ b/contracts/ibc-reflect-send/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/ibc-reflect/Cargo.lock b/contracts/ibc-reflect/Cargo.lock index b724f6347..62b5b5863 100644 --- a/contracts/ibc-reflect/Cargo.lock +++ b/contracts/ibc-reflect/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/queue/Cargo.lock b/contracts/queue/Cargo.lock index da2ccab8a..f58613a3e 100644 --- a/contracts/queue/Cargo.lock +++ b/contracts/queue/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/reflect/Cargo.lock b/contracts/reflect/Cargo.lock index 1421b232b..2af6135c1 100644 --- a/contracts/reflect/Cargo.lock +++ b/contracts/reflect/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/staking/Cargo.lock b/contracts/staking/Cargo.lock index 10dd53297..5901a7462 100644 --- a/contracts/staking/Cargo.lock +++ b/contracts/staking/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", diff --git a/contracts/virus/Cargo.lock b/contracts/virus/Cargo.lock index 2c3b4ae0e..ffc86f390 100644 --- a/contracts/virus/Cargo.lock +++ b/contracts/virus/Cargo.lock @@ -551,7 +551,7 @@ dependencies = [ [[package]] name = "cw-schema" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "cw-schema-derive", "indexmap 2.4.0", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cw-schema-derive" -version = "2.1.3" +version = "2.2.0-rc.1" dependencies = [ "heck", "itertools 0.13.0", From 10ee9faba12366067767d61834a6aed77214ea0a Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 8 Oct 2024 15:28:57 +0200 Subject: [PATCH 26/60] Add enum codegen --- Cargo.lock | 1 + packages/cw-schema-codegen/Cargo.toml | 3 ++ packages/cw-schema-codegen/src/lib.rs | 1 + packages/cw-schema-codegen/src/rust.rs | 13 +++++ .../templates/rust/enum.tpl.rs | 5 ++ packages/cw-schema-codegen/tests/rust_tpl.rs | 53 +++++++++++++++++++ .../snapshots/rust_tpl__complex_enum.snap | 11 ++++ .../tests/snapshots/rust_tpl__empty_enum.snap | 7 +++ .../snapshots/rust_tpl__simple_enum.snap | 11 ++++ 9 files changed, 105 insertions(+) create mode 100644 packages/cw-schema-codegen/src/lib.rs create mode 100644 packages/cw-schema-codegen/src/rust.rs create mode 100644 packages/cw-schema-codegen/tests/rust_tpl.rs create mode 100644 packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap diff --git a/Cargo.lock b/Cargo.lock index 5ca227bbc..c8c9a4112 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -945,6 +945,7 @@ dependencies = [ "cw-schema", "either", "frunk", + "insta", "log", "serde_json", "simple_logger", diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index 9d0daaaef..4e70ae382 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -16,3 +16,6 @@ log = "0.4.22" serde_json = "1.0.128" simple_logger = "5.0.0" strum = { version = "0.26.3", default-features = false, features = ["derive"] } + +[dev-dependencies] +insta = "1.40.0" diff --git a/packages/cw-schema-codegen/src/lib.rs b/packages/cw-schema-codegen/src/lib.rs new file mode 100644 index 000000000..0ad9e7d3d --- /dev/null +++ b/packages/cw-schema-codegen/src/lib.rs @@ -0,0 +1 @@ +pub mod rust; diff --git a/packages/cw-schema-codegen/src/rust.rs b/packages/cw-schema-codegen/src/rust.rs new file mode 100644 index 000000000..393970402 --- /dev/null +++ b/packages/cw-schema-codegen/src/rust.rs @@ -0,0 +1,13 @@ +use askama::Template; + +pub struct EnumVariantTemplate<'a> { + pub name: &'a str, + pub types: Option<&'a [&'a str]>, +} + +#[derive(Template)] +#[template(escape = "none", path = "rust/enum.tpl.rs")] +pub struct EnumTemplate<'a> { + pub name: &'a str, + pub variants: &'a [EnumVariantTemplate<'a>], +} diff --git a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs index e69de29bb..f140c84b3 100644 --- a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -0,0 +1,5 @@ +pub enum {{ name }} { + {% for variant in variants %} + {{ variant.name }} {% if let Some(types) = variant.types %}({% for ty in types %} {{ ty }}, {% endfor %}) {% endif %}, + {% endfor %} +} \ No newline at end of file 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 000000000..74062015b --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust_tpl.rs @@ -0,0 +1,53 @@ +use askama::Template; +use cw_schema_codegen::rust::{EnumTemplate, EnumVariantTemplate}; + +#[test] +fn simple_enum() { + let tpl = EnumTemplate { + name: "Simple", + variants: &[ + EnumVariantTemplate { + name: "One", + types: None, + }, + EnumVariantTemplate { + name: "Two", + types: None, + }, + ], + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn complex_enum() { + let tpl = EnumTemplate { + name: "Complex", + variants: &[ + EnumVariantTemplate { + name: "One", + types: Some(&["u64"]), + }, + EnumVariantTemplate { + name: "Two", + types: Some(&["String", "u64"]), + }, + ], + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn empty_enum() { + let tpl = EnumTemplate { + name: "Empty", + variants: &[], + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} 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 000000000..765052ffc --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -0,0 +1,11 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +pub enum Complex { + + One ( u64, ) , + + Two ( String, u64, ) , + +} 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 000000000..7819505df --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap @@ -0,0 +1,7 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +pub enum Empty { + +} 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 000000000..bd3091218 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -0,0 +1,11 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +pub enum Simple { + + One , + + Two , + +} From 14add2334dada240f599d9030da9886da688e2fe Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 15 Oct 2024 10:00:53 +0200 Subject: [PATCH 27/60] Add some templates --- Cargo.lock | 1 - packages/cw-schema-codegen/Cargo.toml | 1 - packages/cw-schema-codegen/src/main.rs | 6 ++---- packages/cw-schema-codegen/src/rust.rs | 22 +++++++++++++++++++++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8c9a4112..b2f624b78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -949,7 +949,6 @@ dependencies = [ "log", "serde_json", "simple_logger", - "strum", ] [[package]] diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index 4e70ae382..97554d137 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -15,7 +15,6 @@ frunk = "0.4.3" log = "0.4.22" serde_json = "1.0.128" simple_logger = "5.0.0" -strum = { version = "0.26.3", default-features = false, features = ["derive"] } [dev-dependencies] insta = "1.40.0" diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index fb19c91bb..34a19edf2 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -10,10 +10,8 @@ use std::{ io::{self, Write}, path::PathBuf, }; -use strum::Display; -#[derive(Clone, Copy, Default, Display, ValueEnum)] -#[strum(serialize_all = "kebab-case")] +#[derive(Clone, Copy, Default, ValueEnum)] pub enum Language { #[default] Rust, @@ -25,7 +23,7 @@ pub enum Language { #[clap(about, author, version)] /// Official CosmWasm codegen tool struct Opts { - #[clap(default_value_t, long, short)] + #[clap(default_value_t, long, short, value_enum)] /// Programming language to generate code for language: Language, diff --git a/packages/cw-schema-codegen/src/rust.rs b/packages/cw-schema-codegen/src/rust.rs index 393970402..073c31896 100644 --- a/packages/cw-schema-codegen/src/rust.rs +++ b/packages/cw-schema-codegen/src/rust.rs @@ -2,7 +2,7 @@ use askama::Template; pub struct EnumVariantTemplate<'a> { pub name: &'a str, - pub types: Option<&'a [&'a str]>, + pub ty: TypeTemplate<'a>, } #[derive(Template)] @@ -11,3 +11,23 @@ pub struct EnumTemplate<'a> { pub name: &'a str, pub variants: &'a [EnumVariantTemplate<'a>], } + +pub struct FieldTemplate<'a> { + pub name: &'a str, + pub ty: &'a str, +} + +pub enum TypeTemplate<'a> { + Unit, + Tuple(&'a [&'a str]), + Named { + fields: &'a [FieldTemplate<'a>], + } +} + +#[derive(Template)] +#[template(escape = "none", path = "rust/struct.tpl.rs")] +pub struct StructTemplate<'a> { + pub name: &'a str, + pub ty: TypeTemplate<'a>, +} From 278047472d9ab14464ae50fae8131e3eac07b685 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 24 Oct 2024 15:39:54 +0200 Subject: [PATCH 28/60] Fix enum templates --- packages/cw-schema-codegen/src/main.rs | 4 ++-- .../templates/rust/enum.tpl.rs | 18 ++++++++++++++- packages/cw-schema-codegen/tests/rust_tpl.rs | 21 +++++++++++++----- .../snapshots/rust_tpl__complex_enum.snap | 22 +++++++++++++++++-- .../snapshots/rust_tpl__simple_enum.snap | 10 +++++++-- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index 34a19edf2..70d572fcf 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -11,7 +11,7 @@ use std::{ path::PathBuf, }; -#[derive(Clone, Copy, Default, ValueEnum)] +#[derive(Clone, Copy, Debug, Default, ValueEnum)] pub enum Language { #[default] Rust, @@ -54,7 +54,7 @@ fn main() -> anyhow::Result<()> { .init()?; let opts: Opts = Opts::parse(); - info!("Generating code for {} from {:?}", opts.language, opts.file); + info!("Generating code for {:?} from {:?}", opts.language, opts.file); let schema = std::fs::read_to_string(&opts.file)?; let schema: cw_schema::Schema = serde_json::from_str(&schema)?; diff --git a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs index f140c84b3..8ea48d743 100644 --- a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -1,5 +1,21 @@ pub enum {{ name }} { {% for variant in variants %} - {{ variant.name }} {% if let Some(types) = variant.types %}({% for ty in types %} {{ ty }}, {% endfor %}) {% endif %}, + {{ variant.name }} + {% match variant.ty %} + {% when TypeTemplate::Unit %} + {% when TypeTemplate::Tuple with (types) %} + ( + {% for ty in types %} + {{ ty }}, + {% endfor %} + ) + {% when TypeTemplate::Named with { fields } %} + { + {% for field in fields %} + {{ field.name }}: {{ field.ty }}, + {% endfor %} + } + {% endmatch %} + , {% endfor %} } \ No newline at end of file diff --git a/packages/cw-schema-codegen/tests/rust_tpl.rs b/packages/cw-schema-codegen/tests/rust_tpl.rs index 74062015b..5ad8bd379 100644 --- a/packages/cw-schema-codegen/tests/rust_tpl.rs +++ b/packages/cw-schema-codegen/tests/rust_tpl.rs @@ -1,5 +1,5 @@ use askama::Template; -use cw_schema_codegen::rust::{EnumTemplate, EnumVariantTemplate}; +use cw_schema_codegen::rust::{EnumTemplate, EnumVariantTemplate, FieldTemplate, TypeTemplate}; #[test] fn simple_enum() { @@ -8,11 +8,11 @@ fn simple_enum() { variants: &[ EnumVariantTemplate { name: "One", - types: None, + ty: TypeTemplate::Unit, }, EnumVariantTemplate { name: "Two", - types: None, + ty: TypeTemplate::Unit, }, ], }; @@ -28,11 +28,22 @@ fn complex_enum() { variants: &[ EnumVariantTemplate { name: "One", - types: Some(&["u64"]), + ty: TypeTemplate::Tuple(&["u64"]), }, EnumVariantTemplate { name: "Two", - types: Some(&["String", "u64"]), + ty: TypeTemplate::Named { + fields: &[ + FieldTemplate { + name: "a", + ty: "u64", + }, + FieldTemplate { + name: "b", + ty: "String", + }, + ], + }, }, ], }; 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 index 765052ffc..0c3629047 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -4,8 +4,26 @@ expression: rendered --- pub enum Complex { - One ( u64, ) , + One + + ( + + u64, + + ) + + , - Two ( String, u64, ) , + Two + + { + + a: u64, + + 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 index bd3091218..eb0f302cf 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -4,8 +4,14 @@ expression: rendered --- pub enum Simple { - One , + One + + + , - Two , + Two + + + , } From 30b0d919a8c570e1bdef57b8be384b8406cc3a5c Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Thu, 24 Oct 2024 16:01:04 +0200 Subject: [PATCH 29/60] Add struct codegen --- packages/cw-schema-codegen/src/main.rs | 5 +- packages/cw-schema-codegen/src/rust.rs | 4 +- .../templates/rust/struct.tpl.rs | 18 +++++++ packages/cw-schema-codegen/tests/rust_tpl.rs | 48 ++++++++++++++++++- .../snapshots/rust_tpl__empty_struct.snap | 8 ++++ .../snapshots/rust_tpl__named_struct.snap | 14 ++++++ .../snapshots/rust_tpl__tuple_struct.snap | 14 ++++++ 7 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index 70d572fcf..853444ba8 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -54,7 +54,10 @@ fn main() -> anyhow::Result<()> { .init()?; let opts: Opts = Opts::parse(); - info!("Generating code for {:?} from {:?}", opts.language, opts.file); + info!( + "Generating code for {:?} from {:?}", + opts.language, opts.file + ); let schema = std::fs::read_to_string(&opts.file)?; let schema: cw_schema::Schema = serde_json::from_str(&schema)?; diff --git a/packages/cw-schema-codegen/src/rust.rs b/packages/cw-schema-codegen/src/rust.rs index 073c31896..6e94df713 100644 --- a/packages/cw-schema-codegen/src/rust.rs +++ b/packages/cw-schema-codegen/src/rust.rs @@ -20,9 +20,7 @@ pub struct FieldTemplate<'a> { pub enum TypeTemplate<'a> { Unit, Tuple(&'a [&'a str]), - Named { - fields: &'a [FieldTemplate<'a>], - } + Named { fields: &'a [FieldTemplate<'a>] }, } #[derive(Template)] diff --git a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs index e69de29bb..394cb98cb 100644 --- a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs @@ -0,0 +1,18 @@ +pub struct {{ name }} + +{% match ty %} + {% when TypeTemplate::Unit %} + ; + {% when TypeTemplate::Tuple with (types) %} + ( + {% for ty in types %} + {{ ty }}, + {% endfor %} + ); + {% when TypeTemplate::Named with { fields } %} + { + {% for field in fields %} + {{ field.name }}: {{ field.ty }}, + {% endfor %} + } +{% endmatch %} diff --git a/packages/cw-schema-codegen/tests/rust_tpl.rs b/packages/cw-schema-codegen/tests/rust_tpl.rs index 5ad8bd379..5dddd73d8 100644 --- a/packages/cw-schema-codegen/tests/rust_tpl.rs +++ b/packages/cw-schema-codegen/tests/rust_tpl.rs @@ -1,5 +1,7 @@ use askama::Template; -use cw_schema_codegen::rust::{EnumTemplate, EnumVariantTemplate, FieldTemplate, TypeTemplate}; +use cw_schema_codegen::rust::{ + EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, +}; #[test] fn simple_enum() { @@ -62,3 +64,47 @@ fn empty_enum() { let rendered = tpl.render().unwrap(); insta::assert_snapshot!(rendered); } + +#[test] +fn empty_struct() { + let tpl = StructTemplate { + name: "Empty", + ty: TypeTemplate::Unit, + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn tuple_struct() { + let tpl = StructTemplate { + name: "Tuple", + ty: TypeTemplate::Tuple(&["u64", "String"]), + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} + +#[test] +fn named_struct() { + let tpl = StructTemplate { + name: "Named", + ty: TypeTemplate::Named { + fields: &[ + FieldTemplate { + name: "a", + ty: "u64", + }, + FieldTemplate { + name: "b", + ty: "String", + }, + ], + }, + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} 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 000000000..c3cb28d6f --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap @@ -0,0 +1,8 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +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 000000000..cab901934 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap @@ -0,0 +1,14 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +pub struct Named + + + { + + a: u64, + + b: String, + + } 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 000000000..6607dfe97 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap @@ -0,0 +1,14 @@ +--- +source: packages/cw-schema-codegen/tests/rust_tpl.rs +expression: rendered +--- +pub struct Tuple + + + ( + + u64, + + String, + + ); From 9855d422d987275d25565d8d6c29e81a19df63e4 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 25 Oct 2024 18:21:02 +0200 Subject: [PATCH 30/60] PoC Rust codegen --- packages/cw-schema-codegen/src/main.rs | 153 +++++++++++++++++- packages/cw-schema-codegen/src/rust.rs | 20 ++- .../templates/rust/enum.tpl.rs | 12 ++ .../templates/rust/struct.tpl.rs | 8 + packages/cw-schema-codegen/tests/rust_tpl.rs | 57 ++++--- 5 files changed, 223 insertions(+), 27 deletions(-) diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index 853444ba8..5264f907f 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -6,12 +6,13 @@ extern crate log; use clap::{Parser, ValueEnum}; use std::{ - fs::File, + borrow::Cow, + fs::{self, File}, io::{self, Write}, path::PathBuf, }; -#[derive(Clone, Copy, Debug, Default, ValueEnum)] +#[derive(Clone, Copy, Debug, Default, PartialEq, ValueEnum)] pub enum Language { #[default] Rust, @@ -48,6 +49,52 @@ impl Opts { } } +fn expand_node_name<'a>( + schema: &'a cw_schema::SchemaV1, + node: &'a cw_schema::Node, +) -> Cow<'a, str> { + match node.value { + cw_schema::NodeType::Array { items } => { + let items = &schema.definitions[items]; + format!("Vec<{}>", expand_node_name(schema, items)).into() + } + cw_schema::NodeType::Float => "f32".into(), + cw_schema::NodeType::Double => "f64".into(), + cw_schema::NodeType::Boolean => "bool".into(), + cw_schema::NodeType::String => "String".into(), + cw_schema::NodeType::Integer { signed, precision } => { + let ty = if signed { "i" } else { "u" }; + format!("{ty}{precision}").into() + } + cw_schema::NodeType::Binary => "Vec".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("Option<{}>", expand_node_name(schema, inner)).into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { ref items } => { + let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("({})", items).into() + } + cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + _ => todo!(), + } +} + +fn prepare_docs(desc: Option<&str>) -> Cow<'_, [Cow<'_, str>]> { + desc.map(|desc| { + desc.lines() + .map(|line| line.replace('"', "\\\"").into()) + .collect() + }) + .unwrap_or(Cow::Borrowed(&[])) +} + fn main() -> anyhow::Result<()> { simple_logger::SimpleLogger::new() .without_timestamps() @@ -59,11 +106,111 @@ fn main() -> anyhow::Result<()> { opts.language, opts.file ); - let schema = std::fs::read_to_string(&opts.file)?; + ensure!(opts.file.exists(), "Schema file does not exist"); + ensure!( + opts.language == Language::Rust, + "Only Rust code generation is supported at the moment" + ); + + let schema = fs::read_to_string(&opts.file)?; let schema: cw_schema::Schema = serde_json::from_str(&schema)?; let cw_schema::Schema::V1(schema) = schema else { bail!("Unsupported schema version"); }; + let mut output = opts.output()?; + + schema.definitions.iter().for_each(|node| { + debug!("Processing node: {node:?}"); + + match node.value { + cw_schema::NodeType::Struct(ref sty) => { + let structt = cw_schema_codegen::rust::StructTemplate { + name: &node.name, + docs: prepare_docs(node.description.as_deref()), + ty: match sty { + cw_schema::StructType::Unit => cw_schema_codegen::rust::TypeTemplate::Unit, + cw_schema::StructType::Named { ref properties } => { + cw_schema_codegen::rust::TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| { + let ty = expand_node_name( + &schema, + &schema.definitions[prop.value], + ); + cw_schema_codegen::rust::FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty, + } + }) + .collect(), + } + } + _ => unreachable!(), + }, + }; + + writeln!(output, "{structt}").unwrap(); + } + cw_schema::NodeType::Enum { ref cases, .. } => { + let enumm = cw_schema_codegen::rust::EnumTemplate { + name: &node.name, + docs: prepare_docs(node.description.as_deref()), + variants: cases + .iter() + .map( + |(name, case)| cw_schema_codegen::rust::EnumVariantTemplate { + name, + docs: prepare_docs(case.description.as_deref()), + ty: match case.value { + cw_schema::EnumValue::Unit => { + cw_schema_codegen::rust::TypeTemplate::Unit + } + cw_schema::EnumValue::Tuple { ref items } => { + let items = items + .iter() + .map(|item| { + let node = &schema.definitions[*item]; + expand_node_name(&schema, node) + }) + .collect(); + + cw_schema_codegen::rust::TypeTemplate::Tuple(items) + } + cw_schema::EnumValue::Named { ref properties, .. } => { + cw_schema_codegen::rust::TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| { + let ty = expand_node_name( + &schema, + &schema.definitions[prop.value], + ); + cw_schema_codegen::rust::FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs( + prop.description.as_deref(), + ), + ty, + } + }) + .collect(), + } + } + _ => unreachable!(), + }, + }, + ) + .collect(), + }; + + writeln!(output, "{enumm}").unwrap(); + } + _ => (), + } + }); + Ok(()) } diff --git a/packages/cw-schema-codegen/src/rust.rs b/packages/cw-schema-codegen/src/rust.rs index 6e94df713..f5ef51961 100644 --- a/packages/cw-schema-codegen/src/rust.rs +++ b/packages/cw-schema-codegen/src/rust.rs @@ -1,7 +1,10 @@ use askama::Template; +use std::borrow::Cow; +#[derive(Clone)] pub struct EnumVariantTemplate<'a> { pub name: &'a str, + pub docs: Cow<'a, [Cow<'a, str>]>, pub ty: TypeTemplate<'a>, } @@ -9,23 +12,30 @@ pub struct EnumVariantTemplate<'a> { #[template(escape = "none", path = "rust/enum.tpl.rs")] pub struct EnumTemplate<'a> { pub name: &'a str, - pub variants: &'a [EnumVariantTemplate<'a>], + pub docs: Cow<'a, [Cow<'a, str>]>, + pub variants: Cow<'a, [EnumVariantTemplate<'a>]>, } +#[derive(Clone)] pub struct FieldTemplate<'a> { - pub name: &'a str, - pub ty: &'a str, + 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(&'a [&'a str]), - Named { fields: &'a [FieldTemplate<'a>] }, + 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: &'a str, + pub docs: Cow<'a, [Cow<'a, str>]>, pub ty: TypeTemplate<'a>, } diff --git a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs index 8ea48d743..2d6081ac4 100644 --- a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -1,5 +1,13 @@ +{% for doc in docs %} + #[doc = "{{ doc }}"] +{% endfor %} + pub enum {{ name }} { {% for variant in variants %} + {% for doc in variant.docs %} + #[doc = "{{ doc }}"] + {% endfor %} + {{ variant.name }} {% match variant.ty %} {% when TypeTemplate::Unit %} @@ -12,6 +20,10 @@ pub enum {{ name }} { {% when TypeTemplate::Named with { fields } %} { {% for field in fields %} + {% for doc in field.docs %} + #[doc = "{{ doc }}"] + {% endfor %} + {{ field.name }}: {{ field.ty }}, {% endfor %} } diff --git a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs index 394cb98cb..9b3cac4f4 100644 --- a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs @@ -1,3 +1,7 @@ +{% for doc in docs %} + #[doc = "{{ doc }}"] +{% endfor %} + pub struct {{ name }} {% match ty %} @@ -12,6 +16,10 @@ pub struct {{ name }} {% when TypeTemplate::Named with { fields } %} { {% for field in fields %} + {% for doc in field.docs %} + #[doc = "{{ doc }}"] + {% endfor %} + {{ field.name }}: {{ field.ty }}, {% endfor %} } diff --git a/packages/cw-schema-codegen/tests/rust_tpl.rs b/packages/cw-schema-codegen/tests/rust_tpl.rs index 5dddd73d8..69cebb02c 100644 --- a/packages/cw-schema-codegen/tests/rust_tpl.rs +++ b/packages/cw-schema-codegen/tests/rust_tpl.rs @@ -1,3 +1,5 @@ +use std::borrow::Cow; + use askama::Template; use cw_schema_codegen::rust::{ EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, @@ -7,16 +9,19 @@ use cw_schema_codegen::rust::{ fn simple_enum() { let tpl = EnumTemplate { name: "Simple", - variants: &[ + docs: Cow::Borrowed(&[Cow::Borrowed("Simple enum")]), + variants: Cow::Borrowed(&[ EnumVariantTemplate { name: "One", + docs: Cow::Borrowed(&[Cow::Borrowed("One variant")]), ty: TypeTemplate::Unit, }, EnumVariantTemplate { name: "Two", + docs: Cow::Borrowed(&[Cow::Borrowed("Two variant")]), ty: TypeTemplate::Unit, }, - ], + ]), }; let rendered = tpl.render().unwrap(); @@ -27,27 +32,32 @@ fn simple_enum() { fn complex_enum() { let tpl = EnumTemplate { name: "Complex", - variants: &[ + docs: Cow::Borrowed(&[Cow::Borrowed("Complex enum")]), + variants: Cow::Borrowed(&[ EnumVariantTemplate { name: "One", - ty: TypeTemplate::Tuple(&["u64"]), + docs: Cow::Borrowed(&[Cow::Borrowed("One variant")]), + ty: TypeTemplate::Tuple(Cow::Borrowed(&[Cow::Borrowed("u64")])), }, EnumVariantTemplate { name: "Two", + docs: Cow::Borrowed(&[Cow::Borrowed("Two variant")]), ty: TypeTemplate::Named { - fields: &[ + fields: Cow::Borrowed(&[ FieldTemplate { - name: "a", - ty: "u64", + name: Cow::Borrowed("a"), + docs: Cow::Borrowed(&[Cow::Borrowed("Field a")]), + ty: Cow::Borrowed("u64"), }, FieldTemplate { - name: "b", - ty: "String", + name: Cow::Borrowed("b"), + docs: Cow::Borrowed(&[Cow::Borrowed("Field b")]), + ty: Cow::Borrowed("String"), }, - ], + ]), }, }, - ], + ]), }; let rendered = tpl.render().unwrap(); @@ -58,7 +68,8 @@ fn complex_enum() { fn empty_enum() { let tpl = EnumTemplate { name: "Empty", - variants: &[], + docs: Cow::Borrowed(&[Cow::Borrowed("Empty enum")]), + variants: Cow::Borrowed(&[]), }; let rendered = tpl.render().unwrap(); @@ -69,6 +80,7 @@ fn empty_enum() { fn empty_struct() { let tpl = StructTemplate { name: "Empty", + docs: Cow::Borrowed(&[Cow::Borrowed("Empty struct")]), ty: TypeTemplate::Unit, }; @@ -80,7 +92,11 @@ fn empty_struct() { fn tuple_struct() { let tpl = StructTemplate { name: "Tuple", - ty: TypeTemplate::Tuple(&["u64", "String"]), + docs: Cow::Borrowed(&[Cow::Borrowed("Tuple struct")]), + ty: TypeTemplate::Tuple(Cow::Borrowed(&[ + Cow::Borrowed("u64"), + Cow::Borrowed("String"), + ])), }; let rendered = tpl.render().unwrap(); @@ -91,17 +107,20 @@ fn tuple_struct() { fn named_struct() { let tpl = StructTemplate { name: "Named", + docs: Cow::Borrowed(&[Cow::Borrowed("Named struct")]), ty: TypeTemplate::Named { - fields: &[ + fields: Cow::Borrowed(&[ FieldTemplate { - name: "a", - ty: "u64", + name: Cow::Borrowed("a"), + docs: Cow::Borrowed(&[Cow::Borrowed("Field a")]), + ty: Cow::Borrowed("u64"), }, FieldTemplate { - name: "b", - ty: "String", + name: Cow::Borrowed("b"), + docs: Cow::Borrowed(&[Cow::Borrowed("Field b")]), + ty: Cow::Borrowed("String"), }, - ], + ]), }, }; From 2b560a2e77ab21fb5d5e4c2262d6484b419eec35 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 28 Oct 2024 10:13:36 +0100 Subject: [PATCH 31/60] Slight refactor --- packages/cw-schema-codegen/src/main.rs | 141 +----------------- packages/cw-schema-codegen/src/rust/mod.rs | 140 +++++++++++++++++ .../src/{rust.rs => rust/template.rs} | 0 packages/cw-schema-codegen/tests/rust_tpl.rs | 2 +- .../snapshots/rust_tpl__complex_enum.snap | 19 +++ .../tests/snapshots/rust_tpl__empty_enum.snap | 3 + .../snapshots/rust_tpl__empty_struct.snap | 3 + .../snapshots/rust_tpl__named_struct.snap | 11 ++ .../snapshots/rust_tpl__simple_enum.snap | 11 ++ .../snapshots/rust_tpl__tuple_struct.snap | 3 + 10 files changed, 195 insertions(+), 138 deletions(-) create mode 100644 packages/cw-schema-codegen/src/rust/mod.rs rename packages/cw-schema-codegen/src/{rust.rs => rust/template.rs} (100%) diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index 5264f907f..e93ddf72a 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -6,7 +6,6 @@ extern crate log; use clap::{Parser, ValueEnum}; use std::{ - borrow::Cow, fs::{self, File}, io::{self, Write}, path::PathBuf, @@ -17,6 +16,7 @@ pub enum Language { #[default] Rust, Go, + Python, Typescript, } @@ -49,52 +49,6 @@ impl Opts { } } -fn expand_node_name<'a>( - schema: &'a cw_schema::SchemaV1, - node: &'a cw_schema::Node, -) -> Cow<'a, str> { - match node.value { - cw_schema::NodeType::Array { items } => { - let items = &schema.definitions[items]; - format!("Vec<{}>", expand_node_name(schema, items)).into() - } - cw_schema::NodeType::Float => "f32".into(), - cw_schema::NodeType::Double => "f64".into(), - cw_schema::NodeType::Boolean => "bool".into(), - cw_schema::NodeType::String => "String".into(), - cw_schema::NodeType::Integer { signed, precision } => { - let ty = if signed { "i" } else { "u" }; - format!("{ty}{precision}").into() - } - cw_schema::NodeType::Binary => "Vec".into(), - cw_schema::NodeType::Optional { inner } => { - let inner = &schema.definitions[inner]; - format!("Option<{}>", expand_node_name(schema, inner)).into() - } - cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), - cw_schema::NodeType::Tuple { ref items } => { - let items = items - .iter() - .map(|item| expand_node_name(schema, &schema.definitions[*item])) - .collect::>() - .join(", "); - - format!("({})", items).into() - } - cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), - _ => todo!(), - } -} - -fn prepare_docs(desc: Option<&str>) -> Cow<'_, [Cow<'_, str>]> { - desc.map(|desc| { - desc.lines() - .map(|line| line.replace('"', "\\\"").into()) - .collect() - }) - .unwrap_or(Cow::Borrowed(&[])) -} - fn main() -> anyhow::Result<()> { simple_logger::SimpleLogger::new() .without_timestamps() @@ -120,97 +74,10 @@ fn main() -> anyhow::Result<()> { let mut output = opts.output()?; - schema.definitions.iter().for_each(|node| { + schema.definitions.iter().try_for_each(|node| { debug!("Processing node: {node:?}"); - - match node.value { - cw_schema::NodeType::Struct(ref sty) => { - let structt = cw_schema_codegen::rust::StructTemplate { - name: &node.name, - docs: prepare_docs(node.description.as_deref()), - ty: match sty { - cw_schema::StructType::Unit => cw_schema_codegen::rust::TypeTemplate::Unit, - cw_schema::StructType::Named { ref properties } => { - cw_schema_codegen::rust::TypeTemplate::Named { - fields: properties - .iter() - .map(|(name, prop)| { - let ty = expand_node_name( - &schema, - &schema.definitions[prop.value], - ); - cw_schema_codegen::rust::FieldTemplate { - name: Cow::Borrowed(name), - docs: prepare_docs(prop.description.as_deref()), - ty, - } - }) - .collect(), - } - } - _ => unreachable!(), - }, - }; - - writeln!(output, "{structt}").unwrap(); - } - cw_schema::NodeType::Enum { ref cases, .. } => { - let enumm = cw_schema_codegen::rust::EnumTemplate { - name: &node.name, - docs: prepare_docs(node.description.as_deref()), - variants: cases - .iter() - .map( - |(name, case)| cw_schema_codegen::rust::EnumVariantTemplate { - name, - docs: prepare_docs(case.description.as_deref()), - ty: match case.value { - cw_schema::EnumValue::Unit => { - cw_schema_codegen::rust::TypeTemplate::Unit - } - cw_schema::EnumValue::Tuple { ref items } => { - let items = items - .iter() - .map(|item| { - let node = &schema.definitions[*item]; - expand_node_name(&schema, node) - }) - .collect(); - - cw_schema_codegen::rust::TypeTemplate::Tuple(items) - } - cw_schema::EnumValue::Named { ref properties, .. } => { - cw_schema_codegen::rust::TypeTemplate::Named { - fields: properties - .iter() - .map(|(name, prop)| { - let ty = expand_node_name( - &schema, - &schema.definitions[prop.value], - ); - cw_schema_codegen::rust::FieldTemplate { - name: Cow::Borrowed(name), - docs: prepare_docs( - prop.description.as_deref(), - ), - ty, - } - }) - .collect(), - } - } - _ => unreachable!(), - }, - }, - ) - .collect(), - }; - - writeln!(output, "{enumm}").unwrap(); - } - _ => (), - } - }); + cw_schema_codegen::rust::process_node(&mut output, &schema, node) + })?; Ok(()) } 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 000000000..916ca5823 --- /dev/null +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -0,0 +1,140 @@ +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!("Vec<{}>", expand_node_name(schema, items)).into() + } + cw_schema::NodeType::Float => "f32".into(), + cw_schema::NodeType::Double => "f64".into(), + cw_schema::NodeType::Boolean => "bool".into(), + cw_schema::NodeType::String => "String".into(), + cw_schema::NodeType::Integer { signed, precision } => { + let ty = if signed { "i" } else { "u" }; + format!("{ty}{precision}").into() + } + cw_schema::NodeType::Binary => "Vec".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("Option<{}>", expand_node_name(schema, inner)).into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { ref items } => { + let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("({})", items).into() + } + cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + _ => todo!(), + } +} + +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, + 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)| { + let ty = expand_node_name(schema, &schema.definitions[prop.value]); + FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty, + } + }) + .collect(), + }, + _ => unreachable!(), + }, + }; + + writeln!(output, "{structt}")?; + } + cw_schema::NodeType::Enum { ref cases, .. } => { + let enumm = EnumTemplate { + name: &node.name, + docs: prepare_docs(node.description.as_deref()), + variants: cases + .iter() + .map(|(name, case)| EnumVariantTemplate { + 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| { + let node = &schema.definitions[*item]; + expand_node_name(schema, node) + }) + .collect(); + + TypeTemplate::Tuple(items) + } + cw_schema::EnumValue::Named { ref properties, .. } => { + TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| { + let ty = expand_node_name( + schema, + &schema.definitions[prop.value], + ); + FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty, + } + }) + .collect(), + } + } + _ => unreachable!(), + }, + }) + .collect(), + }; + + writeln!(output, "{enumm}")?; + } + _ => (), + } + + Ok(()) +} diff --git a/packages/cw-schema-codegen/src/rust.rs b/packages/cw-schema-codegen/src/rust/template.rs similarity index 100% rename from packages/cw-schema-codegen/src/rust.rs rename to packages/cw-schema-codegen/src/rust/template.rs diff --git a/packages/cw-schema-codegen/tests/rust_tpl.rs b/packages/cw-schema-codegen/tests/rust_tpl.rs index 69cebb02c..bc7ad7604 100644 --- a/packages/cw-schema-codegen/tests/rust_tpl.rs +++ b/packages/cw-schema-codegen/tests/rust_tpl.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use askama::Template; -use cw_schema_codegen::rust::{ +use cw_schema_codegen::rust::template::{ EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, }; 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 index 0c3629047..319a69340 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -2,8 +2,15 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- + #[doc = "Complex enum"] + + pub enum Complex { + + #[doc = "One variant"] + + One ( @@ -14,12 +21,24 @@ pub enum Complex { , + + #[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 index 7819505df..180574367 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- + #[doc = "Empty enum"] + + 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 index c3cb28d6f..9017b8729 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- + #[doc = "Empty struct"] + + 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 index cab901934..fec1e4721 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap @@ -2,13 +2,24 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- + #[doc = "Named struct"] + + 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 index eb0f302cf..903298dca 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -2,13 +2,24 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- + #[doc = "Simple enum"] + + 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 index 6607dfe97..1d2dd2344 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- + #[doc = "Tuple struct"] + + pub struct Tuple From db942c0fe6c32440c6f92df90ba18603f9870464 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 28 Oct 2024 10:52:34 +0100 Subject: [PATCH 32/60] Add serde renames for prettier enums --- packages/cw-schema-codegen/Cargo.toml | 3 +- packages/cw-schema-codegen/src/rust/mod.rs | 51 ++++++++++--------- .../cw-schema-codegen/src/rust/template.rs | 7 +-- .../templates/rust/enum.tpl.rs | 7 +++ .../templates/rust/struct.tpl.rs | 1 + packages/cw-schema-codegen/tests/rust_tpl.rs | 24 +++++---- .../snapshots/rust_tpl__complex_enum.snap | 7 +++ .../tests/snapshots/rust_tpl__empty_enum.snap | 1 + .../snapshots/rust_tpl__empty_struct.snap | 1 + .../snapshots/rust_tpl__named_struct.snap | 1 + .../snapshots/rust_tpl__simple_enum.snap | 7 +++ .../snapshots/rust_tpl__tuple_struct.snap | 1 + 12 files changed, 74 insertions(+), 37 deletions(-) diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index 97554d137..f31f233f9 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -12,9 +12,10 @@ clap = { version = "4.5.18", features = ["derive"] } cw-schema = { version = "=2.2.0-rc.1", path = "../cw-schema" } either = "1.13.0" frunk = "0.4.3" +heck = "0.5.0" log = "0.4.22" serde_json = "1.0.128" -simple_logger = "5.0.0" +simple_logger = { version = "5.0.0", features = ["stderr"] } [dev-dependencies] insta = "1.40.0" diff --git a/packages/cw-schema-codegen/src/rust/mod.rs b/packages/cw-schema-codegen/src/rust/mod.rs index 916ca5823..95c5ac2aa 100644 --- a/packages/cw-schema-codegen/src/rust/mod.rs +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -1,6 +1,7 @@ use self::template::{ EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, }; +use heck::ToPascalCase; use std::{borrow::Cow, io}; pub mod template; @@ -38,7 +39,13 @@ fn expand_node_name<'a>( format!("({})", items).into() } cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), - _ => todo!(), + + cw_schema::NodeType::Decimal { precision, signed } => todo!(), + cw_schema::NodeType::Address => todo!(), + cw_schema::NodeType::Checksum => todo!(), + cw_schema::NodeType::HexBinary => todo!(), + cw_schema::NodeType::Timestamp => todo!(), + cw_schema::NodeType::Unit => Cow::Borrowed("()"), } } @@ -62,24 +69,26 @@ where match node.value { cw_schema::NodeType::Struct(ref sty) => { let structt = StructTemplate { - name: &node.name, + 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)| { - let ty = expand_node_name(schema, &schema.definitions[prop.value]); - FieldTemplate { - name: Cow::Borrowed(name), - docs: prepare_docs(prop.description.as_deref()), - ty, - } + .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(), }, - _ => unreachable!(), + cw_schema::StructType::Tuple { ref items } => TypeTemplate::Tuple( + items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect(), + ), }, }; @@ -87,21 +96,21 @@ where } cw_schema::NodeType::Enum { ref cases, .. } => { let enumm = EnumTemplate { - name: &node.name, + name: node.name.clone(), docs: prepare_docs(node.description.as_deref()), variants: cases .iter() .map(|(name, case)| EnumVariantTemplate { - name, + 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| { - let node = &schema.definitions[*item]; - expand_node_name(schema, node) + expand_node_name(schema, &schema.definitions[*item]) }) .collect(); @@ -111,21 +120,17 @@ where TypeTemplate::Named { fields: properties .iter() - .map(|(name, prop)| { - let ty = expand_node_name( + .map(|(name, prop)| FieldTemplate { + name: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name( schema, &schema.definitions[prop.value], - ); - FieldTemplate { - name: Cow::Borrowed(name), - docs: prepare_docs(prop.description.as_deref()), - ty, - } + ), }) .collect(), } } - _ => unreachable!(), }, }) .collect(), diff --git a/packages/cw-schema-codegen/src/rust/template.rs b/packages/cw-schema-codegen/src/rust/template.rs index f5ef51961..987165c7f 100644 --- a/packages/cw-schema-codegen/src/rust/template.rs +++ b/packages/cw-schema-codegen/src/rust/template.rs @@ -3,15 +3,16 @@ use std::borrow::Cow; #[derive(Clone)] pub struct EnumVariantTemplate<'a> { - pub name: &'a str, + 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: &'a str, + pub name: Cow<'a, str>, pub docs: Cow<'a, [Cow<'a, str>]>, pub variants: Cow<'a, [EnumVariantTemplate<'a>]>, } @@ -35,7 +36,7 @@ pub enum TypeTemplate<'a> { #[derive(Template)] #[template(escape = "none", path = "rust/struct.tpl.rs")] pub struct StructTemplate<'a> { - pub name: &'a str, + pub name: Cow<'a, str>, pub docs: Cow<'a, [Cow<'a, str>]>, pub ty: TypeTemplate<'a>, } diff --git a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs index 2d6081ac4..e0768fef1 100644 --- a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -2,12 +2,19 @@ #[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 %} diff --git a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs index 9b3cac4f4..87173daa9 100644 --- a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs @@ -2,6 +2,7 @@ #[doc = "{{ doc }}"] {% endfor %} +#[cosmwasm_schema::cw_serde] pub struct {{ name }} {% match ty %} diff --git a/packages/cw-schema-codegen/tests/rust_tpl.rs b/packages/cw-schema-codegen/tests/rust_tpl.rs index bc7ad7604..3fdbf90c4 100644 --- a/packages/cw-schema-codegen/tests/rust_tpl.rs +++ b/packages/cw-schema-codegen/tests/rust_tpl.rs @@ -8,17 +8,19 @@ use cw_schema_codegen::rust::template::{ #[test] fn simple_enum() { let tpl = EnumTemplate { - name: "Simple", + name: Cow::Borrowed("Simple"), docs: Cow::Borrowed(&[Cow::Borrowed("Simple enum")]), variants: Cow::Borrowed(&[ EnumVariantTemplate { - name: "One", + name: Cow::Borrowed("One"), docs: Cow::Borrowed(&[Cow::Borrowed("One variant")]), + serde_rename: None, ty: TypeTemplate::Unit, }, EnumVariantTemplate { - name: "Two", + name: Cow::Borrowed("Two"), docs: Cow::Borrowed(&[Cow::Borrowed("Two variant")]), + serde_rename: None, ty: TypeTemplate::Unit, }, ]), @@ -31,17 +33,19 @@ fn simple_enum() { #[test] fn complex_enum() { let tpl = EnumTemplate { - name: "Complex", + name: Cow::Borrowed("Complex"), docs: Cow::Borrowed(&[Cow::Borrowed("Complex enum")]), variants: Cow::Borrowed(&[ EnumVariantTemplate { - name: "One", + name: Cow::Borrowed("One"), docs: Cow::Borrowed(&[Cow::Borrowed("One variant")]), + serde_rename: None, ty: TypeTemplate::Tuple(Cow::Borrowed(&[Cow::Borrowed("u64")])), }, EnumVariantTemplate { - name: "Two", + name: Cow::Borrowed("Two"), docs: Cow::Borrowed(&[Cow::Borrowed("Two variant")]), + serde_rename: None, ty: TypeTemplate::Named { fields: Cow::Borrowed(&[ FieldTemplate { @@ -67,7 +71,7 @@ fn complex_enum() { #[test] fn empty_enum() { let tpl = EnumTemplate { - name: "Empty", + name: Cow::Borrowed("Empty"), docs: Cow::Borrowed(&[Cow::Borrowed("Empty enum")]), variants: Cow::Borrowed(&[]), }; @@ -79,7 +83,7 @@ fn empty_enum() { #[test] fn empty_struct() { let tpl = StructTemplate { - name: "Empty", + name: Cow::Borrowed("Empty"), docs: Cow::Borrowed(&[Cow::Borrowed("Empty struct")]), ty: TypeTemplate::Unit, }; @@ -91,7 +95,7 @@ fn empty_struct() { #[test] fn tuple_struct() { let tpl = StructTemplate { - name: "Tuple", + name: Cow::Borrowed("Tuple"), docs: Cow::Borrowed(&[Cow::Borrowed("Tuple struct")]), ty: TypeTemplate::Tuple(Cow::Borrowed(&[ Cow::Borrowed("u64"), @@ -106,7 +110,7 @@ fn tuple_struct() { #[test] fn named_struct() { let tpl = StructTemplate { - name: "Named", + name: Cow::Borrowed("Named"), docs: Cow::Borrowed(&[Cow::Borrowed("Named struct")]), ty: TypeTemplate::Named { fields: Cow::Borrowed(&[ 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 index 319a69340..d219e9437 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -5,12 +5,16 @@ expression: rendered #[doc = "Complex enum"] +#[cosmwasm_schema::cw_serde] pub enum Complex { #[doc = "One variant"] + + + One ( @@ -25,6 +29,9 @@ pub enum Complex { #[doc = "Two variant"] + + + Two { 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 index 180574367..876c882b0 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap @@ -5,6 +5,7 @@ expression: rendered #[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 index 9017b8729..6766ff832 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap @@ -5,6 +5,7 @@ expression: rendered #[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 index fec1e4721..f37ab2f6b 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap @@ -5,6 +5,7 @@ expression: rendered #[doc = "Named struct"] +#[cosmwasm_schema::cw_serde] pub struct Named 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 index 903298dca..c5d5dd0f9 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -5,12 +5,16 @@ expression: rendered #[doc = "Simple enum"] +#[cosmwasm_schema::cw_serde] pub enum Simple { #[doc = "One variant"] + + + One @@ -20,6 +24,9 @@ pub enum Simple { #[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 index 1d2dd2344..54d55450b 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap @@ -5,6 +5,7 @@ expression: rendered #[doc = "Tuple struct"] +#[cosmwasm_schema::cw_serde] pub struct Tuple From f7f567295874dc8a999fafa0b9583b4e4de862fb Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 30 Oct 2024 09:56:07 +0100 Subject: [PATCH 33/60] Fix Rust enums, add dummy modules for other languages --- Cargo.lock | 1 + packages/cw-schema-codegen/src/go/mod.rs | 1 + packages/cw-schema-codegen/src/go/template.rs | 9 +++++++++ packages/cw-schema-codegen/src/lib.rs | 2 ++ packages/cw-schema-codegen/src/main.rs | 7 +++++-- packages/cw-schema-codegen/src/typescript/mod.rs | 1 + packages/cw-schema-codegen/src/typescript/template.rs | 9 +++++++++ packages/cw-schema-codegen/templates/go/enum.tpl.go | 0 packages/cw-schema-codegen/templates/go/struct.tpl.go | 0 .../cw-schema-codegen/templates/typescript/enum.tpl.ts | 0 .../cw-schema-codegen/templates/typescript/struct.tpl.ts | 0 packages/cw-schema/src/lib.rs | 3 --- 12 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 packages/cw-schema-codegen/src/go/mod.rs create mode 100644 packages/cw-schema-codegen/src/go/template.rs create mode 100644 packages/cw-schema-codegen/src/typescript/mod.rs create mode 100644 packages/cw-schema-codegen/src/typescript/template.rs create mode 100644 packages/cw-schema-codegen/templates/go/enum.tpl.go create mode 100644 packages/cw-schema-codegen/templates/go/struct.tpl.go create mode 100644 packages/cw-schema-codegen/templates/typescript/enum.tpl.ts create mode 100644 packages/cw-schema-codegen/templates/typescript/struct.tpl.ts diff --git a/Cargo.lock b/Cargo.lock index b2f624b78..3f6175909 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -945,6 +945,7 @@ dependencies = [ "cw-schema", "either", "frunk", + "heck", "insta", "log", "serde_json", 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 000000000..612b5b95f --- /dev/null +++ b/packages/cw-schema-codegen/src/go/mod.rs @@ -0,0 +1 @@ +pub mod template; 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 000000000..ea807e3a2 --- /dev/null +++ b/packages/cw-schema-codegen/src/go/template.rs @@ -0,0 +1,9 @@ +use askama::Template; + +#[derive(Template)] +#[template(escape = "none", path = "go/enum.tpl.go")] +pub struct EnumTemplate {} + +#[derive(Template)] +#[template(escape = "none", path = "go/struct.tpl.go")] +pub struct StructTemplate {} diff --git a/packages/cw-schema-codegen/src/lib.rs b/packages/cw-schema-codegen/src/lib.rs index 0ad9e7d3d..b56983812 100644 --- a/packages/cw-schema-codegen/src/lib.rs +++ b/packages/cw-schema-codegen/src/lib.rs @@ -1 +1,3 @@ +pub mod go; pub mod rust; +pub mod typescript; diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index e93ddf72a..e10f534c7 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -62,8 +62,11 @@ fn main() -> anyhow::Result<()> { ensure!(opts.file.exists(), "Schema file does not exist"); ensure!( - opts.language == Language::Rust, - "Only Rust code generation is supported at the moment" + 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)?; 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 000000000..612b5b95f --- /dev/null +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -0,0 +1 @@ +pub mod template; 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 000000000..bee10e6fd --- /dev/null +++ b/packages/cw-schema-codegen/src/typescript/template.rs @@ -0,0 +1,9 @@ +use askama::Template; + +#[derive(Template)] +#[template(escape = "none", path = "typescript/enum.tpl.ts")] +pub struct EnumTemplate {} + +#[derive(Template)] +#[template(escape = "none", path = "typescript/struct.tpl.ts")] +pub struct StructTemplate {} 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 000000000..e69de29bb 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 000000000..e69de29bb 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 000000000..e69de29bb 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 000000000..e69de29bb diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index 9280abfb3..659e68e2f 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -31,7 +31,6 @@ pub struct StructProperty { #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", untagged)] -#[non_exhaustive] pub enum StructType { Unit, Named { @@ -56,7 +55,6 @@ pub struct EnumCase { #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", tag = "type")] -#[non_exhaustive] pub enum EnumValue { Unit, Named { @@ -71,7 +69,6 @@ pub enum EnumValue { #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", tag = "type")] -#[non_exhaustive] pub enum NodeType { // Floating point numbers Float, From f93d67c5b4f5203fa3fc96e1088daf9410d487c0 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 30 Oct 2024 15:46:49 +0100 Subject: [PATCH 34/60] WIP TypeScript codegen --- Cargo.lock | 1 + packages/cw-schema-codegen/Cargo.toml | 1 + packages/cw-schema-codegen/src/main.rs | 9 +- .../cw-schema-codegen/src/typescript/mod.rs | 144 ++++++++++++++++++ .../src/typescript/template.rs | 36 ++++- .../templates/rust/enum.tpl.rs | 6 +- .../templates/rust/struct.tpl.rs | 6 +- .../templates/typescript/enum.tpl.ts | 38 +++++ .../templates/typescript/struct.tpl.ts | 30 ++++ 9 files changed, 262 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f6175909..823804258 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -945,6 +945,7 @@ dependencies = [ "cw-schema", "either", "frunk", + "frunk_core", "heck", "insta", "log", diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index f31f233f9..aa004d950 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -12,6 +12,7 @@ clap = { version = "4.5.18", features = ["derive"] } cw-schema = { version = "=2.2.0-rc.1", path = "../cw-schema" } either = "1.13.0" frunk = "0.4.3" +frunk_core = "0.4.3" heck = "0.5.0" log = "0.4.22" serde_json = "1.0.128" diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index e10f534c7..7331768ef 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -79,7 +79,14 @@ fn main() -> anyhow::Result<()> { schema.definitions.iter().try_for_each(|node| { debug!("Processing node: {node:?}"); - cw_schema_codegen::rust::process_node(&mut output, &schema, node) + + match opts.language { + Language::Rust => cw_schema_codegen::rust::process_node(&mut output, &schema, node), + Language::Typescript => { + cw_schema_codegen::typescript::process_node(&mut output, &schema, node) + } + Language::Go | Language::Python => todo!(), + } })?; Ok(()) diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs index 612b5b95f..19c6d955a 100644 --- a/packages/cw-schema-codegen/src/typescript/mod.rs +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -1 +1,145 @@ +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 => "number".into(), + cw_schema::NodeType::Double => "number".into(), + cw_schema::NodeType::Boolean => "boolean".into(), + cw_schema::NodeType::String => "string".into(), + cw_schema::NodeType::Integer { signed, precision } => { + "string".into() + /*let ty = if signed { "i" } else { "u" }; + format!("{ty}{precision}").into()*/ + } + cw_schema::NodeType::Binary => "Uint8Array".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("{} | null", expand_node_name(schema, inner)).into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { ref items } => { + let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("[{}]", items).into() + } + cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + + cw_schema::NodeType::Decimal { precision, signed } => todo!(), + cw_schema::NodeType::Address => todo!(), + cw_schema::NodeType::Checksum => todo!(), + cw_schema::NodeType::HexBinary => todo!(), + cw_schema::NodeType::Timestamp => todo!(), + cw_schema::NodeType::Unit => Cow::Borrowed("void"), + } +} + +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.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/typescript/template.rs b/packages/cw-schema-codegen/src/typescript/template.rs index bee10e6fd..5ee51e9de 100644 --- a/packages/cw-schema-codegen/src/typescript/template.rs +++ b/packages/cw-schema-codegen/src/typescript/template.rs @@ -1,9 +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 = "typescript/enum.tpl.ts")] -pub struct EnumTemplate {} +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 = "typescript/struct.tpl.ts")] -pub struct StructTemplate {} +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/templates/rust/enum.tpl.rs b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs index e0768fef1..6898de1af 100644 --- a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -1,3 +1,5 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + {% for doc in docs %} #[doc = "{{ doc }}"] {% endfor %} @@ -20,9 +22,7 @@ pub enum {{ name }} { {% when TypeTemplate::Unit %} {% when TypeTemplate::Tuple with (types) %} ( - {% for ty in types %} - {{ ty }}, - {% endfor %} + {{ types|join(", ") }} ) {% when TypeTemplate::Named with { fields } %} { diff --git a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs index 87173daa9..3d2f8a005 100644 --- a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs @@ -1,3 +1,5 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + {% for doc in docs %} #[doc = "{{ doc }}"] {% endfor %} @@ -10,9 +12,7 @@ pub struct {{ name }} ; {% when TypeTemplate::Tuple with (types) %} ( - {% for ty in types %} - {{ ty }}, - {% endfor %} + {{ types|join(", ") }} ); {% when TypeTemplate::Named with { fields } %} { diff --git a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts index e69de29bb..8ab50d8e6 100644 --- a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts @@ -0,0 +1,38 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +/** +{% for doc in docs %} + * {{ doc }} +{% endfor %} + */ + +type {{ name }} = +{% for variant in variants %} + | + + /** + {% for doc in variant.docs %} + * {{ doc }} + {% endfor %} + */ + + {% match variant.ty %} + {% when TypeTemplate::Unit %} + { "{{ variant.name }}": {} } + {% when TypeTemplate::Tuple with (types) %} + { "{{ variant.name }}": [{{ types|join(", ") }}] } + {% when TypeTemplate::Named with { fields } %} + { "{{ variant.name }}": { + {% for field in fields %} + /** + {% for doc in field.docs %} + * {{ doc }} + {% endfor %} + */ + + {{ field.name }}: {{ field.ty }}; + {% endfor %} + } } + {% endmatch %} +{% endfor %} +; \ No newline at end of file diff --git a/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts index e69de29bb..8d7eb0a4f 100644 --- a/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts @@ -0,0 +1,30 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +/** +{% for doc in docs %} + * {{ doc }} +{% endfor %} + */ + +type {{ name }} = +{% match ty %} + {% when TypeTemplate::Unit %} + void + {% when TypeTemplate::Tuple with (types) %} + [{{ types|join(", ") }}] + {% when TypeTemplate::Named with { fields } %} + { + {% for field in fields %} + /** + {% for doc in field.docs %} + * {{ doc }} + {% endfor %} + */ + + {{ field.name }}: {{ field.ty }}; + {% endfor %} + } +{% endmatch %} +; + +export { {{ name }} }; From 386a467cdefaf771c63583099e65153d91785cd6 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 30 Oct 2024 16:06:08 +0100 Subject: [PATCH 35/60] Export enum type in TypeScript --- packages/cw-schema-codegen/templates/typescript/enum.tpl.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts index 8ab50d8e6..f2b897ccf 100644 --- a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts @@ -35,4 +35,6 @@ type {{ name }} = } } {% endmatch %} {% endfor %} -; \ No newline at end of file +; + +export { {{ name }} }; From 08d06c4eb08a945326748d8a275aad65a537614a Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 4 Nov 2024 15:46:34 +0100 Subject: [PATCH 36/60] Deserialize the full CosmWasm API definition --- Cargo.lock | 1 + packages/cw-schema-codegen/Cargo.toml | 1 + packages/cw-schema-codegen/src/main.rs | 72 +++++++++++++++---- packages/cw-schema-codegen/src/rust/mod.rs | 6 +- .../cw-schema-codegen/src/typescript/mod.rs | 18 ++--- packages/cw-schema/src/lib.rs | 16 ++--- packages/schema/src/idl.rs | 20 +++--- packages/schema/src/lib.rs | 3 + 8 files changed, 90 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 823804258..8549fb989 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -942,6 +942,7 @@ dependencies = [ "anyhow", "askama", "clap", + "cosmwasm-schema", "cw-schema", "either", "frunk", diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index aa004d950..5acc60be6 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -9,6 +9,7 @@ publish = false anyhow = "1.0.89" askama = { version = "0.12.1", default-features = false } clap = { version = "4.5.18", features = ["derive"] } +cosmwasm-schema = { version = "=2.2.0-rc.1", path = "../schema" } cw-schema = { version = "=2.2.0-rc.1", path = "../cw-schema" } either = "1.13.0" frunk = "0.4.3" diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index 7331768ef..86cd7a2b4 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -6,6 +6,7 @@ extern crate log; use clap::{Parser, ValueEnum}; use std::{ + collections::HashSet, fs::{self, File}, io::{self, Write}, path::PathBuf, @@ -49,9 +50,38 @@ impl Opts { } } +fn generate_defs( + output: &mut W, + language: Language, + schema: &cw_schema::Schema, +) -> 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) + } + Language::Go | Language::Python => todo!(), + } + })?; + + Ok(()) +} + fn main() -> anyhow::Result<()> { simple_logger::SimpleLogger::new() .without_timestamps() + .with_level(log::LevelFilter::Info) + .env() .init()?; let opts: Opts = Opts::parse(); @@ -70,24 +100,40 @@ fn main() -> anyhow::Result<()> { ); let schema = fs::read_to_string(&opts.file)?; - let schema: cw_schema::Schema = serde_json::from_str(&schema)?; - let cw_schema::Schema::V1(schema) = schema else { - bail!("Unsupported schema version"); - }; + let schema: cosmwasm_schema::JsonCwApi = serde_json::from_str(&schema)?; let mut output = opts.output()?; - schema.definitions.iter().try_for_each(|node| { - debug!("Processing node: {node:?}"); + if let Some(ref instantiate) = schema.instantiate { + generate_defs(&mut output, opts.language, instantiate)?; + } - match opts.language { - Language::Rust => cw_schema_codegen::rust::process_node(&mut output, &schema, node), - Language::Typescript => { - cw_schema_codegen::typescript::process_node(&mut output, &schema, node) - } - Language::Go | Language::Python => todo!(), + if let Some(ref execute) = schema.execute { + generate_defs(&mut output, opts.language, execute)?; + } + + if let Some(ref query) = schema.query { + generate_defs(&mut output, opts.language, query)?; + } + + if let Some(ref migrate) = schema.migrate { + generate_defs(&mut output, opts.language, migrate)?; + } + + if let Some(ref sudo) = schema.sudo { + generate_defs(&mut output, opts.language, sudo)?; + } + + 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)?; } - })?; + } Ok(()) } diff --git a/packages/cw-schema-codegen/src/rust/mod.rs b/packages/cw-schema-codegen/src/rust/mod.rs index 95c5ac2aa..4f2dc307c 100644 --- a/packages/cw-schema-codegen/src/rust/mod.rs +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -41,10 +41,10 @@ fn expand_node_name<'a>( cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), cw_schema::NodeType::Decimal { precision, signed } => todo!(), - cw_schema::NodeType::Address => todo!(), - cw_schema::NodeType::Checksum => todo!(), + cw_schema::NodeType::Address => "cosmrs::AccountId".into(), + cw_schema::NodeType::Checksum => "cosmrs::tendermint::Hash".into(), cw_schema::NodeType::HexBinary => todo!(), - cw_schema::NodeType::Timestamp => todo!(), + cw_schema::NodeType::Timestamp => "cosmrs::tendermint::Time".into(), cw_schema::NodeType::Unit => Cow::Borrowed("()"), } } diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs index 19c6d955a..74f3d9e00 100644 --- a/packages/cw-schema-codegen/src/typescript/mod.rs +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -19,11 +19,7 @@ fn expand_node_name<'a>( cw_schema::NodeType::Double => "number".into(), cw_schema::NodeType::Boolean => "boolean".into(), cw_schema::NodeType::String => "string".into(), - cw_schema::NodeType::Integer { signed, precision } => { - "string".into() - /*let ty = if signed { "i" } else { "u" }; - format!("{ty}{precision}").into()*/ - } + cw_schema::NodeType::Integer { .. } => "string".into(), cw_schema::NodeType::Binary => "Uint8Array".into(), cw_schema::NodeType::Optional { inner } => { let inner = &schema.definitions[inner]; @@ -41,8 +37,8 @@ fn expand_node_name<'a>( } cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), - cw_schema::NodeType::Decimal { precision, signed } => todo!(), - cw_schema::NodeType::Address => todo!(), + cw_schema::NodeType::Decimal { .. } => "string".into(), + cw_schema::NodeType::Address => "string".into(), cw_schema::NodeType::Checksum => todo!(), cw_schema::NodeType::HexBinary => todo!(), cw_schema::NodeType::Timestamp => todo!(), @@ -51,12 +47,8 @@ fn expand_node_name<'a>( } fn prepare_docs(desc: Option<&str>) -> Cow<'_, [Cow<'_, str>]> { - desc.map(|desc| { - desc.lines() - .map(|line| line.replace('"', "\\\"").into()) - .collect() - }) - .unwrap_or(Cow::Borrowed(&[])) + desc.map(|desc| desc.lines().map(Into::into).collect()) + .unwrap_or(Cow::Borrowed(&[])) } pub fn process_node( diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index 659e68e2f..8aaa809b9 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -19,7 +19,7 @@ pub type DefinitionReference = usize; mod default_impls; #[skip_serializing_none] -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct StructProperty { @@ -28,7 +28,7 @@ pub struct StructProperty { } #[skip_serializing_none] -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", untagged)] pub enum StructType { @@ -42,7 +42,7 @@ pub enum StructType { } #[skip_serializing_none] -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct EnumCase { @@ -52,7 +52,7 @@ pub struct EnumCase { } #[skip_serializing_none] -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", tag = "type")] pub enum EnumValue { @@ -66,7 +66,7 @@ pub enum EnumValue { } #[skip_serializing_none] -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", tag = "type")] pub enum NodeType { @@ -113,7 +113,7 @@ pub enum NodeType { } #[skip_serializing_none] -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct Node { @@ -124,7 +124,7 @@ pub struct Node { } #[skip_serializing_none] -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase")] pub struct SchemaV1 { @@ -133,7 +133,7 @@ pub struct SchemaV1 { } #[skip_serializing_none] -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "std", derive(::schemars::JsonSchema))] #[serde(rename_all = "camelCase", tag = "type")] #[non_exhaustive] diff --git a/packages/schema/src/idl.rs b/packages/schema/src/idl.rs index 9f838fbcf..6177636d6 100644 --- a/packages/schema/src/idl.rs +++ b/packages/schema/src/idl.rs @@ -98,17 +98,17 @@ impl Api { } /// A JSON representation of a contract's API. -#[derive(serde::Serialize)] +#[derive(serde::Deserialize, serde::Serialize)] pub struct JsonCwApi { - contract_name: String, - contract_version: String, - idl_version: String, - instantiate: Option, - execute: Option, - query: Option, - migrate: Option, - sudo: Option, - responses: Option>, + 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 { diff --git a/packages/schema/src/lib.rs b/packages/schema/src/lib.rs index 9b5381d08..628eb1ed3 100644 --- a/packages/schema/src/lib.rs +++ b/packages/schema/src/lib.rs @@ -97,3 +97,6 @@ pub use cosmwasm_schema_derive::write_api; pub use cw_schema; pub use schemars; pub use serde; + +#[doc(hidden)] +pub use self::idl::JsonCwApi; From 5b7caf0c068c7e176411bd2ae3a45771a55b9a01 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 12 Nov 2024 15:12:00 +0100 Subject: [PATCH 37/60] Add some TypeScript snapshots --- packages/cw-schema-codegen/Cargo.toml | 1 + packages/cw-schema-codegen/build.rs | 3 + packages/cw-schema-codegen/src/go/template.rs | 36 +++++++++++- .../templates/go/enum.tpl.go | 2 + .../templates/go/struct.tpl.go | 21 +++++++ .../templates/typescript/enum.tpl.ts | 4 ++ .../snapshots/rust_tpl__complex_enum.snap | 7 ++- .../tests/snapshots/rust_tpl__empty_enum.snap | 3 + .../snapshots/rust_tpl__empty_struct.snap | 3 + .../snapshots/rust_tpl__named_struct.snap | 3 + .../snapshots/rust_tpl__simple_enum.snap | 3 + .../snapshots/rust_tpl__tuple_struct.snap | 9 ++- .../snapshots/typescript__codegen_snap-2.snap | 17 ++++++ .../snapshots/typescript__codegen_snap-3.snap | 17 ++++++ .../snapshots/typescript__codegen_snap-4.snap | 19 +++++++ .../snapshots/typescript__codegen_snap-5.snap | 55 +++++++++++++++++++ .../snapshots/typescript__codegen_snap.snap | 31 +++++++++++ .../cw-schema-codegen/tests/typescript.rs | 54 ++++++++++++++++++ 18 files changed, 278 insertions(+), 10 deletions(-) create mode 100644 packages/cw-schema-codegen/build.rs create mode 100644 packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap create mode 100644 packages/cw-schema-codegen/tests/typescript.rs diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index 5acc60be6..afc6d6987 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -4,6 +4,7 @@ authors = ["Aumetra Weisman "] edition = "2021" version.workspace = true publish = false +build = "build.rs" [dependencies] anyhow = "1.0.89" diff --git a/packages/cw-schema-codegen/build.rs b/packages/cw-schema-codegen/build.rs new file mode 100644 index 000000000..73f98cda4 --- /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/template.rs b/packages/cw-schema-codegen/src/go/template.rs index ea807e3a2..90c02e1b2 100644 --- a/packages/cw-schema-codegen/src/go/template.rs +++ b/packages/cw-schema-codegen/src/go/template.rs @@ -1,9 +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 = "go/enum.tpl.go")] -pub struct EnumTemplate {} +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 = "go/struct.tpl.go")] -pub struct StructTemplate {} +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/templates/go/enum.tpl.go b/packages/cw-schema-codegen/templates/go/enum.tpl.go index e69de29bb..ec0d54cc8 100644 --- a/packages/cw-schema-codegen/templates/go/enum.tpl.go +++ b/packages/cw-schema-codegen/templates/go/enum.tpl.go @@ -0,0 +1,2 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + diff --git a/packages/cw-schema-codegen/templates/go/struct.tpl.go b/packages/cw-schema-codegen/templates/go/struct.tpl.go index e69de29bb..48b420e7f 100644 --- a/packages/cw-schema-codegen/templates/go/struct.tpl.go +++ b/packages/cw-schema-codegen/templates/go/struct.tpl.go @@ -0,0 +1,21 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +package cwcodegen + +{% for doc in docs %} + // {{ doc }} +{% endfor %} +type {{ name }} struct { + {% match ty %} + {% when TypeTemplate::Unit %} + {% when TypeTemplate::Tuple with (types) %} + {{ todo!() }} + {% when TypeTemplate::Named with { fields } %} + {% for field in fields %} + {% for doc in docs %} + // {{ doc }} + {% endfor %} + {{ field.name|capitalize }} {{ field.ty }} `json:"{{ field.name }}"` + {% endfor %} + {% endmatch %} +} diff --git a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts index f2b897ccf..70c675385 100644 --- a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts @@ -35,6 +35,10 @@ type {{ name }} = } } {% endmatch %} {% endfor %} + +{% if variants.len() == 0 %} + never; +{% endif %} ; export { {{ name }} }; 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 index d219e9437..00c3725ff 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + #[doc = "Complex enum"] @@ -18,9 +21,7 @@ pub enum Complex { One ( - - u64, - + u64 ) , 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 index 876c882b0..8e97ca0d4 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + #[doc = "Empty enum"] 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 index 6766ff832..be4cd9a49 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + #[doc = "Empty struct"] 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 index f37ab2f6b..b6d3ba954 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + #[doc = "Named struct"] 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 index c5d5dd0f9..7d5b52b2e 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + #[doc = "Simple enum"] 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 index 54d55450b..90eff5f1c 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap @@ -2,6 +2,9 @@ source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered --- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + #[doc = "Tuple struct"] @@ -10,9 +13,5 @@ pub struct Tuple ( - - u64, - - String, - + 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 000000000..7cfb7b4a7 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap @@ -0,0 +1,17 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +/** + + */ + +type Uwu = + + [string, string] + +; + +export { Uwu }; 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 000000000..c13999ac2 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap @@ -0,0 +1,17 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +/** + + */ + +type Òwó = + + void + +; + +export { Òwó }; 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 000000000..9f0cb760f --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap @@ -0,0 +1,19 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +/** + + */ + +type Empty = + + + + never; + +; + +export { Empty }; 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 000000000..5bd7258ec --- /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. + +/** + + */ + +type Hehehe = + + | + + /** + + */ + + + { "A": {} } + + + | + + /** + + */ + + + { "B": [string] } + + + | + + /** + + */ + + + { "C": { + + /** + + */ + + field: string; + + } } + + + + +; + +export { Hehehe }; 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 000000000..b36d30ea3 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap @@ -0,0 +1,31 @@ +--- +source: packages/cw-schema-codegen/tests/typescript.rs +expression: output +--- +// This code is @generated by cw-schema-codegen. Do not modify this manually. + +/** + + */ + +type Owo = + + { + + /** + + */ + + field_1: string; + + /** + + */ + + field_2: string; + + } + +; + +export { Owo }; diff --git a/packages/cw-schema-codegen/tests/typescript.rs b/packages/cw-schema-codegen/tests/typescript.rs new file mode 100644 index 000000000..11cb4fff4 --- /dev/null +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -0,0 +1,54 @@ +use cw_schema::Schemaifier; + +#[derive(Schemaifier)] +struct Owo { + field_1: u32, + field_2: String, +} + +#[derive(Schemaifier)] +struct Uwu(String, u32); + +#[derive(Schemaifier)] +struct Òwó; + +#[derive(Schemaifier)] +enum Empty {} + +#[derive(Schemaifier)] +enum Hehehe { + A, + B(u32), + C { field: String }, +} + +#[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).unwrap(); + String::from_utf8(buf).unwrap() + }) + .collect::(); + + insta::assert_snapshot!(output); + } +} From d91cd1bc3a33be4b7ae819c4ea675716b3036fd6 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 12 Nov 2024 15:24:27 +0100 Subject: [PATCH 38/60] More robust non-static type equality --- packages/cw-schema/src/lib.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index 8aaa809b9..b0e80c2c9 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -6,7 +6,7 @@ extern crate alloc; extern crate std; use alloc::{borrow::Cow, collections::BTreeMap, vec::Vec}; -use core::hash::BuildHasherDefault; +use core::{any::TypeId, hash::BuildHasherDefault, marker::PhantomData}; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; @@ -142,27 +142,32 @@ pub enum Schema { } #[derive(Hash, PartialEq, Eq)] -pub struct Identifier(usize); +pub struct Identifier(TypeId); impl Identifier { pub fn of() -> Self where T: ?Sized, { - // Don't do this at home. I'm a professional. + // Taken from : https://github.com/sagebind/castaway/blob/a7baeab32d75d0f105d1415210a2867d213f8818/src/utils.rs#L36 // - // This is a hack based on the assumption that each type has will produce a unique monomorphized function. - // Therefore each function has a distinct function pointer. - // - // The compiler _might_ break this assumption in the future. - #[inline] - fn type_id_of() -> usize { - type_id_of:: as usize + // 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::() + } } - debug_assert_eq!(type_id_of::(), type_id_of::()); + let phantom = PhantomData::; + let ty_id = NonStaticAny::get_type_id(unsafe { + core::mem::transmute::<&dyn NonStaticAny, &(dyn NonStaticAny + 'static)>(&phantom) + }); - Self(type_id_of::()) + Identifier(ty_id) } } From 4de3214de7eb1cd3fd9976d97ef1e8103a0e3d90 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 12 Nov 2024 15:59:40 +0100 Subject: [PATCH 39/60] Add TypeScript compile checks --- Cargo.lock | 21 ++++--- packages/cw-schema-codegen/Cargo.toml | 3 + .../cw-schema-codegen/src/typescript/mod.rs | 1 - .../cw-schema-codegen/tests/typescript.rs | 58 +++++++++++++++++-- packages/cw-schema-derive/src/expand.rs | 2 + packages/cw-schema/src/lib.rs | 10 +++- 6 files changed, 77 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8549fb989..8ef3cf348 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -950,8 +950,10 @@ dependencies = [ "heck", "insta", "log", + "serde", "serde_json", "simple_logger", + "tempfile", ] [[package]] @@ -1282,9 +1284,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" @@ -1659,9 +1661,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" @@ -2328,9 +2330,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", @@ -2707,14 +2709,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]] diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index afc6d6987..6f9e6c7d0 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -22,3 +22,6 @@ simple_logger = { version = "5.0.0", features = ["stderr"] } [dev-dependencies] insta = "1.40.0" +serde = { workspace = true, features = ["derive"] } +serde_json = "1.0.128" +tempfile = "3.14.0" diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs index 74f3d9e00..fba8e3e7a 100644 --- a/packages/cw-schema-codegen/src/typescript/mod.rs +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -1,7 +1,6 @@ use self::template::{ EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, }; -use heck::ToPascalCase; use std::{borrow::Cow, io}; pub mod template; diff --git a/packages/cw-schema-codegen/tests/typescript.rs b/packages/cw-schema-codegen/tests/typescript.rs index 11cb4fff4..c19fd9d07 100644 --- a/packages/cw-schema-codegen/tests/typescript.rs +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -1,21 +1,23 @@ use cw_schema::Schemaifier; +use serde::Serialize; +use std::io::Write; -#[derive(Schemaifier)] +#[derive(Schemaifier, Serialize)] struct Owo { field_1: u32, field_2: String, } -#[derive(Schemaifier)] +#[derive(Schemaifier, Serialize)] struct Uwu(String, u32); -#[derive(Schemaifier)] +#[derive(Schemaifier, Serialize)] struct Òwó; -#[derive(Schemaifier)] +#[derive(Schemaifier, Serialize)] enum Empty {} -#[derive(Schemaifier)] +#[derive(Schemaifier, Serialize)] enum Hehehe { A, B(u32), @@ -52,3 +54,49 @@ fn codegen_snap() { insta::assert_snapshot!(output); } } + +#[test] +fn assert_validity() { + let schemas = [ + cw_schema::schema_of::(), + cw_schema::schema_of::(), + cw_schema::schema_of::<Òwó>(), + cw_schema::schema_of::(), + cw_schema::schema_of::(), + ]; + + for schema 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).unwrap(); + String::from_utf8(buf).unwrap() + }) + .collect::(); + + let mut file = tempfile::NamedTempFile::with_suffix(".ts").unwrap(); + file.write_all(output.as_bytes()).unwrap(); + file.flush().unwrap(); + + let output = std::process::Command::new("npx") + .arg("--package=typescript") + .arg("--") + .arg("tsc") + .arg(file.path()) + .output() + .unwrap(); + + assert!( + output.status.success(), + "stdout: {stdout}, stderr: {stderr}", + stdout = String::from_utf8_lossy(&output.stdout), + stderr = String::from_utf8_lossy(&output.stderr) + ); + } +} diff --git a/packages/cw-schema-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs index a06646138..e724797fb 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -375,6 +375,7 @@ fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result #crate_path::DefinitionReference { let node = #crate_path::Node { @@ -461,6 +462,7 @@ fn expand_struct(mut meta: ContainerMeta, input: DataStruct) -> syn::Result #crate_path::DefinitionReference { let node = { diff --git a/packages/cw-schema/src/lib.rs b/packages/cw-schema/src/lib.rs index b0e80c2c9..0e1c2c339 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -153,11 +153,16 @@ impl Identifier { // // Seems more robust than the previous implementation. trait NonStaticAny { - fn get_type_id(&self) -> TypeId where Self: 'static; + fn get_type_id(&self) -> TypeId + where + Self: 'static; } impl NonStaticAny for PhantomData { - fn get_type_id(&self) -> TypeId where Self: 'static { + fn get_type_id(&self) -> TypeId + where + Self: 'static, + { TypeId::of::() } } @@ -198,7 +203,6 @@ impl SchemaVisitor { } pub trait Schemaifier { - #[doc(hidden)] fn id() -> Identifier { Identifier::of::() } From 6c6e2ad68da1ff12536e8650ab1fcc91cf2ab174 Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Wed, 6 Nov 2024 08:17:03 +0100 Subject: [PATCH 40/60] feat: Python codegen init --- packages/cw-schema-codegen/src/lib.rs | 1 + packages/cw-schema-codegen/src/main.rs | 3 +- packages/cw-schema-codegen/src/python/mod.rs | 137 ++++++++++++++++++ .../cw-schema-codegen/src/python/template.rs | 41 ++++++ .../templates/python/enum.tpl.py | 40 +++++ .../templates/python/struct.tpl.py | 30 ++++ .../snapshots/rust_tpl__complex_enum.snap | 1 + .../tests/snapshots/rust_tpl__empty_enum.snap | 1 + .../snapshots/rust_tpl__empty_struct.snap | 1 + .../snapshots/rust_tpl__named_struct.snap | 1 + .../snapshots/rust_tpl__simple_enum.snap | 1 + .../snapshots/rust_tpl__tuple_struct.snap | 1 + 12 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 packages/cw-schema-codegen/src/python/mod.rs create mode 100644 packages/cw-schema-codegen/src/python/template.rs create mode 100644 packages/cw-schema-codegen/templates/python/enum.tpl.py create mode 100644 packages/cw-schema-codegen/templates/python/struct.tpl.py diff --git a/packages/cw-schema-codegen/src/lib.rs b/packages/cw-schema-codegen/src/lib.rs index b56983812..224f90fb8 100644 --- a/packages/cw-schema-codegen/src/lib.rs +++ b/packages/cw-schema-codegen/src/lib.rs @@ -1,3 +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 index 86cd7a2b4..b8038d315 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -70,7 +70,8 @@ where Language::Typescript => { cw_schema_codegen::typescript::process_node(output, schema, node) } - Language::Go | Language::Python => todo!(), + Language::Python => cw_schema_codegen::python::process_node(output, schema, node), + Language::Go => todo!(), } })?; 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 000000000..74f3d9e00 --- /dev/null +++ b/packages/cw-schema-codegen/src/python/mod.rs @@ -0,0 +1,137 @@ +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 => "number".into(), + cw_schema::NodeType::Double => "number".into(), + cw_schema::NodeType::Boolean => "boolean".into(), + cw_schema::NodeType::String => "string".into(), + cw_schema::NodeType::Integer { .. } => "string".into(), + cw_schema::NodeType::Binary => "Uint8Array".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("{} | null", expand_node_name(schema, inner)).into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { ref items } => { + let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("[{}]", items).into() + } + cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + + cw_schema::NodeType::Decimal { .. } => "string".into(), + cw_schema::NodeType::Address => "string".into(), + cw_schema::NodeType::Checksum => todo!(), + cw_schema::NodeType::HexBinary => todo!(), + cw_schema::NodeType::Timestamp => todo!(), + cw_schema::NodeType::Unit => Cow::Borrowed("void"), + } +} + +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 000000000..11b860ed9 --- /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/templates/python/enum.tpl.py b/packages/cw-schema-codegen/templates/python/enum.tpl.py new file mode 100644 index 000000000..21ee91261 --- /dev/null +++ b/packages/cw-schema-codegen/templates/python/enum.tpl.py @@ -0,0 +1,40 @@ +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +/** +{% for doc in docs %} + * {{ doc }} +{% endfor %} + */ + +type {{ name }} = +{% for variant in variants %} + | + + /** + {% for doc in variant.docs %} + * {{ doc }} + {% endfor %} + */ + + {% match variant.ty %} + {% when TypeTemplate::Unit %} + { "{{ variant.name }}": {} } + {% when TypeTemplate::Tuple with (types) %} + { "{{ variant.name }}": [{{ types|join(", ") }}] } + {% when TypeTemplate::Named with { fields } %} + { "{{ variant.name }}": { + {% for field in fields %} + /** + {% for doc in field.docs %} + * {{ doc }} + {% endfor %} + */ + + {{ field.name }}: {{ field.ty }}; + {% endfor %} + } } + {% endmatch %} +{% endfor %} +; + +export { {{ name }} }; 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 000000000..08b30d5d4 --- /dev/null +++ b/packages/cw-schema-codegen/templates/python/struct.tpl.py @@ -0,0 +1,30 @@ +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +/** +{% for doc in docs %} + * {{ doc }} +{% endfor %} + */ + +type {{ name }} = +{% match ty %} + {% when TypeTemplate::Unit %} + void + {% when TypeTemplate::Tuple with (types) %} + [{{ types|join(", ") }}] + {% when TypeTemplate::Named with { fields } %} + { + {% for field in fields %} + /** + {% for doc in field.docs %} + * {{ doc }} + {% endfor %} + */ + + {{ field.name }}: {{ field.ty }}; + {% endfor %} + } +{% endmatch %} +; + +export { {{ name }} }; 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 index 00c3725ff..e1c4a9758 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -1,6 +1,7 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered +snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. 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 index 8e97ca0d4..cb79d1753 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap @@ -1,6 +1,7 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered +snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. 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 index be4cd9a49..3103d42b2 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap @@ -1,6 +1,7 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered +snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. 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 index b6d3ba954..dd3525ae0 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap @@ -1,6 +1,7 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered +snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. 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 index 7d5b52b2e..e7ed6b8cf 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -1,6 +1,7 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered +snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. 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 index 90eff5f1c..358693556 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap @@ -1,6 +1,7 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered +snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. From fc490791b57150c99b63cfab3b4b7eb2bcafc30f Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Fri, 8 Nov 2024 08:11:23 +0100 Subject: [PATCH 41/60] feat: Add Python codegen --- Cargo.toml | 2 +- .../cw-schema-codegen/playground/.gitignore | 1 + .../cw-schema-codegen/playground/Cargo.lock | 96 ++++++++++++++ .../cw-schema-codegen/playground/Cargo.toml | 11 ++ .../playground/playground.py | 119 ++++++++++++++++++ .../cw-schema-codegen/playground/src/main.rs | 59 +++++++++ packages/cw-schema-codegen/playground/test.sh | 1 + packages/cw-schema-codegen/src/python/mod.rs | 3 + .../templates/python/enum.tpl.py | 60 ++++----- .../templates/python/struct.tpl.py | 29 ++++- .../cw-schema-codegen/tests/python_tpl.rs | 29 +++++ .../snapshots/python_tpl__simple_enum.snap | 42 +++++++ 12 files changed, 421 insertions(+), 31 deletions(-) create mode 100644 packages/cw-schema-codegen/playground/.gitignore create mode 100644 packages/cw-schema-codegen/playground/Cargo.lock create mode 100644 packages/cw-schema-codegen/playground/Cargo.toml create mode 100644 packages/cw-schema-codegen/playground/playground.py create mode 100644 packages/cw-schema-codegen/playground/src/main.rs create mode 100755 packages/cw-schema-codegen/playground/test.sh create mode 100644 packages/cw-schema-codegen/tests/python_tpl.rs create mode 100644 packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap diff --git a/Cargo.toml b/Cargo.toml index c94fa1046..c06f9b080 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = ["packages/*"] -exclude = ["contracts"] +exclude = ["contracts", "packages/cw-schema-codegen/playground"] # Resolver has to be set explicitly in workspaces # due to https://github.com/rust-lang/cargo/issues/9956 diff --git a/packages/cw-schema-codegen/playground/.gitignore b/packages/cw-schema-codegen/playground/.gitignore new file mode 100644 index 000000000..ea8c4bf7f --- /dev/null +++ b/packages/cw-schema-codegen/playground/.gitignore @@ -0,0 +1 @@ +/target diff --git a/packages/cw-schema-codegen/playground/Cargo.lock b/packages/cw-schema-codegen/playground/Cargo.lock new file mode 100644 index 000000000..867ff0bae --- /dev/null +++ b/packages/cw-schema-codegen/playground/Cargo.lock @@ -0,0 +1,96 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "proc-macro2" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serialization" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "syn" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" diff --git a/packages/cw-schema-codegen/playground/Cargo.toml b/packages/cw-schema-codegen/playground/Cargo.toml new file mode 100644 index 000000000..a5aa7ba8f --- /dev/null +++ b/packages/cw-schema-codegen/playground/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "serialization" +version = "0.1.0" +edition = "2021" + +[features] +deserialize = [] + +[dependencies] +serde = { version = "1.0.215", features = ["derive", "serde_derive"] } +serde_json = "1.0.133" diff --git a/packages/cw-schema-codegen/playground/playground.py b/packages/cw-schema-codegen/playground/playground.py new file mode 100644 index 000000000..ac850f87d --- /dev/null +++ b/packages/cw-schema-codegen/playground/playground.py @@ -0,0 +1,119 @@ +from dataclasses import dataclass, field +from dataclasses_json import dataclass_json, config +from typing import Optional, Iterable +import sys +import json + + +# TODO tkulik: try to get rid of the `dataclasses_json` dependency + + +enum_field = lambda: field(default=None, metadata=config(exclude=lambda x: x is None)) + +@dataclass_json +@dataclass +class SomeEnum: + class VariantIndicator: + pass + + class Field3Type: + a: str + b: int + + class Field5Type: + a: Iterable['SomeEnum'] + + Field1: Optional[VariantIndicator] = enum_field() + Field2: Optional[tuple[int, int]] = enum_field() + Field3: Optional[Field3Type] = enum_field() + Field4: Optional[Iterable['SomeEnum']] = enum_field() + Field5: Optional[Field5Type] = enum_field() + + def deserialize(json): + if not ":" in json: + if json == '"Field1"': + return SomeEnum(Field1=SomeEnum.VariantIndicator()) + else: + raise Exception(f"Deserialization error, undefined variant: {json}") + else: + return SomeEnum.from_json(json) + + def serialize(self): + if self.Field1 is not None: + return '"Field1"' + else: + return SomeEnum.to_json(self) + +@dataclass_json +@dataclass +class UnitStructure: + def deserialize(json): + if json == "null": + return UnitStructure() + else: + Exception(f"Deserialization error, undefined value: {json}") + + def serialize(self): + return 'null' + +@dataclass_json +@dataclass +class TupleStructure: + Tuple: tuple[int, str, int] + + def deserialize(json): + return TupleStructure.from_json(f'{{ "Tuple": {json} }}') + + def serialize(self): + return json.dumps(self.Tuple) + +@dataclass_json +@dataclass +class NamedStructure: + a: str + b: int + c: Iterable['SomeEnum'] + + def deserialize(json): + return NamedStructure.from_json(json) + + def serialize(self): + return self.to_json() + +### +### TESTS: +### + +for (index, input) in enumerate(sys.stdin): + input = input.rstrip() + try: + if index < 5: + deserialized = SomeEnum.deserialize(input) + elif index == 5: + deserialized = UnitStructure.deserialize(input) + elif index == 6: + deserialized = TupleStructure.deserialize(input) + else: + deserialized = NamedStructure.deserialize(input) + except: + raise(Exception(f"This json can't be deserialized: {input}")) + serialized = deserialized.serialize() + print(serialized) + + +# def handle_msg(json): +# a = SomeEnum.deserialize(json) +# if a.Field1 is not None: +# print("SomeEnum::Field1") +# elif a.Field2 is not None: +# print(a.Field2[0]) +# print(a.Field2[1]) +# elif a.Field3 is not None: +# print(a.Field3) +# elif a.Field4 is not None: +# print(a.Field4) +# elif a.Field5 is not None: +# print(a.Field5) + +# handle_msg('"Field1"') +# handle_msg('{"Field2": [10, 12]}') \ No newline at end of file diff --git a/packages/cw-schema-codegen/playground/src/main.rs b/packages/cw-schema-codegen/playground/src/main.rs new file mode 100644 index 000000000..747e7ab89 --- /dev/null +++ b/packages/cw-schema-codegen/playground/src/main.rs @@ -0,0 +1,59 @@ + +use serde::{Deserialize, Serialize}; + + +#[derive(Serialize, Deserialize)] +pub enum SomeEnum { + Field1, + Field2(u32, u32), + Field3 { + a: String, + b: u32 + }, + Field4(Box), + Field5 { a: Box }, +} + +#[derive(Serialize, Deserialize)] +pub struct UnitStructure; + +#[derive(Serialize, Deserialize)] +pub struct TupleStructure(u32, String, u128); + +#[derive(Serialize, Deserialize)] +pub struct NamedStructure { + a: String, + b: u8, + c: SomeEnum +} + + +#[cfg(not(feature = "deserialize"))] +fn main() { + println!("{}", serde_json::to_string(&SomeEnum::Field1).unwrap()); + println!("{}", serde_json::to_string(&SomeEnum::Field2(10, 23)).unwrap()); + println!("{}", serde_json::to_string(&SomeEnum::Field3 {a: "sdf".to_string(), b: 12}).unwrap()); + println!("{}", serde_json::to_string(&SomeEnum::Field4(Box::new(SomeEnum::Field1))).unwrap()); + println!("{}", serde_json::to_string(&SomeEnum::Field5 { a: Box::new(SomeEnum::Field1) }).unwrap()); + println!("{}", serde_json::to_string(&UnitStructure {}).unwrap()); + println!("{}", serde_json::to_string(&TupleStructure(10, "aasdf".to_string(), 2)).unwrap()); + println!("{}", serde_json::to_string(&NamedStructure {a: "awer".to_string(), b: 4, c: SomeEnum::Field1}).unwrap()); +} + +#[cfg(feature = "deserialize")] +fn main() { + use std::io::BufRead; + for (index, line) in std::io::BufReader::new(std::io::stdin()).lines().enumerate() { + let line = line.unwrap(); + println!("{line}"); + if index < 5 { + let _: SomeEnum = serde_json::from_str(&line).unwrap(); + } else if index == 5 { + let _: UnitStructure = serde_json::from_str(&line).unwrap(); + } else if index == 6 { + let _: TupleStructure = serde_json::from_str(&line).unwrap(); + } else { + let _: NamedStructure = serde_json::from_str(&line).unwrap(); + } + } +} diff --git a/packages/cw-schema-codegen/playground/test.sh b/packages/cw-schema-codegen/playground/test.sh new file mode 100755 index 000000000..921d0e29b --- /dev/null +++ b/packages/cw-schema-codegen/playground/test.sh @@ -0,0 +1 @@ +cargo run | python playground.py | cargo run --features "deserialize" \ No newline at end of file diff --git a/packages/cw-schema-codegen/src/python/mod.rs b/packages/cw-schema-codegen/src/python/mod.rs index 74f3d9e00..da918a8b0 100644 --- a/packages/cw-schema-codegen/src/python/mod.rs +++ b/packages/cw-schema-codegen/src/python/mod.rs @@ -43,6 +43,7 @@ fn expand_node_name<'a>( cw_schema::NodeType::HexBinary => todo!(), cw_schema::NodeType::Timestamp => todo!(), cw_schema::NodeType::Unit => Cow::Borrowed("void"), + _ => todo!() } } @@ -82,6 +83,7 @@ where .map(|item| expand_node_name(schema, &schema.definitions[*item])) .collect(), ), + _ => todo!() }, }; @@ -123,6 +125,7 @@ where .collect(), } } + _ => todo!() }, }) .collect(), diff --git a/packages/cw-schema-codegen/templates/python/enum.tpl.py b/packages/cw-schema-codegen/templates/python/enum.tpl.py index 21ee91261..d4ecbce50 100644 --- a/packages/cw-schema-codegen/templates/python/enum.tpl.py +++ b/packages/cw-schema-codegen/templates/python/enum.tpl.py @@ -1,40 +1,44 @@ # This code is @generated by cw-schema-codegen. Do not modify this manually. +from dataclasses import dataclass, field +from dataclasses_json import dataclass_json, config +from typing import Optional, Iterable -/** -{% for doc in docs %} - * {{ doc }} -{% endfor %} - */ +enum_field = lambda: field(default=None, metadata=config(exclude=lambda x: x is None)) -type {{ name }} = -{% for variant in variants %} - | +@dataclass_json +@dataclass +class {{ name }}: + '''{% for doc in docs %} + {{ doc }} + {% endfor %}''' + + class VariantIndicator: + ''' + This structure is an indicator of the simple enum variant that is currently contained + in this enum structure. It's used only for the enum variants that does not contain + any inner structure. It's constructed automatically and it's not intend to be manually + used by the user. + ''' + pass - /** - {% for doc in variant.docs %} - * {{ doc }} - {% endfor %} - */ +{% for variant in variants %} + '''{% for doc in variant.docs %} + {{ doc }} + {% endfor %}''' {% match variant.ty %} {% when TypeTemplate::Unit %} - { "{{ variant.name }}": {} } + {{ variant.name }}: Optional[VariantIndicator] = enum_field() {% when TypeTemplate::Tuple with (types) %} - { "{{ variant.name }}": [{{ types|join(", ") }}] } + {{ variant.name }}: Optional[tuple[{{ types|join(", ") }}]] = enum_field() {% when TypeTemplate::Named with { fields } %} - { "{{ variant.name }}": { + class {{ variant.name }}Type: {% for field in fields %} - /** - {% for doc in field.docs %} - * {{ doc }} - {% endfor %} - */ - - {{ field.name }}: {{ field.ty }}; + '''{% for doc in field.docs %} + # {{ doc }} + {% endfor %}''' + {{ field.name }}: {{ field.ty }} {% endfor %} - } } + {{ variant.name }}: Optional[{{ variant.name }}Type] = enum_field() {% endmatch %} -{% endfor %} -; - -export { {{ 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 index 08b30d5d4..ef7ef8698 100644 --- a/packages/cw-schema-codegen/templates/python/struct.tpl.py +++ b/packages/cw-schema-codegen/templates/python/struct.tpl.py @@ -25,6 +25,31 @@ {% endfor %} } {% endmatch %} -; -export { {{ name }} }; + + +# This code is @generated by cw-schema-codegen. Do not modify this manually. +from dataclasses import dataclass, field +from dataclasses_json import dataclass_json, config +from typing import Optional, Iterable + +@dataclass_json +@dataclass +class {{ name }}: + '''{% for doc in docs %} + {{ doc }} + {% endfor %}''' + + {% match ty %} + {% when TypeTemplate::Unit %} + pass + {% when TypeTemplate::Tuple with (types) %} + {{ variant.name }}: tuple[{{ types|join(", ") }}] + {% when TypeTemplate::Named with { fields } %} + {% for field in fields %} + '''{% for doc in field.docs %} + # {{ doc }} + {% endfor %}''' + {{ field.name }}: {{ field.ty }} + {% endfor %} + {% endmatch %} 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 000000000..410995922 --- /dev/null +++ b/packages/cw-schema-codegen/tests/python_tpl.rs @@ -0,0 +1,29 @@ +use std::borrow::Cow; + +use askama::Template; +use cw_schema_codegen::python::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")]), + ty: TypeTemplate::Unit, + }, + EnumVariantTemplate { + name: Cow::Borrowed("Two"), + docs: Cow::Borrowed(&[Cow::Borrowed("Two variant")]), + ty: TypeTemplate::Unit, + }, + ]), + }; + + let rendered = tpl.render().unwrap(); + insta::assert_snapshot!(rendered); +} diff --git a/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap new file mode 100644 index 000000000..3ec74d43f --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap @@ -0,0 +1,42 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: rendered +snapshot_kind: text +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. +from dataclasses import dataclass, field +from dataclasses_json import dataclass_json, config +from typing import Optional, Iterable + +enum_field = lambda: field(default=None, metadata=config(exclude=lambda x: x is None)) + +@dataclass_json +@dataclass +class Simple: + ''' + Simple enum + ''' + + class VariantIndicator: + ''' + This structure is an indicator of the simple enum variant that is currently contained + in this enum structure. It's used only for the enum variants that does not contain + any inner structure. It's constructed automatically and it's not intend to be manually + used by the user. + ''' + pass + + + + ''' + One variant + ''' + + One: Optional[VariantIndicator] = enum_field() + + + ''' + Two variant + ''' + + Two: Optional[VariantIndicator] = enum_field() From 2a737c85a640af87c7cea521cd2e93937ecf27a9 Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Fri, 22 Nov 2024 15:42:51 +0100 Subject: [PATCH 42/60] chore: Replace dataclasses and dataclasses_json with pydantic --- .../playground/playground.py | 142 +++++++----------- .../templates/python/enum.tpl.py | 68 ++++----- .../templates/python/struct.tpl.py | 72 +++------ .../snapshots/python_tpl__simple_enum.snap | 54 +++---- 4 files changed, 130 insertions(+), 206 deletions(-) diff --git a/packages/cw-schema-codegen/playground/playground.py b/packages/cw-schema-codegen/playground/playground.py index ac850f87d..6a3582e88 100644 --- a/packages/cw-schema-codegen/playground/playground.py +++ b/packages/cw-schema-codegen/playground/playground.py @@ -1,84 +1,46 @@ -from dataclasses import dataclass, field -from dataclasses_json import dataclass_json, config -from typing import Optional, Iterable import sys -import json +from typing import Literal, Union, Tuple +from pydantic import BaseModel, RootModel -# TODO tkulik: try to get rid of the `dataclasses_json` dependency +class SomeEnum(RootModel): + class Field1(RootModel[Literal['Field1']]): + pass + class Field2(BaseModel): + Field2: Tuple[int, int] -enum_field = lambda: field(default=None, metadata=config(exclude=lambda x: x is None)) + class Field3(BaseModel): + class __InnerStruct(BaseModel): + a: str + b: int + Field3: __InnerStruct -@dataclass_json -@dataclass -class SomeEnum: - class VariantIndicator: - pass + class Field4(BaseModel): + Field4: 'SomeEnum' - class Field3Type: - a: str - b: int - - class Field5Type: - a: Iterable['SomeEnum'] - - Field1: Optional[VariantIndicator] = enum_field() - Field2: Optional[tuple[int, int]] = enum_field() - Field3: Optional[Field3Type] = enum_field() - Field4: Optional[Iterable['SomeEnum']] = enum_field() - Field5: Optional[Field5Type] = enum_field() - - def deserialize(json): - if not ":" in json: - if json == '"Field1"': - return SomeEnum(Field1=SomeEnum.VariantIndicator()) - else: - raise Exception(f"Deserialization error, undefined variant: {json}") - else: - return SomeEnum.from_json(json) - - def serialize(self): - if self.Field1 is not None: - return '"Field1"' - else: - return SomeEnum.to_json(self) - -@dataclass_json -@dataclass -class UnitStructure: - def deserialize(json): - if json == "null": - return UnitStructure() - else: - Exception(f"Deserialization error, undefined value: {json}") - - def serialize(self): - return 'null' - -@dataclass_json -@dataclass -class TupleStructure: - Tuple: tuple[int, str, int] - - def deserialize(json): - return TupleStructure.from_json(f'{{ "Tuple": {json} }}') - - def serialize(self): - return json.dumps(self.Tuple) - -@dataclass_json -@dataclass -class NamedStructure: + class Field5(BaseModel): + class __InnerStruct(BaseModel): + a: 'SomeEnum' + Field5: __InnerStruct + + root: Union[Field1, Field2, Field3, Field4, Field5] + + +class UnitStructure(RootModel): + root: None + + +class TupleStructure(RootModel): + root: Tuple[int, str, int] + + +class NamedStructure(BaseModel): a: str b: int - c: Iterable['SomeEnum'] + c: SomeEnum + - def deserialize(json): - return NamedStructure.from_json(json) - - def serialize(self): - return self.to_json() ### ### TESTS: @@ -88,32 +50,36 @@ def serialize(self): input = input.rstrip() try: if index < 5: - deserialized = SomeEnum.deserialize(input) + deserialized = SomeEnum.model_validate_json(input) elif index == 5: - deserialized = UnitStructure.deserialize(input) + deserialized = UnitStructure.model_validate_json(input) elif index == 6: - deserialized = TupleStructure.deserialize(input) + deserialized = TupleStructure.model_validate_json(input) else: - deserialized = NamedStructure.deserialize(input) + deserialized = NamedStructure.model_validate_json(input) except: raise(Exception(f"This json can't be deserialized: {input}")) - serialized = deserialized.serialize() + serialized = deserialized.model_dump_json() print(serialized) # def handle_msg(json): -# a = SomeEnum.deserialize(json) -# if a.Field1 is not None: +# a = SomeEnum.model_validate_json(json) +# if isinstance(a.root, SomeEnum.Field1): # print("SomeEnum::Field1") -# elif a.Field2 is not None: -# print(a.Field2[0]) -# print(a.Field2[1]) -# elif a.Field3 is not None: -# print(a.Field3) -# elif a.Field4 is not None: -# print(a.Field4) -# elif a.Field5 is not None: -# print(a.Field5) +# elif isinstance(a.root, SomeEnum.Field2): +# print(a.root.Field2[0]) +# print(a.root.Field2[1]) +# elif isinstance(a.root, SomeEnum.Field3): +# print(a.root.Field3) +# elif isinstance(a.root, SomeEnum.Field4): +# print(a.root.Field4) +# elif isinstance(a.root, SomeEnum.Field5): +# print(a.root.Field5) # handle_msg('"Field1"') -# handle_msg('{"Field2": [10, 12]}') \ No newline at end of file +# handle_msg('{"Field2": [10, 12]}') +# handle_msg('{"Field3": { "a": "10", "b": 12 } }') +# handle_msg('{"Field4": { "Field4": "Field1" } }') +# handle_msg('{"Field5": { "a": "Field1" } }') +# handle_msg('{"Field5": { "a": { "Field5": { "a": "Field1" } } } }') \ No newline at end of file diff --git a/packages/cw-schema-codegen/templates/python/enum.tpl.py b/packages/cw-schema-codegen/templates/python/enum.tpl.py index d4ecbce50..d4bb2b5c7 100644 --- a/packages/cw-schema-codegen/templates/python/enum.tpl.py +++ b/packages/cw-schema-codegen/templates/python/enum.tpl.py @@ -1,44 +1,38 @@ # This code is @generated by cw-schema-codegen. Do not modify this manually. -from dataclasses import dataclass, field -from dataclasses_json import dataclass_json, config -from typing import Optional, Iterable -enum_field = lambda: field(default=None, metadata=config(exclude=lambda x: x is None)) +import typing +from pydantic import BaseModel, RootModel -@dataclass_json -@dataclass -class {{ name }}: - '''{% for doc in docs %} +class {{ name }}(RootModel): + """{% for doc in docs %} {{ doc }} - {% endfor %}''' - - class VariantIndicator: - ''' - This structure is an indicator of the simple enum variant that is currently contained - in this enum structure. It's used only for the enum variants that does not contain - any inner structure. It's constructed automatically and it's not intend to be manually - used by the user. - ''' - pass - + {% endfor %}""" {% for variant in variants %} - '''{% for doc in variant.docs %} - {{ doc }} - {% endfor %}''' - {% match variant.ty %} - {% when TypeTemplate::Unit %} - {{ variant.name }}: Optional[VariantIndicator] = enum_field() - {% when TypeTemplate::Tuple with (types) %} - {{ variant.name }}: Optional[tuple[{{ types|join(", ") }}]] = enum_field() - {% when TypeTemplate::Named with { fields } %} - class {{ variant.name }}Type: - {% for field in fields %} - '''{% for doc in field.docs %} - # {{ doc }} - {% endfor %}''' - {{ field.name }}: {{ field.ty }} - {% endfor %} - {{ variant.name }}: Optional[{{ variant.name }}Type] = enum_field() - {% endmatch %} +{% match variant.ty %} +{% when TypeTemplate::Unit %} + class {{ variant.name }}(RootModel): + """{% for doc in variant.docs %} + {{ doc }} + {% endfor %}""" + root: None +{% 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 __Inner: + """{% 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 %} \ 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 index ef7ef8698..6fa24d395 100644 --- a/packages/cw-schema-codegen/templates/python/struct.tpl.py +++ b/packages/cw-schema-codegen/templates/python/struct.tpl.py @@ -1,55 +1,31 @@ # This code is @generated by cw-schema-codegen. Do not modify this manually. -/** -{% for doc in docs %} - * {{ doc }} -{% endfor %} - */ - -type {{ name }} = -{% match ty %} - {% when TypeTemplate::Unit %} - void - {% when TypeTemplate::Tuple with (types) %} - [{{ types|join(", ") }}] - {% when TypeTemplate::Named with { fields } %} - { - {% for field in fields %} - /** - {% for doc in field.docs %} - * {{ doc }} - {% endfor %} - */ - - {{ field.name }}: {{ field.ty }}; - {% endfor %} - } -{% endmatch %} - +import typing +from pydantic import BaseModel, RootModel -# This code is @generated by cw-schema-codegen. Do not modify this manually. -from dataclasses import dataclass, field -from dataclasses_json import dataclass_json, config -from typing import Optional, Iterable - -@dataclass_json -@dataclass -class {{ name }}: +{% match ty %} +{% when TypeTemplate::Unit %} +class {{ name }}(RootModel): '''{% for doc in docs %} {{ doc }} {% endfor %}''' - - {% match ty %} - {% when TypeTemplate::Unit %} - pass - {% when TypeTemplate::Tuple with (types) %} - {{ variant.name }}: tuple[{{ types|join(", ") }}] - {% when TypeTemplate::Named with { fields } %} - {% for field in fields %} - '''{% for doc in field.docs %} - # {{ doc }} - {% endfor %}''' - {{ field.name }}: {{ field.ty }} - {% endfor %} - {% endmatch %} + 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/tests/snapshots/python_tpl__simple_enum.snap b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap index 3ec74d43f..e937c0fb7 100644 --- a/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap @@ -4,39 +4,27 @@ expression: rendered snapshot_kind: text --- # This code is @generated by cw-schema-codegen. Do not modify this manually. -from dataclasses import dataclass, field -from dataclasses_json import dataclass_json, config -from typing import Optional, Iterable -enum_field = lambda: field(default=None, metadata=config(exclude=lambda x: x is None)) +import typing +from pydantic import BaseModel, RootModel -@dataclass_json -@dataclass -class Simple: - ''' +class Simple(RootModel): + """ Simple enum - ''' - - class VariantIndicator: - ''' - This structure is an indicator of the simple enum variant that is currently contained - in this enum structure. It's used only for the enum variants that does not contain - any inner structure. It's constructed automatically and it's not intend to be manually - used by the user. - ''' - pass - - - - ''' - One variant - ''' - - One: Optional[VariantIndicator] = enum_field() - - - ''' - Two variant - ''' - - Two: Optional[VariantIndicator] = enum_field() + """ + + + + class One(RootModel): + """ + One variant + """ + root: None + + + + class Two(RootModel): + """ + Two variant + """ + root: None From 126b2b782a372d3ad636611373612393987f1ab7 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 25 Nov 2024 18:41:19 +0100 Subject: [PATCH 43/60] TypeScript E2E tests --- Cargo.lock | 44 +- packages/cw-schema-codegen/Cargo.toml | 5 +- packages/cw-schema-codegen/src/main.rs | 18 +- .../cw-schema-codegen/src/typescript/mod.rs | 35 +- .../src/typescript/template.rs | 2 + .../templates/typescript/enum.tpl.ts | 24 +- .../templates/typescript/struct.tpl.ts | 20 +- .../snapshots/typescript__codegen_snap-2.snap | 12 +- .../snapshots/typescript__codegen_snap-3.snap | 12 +- .../snapshots/typescript__codegen_snap-4.snap | 12 +- .../snapshots/typescript__codegen_snap-5.snap | 28 +- .../snapshots/typescript__codegen_snap.snap | 18 +- .../cw-schema-codegen/tests/ts-e2e/.gitignore | 2 + .../tests/ts-e2e/package-lock.json | 575 ++++++++++++++++++ .../tests/ts-e2e/package.json | 22 + .../tests/ts-e2e/src/index.ts | 19 + .../tests/ts-e2e/tsconfig.json | 111 ++++ .../cw-schema-codegen/tests/typescript.rs | 148 ++++- 18 files changed, 1006 insertions(+), 101 deletions(-) create mode 100644 packages/cw-schema-codegen/tests/ts-e2e/.gitignore create mode 100644 packages/cw-schema-codegen/tests/ts-e2e/package-lock.json create mode 100644 packages/cw-schema-codegen/tests/ts-e2e/package.json create mode 100644 packages/cw-schema-codegen/tests/ts-e2e/src/index.ts create mode 100644 packages/cw-schema-codegen/tests/ts-e2e/tsconfig.json diff --git a/Cargo.lock b/Cargo.lock index 8ef3cf348..8ba9ad058 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,6 +126,15 @@ 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 = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "ark-bls12-381" version = "0.4.0" @@ -940,20 +949,23 @@ name = "cw-schema-codegen" version = "2.2.0-rc.1" dependencies = [ "anyhow", + "arbitrary", "askama", "clap", "cosmwasm-schema", "cw-schema", + "derive_arbitrary", "either", "frunk", "frunk_core", "heck", "insta", "log", + "mimalloc", + "rand", "serde", "serde_json", "simple_logger", - "tempfile", ] [[package]] @@ -1047,6 +1059,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" @@ -1671,6 +1694,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" @@ -1741,6 +1774,15 @@ 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" diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index 6f9e6c7d0..984819e37 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -17,11 +17,14 @@ frunk = "0.4.3" frunk_core = "0.4.3" heck = "0.5.0" log = "0.4.22" +mimalloc = "0.1.43" serde_json = "1.0.128" simple_logger = { version = "5.0.0", features = ["stderr"] } [dev-dependencies] +arbitrary = { version = "=1.3.2", features = ["derive"] } +derive_arbitrary = "=1.3.2" insta = "1.40.0" +rand = { version = "0.8.5", features = ["min_const_gen"] } serde = { workspace = true, features = ["derive"] } serde_json = "1.0.128" -tempfile = "3.14.0" diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index 86cd7a2b4..85108868f 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -12,6 +12,9 @@ use std::{ path::PathBuf, }; +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + #[derive(Clone, Copy, Debug, Default, PartialEq, ValueEnum)] pub enum Language { #[default] @@ -54,6 +57,7 @@ fn generate_defs( output: &mut W, language: Language, schema: &cw_schema::Schema, + add_imports: bool, ) -> anyhow::Result<()> where W: io::Write, @@ -68,7 +72,7 @@ where match language { Language::Rust => cw_schema_codegen::rust::process_node(output, schema, node), Language::Typescript => { - cw_schema_codegen::typescript::process_node(output, schema, node) + cw_schema_codegen::typescript::process_node(output, schema, node, add_imports) } Language::Go | Language::Python => todo!(), } @@ -105,23 +109,23 @@ fn main() -> anyhow::Result<()> { let mut output = opts.output()?; if let Some(ref instantiate) = schema.instantiate { - generate_defs(&mut output, opts.language, instantiate)?; + generate_defs(&mut output, opts.language, instantiate, true)?; } if let Some(ref execute) = schema.execute { - generate_defs(&mut output, opts.language, execute)?; + generate_defs(&mut output, opts.language, execute, false)?; } if let Some(ref query) = schema.query { - generate_defs(&mut output, opts.language, query)?; + generate_defs(&mut output, opts.language, query, false)?; } if let Some(ref migrate) = schema.migrate { - generate_defs(&mut output, opts.language, migrate)?; + generate_defs(&mut output, opts.language, migrate, false)?; } if let Some(ref sudo) = schema.sudo { - generate_defs(&mut output, opts.language, sudo)?; + generate_defs(&mut output, opts.language, sudo, false)?; } if let Some(ref responses) = schema.responses { @@ -131,7 +135,7 @@ fn main() -> anyhow::Result<()> { .collect::>(); for response in responses { - generate_defs(&mut output, opts.language, response)?; + generate_defs(&mut output, opts.language, response, false)?; } } diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs index fba8e3e7a..c2067bb5f 100644 --- a/packages/cw-schema-codegen/src/typescript/mod.rs +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -12,19 +12,20 @@ fn expand_node_name<'a>( match node.value { cw_schema::NodeType::Array { items } => { let items = &schema.definitions[items]; - format!("{}[]", expand_node_name(schema, items)).into() + format!("z.array({})", expand_node_name(schema, items)).into() } - cw_schema::NodeType::Float => "number".into(), - cw_schema::NodeType::Double => "number".into(), - cw_schema::NodeType::Boolean => "boolean".into(), - cw_schema::NodeType::String => "string".into(), - cw_schema::NodeType::Integer { .. } => "string".into(), - cw_schema::NodeType::Binary => "Uint8Array".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()".into(), + cw_schema::NodeType::Binary => "z.instanceof(Uint8Array)".into(), cw_schema::NodeType::Optional { inner } => { let inner = &schema.definitions[inner]; - format!("{} | null", expand_node_name(schema, inner)).into() + format!("{}.optional()", expand_node_name(schema, inner)).into() } - cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + + cw_schema::NodeType::Struct(..) => format!("{}Schema", node.name).into(), cw_schema::NodeType::Tuple { ref items } => { let items = items .iter() @@ -34,14 +35,17 @@ fn expand_node_name<'a>( format!("[{}]", items).into() } - cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + cw_schema::NodeType::Enum { .. } => format!("{}Schema", node.name).into(), - cw_schema::NodeType::Decimal { .. } => "string".into(), - cw_schema::NodeType::Address => "string".into(), + cw_schema::NodeType::Decimal { .. } => "z.string()".into(), + cw_schema::NodeType::Address => "z.string()".into(), cw_schema::NodeType::Checksum => todo!(), cw_schema::NodeType::HexBinary => todo!(), - cw_schema::NodeType::Timestamp => todo!(), - cw_schema::NodeType::Unit => Cow::Borrowed("void"), + cw_schema::NodeType::Timestamp => { + // ToDo: Replace with better type + "z.string()".into() + } + cw_schema::NodeType::Unit => "z.void()".into(), } } @@ -54,6 +58,7 @@ pub fn process_node( output: &mut O, schema: &cw_schema::SchemaV1, node: &cw_schema::Node, + add_imports: bool, ) -> io::Result<()> where O: io::Write, @@ -82,6 +87,7 @@ where .collect(), ), }, + add_imports, }; writeln!(output, "{structt}")?; @@ -125,6 +131,7 @@ where }, }) .collect(), + add_imports, }; writeln!(output, "{enumm}")?; diff --git a/packages/cw-schema-codegen/src/typescript/template.rs b/packages/cw-schema-codegen/src/typescript/template.rs index 5ee51e9de..89af73e39 100644 --- a/packages/cw-schema-codegen/src/typescript/template.rs +++ b/packages/cw-schema-codegen/src/typescript/template.rs @@ -14,6 +14,7 @@ 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)] @@ -38,4 +39,5 @@ 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/typescript/enum.tpl.ts b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts index 70c675385..28ba77c76 100644 --- a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts @@ -1,15 +1,17 @@ // 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 %} */ -type {{ name }} = +const {{ name }}Schema = z.union([ {% for variant in variants %} - | - /** {% for doc in variant.docs %} * {{ doc }} @@ -18,11 +20,11 @@ type {{ name }} = {% match variant.ty %} {% when TypeTemplate::Unit %} - { "{{ variant.name }}": {} } + z.object({ "{{ variant.name }}": z.void() }), {% when TypeTemplate::Tuple with (types) %} - { "{{ variant.name }}": [{{ types|join(", ") }}] } + z.object({ "{{ variant.name }}": z.tuple([{{ types|join(", ") }}]) }), {% when TypeTemplate::Named with { fields } %} - { "{{ variant.name }}": { + z.object({ "{{ variant.name }}": z.object({ {% for field in fields %} /** {% for doc in field.docs %} @@ -30,15 +32,17 @@ type {{ name }} = {% endfor %} */ - {{ field.name }}: {{ field.ty }}; + {{ field.name }}: {{ field.ty }}, {% endfor %} - } } + }) }), {% endmatch %} {% endfor %} {% if variants.len() == 0 %} never; {% endif %} -; +]); + +type {{ name }} = z.infer; -export { {{ name }} }; +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 index 8d7eb0a4f..639e1c57d 100644 --- a/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts @@ -1,19 +1,23 @@ // 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 %} */ -type {{ name }} = +const {{ name }}Schema = {% match ty %} {% when TypeTemplate::Unit %} - void + z.void() {% when TypeTemplate::Tuple with (types) %} - [{{ types|join(", ") }}] + z.tuple([{{ types|join(", ") }}]) {% when TypeTemplate::Named with { fields } %} - { + z.object({ {% for field in fields %} /** {% for doc in field.docs %} @@ -21,10 +25,12 @@ type {{ name }} = {% endfor %} */ - {{ field.name }}: {{ field.ty }}; + {{ field.name }}: {{ field.ty }}, {% endfor %} - } + }) {% endmatch %} ; -export { {{ name }} }; +type {{ name }} = z.infer; + +export { {{ name }}, {{ name }}Schema }; 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 index 7cfb7b4a7..f2c6c518d 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap @@ -4,14 +4,20 @@ expression: output --- // This code is @generated by cw-schema-codegen. Do not modify this manually. + +import { z } from 'zod'; + + /** */ -type Uwu = +const UwuSchema = - [string, string] + z.tuple([z.string(), z.string()]) ; -export { Uwu }; +type Uwu = z.infer; + +export { Uwu, UwuSchema }; diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap index c13999ac2..e01ffd038 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap @@ -4,14 +4,20 @@ expression: output --- // This code is @generated by cw-schema-codegen. Do not modify this manually. + +import { z } from 'zod'; + + /** */ -type Òwó = +const ÒwóSchema = - void + z.void() ; -export { Òwó }; +type Òwó = z.infer; + +export { Òwó, ÒwóSchema }; diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap index 9f0cb760f..994b84ded 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap @@ -4,16 +4,22 @@ expression: output --- // This code is @generated by cw-schema-codegen. Do not modify this manually. + +import { z } from 'zod'; + + /** */ -type Empty = +const EmptySchema = z.union([ never; -; +]); + +type Empty = z.infer; -export { Empty }; +export { Empty, EmptySchema }; diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap index 5bd7258ec..a22c8912b 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap @@ -4,52 +4,52 @@ expression: output --- // This code is @generated by cw-schema-codegen. Do not modify this manually. + +import { z } from 'zod'; + + /** */ -type Hehehe = - - | +const HeheheSchema = z.union([ /** */ - { "A": {} } + z.object({ "A": z.void() }), - | - /** */ - { "B": [string] } + z.object({ "B": z.tuple([z.string()]) }), - | - /** */ - { "C": { + z.object({ "C": z.object({ /** */ - field: string; + field: z.string(), - } } + }) }), -; +]); + +type Hehehe = z.infer; -export { Hehehe }; +export { Hehehe, HeheheSchema }; diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap index b36d30ea3..cd3b7d47c 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap @@ -4,28 +4,34 @@ expression: output --- // This code is @generated by cw-schema-codegen. Do not modify this manually. + +import { z } from 'zod'; + + /** */ -type Owo = +const OwoSchema = - { + z.object({ /** */ - field_1: string; + field_1: z.string(), /** */ - field_2: string; + field_2: z.string(), - } + }) ; -export { Owo }; +type Owo = z.infer; + +export { Owo, OwoSchema }; diff --git a/packages/cw-schema-codegen/tests/ts-e2e/.gitignore b/packages/cw-schema-codegen/tests/ts-e2e/.gitignore new file mode 100644 index 000000000..83595e556 --- /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 000000000..ffdeb6df5 --- /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 000000000..9a6c92350 --- /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 000000000..3c976dc7b --- /dev/null +++ b/packages/cw-schema-codegen/tests/ts-e2e/src/index.ts @@ -0,0 +1,19 @@ +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); + +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 000000000..5910b38c6 --- /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 index c19fd9d07..50427b04b 100644 --- a/packages/cw-schema-codegen/tests/typescript.rs +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -1,29 +1,67 @@ +use arbitrary::Arbitrary; use cw_schema::Schemaifier; -use serde::Serialize; -use std::io::Write; +use serde::{Deserialize, Serialize}; +use std::{ + fs::File, + io::Write, + process::{Command, Stdio}, +}; -#[derive(Schemaifier, Serialize)] +#[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] struct Owo { field_1: u32, field_2: String, } -#[derive(Schemaifier, Serialize)] +#[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] struct Uwu(String, u32); -#[derive(Schemaifier, Serialize)] +#[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] struct Òwó; -#[derive(Schemaifier, Serialize)] -enum Empty {} +mod empty { + #![allow(unreachable_code)] + use super::*; + + #[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] + pub enum Empty {} +} + +use self::empty::Empty; -#[derive(Schemaifier, Serialize)] +#[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 @@ -46,7 +84,8 @@ fn codegen_snap() { .iter() .map(|node| { let mut buf = Vec::new(); - cw_schema_codegen::typescript::process_node(&mut buf, &schema, node).unwrap(); + cw_schema_codegen::typescript::process_node(&mut buf, &schema, node, true) + .unwrap(); String::from_utf8(buf).unwrap() }) .collect::(); @@ -55,17 +94,51 @@ fn codegen_snap() { } } +fn wrap Arbitrary<'a> + Into>( + stuff: &mut arbitrary::Unstructured, +) -> Combined { + T::arbitrary(stuff).unwrap().into() +} + +fn type_name() -> String { + let name = std::any::type_name::().split(':').last().unwrap(); + format!("{name}Schema") +} + #[test] fn assert_validity() { - let schemas = [ - cw_schema::schema_of::(), - cw_schema::schema_of::(), - cw_schema::schema_of::<Òwó>(), - cw_schema::schema_of::(), - cw_schema::schema_of::(), + #[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ó>(), + ), + ( + cw_schema::schema_of::(), + wrap::, + type_name::(), + ), + ( + cw_schema::schema_of::(), + wrap::, + type_name::(), + ), ]; - for schema in schemas { + 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!(); }; @@ -75,28 +148,39 @@ fn assert_validity() { .iter() .map(|node| { let mut buf = Vec::new(); - cw_schema_codegen::typescript::process_node(&mut buf, &schema, node).unwrap(); + cw_schema_codegen::typescript::process_node(&mut buf, schema, node, true) + .unwrap(); String::from_utf8(buf).unwrap() }) .collect::(); - let mut file = tempfile::NamedTempFile::with_suffix(".ts").unwrap(); - file.write_all(output.as_bytes()).unwrap(); - file.flush().unwrap(); + let e2e_dir = format!("{}/tests/ts-e2e", env!("CARGO_MANIFEST_DIR")); + let gen_file_path = format!("{}/src/gen.ts", e2e_dir); + 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 install_status = Command::new("npm").arg("i").current_dir(&e2e_dir).status().unwrap(); + assert!(install_status.success()); - let output = std::process::Command::new("npx") - .arg("--package=typescript") - .arg("--") - .arg("tsc") - .arg(file.path()) - .output() + let mut child = Command::new("npm") + .args(["test", type_name]) + .current_dir(e2e_dir) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() .unwrap(); - assert!( - output.status.success(), - "stdout: {stdout}, stderr: {stderr}", - stdout = String::from_utf8_lossy(&output.stdout), - stderr = String::from_utf8_lossy(&output.stderr) - ); + { + let mut stdin = child.stdin.take().unwrap(); + stdin.write_all(serialized.as_bytes()).unwrap(); + } + + let output = child.wait_with_output().unwrap(); + let deserialized: Combined = serde_json::from_slice(&output.stdout).unwrap(); + + assert_eq!(data, deserialized); } } From 777aca330c16079a43c8525ae1f723c6761cb8be Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Tue, 26 Nov 2024 14:22:46 +0100 Subject: [PATCH 44/60] chore: Add tests and validate schemas --- .../playground/playground.py | 25 +-- packages/cw-schema-codegen/src/python/mod.rs | 27 ++- .../templates/python/enum.tpl.py | 27 +-- .../templates/python/struct.tpl.py | 3 +- .../cw-schema-codegen/tests/python_tpl.rs | 175 +++++++++++++++--- .../snapshots/python_tpl__simple_enum.snap | 42 +++-- 6 files changed, 217 insertions(+), 82 deletions(-) diff --git a/packages/cw-schema-codegen/playground/playground.py b/packages/cw-schema-codegen/playground/playground.py index 6a3582e88..f3adbfad1 100644 --- a/packages/cw-schema-codegen/playground/playground.py +++ b/packages/cw-schema-codegen/playground/playground.py @@ -24,7 +24,7 @@ class __InnerStruct(BaseModel): a: 'SomeEnum' Field5: __InnerStruct - root: Union[Field1, Field2, Field3, Field4, Field5] + root: Union[Field1, Field2, Field3, Field4, Field5,] class UnitStructure(RootModel): @@ -46,21 +46,14 @@ class NamedStructure(BaseModel): ### TESTS: ### -for (index, input) in enumerate(sys.stdin): - input = input.rstrip() - try: - if index < 5: - deserialized = SomeEnum.model_validate_json(input) - elif index == 5: - deserialized = UnitStructure.model_validate_json(input) - elif index == 6: - deserialized = TupleStructure.model_validate_json(input) - else: - deserialized = NamedStructure.model_validate_json(input) - except: - raise(Exception(f"This json can't be deserialized: {input}")) - serialized = deserialized.model_dump_json() - print(serialized) +print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) +print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) +print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) +print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) +print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) +print(UnitStructure.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) +print(TupleStructure.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) +print(NamedStructure.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) # def handle_msg(json): diff --git a/packages/cw-schema-codegen/src/python/mod.rs b/packages/cw-schema-codegen/src/python/mod.rs index da918a8b0..b60d0e0c0 100644 --- a/packages/cw-schema-codegen/src/python/mod.rs +++ b/packages/cw-schema-codegen/src/python/mod.rs @@ -1,7 +1,6 @@ use self::template::{ EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, }; -use heck::ToPascalCase; use std::{borrow::Cow, io}; pub mod template; @@ -15,15 +14,15 @@ fn expand_node_name<'a>( let items = &schema.definitions[items]; format!("{}[]", expand_node_name(schema, items)).into() } - cw_schema::NodeType::Float => "number".into(), - cw_schema::NodeType::Double => "number".into(), - cw_schema::NodeType::Boolean => "boolean".into(), - cw_schema::NodeType::String => "string".into(), - cw_schema::NodeType::Integer { .. } => "string".into(), - cw_schema::NodeType::Binary => "Uint8Array".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!("{} | null", expand_node_name(schema, inner)).into() + format!("typing.Optional[{}]", expand_node_name(schema, inner)).into() } cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), cw_schema::NodeType::Tuple { ref items } => { @@ -37,13 +36,13 @@ fn expand_node_name<'a>( } cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), - cw_schema::NodeType::Decimal { .. } => "string".into(), - cw_schema::NodeType::Address => "string".into(), + cw_schema::NodeType::Decimal { .. } => "decimal.Decimal".into(), + cw_schema::NodeType::Address => "str".into(), cw_schema::NodeType::Checksum => todo!(), cw_schema::NodeType::HexBinary => todo!(), cw_schema::NodeType::Timestamp => todo!(), - cw_schema::NodeType::Unit => Cow::Borrowed("void"), - _ => todo!() + cw_schema::NodeType::Unit => "None".into(), + _ => todo!(), } } @@ -83,7 +82,7 @@ where .map(|item| expand_node_name(schema, &schema.definitions[*item])) .collect(), ), - _ => todo!() + _ => todo!(), }, }; @@ -125,7 +124,7 @@ where .collect(), } } - _ => todo!() + _ => todo!(), }, }) .collect(), diff --git a/packages/cw-schema-codegen/templates/python/enum.tpl.py b/packages/cw-schema-codegen/templates/python/enum.tpl.py index d4bb2b5c7..5f647687e 100644 --- a/packages/cw-schema-codegen/templates/python/enum.tpl.py +++ b/packages/cw-schema-codegen/templates/python/enum.tpl.py @@ -1,6 +1,7 @@ # 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): @@ -15,7 +16,7 @@ class {{ variant.name }}(RootModel): """{% for doc in variant.docs %} {{ doc }} {% endfor %}""" - root: None + root: typing.Literal['{{ variant.name }}'] {% when TypeTemplate::Tuple with (types) %} class {{ variant.name }}(BaseModel): """{% for doc in variant.docs %} @@ -23,16 +24,18 @@ class {{ variant.name }}(BaseModel): {% endfor %}""" {{ variant.name }}: typing.Tuple[{{ types|join(", ") }}] {% when TypeTemplate::Named with { fields } %} - class __Inner: - """{% for doc in variant.docs %} - {{ doc }} - {% endfor %}""" - {% for field in fields %} - {{ field.name }}: {{ field.ty }} - """{% for doc in field.docs %} - # {{ doc }} - {% endfor %}""" - {% endfor %} + 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 %} \ No newline at end of file +{% 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 index 6fa24d395..c565beda4 100644 --- a/packages/cw-schema-codegen/templates/python/struct.tpl.py +++ b/packages/cw-schema-codegen/templates/python/struct.tpl.py @@ -1,6 +1,7 @@ # This code is @generated by cw-schema-codegen. Do not modify this manually. import typing +import decimal from pydantic import BaseModel, RootModel @@ -10,7 +11,7 @@ class {{ name }}(RootModel): '''{% for doc in docs %} {{ doc }} {% endfor %}''' - root: None + root: None {% when TypeTemplate::Tuple with (types) %} class {{ name }}(RootModel): '''{% for doc in docs %} diff --git a/packages/cw-schema-codegen/tests/python_tpl.rs b/packages/cw-schema-codegen/tests/python_tpl.rs index 410995922..347d977b0 100644 --- a/packages/cw-schema-codegen/tests/python_tpl.rs +++ b/packages/cw-schema-codegen/tests/python_tpl.rs @@ -1,29 +1,156 @@ -use std::borrow::Cow; +use cw_schema::Schemaifier; +use serde::{Deserialize, Serialize}; +use std::io::Write; -use askama::Template; -use cw_schema_codegen::python::template::{ - EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, -}; +#[derive(Schemaifier, Serialize, Deserialize)] +pub enum SomeEnum { + Field1, + Field2(u32, u32), + Field3 { a: String, b: u32 }, + // Field4(Box), // TODO tkulik: Do we want to support Box ? + // Field5 { a: Box }, +} + +#[derive(Schemaifier, Serialize, Deserialize)] +pub struct UnitStructure; + +#[derive(Schemaifier, Serialize, Deserialize)] +pub struct TupleStructure(u32, String, u128); + +#[derive(Schemaifier, Serialize, Deserialize)] +pub struct NamedStructure { + a: String, + b: u8, + c: SomeEnum, +} #[test] fn simple_enum() { - 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")]), - ty: TypeTemplate::Unit, - }, - EnumVariantTemplate { - name: Cow::Borrowed("Two"), - docs: Cow::Borrowed(&[Cow::Borrowed("Two variant")]), - ty: TypeTemplate::Unit, - }, - ]), - }; - - let rendered = tpl.render().unwrap(); - insta::assert_snapshot!(rendered); + // generate the schemas for each of the above types + let schemas = [ + cw_schema::schema_of::(), + cw_schema::schema_of::(), + cw_schema::schema_of::(), + cw_schema::schema_of::(), + ]; + + // run the codegen to typescript + for schema in schemas { + let cw_schema::Schema::V1(schema) = schema else { + panic!(); + }; + + let output = schema + .definitions + .iter() + .map(|node| { + let mut buf = Vec::new(); + cw_schema_codegen::python::process_node(&mut buf, &schema, node).unwrap(); + String::from_utf8(buf).unwrap() + }) + .collect::(); + + insta::assert_snapshot!(output); + } +} + +macro_rules! validator { + ($typ:ty) => {{ + let a: Box ()> = Box::new(|output| { + serde_json::from_str::<$typ>(output).unwrap(); + }); + a + }}; +} + +#[test] +fn assert_validity() { + let schemas = [ + ( + "SomeEnum", + cw_schema::schema_of::(), + serde_json::to_string(&SomeEnum::Field1).unwrap(), + validator!(SomeEnum), + ), + ( + "SomeEnum", + cw_schema::schema_of::(), + serde_json::to_string(&SomeEnum::Field2(10, 23)).unwrap(), + validator!(SomeEnum), + ), + ( + "SomeEnum", + cw_schema::schema_of::(), + serde_json::to_string(&SomeEnum::Field3 { + a: "sdf".to_string(), + b: 12, + }) + .unwrap(), + validator!(SomeEnum), + ), + ( + "UnitStructure", + cw_schema::schema_of::(), + serde_json::to_string(&UnitStructure {}).unwrap(), + validator!(UnitStructure), + ), + ( + "TupleStructure", + cw_schema::schema_of::(), + serde_json::to_string(&TupleStructure(10, "aasdf".to_string(), 2)).unwrap(), + validator!(TupleStructure), + ), + ( + "NamedStructure", + cw_schema::schema_of::(), + serde_json::to_string(&NamedStructure { + a: "awer".to_string(), + b: 4, + c: SomeEnum::Field1, + }) + .unwrap(), + validator!(NamedStructure), + ), + ]; + + for (type_name, schema, example, validator) in schemas { + let cw_schema::Schema::V1(schema) = schema else { + unreachable!(); + }; + + let schema_output = schema + .definitions + .iter() + .map(|node| { + let mut buf = Vec::new(); + cw_schema_codegen::python::process_node(&mut buf, &schema, node).unwrap(); + String::from_utf8(buf).unwrap() + }) + .collect::(); + + let mut file = tempfile::NamedTempFile::with_suffix(".py").unwrap(); + file.write_all(schema_output.as_bytes()).unwrap(); + file.write( + 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/snapshots/python_tpl__simple_enum.snap b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap index e937c0fb7..a8a9224d1 100644 --- a/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap @@ -1,30 +1,42 @@ --- source: packages/cw-schema-codegen/tests/python_tpl.rs -expression: rendered +expression: output snapshot_kind: text --- # This code is @generated by cw-schema-codegen. Do not modify this manually. import typing +import decimal from pydantic import BaseModel, RootModel -class Simple(RootModel): - """ - Simple enum - """ +class SomeEnum(RootModel): + """""" - class One(RootModel): - """ - One variant - """ - root: None + class Field1(RootModel): + """""" + root: typing.Literal['Field1'] - class Two(RootModel): - """ - Two variant - """ - root: None + class Field2(BaseModel): + """""" + Field2: typing.Tuple[int, int] + + + + class Field3(BaseModel): + class __Inner(BaseModel): + """""" + + a: str + """""" + + b: int + """""" + + Field3: __Inner + + + root: typing.Union[ Field1, Field2, Field3, ] From dcbc88788449418760853eeb29ade3cbf835714d Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 27 Nov 2024 14:12:01 +0100 Subject: [PATCH 45/60] Fix TypeScript codegen --- .../cw-schema-codegen/src/typescript/mod.rs | 2 +- .../templates/typescript/enum.tpl.ts | 2 +- .../templates/typescript/struct.tpl.ts | 2 +- .../snapshots/typescript__codegen_snap-2.snap | 2 +- .../snapshots/typescript__codegen_snap-3.snap | 2 +- .../snapshots/typescript__codegen_snap-5.snap | 4 +- .../snapshots/typescript__codegen_snap.snap | 2 +- .../tests/ts-e2e/src/index.ts | 3 + .../cw-schema-codegen/tests/typescript.rs | 56 +++++++++++-------- 9 files changed, 43 insertions(+), 32 deletions(-) diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs index c2067bb5f..0628f47cb 100644 --- a/packages/cw-schema-codegen/src/typescript/mod.rs +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -18,7 +18,7 @@ fn expand_node_name<'a>( 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()".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]; diff --git a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts index 28ba77c76..92b826914 100644 --- a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts @@ -20,7 +20,7 @@ const {{ name }}Schema = z.union([ {% match variant.ty %} {% when TypeTemplate::Unit %} - z.object({ "{{ variant.name }}": z.void() }), + 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 } %} diff --git a/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts index 639e1c57d..7b98afb51 100644 --- a/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts @@ -13,7 +13,7 @@ import { z } from 'zod'; const {{ name }}Schema = {% match ty %} {% when TypeTemplate::Unit %} - z.void() + z.null() {% when TypeTemplate::Tuple with (types) %} z.tuple([{{ types|join(", ") }}]) {% when TypeTemplate::Named with { fields } %} 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 index f2c6c518d..da104338b 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap @@ -14,7 +14,7 @@ import { z } from 'zod'; const UwuSchema = - z.tuple([z.string(), z.string()]) + z.tuple([z.string(), z.string().or(z.number())]) ; 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 index e01ffd038..167853d6e 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap @@ -14,7 +14,7 @@ import { z } from 'zod'; const ÒwóSchema = - z.void() + z.null() ; 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 index a22c8912b..4b30b45a2 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap @@ -19,7 +19,7 @@ const HeheheSchema = z.union([ */ - z.object({ "A": z.void() }), + z.object({ "A": z.null() }).or(z.literal("A")), /** @@ -27,7 +27,7 @@ const HeheheSchema = z.union([ */ - z.object({ "B": z.tuple([z.string()]) }), + z.object({ "B": z.tuple([z.string().or(z.number())]) }), /** diff --git a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap index cd3b7d47c..83e4dae1e 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap @@ -20,7 +20,7 @@ const OwoSchema = */ - field_1: z.string(), + field_1: z.string().or(z.number()), /** diff --git a/packages/cw-schema-codegen/tests/ts-e2e/src/index.ts b/packages/cw-schema-codegen/tests/ts-e2e/src/index.ts index 3c976dc7b..00ecd472c 100644 --- a/packages/cw-schema-codegen/tests/ts-e2e/src/index.ts +++ b/packages/cw-schema-codegen/tests/ts-e2e/src/index.ts @@ -14,6 +14,9 @@ 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/typescript.rs b/packages/cw-schema-codegen/tests/typescript.rs index 50427b04b..0400a090e 100644 --- a/packages/cw-schema-codegen/tests/typescript.rs +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -1,4 +1,5 @@ use arbitrary::Arbitrary; +use core::str; use cw_schema::Schemaifier; use serde::{Deserialize, Serialize}; use std::{ @@ -19,15 +20,8 @@ struct Uwu(String, u32); #[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] struct Òwó; -mod empty { - #![allow(unreachable_code)] - use super::*; - - #[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] - pub enum Empty {} -} - -use self::empty::Empty; +#[derive(Schemaifier, Debug, Deserialize, PartialEq, Serialize)] +pub enum Empty {} #[derive(Arbitrary, Schemaifier, Debug, Deserialize, PartialEq, Serialize)] enum Hehehe { @@ -84,8 +78,7 @@ fn codegen_snap() { .iter() .map(|node| { let mut buf = Vec::new(); - cw_schema_codegen::typescript::process_node(&mut buf, &schema, node, true) - .unwrap(); + cw_schema_codegen::typescript::process_node(&mut buf, &schema, node, true).unwrap(); String::from_utf8(buf).unwrap() }) .collect::(); @@ -124,11 +117,12 @@ fn assert_validity() { wrap::<Òwó>, type_name::<Òwó>(), ), - ( + // `Empty` is a non-constructable type + /*( cw_schema::schema_of::(), wrap::, type_name::(), - ), + ),*/ ( cw_schema::schema_of::(), wrap::, @@ -136,6 +130,17 @@ fn assert_validity() { ), ]; + 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 { @@ -148,26 +153,20 @@ fn assert_validity() { .iter() .map(|node| { let mut buf = Vec::new(); - cw_schema_codegen::typescript::process_node(&mut buf, schema, node, true) - .unwrap(); + cw_schema_codegen::typescript::process_node(&mut buf, schema, node, true).unwrap(); String::from_utf8(buf).unwrap() }) .collect::(); - let e2e_dir = format!("{}/tests/ts-e2e", env!("CARGO_MANIFEST_DIR")); - let gen_file_path = format!("{}/src/gen.ts", e2e_dir); - let mut gen_file = File::create(gen_file_path).unwrap(); + 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 install_status = Command::new("npm").arg("i").current_dir(&e2e_dir).status().unwrap(); - assert!(install_status.success()); - let mut child = Command::new("npm") .args(["test", type_name]) - .current_dir(e2e_dir) + .current_dir(&e2e_dir) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() @@ -178,8 +177,17 @@ fn assert_validity() { stdin.write_all(serialized.as_bytes()).unwrap(); } - let output = child.wait_with_output().unwrap(); - let deserialized: Combined = serde_json::from_slice(&output.stdout).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); } From 4e8d217880dfc6fae0079f170eba49d2ead5e712 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 27 Nov 2024 14:25:52 +0100 Subject: [PATCH 46/60] Add polyfill types to Rust codegen --- packages/cw-schema-codegen/src/rust/mod.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/cw-schema-codegen/src/rust/mod.rs b/packages/cw-schema-codegen/src/rust/mod.rs index 4f2dc307c..b87457c74 100644 --- a/packages/cw-schema-codegen/src/rust/mod.rs +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -40,12 +40,18 @@ fn expand_node_name<'a>( } cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), - cw_schema::NodeType::Decimal { precision, signed } => todo!(), + 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!(), + 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 => Cow::Borrowed("()"), + cw_schema::NodeType::Unit => "()".into(), } } From 1b38229e855bf7f58f460e7c6d7022e00a58918c Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 27 Nov 2024 14:28:40 +0100 Subject: [PATCH 47/60] Use TypeScript polyfill --- packages/cw-schema-codegen/src/rust/mod.rs | 7 +++++-- packages/cw-schema-codegen/src/typescript/mod.rs | 10 ++++++++-- packages/cw-schema-codegen/tests/typescript.rs | 10 +++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/cw-schema-codegen/src/rust/mod.rs b/packages/cw-schema-codegen/src/rust/mod.rs index b87457c74..d651b0e51 100644 --- a/packages/cw-schema-codegen/src/rust/mod.rs +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -40,7 +40,10 @@ fn expand_node_name<'a>( } cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), - cw_schema::NodeType::Decimal { precision: _, signed: _ } => { + cw_schema::NodeType::Decimal { + precision: _, + signed: _, + } => { // ToDo: Actually use a decimal type here "String".into() } @@ -49,7 +52,7 @@ fn expand_node_name<'a>( 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(), } diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs index 0628f47cb..91608f5da 100644 --- a/packages/cw-schema-codegen/src/typescript/mod.rs +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -39,8 +39,14 @@ fn expand_node_name<'a>( cw_schema::NodeType::Decimal { .. } => "z.string()".into(), cw_schema::NodeType::Address => "z.string()".into(), - cw_schema::NodeType::Checksum => todo!(), - cw_schema::NodeType::HexBinary => todo!(), + 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() diff --git a/packages/cw-schema-codegen/tests/typescript.rs b/packages/cw-schema-codegen/tests/typescript.rs index 0400a090e..1057f2db2 100644 --- a/packages/cw-schema-codegen/tests/typescript.rs +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -135,11 +135,11 @@ fn assert_validity() { // make sure the dependencies are installed let install_status = Command::new("npm") - .arg("i") - .current_dir(&e2e_dir) - .status() - .unwrap(); - assert!(install_status.success()); + .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); From 285abd6dc296e14200466425b7e2814fd14cc6dd Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Wed, 27 Nov 2024 11:30:18 +0100 Subject: [PATCH 48/60] chore: Remove python playground --- Cargo.toml | 2 +- .../cw-schema-codegen/playground/.gitignore | 1 - .../cw-schema-codegen/playground/Cargo.lock | 96 ------------------- .../cw-schema-codegen/playground/Cargo.toml | 11 --- .../playground/playground.py | 78 --------------- .../cw-schema-codegen/playground/src/main.rs | 59 ------------ packages/cw-schema-codegen/playground/test.sh | 1 - 7 files changed, 1 insertion(+), 247 deletions(-) delete mode 100644 packages/cw-schema-codegen/playground/.gitignore delete mode 100644 packages/cw-schema-codegen/playground/Cargo.lock delete mode 100644 packages/cw-schema-codegen/playground/Cargo.toml delete mode 100644 packages/cw-schema-codegen/playground/playground.py delete mode 100644 packages/cw-schema-codegen/playground/src/main.rs delete mode 100755 packages/cw-schema-codegen/playground/test.sh diff --git a/Cargo.toml b/Cargo.toml index c06f9b080..c94fa1046 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = ["packages/*"] -exclude = ["contracts", "packages/cw-schema-codegen/playground"] +exclude = ["contracts"] # Resolver has to be set explicitly in workspaces # due to https://github.com/rust-lang/cargo/issues/9956 diff --git a/packages/cw-schema-codegen/playground/.gitignore b/packages/cw-schema-codegen/playground/.gitignore deleted file mode 100644 index ea8c4bf7f..000000000 --- a/packages/cw-schema-codegen/playground/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/packages/cw-schema-codegen/playground/Cargo.lock b/packages/cw-schema-codegen/playground/Cargo.lock deleted file mode 100644 index 867ff0bae..000000000 --- a/packages/cw-schema-codegen/playground/Cargo.lock +++ /dev/null @@ -1,96 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "proc-macro2" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "serde" -version = "1.0.215" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.215" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.133" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" -dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", -] - -[[package]] -name = "serialization" -version = "0.1.0" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] -name = "syn" -version = "2.0.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" diff --git a/packages/cw-schema-codegen/playground/Cargo.toml b/packages/cw-schema-codegen/playground/Cargo.toml deleted file mode 100644 index a5aa7ba8f..000000000 --- a/packages/cw-schema-codegen/playground/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "serialization" -version = "0.1.0" -edition = "2021" - -[features] -deserialize = [] - -[dependencies] -serde = { version = "1.0.215", features = ["derive", "serde_derive"] } -serde_json = "1.0.133" diff --git a/packages/cw-schema-codegen/playground/playground.py b/packages/cw-schema-codegen/playground/playground.py deleted file mode 100644 index f3adbfad1..000000000 --- a/packages/cw-schema-codegen/playground/playground.py +++ /dev/null @@ -1,78 +0,0 @@ -import sys -from typing import Literal, Union, Tuple -from pydantic import BaseModel, RootModel - - -class SomeEnum(RootModel): - class Field1(RootModel[Literal['Field1']]): - pass - - class Field2(BaseModel): - Field2: Tuple[int, int] - - class Field3(BaseModel): - class __InnerStruct(BaseModel): - a: str - b: int - Field3: __InnerStruct - - class Field4(BaseModel): - Field4: 'SomeEnum' - - class Field5(BaseModel): - class __InnerStruct(BaseModel): - a: 'SomeEnum' - Field5: __InnerStruct - - root: Union[Field1, Field2, Field3, Field4, Field5,] - - -class UnitStructure(RootModel): - root: None - - -class TupleStructure(RootModel): - root: Tuple[int, str, int] - - -class NamedStructure(BaseModel): - a: str - b: int - c: SomeEnum - - - -### -### TESTS: -### - -print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) -print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) -print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) -print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) -print(SomeEnum.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) -print(UnitStructure.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) -print(TupleStructure.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) -print(NamedStructure.model_validate_json(sys.stdin.readline().rstrip()).model_dump_json()) - - -# def handle_msg(json): -# a = SomeEnum.model_validate_json(json) -# if isinstance(a.root, SomeEnum.Field1): -# print("SomeEnum::Field1") -# elif isinstance(a.root, SomeEnum.Field2): -# print(a.root.Field2[0]) -# print(a.root.Field2[1]) -# elif isinstance(a.root, SomeEnum.Field3): -# print(a.root.Field3) -# elif isinstance(a.root, SomeEnum.Field4): -# print(a.root.Field4) -# elif isinstance(a.root, SomeEnum.Field5): -# print(a.root.Field5) - -# handle_msg('"Field1"') -# handle_msg('{"Field2": [10, 12]}') -# handle_msg('{"Field3": { "a": "10", "b": 12 } }') -# handle_msg('{"Field4": { "Field4": "Field1" } }') -# handle_msg('{"Field5": { "a": "Field1" } }') -# handle_msg('{"Field5": { "a": { "Field5": { "a": "Field1" } } } }') \ No newline at end of file diff --git a/packages/cw-schema-codegen/playground/src/main.rs b/packages/cw-schema-codegen/playground/src/main.rs deleted file mode 100644 index 747e7ab89..000000000 --- a/packages/cw-schema-codegen/playground/src/main.rs +++ /dev/null @@ -1,59 +0,0 @@ - -use serde::{Deserialize, Serialize}; - - -#[derive(Serialize, Deserialize)] -pub enum SomeEnum { - Field1, - Field2(u32, u32), - Field3 { - a: String, - b: u32 - }, - Field4(Box), - Field5 { a: Box }, -} - -#[derive(Serialize, Deserialize)] -pub struct UnitStructure; - -#[derive(Serialize, Deserialize)] -pub struct TupleStructure(u32, String, u128); - -#[derive(Serialize, Deserialize)] -pub struct NamedStructure { - a: String, - b: u8, - c: SomeEnum -} - - -#[cfg(not(feature = "deserialize"))] -fn main() { - println!("{}", serde_json::to_string(&SomeEnum::Field1).unwrap()); - println!("{}", serde_json::to_string(&SomeEnum::Field2(10, 23)).unwrap()); - println!("{}", serde_json::to_string(&SomeEnum::Field3 {a: "sdf".to_string(), b: 12}).unwrap()); - println!("{}", serde_json::to_string(&SomeEnum::Field4(Box::new(SomeEnum::Field1))).unwrap()); - println!("{}", serde_json::to_string(&SomeEnum::Field5 { a: Box::new(SomeEnum::Field1) }).unwrap()); - println!("{}", serde_json::to_string(&UnitStructure {}).unwrap()); - println!("{}", serde_json::to_string(&TupleStructure(10, "aasdf".to_string(), 2)).unwrap()); - println!("{}", serde_json::to_string(&NamedStructure {a: "awer".to_string(), b: 4, c: SomeEnum::Field1}).unwrap()); -} - -#[cfg(feature = "deserialize")] -fn main() { - use std::io::BufRead; - for (index, line) in std::io::BufReader::new(std::io::stdin()).lines().enumerate() { - let line = line.unwrap(); - println!("{line}"); - if index < 5 { - let _: SomeEnum = serde_json::from_str(&line).unwrap(); - } else if index == 5 { - let _: UnitStructure = serde_json::from_str(&line).unwrap(); - } else if index == 6 { - let _: TupleStructure = serde_json::from_str(&line).unwrap(); - } else { - let _: NamedStructure = serde_json::from_str(&line).unwrap(); - } - } -} diff --git a/packages/cw-schema-codegen/playground/test.sh b/packages/cw-schema-codegen/playground/test.sh deleted file mode 100755 index 921d0e29b..000000000 --- a/packages/cw-schema-codegen/playground/test.sh +++ /dev/null @@ -1 +0,0 @@ -cargo run | python playground.py | cargo run --features "deserialize" \ No newline at end of file From 6801e885c0911ccd216fbb1abaebfdbb4f01db82 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 2 Dec 2024 13:35:59 +0100 Subject: [PATCH 49/60] Fix up a few things --- Cargo.lock | 1 + packages/cw-schema-codegen/Cargo.toml | 1 + packages/cw-schema-codegen/tests/python_tpl.rs | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ba9ad058..a163c6ce9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -966,6 +966,7 @@ dependencies = [ "serde", "serde_json", "simple_logger", + "tempfile", ] [[package]] diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index 984819e37..581468a6e 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -28,3 +28,4 @@ insta = "1.40.0" rand = { version = "0.8.5", features = ["min_const_gen"] } serde = { workspace = true, features = ["derive"] } serde_json = "1.0.128" +tempfile = "3.14.0" diff --git a/packages/cw-schema-codegen/tests/python_tpl.rs b/packages/cw-schema-codegen/tests/python_tpl.rs index 347d977b0..60764c8ca 100644 --- a/packages/cw-schema-codegen/tests/python_tpl.rs +++ b/packages/cw-schema-codegen/tests/python_tpl.rs @@ -56,7 +56,7 @@ fn simple_enum() { macro_rules! validator { ($typ:ty) => {{ - let a: Box ()> = Box::new(|output| { + let a: Box = Box::new(|output| { serde_json::from_str::<$typ>(output).unwrap(); }); a @@ -130,7 +130,7 @@ fn assert_validity() { let mut file = tempfile::NamedTempFile::with_suffix(".py").unwrap(); file.write_all(schema_output.as_bytes()).unwrap(); - file.write( + file.write_all( format!( "import sys; print({type_name}.model_validate_json('{example}').model_dump_json())" ) From f3f338cde229285f4f74806b48edb8f78c94eef3 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 2 Dec 2024 14:24:45 +0100 Subject: [PATCH 50/60] Add some Go codegen --- packages/cw-schema-codegen/src/go/mod.rs | 159 ++++++++++++++++++ packages/cw-schema-codegen/src/go/template.rs | 4 + packages/cw-schema-codegen/src/main.rs | 6 +- packages/cw-schema-codegen/src/python/mod.rs | 3 - .../templates/go/enum.tpl.go | 37 ++++ .../templates/go/struct.tpl.go | 31 ++-- .../templates/rust/enum.tpl.rs | 55 +++--- .../templates/rust/struct.tpl.rs | 32 ++-- .../templates/typescript/enum.tpl.ts | 38 ++--- .../templates/typescript/struct.tpl.ts | 30 ++-- 10 files changed, 299 insertions(+), 96 deletions(-) diff --git a/packages/cw-schema-codegen/src/go/mod.rs b/packages/cw-schema-codegen/src/go/mod.rs index 612b5b95f..c7f129b94 100644 --- a/packages/cw-schema-codegen/src/go/mod.rs +++ b/packages/cw-schema-codegen/src/go/mod.rs @@ -1 +1,160 @@ +use self::template::{ + EnumTemplate, EnumVariantTemplate, FieldTemplate, StructTemplate, TypeTemplate, +}; +use heck::ToPascalCase; +use std::{borrow::Cow, io}; + pub mod template; + +fn expand_node_name<'a>( + schema: &'a cw_schema::SchemaV1, + node: &'a cw_schema::Node, +) -> Cow<'a, str> { + match node.value { + cw_schema::NodeType::Array { items } => { + let items = &schema.definitions[items]; + format!("[]{}", expand_node_name(schema, items)).into() + } + cw_schema::NodeType::Float => "float32".into(), + cw_schema::NodeType::Double => "float64".into(), + cw_schema::NodeType::Boolean => "bool".into(), + cw_schema::NodeType::String => "string".into(), + cw_schema::NodeType::Integer { signed, precision } => { + let ty = if signed { "int" } else { "uint" }; + format!("{ty}{precision}").into() + } + cw_schema::NodeType::Binary => "[]byte".into(), + cw_schema::NodeType::Optional { inner } => { + let inner = &schema.definitions[inner]; + format!("{}", expand_node_name(schema, inner)).into() + } + cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), + cw_schema::NodeType::Tuple { items: _ } => { + /*let items = items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect::>() + .join(", "); + + format!("({})", items).into()*/ + "[]interface{}".into() + } + cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), + + cw_schema::NodeType::Decimal { + precision: _, + signed: _, + } => { + // ToDo: Actually use a decimal type here + "string".into() + } + cw_schema::NodeType::Address => "Address".into(), + cw_schema::NodeType::Checksum => "string".into(), + cw_schema::NodeType::HexBinary => { + // ToDo: Actually use a hex-encoded binary type here + "string".into() + } + cw_schema::NodeType::Timestamp => "string".into(), + cw_schema::NodeType::Unit => "struct{}".into(), + } +} + +fn prepare_docs(desc: Option<&str>) -> Cow<'_, [Cow<'_, str>]> { + desc.map(|desc| { + desc.lines() + .map(|line| line.replace('"', "\\\"").into()) + .collect() + }) + .unwrap_or(Cow::Borrowed(&[])) +} + +pub fn process_node( + output: &mut O, + schema: &cw_schema::SchemaV1, + node: &cw_schema::Node, + add_package: bool, +) -> io::Result<()> +where + O: io::Write, +{ + match node.value { + cw_schema::NodeType::Struct(ref sty) => { + let structt = StructTemplate { + add_package, + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + ty: match sty { + cw_schema::StructType::Unit => TypeTemplate::Unit, + cw_schema::StructType::Named { ref properties } => TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Owned(name.to_pascal_case()), + rename: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name(schema, &schema.definitions[prop.value]), + }) + .collect(), + }, + cw_schema::StructType::Tuple { ref items } => TypeTemplate::Tuple( + items + .iter() + .map(|item| expand_node_name(schema, &schema.definitions[*item])) + .collect(), + ), + }, + }; + + writeln!(output, "{structt}")?; + } + cw_schema::NodeType::Enum { ref cases, .. } => { + let enumm = EnumTemplate { + add_package, + name: node.name.clone(), + docs: prepare_docs(node.description.as_deref()), + variants: cases + .iter() + .map(|(name, case)| EnumVariantTemplate { + name: name.to_pascal_case().into(), + rename: Cow::Borrowed(name), + docs: prepare_docs(case.description.as_deref()), + ty: match case.value { + cw_schema::EnumValue::Unit => TypeTemplate::Unit, + cw_schema::EnumValue::Tuple { ref items } => { + let items = items + .iter() + .map(|item| { + expand_node_name(schema, &schema.definitions[*item]) + }) + .collect(); + + TypeTemplate::Tuple(items) + } + cw_schema::EnumValue::Named { ref properties, .. } => { + TypeTemplate::Named { + fields: properties + .iter() + .map(|(name, prop)| FieldTemplate { + name: Cow::Owned(name.to_pascal_case()), + rename: Cow::Borrowed(name), + docs: prepare_docs(prop.description.as_deref()), + ty: expand_node_name( + schema, + &schema.definitions[prop.value], + ), + }) + .collect(), + } + } + }, + }) + .collect(), + }; + + writeln!(output, "{enumm}")?; + } + _ => (), + } + + Ok(()) +} diff --git a/packages/cw-schema-codegen/src/go/template.rs b/packages/cw-schema-codegen/src/go/template.rs index 90c02e1b2..cfdf50a45 100644 --- a/packages/cw-schema-codegen/src/go/template.rs +++ b/packages/cw-schema-codegen/src/go/template.rs @@ -4,6 +4,7 @@ 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>, } @@ -11,6 +12,7 @@ pub struct EnumVariantTemplate<'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>]>, @@ -19,6 +21,7 @@ pub struct EnumTemplate<'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>, } @@ -35,6 +38,7 @@ pub enum TypeTemplate<'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/main.rs b/packages/cw-schema-codegen/src/main.rs index e01f8bff3..2677ea717 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -57,7 +57,7 @@ fn generate_defs( output: &mut W, language: Language, schema: &cw_schema::Schema, - add_imports: bool, + add_imports_or_package: bool, ) -> anyhow::Result<()> where W: io::Write, @@ -72,10 +72,10 @@ where 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) + 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 => todo!(), + Language::Go => cw_schema_codegen::go::process_node(output, schema, node, add_imports_or_package), } })?; diff --git a/packages/cw-schema-codegen/src/python/mod.rs b/packages/cw-schema-codegen/src/python/mod.rs index b60d0e0c0..07ac50a31 100644 --- a/packages/cw-schema-codegen/src/python/mod.rs +++ b/packages/cw-schema-codegen/src/python/mod.rs @@ -42,7 +42,6 @@ fn expand_node_name<'a>( cw_schema::NodeType::HexBinary => todo!(), cw_schema::NodeType::Timestamp => todo!(), cw_schema::NodeType::Unit => "None".into(), - _ => todo!(), } } @@ -82,7 +81,6 @@ where .map(|item| expand_node_name(schema, &schema.definitions[*item])) .collect(), ), - _ => todo!(), }, }; @@ -124,7 +122,6 @@ where .collect(), } } - _ => todo!(), }, }) .collect(), diff --git a/packages/cw-schema-codegen/templates/go/enum.tpl.go b/packages/cw-schema-codegen/templates/go/enum.tpl.go index ec0d54cc8..ac8df8c3f 100644 --- a/packages/cw-schema-codegen/templates/go/enum.tpl.go +++ b/packages/cw-schema-codegen/templates/go/enum.tpl.go @@ -1,2 +1,39 @@ // This code is @generated by cw-schema-codegen. Do not modify this manually. +{% if add_package %} +package cwcodegen + +import ( + "github.com/cosmos/cosmos-sdk/types/address" +) +{% endif %} + +{% for variant in variants %} +{% match variant.ty %} +{% when TypeTemplate::Unit %} +type {{ name }}{{ variant.name }} struct{} +{% when TypeTemplate::Tuple(types) %} +type {{ name }}{{ variant.name }} []interface{} +{% when TypeTemplate::Named { fields } %} +type {{ name }}{{ variant.name }} struct { + {% for field in fields %} + {% for doc in docs %} + // {{ doc }} + {% endfor %} + {{ field.name }} {{ field.ty }} `json:"{{ field.rename }}"` + {% endfor %} +} +{% endmatch %} +{% endfor %} + +{% for doc in docs %} + // {{ doc }} +{% endfor %} +type {{ name }} struct { +{% for variant in variants %} +{% for doc in docs %} + // {{ doc }} +{% endfor %} + {{ variant.name}} {{ name }}{{ variant.name }} `json:"{{ variant.rename }}"` +{% endfor %} +} diff --git a/packages/cw-schema-codegen/templates/go/struct.tpl.go b/packages/cw-schema-codegen/templates/go/struct.tpl.go index 48b420e7f..0a405140e 100644 --- a/packages/cw-schema-codegen/templates/go/struct.tpl.go +++ b/packages/cw-schema-codegen/templates/go/struct.tpl.go @@ -1,21 +1,28 @@ // This code is @generated by cw-schema-codegen. Do not modify this manually. +{% if add_package %} package cwcodegen +import ( + "github.com/cosmos/cosmos-sdk/types" +) +{% endif %} + {% for doc in docs %} // {{ doc }} {% endfor %} +{% match ty %} +{% when TypeTemplate::Unit %} +type {{ name }} struct{} +{% when TypeTemplate::Tuple with (types) %} +type {{ name }} []interface{} /* todo: replace with true tuples if i can think of it */ +{% when TypeTemplate::Named with { fields } %} type {{ name }} struct { - {% match ty %} - {% when TypeTemplate::Unit %} - {% when TypeTemplate::Tuple with (types) %} - {{ todo!() }} - {% when TypeTemplate::Named with { fields } %} - {% for field in fields %} - {% for doc in docs %} - // {{ doc }} - {% endfor %} - {{ field.name|capitalize }} {{ field.ty }} `json:"{{ field.name }}"` - {% endfor %} - {% endmatch %} +{% 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/rust/enum.tpl.rs b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs index 6898de1af..9f3d66dc9 100644 --- a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -6,35 +6,34 @@ #[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 %} +{% for variant in variants %} +{% for doc in variant.docs %} + #[doc = "{{ doc }}"] +{% endfor %} - {{ 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 %} +{% match variant.serde_rename %} +{% when Some with (rename) %} + #[serde(rename = "{{ rename }}")] +{% when None %} +{% endmatch %} - {{ field.name }}: {{ field.ty }}, - {% endfor %} - } - {% 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 %} +{% 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 index 3d2f8a005..e25615739 100644 --- a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs @@ -1,27 +1,27 @@ // This code is @generated by cw-schema-codegen. Do not modify this manually. {% for doc in docs %} - #[doc = "{{ doc }}"] +#[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 %} +{% 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 %} - } + {{ 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 index 92b826914..8d794509a 100644 --- a/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/enum.tpl.ts @@ -18,28 +18,28 @@ const {{ name }}Schema = z.union([ {% 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 %} +{% 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; +never; {% endif %} ]); diff --git a/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts index 7b98afb51..a6bd159cb 100644 --- a/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts +++ b/packages/cw-schema-codegen/templates/typescript/struct.tpl.ts @@ -12,22 +12,22 @@ import { z } from 'zod'; 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 %} - */ +{% 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 %} - }) + {{ field.name }}: {{ field.ty }}, +{% endfor %} +}) {% endmatch %} ; From d2b5896ebcded13d54a73f3cba3266c0a41692cf Mon Sep 17 00:00:00 2001 From: Tomasz Kulik Date: Tue, 10 Dec 2024 11:58:16 +0100 Subject: [PATCH 51/60] chore: Update python codegen --- Cargo.lock | 1 + packages/cw-schema-codegen/Cargo.toml | 3 + packages/cw-schema-codegen/src/python/mod.rs | 9 +- .../templates/python/struct.tpl.py | 16 +- .../cw-schema-codegen/tests/python_tpl.rs | 139 +++++++++++------- .../snapshots/python_tpl__simple_enum-2.snap | 18 +++ .../snapshots/python_tpl__simple_enum-3.snap | 18 +++ .../snapshots/python_tpl__simple_enum-4.snap | 81 ++++++++++ .../snapshots/python_tpl__simple_enum.snap | 24 ++- 9 files changed, 240 insertions(+), 69 deletions(-) create mode 100644 packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-2.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-3.snap create mode 100644 packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-4.snap diff --git a/Cargo.lock b/Cargo.lock index a163c6ce9..e2b36c113 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,6 +953,7 @@ dependencies = [ "askama", "clap", "cosmwasm-schema", + "cosmwasm-std", "cw-schema", "derive_arbitrary", "either", diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index 581468a6e..0042cf7c7 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -29,3 +29,6 @@ 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/src/python/mod.rs b/packages/cw-schema-codegen/src/python/mod.rs index 07ac50a31..b2b76a998 100644 --- a/packages/cw-schema-codegen/src/python/mod.rs +++ b/packages/cw-schema-codegen/src/python/mod.rs @@ -12,7 +12,7 @@ fn expand_node_name<'a>( match node.value { cw_schema::NodeType::Array { items } => { let items = &schema.definitions[items]; - format!("{}[]", expand_node_name(schema, items)).into() + format!("typing.List[{}]", expand_node_name(schema, items)).into() } cw_schema::NodeType::Float => "float".into(), cw_schema::NodeType::Double => "float".into(), @@ -35,12 +35,11 @@ fn expand_node_name<'a>( format!("[{}]", items).into() } cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), - cw_schema::NodeType::Decimal { .. } => "decimal.Decimal".into(), cw_schema::NodeType::Address => "str".into(), - cw_schema::NodeType::Checksum => todo!(), - cw_schema::NodeType::HexBinary => todo!(), - cw_schema::NodeType::Timestamp => todo!(), + cw_schema::NodeType::Checksum => "str".into(), + cw_schema::NodeType::HexBinary => "str".into(), + cw_schema::NodeType::Timestamp => "str".into(), cw_schema::NodeType::Unit => "None".into(), } } diff --git a/packages/cw-schema-codegen/templates/python/struct.tpl.py b/packages/cw-schema-codegen/templates/python/struct.tpl.py index c565beda4..cdf184242 100644 --- a/packages/cw-schema-codegen/templates/python/struct.tpl.py +++ b/packages/cw-schema-codegen/templates/python/struct.tpl.py @@ -8,25 +8,25 @@ {% match ty %} {% when TypeTemplate::Unit %} class {{ name }}(RootModel): - '''{% for doc in docs %} + """{% for doc in docs %} {{ doc }} - {% endfor %}''' + {% endfor %}""" root: None {% when TypeTemplate::Tuple with (types) %} class {{ name }}(RootModel): - '''{% for doc in docs %} + """{% for doc in docs %} {{ doc }} - {% endfor %}''' + {% endfor %}""" root: typing.Tuple[{{ types|join(", ") }}] {% when TypeTemplate::Named with { fields } %} class {{ name }}(BaseModel): - '''{% for doc in docs %} + """{% for doc in docs %} {{ doc }} - {% endfor %}''' + {% endfor %}""" {% for field in fields %} {{ field.name }}: {{ field.ty }} - '''{% for doc in field.docs %} + """{% for doc in field.docs %} # {{ doc }} - {% endfor %}''' + {% endfor %}""" {% endfor %} {% endmatch %} diff --git a/packages/cw-schema-codegen/tests/python_tpl.rs b/packages/cw-schema-codegen/tests/python_tpl.rs index 60764c8ca..57a3c85ac 100644 --- a/packages/cw-schema-codegen/tests/python_tpl.rs +++ b/packages/cw-schema-codegen/tests/python_tpl.rs @@ -2,28 +2,65 @@ use cw_schema::Schemaifier; use serde::{Deserialize, Serialize}; use std::io::Write; -#[derive(Schemaifier, Serialize, Deserialize)] +/// 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 { a: String, b: u32 }, - // Field4(Box), // TODO tkulik: Do we want to support Box ? - // Field5 { a: Box }, + + /// Field3 docs + Field3 { + /// `a` field docs + a: String, + + /// `b` field docs + b: u32, + }, } -#[derive(Schemaifier, Serialize, Deserialize)] +/// This is a struct level documentation for unit struct +#[derive(Schemaifier, Serialize, Deserialize, PartialEq, Debug)] pub struct UnitStructure; -#[derive(Schemaifier, Serialize, Deserialize)] +/// This is a struct level documentation for tuple +#[derive(Schemaifier, Serialize, Deserialize, PartialEq, Debug)] pub struct TupleStructure(u32, String, u128); -#[derive(Schemaifier, Serialize, Deserialize)] +/// 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 @@ -55,61 +92,63 @@ fn simple_enum() { } macro_rules! validator { - ($typ:ty) => {{ - let a: Box = Box::new(|output| { - serde_json::from_str::<$typ>(output).unwrap(); - }); - a + ($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 = [ - ( - "SomeEnum", - cw_schema::schema_of::(), - serde_json::to_string(&SomeEnum::Field1).unwrap(), - validator!(SomeEnum), - ), - ( - "SomeEnum", - cw_schema::schema_of::(), - serde_json::to_string(&SomeEnum::Field2(10, 23)).unwrap(), - validator!(SomeEnum), - ), - ( - "SomeEnum", - cw_schema::schema_of::(), - serde_json::to_string(&SomeEnum::Field3 { + validator!(SomeEnum, SomeEnum::Field1), + validator!(SomeEnum, SomeEnum::Field2(10, 23)), + validator!( + SomeEnum, + SomeEnum::Field3 { a: "sdf".to_string(), b: 12, - }) - .unwrap(), - validator!(SomeEnum), - ), - ( - "UnitStructure", - cw_schema::schema_of::(), - serde_json::to_string(&UnitStructure {}).unwrap(), - validator!(UnitStructure), + } ), - ( - "TupleStructure", - cw_schema::schema_of::(), - serde_json::to_string(&TupleStructure(10, "aasdf".to_string(), 2)).unwrap(), - validator!(TupleStructure), - ), - ( - "NamedStructure", - cw_schema::schema_of::(), - serde_json::to_string(&NamedStructure { + validator!(UnitStructure, UnitStructure {}), + validator!(TupleStructure, TupleStructure(10, "aasdf".to_string(), 2)), + validator!( + NamedStructure, + NamedStructure { a: "awer".to_string(), b: 4, c: SomeEnum::Field1, - }) - .unwrap(), - validator!(NamedStructure), + } + ), + 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: (), + } ), ]; 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 000000000..013eeab78 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-2.snap @@ -0,0 +1,18 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: output +snapshot_kind: text +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + + + +class 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 000000000..00a24c660 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-3.snap @@ -0,0 +1,18 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: output +snapshot_kind: text +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + + + +class 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 000000000..638eb60c6 --- /dev/null +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum-4.snap @@ -0,0 +1,81 @@ +--- +source: packages/cw-schema-codegen/tests/python_tpl.rs +expression: output +snapshot_kind: text +--- +# This code is @generated by cw-schema-codegen. Do not modify this manually. + +import typing +import decimal +from pydantic import BaseModel, RootModel + +class SomeEnum(RootModel): + """ + 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 NamedStructure(BaseModel): + """ + This is a struct level documentation for named structure + """ + + a: str + """ + # `a` field docs + """ + + b: int + """ + # `b` field docs + """ + + c: 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 index a8a9224d1..8cc8c89be 100644 --- a/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap @@ -10,31 +10,43 @@ import decimal from pydantic import BaseModel, RootModel class 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 From 8cc06885cf8a2bdf86546ccc8e8ff03d66bf0108 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 7 Jan 2025 12:46:56 +0100 Subject: [PATCH 52/60] Add E2E scaffold --- packages/cw-schema-codegen/tests/go-e2e/go.mod | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/cw-schema-codegen/tests/go-e2e/go.mod 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 000000000..1d84497ac --- /dev/null +++ b/packages/cw-schema-codegen/tests/go-e2e/go.mod @@ -0,0 +1,3 @@ +module cosmwasm.com/cosmwasm-codegen/e2e + +go 1.23.4 From 403e33fe752c5769663ad358df4bf1c67e6ae914 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Tue, 7 Jan 2025 15:39:34 +0100 Subject: [PATCH 53/60] Add Go E2E tests --- packages/cw-schema-codegen/src/main.rs | 13 +- .../templates/go/enum.tpl.go | 4 +- .../templates/go/struct.tpl.go | 6 +- .../cw-schema-codegen/tests/go-e2e/.gitignore | 1 + .../cw-schema-codegen/tests/go-e2e/go.mod | 90 ++++ .../cw-schema-codegen/tests/go-e2e/go.sum | 407 ++++++++++++++++++ .../cw-schema-codegen/tests/go-e2e/main.go | 34 ++ packages/cw-schema-codegen/tests/go.rs | 166 +++++++ 8 files changed, 710 insertions(+), 11 deletions(-) create mode 100644 packages/cw-schema-codegen/tests/go-e2e/.gitignore create mode 100644 packages/cw-schema-codegen/tests/go-e2e/go.sum create mode 100644 packages/cw-schema-codegen/tests/go-e2e/main.go create mode 100644 packages/cw-schema-codegen/tests/go.rs diff --git a/packages/cw-schema-codegen/src/main.rs b/packages/cw-schema-codegen/src/main.rs index 2677ea717..a99fe9005 100644 --- a/packages/cw-schema-codegen/src/main.rs +++ b/packages/cw-schema-codegen/src/main.rs @@ -71,11 +71,16 @@ where 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::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), + Language::Go => { + cw_schema_codegen::go::process_node(output, schema, node, add_imports_or_package) + } } })?; diff --git a/packages/cw-schema-codegen/templates/go/enum.tpl.go b/packages/cw-schema-codegen/templates/go/enum.tpl.go index ac8df8c3f..914ca42fc 100644 --- a/packages/cw-schema-codegen/templates/go/enum.tpl.go +++ b/packages/cw-schema-codegen/templates/go/enum.tpl.go @@ -1,10 +1,8 @@ // This code is @generated by cw-schema-codegen. Do not modify this manually. {% if add_package %} -package cwcodegen - import ( - "github.com/cosmos/cosmos-sdk/types/address" + _ "github.com/cosmos/cosmos-sdk/types/address" ) {% endif %} diff --git a/packages/cw-schema-codegen/templates/go/struct.tpl.go b/packages/cw-schema-codegen/templates/go/struct.tpl.go index 0a405140e..cb4bb9088 100644 --- a/packages/cw-schema-codegen/templates/go/struct.tpl.go +++ b/packages/cw-schema-codegen/templates/go/struct.tpl.go @@ -1,10 +1,8 @@ // This code is @generated by cw-schema-codegen. Do not modify this manually. {% if add_package %} -package cwcodegen - import ( - "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types" ) {% endif %} @@ -22,7 +20,7 @@ type {{ name }} struct { {% for doc in docs %} // {{ doc }} {% endfor %} - {{ field.name }} {{ field.ty }} `json:"{{ field.rename }}"` + {{ field.name }} *{{ field.ty }} `json:"{{ field.rename }},omitempty"` {% endfor %} } {% endmatch %} 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 000000000..ea1bc79da --- /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 index 1d84497ac..2d2cee40e 100644 --- a/packages/cw-schema-codegen/tests/go-e2e/go.mod +++ b/packages/cw-schema-codegen/tests/go-e2e/go.mod @@ -1,3 +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 000000000..290fe98b7 --- /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 000000000..450213175 --- /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 000000000..035460424 --- /dev/null +++ b/packages/cw-schema-codegen/tests/go.rs @@ -0,0 +1,166 @@ +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() -> &'static str { + let name = std::any::type_name::().split(':').last().unwrap(); + name +} + +#[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!("{}/gen.go", e2e_dir); + + // 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); + } +} From a91f47901aeb93d08cdbfb705f0c7c8b3b2f8eae Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 13 Jan 2025 12:32:50 +0100 Subject: [PATCH 54/60] Fix some more E2E test issues --- Cargo.lock | 58 ------------------- packages/cw-schema-codegen/Cargo.toml | 2 - packages/cw-schema-codegen/src/go/mod.rs | 15 ++--- .../templates/go/enum.tpl.go | 4 +- .../templates/go/struct.tpl.go | 2 +- .../cw-schema-codegen/tests/go-e2e/main.go | 2 +- packages/cw-schema-codegen/tests/go.rs | 10 ++-- .../cw-schema-codegen/tests/typescript.rs | 2 +- 8 files changed, 16 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2b36c113..966b5b123 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -957,8 +957,6 @@ dependencies = [ "cw-schema", "derive_arbitrary", "either", - "frunk", - "frunk_core", "heck", "insta", "log", @@ -1344,62 +1342,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "frunk" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874b6a17738fc273ec753618bac60ddaeac48cb1d7684c3e7bd472e57a28b817" -dependencies = [ - "frunk_core", - "frunk_derives", - "frunk_proc_macros", - "serde", -] - -[[package]] -name = "frunk_core" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3529a07095650187788833d585c219761114005d5976185760cf794d265b6a5c" -dependencies = [ - "serde", -] - -[[package]] -name = "frunk_derives" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e99b8b3c28ae0e84b604c75f721c21dc77afb3706076af5e8216d15fd1deaae3" -dependencies = [ - "frunk_proc_macro_helpers", - "quote", - "syn 2.0.77", -] - -[[package]] -name = "frunk_proc_macro_helpers" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a956ef36c377977e512e227dcad20f68c2786ac7a54dacece3746046fea5ce" -dependencies = [ - "frunk_core", - "proc-macro2", - "quote", - "syn 2.0.77", -] - -[[package]] -name = "frunk_proc_macros" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e86c2c9183662713fea27ea527aad20fb15fee635a71081ff91bf93df4dc51" -dependencies = [ - "frunk_core", - "frunk_proc_macro_helpers", - "quote", - "syn 2.0.77", -] - [[package]] name = "funty" version = "2.0.0" diff --git a/packages/cw-schema-codegen/Cargo.toml b/packages/cw-schema-codegen/Cargo.toml index 0042cf7c7..1dc8c19ad 100644 --- a/packages/cw-schema-codegen/Cargo.toml +++ b/packages/cw-schema-codegen/Cargo.toml @@ -13,8 +13,6 @@ clap = { version = "4.5.18", features = ["derive"] } cosmwasm-schema = { version = "=2.2.0-rc.1", path = "../schema" } cw-schema = { version = "=2.2.0-rc.1", path = "../cw-schema" } either = "1.13.0" -frunk = "0.4.3" -frunk_core = "0.4.3" heck = "0.5.0" log = "0.4.22" mimalloc = "0.1.43" diff --git a/packages/cw-schema-codegen/src/go/mod.rs b/packages/cw-schema-codegen/src/go/mod.rs index c7f129b94..411e015dc 100644 --- a/packages/cw-schema-codegen/src/go/mod.rs +++ b/packages/cw-schema-codegen/src/go/mod.rs @@ -29,15 +29,12 @@ fn expand_node_name<'a>( format!("{}", expand_node_name(schema, inner)).into() } cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), - cw_schema::NodeType::Tuple { items: _ } => { - /*let items = items - .iter() - .map(|item| expand_node_name(schema, &schema.definitions[*item])) - .collect::>() - .join(", "); - - format!("({})", items).into()*/ - "[]interface{}".into() + cw_schema::NodeType::Tuple { ref items } => { + if items.len() == 1 { + "interface{}" + } else { + "[]interface{}" + }.into() } cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), diff --git a/packages/cw-schema-codegen/templates/go/enum.tpl.go b/packages/cw-schema-codegen/templates/go/enum.tpl.go index 914ca42fc..6acc079d5 100644 --- a/packages/cw-schema-codegen/templates/go/enum.tpl.go +++ b/packages/cw-schema-codegen/templates/go/enum.tpl.go @@ -11,7 +11,7 @@ import ( {% when TypeTemplate::Unit %} type {{ name }}{{ variant.name }} struct{} {% when TypeTemplate::Tuple(types) %} -type {{ name }}{{ variant.name }} []interface{} +type {{ name }}{{ variant.name }} {% if types.len() > 1 %} [] {% endif %} interface{} {% when TypeTemplate::Named { fields } %} type {{ name }}{{ variant.name }} struct { {% for field in fields %} @@ -32,6 +32,6 @@ type {{ name }} struct { {% for doc in docs %} // {{ doc }} {% endfor %} - {{ variant.name}} {{ name }}{{ variant.name }} `json:"{{ variant.rename }}"` + {{ 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 index cb4bb9088..ea8ad79b8 100644 --- a/packages/cw-schema-codegen/templates/go/struct.tpl.go +++ b/packages/cw-schema-codegen/templates/go/struct.tpl.go @@ -20,7 +20,7 @@ type {{ name }} struct { {% for doc in docs %} // {{ doc }} {% endfor %} - {{ field.name }} *{{ field.ty }} `json:"{{ field.rename }},omitempty"` + {{ field.name }} *{{ field.ty }} `json:"{{ field.rename }}"` {% endfor %} } {% endmatch %} diff --git a/packages/cw-schema-codegen/tests/go-e2e/main.go b/packages/cw-schema-codegen/tests/go-e2e/main.go index 450213175..6f6e1ff0f 100644 --- a/packages/cw-schema-codegen/tests/go-e2e/main.go +++ b/packages/cw-schema-codegen/tests/go-e2e/main.go @@ -18,7 +18,7 @@ func main() { data := buffer.Bytes() - var out TestType + var out *TestType if err := json.Unmarshal(data, &out); err != nil { panic(err) } diff --git a/packages/cw-schema-codegen/tests/go.rs b/packages/cw-schema-codegen/tests/go.rs index 035460424..9055f7ce2 100644 --- a/packages/cw-schema-codegen/tests/go.rs +++ b/packages/cw-schema-codegen/tests/go.rs @@ -63,14 +63,14 @@ fn wrap Arbitrary<'a> + Into>( } fn type_name() -> &'static str { - let name = std::any::type_name::().split(':').last().unwrap(); + let name = std::any::type_name::().split(':').next_back().unwrap(); name } #[test] fn e2e() { #[allow(clippy::type_complexity)] - let schemas: &[(_, fn(&mut arbitrary::Unstructured) -> Combined, _)] = &[ + let schemas: &[(_, fn(&mut arbitrary::Unstructured<'_>) -> Combined, _)] = &[ ( cw_schema::schema_of::(), wrap::, @@ -81,11 +81,11 @@ fn e2e() { wrap::, type_name::(), ), - /*( + ( cw_schema::schema_of::<Òwó>(), wrap::<Òwó>, type_name::<Òwó>(), - ),*/ + ), // `Empty` is a non-constructable type /*( cw_schema::schema_of::(), @@ -100,7 +100,7 @@ fn e2e() { ]; let e2e_dir = format!("{}/tests/go-e2e", env!("CARGO_MANIFEST_DIR")); - let gen_file_path = format!("{}/gen.go", e2e_dir); + let gen_file_path = format!("{e2e_dir}/gen.go"); // make sure the dependencies are installed let install_status = Command::new("go") diff --git a/packages/cw-schema-codegen/tests/typescript.rs b/packages/cw-schema-codegen/tests/typescript.rs index 1057f2db2..7e8fb2a68 100644 --- a/packages/cw-schema-codegen/tests/typescript.rs +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -94,7 +94,7 @@ fn wrap Arbitrary<'a> + Into>( } fn type_name() -> String { - let name = std::any::type_name::().split(':').last().unwrap(); + let name = std::any::type_name::().split(':').next_back().unwrap(); format!("{name}Schema") } From bd164c039e33fbb79a8c7e2c2f06972a5cad3d20 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 20 Jan 2025 12:56:46 +0100 Subject: [PATCH 55/60] Rust E2E tests --- Cargo.toml | 2 +- packages/cw-schema-codegen/src/go/mod.rs | 11 +- packages/cw-schema-codegen/tests/go.rs | 4 +- .../tests/rust-e2e/Cargo.lock | 503 ++++++++++++++++++ .../tests/rust-e2e/Cargo.toml | 8 + .../tests/rust-e2e/src/gen.rs | 51 ++ .../tests/rust-e2e/src/main.rs | 6 + packages/cw-schema-codegen/tests/rust.rs | 158 ++++++ packages/cw-schema-derive/src/expand.rs | 12 +- 9 files changed, 745 insertions(+), 10 deletions(-) create mode 100644 packages/cw-schema-codegen/tests/rust-e2e/Cargo.lock create mode 100644 packages/cw-schema-codegen/tests/rust-e2e/Cargo.toml create mode 100644 packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs create mode 100644 packages/cw-schema-codegen/tests/rust-e2e/src/main.rs create mode 100644 packages/cw-schema-codegen/tests/rust.rs diff --git a/Cargo.toml b/Cargo.toml index c94fa1046..4e4c61c5a 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/packages/cw-schema-codegen/src/go/mod.rs b/packages/cw-schema-codegen/src/go/mod.rs index 411e015dc..7334cbee4 100644 --- a/packages/cw-schema-codegen/src/go/mod.rs +++ b/packages/cw-schema-codegen/src/go/mod.rs @@ -29,13 +29,12 @@ fn expand_node_name<'a>( format!("{}", expand_node_name(schema, inner)).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::Tuple { ref items } => if items.len() == 1 { + "interface{}" + } else { + "[]interface{}" } + .into(), cw_schema::NodeType::Enum { .. } => node.name.as_ref().into(), cw_schema::NodeType::Decimal { diff --git a/packages/cw-schema-codegen/tests/go.rs b/packages/cw-schema-codegen/tests/go.rs index 9055f7ce2..a9f60b631 100644 --- a/packages/cw-schema-codegen/tests/go.rs +++ b/packages/cw-schema-codegen/tests/go.rs @@ -131,7 +131,9 @@ fn e2e() { 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(); + 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(); 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 000000000..27923bff0 --- /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 = 4 + +[[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 000000000..fb2380157 --- /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 000000000..0ea1e1526 --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs @@ -0,0 +1,51 @@ +// This code is @generated by cw-schema-codegen. Do not modify this manually. + + + +#[cosmwasm_schema::cw_serde] +pub enum Hehehe { + + + + + #[serde(rename = "A")] + + + A + + + , + + + + + #[serde(rename = "B")] + + + B + + ( + u32 + ) + + , + + + + + #[serde(rename = "C")] + + + C + + { + + + field: String, + + } + + , + +} +pub type TestType = 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 000000000..248c26dce --- /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 000000000..13de70ad7 --- /dev/null +++ b/packages/cw-schema-codegen/tests/rust.rs @@ -0,0 +1,158 @@ +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() -> &'static str { + let name = std::any::type_name::().split(':').next_back().unwrap(); + name +} + +#[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-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs index e724797fb..b0c12096f 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -108,7 +108,7 @@ impl SerdeContainerOptions { } else if meta.path.is_ident("untagged") { options.untagged = true; } else { - print_warning( + /*print_warning( "unknown serde attribute", format!( "unknown attribute \"{}\"", @@ -118,7 +118,7 @@ impl SerdeContainerOptions { .unwrap_or_else(|| "[error]".into()) ), ) - .unwrap(); + .unwrap();*/ // TODO: support other serde attributes // @@ -129,6 +129,14 @@ impl SerdeContainerOptions { .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(()) })?; } From 2a367aea17c4e7e963a3576c3924550d809ef1fa Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 20 Jan 2025 14:04:11 +0100 Subject: [PATCH 56/60] Fix issues with duplicated names --- .../templates/rust/enum.tpl.rs | 2 + .../templates/rust/struct.tpl.rs | 2 + packages/cw-schema-codegen/tests/go.rs | 7 +- .../tests/rust-e2e/src/gen.rs | 6 +- packages/cw-schema-codegen/tests/rust.rs | 7 +- .../snapshots/python_tpl__simple_enum-2.snap | 3 +- .../snapshots/python_tpl__simple_enum-3.snap | 3 +- .../snapshots/python_tpl__simple_enum-4.snap | 7 +- .../snapshots/python_tpl__simple_enum.snap | 3 +- .../snapshots/rust_tpl__complex_enum.snap | 67 +++++++++---------- .../tests/snapshots/rust_tpl__empty_enum.snap | 5 +- .../snapshots/rust_tpl__empty_struct.snap | 7 +- .../snapshots/rust_tpl__named_struct.snap | 31 ++++----- .../snapshots/rust_tpl__simple_enum.snap | 41 ++++++------ .../snapshots/rust_tpl__tuple_struct.snap | 11 +-- .../snapshots/typescript__codegen_snap-2.snap | 10 +-- .../snapshots/typescript__codegen_snap-3.snap | 10 +-- .../snapshots/typescript__codegen_snap-4.snap | 8 +-- .../snapshots/typescript__codegen_snap-5.snap | 40 +++++------ .../snapshots/typescript__codegen_snap.snap | 32 ++++----- .../cw-schema-codegen/tests/typescript.rs | 5 +- packages/cw-schema-derive/src/expand.rs | 10 ++- 22 files changed, 167 insertions(+), 150 deletions(-) diff --git a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs index 9f3d66dc9..496acaeaf 100644 --- a/packages/cw-schema-codegen/templates/rust/enum.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/enum.tpl.rs @@ -1,5 +1,7 @@ // 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 %} diff --git a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs index e25615739..cf8c3580d 100644 --- a/packages/cw-schema-codegen/templates/rust/struct.tpl.rs +++ b/packages/cw-schema-codegen/templates/rust/struct.tpl.rs @@ -1,5 +1,7 @@ // 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 %} diff --git a/packages/cw-schema-codegen/tests/go.rs b/packages/cw-schema-codegen/tests/go.rs index a9f60b631..cce081a0d 100644 --- a/packages/cw-schema-codegen/tests/go.rs +++ b/packages/cw-schema-codegen/tests/go.rs @@ -62,9 +62,10 @@ fn wrap Arbitrary<'a> + Into>( T::arbitrary(stuff).unwrap().into() } -fn type_name() -> &'static str { - let name = std::any::type_name::().split(':').next_back().unwrap(); - name +fn type_name() -> String { + std::any::type_name::() + .replace("::", "_") + .replace(['<', '>'], "_") } #[test] diff --git a/packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs b/packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs index 0ea1e1526..a90ddd927 100644 --- a/packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs +++ b/packages/cw-schema-codegen/tests/rust-e2e/src/gen.rs @@ -1,9 +1,11 @@ // This code is @generated by cw-schema-codegen. Do not modify this manually. +#![allow(non_camel_case_types)] + #[cosmwasm_schema::cw_serde] -pub enum Hehehe { +pub enum rust_Hehehe { @@ -48,4 +50,4 @@ pub enum Hehehe { , } -pub type TestType = Hehehe; \ No newline at end of file +pub type TestType = rust_Hehehe; \ No newline at end of file diff --git a/packages/cw-schema-codegen/tests/rust.rs b/packages/cw-schema-codegen/tests/rust.rs index 13de70ad7..eaca0e367 100644 --- a/packages/cw-schema-codegen/tests/rust.rs +++ b/packages/cw-schema-codegen/tests/rust.rs @@ -62,9 +62,10 @@ fn wrap Arbitrary<'a> + Into>( T::arbitrary(stuff).unwrap().into() } -fn type_name() -> &'static str { - let name = std::any::type_name::().split(':').next_back().unwrap(); - name +fn type_name() -> String { + std::any::type_name::() + .replace("::", "_") + .replace(['<', '>'], "_") } #[test] 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 index 013eeab78..d534a7cb6 100644 --- 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 @@ -1,7 +1,6 @@ --- source: packages/cw-schema-codegen/tests/python_tpl.rs expression: output -snapshot_kind: text --- # This code is @generated by cw-schema-codegen. Do not modify this manually. @@ -11,7 +10,7 @@ from pydantic import BaseModel, RootModel -class UnitStructure(RootModel): +class python_tpl_UnitStructure(RootModel): """ This is a struct level documentation for unit struct """ 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 index 00a24c660..c85540432 100644 --- 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 @@ -1,7 +1,6 @@ --- source: packages/cw-schema-codegen/tests/python_tpl.rs expression: output -snapshot_kind: text --- # This code is @generated by cw-schema-codegen. Do not modify this manually. @@ -11,7 +10,7 @@ from pydantic import BaseModel, RootModel -class TupleStructure(RootModel): +class python_tpl_TupleStructure(RootModel): """ This is a struct level documentation for tuple """ 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 index 638eb60c6..6f33a3b35 100644 --- 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 @@ -1,7 +1,6 @@ --- source: packages/cw-schema-codegen/tests/python_tpl.rs expression: output -snapshot_kind: text --- # This code is @generated by cw-schema-codegen. Do not modify this manually. @@ -9,7 +8,7 @@ import typing import decimal from pydantic import BaseModel, RootModel -class SomeEnum(RootModel): +class python_tpl_SomeEnum(RootModel): """ This is a struct level documentation for enum type """ @@ -60,7 +59,7 @@ from pydantic import BaseModel, RootModel -class NamedStructure(BaseModel): +class python_tpl_NamedStructure(BaseModel): """ This is a struct level documentation for named structure """ @@ -75,7 +74,7 @@ class NamedStructure(BaseModel): # `b` field docs """ - c: SomeEnum + 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 index 8cc8c89be..b2e7ebb93 100644 --- a/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/python_tpl__simple_enum.snap @@ -1,7 +1,6 @@ --- source: packages/cw-schema-codegen/tests/python_tpl.rs expression: output -snapshot_kind: text --- # This code is @generated by cw-schema-codegen. Do not modify this manually. @@ -9,7 +8,7 @@ import typing import decimal from pydantic import BaseModel, RootModel -class SomeEnum(RootModel): +class python_tpl_SomeEnum(RootModel): """ This is a struct level documentation for enum type """ 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 index e1c4a9758..80aa043ae 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__complex_enum.snap @@ -1,57 +1,56 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered -snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. +#![allow(non_camel_case_types)] + #[doc = "Complex enum"] #[cosmwasm_schema::cw_serde] pub enum Complex { - - - #[doc = "One variant"] - - - - One - - ( - u64 - ) - + #[doc = "One variant"] + + + + + + One + + ( + u64 + ) + , - + + + #[doc = "Two variant"] + + + + + + Two + + { - #[doc = "Two variant"] - + #[doc = "Field a"] + a: u64, - - Two - { - - - #[doc = "Field a"] - - - a: u64, - - - #[doc = "Field b"] - - - b: String, - - } + #[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 index cb79d1753..865b9faea 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_enum.snap @@ -1,15 +1,16 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered -snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. +#![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 index 3103d42b2..3444f88fa 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__empty_struct.snap @@ -1,16 +1,17 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered -snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. +#![allow(non_camel_case_types)] - #[doc = "Empty struct"] + +#[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 index dd3525ae0..bba7ead54 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__named_struct.snap @@ -1,30 +1,31 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered -snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. +#![allow(non_camel_case_types)] - #[doc = "Named struct"] + +#[doc = "Named struct"] #[cosmwasm_schema::cw_serde] pub struct Named - { - - - #[doc = "Field a"] - +{ + + + #[doc = "Field a"] + + + a: u64, + + + #[doc = "Field b"] + - a: u64, - - - #[doc = "Field b"] - + b: String, - 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 index e7ed6b8cf..db289a16b 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__simple_enum.snap @@ -1,39 +1,40 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered -snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. +#![allow(non_camel_case_types)] + #[doc = "Simple enum"] #[cosmwasm_schema::cw_serde] pub enum Simple { - - - #[doc = "One variant"] - - - - One - - + #[doc = "One variant"] + + + + + + One + + , - - - #[doc = "Two variant"] - - - - Two - - + #[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 index 358693556..87a2426e6 100644 --- a/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap +++ b/packages/cw-schema-codegen/tests/snapshots/rust_tpl__tuple_struct.snap @@ -1,18 +1,19 @@ --- source: packages/cw-schema-codegen/tests/rust_tpl.rs expression: rendered -snapshot_kind: text --- // This code is @generated by cw-schema-codegen. Do not modify this manually. +#![allow(non_camel_case_types)] - #[doc = "Tuple struct"] + +#[doc = "Tuple struct"] #[cosmwasm_schema::cw_serde] pub struct Tuple - ( - u64, String - ); +( + 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 index da104338b..982133608 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-2.snap @@ -12,12 +12,12 @@ import { z } from 'zod'; */ -const UwuSchema = +const typescript_UwuSchema = + + z.tuple([z.string(), z.string().or(z.number())]) - z.tuple([z.string(), z.string().or(z.number())]) - ; -type Uwu = z.infer; +type typescript_Uwu = z.infer; -export { Uwu, UwuSchema }; +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 index 167853d6e..e6b697a9d 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-3.snap @@ -12,12 +12,12 @@ import { z } from 'zod'; */ -const ÒwóSchema = +const typescript_ÒwóSchema = + + z.null() - z.null() - ; -type Òwó = z.infer; +type typescript_Òwó = z.infer; -export { Òwó, ÒwóSchema }; +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 index 994b84ded..c2811eefe 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-4.snap @@ -12,14 +12,14 @@ import { z } from 'zod'; */ -const EmptySchema = z.union([ +const typescript_EmptySchema = z.union([ - never; +never; ]); -type Empty = z.infer; +type typescript_Empty = z.infer; -export { Empty, EmptySchema }; +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 index 4b30b45a2..143b652e5 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap-5.snap @@ -12,44 +12,44 @@ import { z } from 'zod'; */ -const HeheheSchema = z.union([ +const typescript_HeheheSchema = z.union([ /** */ - - z.object({ "A": z.null() }).or(z.literal("A")), - + + z.object({ "A": z.null() }).or(z.literal("A")), + /** */ - - z.object({ "B": z.tuple([z.string().or(z.number())]) }), - + + z.object({ "B": z.tuple([z.string().or(z.number())]) }), + /** */ - - z.object({ "C": z.object({ - - /** - - */ - - field: z.string(), - - }) }), - + + z.object({ "C": z.object({ + + /** + + */ + + field: z.string(), + +}) }), + ]); -type Hehehe = z.infer; +type typescript_Hehehe = z.infer; -export { Hehehe, HeheheSchema }; +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 index 83e4dae1e..7d2abff64 100644 --- a/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap +++ b/packages/cw-schema-codegen/tests/snapshots/typescript__codegen_snap.snap @@ -12,26 +12,26 @@ import { z } from 'zod'; */ -const OwoSchema = +const typescript_OwoSchema = - z.object({ - - /** - - */ + z.object({ - field_1: z.string().or(z.number()), - - /** - - */ + /** + + */ - field_2: z.string(), - - }) + field_1: z.string().or(z.number()), + + /** + + */ + + field_2: z.string(), + +}) ; -type Owo = z.infer; +type typescript_Owo = z.infer; -export { Owo, OwoSchema }; +export { typescript_Owo, typescript_OwoSchema }; diff --git a/packages/cw-schema-codegen/tests/typescript.rs b/packages/cw-schema-codegen/tests/typescript.rs index 7e8fb2a68..e0334a035 100644 --- a/packages/cw-schema-codegen/tests/typescript.rs +++ b/packages/cw-schema-codegen/tests/typescript.rs @@ -94,7 +94,10 @@ fn wrap Arbitrary<'a> + Into>( } fn type_name() -> String { - let name = std::any::type_name::().split(':').next_back().unwrap(); + let name = std::any::type_name::() + .replace("::", "_") + .replace(['<', '>'], "_"); + format!("{name}Schema") } diff --git a/packages/cw-schema-derive/src/expand.rs b/packages/cw-schema-derive/src/expand.rs index b0c12096f..843d3c283 100644 --- a/packages/cw-schema-derive/src/expand.rs +++ b/packages/cw-schema-derive/src/expand.rs @@ -387,7 +387,10 @@ fn expand_enum(mut meta: ContainerMeta, input: DataEnum) -> syn::Result #crate_path::DefinitionReference { let node = #crate_path::Node { - name: stringify!(#name).into(), + name: std::any::type_name::() + .replace("::", "_") + .replace(['<', '>'], "_") + .into(), description: #description, value: #crate_path::NodeType::Enum { discriminator: None, @@ -459,7 +462,10 @@ fn expand_struct(mut meta: ContainerMeta, input: DataStruct) -> syn::Result() + .replace("::", "_") + .replace(['<', '>'], "_") + .into(), description: #description, value: #node_ty, } From 3e56a498a61f9d9bdc0bccc97ca50a72af43ed2c Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 10 Feb 2025 13:20:04 +0100 Subject: [PATCH 57/60] Add missing derives --- packages/std/src/eureka.rs | 8 ++++++-- packages/std/src/results/cosmos_msg.rs | 5 ++++- packages/std/src/types.rs | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/std/src/eureka.rs b/packages/std/src/eureka.rs index 14c1e916e..629570edc 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/results/cosmos_msg.rs b/packages/std/src/results/cosmos_msg.rs index fc6261d77..957a2689d 100644 --- a/packages/std/src/results/cosmos_msg.rs +++ b/packages/std/src/results/cosmos_msg.rs @@ -48,7 +48,10 @@ 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 {} diff --git a/packages/std/src/types.rs b/packages/std/src/types.rs index 57bce01df..2ba18d453 100644 --- a/packages/std/src/types.rs +++ b/packages/std/src/types.rs @@ -123,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. /// From e77dd610041d781ef20e7ae06e618588d25a4565 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 10 Feb 2025 13:49:48 +0100 Subject: [PATCH 58/60] Add support for maps (because that's a thing people do apparently) --- packages/cw-schema-codegen/src/go/mod.rs | 7 +++ packages/cw-schema-codegen/src/python/mod.rs | 7 +++ packages/cw-schema-codegen/src/rust/mod.rs | 10 ++++ .../cw-schema-codegen/src/typescript/mod.rs | 6 ++ packages/cw-schema/src/default_impls.rs | 58 ++++++++++++++++++- packages/cw-schema/src/lib.rs | 15 +++++ 6 files changed, 102 insertions(+), 1 deletion(-) diff --git a/packages/cw-schema-codegen/src/go/mod.rs b/packages/cw-schema-codegen/src/go/mod.rs index 7334cbee4..ebba81f4c 100644 --- a/packages/cw-schema-codegen/src/go/mod.rs +++ b/packages/cw-schema-codegen/src/go/mod.rs @@ -28,6 +28,13 @@ fn expand_node_name<'a>( 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{}" diff --git a/packages/cw-schema-codegen/src/python/mod.rs b/packages/cw-schema-codegen/src/python/mod.rs index b2b76a998..a44b7b266 100644 --- a/packages/cw-schema-codegen/src/python/mod.rs +++ b/packages/cw-schema-codegen/src/python/mod.rs @@ -24,6 +24,13 @@ fn expand_node_name<'a>( 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 diff --git a/packages/cw-schema-codegen/src/rust/mod.rs b/packages/cw-schema-codegen/src/rust/mod.rs index d651b0e51..b9531568c 100644 --- a/packages/cw-schema-codegen/src/rust/mod.rs +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -28,6 +28,16 @@ fn expand_node_name<'a>( 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 diff --git a/packages/cw-schema-codegen/src/typescript/mod.rs b/packages/cw-schema-codegen/src/typescript/mod.rs index 91608f5da..a836e801b 100644 --- a/packages/cw-schema-codegen/src/typescript/mod.rs +++ b/packages/cw-schema-codegen/src/typescript/mod.rs @@ -25,6 +25,12 @@ fn expand_node_name<'a>( 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 diff --git a/packages/cw-schema/src/default_impls.rs b/packages/cw-schema/src/default_impls.rs index 298b80c1b..630472ca0 100644 --- a/packages/cw-schema/src/default_impls.rs +++ b/packages/cw-schema/src/default_impls.rs @@ -1,12 +1,14 @@ -use crate::{Node, NodeType, Schemaifier}; +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(), @@ -20,6 +22,7 @@ impl Schemaifier for () { } impl Schemaifier for str { + #[inline] fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { visitor.insert( Self::id(), @@ -33,6 +36,7 @@ impl Schemaifier for str { } impl Schemaifier for String { + #[inline] fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { visitor.insert( Self::id(), @@ -49,6 +53,7 @@ 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)), @@ -67,6 +72,7 @@ macro_rules! impl_integer { 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(), @@ -80,6 +86,7 @@ impl Schemaifier for f32 { } impl Schemaifier for f64 { + #[inline] fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { visitor.insert( Self::id(), @@ -93,6 +100,7 @@ impl Schemaifier for f64 { } impl Schemaifier for bool { + #[inline] fn visit_schema(visitor: &mut crate::SchemaVisitor) -> crate::DefinitionReference { visitor.insert( Self::id(), @@ -109,6 +117,7 @@ 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::()), @@ -126,6 +135,7 @@ 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::()), @@ -169,6 +179,7 @@ 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::()), @@ -182,10 +193,54 @@ where } } +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) } @@ -195,6 +250,7 @@ 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 index 0e1c2c339..54d32378c 100644 --- a/packages/cw-schema/src/lib.rs +++ b/packages/cw-schema/src/lib.rs @@ -65,6 +65,15 @@ pub enum EnumValue { }, } +#[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))] @@ -106,6 +115,12 @@ pub enum NodeType { cases: BTreeMap, EnumCase>, }, + Map { + kind: MapKind, + key: DefinitionReference, + value: DefinitionReference, + }, + Optional { inner: DefinitionReference, }, From 5a13c0a9106f2c838c8e23c162286fadf5e6d031 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 10 Feb 2025 13:50:42 +0100 Subject: [PATCH 59/60] Fix lockfiles --- Cargo.lock | 2 +- packages/cw-schema-codegen/tests/rust-e2e/Cargo.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c9771801..87092ff8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "Inflector" diff --git a/packages/cw-schema-codegen/tests/rust-e2e/Cargo.lock b/packages/cw-schema-codegen/tests/rust-e2e/Cargo.lock index 27923bff0..61c92e6cd 100644 --- a/packages/cw-schema-codegen/tests/rust-e2e/Cargo.lock +++ b/packages/cw-schema-codegen/tests/rust-e2e/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "cosmwasm-schema" From 73a1f2c28de44ea7fa73dd4f6a95bea0eb610f39 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 10 Feb 2025 13:52:30 +0100 Subject: [PATCH 60/60] Fix CI failures --- contracts/nested-contracts/Cargo.lock | 18 +- contracts/replier/Cargo.lock | 372 +++++++++++++++++++-- packages/cw-schema-codegen/src/rust/mod.rs | 13 +- 3 files changed, 366 insertions(+), 37 deletions(-) diff --git a/contracts/nested-contracts/Cargo.lock b/contracts/nested-contracts/Cargo.lock index a109dc683..9e91e26e2 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/replier/Cargo.lock b/contracts/replier/Cargo.lock index 1dd590748..2575b7781 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/packages/cw-schema-codegen/src/rust/mod.rs b/packages/cw-schema-codegen/src/rust/mod.rs index b9531568c..ec9ebb0dd 100644 --- a/packages/cw-schema-codegen/src/rust/mod.rs +++ b/packages/cw-schema-codegen/src/rust/mod.rs @@ -28,15 +28,22 @@ fn expand_node_name<'a>( let inner = &schema.definitions[inner]; format!("Option<{}>", expand_node_name(schema, inner)).into() } - cw_schema::NodeType::Map { ref kind, key, value } => { + 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::BTree => { + format!("alloc::collections::BTreeMap<{key}, {value}>") + } cw_schema::MapKind::Hash => format!("std::collections::HashMap<{key}, {value}>"), _ => unimplemented!(), - }.into() + } + .into() } cw_schema::NodeType::Struct(..) => node.name.as_ref().into(), cw_schema::NodeType::Tuple { ref items } => {