Skip to content

Commit

Permalink
cosmos-sdk-proto: use buf's enable_type_names feature (#490)
Browse files Browse the repository at this point in the history
Automatically impl the `prost::Name` trait using `buf` rather than
manually maintaining a type registry in `type_names.rs`
  • Loading branch information
tony-iqlusion authored Aug 14, 2024
1 parent 363eaaf commit 1cf7192
Show file tree
Hide file tree
Showing 77 changed files with 5,660 additions and 508 deletions.
1 change: 0 additions & 1 deletion cosmos-sdk-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
extern crate alloc;

pub mod traits;
mod type_names;

pub use prost;
pub use tendermint_proto as tendermint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ pub struct Module {
#[prost(string, repeated, tag = "9")]
pub prepare_check_staters: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
impl ::prost::Name for Module {
const NAME: &'static str = "Module";
const PACKAGE: &'static str = "cosmos.app.runtime.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.runtime.v1alpha1.{}", Self::NAME)
}
}
/// StoreKeyConfig may be supplied to override the default module store key, which
/// is the module name.
#[allow(clippy::derive_partial_eq_without_eq)]
Expand All @@ -58,5 +65,12 @@ pub struct StoreKeyConfig {
#[prost(string, tag = "2")]
pub kv_store_key: ::prost::alloc::string::String,
}
impl ::prost::Name for StoreKeyConfig {
const NAME: &'static str = "StoreKeyConfig";
const PACKAGE: &'static str = "cosmos.app.runtime.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.runtime.v1alpha1.{}", Self::NAME)
}
}
include!("cosmos.app.runtime.v1alpha1.serde.rs");
// @@protoc_insertion_point(module)
56 changes: 56 additions & 0 deletions cosmos-sdk-proto/src/prost/cosmos-sdk/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.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -69,6 +76,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.
#[allow(clippy::derive_partial_eq_without_eq)]
Expand All @@ -79,6 +93,13 @@ 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)
}
}
/// Config represents the configuration for a Cosmos SDK ABCI app.
/// It is intended that all state machine logic including the version of
/// baseapp and tx handlers (and possibly even Tendermint) that an app needs
Expand All @@ -98,6 +119,13 @@ pub struct Config {
#[prost(message, repeated, tag = "2")]
pub golang_bindings: ::prost::alloc::vec::Vec<GolangBinding>,
}
impl ::prost::Name for Config {
const NAME: &'static str = "Config";
const PACKAGE: &'static str = "cosmos.app.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.v1alpha1.{}", Self::NAME)
}
}
/// ModuleConfig is a module configuration for an app.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -124,6 +152,13 @@ pub struct ModuleConfig {
#[prost(message, repeated, tag = "3")]
pub golang_bindings: ::prost::alloc::vec::Vec<GolangBinding>,
}
impl ::prost::Name for ModuleConfig {
const NAME: &'static str = "ModuleConfig";
const PACKAGE: &'static str = "cosmos.app.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.v1alpha1.{}", Self::NAME)
}
}
/// GolangBinding is an explicit interface type to implementing type binding for dependency injection.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -135,10 +170,24 @@ pub struct GolangBinding {
#[prost(string, tag = "2")]
pub implementation: ::prost::alloc::string::String,
}
impl ::prost::Name for GolangBinding {
const NAME: &'static str = "GolangBinding";
const PACKAGE: &'static str = "cosmos.app.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.v1alpha1.{}", Self::NAME)
}
}
/// QueryConfigRequest is the Query/Config request type.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryConfigRequest {}
impl ::prost::Name for QueryConfigRequest {
const NAME: &'static str = "QueryConfigRequest";
const PACKAGE: &'static str = "cosmos.app.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.v1alpha1.{}", Self::NAME)
}
}
/// QueryConfigRequest is the Query/Config response type.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -147,6 +196,13 @@ pub struct QueryConfigResponse {
#[prost(message, optional, tag = "1")]
pub config: ::core::option::Option<Config>,
}
impl ::prost::Name for QueryConfigResponse {
const NAME: &'static str = "QueryConfigResponse";
const PACKAGE: &'static str = "cosmos.app.v1alpha1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.app.v1alpha1.{}", Self::NAME)
}
}
include!("cosmos.app.v1alpha1.serde.rs");
include!("cosmos.app.v1alpha1.tonic.rs");
// @@protoc_insertion_point(module)
14 changes: 14 additions & 0 deletions cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.auth.module.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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 @@ -25,5 +32,12 @@ 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)
}
}
include!("cosmos.auth.module.v1.serde.rs");
// @@protoc_insertion_point(module)
Loading

0 comments on commit 1cf7192

Please sign in to comment.