From c7a3e039ce4d58062aa4d1f0556024bb6da5922f Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 2 Oct 2023 19:17:57 -0600 Subject: [PATCH] cosmos-sdk-proto: replace `TypeUrl` with `Name` trait The `Name` trait added upstream in `prost` can be used to compute the type URL using `Name::type_url`: https://github.com/tokio-rs/prost/pull/896 The new `Any::{from_msg, to_msg}` methods can be used to serialize `Message` types to/from messages. This commit switches from the `TypeUrl` trait to `Name` and relies more on upstream functionality in `prost`. Unfortunately it shipped with a bug in the default `Name::full_name` method, so a workaround is temporarily used until a fix ships: https://github.com/tokio-rs/prost/pull/923 --- cosmos-sdk-proto/src/lib.rs | 2 +- cosmos-sdk-proto/src/traits.rs | 29 +- cosmos-sdk-proto/src/type_names.rs | 507 +++++++++++++++++++++++++++++ cosmos-sdk-proto/src/type_urls.rs | 227 ------------- cosmrs/src/tx/msg.rs | 4 +- 5 files changed, 515 insertions(+), 254 deletions(-) create mode 100644 cosmos-sdk-proto/src/type_names.rs delete mode 100644 cosmos-sdk-proto/src/type_urls.rs diff --git a/cosmos-sdk-proto/src/lib.rs b/cosmos-sdk-proto/src/lib.rs index 9a37dc66..4e96f921 100644 --- a/cosmos-sdk-proto/src/lib.rs +++ b/cosmos-sdk-proto/src/lib.rs @@ -12,7 +12,7 @@ #![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)] pub mod traits; -mod type_urls; +mod type_names; pub use prost; pub use prost_types::Any; diff --git a/cosmos-sdk-proto/src/traits.rs b/cosmos-sdk-proto/src/traits.rs index 0b3c4e2a..619ed9e7 100644 --- a/cosmos-sdk-proto/src/traits.rs +++ b/cosmos-sdk-proto/src/traits.rs @@ -1,46 +1,27 @@ //! Support traits for Cosmos SDK protobufs. -pub use prost::Message; +pub use prost::{Message, Name}; use crate::Any; use prost::{DecodeError, EncodeError}; use std::str::FromStr; -/// Associate a type URL with a given proto. -pub trait TypeUrl: Message { - /// Type URL value - const TYPE_URL: &'static str; -} - /// Extension trait for [`Message`]. pub trait MessageExt: Message { /// Parse this message proto from [`Any`]. fn from_any(any: &Any) -> Result where - Self: Default + Sized + TypeUrl, + Self: Default + Name + Sized, { - if any.type_url == Self::TYPE_URL { - Ok(Self::decode(&*any.value)?) - } else { - let mut err = DecodeError::new(format!( - "expected type URL: \"{}\" (got: \"{}\")", - Self::TYPE_URL, - &any.type_url - )); - err.push("unexpected type URL", "type_url"); - Err(err) - } + any.to_msg() } /// Serialize this message proto as [`Any`]. fn to_any(&self) -> Result where - Self: TypeUrl, + Self: Name + Sized, { - self.to_bytes().map(|bytes| Any { - type_url: Self::TYPE_URL.to_owned(), - value: bytes, - }) + Any::from_msg(self) } /// Serialize this protobuf message as a byte vector. diff --git a/cosmos-sdk-proto/src/type_names.rs b/cosmos-sdk-proto/src/type_names.rs new file mode 100644 index 00000000..7985b29a --- /dev/null +++ b/cosmos-sdk-proto/src/type_names.rs @@ -0,0 +1,507 @@ +//! Registry of type URLs associated with various protobuf types defined in +//! this crate. + +// TODO(tarcieri): leverage first-class support for type URLs in prost? +// See: https://github.com/tokio-rs/prost/issues/299 + +use crate::{cosmos, ibc, traits::Name}; + +impl Name for ibc::core::client::v1::ClientUpdateProposal { + const NAME: &'static str = "ClientUpdateProposal"; + const PACKAGE: &'static str = "ibc.core.client.v1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::upgrade::v1beta1::SoftwareUpgradeProposal { + const NAME: &'static str = "SoftwareUpgradeProposal"; + const PACKAGE: &'static str = "cosmos.upgrade.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::params::v1beta1::ParameterChangeProposal { + const NAME: &'static str = "ParameterChangeProposal"; + const PACKAGE: &'static str = "cosmos.params.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::distribution::v1beta1::CommunityPoolSpendProposal { + const NAME: &'static str = "CommunityPoolSpendProposal"; + const PACKAGE: &'static str = "cosmos.distribution.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::gov::v1beta1::TextProposal { + const NAME: &'static str = "TextProposal"; + const PACKAGE: &'static str = "cosmos.gov.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::crypto::secp256k1::PubKey { + const NAME: &'static str = "PubKey"; + const PACKAGE: &'static str = "cosmos.crypto.secp256k1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::vesting::v1beta1::PeriodicVestingAccount { + const NAME: &'static str = "PeriodicVestingAccount"; + const PACKAGE: &'static str = "cosmos.vesting.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::bank::v1beta1::MsgSend { + const NAME: &'static str = "MsgSend"; + const PACKAGE: &'static str = "cosmos.bank.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::bank::v1beta1::MsgMultiSend { + const NAME: &'static str = "MsgMultiSend"; + const PACKAGE: &'static str = "cosmos.bank.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::distribution::v1beta1::MsgSetWithdrawAddress { + const NAME: &'static str = "MsgSetWithdrawAddress"; + const PACKAGE: &'static str = "cosmos.distribution.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward { + const NAME: &'static str = "MsgWithdrawDelegatorReward"; + const PACKAGE: &'static str = "cosmos.distribution.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission { + const NAME: &'static str = "MsgWithdrawValidatorCommission"; + const PACKAGE: &'static str = "cosmos.distribution.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::distribution::v1beta1::MsgFundCommunityPool { + const NAME: &'static str = "MsgFundCommunityPool"; + const PACKAGE: &'static str = "cosmos.distribution.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::feegrant::v1beta1::MsgGrantAllowance { + const NAME: &'static str = "MsgGrantAllowance"; + const PACKAGE: &'static str = "cosmos.feegrant.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::feegrant::v1beta1::MsgRevokeAllowance { + const NAME: &'static str = "MsgRevokeAllowance"; + const PACKAGE: &'static str = "cosmos.feegrant.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::feegrant::v1beta1::BasicAllowance { + const NAME: &'static str = "BasicAllowance"; + const PACKAGE: &'static str = "cosmos.feegrant.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::feegrant::v1beta1::PeriodicAllowance { + const NAME: &'static str = "PeriodicAllowance"; + const PACKAGE: &'static str = "cosmos.feegrant.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::feegrant::v1beta1::AllowedMsgAllowance { + const NAME: &'static str = "AllowedMsgAllowance"; + const PACKAGE: &'static str = "cosmos.feegrant.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::staking::v1beta1::MsgDelegate { + const NAME: &'static str = "MsgDelegate"; + const PACKAGE: &'static str = "cosmos.staking.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::staking::v1beta1::MsgUndelegate { + const NAME: &'static str = "MsgUndelegate"; + const PACKAGE: &'static str = "cosmos.staking.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::staking::v1beta1::MsgBeginRedelegate { + const NAME: &'static str = "MsgBeginRedelegate"; + const PACKAGE: &'static str = "cosmos.staking.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::base::abci::v1beta1::MsgData { + const NAME: &'static str = "MsgData"; + const PACKAGE: &'static str = "cosmos.base.v1beta1.abci"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::base::abci::v1beta1::TxMsgData { + const NAME: &'static str = "TxMsgData"; + const PACKAGE: &'static str = "cosmos.base.v1beta1.abci"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::auth::v1beta1::BaseAccount { + const NAME: &'static str = "BaseAccount"; + const PACKAGE: &'static str = "cosmos.auth.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::auth::v1beta1::ModuleAccount { + const NAME: &'static str = "ModuleAccount"; + const PACKAGE: &'static str = "cosmos.auth.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::tx::v1beta1::Tx { + const NAME: &'static str = "Tx"; + const PACKAGE: &'static str = "cosmos.tx.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::tx::v1beta1::AuthInfo { + const NAME: &'static str = "AuthInfo"; + const PACKAGE: &'static str = "cosmos.tx.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::tx::v1beta1::Fee { + const NAME: &'static str = "Fee"; + const PACKAGE: &'static str = "cosmos.tx.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::tx::v1beta1::TxBody { + const NAME: &'static str = "TxBody"; + const PACKAGE: &'static str = "cosmos.tx.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::tx::v1beta1::SignerInfo { + const NAME: &'static str = "SingerInfo"; + const PACKAGE: &'static str = "cosmos.tx.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for cosmos::tx::v1beta1::ModeInfo { + const NAME: &'static str = "ModeInfo"; + const PACKAGE: &'static str = "cosmos.tx.v1beta1"; + + fn full_name() -> String { + full_name::() + } +} + +impl Name for ibc::applications::transfer::v1::MsgTransfer { + const NAME: &'static str = "MsgTransfer"; + const PACKAGE: &'static str = "ibc.applications.transfer.v1"; + + fn full_name() -> String { + full_name::() + } +} + +#[cfg(feature = "cosmwasm")] +mod wasm { + use crate::{cosmwasm, traits::Name}; + use super::full_name; + + const PACKAGE: &'static str = "cosmwasm.wasm.v1"; + + impl Name for cosmwasm::wasm::v1::MigrateContractProposal { + const NAME: &'static str = "MigrateContractProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::UpdateInstantiateConfigProposal { + const NAME: &'static str = "UpdateInstantiateConfigProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::SudoContractProposal { + const NAME: &'static str = "SudoContractProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::ExecuteContractProposal { + const NAME: &'static str = "ExecuteContractProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::UpdateAdminProposal { + const NAME: &'static str = "UpdateAdminProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::ClearAdminProposal { + const NAME: &'static str = "ClearAdminProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::PinCodesProposal { + const NAME: &'static str = "PinCodesProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::UnpinCodesProposal { + const NAME: &'static str = "UnpinCodesProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::InstantiateContractProposal { + const NAME: &'static str = "InstantiateContractProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::StoreCodeProposal { + const NAME: &'static str = "StoreCodeProposal"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgStoreCode { + const NAME: &'static str = "MsgStoreCode"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgInstantiateContract { + const NAME: &'static str = "MsgInstantiateContract"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgExecuteContract { + const NAME: &'static str = "MsgExecuteContract"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgMigrateContract { + const NAME: &'static str = "MsgMigrateContract"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgUpdateAdmin { + const NAME: &'static str = "MsgUpdateAdmin"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgClearAdmin { + const NAME: &'static str = "MsgClearAdmin"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgStoreCodeResponse { + const NAME: &'static str = "MsgStoreCodeResponse"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgInstantiateContractResponse { + const NAME: &'static str = "MsgInstantiateContractResponse"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgExecuteContractResponse { + const NAME: &'static str = "MsgExecuteContractResponse"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgMigrateContractResponse { + const NAME: &'static str = "MsgMigrateContractResponse"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgUpdateAdminResponse { + const NAME: &'static str = "MsgUpdateAdminResponse"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } + + impl Name for cosmwasm::wasm::v1::MsgClearAdminResponse { + const NAME: &'static str = "MsgClearAdminResponse"; + const PACKAGE: &'static str = PACKAGE; + + fn full_name() -> String { + full_name::() + } + } +} + +/// Workaround until tokio-rs/prost#923 is released +// TODO(tarcieri): remove this before final release +fn full_name() -> String { + format!("{}.{}", T::PACKAGE, T::NAME) +} diff --git a/cosmos-sdk-proto/src/type_urls.rs b/cosmos-sdk-proto/src/type_urls.rs deleted file mode 100644 index d277ed7d..00000000 --- a/cosmos-sdk-proto/src/type_urls.rs +++ /dev/null @@ -1,227 +0,0 @@ -//! Registry of type URLs associated with various protobuf types defined in -//! this crate. - -// TODO(tarcieri): leverage first-class support for type URLs in prost? -// See: https://github.com/tokio-rs/prost/issues/299 - -use crate::{cosmos, ibc, traits::TypeUrl}; - -impl TypeUrl for ibc::core::client::v1::ClientUpdateProposal { - const TYPE_URL: &'static str = "/ibc.core.client.v1.ClientUpdateProposal"; -} - -impl TypeUrl for cosmos::upgrade::v1beta1::SoftwareUpgradeProposal { - const TYPE_URL: &'static str = "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal"; -} - -impl TypeUrl for cosmos::params::v1beta1::ParameterChangeProposal { - const TYPE_URL: &'static str = "/cosmos.params.v1beta1.ParameterChangeProposal"; -} - -impl TypeUrl for cosmos::distribution::v1beta1::CommunityPoolSpendProposal { - const TYPE_URL: &'static str = "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal"; -} -impl TypeUrl for cosmos::gov::v1beta1::TextProposal { - const TYPE_URL: &'static str = "/cosmos.gov.v1beta1.TextProposal"; -} - -impl TypeUrl for cosmos::crypto::secp256k1::PubKey { - const TYPE_URL: &'static str = "/cosmos.crypto.secp256k1.PubKey"; -} - -impl TypeUrl for cosmos::vesting::v1beta1::PeriodicVestingAccount { - const TYPE_URL: &'static str = "/cosmos.vesting.v1beta1.PeriodicVestingAccount"; -} - -impl TypeUrl for cosmos::bank::v1beta1::MsgSend { - const TYPE_URL: &'static str = "/cosmos.bank.v1beta1.MsgSend"; -} - -impl TypeUrl for cosmos::bank::v1beta1::MsgMultiSend { - const TYPE_URL: &'static str = "/cosmos.bank.v1beta1.MsgMultiSend"; -} - -impl TypeUrl for cosmos::distribution::v1beta1::MsgSetWithdrawAddress { - const TYPE_URL: &'static str = "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress"; -} - -impl TypeUrl for cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward { - const TYPE_URL: &'static str = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward"; -} - -impl TypeUrl for cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission { - const TYPE_URL: &'static str = "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission"; -} - -impl TypeUrl for cosmos::distribution::v1beta1::MsgFundCommunityPool { - const TYPE_URL: &'static str = "/cosmos.distribution.v1beta1.MsgFundCommunityPool"; -} - -impl TypeUrl for cosmos::feegrant::v1beta1::MsgGrantAllowance { - const TYPE_URL: &'static str = "/cosmos.feegrant.v1beta1.MsgGrantAllowance"; -} - -impl TypeUrl for cosmos::feegrant::v1beta1::MsgRevokeAllowance { - const TYPE_URL: &'static str = "/cosmos.feegrant.v1beta1.MsgRevokeAllowance"; -} - -impl TypeUrl for cosmos::feegrant::v1beta1::BasicAllowance { - const TYPE_URL: &'static str = "/cosmos.feegrant.v1beta1.BasicAllowance"; -} - -impl TypeUrl for cosmos::feegrant::v1beta1::PeriodicAllowance { - const TYPE_URL: &'static str = "/cosmos.feegrant.v1beta1.PeriodicAllowance"; -} - -impl TypeUrl for cosmos::feegrant::v1beta1::AllowedMsgAllowance { - const TYPE_URL: &'static str = "/cosmos.feegrant.v1beta1.AllowedMsgAllowance"; -} - -impl TypeUrl for cosmos::staking::v1beta1::MsgDelegate { - const TYPE_URL: &'static str = "/cosmos.staking.v1beta1.MsgDelegate"; -} - -impl TypeUrl for cosmos::staking::v1beta1::MsgUndelegate { - const TYPE_URL: &'static str = "/cosmos.staking.v1beta1.MsgUndelegate"; -} - -impl TypeUrl for cosmos::staking::v1beta1::MsgBeginRedelegate { - const TYPE_URL: &'static str = "/cosmos.staking.v1beta1.MsgBeginRedelegate"; -} - -impl TypeUrl for cosmos::base::abci::v1beta1::MsgData { - const TYPE_URL: &'static str = "/cosmos.base.v1beta1.abci.MsgData"; -} - -impl TypeUrl for cosmos::base::abci::v1beta1::TxMsgData { - const TYPE_URL: &'static str = "/cosmos.base.v1beta1.abci.TxMsgData"; -} - -impl TypeUrl for cosmos::auth::v1beta1::BaseAccount { - const TYPE_URL: &'static str = "/cosmos.auth.v1beta1.BaseAccount"; -} - -impl TypeUrl for cosmos::auth::v1beta1::ModuleAccount { - const TYPE_URL: &'static str = "/cosmos.auth.v1beta1.ModuleAccount"; -} - -impl TypeUrl for cosmos::tx::v1beta1::Tx { - const TYPE_URL: &'static str = "/cosmos.tx.v1beta1.Tx"; -} - -impl TypeUrl for cosmos::tx::v1beta1::AuthInfo { - const TYPE_URL: &'static str = "/cosmos.tx.v1beta1.AuthInfo"; -} - -impl TypeUrl for cosmos::tx::v1beta1::Fee { - const TYPE_URL: &'static str = "/cosmos.tx.v1beta1.Fee"; -} - -impl TypeUrl for cosmos::tx::v1beta1::TxBody { - const TYPE_URL: &'static str = "/cosmos.tx.v1beta1.TxBody"; -} - -impl TypeUrl for cosmos::tx::v1beta1::SignerInfo { - const TYPE_URL: &'static str = "/cosmos.tx.v1beta1.SingerInfo"; -} - -impl TypeUrl for cosmos::tx::v1beta1::ModeInfo { - const TYPE_URL: &'static str = "/cosmos.tx.v1beta1.ModeInfo"; -} - -impl TypeUrl for ibc::applications::transfer::v1::MsgTransfer { - const TYPE_URL: &'static str = "/ibc.applications.transfer.v1.MsgTransfer"; -} - -#[cfg(feature = "cosmwasm")] -mod wasm { - use crate::{cosmwasm, traits::TypeUrl}; - - impl TypeUrl for cosmwasm::wasm::v1::MigrateContractProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MigrateContractProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::UpdateInstantiateConfigProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.UpdateInstantiateConfigProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::SudoContractProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.SudoContractProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::ExecuteContractProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.ExecuteContractProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::UpdateAdminProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.UpdateAdminProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::ClearAdminProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.ClearAdminProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::PinCodesProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.PinCodesProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::UnpinCodesProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.UnpinCodesProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::InstantiateContractProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.InstantiateContractProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::StoreCodeProposal { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.StoreCodeProposal"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgStoreCode { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgStoreCode"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgInstantiateContract { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgInstantiateContract"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgExecuteContract { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgExecuteContract"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgMigrateContract { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgMigrateContract"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgUpdateAdmin { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgUpdateAdmin"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgClearAdmin { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgClearAdmin"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgStoreCodeResponse { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgStoreCodeResponse"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgInstantiateContractResponse { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgInstantiateContractResponse"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgExecuteContractResponse { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgExecuteContractResponse"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgMigrateContractResponse { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgMigrateContractResponse"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgUpdateAdminResponse { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgUpdateAdminResponse"; - } - - impl TypeUrl for cosmwasm::wasm::v1::MsgClearAdminResponse { - const TYPE_URL: &'static str = "/cosmwasm.wasm.v1.MsgClearAdminResponse"; - } -} diff --git a/cosmrs/src/tx/msg.rs b/cosmrs/src/tx/msg.rs index 61a343f3..19bc29d6 100644 --- a/cosmrs/src/tx/msg.rs +++ b/cosmrs/src/tx/msg.rs @@ -1,7 +1,7 @@ //! Transaction messages use crate::{ - proto::traits::{MessageExt, TypeUrl}, + proto::traits::{MessageExt, Name}, Any, ErrorReport, Result, }; @@ -15,7 +15,7 @@ pub trait Msg: Clone + Sized + TryFrom + Into { /// Protocol Buffers type - type Proto: Default + MessageExt + Sized + TypeUrl; + type Proto: Default + MessageExt + Name + Sized; /// Parse this message proto from [`Any`]. fn from_any(any: &Any) -> Result {