Skip to content

Commit

Permalink
prost: auto derive prost::Name (#163)
Browse files Browse the repository at this point in the history
* cmd(compile): auto derive `prost::Name`

* tools(proto-compiler): patch `Name` impl on `ValidatorsVec`

* ibc-proto: regenerate protos with `Name` impl

* Add changelog entry

* Require `prost` >= 0.12.3

---------

Co-authored-by: Romain Ruetschi <romain@informal.systems>
  • Loading branch information
erwanor and romac authored Nov 22, 2023
1 parent ed5ccac commit 8a4cd24
Show file tree
Hide file tree
Showing 60 changed files with 5,839 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/features/163-prost-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Derive the `prost::Name` trait for all Protobuf messages
([\#163](https://github.com/cosmos/ibc-proto-rs/pull/163))
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ doctest = false
all-features = true

[dependencies]
prost = { version = "0.12", default-features = false, features = ["prost-derive"] }
prost = { version = "0.12.3", default-features = false, features = ["prost-derive"] }
bytes = { version = "1.2", default-features = false }
tonic = { version = "0.10", default-features = false, optional = true }
serde = { version = "1.0", default-features = false, optional = true }
Expand Down
21 changes: 21 additions & 0 deletions src/prost/cosmos.app.v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ pub struct ModuleDescriptor {
#[prost(message, repeated, tag = "3")]
pub can_migrate_from: ::prost::alloc::vec::Vec<MigrateFromInfo>,
}
impl ::prost::Name for ModuleDescriptor {
const NAME: &'static str = "ModuleDescriptor";
const PACKAGE: &'static str = "cosmos.app.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.v1alpha1.{}", Self::NAME)
}
}
/// PackageReference is a reference to a protobuf package used by a module.
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down Expand Up @@ -70,6 +77,13 @@ pub struct PackageReference {
#[prost(uint32, tag = "2")]
pub revision: u32,
}
impl ::prost::Name for PackageReference {
const NAME: &'static str = "PackageReference";
const PACKAGE: &'static str = "cosmos.app.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.v1alpha1.{}", Self::NAME)
}
}
/// MigrateFromInfo is information on a module version that a newer module
/// can migrate from.
#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
Expand All @@ -81,3 +95,10 @@ pub struct MigrateFromInfo {
#[prost(string, tag = "1")]
pub module: ::prost::alloc::string::String,
}
impl ::prost::Name for MigrateFromInfo {
const NAME: &'static str = "MigrateFromInfo";
const PACKAGE: &'static str = "cosmos.app.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.v1alpha1.{}", Self::NAME)
}
}
14 changes: 14 additions & 0 deletions src/prost/cosmos.auth.module.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ pub struct Module {
#[prost(string, tag = "3")]
pub authority: ::prost::alloc::string::String,
}
impl ::prost::Name for Module {
const NAME: &'static str = "Module";
const PACKAGE: &'static str = "cosmos.auth.module.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.auth.module.v1.{}", Self::NAME)
}
}
/// ModuleAccountPermission represents permissions for a module account.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -24,3 +31,10 @@ pub struct ModuleAccountPermission {
#[prost(string, repeated, tag = "2")]
pub permissions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
impl ::prost::Name for ModuleAccountPermission {
const NAME: &'static str = "ModuleAccountPermission";
const PACKAGE: &'static str = "cosmos.auth.module.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.auth.module.v1.{}", Self::NAME)
}
}
Loading

0 comments on commit 8a4cd24

Please sign in to comment.