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

add serde definitions #1

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a2d1abc
add serde definitions
ash-burnt Jun 1, 2024
8bfa16c
add pbjson
ash-burnt Jun 1, 2024
11179f1
add wasmd, update plugins
ash-burnt Jun 1, 2024
17d17d9
extern google types with pbjson-types
ash-burnt Jun 2, 2024
702d384
compiles
ash-burnt Jun 2, 2024
89cc500
patch validators policy for serde
ash-burnt Jun 2, 2024
69dd4c9
different patch for serde
ash-burnt Jun 2, 2024
5ebab1c
add more name definitions for authorizations
ash-burnt Jun 3, 2024
4b1332e
cosmrs: basic parsing of `msg_responses` field inside `TxMsgData` (#472)
jstuczyn Jun 13, 2024
17838dd
cosmos-sdk-proto v0.22.0 (#473)
tony-iqlusion Jun 27, 2024
64f4839
cosmrs v0.17.0 (#474)
tony-iqlusion Jun 27, 2024
ae003db
Bump tendermint-rs dependencies to v0.38 (#476)
tony-iqlusion Jul 18, 2024
c5db4e5
cosmos-sdk-proto: add support for `no_std` (#478)
conr2d Jul 31, 2024
871e514
cosmrs: support coins with amount `0`, empty denom (#479)
tony-iqlusion Aug 1, 2024
d94d08b
cosmos-sdk-proto v0.23.0 (#480)
tony-iqlusion Aug 3, 2024
eba698b
cosmrs v0.18.0 (#481)
tony-iqlusion Aug 3, 2024
9e1b3d6
Bump tendermint-rs dependencies to v0.39 (#482)
tony-iqlusion Aug 8, 2024
0dde80f
updated with upstream tendermint changes
ash-burnt Aug 8, 2024
9dae930
switch to informal pbjson
ash-burnt Aug 8, 2024
fda84ca
review notes
ash-burnt Aug 8, 2024
6755fa0
Bump tendermint-rs crates to v0.39.1 (#483)
tony-iqlusion Aug 9, 2024
b716d6d
Update cosmos-sdk-proto/Cargo.toml
ash-burnt Aug 9, 2024
b7e04cc
remove comment
ash-burnt Aug 9, 2024
f9e43da
Merge branch 'feat/serde' of github.com-ash:burnt-labs/cosmos-rust in…
ash-burnt Aug 9, 2024
8474c92
cargo changes
ash-burnt Aug 9, 2024
d36b12b
pull upstream
ash-burnt Aug 9, 2024
0960168
formatting
ash-burnt Aug 9, 2024
e8b7d05
cosmwasm authorizations don't exist in this version
ash-burnt Aug 9, 2024
304bc5d
bring in pbjson for serialization
ash-burnt Aug 9, 2024
395d8d7
Update cosmos-sdk-proto/Cargo.toml
ash-burnt Aug 9, 2024
39988e6
Update cosmos-sdk-proto/Cargo.toml
ash-burnt Aug 9, 2024
608a337
move serialization into a feature tag
ash-burnt Aug 9, 2024
368b109
change name to serde
ash-burnt Aug 11, 2024
41b9a21
format
ash-burnt Aug 13, 2024
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
422 changes: 298 additions & 124 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions cosmos-sdk-proto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.23.0 (2024-08-02)
### Added
- Support for `no_std` ([#478])

### Changed
- Bump `tendermint-proto` dependency to v0.38 ([#476])

[#476]: https://github.com/cosmos/cosmos-rust/pull/476
[#478]: https://github.com/cosmos/cosmos-rust/pull/478

## 0.22.0 (2024-06-27)
### Changed
- Bump `tendermint-proto` dependency to v0.37 ([#469])

[#469]: https://github.com/cosmos/cosmos-rust/pull/469

## 0.21.1 (2024-03-15)
### Removed
- Deprecated `MessageExt` methods: missed from v0.21.0, technically a breaking
Expand Down
15 changes: 9 additions & 6 deletions cosmos-sdk-proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cosmos-sdk-proto"
version = "0.22.0-pre"
version = "0.24.0-pre"
authors = [
"Justin Kilpatrick <justin@althea.net>",
"Greg Szabo <greg@informal.systems>",
Expand All @@ -16,18 +16,21 @@ edition = "2021"
rust-version = "1.72"

[dependencies]
prost = "0.12.3"
prost-types = "0.12"
tendermint-proto = "0.37"
prost = { version = "0.13", default-features = false }
tendermint-proto = "0.39.1"

# Optional dependencies
tonic = { version = "0.11", optional = true, default-features = false, features = ["codegen", "prost"] }
tonic = { version = "0.12", optional = true, default-features = false, features = ["codegen", "prost"] }
serde = { version = "1.0.203", optional = true, default-features = false, features = ["alloc"] }
pbjson = { package = "informalsystems-pbjson", optional = true, version = "0.7" }

[features]
default = ["grpc-transport"]
grpc = ["tonic"]
std = ["prost/std", "tendermint-proto/std"]
grpc = ["std", "tonic"]
grpc-transport = ["grpc", "tonic/transport"]
cosmwasm = []
serde = ["dep:serde", "tendermint-proto/std", "pbjson"]

[package.metadata.docs.rs]
all-features = true
Expand Down
5 changes: 4 additions & 1 deletion cosmos-sdk-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
)]
#![forbid(unsafe_code)]
#![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)]
#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

pub mod traits;
mod type_names;

pub use prost;
pub use prost_types::{Any, Timestamp};
pub use tendermint_proto as tendermint;
pub use tendermint_proto::google::protobuf::{Any, Timestamp};

/// The version (commit hash) of the Cosmos SDK used when generating this library.
pub const COSMOS_SDK_VERSION: &str = include_str!("prost/cosmos-sdk/COSMOS_SDK_COMMIT");
Expand Down
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,79 @@
// @generated
#[cfg(feature = "serde")]
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()
}
}
#[cfg(feature = "serde")]
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 {}
#[cfg(feature = "serde")]
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<::tendermint_proto::google::protobuf::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