├── .gitignore ├── rust-toolchain ├── cosmos-sdk-proto ├── src │ ├── prost │ │ ├── wasmd │ │ │ ├── WASMD_COMMIT │ │ │ ├── amino.rs │ │ │ ├── cosmos.msg.v1.rs │ │ │ ├── cosmos.query.v1.rs │ │ │ └── cosmos.base.v1beta1.rs │ │ └── cosmos-sdk │ │ │ ├── COSMOS_SDK_COMMIT │ │ │ ├── amino.rs │ │ │ ├── cosmos.msg.v1.rs │ │ │ ├── cosmos.query.v1.rs │ │ │ ├── cosmos.msg.textual.v1.rs │ │ │ ├── cosmos.nft.module.v1.rs │ │ │ ├── cosmos.authz.module.v1.rs │ │ │ ├── cosmos.params.module.v1.rs │ │ │ ├── cosmos.genutil.module.v1.rs │ │ │ ├── cosmos.vesting.module.v1.rs │ │ │ ├── cosmos.evidence.module.v1.rs │ │ │ ├── cosmos.feegrant.module.v1.rs │ │ │ ├── cosmos.orm.module.v1alpha1.rs │ │ │ ├── cosmos.circuit.module.v1.rs │ │ │ ├── cosmos.upgrade.module.v1.rs │ │ │ ├── cosmos.genutil.v1beta1.rs │ │ │ ├── cosmos.slashing.module.v1.rs │ │ │ ├── cosmos.consensus.module.v1.rs │ │ │ ├── cosmos.mint.module.v1.rs │ │ │ ├── cosmos.distribution.module.v1.rs │ │ │ ├── cosmos.crypto.multisig.rs │ │ │ ├── cosmos.crisis.module.v1.rs │ │ │ ├── cosmos.gov.module.v1.rs │ │ │ ├── cosmos.tx.config.v1.rs │ │ │ ├── cosmos.group.module.v1.rs │ │ │ ├── cosmos.crypto.hd.v1.rs │ │ │ ├── cosmos.reflection.v1.rs │ │ │ ├── cosmos.crypto.secp256r1.rs │ │ │ ├── cosmos.store.internal.kv.v1beta1.rs │ │ │ ├── cosmos.crypto.secp256k1.rs │ │ │ ├── cosmos.staking.module.v1.rs │ │ │ ├── cosmos.bank.module.v1.rs │ │ │ ├── cosmos.crypto.ed25519.rs │ │ │ ├── cosmos.crypto.multisig.v1beta1.rs │ │ │ ├── cosmos.auth.module.v1.rs │ │ │ ├── cosmos.nft.module.v1.serde.rs │ │ │ ├── cosmos.authz.module.v1.serde.rs │ │ │ ├── cosmos.base.v1beta1.rs │ │ │ ├── cosmos.params.module.v1.serde.rs │ │ │ ├── cosmos.genutil.module.v1.serde.rs │ │ │ ├── cosmos.vesting.module.v1.serde.rs │ │ │ ├── cosmos.base.reflection.v1beta1.rs │ │ │ ├── cosmos.evidence.module.v1.serde.rs │ │ │ ├── cosmos.feegrant.module.v1.serde.rs │ │ │ └── cosmos.orm.module.v1alpha1.serde.rs │ └── traits.rs ├── Cargo.toml └── README.md ├── .images └── cosmos.png ├── cosmrs ├── src │ ├── base │ │ ├── query.rs │ │ ├── denom.rs │ │ └── coin.rs │ ├── crypto │ │ ├── secp256k1.rs │ │ └── compact_bit_array.rs │ ├── auth.rs │ ├── bank.rs │ ├── crypto.rs │ ├── abci.rs │ ├── base.rs │ ├── feegrant.rs │ ├── vesting.rs │ ├── distribution.rs │ ├── slashing │ │ ├── query_params_request.rs │ │ ├── missed_block.rs │ │ ├── query_signing_infos_request.rs │ │ ├── query_params_response.rs │ │ ├── query_signing_info_request.rs │ │ ├── query_signing_info_response.rs │ │ ├── signing_info.rs │ │ ├── validator_missed_blocks.rs │ │ ├── query_signing_infos_response.rs │ │ ├── msg_unjail.rs │ │ ├── genesis_state.rs │ │ └── params.rs │ ├── staking │ │ ├── query_historical_info_request.rs │ │ ├── query_validator_request.rs │ │ ├── query_validator_response.rs │ │ ├── query_historical_info_response.rs │ │ ├── query_validators_request.rs │ │ ├── commission_rates.rs │ │ ├── historical_info.rs │ │ ├── description.rs │ │ ├── query_validators_response.rs │ │ ├── commission.rs │ │ ├── msg_delegate.rs │ │ ├── msg_undelegate.rs │ │ └── msg_begin_redelegate.rs │ ├── tx │ │ ├── msg.rs │ │ ├── raw.rs │ │ ├── builder.rs │ │ └── auth_info.rs │ ├── abci │ │ └── gas_info.rs │ ├── slashing.rs │ ├── staking.rs │ ├── cosmwasm │ │ ├── query_code_response.rs │ │ ├── absolute_tx_position.rs │ │ ├── contract_code_history_entry.rs │ │ ├── code_info_response.rs │ │ ├── access_config.rs │ │ ├── contract_info.rs │ │ ├── msg_clear_admin.rs │ │ ├── msg_migrate_contract.rs │ │ ├── msg_update_admin.rs │ │ ├── msg_store_code.rs │ │ └── msg_execute_contract.rs │ ├── vesting │ │ ├── period.rs │ │ ├── delayed_vesting_account.rs │ │ ├── permanent_locked_account.rs │ │ ├── continuous_vesting_account.rs │ │ ├── periodic_vesting_account.rs │ │ └── base_vesting_account.rs │ ├── auth │ │ ├── module_account.rs │ │ └── base_account.rs │ ├── cosmwasm.rs │ ├── lib.rs │ ├── error.rs │ ├── bank │ │ ├── msg_send.rs │ │ ├── msg_multi_send.rs │ │ └── multi_send_io.rs │ ├── feegrant │ │ ├── msg_revoke_allowance.rs │ │ ├── msg_grant_allowance.rs │ │ ├── allowed_msg_allowance.rs │ │ └── basic_allowance.rs │ └── distribution │ │ ├── msg_set_withdraw_address.rs │ │ ├── msg_withdraw_validator_commission.rs │ │ ├── msg_withdraw_delegator_reward.rs │ │ └── msg_fund_community_pool.rs ├── Cargo.toml └── README.md ├── Cargo.toml ├── .github ├── dependabot.yml └── workflows │ ├── proto-build.yml │ ├── workspace.yml │ ├── cosmos-sdk-proto.yml │ └── cosmrs.yml ├── .gitmodules ├── proto-build ├── Cargo.toml ├── buf.sdk.gen.yaml └── buf.wasmd.gen.yaml └── .githooks └── pre-commit /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /rust-toolchain: -------------------------------------------------------------------------------- 1 | 1.75.0 2 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/wasmd/WASMD_COMMIT: -------------------------------------------------------------------------------- 1 | v0.52.0 -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/COSMOS_SDK_COMMIT: -------------------------------------------------------------------------------- 1 | v0.50.9 -------------------------------------------------------------------------------- /.images/cosmos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmos/cosmos-rust/HEAD/.images/cosmos.png -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/wasmd/amino.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /cosmrs/src/base/query.rs: -------------------------------------------------------------------------------- 1 | mod pagination; 2 | 3 | pub use pagination::{PageRequest, PageResponse}; 4 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/amino.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/wasmd/cosmos.msg.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.msg.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/wasmd/cosmos.query.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.query.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.msg.textual.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "proto-build", 5 | "cosmos-sdk-proto", 6 | "cosmrs" 7 | ] 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: "/" 5 | schedule: 6 | interval: weekly 7 | open-pull-requests-limit: 10 8 | -------------------------------------------------------------------------------- /cosmrs/src/crypto/secp256k1.rs: -------------------------------------------------------------------------------- 1 | //! ECDSA/secp256k1 support 2 | 3 | mod signing_key; 4 | 5 | pub use self::signing_key::{EcdsaSigner, SigningKey}; 6 | pub use k256::ecdsa::{Signature, VerifyingKey}; 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cosmos-sdk"] 2 | path = cosmos-sdk-go 3 | url = https://github.com/cosmos/cosmos-sdk.git 4 | [submodule "wasmd"] 5 | path = wasmd 6 | url = https://github.com/CosmWasm/wasmd.git 7 | -------------------------------------------------------------------------------- /cosmrs/src/auth.rs: -------------------------------------------------------------------------------- 1 | //! Authentication module: AuthN-related functionality. 2 | 3 | mod base_account; 4 | mod module_account; 5 | 6 | pub use self::{base_account::BaseAccount, module_account::ModuleAccount}; 7 | -------------------------------------------------------------------------------- /cosmrs/src/bank.rs: -------------------------------------------------------------------------------- 1 | //! Bank module support 2 | //! 3 | //! 4 | 5 | mod msg_multi_send; 6 | mod msg_send; 7 | mod multi_send_io; 8 | 9 | pub use self::{msg_multi_send::MsgMultiSend, msg_send::MsgSend, multi_send_io::MultiSendIo}; 10 | -------------------------------------------------------------------------------- /cosmrs/src/crypto.rs: -------------------------------------------------------------------------------- 1 | //! Cryptographic functionality 2 | 3 | pub mod secp256k1; 4 | 5 | mod compact_bit_array; 6 | mod legacy_amino; 7 | mod public_key; 8 | 9 | pub use self::{ 10 | compact_bit_array::CompactBitArray, legacy_amino::LegacyAminoMultisig, public_key::PublicKey, 11 | }; 12 | -------------------------------------------------------------------------------- /cosmrs/src/abci.rs: -------------------------------------------------------------------------------- 1 | //! Application/BlockChain Interface (ABCI)-related functionality. 2 | 3 | mod gas_info; 4 | mod msg_data; 5 | 6 | pub use self::{ 7 | gas_info::GasInfo, 8 | msg_data::{MsgData, MsgResponse, TxMsgData}, 9 | }; 10 | 11 | /// Transaction data. 12 | pub type Data = Vec; 13 | -------------------------------------------------------------------------------- /cosmrs/src/base.rs: -------------------------------------------------------------------------------- 1 | //! Base functionality. 2 | 3 | mod account_id; 4 | mod coin; 5 | mod denom; 6 | 7 | /// Query support 8 | pub mod query; 9 | 10 | pub use self::{account_id::AccountId, coin::Coin, denom::Denom}; 11 | 12 | /// Amounts. 13 | pub type Amount = u128; 14 | 15 | /// Gas cost. 16 | pub type Gas = u64; 17 | -------------------------------------------------------------------------------- /proto-build/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "proto-build" 3 | version = "0.1.0" 4 | authors = ["Justin Kilpatrick ", "Tony Arcieri "] 5 | edition = "2018" 6 | publish = false 7 | rust-version = "1.75" 8 | 9 | [dependencies] 10 | prost = "0.13" 11 | prost-build = "0.13" 12 | tonic = "0.13" 13 | tonic-build = "0.13" 14 | regex = "1" 15 | walkdir = "2" 16 | -------------------------------------------------------------------------------- /proto-build/buf.sdk.gen.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | plugins: 3 | - plugin: buf.build/community/neoeinstein-prost:v0.3.1 4 | out: . 5 | opt: 6 | - compile_well_known_types 7 | - enable_type_names 8 | - extern_path=.google.protobuf=::tendermint_proto::google::protobuf 9 | - extern_path=.tendermint=::tendermint_proto 10 | - plugin: buf.build/community/neoeinstein-prost-serde:v0.3.0 11 | out: . 12 | - plugin: buf.build/community/neoeinstein-tonic:v0.3.0 13 | out: . 14 | -------------------------------------------------------------------------------- /cosmrs/src/feegrant.rs: -------------------------------------------------------------------------------- 1 | //! Fee grant module support 2 | //! 3 | //! 4 | 5 | mod allowed_msg_allowance; 6 | mod basic_allowance; 7 | mod msg_grant_allowance; 8 | mod msg_revoke_allowance; 9 | mod periodic_allowance; 10 | 11 | pub use self::{ 12 | allowed_msg_allowance::AllowedMsgAllowance, basic_allowance::BasicAllowance, 13 | msg_grant_allowance::MsgGrantAllowance, msg_revoke_allowance::MsgRevokeAllowance, 14 | periodic_allowance::PeriodicAllowance, 15 | }; 16 | -------------------------------------------------------------------------------- /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | LC_ALL=C 3 | 4 | local_branch="$(git rev-parse --abbrev-ref HEAD)" 5 | 6 | valid_branch_regex="[a-z0-9._-]+\/[a-z0-9._-]+$" 7 | 8 | message="There is something wrong with your branch name. Branch names in this project must adhere to the format username/branch-name. Your commit will be rejected. You should rename your branch to a valid name and try again." 9 | 10 | if [[ ! $local_branch =~ $valid_branch_regex ]] 11 | then 12 | echo "$message" 13 | exit 1 14 | fi 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /proto-build/buf.wasmd.gen.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | plugins: 3 | - plugin: buf.build/community/neoeinstein-prost:v0.3.1 4 | out: . 5 | opt: 6 | - compile_well_known_types 7 | - enable_type_names 8 | - extern_path=.google.protobuf=::tendermint_proto::google::protobuf 9 | - extern_path=.tendermint=::tendermint_proto::v0_34 10 | - plugin: buf.build/community/neoeinstein-prost-serde:v0.3.0 11 | out: . 12 | - plugin: buf.build/community/neoeinstein-tonic:v0.3.0 13 | out: . 14 | opt: 15 | - no_server=true 16 | -------------------------------------------------------------------------------- /cosmrs/src/vesting.rs: -------------------------------------------------------------------------------- 1 | //! Vesting-related types 2 | 3 | mod base_vesting_account; 4 | mod continuous_vesting_account; 5 | mod delayed_vesting_account; 6 | mod period; 7 | mod periodic_vesting_account; 8 | mod permanent_locked_account; 9 | 10 | pub use self::{ 11 | base_vesting_account::BaseVestingAccount, continuous_vesting_account::ContinuousVestingAccount, 12 | delayed_vesting_account::DelayedVestingAccount, period::Period, 13 | periodic_vesting_account::PeriodicVestingAccount, 14 | permanent_locked_account::PermanentLockedAccount, 15 | }; 16 | -------------------------------------------------------------------------------- /cosmrs/src/distribution.rs: -------------------------------------------------------------------------------- 1 | //! Distribution module support 2 | //! 3 | //! 4 | 5 | mod msg_fund_community_pool; 6 | mod msg_set_withdraw_address; 7 | mod msg_withdraw_delegator_reward; 8 | mod msg_withdraw_validator_commission; 9 | 10 | pub use self::{ 11 | msg_fund_community_pool::MsgFundCommunityPool, msg_set_withdraw_address::MsgSetWithdrawAddress, 12 | msg_withdraw_delegator_reward::MsgWithdrawDelegatorReward, 13 | msg_withdraw_validator_commission::MsgWithdrawValidatorCommission, 14 | }; 15 | -------------------------------------------------------------------------------- /.github/workflows/proto-build.yml: -------------------------------------------------------------------------------- 1 | name: proto-build 2 | 3 | on: 4 | push: 5 | branches: main 6 | pull_request: 7 | paths: 8 | - ".github/workflows/proto-build.yml" 9 | - "proto-build/**" 10 | - "Cargo.*" 11 | 12 | defaults: 13 | run: 14 | working-directory: proto-build 15 | 16 | env: 17 | CARGO_TERM_COLOR: always 18 | RUSTFLAGS: -Dwarnings 19 | 20 | jobs: 21 | build: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v2 25 | - run: cargo build --verbose 26 | - run: cargo test --verbose 27 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.nft.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the nft module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module {} 6 | impl ::prost::Name for Module { 7 | const NAME: &'static str = "Module"; 8 | const PACKAGE: &'static str = "cosmos.nft.module.v1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.nft.module.v1.{}", Self::NAME) 11 | } 12 | } 13 | include!("cosmos.nft.module.v1.serde.rs"); 14 | // @@protoc_insertion_point(module) 15 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.authz.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the authz module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module {} 6 | impl ::prost::Name for Module { 7 | const NAME: &'static str = "Module"; 8 | const PACKAGE: &'static str = "cosmos.authz.module.v1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.authz.module.v1.{}", Self::NAME) 11 | } 12 | } 13 | include!("cosmos.authz.module.v1.serde.rs"); 14 | // @@protoc_insertion_point(module) 15 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.params.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the params module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module {} 6 | impl ::prost::Name for Module { 7 | const NAME: &'static str = "Module"; 8 | const PACKAGE: &'static str = "cosmos.params.module.v1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.params.module.v1.{}", Self::NAME) 11 | } 12 | } 13 | include!("cosmos.params.module.v1.serde.rs"); 14 | // @@protoc_insertion_point(module) 15 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.genutil.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object for the genutil module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module {} 6 | impl ::prost::Name for Module { 7 | const NAME: &'static str = "Module"; 8 | const PACKAGE: &'static str = "cosmos.genutil.module.v1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.genutil.module.v1.{}", Self::NAME) 11 | } 12 | } 13 | include!("cosmos.genutil.module.v1.serde.rs"); 14 | // @@protoc_insertion_point(module) 15 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.vesting.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the vesting module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module {} 6 | impl ::prost::Name for Module { 7 | const NAME: &'static str = "Module"; 8 | const PACKAGE: &'static str = "cosmos.vesting.module.v1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.vesting.module.v1.{}", Self::NAME) 11 | } 12 | } 13 | include!("cosmos.vesting.module.v1.serde.rs"); 14 | // @@protoc_insertion_point(module) 15 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.evidence.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the evidence module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module {} 6 | impl ::prost::Name for Module { 7 | const NAME: &'static str = "Module"; 8 | const PACKAGE: &'static str = "cosmos.evidence.module.v1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.evidence.module.v1.{}", Self::NAME) 11 | } 12 | } 13 | include!("cosmos.evidence.module.v1.serde.rs"); 14 | // @@protoc_insertion_point(module) 15 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.feegrant.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the feegrant module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module {} 6 | impl ::prost::Name for Module { 7 | const NAME: &'static str = "Module"; 8 | const PACKAGE: &'static str = "cosmos.feegrant.module.v1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.feegrant.module.v1.{}", Self::NAME) 11 | } 12 | } 13 | include!("cosmos.feegrant.module.v1.serde.rs"); 14 | // @@protoc_insertion_point(module) 15 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/query_params_request.rs: -------------------------------------------------------------------------------- 1 | use crate::proto; 2 | 3 | /// QueryParamsRequest is the request type for the Query/Params RPC method 4 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] 5 | pub struct QueryParamsRequest {} 6 | 7 | impl From for QueryParamsRequest { 8 | fn from(_proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::QueryParamsRequest) -> Self { 9 | QueryParamsRequest {} 10 | } 11 | } 12 | impl From for proto::cosmos::slashing::v1beta1::QueryParamsRequest { 13 | fn from(_request: QueryParamsRequest) -> Self { 14 | cosmos_sdk_proto::cosmos::slashing::v1beta1::QueryParamsRequest {} 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.orm.module.v1alpha1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module defines the ORM module which adds providers to the app container for 3 | /// ORM ModuleDB's and in the future will automatically register query 4 | /// services for modules that use the ORM. 5 | #[allow(clippy::derive_partial_eq_without_eq)] 6 | #[derive(Clone, PartialEq, ::prost::Message)] 7 | pub struct Module {} 8 | impl ::prost::Name for Module { 9 | const NAME: &'static str = "Module"; 10 | const PACKAGE: &'static str = "cosmos.orm.module.v1alpha1"; 11 | fn full_name() -> ::prost::alloc::string::String { 12 | ::prost::alloc::format!("cosmos.orm.module.v1alpha1.{}", Self::NAME) 13 | } 14 | } 15 | include!("cosmos.orm.module.v1alpha1.serde.rs"); 16 | // @@protoc_insertion_point(module) 17 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.circuit.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the circuit module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// authority defines the custom module authority. If not set, defaults to the governance module. 7 | #[prost(string, tag = "1")] 8 | pub authority: ::prost::alloc::string::String, 9 | } 10 | impl ::prost::Name for Module { 11 | const NAME: &'static str = "Module"; 12 | const PACKAGE: &'static str = "cosmos.circuit.module.v1"; 13 | fn full_name() -> ::prost::alloc::string::String { 14 | ::prost::alloc::format!("cosmos.circuit.module.v1.{}", Self::NAME) 15 | } 16 | } 17 | include!("cosmos.circuit.module.v1.serde.rs"); 18 | // @@protoc_insertion_point(module) 19 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.upgrade.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the upgrade module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// authority defines the custom module authority. If not set, defaults to the governance module. 7 | #[prost(string, tag = "1")] 8 | pub authority: ::prost::alloc::string::String, 9 | } 10 | impl ::prost::Name for Module { 11 | const NAME: &'static str = "Module"; 12 | const PACKAGE: &'static str = "cosmos.upgrade.module.v1"; 13 | fn full_name() -> ::prost::alloc::string::String { 14 | ::prost::alloc::format!("cosmos.upgrade.module.v1.{}", Self::NAME) 15 | } 16 | } 17 | include!("cosmos.upgrade.module.v1.serde.rs"); 18 | // @@protoc_insertion_point(module) 19 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.genutil.v1beta1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// GenesisState defines the raw genesis transaction in JSON. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct GenesisState { 6 | /// gen_txs defines the genesis transactions. 7 | #[prost(bytes = "vec", repeated, tag = "1")] 8 | pub gen_txs: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, 9 | } 10 | impl ::prost::Name for GenesisState { 11 | const NAME: &'static str = "GenesisState"; 12 | const PACKAGE: &'static str = "cosmos.genutil.v1beta1"; 13 | fn full_name() -> ::prost::alloc::string::String { 14 | ::prost::alloc::format!("cosmos.genutil.v1beta1.{}", Self::NAME) 15 | } 16 | } 17 | include!("cosmos.genutil.v1beta1.serde.rs"); 18 | // @@protoc_insertion_point(module) 19 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.slashing.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the slashing module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// authority defines the custom module authority. If not set, defaults to the governance module. 7 | #[prost(string, tag = "1")] 8 | pub authority: ::prost::alloc::string::String, 9 | } 10 | impl ::prost::Name for Module { 11 | const NAME: &'static str = "Module"; 12 | const PACKAGE: &'static str = "cosmos.slashing.module.v1"; 13 | fn full_name() -> ::prost::alloc::string::String { 14 | ::prost::alloc::format!("cosmos.slashing.module.v1.{}", Self::NAME) 15 | } 16 | } 17 | include!("cosmos.slashing.module.v1.serde.rs"); 18 | // @@protoc_insertion_point(module) 19 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.consensus.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the consensus module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// authority defines the custom module authority. If not set, defaults to the governance module. 7 | #[prost(string, tag = "1")] 8 | pub authority: ::prost::alloc::string::String, 9 | } 10 | impl ::prost::Name for Module { 11 | const NAME: &'static str = "Module"; 12 | const PACKAGE: &'static str = "cosmos.consensus.module.v1"; 13 | fn full_name() -> ::prost::alloc::string::String { 14 | ::prost::alloc::format!("cosmos.consensus.module.v1.{}", Self::NAME) 15 | } 16 | } 17 | include!("cosmos.consensus.module.v1.serde.rs"); 18 | // @@protoc_insertion_point(module) 19 | -------------------------------------------------------------------------------- /.github/workflows/workspace.yml: -------------------------------------------------------------------------------- 1 | name: Workspace 2 | 3 | on: 4 | push: 5 | branches: main 6 | paths-ignore: 7 | - README.md 8 | pull_request: 9 | paths-ignore: 10 | - README.md 11 | 12 | env: 13 | CARGO_TERM_COLOR: always 14 | RUSTFLAGS: -Dwarnings 15 | 16 | jobs: 17 | rustfmt: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v2 21 | - uses: dtolnay/rust-toolchain@master 22 | with: 23 | toolchain: 1.75.0 24 | components: rustfmt 25 | - run: cargo fmt --all -- --check 26 | 27 | clippy: 28 | runs-on: ubuntu-latest 29 | steps: 30 | - uses: actions/checkout@v2 31 | - uses: dtolnay/rust-toolchain@master 32 | with: 33 | toolchain: 1.75.0 34 | components: clippy 35 | - run: cargo clippy --all --all-features -- -D warnings 36 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.mint.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the mint module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | #[prost(string, tag = "1")] 7 | pub fee_collector_name: ::prost::alloc::string::String, 8 | /// authority defines the custom module authority. If not set, defaults to the governance module. 9 | #[prost(string, tag = "2")] 10 | pub authority: ::prost::alloc::string::String, 11 | } 12 | impl ::prost::Name for Module { 13 | const NAME: &'static str = "Module"; 14 | const PACKAGE: &'static str = "cosmos.mint.module.v1"; 15 | fn full_name() -> ::prost::alloc::string::String { 16 | ::prost::alloc::format!("cosmos.mint.module.v1.{}", Self::NAME) 17 | } 18 | } 19 | include!("cosmos.mint.module.v1.serde.rs"); 20 | // @@protoc_insertion_point(module) 21 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.distribution.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the distribution module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | #[prost(string, tag = "1")] 7 | pub fee_collector_name: ::prost::alloc::string::String, 8 | /// authority defines the custom module authority. If not set, defaults to the governance module. 9 | #[prost(string, tag = "2")] 10 | pub authority: ::prost::alloc::string::String, 11 | } 12 | impl ::prost::Name for Module { 13 | const NAME: &'static str = "Module"; 14 | const PACKAGE: &'static str = "cosmos.distribution.module.v1"; 15 | fn full_name() -> ::prost::alloc::string::String { 16 | ::prost::alloc::format!("cosmos.distribution.module.v1.{}", Self::NAME) 17 | } 18 | } 19 | include!("cosmos.distribution.module.v1.serde.rs"); 20 | // @@protoc_insertion_point(module) 21 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.crypto.multisig.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// LegacyAminoPubKey specifies a public key type 3 | /// which nests multiple public keys and a threshold, 4 | /// it uses legacy amino address rules. 5 | #[allow(clippy::derive_partial_eq_without_eq)] 6 | #[derive(Clone, PartialEq, ::prost::Message)] 7 | pub struct LegacyAminoPubKey { 8 | #[prost(uint32, tag = "1")] 9 | pub threshold: u32, 10 | #[prost(message, repeated, tag = "2")] 11 | pub public_keys: ::prost::alloc::vec::Vec<::tendermint_proto::google::protobuf::Any>, 12 | } 13 | impl ::prost::Name for LegacyAminoPubKey { 14 | const NAME: &'static str = "LegacyAminoPubKey"; 15 | const PACKAGE: &'static str = "cosmos.crypto.multisig"; 16 | fn full_name() -> ::prost::alloc::string::String { 17 | ::prost::alloc::format!("cosmos.crypto.multisig.{}", Self::NAME) 18 | } 19 | } 20 | include!("cosmos.crypto.multisig.serde.rs"); 21 | // @@protoc_insertion_point(module) 22 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/missed_block.rs: -------------------------------------------------------------------------------- 1 | use crate::proto; 2 | 3 | /// MissedBlock contains height and missed status as boolean. 4 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] 5 | pub struct MissedBlock { 6 | /// index is the height at which the block was missed. 7 | pub index: i64, 8 | 9 | /// missed is the missed status. 10 | pub missed: bool, 11 | } 12 | 13 | impl From for MissedBlock { 14 | fn from(proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::MissedBlock) -> MissedBlock { 15 | MissedBlock { 16 | index: proto.index, 17 | missed: proto.missed, 18 | } 19 | } 20 | } 21 | 22 | impl From for cosmos_sdk_proto::cosmos::slashing::v1beta1::MissedBlock { 23 | fn from(missed_block: MissedBlock) -> Self { 24 | cosmos_sdk_proto::cosmos::slashing::v1beta1::MissedBlock { 25 | index: missed_block.index, 26 | missed: missed_block.missed, 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.crisis.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the crisis module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// fee_collector_name is the name of the FeeCollector ModuleAccount. 7 | #[prost(string, tag = "1")] 8 | pub fee_collector_name: ::prost::alloc::string::String, 9 | /// authority defines the custom module authority. If not set, defaults to the governance module. 10 | #[prost(string, tag = "2")] 11 | pub authority: ::prost::alloc::string::String, 12 | } 13 | impl ::prost::Name for Module { 14 | const NAME: &'static str = "Module"; 15 | const PACKAGE: &'static str = "cosmos.crisis.module.v1"; 16 | fn full_name() -> ::prost::alloc::string::String { 17 | ::prost::alloc::format!("cosmos.crisis.module.v1.{}", Self::NAME) 18 | } 19 | } 20 | include!("cosmos.crisis.module.v1.serde.rs"); 21 | // @@protoc_insertion_point(module) 22 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.gov.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the gov module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// max_metadata_len defines the maximum proposal metadata length. 7 | /// Defaults to 255 if not explicitly set. 8 | #[prost(uint64, tag = "1")] 9 | pub max_metadata_len: u64, 10 | /// authority defines the custom module authority. If not set, defaults to the governance module. 11 | #[prost(string, tag = "2")] 12 | pub authority: ::prost::alloc::string::String, 13 | } 14 | impl ::prost::Name for Module { 15 | const NAME: &'static str = "Module"; 16 | const PACKAGE: &'static str = "cosmos.gov.module.v1"; 17 | fn full_name() -> ::prost::alloc::string::String { 18 | ::prost::alloc::format!("cosmos.gov.module.v1.{}", Self::NAME) 19 | } 20 | } 21 | include!("cosmos.gov.module.v1.serde.rs"); 22 | // @@protoc_insertion_point(module) 23 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.tx.config.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Config is the config object of the x/auth/tx package. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Config { 6 | /// skip_ante_handler defines whether the ante handler registration should be skipped in case an app wants to override 7 | /// this functionality. 8 | #[prost(bool, tag = "1")] 9 | pub skip_ante_handler: bool, 10 | /// skip_post_handler defines whether the post handler registration should be skipped in case an app wants to override 11 | /// this functionality. 12 | #[prost(bool, tag = "2")] 13 | pub skip_post_handler: bool, 14 | } 15 | impl ::prost::Name for Config { 16 | const NAME: &'static str = "Config"; 17 | const PACKAGE: &'static str = "cosmos.tx.config.v1"; 18 | fn full_name() -> ::prost::alloc::string::String { 19 | ::prost::alloc::format!("cosmos.tx.config.v1.{}", Self::NAME) 20 | } 21 | } 22 | include!("cosmos.tx.config.v1.serde.rs"); 23 | // @@protoc_insertion_point(module) 24 | -------------------------------------------------------------------------------- /cosmrs/src/staking/query_historical_info_request.rs: -------------------------------------------------------------------------------- 1 | use crate::proto; 2 | 3 | /// QueryHistoricalInfoRequest is request type for the Query/HistoricalInfo RPC 4 | /// method. 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct QueryHistoricalInfoRequest { 7 | /// height defines at which height to query the historical info. 8 | pub height: i64, 9 | } 10 | 11 | impl From 12 | for QueryHistoricalInfoRequest 13 | { 14 | fn from(proto: cosmos_sdk_proto::cosmos::staking::v1beta1::QueryHistoricalInfoRequest) -> Self { 15 | QueryHistoricalInfoRequest { 16 | height: proto.height, 17 | } 18 | } 19 | } 20 | 21 | impl From 22 | for proto::cosmos::staking::v1beta1::QueryHistoricalInfoRequest 23 | { 24 | fn from(query_historical_info_request: QueryHistoricalInfoRequest) -> Self { 25 | proto::cosmos::staking::v1beta1::QueryHistoricalInfoRequest { 26 | height: query_historical_info_request.height, 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/query_signing_infos_request.rs: -------------------------------------------------------------------------------- 1 | use crate::base::query::PageRequest; 2 | use crate::proto; 3 | 4 | /// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC 5 | /// method 6 | #[derive(Clone, Debug, Eq, PartialEq)] 7 | pub struct QuerySigningInfosRequest { 8 | /// Pagination control of the request 9 | pub pagination: Option, 10 | } 11 | 12 | impl From for QuerySigningInfosRequest { 13 | fn from(proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::QuerySigningInfosRequest) -> Self { 14 | QuerySigningInfosRequest { 15 | pagination: proto.pagination.map(Into::into), 16 | } 17 | } 18 | } 19 | 20 | impl From for proto::cosmos::slashing::v1beta1::QuerySigningInfosRequest { 21 | fn from(signing_infos_request: QuerySigningInfosRequest) -> Self { 22 | proto::cosmos::slashing::v1beta1::QuerySigningInfosRequest { 23 | pagination: signing_infos_request.pagination.map(Into::into), 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/query_params_response.rs: -------------------------------------------------------------------------------- 1 | use crate::slashing::Params; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// QueryParamsResponse is the response type for the Query/Params RPC method 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub struct QueryParamsResponse { 7 | /// Parameters of the slashing module 8 | pub params: Option, 9 | } 10 | 11 | impl TryFrom for QueryParamsResponse { 12 | type Error = ErrorReport; 13 | 14 | fn try_from( 15 | proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::QueryParamsResponse, 16 | ) -> Result { 17 | Ok(QueryParamsResponse { 18 | params: proto.params.map(TryInto::try_into).transpose()?, 19 | }) 20 | } 21 | } 22 | 23 | impl From for proto::cosmos::slashing::v1beta1::QueryParamsResponse { 24 | fn from(params_response: QueryParamsResponse) -> Self { 25 | proto::cosmos::slashing::v1beta1::QueryParamsResponse { 26 | params: params_response.params.map(Into::into), 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cosmrs/src/tx/msg.rs: -------------------------------------------------------------------------------- 1 | //! Transaction messages 2 | 3 | use crate::{ 4 | proto::traits::{MessageExt, Name}, 5 | Any, ErrorReport, Result, 6 | }; 7 | 8 | /// Message types. 9 | /// 10 | /// Types which impl this trait map one-to-one with a corresponding Protocol 11 | /// Buffers type, but can assert additional invariants and/or additional 12 | /// functionality beyond the raw proto, as well as providing a more idiomatic 13 | /// Rust type to work with. 14 | pub trait Msg: 15 | Clone + Sized + TryFrom + Into 16 | { 17 | /// Protocol Buffers type 18 | type Proto: Default + MessageExt + Name + Sized; 19 | 20 | /// Parse this message proto from [`Any`]. 21 | fn from_any(any: &Any) -> Result { 22 | any.to_msg::()?.try_into() 23 | } 24 | 25 | /// Serialize this message proto as [`Any`]. 26 | fn to_any(&self) -> Result { 27 | self.clone().into_any() 28 | } 29 | 30 | /// Convert this message proto into [`Any`]. 31 | fn into_any(self) -> Result { 32 | Ok(Any::from_msg(&self.into())?) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cosmrs/src/staking/query_validator_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, AccountId, ErrorReport, Result}; 2 | 3 | /// QueryValidatorRequest is response type for the Query/Validator RPC method 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct QueryValidatorRequest { 6 | /// validator_addr defines the validator address to query for. 7 | pub validator_addr: AccountId, 8 | } 9 | 10 | impl TryFrom for QueryValidatorRequest { 11 | type Error = ErrorReport; 12 | 13 | fn try_from( 14 | proto: cosmos_sdk_proto::cosmos::staking::v1beta1::QueryValidatorRequest, 15 | ) -> Result { 16 | Ok(QueryValidatorRequest { 17 | validator_addr: proto.validator_addr.parse()?, 18 | }) 19 | } 20 | } 21 | 22 | impl From for proto::cosmos::staking::v1beta1::QueryValidatorRequest { 23 | fn from(query_validator_request: QueryValidatorRequest) -> Self { 24 | proto::cosmos::staking::v1beta1::QueryValidatorRequest { 25 | validator_addr: query_validator_request.validator_addr.to_string(), 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cosmrs/src/staking/query_validator_response.rs: -------------------------------------------------------------------------------- 1 | use crate::staking::Validator; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// QueryValidatorResponse is response type for the Query/Validator RPC method 5 | #[derive(Clone, Debug, PartialEq)] 6 | pub struct QueryValidatorResponse { 7 | /// validator defines the validator info. 8 | pub validator: Option, 9 | } 10 | 11 | impl TryFrom for QueryValidatorResponse { 12 | type Error = ErrorReport; 13 | 14 | fn try_from( 15 | proto: cosmos_sdk_proto::cosmos::staking::v1beta1::QueryValidatorResponse, 16 | ) -> Result { 17 | Ok(QueryValidatorResponse { 18 | validator: proto.validator.map(TryInto::try_into).transpose()?, 19 | }) 20 | } 21 | } 22 | 23 | impl From for proto::cosmos::staking::v1beta1::QueryValidatorResponse { 24 | fn from(query_validator_response: QueryValidatorResponse) -> Self { 25 | proto::cosmos::staking::v1beta1::QueryValidatorResponse { 26 | validator: query_validator_response.validator.map(Into::into), 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cosmrs/src/abci/gas_info.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, ErrorReport, Gas, Result}; 2 | use serde::{Deserialize, Serialize}; 3 | 4 | /// [`GasInfo`] defines constraints for how much gas to use to execute a 5 | /// transaction. 6 | #[derive(Copy, Clone, Debug, Serialize, Deserialize, Default, Eq, PartialEq)] 7 | pub struct GasInfo { 8 | /// GasWanted is the maximum units of work we allow this tx to perform. 9 | pub gas_wanted: Gas, 10 | 11 | /// GasUsed is the amount of gas actually consumed. 12 | pub gas_used: Gas, 13 | } 14 | 15 | impl TryFrom for GasInfo { 16 | type Error = ErrorReport; 17 | 18 | fn try_from(proto: proto::cosmos::base::abci::v1beta1::GasInfo) -> Result { 19 | Ok(GasInfo { 20 | gas_wanted: proto.gas_wanted, 21 | gas_used: proto.gas_used, 22 | }) 23 | } 24 | } 25 | 26 | impl From for proto::cosmos::base::abci::v1beta1::GasInfo { 27 | fn from(info: GasInfo) -> Self { 28 | proto::cosmos::base::abci::v1beta1::GasInfo { 29 | gas_wanted: info.gas_wanted, 30 | gas_used: info.gas_wanted, 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cosmrs/src/slashing.rs: -------------------------------------------------------------------------------- 1 | //! Slashing module support 2 | //! 3 | //! 4 | 5 | mod genesis_state; 6 | mod missed_block; 7 | mod msg_unjail; 8 | mod params; 9 | mod query_params_request; 10 | mod query_params_response; 11 | mod query_signing_info_request; 12 | mod query_signing_info_response; 13 | mod query_signing_infos_request; 14 | mod query_signing_infos_response; 15 | mod signing_info; 16 | mod validator_missed_blocks; 17 | mod validator_signing_info; 18 | 19 | pub use self::{ 20 | genesis_state::GenesisState, 21 | missed_block::MissedBlock, 22 | msg_unjail::{MsgUnjail, MsgUnjailResponse}, 23 | params::Params, 24 | query_params_request::QueryParamsRequest, 25 | query_params_response::QueryParamsResponse, 26 | query_signing_info_request::QuerySigningInfoRequest, 27 | query_signing_info_response::QuerySigningInfoResponse, 28 | query_signing_infos_request::QuerySigningInfosRequest, 29 | query_signing_infos_response::QuerySigningInfosResponse, 30 | signing_info::SigningInfo, 31 | validator_missed_blocks::ValidatorMissedBlocks, 32 | validator_signing_info::ValidatorSigningInfo, 33 | }; 34 | -------------------------------------------------------------------------------- /cosmrs/src/staking.rs: -------------------------------------------------------------------------------- 1 | //! Staking module support 2 | //! 3 | //! 4 | 5 | mod commission; 6 | mod commission_rates; 7 | mod description; 8 | mod historical_info; 9 | mod msg_begin_redelegate; 10 | mod msg_delegate; 11 | mod msg_undelegate; 12 | mod query_historical_info_request; 13 | mod query_historical_info_response; 14 | mod query_validator_request; 15 | mod query_validator_response; 16 | mod query_validators_request; 17 | mod query_validators_response; 18 | mod validator; 19 | 20 | pub use self::{ 21 | commission::Commission, commission_rates::CommissionRates, description::Description, 22 | historical_info::HistoricalInfo, msg_begin_redelegate::MsgBeginRedelegate, 23 | msg_delegate::MsgDelegate, msg_undelegate::MsgUndelegate, 24 | query_historical_info_request::QueryHistoricalInfoRequest, 25 | query_historical_info_response::QueryHistoricalInfoResponse, 26 | query_validator_request::QueryValidatorRequest, 27 | query_validator_response::QueryValidatorResponse, 28 | query_validators_request::QueryValidatorsRequest, 29 | query_validators_response::QueryValidatorsResponse, validator::Validator, 30 | }; 31 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/query_signing_info_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, AccountId, ErrorReport, Result}; 2 | 3 | /// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC 4 | /// method 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub struct QuerySigningInfoRequest { 7 | /// cons_address is the address to query signing info of 8 | pub cons_address: AccountId, 9 | } 10 | 11 | impl TryFrom 12 | for QuerySigningInfoRequest 13 | { 14 | type Error = ErrorReport; 15 | 16 | fn try_from( 17 | proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::QuerySigningInfoRequest, 18 | ) -> Result { 19 | Ok(QuerySigningInfoRequest { 20 | cons_address: proto.cons_address.parse()?, 21 | }) 22 | } 23 | } 24 | 25 | impl From for proto::cosmos::slashing::v1beta1::QuerySigningInfoRequest { 26 | fn from(signing_info_response: QuerySigningInfoRequest) -> Self { 27 | proto::cosmos::slashing::v1beta1::QuerySigningInfoRequest { 28 | cons_address: signing_info_response.cons_address.to_string(), 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.group.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the group module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// max_execution_period defines the max duration after a proposal's voting period ends that members can send a MsgExec 7 | /// to execute the proposal. 8 | #[prost(message, optional, tag = "1")] 9 | pub max_execution_period: 10 | ::core::option::Option<::tendermint_proto::google::protobuf::Duration>, 11 | /// max_metadata_len defines the max length of the metadata bytes field for various entities within the group module. 12 | /// Defaults to 255 if not explicitly set. 13 | #[prost(uint64, tag = "2")] 14 | pub max_metadata_len: u64, 15 | } 16 | impl ::prost::Name for Module { 17 | const NAME: &'static str = "Module"; 18 | const PACKAGE: &'static str = "cosmos.group.module.v1"; 19 | fn full_name() -> ::prost::alloc::string::String { 20 | ::prost::alloc::format!("cosmos.group.module.v1.{}", Self::NAME) 21 | } 22 | } 23 | include!("cosmos.group.module.v1.serde.rs"); 24 | // @@protoc_insertion_point(module) 25 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/query_code_response.rs: -------------------------------------------------------------------------------- 1 | use super::CodeInfoResponse; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// QueryCodeResponse is the response type for the Query/Code RPC method. 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct QueryCodeResponse { 7 | /// If available, the associated code ID metadata. 8 | pub code_info: Option, 9 | 10 | /// The original wasm bytes. 11 | pub data: Vec, 12 | } 13 | 14 | impl TryFrom for QueryCodeResponse { 15 | type Error = ErrorReport; 16 | 17 | fn try_from(proto: proto::cosmwasm::wasm::v1::QueryCodeResponse) -> Result { 18 | Ok(QueryCodeResponse { 19 | code_info: proto.code_info.map(TryFrom::try_from).transpose()?, 20 | data: proto.data, 21 | }) 22 | } 23 | } 24 | 25 | impl From for proto::cosmwasm::wasm::v1::QueryCodeResponse { 26 | fn from(response: QueryCodeResponse) -> Self { 27 | proto::cosmwasm::wasm::v1::QueryCodeResponse { 28 | code_info: response.code_info.map(Into::into), 29 | data: response.data, 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/traits.rs: -------------------------------------------------------------------------------- 1 | //! Support traits for Cosmos SDK protobufs. 2 | 3 | pub use prost::{Message, Name}; 4 | 5 | use alloc::{string::String, vec::Vec}; 6 | use core::str::FromStr; 7 | use prost::EncodeError; 8 | 9 | /// Extension trait for [`Message`]. 10 | pub trait MessageExt: Message { 11 | /// Serialize this protobuf message as a byte vector. 12 | fn to_bytes(&self) -> Result, EncodeError>; 13 | } 14 | 15 | impl MessageExt for M 16 | where 17 | M: prost::Message, 18 | { 19 | fn to_bytes(&self) -> Result, EncodeError> { 20 | let mut bytes = Vec::new(); 21 | Message::encode(self, &mut bytes)?; 22 | Ok(bytes) 23 | } 24 | } 25 | 26 | /// Extension traits for optionally parsing non-empty strings. 27 | /// 28 | /// This is a common pattern in Cosmos SDK protobufs. 29 | pub trait ParseOptional: AsRef { 30 | /// Parse optional field. 31 | fn parse_optional(&self) -> Result, T::Err> { 32 | if self.as_ref().is_empty() { 33 | Ok(None) 34 | } else { 35 | Ok(Some(self.as_ref().parse()?)) 36 | } 37 | } 38 | } 39 | 40 | impl ParseOptional for str {} 41 | impl ParseOptional for String {} 42 | -------------------------------------------------------------------------------- /cosmrs/src/vesting/period.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, Coin, ErrorReport, Result}; 2 | 3 | /// [`Period`] defines a length of time and amount of coins that will vest. 4 | #[derive(Clone, Debug, Eq, PartialEq)] 5 | pub struct Period { 6 | /// Length of this vesting period in seconds. 7 | pub length: i64, 8 | 9 | /// The amount of coins (per denomination) that will vest upon this period finishing. 10 | pub amount: Vec, 11 | } 12 | 13 | impl TryFrom for Period { 14 | type Error = ErrorReport; 15 | 16 | fn try_from(proto: proto::cosmos::vesting::v1beta1::Period) -> Result { 17 | Ok(Period { 18 | length: proto.length, 19 | amount: proto 20 | .amount 21 | .into_iter() 22 | .map(TryFrom::try_from) 23 | .collect::>()?, 24 | }) 25 | } 26 | } 27 | 28 | impl From for proto::cosmos::vesting::v1beta1::Period { 29 | fn from(period: Period) -> Self { 30 | proto::cosmos::vesting::v1beta1::Period { 31 | length: period.length, 32 | amount: period.amount.into_iter().map(Into::into).collect(), 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/absolute_tx_position.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, ErrorReport, Result}; 2 | 3 | /// AbsoluteTxPosition is a unique transaction position that allows for global 4 | /// ordering of transactions. 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct AbsoluteTxPosition { 7 | /// BlockHeight is the block the contract was created at 8 | pub block_height: u64, 9 | /// TxIndex is a monotonic counter within the block (actual transaction index, or gas consumed) 10 | pub tx_index: u64, 11 | } 12 | 13 | impl TryFrom for AbsoluteTxPosition { 14 | type Error = ErrorReport; 15 | 16 | fn try_from( 17 | proto: proto::cosmwasm::wasm::v1::AbsoluteTxPosition, 18 | ) -> Result { 19 | Ok(AbsoluteTxPosition { 20 | block_height: proto.block_height, 21 | tx_index: proto.tx_index, 22 | }) 23 | } 24 | } 25 | 26 | impl From for proto::cosmwasm::wasm::v1::AbsoluteTxPosition { 27 | fn from(pos: AbsoluteTxPosition) -> Self { 28 | proto::cosmwasm::wasm::v1::AbsoluteTxPosition { 29 | block_height: pos.block_height, 30 | tx_index: pos.tx_index, 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cosmrs/src/staking/query_historical_info_response.rs: -------------------------------------------------------------------------------- 1 | use crate::staking::HistoricalInfo; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC 5 | /// method. 6 | #[derive(Clone, Debug, PartialEq)] 7 | pub struct QueryHistoricalInfoResponse { 8 | /// hist defines the historical info at the given height. 9 | pub hist: Option, 10 | } 11 | 12 | impl TryFrom 13 | for QueryHistoricalInfoResponse 14 | { 15 | type Error = ErrorReport; 16 | 17 | fn try_from( 18 | proto: cosmos_sdk_proto::cosmos::staking::v1beta1::QueryHistoricalInfoResponse, 19 | ) -> Result { 20 | Ok(QueryHistoricalInfoResponse { 21 | hist: proto.hist.map(TryInto::try_into).transpose()?, 22 | }) 23 | } 24 | } 25 | 26 | impl From 27 | for proto::cosmos::staking::v1beta1::QueryHistoricalInfoResponse 28 | { 29 | fn from(query_historical_info_response: QueryHistoricalInfoResponse) -> Self { 30 | proto::cosmos::staking::v1beta1::QueryHistoricalInfoResponse { 31 | hist: query_historical_info_response.hist.map(Into::into), 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/query_signing_info_response.rs: -------------------------------------------------------------------------------- 1 | use crate::slashing::ValidatorSigningInfo; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC 5 | /// method 6 | #[derive(Clone, Debug, Eq, PartialEq)] 7 | pub struct QuerySigningInfoResponse { 8 | /// val_signing_info is the signing info of requested val cons address 9 | pub val_signing_info: Option, 10 | } 11 | 12 | impl TryFrom 13 | for QuerySigningInfoResponse 14 | { 15 | type Error = ErrorReport; 16 | 17 | fn try_from( 18 | proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::QuerySigningInfoResponse, 19 | ) -> Result { 20 | Ok(QuerySigningInfoResponse { 21 | val_signing_info: proto.val_signing_info.map(TryFrom::try_from).transpose()?, 22 | }) 23 | } 24 | } 25 | 26 | impl From for proto::cosmos::slashing::v1beta1::QuerySigningInfoResponse { 27 | fn from(signing_info_response: QuerySigningInfoResponse) -> Self { 28 | proto::cosmos::slashing::v1beta1::QuerySigningInfoResponse { 29 | val_signing_info: signing_info_response.val_signing_info.map(Into::into), 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cosmrs/src/staking/query_validators_request.rs: -------------------------------------------------------------------------------- 1 | use crate::base::query::PageRequest; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// QueryValidatorsRequest is request type for Query/Validators RPC method. 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub struct QueryValidatorsRequest { 7 | /// status enables to query for validators matching a given status. 8 | pub status: String, 9 | 10 | /// pagination defines an optional pagination for the request. 11 | pub pagination: Option, 12 | } 13 | 14 | impl TryFrom for QueryValidatorsRequest { 15 | type Error = ErrorReport; 16 | 17 | fn try_from( 18 | proto: cosmos_sdk_proto::cosmos::staking::v1beta1::QueryValidatorsRequest, 19 | ) -> Result { 20 | Ok(QueryValidatorsRequest { 21 | status: proto.status, 22 | pagination: proto.pagination.map(Into::into), 23 | }) 24 | } 25 | } 26 | 27 | impl From for proto::cosmos::staking::v1beta1::QueryValidatorsRequest { 28 | fn from(query_validators_request: QueryValidatorsRequest) -> Self { 29 | proto::cosmos::staking::v1beta1::QueryValidatorsRequest { 30 | status: query_validators_request.status, 31 | pagination: query_validators_request.pagination.map(Into::into), 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.crypto.hd.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// BIP44Params is used as path field in ledger item in Record. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Bip44Params { 6 | /// purpose is a constant set to 44' (or 0x8000002C) following the BIP43 recommendation 7 | #[prost(uint32, tag = "1")] 8 | pub purpose: u32, 9 | /// coin_type is a constant that improves privacy 10 | #[prost(uint32, tag = "2")] 11 | pub coin_type: u32, 12 | /// account splits the key space into independent user identities 13 | #[prost(uint32, tag = "3")] 14 | pub account: u32, 15 | /// change is a constant used for public derivation. Constant 0 is used for external chain and constant 1 for internal 16 | /// chain. 17 | #[prost(bool, tag = "4")] 18 | pub change: bool, 19 | /// address_index is used as child index in BIP32 derivation 20 | #[prost(uint32, tag = "5")] 21 | pub address_index: u32, 22 | } 23 | impl ::prost::Name for Bip44Params { 24 | const NAME: &'static str = "BIP44Params"; 25 | const PACKAGE: &'static str = "cosmos.crypto.hd.v1"; 26 | fn full_name() -> ::prost::alloc::string::String { 27 | ::prost::alloc::format!("cosmos.crypto.hd.v1.{}", Self::NAME) 28 | } 29 | } 30 | include!("cosmos.crypto.hd.v1.serde.rs"); 31 | // @@protoc_insertion_point(module) 32 | -------------------------------------------------------------------------------- /cosmrs/src/auth/module_account.rs: -------------------------------------------------------------------------------- 1 | use super::BaseAccount; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// ModuleAccount defines an account for modules that holds coins on a pool. 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub struct ModuleAccount { 7 | /// [`BaseAccount`] specification of this module account. 8 | pub base_account: Option, 9 | 10 | /// Name of the module. 11 | pub name: String, 12 | 13 | /// Permissions associated with this module account. 14 | pub permissions: Vec, 15 | } 16 | 17 | impl TryFrom for ModuleAccount { 18 | type Error = ErrorReport; 19 | 20 | fn try_from(proto: proto::cosmos::auth::v1beta1::ModuleAccount) -> Result { 21 | Ok(ModuleAccount { 22 | base_account: proto.base_account.map(TryFrom::try_from).transpose()?, 23 | name: proto.name, 24 | permissions: proto.permissions, 25 | }) 26 | } 27 | } 28 | 29 | impl From for proto::cosmos::auth::v1beta1::ModuleAccount { 30 | fn from(account: ModuleAccount) -> proto::cosmos::auth::v1beta1::ModuleAccount { 31 | proto::cosmos::auth::v1beta1::ModuleAccount { 32 | base_account: account.base_account.map(Into::into), 33 | name: account.name, 34 | permissions: account.permissions, 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /cosmrs/src/staking/commission_rates.rs: -------------------------------------------------------------------------------- 1 | use crate::proto; 2 | 3 | /// CommissionRates defines the initial commission rates to be used for creating 4 | /// a validator. 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct CommissionRates { 7 | /// rate is the commission rate charged to delegators, as a fraction. 8 | pub rate: String, 9 | 10 | /// max_rate defines the maximum commission rate which validator can ever charge, as a fraction. 11 | pub max_rate: String, 12 | 13 | /// max_change_rate defines the maximum daily increase of the validator commission, as a fraction. 14 | pub max_change_rate: String, 15 | } 16 | 17 | impl From for CommissionRates { 18 | fn from(proto: cosmos_sdk_proto::cosmos::staking::v1beta1::CommissionRates) -> Self { 19 | CommissionRates { 20 | rate: proto.rate, 21 | max_rate: proto.max_rate, 22 | max_change_rate: proto.max_change_rate, 23 | } 24 | } 25 | } 26 | 27 | impl From for proto::cosmos::staking::v1beta1::CommissionRates { 28 | fn from(commission_rates: CommissionRates) -> Self { 29 | proto::cosmos::staking::v1beta1::CommissionRates { 30 | rate: commission_rates.rate, 31 | max_rate: commission_rates.max_rate, 32 | max_change_rate: commission_rates.max_change_rate, 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cosmrs/src/vesting/delayed_vesting_account.rs: -------------------------------------------------------------------------------- 1 | use super::BaseVestingAccount; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// [`DelayedVestingAccount`] implements the `VestingAccount` interface. 5 | /// 6 | /// It vests all coins after a specific time, but non prior. In other words, 7 | /// it keeps them locked until a specified time. 8 | #[derive(Clone, Debug, Eq, PartialEq)] 9 | pub struct DelayedVestingAccount { 10 | /// Base vesting account specification required for this vesting implementation. 11 | pub base_vesting_account: Option, 12 | } 13 | 14 | impl TryFrom for DelayedVestingAccount { 15 | type Error = ErrorReport; 16 | 17 | fn try_from( 18 | proto: proto::cosmos::vesting::v1beta1::DelayedVestingAccount, 19 | ) -> Result { 20 | Ok(DelayedVestingAccount { 21 | base_vesting_account: proto 22 | .base_vesting_account 23 | .map(TryFrom::try_from) 24 | .transpose()?, 25 | }) 26 | } 27 | } 28 | 29 | impl From for proto::cosmos::vesting::v1beta1::DelayedVestingAccount { 30 | fn from(account: DelayedVestingAccount) -> Self { 31 | proto::cosmos::vesting::v1beta1::DelayedVestingAccount { 32 | base_vesting_account: account.base_vesting_account.map(Into::into), 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/signing_info.rs: -------------------------------------------------------------------------------- 1 | use crate::slashing::validator_signing_info::ValidatorSigningInfo; 2 | use crate::{proto, AccountId, ErrorReport, Result}; 3 | 4 | /// SigningInfo stores validator signing info of corresponding address. 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub struct SigningInfo { 7 | /// address is the validator address. 8 | pub address: AccountId, 9 | 10 | /// validator_signing_info represents the signing info of this validator. 11 | pub validator_signing_info: Option, 12 | } 13 | 14 | impl TryFrom for SigningInfo { 15 | type Error = ErrorReport; 16 | 17 | fn try_from(proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::SigningInfo) -> Result { 18 | Ok(SigningInfo { 19 | address: proto.address.parse()?, 20 | validator_signing_info: proto 21 | .validator_signing_info 22 | .map(TryInto::try_into) 23 | .transpose()?, 24 | }) 25 | } 26 | } 27 | 28 | impl From for cosmos_sdk_proto::cosmos::slashing::v1beta1::SigningInfo { 29 | fn from(signing_info: SigningInfo) -> Self { 30 | cosmos_sdk_proto::cosmos::slashing::v1beta1::SigningInfo { 31 | address: signing_info.address.to_string(), 32 | validator_signing_info: signing_info.validator_signing_info.map(Into::into), 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm.rs: -------------------------------------------------------------------------------- 1 | //! CosmWasm messages 2 | //! 3 | //! - Tutorial: 4 | //! - Protocol Docs: 5 | 6 | mod absolute_tx_position; 7 | mod access_config; 8 | mod code_info_response; 9 | mod contract_code_history_entry; 10 | mod contract_info; 11 | mod msg_clear_admin; 12 | mod msg_execute_contract; 13 | mod msg_initiate_contract; 14 | mod msg_migrate_contract; 15 | mod msg_store_code; 16 | mod msg_update_admin; 17 | mod query_code_response; 18 | 19 | pub use self::{ 20 | absolute_tx_position::AbsoluteTxPosition, 21 | access_config::AccessConfig, 22 | code_info_response::CodeInfoResponse, 23 | contract_code_history_entry::ContractCodeHistoryEntry, 24 | contract_info::ContractInfo, 25 | msg_clear_admin::{MsgClearAdmin, MsgClearAdminResponse}, 26 | msg_execute_contract::{MsgExecuteContract, MsgExecuteContractResponse}, 27 | msg_initiate_contract::{MsgInstantiateContract, MsgInstantiateContractResponse}, 28 | msg_migrate_contract::{MsgMigrateContract, MsgMigrateContractResponse}, 29 | msg_store_code::{MsgStoreCode, MsgStoreCodeResponse}, 30 | msg_update_admin::{MsgUpdateAdmin, MsgUpdateAdminResponse}, 31 | query_code_response::QueryCodeResponse, 32 | }; 33 | pub use crate::proto::cosmwasm::wasm::v1::AccessType; 34 | 35 | /// The ID of a particular contract code assigned by the chain. 36 | pub type ContractCodeId = u64; 37 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/validator_missed_blocks.rs: -------------------------------------------------------------------------------- 1 | use crate::proto; 2 | use crate::slashing::MissedBlock; 3 | 4 | /// ValidatorMissedBlocks contains array of missed blocks of corresponding 5 | /// address. 6 | #[derive(Clone, Debug, Eq, PartialEq)] 7 | pub struct ValidatorMissedBlocks { 8 | /// address is the validator address. 9 | pub address: String, 10 | 11 | /// missed_blocks is an array of missed blocks by the validator. 12 | pub missed_blocks: Vec, 13 | } 14 | 15 | impl From for ValidatorMissedBlocks { 16 | fn from( 17 | proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::ValidatorMissedBlocks, 18 | ) -> ValidatorMissedBlocks { 19 | ValidatorMissedBlocks { 20 | address: proto.address, 21 | missed_blocks: proto.missed_blocks.into_iter().map(Into::into).collect(), 22 | } 23 | } 24 | } 25 | 26 | impl From 27 | for cosmos_sdk_proto::cosmos::slashing::v1beta1::ValidatorMissedBlocks 28 | { 29 | fn from(missed_blocks: ValidatorMissedBlocks) -> Self { 30 | cosmos_sdk_proto::cosmos::slashing::v1beta1::ValidatorMissedBlocks { 31 | address: missed_blocks.address, 32 | missed_blocks: missed_blocks 33 | .missed_blocks 34 | .into_iter() 35 | .map(Into::into) 36 | .collect(), 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cosmos-sdk-proto" 3 | version = "0.27.0" 4 | authors = [ 5 | "Justin Kilpatrick ", 6 | "Greg Szabo ", 7 | "Tony Arcieri " 8 | ] 9 | license = "Apache-2.0" 10 | repository = "https://github.com/cosmos/cosmos-rust/tree/main/cosmos-sdk-proto" 11 | description = "Protobuf stuct defintions for interacting Cosmos SDK powered blockchains" 12 | readme = "README.md" 13 | categories = ["cryptography", "cryptography::cryptocurrencies", "database"] 14 | keywords = ["blockchain", "cosmos", "tendermint", "proto"] 15 | edition = "2021" 16 | rust-version = "1.75" 17 | 18 | [dependencies] 19 | prost = { version = "0.13", default-features = false } 20 | tendermint-proto = { version = "0.40.0" } 21 | 22 | # Optional dependencies 23 | tonic = { version = "0.13", optional = true, default-features = false, features = ["codegen", "prost"] } 24 | serde = { version = "1.0.203", optional = true, default-features = false, features = ["alloc"] } 25 | pbjson = { package = "informalsystems-pbjson", optional = true, default-features = false, version = "0.7" } 26 | 27 | [features] 28 | default = ["grpc-transport"] 29 | std = ["prost/std", "tendermint-proto/std"] 30 | grpc = ["std", "tonic"] 31 | grpc-transport = ["grpc", "tonic/transport"] 32 | cosmwasm = [] 33 | serde = ["dep:serde", "pbjson"] 34 | 35 | [package.metadata.docs.rs] 36 | all-features = true 37 | rustdoc-args = ["--cfg", "docsrs"] 38 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.reflection.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// FileDescriptorsRequest is the Query/FileDescriptors request type. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct FileDescriptorsRequest {} 6 | impl ::prost::Name for FileDescriptorsRequest { 7 | const NAME: &'static str = "FileDescriptorsRequest"; 8 | const PACKAGE: &'static str = "cosmos.reflection.v1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.reflection.v1.{}", Self::NAME) 11 | } 12 | } 13 | /// FileDescriptorsResponse is the Query/FileDescriptors response type. 14 | #[allow(clippy::derive_partial_eq_without_eq)] 15 | #[derive(Clone, PartialEq, ::prost::Message)] 16 | pub struct FileDescriptorsResponse { 17 | /// files is the file descriptors. 18 | #[prost(message, repeated, tag = "1")] 19 | pub files: ::prost::alloc::vec::Vec<::tendermint_proto::google::protobuf::FileDescriptorProto>, 20 | } 21 | impl ::prost::Name for FileDescriptorsResponse { 22 | const NAME: &'static str = "FileDescriptorsResponse"; 23 | const PACKAGE: &'static str = "cosmos.reflection.v1"; 24 | fn full_name() -> ::prost::alloc::string::String { 25 | ::prost::alloc::format!("cosmos.reflection.v1.{}", Self::NAME) 26 | } 27 | } 28 | include!("cosmos.reflection.v1.serde.rs"); 29 | include!("cosmos.reflection.v1.tonic.rs"); 30 | // @@protoc_insertion_point(module) 31 | -------------------------------------------------------------------------------- /cosmrs/src/vesting/permanent_locked_account.rs: -------------------------------------------------------------------------------- 1 | use super::BaseVestingAccount; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// [`PermanentLockedAccount`] implements the `VestingAccount` interface. It does 5 | /// not ever release coins, locking them indefinitely. 6 | /// 7 | /// Coins in this account can still be used for delegating and for governance 8 | /// votes even while locked. 9 | #[derive(Clone, Debug, Eq, PartialEq)] 10 | pub struct PermanentLockedAccount { 11 | /// Base vesting account specification required for this vesting implementation. 12 | pub base_vesting_account: Option, 13 | } 14 | 15 | impl TryFrom for PermanentLockedAccount { 16 | type Error = ErrorReport; 17 | 18 | fn try_from( 19 | proto: proto::cosmos::vesting::v1beta1::PermanentLockedAccount, 20 | ) -> Result { 21 | Ok(PermanentLockedAccount { 22 | base_vesting_account: proto 23 | .base_vesting_account 24 | .map(TryFrom::try_from) 25 | .transpose()?, 26 | }) 27 | } 28 | } 29 | 30 | impl From for proto::cosmos::vesting::v1beta1::PermanentLockedAccount { 31 | fn from(account: PermanentLockedAccount) -> Self { 32 | proto::cosmos::vesting::v1beta1::PermanentLockedAccount { 33 | base_vesting_account: account.base_vesting_account.map(Into::into), 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /cosmrs/src/tx/raw.rs: -------------------------------------------------------------------------------- 1 | //! Raw transaction. 2 | 3 | use crate::{ 4 | proto::{ 5 | self, 6 | traits::{Message, MessageExt}, 7 | }, 8 | Result, 9 | }; 10 | 11 | #[cfg(feature = "rpc")] 12 | use crate::rpc; 13 | 14 | /// Response from `/broadcast_tx_commit` 15 | #[cfg(feature = "rpc")] 16 | pub type TxCommitResponse = rpc::endpoint::broadcast::tx_commit::Response; 17 | 18 | /// Raw transaction 19 | #[derive(Clone, Debug)] 20 | pub struct Raw(proto::cosmos::tx::v1beta1::TxRaw); 21 | 22 | impl Raw { 23 | /// Deserialize raw transaction from serialized protobuf. 24 | pub fn from_bytes(bytes: &[u8]) -> Result { 25 | Ok(Raw(Message::decode(bytes)?)) 26 | } 27 | 28 | /// Serialize raw transaction as a byte vector. 29 | pub fn to_bytes(&self) -> Result> { 30 | Ok(self.0.to_bytes()?) 31 | } 32 | 33 | /// Broadcast this transaction using the provided RPC client 34 | #[cfg(feature = "rpc")] 35 | pub async fn broadcast_commit(&self, client: &C) -> Result 36 | where 37 | C: rpc::Client + Send + Sync, 38 | { 39 | Ok(client.broadcast_tx_commit(self.to_bytes()?).await?) 40 | } 41 | } 42 | 43 | impl From for Raw { 44 | fn from(tx: proto::cosmos::tx::v1beta1::TxRaw) -> Self { 45 | Raw(tx) 46 | } 47 | } 48 | 49 | impl From for proto::cosmos::tx::v1beta1::TxRaw { 50 | fn from(tx: Raw) -> proto::cosmos::tx::v1beta1::TxRaw { 51 | tx.0 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.crypto.secp256r1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// PubKey defines a secp256r1 ECDSA public key. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct PubKey { 6 | /// Point on secp256r1 curve in a compressed representation as specified in section 7 | /// 4.3.6 of ANSI X9.62: 8 | #[prost(bytes = "vec", tag = "1")] 9 | pub key: ::prost::alloc::vec::Vec, 10 | } 11 | impl ::prost::Name for PubKey { 12 | const NAME: &'static str = "PubKey"; 13 | const PACKAGE: &'static str = "cosmos.crypto.secp256r1"; 14 | fn full_name() -> ::prost::alloc::string::String { 15 | ::prost::alloc::format!("cosmos.crypto.secp256r1.{}", Self::NAME) 16 | } 17 | } 18 | /// PrivKey defines a secp256r1 ECDSA private key. 19 | #[allow(clippy::derive_partial_eq_without_eq)] 20 | #[derive(Clone, PartialEq, ::prost::Message)] 21 | pub struct PrivKey { 22 | /// secret number serialized using big-endian encoding 23 | #[prost(bytes = "vec", tag = "1")] 24 | pub secret: ::prost::alloc::vec::Vec, 25 | } 26 | impl ::prost::Name for PrivKey { 27 | const NAME: &'static str = "PrivKey"; 28 | const PACKAGE: &'static str = "cosmos.crypto.secp256r1"; 29 | fn full_name() -> ::prost::alloc::string::String { 30 | ::prost::alloc::format!("cosmos.crypto.secp256r1.{}", Self::NAME) 31 | } 32 | } 33 | include!("cosmos.crypto.secp256r1.serde.rs"); 34 | // @@protoc_insertion_point(module) 35 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.store.internal.kv.v1beta1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // This is duplicated from the base kv directory to avoid a circular dependency with the cosmos-sdk 3 | 4 | /// Pairs defines a repeated slice of Pair objects. 5 | #[allow(clippy::derive_partial_eq_without_eq)] 6 | #[derive(Clone, PartialEq, ::prost::Message)] 7 | pub struct Pairs { 8 | #[prost(message, repeated, tag = "1")] 9 | pub pairs: ::prost::alloc::vec::Vec, 10 | } 11 | impl ::prost::Name for Pairs { 12 | const NAME: &'static str = "Pairs"; 13 | const PACKAGE: &'static str = "cosmos.store.internal.kv.v1beta1"; 14 | fn full_name() -> ::prost::alloc::string::String { 15 | ::prost::alloc::format!("cosmos.store.internal.kv.v1beta1.{}", Self::NAME) 16 | } 17 | } 18 | /// Pair defines a key/value bytes tuple. 19 | #[allow(clippy::derive_partial_eq_without_eq)] 20 | #[derive(Clone, PartialEq, ::prost::Message)] 21 | pub struct Pair { 22 | #[prost(bytes = "vec", tag = "1")] 23 | pub key: ::prost::alloc::vec::Vec, 24 | #[prost(bytes = "vec", tag = "2")] 25 | pub value: ::prost::alloc::vec::Vec, 26 | } 27 | impl ::prost::Name for Pair { 28 | const NAME: &'static str = "Pair"; 29 | const PACKAGE: &'static str = "cosmos.store.internal.kv.v1beta1"; 30 | fn full_name() -> ::prost::alloc::string::String { 31 | ::prost::alloc::format!("cosmos.store.internal.kv.v1beta1.{}", Self::NAME) 32 | } 33 | } 34 | include!("cosmos.store.internal.kv.v1beta1.serde.rs"); 35 | // @@protoc_insertion_point(module) 36 | -------------------------------------------------------------------------------- /.github/workflows/cosmos-sdk-proto.yml: -------------------------------------------------------------------------------- 1 | name: cosmos-sdk-proto 2 | 3 | on: 4 | push: 5 | branches: main 6 | pull_request: 7 | paths: 8 | - ".github/workflows/cosmos-sdk-proto.yml" 9 | - "cosmos-sdk-proto/**" 10 | - "Cargo.*" 11 | 12 | defaults: 13 | run: 14 | working-directory: cosmos-sdk-proto 15 | 16 | env: 17 | CARGO_TERM_COLOR: always 18 | RUSTFLAGS: -Dwarnings 19 | 20 | jobs: 21 | build: 22 | runs-on: ubuntu-latest 23 | strategy: 24 | matrix: 25 | rust: 26 | - 1.75.0 # MSRV 27 | target: 28 | - x86_64-unknown-linux-gnu 29 | - wasm32-unknown-unknown 30 | steps: 31 | - uses: actions/checkout@v1 32 | - uses: dtolnay/rust-toolchain@master 33 | with: 34 | toolchain: ${{ matrix.rust }} 35 | target: ${{ matrix.target }} 36 | - run: cargo build --target ${{ matrix.target }} --release --no-default-features 37 | - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features grpc 38 | - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde 39 | 40 | test: 41 | runs-on: ubuntu-latest 42 | strategy: 43 | matrix: 44 | rust: 45 | - 1.75.0 # MSRV 46 | - stable 47 | steps: 48 | - uses: actions/checkout@v1 49 | - uses: dtolnay/rust-toolchain@master 50 | with: 51 | toolchain: ${{ matrix.rust }} 52 | - run: cargo test --release 53 | - run: cargo test --all-features --release 54 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.crypto.secp256k1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// PubKey defines a secp256k1 public key 3 | /// Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte 4 | /// if the y-coordinate is the lexicographically largest of the two associated with 5 | /// the x-coordinate. Otherwise the first byte is a 0x03. 6 | /// This prefix is followed with the x-coordinate. 7 | #[allow(clippy::derive_partial_eq_without_eq)] 8 | #[derive(Clone, PartialEq, ::prost::Message)] 9 | pub struct PubKey { 10 | #[prost(bytes = "vec", tag = "1")] 11 | pub key: ::prost::alloc::vec::Vec, 12 | } 13 | impl ::prost::Name for PubKey { 14 | const NAME: &'static str = "PubKey"; 15 | const PACKAGE: &'static str = "cosmos.crypto.secp256k1"; 16 | fn full_name() -> ::prost::alloc::string::String { 17 | ::prost::alloc::format!("cosmos.crypto.secp256k1.{}", Self::NAME) 18 | } 19 | } 20 | /// PrivKey defines a secp256k1 private key. 21 | #[allow(clippy::derive_partial_eq_without_eq)] 22 | #[derive(Clone, PartialEq, ::prost::Message)] 23 | pub struct PrivKey { 24 | #[prost(bytes = "vec", tag = "1")] 25 | pub key: ::prost::alloc::vec::Vec, 26 | } 27 | impl ::prost::Name for PrivKey { 28 | const NAME: &'static str = "PrivKey"; 29 | const PACKAGE: &'static str = "cosmos.crypto.secp256k1"; 30 | fn full_name() -> ::prost::alloc::string::String { 31 | ::prost::alloc::format!("cosmos.crypto.secp256k1.{}", Self::NAME) 32 | } 33 | } 34 | include!("cosmos.crypto.secp256k1.serde.rs"); 35 | // @@protoc_insertion_point(module) 36 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/contract_code_history_entry.rs: -------------------------------------------------------------------------------- 1 | use super::{AbsoluteTxPosition, ContractCodeId}; 2 | use crate::{ 3 | proto::{self, cosmwasm::wasm::v1::ContractCodeHistoryOperationType}, 4 | Error, ErrorReport, Result, 5 | }; 6 | 7 | /// ContractCodeHistoryEntry metadata to a contract. 8 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 9 | pub struct ContractCodeHistoryEntry { 10 | /// The source of this history entry. 11 | pub operation: ContractCodeHistoryOperationType, 12 | 13 | /// Reference to the stored Wasm code. 14 | pub code_id: ContractCodeId, 15 | 16 | /// Updated Tx position when the operation was executed. 17 | pub updated: Option, 18 | 19 | /// Raw message returned by a wasm contract. 20 | pub msg: Vec, 21 | } 22 | 23 | impl TryFrom for ContractCodeHistoryEntry { 24 | type Error = ErrorReport; 25 | 26 | fn try_from( 27 | proto: proto::cosmwasm::wasm::v1::ContractCodeHistoryEntry, 28 | ) -> Result { 29 | Ok(ContractCodeHistoryEntry { 30 | operation: ContractCodeHistoryOperationType::try_from(proto.operation).map_err( 31 | |_| Error::InvalidEnumValue { 32 | name: "operation", 33 | found_value: proto.operation, 34 | }, 35 | )?, 36 | code_id: proto.code_id, 37 | updated: proto.updated.map(TryFrom::try_from).transpose()?, 38 | msg: proto.msg, 39 | }) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cosmrs/src/crypto/compact_bit_array.rs: -------------------------------------------------------------------------------- 1 | //! Compact bit array. 2 | 3 | use crate::proto; 4 | 5 | /// [`CompactBitArray`] is an implementation of a space efficient bit array. 6 | /// 7 | /// This is used to ensure that the encoded data takes up a minimal amount of 8 | /// space after proto encoding. 9 | #[derive(Clone, Debug, PartialEq)] 10 | pub struct CompactBitArray { 11 | // TODO(tarcieri): better internal representation for this, e.g. `bitvec` 12 | inner: proto::cosmos::crypto::multisig::v1beta1::CompactBitArray, 13 | } 14 | 15 | impl CompactBitArray { 16 | /// Create a new [`CompactBitArray`] from a given number of extra 17 | /// bits stored and a byte slice containing the bits. 18 | pub fn new(extra_bits_stored: u32, elems: impl Into>) -> CompactBitArray { 19 | let inner = proto::cosmos::crypto::multisig::v1beta1::CompactBitArray { 20 | extra_bits_stored, 21 | elems: elems.into(), 22 | }; 23 | 24 | CompactBitArray { inner } 25 | } 26 | } 27 | 28 | impl Eq for CompactBitArray {} 29 | 30 | impl From for CompactBitArray { 31 | fn from(proto: proto::cosmos::crypto::multisig::v1beta1::CompactBitArray) -> CompactBitArray { 32 | CompactBitArray { inner: proto } 33 | } 34 | } 35 | 36 | impl From for proto::cosmos::crypto::multisig::v1beta1::CompactBitArray { 37 | fn from( 38 | bitarray: CompactBitArray, 39 | ) -> proto::cosmos::crypto::multisig::v1beta1::CompactBitArray { 40 | bitarray.inner 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /cosmrs/src/staking/historical_info.rs: -------------------------------------------------------------------------------- 1 | use crate::staking::Validator; 2 | use crate::{proto, ErrorReport, Result}; 3 | use tendermint::block::Header; 4 | 5 | /// HistoricalInfo contains header and validator information for a given block. 6 | /// It is stored as part of staking module's state, which persists the `n` most 7 | /// recent HistoricalInfo 8 | /// (`n` is set by the staking module's `historical_entries` parameter). 9 | #[derive(Clone, Debug, PartialEq)] 10 | pub struct HistoricalInfo { 11 | /// Header of the block 12 | pub header: Option
, 13 | 14 | /// The validator set at the block 15 | pub valset: Vec, 16 | } 17 | 18 | impl TryFrom for HistoricalInfo { 19 | type Error = ErrorReport; 20 | 21 | fn try_from(proto: cosmos_sdk_proto::cosmos::staking::v1beta1::HistoricalInfo) -> Result { 22 | Ok(HistoricalInfo { 23 | header: proto.header.map(TryInto::try_into).transpose()?, 24 | valset: proto 25 | .valset 26 | .into_iter() 27 | .map(TryInto::try_into) 28 | .collect::>()?, 29 | }) 30 | } 31 | } 32 | 33 | impl From for proto::cosmos::staking::v1beta1::HistoricalInfo { 34 | fn from(historical_info: HistoricalInfo) -> Self { 35 | proto::cosmos::staking::v1beta1::HistoricalInfo { 36 | header: historical_info.header.map(Into::into), 37 | valset: historical_info.valset.into_iter().map(Into::into).collect(), 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.staking.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the staking module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// hooks_order specifies the order of staking hooks and should be a list 7 | /// of module names which provide a staking hooks instance. If no order is 8 | /// provided, then hooks will be applied in alphabetical order of module names. 9 | #[prost(string, repeated, tag = "1")] 10 | pub hooks_order: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, 11 | /// authority defines the custom module authority. If not set, defaults to the governance module. 12 | #[prost(string, tag = "2")] 13 | pub authority: ::prost::alloc::string::String, 14 | /// bech32_prefix_validator is the bech32 validator prefix for the app. 15 | #[prost(string, tag = "3")] 16 | pub bech32_prefix_validator: ::prost::alloc::string::String, 17 | /// bech32_prefix_consensus is the bech32 consensus node prefix for the app. 18 | #[prost(string, tag = "4")] 19 | pub bech32_prefix_consensus: ::prost::alloc::string::String, 20 | } 21 | impl ::prost::Name for Module { 22 | const NAME: &'static str = "Module"; 23 | const PACKAGE: &'static str = "cosmos.staking.module.v1"; 24 | fn full_name() -> ::prost::alloc::string::String { 25 | ::prost::alloc::format!("cosmos.staking.module.v1.{}", Self::NAME) 26 | } 27 | } 28 | include!("cosmos.staking.module.v1.serde.rs"); 29 | // @@protoc_insertion_point(module) 30 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/README.md: -------------------------------------------------------------------------------- 1 | # cosmos-sdk-proto 2 | 3 | [![Crate][crate-image]][crate-link] 4 | [![Docs][docs-image]][docs-link] 5 | [![Build Status][build-image]][build-link] 6 | [![Apache 2.0 Licensed][license-image]][license-link] 7 | ![MSRV][rustc-image] 8 | 9 | Rust crate for interacting with [Protobufs] defined by the [Cosmos SDK]. 10 | 11 | The goal of this crate is to provide complete proto struct definitions for interacting 12 | with a Cosmos SDK blockchain. 13 | 14 | Currently, this crate only provides a subset of the many total structs exported by 15 | Cosmos SDK proto files. 16 | 17 | Pull requests to expand coverage are welcome. 18 | 19 | [Documentation][docs-link] 20 | 21 | ## Minimum Supported Rust Version 22 | 23 | This crate is supported on Rust **1.75** or newer. 24 | 25 | [//]: # "badges" 26 | [crate-image]: https://img.shields.io/crates/v/cosmos-sdk-proto?logo=rust 27 | [crate-link]: https://crates.io/crates/cosmos-sdk-proto 28 | [docs-image]: https://docs.rs/cosmos-sdk-proto/badge.svg 29 | [docs-link]: https://docs.rs/cosmos-sdk-proto/ 30 | [build-image]: https://github.com/cosmos/cosmos-rust/workflows/cosmos-sdk-proto/badge.svg 31 | [build-link]: https://github.com/cosmos/cosmos-rust/actions/workflows/cosmos-sdk-proto.yml 32 | [license-image]: https://img.shields.io/badge/license-Apache2.0-blue.svg 33 | [license-link]: https://github.com/cosmos/cosmos-rust/blob/master/LICENSE 34 | [rustc-image]: https://img.shields.io/badge/rustc-1.75+-blue.svg 35 | 36 | [//]: # "links" 37 | [Protobufs]: https://github.com/cosmos/cosmos-sdk/tree/master/proto/ 38 | [Cosmos SDK]: https://github.com/cosmos/cosmos-sdk 39 | -------------------------------------------------------------------------------- /cosmrs/src/vesting/continuous_vesting_account.rs: -------------------------------------------------------------------------------- 1 | use super::BaseVestingAccount; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// [`ContinuousVestingAccount`] implements the `VestingAccount` interface. 5 | /// 6 | /// It continuously vests by unlocking coins linearly with respect to time. 7 | #[derive(Clone, Debug, Eq, PartialEq)] 8 | pub struct ContinuousVestingAccount { 9 | /// Base vesting account specification required for this vesting implementation. 10 | pub base_vesting_account: Option, 11 | 12 | /// The BFT time at which a vesting account starts to vest. 13 | pub start_time: i64, 14 | } 15 | 16 | impl TryFrom 17 | for ContinuousVestingAccount 18 | { 19 | type Error = ErrorReport; 20 | 21 | fn try_from( 22 | proto: proto::cosmos::vesting::v1beta1::ContinuousVestingAccount, 23 | ) -> Result { 24 | Ok(ContinuousVestingAccount { 25 | base_vesting_account: proto 26 | .base_vesting_account 27 | .map(TryFrom::try_from) 28 | .transpose()?, 29 | start_time: proto.start_time, 30 | }) 31 | } 32 | } 33 | 34 | impl From for proto::cosmos::vesting::v1beta1::ContinuousVestingAccount { 35 | fn from(account: ContinuousVestingAccount) -> Self { 36 | proto::cosmos::vesting::v1beta1::ContinuousVestingAccount { 37 | base_vesting_account: account.base_vesting_account.map(Into::into), 38 | start_time: 0, 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cosmrs/src/staking/description.rs: -------------------------------------------------------------------------------- 1 | use crate::proto; 2 | 3 | /// Description defines a validator description. 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct Description { 6 | /// moniker defines a human-readable name for the validator. 7 | pub moniker: String, 8 | 9 | /// identity defines an optional identity signature (ex. UPort or Keybase). 10 | pub identity: String, 11 | 12 | /// website defines an optional website link. 13 | pub website: String, 14 | 15 | /// security_contact defines an optional email for security contact. 16 | pub security_contact: String, 17 | 18 | /// details define other optional details. 19 | pub details: String, 20 | } 21 | 22 | impl From for Description { 23 | fn from(proto: cosmos_sdk_proto::cosmos::staking::v1beta1::Description) -> Self { 24 | Description { 25 | moniker: proto.moniker, 26 | identity: proto.identity, 27 | website: proto.website, 28 | security_contact: proto.security_contact, 29 | details: proto.details, 30 | } 31 | } 32 | } 33 | 34 | impl From for proto::cosmos::staking::v1beta1::Description { 35 | fn from(description: Description) -> Self { 36 | proto::cosmos::staking::v1beta1::Description { 37 | moniker: description.moniker, 38 | identity: description.identity, 39 | website: description.website, 40 | security_contact: description.security_contact, 41 | details: description.details, 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /cosmrs/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | #![doc( 3 | html_logo_url = "https://raw.githubusercontent.com/cosmos/cosmos-rust/main/.images/cosmos.png" 4 | )] 5 | #![cfg_attr(docsrs, feature(doc_auto_cfg))] 6 | #![forbid(unsafe_code)] 7 | #![warn( 8 | clippy::checked_conversions, 9 | clippy::panic, 10 | clippy::panic_in_result_fn, 11 | clippy::unwrap_used, 12 | missing_docs, 13 | trivial_casts, 14 | trivial_numeric_casts, 15 | rust_2018_idioms, 16 | unused_lifetimes, 17 | unused_import_braces 18 | )] 19 | 20 | //! ## Re-exports 21 | //! 22 | //! CosmRS re-exports the following crates for easy access: 23 | //! 24 | //! - `bip32`: re-exported as `cosmrs::bip32` 25 | //! - `cosmos-sdk-proto`: re-exported as `cosmrs::proto` 26 | //! - `tendermint`: re-exported as `cosmrs::tendermint` 27 | //! - `tendermint-rpc`: re-exported as `cosmrs::rpc` (requires `rpc` crate feature) 28 | 29 | pub mod abci; 30 | pub mod auth; 31 | pub mod bank; 32 | pub mod crypto; 33 | pub mod distribution; 34 | pub mod feegrant; 35 | pub mod slashing; 36 | pub mod staking; 37 | pub mod tx; 38 | pub mod vesting; 39 | 40 | #[cfg(feature = "cosmwasm")] 41 | pub mod cosmwasm; 42 | 43 | #[cfg(feature = "dev")] 44 | pub mod dev; 45 | 46 | mod base; 47 | mod error; 48 | 49 | pub use crate::{ 50 | base::{query, AccountId, Amount, Coin, Denom, Gas}, 51 | error::{Error, Result}, 52 | tx::Tx, 53 | }; 54 | 55 | pub use cosmos_sdk_proto::{self as proto, Any}; 56 | pub use eyre::Report as ErrorReport; 57 | pub use tendermint; 58 | 59 | #[cfg(feature = "bip32")] 60 | pub use bip32; 61 | 62 | #[cfg(feature = "rpc")] 63 | pub use tendermint_rpc as rpc; 64 | -------------------------------------------------------------------------------- /.github/workflows/cosmrs.yml: -------------------------------------------------------------------------------- 1 | name: cosmrs 2 | 3 | on: 4 | push: 5 | branches: main 6 | pull_request: 7 | paths: 8 | - ".github/workflows/cosmrs.yml" 9 | - "cosmos-sdk-proto/**" 10 | - "cosmrs/**" 11 | - "Cargo.*" 12 | 13 | defaults: 14 | run: 15 | working-directory: cosmrs 16 | 17 | env: 18 | CARGO_TERM_COLOR: always 19 | RUSTFLAGS: -Dwarnings 20 | RUSTDOCFLAGS: -Dwarnings 21 | 22 | jobs: 23 | build: 24 | runs-on: ubuntu-latest 25 | strategy: 26 | matrix: 27 | rust: 28 | - 1.75.0 # MSRV 29 | target: 30 | - x86_64-unknown-linux-gnu 31 | - wasm32-unknown-unknown 32 | steps: 33 | - uses: actions/checkout@v1 34 | - uses: dtolnay/rust-toolchain@master 35 | with: 36 | toolchain: ${{ matrix.rust }} 37 | target: ${{ matrix.target }} 38 | - run: cargo build --target ${{ matrix.target }} --no-default-features --release 39 | 40 | test: 41 | runs-on: ubuntu-latest 42 | strategy: 43 | matrix: 44 | rust: 45 | - 1.75.0 # MSRV 46 | - stable 47 | steps: 48 | - uses: actions/checkout@v1 49 | - uses: dtolnay/rust-toolchain@master 50 | with: 51 | toolchain: ${{ matrix.rust }} 52 | - run: cargo test --release --no-default-features 53 | - run: cargo test --release 54 | - run: cargo test --release --all-features 55 | 56 | doc: 57 | runs-on: ubuntu-latest 58 | steps: 59 | - uses: actions/checkout@v2 60 | - uses: dtolnay/rust-toolchain@master 61 | with: 62 | toolchain: stable 63 | - run: cargo doc --all-features 64 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.bank.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object of the bank module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// blocked_module_accounts_override configures exceptional module accounts which should be blocked from receiving 7 | /// funds. If left empty it defaults to the list of account names supplied in the auth module configuration as 8 | /// module_account_permissions 9 | #[prost(string, repeated, tag = "1")] 10 | pub blocked_module_accounts_override: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, 11 | /// authority defines the custom module authority. If not set, defaults to the governance module. 12 | #[prost(string, tag = "2")] 13 | pub authority: ::prost::alloc::string::String, 14 | /// restrictions_order specifies the order of send restrictions and should be 15 | /// a list of module names which provide a send restriction instance. If no 16 | /// order is provided, then restrictions will be applied in alphabetical order 17 | /// of module names. 18 | #[prost(string, repeated, tag = "3")] 19 | pub restrictions_order: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, 20 | } 21 | impl ::prost::Name for Module { 22 | const NAME: &'static str = "Module"; 23 | const PACKAGE: &'static str = "cosmos.bank.module.v1"; 24 | fn full_name() -> ::prost::alloc::string::String { 25 | ::prost::alloc::format!("cosmos.bank.module.v1.{}", Self::NAME) 26 | } 27 | } 28 | include!("cosmos.bank.module.v1.serde.rs"); 29 | // @@protoc_insertion_point(module) 30 | -------------------------------------------------------------------------------- /cosmrs/src/staking/query_validators_response.rs: -------------------------------------------------------------------------------- 1 | use crate::base::query::PageResponse; 2 | use crate::staking::Validator; 3 | use crate::{proto, ErrorReport, Result}; 4 | 5 | /// QueryValidatorsResponse is response type for the Query/Validators RPC method 6 | #[derive(Clone, Debug, PartialEq)] 7 | pub struct QueryValidatorsResponse { 8 | /// validators contains all the queried validators. 9 | pub validators: Vec, 10 | 11 | /// pagination defines the pagination in the response. 12 | pub pagination: Option, 13 | } 14 | 15 | impl TryFrom for QueryValidatorsResponse { 16 | type Error = ErrorReport; 17 | 18 | fn try_from( 19 | proto: cosmos_sdk_proto::cosmos::staking::v1beta1::QueryValidatorsResponse, 20 | ) -> Result { 21 | Ok(QueryValidatorsResponse { 22 | validators: proto 23 | .validators 24 | .into_iter() 25 | .map(TryInto::try_into) 26 | .collect::>()?, 27 | pagination: proto.pagination.map(Into::into), 28 | }) 29 | } 30 | } 31 | 32 | impl From for proto::cosmos::staking::v1beta1::QueryValidatorsResponse { 33 | fn from(query_validators_response: QueryValidatorsResponse) -> Self { 34 | proto::cosmos::staking::v1beta1::QueryValidatorsResponse { 35 | validators: query_validators_response 36 | .validators 37 | .into_iter() 38 | .map(Into::into) 39 | .collect(), 40 | pagination: query_validators_response.pagination.map(Into::into), 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.crypto.ed25519.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// PubKey is an ed25519 public key for handling Tendermint keys in SDK. 3 | /// It's needed for Any serialization and SDK compatibility. 4 | /// It must not be used in a non Tendermint key context because it doesn't implement 5 | /// ADR-28. Nevertheless, you will like to use ed25519 in app user level 6 | /// then you must create a new proto message and follow ADR-28 for Address construction. 7 | #[allow(clippy::derive_partial_eq_without_eq)] 8 | #[derive(Clone, PartialEq, ::prost::Message)] 9 | pub struct PubKey { 10 | #[prost(bytes = "vec", tag = "1")] 11 | pub key: ::prost::alloc::vec::Vec, 12 | } 13 | impl ::prost::Name for PubKey { 14 | const NAME: &'static str = "PubKey"; 15 | const PACKAGE: &'static str = "cosmos.crypto.ed25519"; 16 | fn full_name() -> ::prost::alloc::string::String { 17 | ::prost::alloc::format!("cosmos.crypto.ed25519.{}", Self::NAME) 18 | } 19 | } 20 | /// PrivKey defines a ed25519 private key. 21 | /// NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context. 22 | #[allow(clippy::derive_partial_eq_without_eq)] 23 | #[derive(Clone, PartialEq, ::prost::Message)] 24 | pub struct PrivKey { 25 | #[prost(bytes = "vec", tag = "1")] 26 | pub key: ::prost::alloc::vec::Vec, 27 | } 28 | impl ::prost::Name for PrivKey { 29 | const NAME: &'static str = "PrivKey"; 30 | const PACKAGE: &'static str = "cosmos.crypto.ed25519"; 31 | fn full_name() -> ::prost::alloc::string::String { 32 | ::prost::alloc::format!("cosmos.crypto.ed25519.{}", Self::NAME) 33 | } 34 | } 35 | include!("cosmos.crypto.ed25519.serde.rs"); 36 | // @@protoc_insertion_point(module) 37 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/code_info_response.rs: -------------------------------------------------------------------------------- 1 | use super::{AccessConfig, ContractCodeId}; 2 | use crate::{proto, AccountId, ErrorReport, Result}; 3 | 4 | /// CodeInfoResponse contains code meta data from CodeInfo 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct CodeInfoResponse { 7 | /// CodeId of the stored contract code. 8 | pub code_id: ContractCodeId, 9 | 10 | /// Bech32 [`AccountId`] of the creator of this smart contract. 11 | pub creator: AccountId, 12 | 13 | /// sha256 hash of the code stored 14 | pub data_hash: Vec, 15 | 16 | /// Instantiate permission. 17 | pub instantiate_permission: Option, 18 | } 19 | 20 | impl TryFrom for CodeInfoResponse { 21 | type Error = ErrorReport; 22 | 23 | fn try_from(proto: proto::cosmwasm::wasm::v1::CodeInfoResponse) -> Result { 24 | Ok(CodeInfoResponse { 25 | code_id: proto.code_id, 26 | creator: proto.creator.parse()?, 27 | data_hash: proto.data_hash, 28 | instantiate_permission: proto 29 | .instantiate_permission 30 | .map(TryInto::try_into) 31 | .transpose()?, 32 | }) 33 | } 34 | } 35 | 36 | impl From for proto::cosmwasm::wasm::v1::CodeInfoResponse { 37 | fn from(code_info: CodeInfoResponse) -> Self { 38 | proto::cosmwasm::wasm::v1::CodeInfoResponse { 39 | code_id: code_info.code_id, 40 | creator: code_info.creator.to_string(), 41 | data_hash: code_info.data_hash, 42 | instantiate_permission: code_info.instantiate_permission.map(Into::into), 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/query_signing_infos_response.rs: -------------------------------------------------------------------------------- 1 | use crate::base::query::PageResponse; 2 | use crate::slashing::ValidatorSigningInfo; 3 | use crate::{proto, ErrorReport, Result}; 4 | 5 | /// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC 6 | /// method 7 | #[derive(Clone, Debug, Eq, PartialEq)] 8 | pub struct QuerySigningInfosResponse { 9 | /// info is the signing info of all validators 10 | pub info: Vec, 11 | 12 | /// pagination information 13 | pub pagination: Option, 14 | } 15 | 16 | impl TryFrom 17 | for QuerySigningInfosResponse 18 | { 19 | type Error = ErrorReport; 20 | 21 | fn try_from( 22 | proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::QuerySigningInfosResponse, 23 | ) -> Result { 24 | Ok(QuerySigningInfosResponse { 25 | info: proto 26 | .info 27 | .into_iter() 28 | .map(TryInto::try_into) 29 | .collect::>()?, 30 | pagination: proto.pagination.map(Into::into), 31 | }) 32 | } 33 | } 34 | 35 | impl From 36 | for proto::cosmos::slashing::v1beta1::QuerySigningInfosResponse 37 | { 38 | fn from(signing_infos_response: QuerySigningInfosResponse) -> Self { 39 | proto::cosmos::slashing::v1beta1::QuerySigningInfosResponse { 40 | info: signing_infos_response 41 | .info 42 | .into_iter() 43 | .map(Into::into) 44 | .collect(), 45 | pagination: signing_infos_response.pagination.map(Into::into), 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.crypto.multisig.v1beta1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. 3 | /// See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers 4 | /// signed and with which modes. 5 | #[allow(clippy::derive_partial_eq_without_eq)] 6 | #[derive(Clone, PartialEq, ::prost::Message)] 7 | pub struct MultiSignature { 8 | #[prost(bytes = "vec", repeated, tag = "1")] 9 | pub signatures: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, 10 | } 11 | impl ::prost::Name for MultiSignature { 12 | const NAME: &'static str = "MultiSignature"; 13 | const PACKAGE: &'static str = "cosmos.crypto.multisig.v1beta1"; 14 | fn full_name() -> ::prost::alloc::string::String { 15 | ::prost::alloc::format!("cosmos.crypto.multisig.v1beta1.{}", Self::NAME) 16 | } 17 | } 18 | /// CompactBitArray is an implementation of a space efficient bit array. 19 | /// This is used to ensure that the encoded data takes up a minimal amount of 20 | /// space after proto encoding. 21 | /// This is not thread safe, and is not intended for concurrent usage. 22 | #[allow(clippy::derive_partial_eq_without_eq)] 23 | #[derive(Clone, PartialEq, ::prost::Message)] 24 | pub struct CompactBitArray { 25 | #[prost(uint32, tag = "1")] 26 | pub extra_bits_stored: u32, 27 | #[prost(bytes = "vec", tag = "2")] 28 | pub elems: ::prost::alloc::vec::Vec, 29 | } 30 | impl ::prost::Name for CompactBitArray { 31 | const NAME: &'static str = "CompactBitArray"; 32 | const PACKAGE: &'static str = "cosmos.crypto.multisig.v1beta1"; 33 | fn full_name() -> ::prost::alloc::string::String { 34 | ::prost::alloc::format!("cosmos.crypto.multisig.v1beta1.{}", Self::NAME) 35 | } 36 | } 37 | include!("cosmos.crypto.multisig.v1beta1.serde.rs"); 38 | // @@protoc_insertion_point(module) 39 | -------------------------------------------------------------------------------- /cosmrs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cosmrs" 3 | version = "0.22.0" 4 | authors = ["Tony Arcieri "] 5 | license = "Apache-2.0" 6 | repository = "https://github.com/cosmos/cosmos-rust/tree/main/cosmrs" 7 | description = "Transaction builder and signer for Cosmos-based blockchains" 8 | readme = "README.md" 9 | categories = ["cryptography", "cryptography::cryptocurrencies", "encoding"] 10 | keywords = ["blockchain", "cosmos", "tendermint", "transaction"] 11 | edition = "2021" 12 | rust-version = "1.72" 13 | 14 | [dependencies] 15 | cosmos-sdk-proto = { version = "0.27", default-features = false, features = ["std"], path = "../cosmos-sdk-proto" } 16 | ecdsa = "0.16" 17 | eyre = "0.6" 18 | k256 = { version = "0.13", default-features = false, features = ["ecdsa", "sha256"] } 19 | rand_core = { version = "0.6", default-features = false } 20 | serde = { version = "1", features = ["serde_derive"] } 21 | serde_json = "1" 22 | signature = { version = "2", features = ["std"] } 23 | subtle-encoding = { version = "0.5", features = ["bech32-preview"] } 24 | tendermint = { version = "0.40.0", features = ["secp256k1"] } 25 | thiserror = "1" 26 | 27 | # optional dependencies 28 | bip32 = { version = "0.5", optional = true, default-features = false, features = ["alloc", "secp256k1"] } 29 | tendermint-rpc = { version = "0.40.0", optional = true, features = ["http-client"] } 30 | tokio = { version = "1", optional = true } 31 | 32 | [dev-dependencies] 33 | hex-literal = "0.4" 34 | 35 | [features] 36 | default = ["bip32", "getrandom"] 37 | cosmwasm = ["cosmos-sdk-proto/cosmwasm"] 38 | dev = ["rpc", "tokio"] 39 | getrandom = ["rand_core/getrandom"] 40 | grpc = ["cosmos-sdk-proto/grpc-transport", "grpc-core"] 41 | grpc-core = ["cosmos-sdk-proto/grpc"] 42 | rpc = ["tendermint-rpc"] 43 | 44 | [package.metadata.docs.rs] 45 | all-features = true 46 | rustdoc-args = ["--cfg", "docsrs"] 47 | -------------------------------------------------------------------------------- /cosmrs/src/error.rs: -------------------------------------------------------------------------------- 1 | //! Error types 2 | 3 | pub use eyre::Result; 4 | 5 | use tendermint::Hash; 6 | use thiserror::Error; 7 | 8 | /// Kinds of errors. 9 | #[derive(Clone, Debug, Eq, Error, PartialEq)] 10 | pub enum Error { 11 | /// Invalid account. 12 | #[error("invalid account ID: {id:?}")] 13 | AccountId { 14 | /// Malformed account ID 15 | id: String, 16 | }, 17 | 18 | /// Cryptographic errors. 19 | #[error("cryptographic error")] 20 | Crypto, 21 | 22 | /// Invalid decimal value. 23 | #[error("invalid decimal value: {value:?}")] 24 | Decimal { 25 | /// Invalid decimal value 26 | value: String, 27 | }, 28 | 29 | /// Invalid denomination. 30 | #[error("invalid denomination: {name:?}")] 31 | Denom { 32 | /// Invalid name 33 | name: String, 34 | }, 35 | 36 | /// Invalid value for the given field of an enum. 37 | #[error("invalid proto enum value: {name:?}, value: {found_value:?}")] 38 | InvalidEnumValue { 39 | /// Name of the enum field 40 | name: &'static str, 41 | 42 | /// Actual value of the field found 43 | found_value: i32, 44 | }, 45 | 46 | /// Protobuf is missing a field. 47 | #[error("missing proto field: {name:?}")] 48 | MissingField { 49 | /// Name of the missing field 50 | name: &'static str, 51 | }, 52 | 53 | /// Unexpected message type. 54 | #[error("unexpected Msg type: {found:?}, expected {expected:?}")] 55 | MsgType { 56 | /// Expected type URL. 57 | expected: &'static str, 58 | 59 | /// Actual type URL found in the [`crate::Any`] message. 60 | found: String, 61 | }, 62 | 63 | /// Transaction not found. 64 | #[error("transaction not found: {hash:?}")] 65 | TxNotFound { 66 | /// Transaction hash that wasn't found. 67 | hash: Hash, 68 | }, 69 | } 70 | -------------------------------------------------------------------------------- /cosmrs/src/slashing/msg_unjail.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, ErrorReport, Result}; 2 | 3 | /// MsgUnjail defines the Msg/Unjail request type 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MsgUnjail { 6 | /// Address of the validator to unjail. 7 | pub validator_addr: AccountId, 8 | } 9 | 10 | impl Msg for MsgUnjail { 11 | type Proto = proto::cosmos::slashing::v1beta1::MsgUnjail; 12 | } 13 | 14 | impl TryFrom for MsgUnjail { 15 | type Error = ErrorReport; 16 | 17 | fn try_from(proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::MsgUnjail) -> Result { 18 | Ok(MsgUnjail { 19 | validator_addr: proto.validator_addr.parse()?, 20 | }) 21 | } 22 | } 23 | 24 | impl From for cosmos_sdk_proto::cosmos::slashing::v1beta1::MsgUnjail { 25 | fn from(msg_unjail: MsgUnjail) -> Self { 26 | cosmos_sdk_proto::cosmos::slashing::v1beta1::MsgUnjail { 27 | validator_addr: msg_unjail.validator_addr.to_string(), 28 | } 29 | } 30 | } 31 | 32 | /// MsgUnjailResponse defines the Msg/Unjail response type 33 | #[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)] 34 | pub struct MsgUnjailResponse {} 35 | 36 | impl Msg for MsgUnjailResponse { 37 | type Proto = proto::cosmos::slashing::v1beta1::MsgUnjailResponse; 38 | } 39 | 40 | impl TryFrom for MsgUnjailResponse { 41 | type Error = ErrorReport; 42 | 43 | fn try_from( 44 | _proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::MsgUnjailResponse, 45 | ) -> Result { 46 | Ok(MsgUnjailResponse {}) 47 | } 48 | } 49 | 50 | impl From for cosmos_sdk_proto::cosmos::slashing::v1beta1::MsgUnjailResponse { 51 | fn from(_: MsgUnjailResponse) -> Self { 52 | cosmos_sdk_proto::cosmos::slashing::v1beta1::MsgUnjailResponse {} 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /cosmrs/src/auth/base_account.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | crypto::PublicKey, 3 | proto, 4 | tx::{AccountNumber, SequenceNumber}, 5 | AccountId, ErrorReport, Result, 6 | }; 7 | 8 | /// [`BaseAccount`] defines a base account type. 9 | /// 10 | /// It contains all the necessary fields for basic account functionality. 11 | /// 12 | /// Any custom account type should extend this type for additional functionality 13 | /// (e.g. vesting). 14 | #[derive(Clone, Debug, Eq, PartialEq)] 15 | pub struct BaseAccount { 16 | /// Bech32 [`AccountId`] of this account. 17 | pub address: AccountId, 18 | 19 | /// Optional [`PublicKey`] associated with this account. 20 | pub pubkey: Option, 21 | 22 | /// `account_number` is the account number of the account in state 23 | pub account_number: AccountNumber, 24 | 25 | /// Sequence of the account, which describes the number of committed transactions signed by a 26 | /// given address. 27 | pub sequence: SequenceNumber, 28 | } 29 | 30 | impl TryFrom for BaseAccount { 31 | type Error = ErrorReport; 32 | 33 | fn try_from(proto: proto::cosmos::auth::v1beta1::BaseAccount) -> Result { 34 | Ok(BaseAccount { 35 | address: proto.address.parse()?, 36 | pubkey: proto.pub_key.map(PublicKey::try_from).transpose()?, 37 | account_number: proto.account_number, 38 | sequence: proto.sequence, 39 | }) 40 | } 41 | } 42 | 43 | impl From for proto::cosmos::auth::v1beta1::BaseAccount { 44 | fn from(account: BaseAccount) -> proto::cosmos::auth::v1beta1::BaseAccount { 45 | proto::cosmos::auth::v1beta1::BaseAccount { 46 | address: account.address.to_string(), 47 | pub_key: account.pubkey.map(Into::into), 48 | account_number: account.account_number, 49 | sequence: account.sequence, 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /cosmrs/src/staking/commission.rs: -------------------------------------------------------------------------------- 1 | use crate::staking::CommissionRates; 2 | use crate::{proto, ErrorReport, Result}; 3 | use cosmos_sdk_proto::Timestamp; 4 | use tendermint::Time; 5 | 6 | /// Commission defines commission parameters for a given validator. 7 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 8 | pub struct Commission { 9 | /// commission_rates defines the initial commission rates to be used for creating a validator. 10 | pub commission_rates: Option, 11 | 12 | /// update_time is the last time the commission rate was changed. 13 | pub update_time: Option