Skip to content

Commit

Permalink
cosmos-sdk-proto: use prost-build to generate Name impls
Browse files Browse the repository at this point in the history
Uses the recently added support in `prost-build` for automatically
generating impls of the `Name` trait, rather than maintaining them by
hand in the `type_names` module.
  • Loading branch information
tony-iqlusion committed Mar 15, 2024
1 parent d902b90 commit dfc3e7e
Show file tree
Hide file tree
Showing 24 changed files with 1,510 additions and 591 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion cosmos-sdk-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)]

pub mod traits;
mod type_names;

pub use prost;
pub use prost_types::{Any, Timestamp};
Expand Down
21 changes: 21 additions & 0 deletions cosmos-sdk-proto/src/prost/ibc-go/cosmos.auth.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ pub struct BaseAccount {
#[prost(uint64, tag = "4")]
pub sequence: u64,
}
impl ::prost::Name for BaseAccount {
const NAME: &'static str = "BaseAccount";
const PACKAGE: &'static str = "cosmos.auth.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.auth.v1beta1.{}", Self::NAME)
}
}
/// ModuleAccount defines an account for modules that holds coins on a pool.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -24,6 +31,13 @@ pub struct ModuleAccount {
#[prost(string, repeated, tag = "3")]
pub permissions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
impl ::prost::Name for ModuleAccount {
const NAME: &'static str = "ModuleAccount";
const PACKAGE: &'static str = "cosmos.auth.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.auth.v1beta1.{}", Self::NAME)
}
}
/// Params defines the parameters for the auth module.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -39,3 +53,10 @@ pub struct Params {
#[prost(uint64, tag = "5")]
pub sig_verify_cost_secp256k1: u64,
}
impl ::prost::Name for Params {
const NAME: &'static str = "Params";
const PACKAGE: &'static str = "cosmos.auth.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.auth.v1beta1.{}", Self::NAME)
}
}
14 changes: 14 additions & 0 deletions cosmos-sdk-proto/src/prost/ibc-go/cosmos.base.query.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ pub struct PageRequest {
#[prost(bool, tag = "4")]
pub count_total: bool,
}
impl ::prost::Name for PageRequest {
const NAME: &'static str = "PageRequest";
const PACKAGE: &'static str = "cosmos.base.query.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.base.query.v1beta1.{}", Self::NAME)
}
}
/// PageResponse is to be embedded in gRPC response messages where the
/// corresponding request message has used PageRequest.
///
Expand All @@ -48,3 +55,10 @@ pub struct PageResponse {
#[prost(uint64, tag = "2")]
pub total: u64,
}
impl ::prost::Name for PageResponse {
const NAME: &'static str = "PageResponse";
const PACKAGE: &'static str = "cosmos.base.query.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.base.query.v1beta1.{}", Self::NAME)
}
}
28 changes: 28 additions & 0 deletions cosmos-sdk-proto/src/prost/ibc-go/cosmos.base.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ pub struct Coin {
#[prost(string, tag = "2")]
pub amount: ::prost::alloc::string::String,
}
impl ::prost::Name for Coin {
const NAME: &'static str = "Coin";
const PACKAGE: &'static str = "cosmos.base.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME)
}
}
/// DecCoin defines a token with a denomination and a decimal amount.
///
/// NOTE: The amount field is an Dec which implements the custom method
Expand All @@ -22,17 +29,38 @@ pub struct DecCoin {
#[prost(string, tag = "2")]
pub amount: ::prost::alloc::string::String,
}
impl ::prost::Name for DecCoin {
const NAME: &'static str = "DecCoin";
const PACKAGE: &'static str = "cosmos.base.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME)
}
}
/// IntProto defines a Protobuf wrapper around an Int object.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IntProto {
#[prost(string, tag = "1")]
pub int: ::prost::alloc::string::String,
}
impl ::prost::Name for IntProto {
const NAME: &'static str = "IntProto";
const PACKAGE: &'static str = "cosmos.base.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME)
}
}
/// DecProto defines a Protobuf wrapper around a Dec object.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DecProto {
#[prost(string, tag = "1")]
pub dec: ::prost::alloc::string::String,
}
impl ::prost::Name for DecProto {
const NAME: &'static str = "DecProto";
const PACKAGE: &'static str = "cosmos.base.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME)
}
}
21 changes: 21 additions & 0 deletions cosmos-sdk-proto/src/prost/ibc-go/cosmos.upgrade.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ pub struct Plan {
#[prost(string, tag = "4")]
pub info: ::prost::alloc::string::String,
}
impl ::prost::Name for Plan {
const NAME: &'static str = "Plan";
const PACKAGE: &'static str = "cosmos.upgrade.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.upgrade.v1beta1.{}", Self::NAME)
}
}
/// SoftwareUpgradeProposal is a gov Content type for initiating a software
/// upgrade.
#[allow(clippy::derive_partial_eq_without_eq)]
Expand All @@ -36,6 +43,13 @@ pub struct SoftwareUpgradeProposal {
#[prost(message, optional, tag = "3")]
pub plan: ::core::option::Option<Plan>,
}
impl ::prost::Name for SoftwareUpgradeProposal {
const NAME: &'static str = "SoftwareUpgradeProposal";
const PACKAGE: &'static str = "cosmos.upgrade.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.upgrade.v1beta1.{}", Self::NAME)
}
}
/// CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software
/// upgrade.
#[allow(clippy::derive_partial_eq_without_eq)]
Expand All @@ -46,3 +60,10 @@ pub struct CancelSoftwareUpgradeProposal {
#[prost(string, tag = "2")]
pub description: ::prost::alloc::string::String,
}
impl ::prost::Name for CancelSoftwareUpgradeProposal {
const NAME: &'static str = "CancelSoftwareUpgradeProposal";
const PACKAGE: &'static str = "cosmos.upgrade.v1beta1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("cosmos.upgrade.v1beta1.{}", Self::NAME)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,30 @@ pub struct Params {
#[prost(bool, tag = "1")]
pub controller_enabled: bool,
}
impl ::prost::Name for Params {
const NAME: &'static str = "Params";
const PACKAGE: &'static str = "ibc.applications.interchain_accounts.controller.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!(
"ibc.applications.interchain_accounts.controller.v1.{}",
Self::NAME
)
}
}
/// QueryParamsRequest is the request type for the Query/Params RPC method.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsRequest {}
impl ::prost::Name for QueryParamsRequest {
const NAME: &'static str = "QueryParamsRequest";
const PACKAGE: &'static str = "ibc.applications.interchain_accounts.controller.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!(
"ibc.applications.interchain_accounts.controller.v1.{}",
Self::NAME
)
}
}
/// QueryParamsResponse is the response type for the Query/Params RPC method.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -19,6 +39,16 @@ pub struct QueryParamsResponse {
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
}
impl ::prost::Name for QueryParamsResponse {
const NAME: &'static str = "QueryParamsResponse";
const PACKAGE: &'static str = "ibc.applications.interchain_accounts.controller.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!(
"ibc.applications.interchain_accounts.controller.v1.{}",
Self::NAME
)
}
}
/// Generated client implementations.
#[cfg(feature = "grpc")]
pub mod query_client {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,30 @@ pub struct Params {
#[prost(string, repeated, tag = "2")]
pub allow_messages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
impl ::prost::Name for Params {
const NAME: &'static str = "Params";
const PACKAGE: &'static str = "ibc.applications.interchain_accounts.host.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!(
"ibc.applications.interchain_accounts.host.v1.{}",
Self::NAME
)
}
}
/// QueryParamsRequest is the request type for the Query/Params RPC method.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsRequest {}
impl ::prost::Name for QueryParamsRequest {
const NAME: &'static str = "QueryParamsRequest";
const PACKAGE: &'static str = "ibc.applications.interchain_accounts.host.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!(
"ibc.applications.interchain_accounts.host.v1.{}",
Self::NAME
)
}
}
/// QueryParamsResponse is the response type for the Query/Params RPC method.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -22,6 +42,16 @@ pub struct QueryParamsResponse {
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
}
impl ::prost::Name for QueryParamsResponse {
const NAME: &'static str = "QueryParamsResponse";
const PACKAGE: &'static str = "ibc.applications.interchain_accounts.host.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!(
"ibc.applications.interchain_accounts.host.v1.{}",
Self::NAME
)
}
}
/// Generated client implementations.
#[cfg(feature = "grpc")]
pub mod query_client {
Expand Down
Loading

0 comments on commit dfc3e7e

Please sign in to comment.