Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cosmos-sdk-proto: add serde derive macros #471

Merged
merged 24 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 70 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cosmos-sdk-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ rust-version = "1.72"
prost = "0.12.3"
prost-types = "0.12"
tendermint-proto = "0.37"
serde = "1.0.203"
tony-iqlusion marked this conversation as resolved.
Show resolved Hide resolved
pbjson = "0.6.0"
pbjson-types = "0.6.0"
tony-iqlusion marked this conversation as resolved.
Show resolved Hide resolved

# Optional dependencies
tonic = { version = "0.11", optional = true, default-features = false, features = ["codegen", "prost"] }
Expand Down
2 changes: 1 addition & 1 deletion cosmos-sdk-proto/src/prost/cosmos-sdk/COSMOS_SDK_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.46.15
v0.47.10
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @generated
/// Module is the module config object for the cosmos.app v1 app module.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Module {}
include!("cosmos.app.module.v1alpha1.serde.rs");
// @@protoc_insertion_point(module)
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// @generated
impl serde::Serialize for Module {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let len = 0;
let struct_ser = serializer.serialize_struct("cosmos.app.module.v1alpha1.Module", len)?;
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for Module {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[];

#[allow(clippy::enum_variant_names)]
enum GeneratedField {}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;

impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;

fn expecting(
&self,
formatter: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}

#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
Err(serde::de::Error::unknown_field(value, FIELDS))
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = Module;

fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct cosmos.app.module.v1alpha1.Module")
}

fn visit_map<V>(self, mut map_: V) -> std::result::Result<Module, V::Error>
where
V: serde::de::MapAccess<'de>,
{
while map_.next_key::<GeneratedField>()?.is_some() {
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
}
Ok(Module {})
}
}
deserializer.deserialize_struct(
"cosmos.app.module.v1alpha1.Module",
FIELDS,
GeneratedVisitor,
)
}
}
10 changes: 9 additions & 1 deletion cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.app.v1alpha1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @generated
/// ModuleDescriptor describes an app module.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModuleDescriptor {
/// go_import names the package that should be imported by an app to load the
Expand All @@ -24,6 +25,7 @@ pub struct ModuleDescriptor {
pub can_migrate_from: ::prost::alloc::vec::Vec<MigrateFromInfo>,
}
/// PackageReference is a reference to a protobuf package used by a module.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PackageReference {
/// name is the fully-qualified name of the package.
Expand Down Expand Up @@ -69,6 +71,7 @@ pub struct PackageReference {
}
/// MigrateFromInfo is information on a module version that a newer module
/// can migrate from.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MigrateFromInfo {
/// module is the fully-qualified protobuf name of the module config object
Expand All @@ -83,13 +86,15 @@ pub struct MigrateFromInfo {
/// allow a mixture of declarative and imperative app wiring, however, apps
/// that strive for the maximum ease of maintainability should be able to describe
/// their state machine with a config object alone.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Config {
/// modules are the module configurations for the app.
#[prost(message, repeated, tag = "1")]
pub modules: ::prost::alloc::vec::Vec<ModuleConfig>,
}
/// ModuleConfig is a module configuration for an app.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModuleConfig {
/// name is the unique name of the module within the app. It should be a name
Expand All @@ -107,17 +112,20 @@ pub struct ModuleConfig {
/// config is the config object for the module. Module config messages should
/// define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension.
#[prost(message, optional, tag = "2")]
pub config: ::core::option::Option<::prost_types::Any>,
pub config: ::core::option::Option<::pbjson_types::Any>,
}
/// QueryConfigRequest is the Query/Config request type.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryConfigRequest {}
/// QueryConfigRequest is the Query/Config response type.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryConfigResponse {
/// config is the current app config.
#[prost(message, optional, tag = "1")]
pub config: ::core::option::Option<Config>,
}
include!("cosmos.app.v1alpha1.serde.rs");
include!("cosmos.app.v1alpha1.tonic.rs");
// @@protoc_insertion_point(module)
Loading
Loading