├── .githooks └── pre-commit ├── .github ├── dependabot.yml └── workflows │ ├── cosmos-sdk-proto.yml │ ├── cosmrs.yml │ ├── proto-build.yml │ └── workspace.yml ├── .gitignore ├── .gitmodules ├── .images └── cosmos.png ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── cosmos-sdk-proto ├── CHANGELOG.md ├── Cargo.toml ├── README.md └── src │ ├── lib.rs │ ├── prost │ ├── cosmos-sdk │ │ ├── COSMOS_SDK_COMMIT │ │ ├── amino.rs │ │ ├── cosmos.app.runtime.v1alpha1.rs │ │ ├── cosmos.app.runtime.v1alpha1.serde.rs │ │ ├── cosmos.app.v1alpha1.rs │ │ ├── cosmos.app.v1alpha1.serde.rs │ │ ├── cosmos.app.v1alpha1.tonic.rs │ │ ├── cosmos.auth.module.v1.rs │ │ ├── cosmos.auth.module.v1.serde.rs │ │ ├── cosmos.auth.v1beta1.rs │ │ ├── cosmos.auth.v1beta1.serde.rs │ │ ├── cosmos.auth.v1beta1.tonic.rs │ │ ├── cosmos.authz.module.v1.rs │ │ ├── cosmos.authz.module.v1.serde.rs │ │ ├── cosmos.authz.v1beta1.rs │ │ ├── cosmos.authz.v1beta1.serde.rs │ │ ├── cosmos.authz.v1beta1.tonic.rs │ │ ├── cosmos.autocli.v1.rs │ │ ├── cosmos.autocli.v1.serde.rs │ │ ├── cosmos.autocli.v1.tonic.rs │ │ ├── cosmos.bank.module.v1.rs │ │ ├── cosmos.bank.module.v1.serde.rs │ │ ├── cosmos.bank.v1beta1.rs │ │ ├── cosmos.bank.v1beta1.serde.rs │ │ ├── cosmos.bank.v1beta1.tonic.rs │ │ ├── cosmos.base.abci.v1beta1.rs │ │ ├── cosmos.base.abci.v1beta1.serde.rs │ │ ├── cosmos.base.node.v1beta1.rs │ │ ├── cosmos.base.node.v1beta1.serde.rs │ │ ├── cosmos.base.node.v1beta1.tonic.rs │ │ ├── cosmos.base.query.v1beta1.rs │ │ ├── cosmos.base.query.v1beta1.serde.rs │ │ ├── cosmos.base.reflection.v1beta1.rs │ │ ├── cosmos.base.reflection.v1beta1.serde.rs │ │ ├── cosmos.base.reflection.v1beta1.tonic.rs │ │ ├── cosmos.base.reflection.v2alpha1.rs │ │ ├── cosmos.base.reflection.v2alpha1.serde.rs │ │ ├── cosmos.base.reflection.v2alpha1.tonic.rs │ │ ├── cosmos.base.tendermint.v1beta1.rs │ │ ├── cosmos.base.tendermint.v1beta1.serde.rs │ │ ├── cosmos.base.tendermint.v1beta1.tonic.rs │ │ ├── cosmos.base.v1beta1.rs │ │ ├── cosmos.base.v1beta1.serde.rs │ │ ├── cosmos.circuit.module.v1.rs │ │ ├── cosmos.circuit.module.v1.serde.rs │ │ ├── cosmos.circuit.v1.rs │ │ ├── cosmos.circuit.v1.serde.rs │ │ ├── cosmos.circuit.v1.tonic.rs │ │ ├── cosmos.consensus.module.v1.rs │ │ ├── cosmos.consensus.module.v1.serde.rs │ │ ├── cosmos.consensus.v1.rs │ │ ├── cosmos.consensus.v1.serde.rs │ │ ├── cosmos.consensus.v1.tonic.rs │ │ ├── cosmos.crisis.module.v1.rs │ │ ├── cosmos.crisis.module.v1.serde.rs │ │ ├── cosmos.crisis.v1beta1.rs │ │ ├── cosmos.crisis.v1beta1.serde.rs │ │ ├── cosmos.crisis.v1beta1.tonic.rs │ │ ├── cosmos.crypto.ed25519.rs │ │ ├── cosmos.crypto.ed25519.serde.rs │ │ ├── cosmos.crypto.hd.v1.rs │ │ ├── cosmos.crypto.hd.v1.serde.rs │ │ ├── cosmos.crypto.keyring.v1.rs │ │ ├── cosmos.crypto.keyring.v1.serde.rs │ │ ├── cosmos.crypto.multisig.rs │ │ ├── cosmos.crypto.multisig.serde.rs │ │ ├── cosmos.crypto.multisig.v1beta1.rs │ │ ├── cosmos.crypto.multisig.v1beta1.serde.rs │ │ ├── cosmos.crypto.secp256k1.rs │ │ ├── cosmos.crypto.secp256k1.serde.rs │ │ ├── cosmos.crypto.secp256r1.rs │ │ ├── cosmos.crypto.secp256r1.serde.rs │ │ ├── cosmos.distribution.module.v1.rs │ │ ├── cosmos.distribution.module.v1.serde.rs │ │ ├── cosmos.distribution.v1beta1.rs │ │ ├── cosmos.distribution.v1beta1.serde.rs │ │ ├── cosmos.distribution.v1beta1.tonic.rs │ │ ├── cosmos.evidence.module.v1.rs │ │ ├── cosmos.evidence.module.v1.serde.rs │ │ ├── cosmos.evidence.v1beta1.rs │ │ ├── cosmos.evidence.v1beta1.serde.rs │ │ ├── cosmos.evidence.v1beta1.tonic.rs │ │ ├── cosmos.feegrant.module.v1.rs │ │ ├── cosmos.feegrant.module.v1.serde.rs │ │ ├── cosmos.feegrant.v1beta1.rs │ │ ├── cosmos.feegrant.v1beta1.serde.rs │ │ ├── cosmos.feegrant.v1beta1.tonic.rs │ │ ├── cosmos.genutil.module.v1.rs │ │ ├── cosmos.genutil.module.v1.serde.rs │ │ ├── cosmos.genutil.v1beta1.rs │ │ ├── cosmos.genutil.v1beta1.serde.rs │ │ ├── cosmos.gov.module.v1.rs │ │ ├── cosmos.gov.module.v1.serde.rs │ │ ├── cosmos.gov.v1.rs │ │ ├── cosmos.gov.v1.serde.rs │ │ ├── cosmos.gov.v1.tonic.rs │ │ ├── cosmos.gov.v1beta1.rs │ │ ├── cosmos.gov.v1beta1.serde.rs │ │ ├── cosmos.gov.v1beta1.tonic.rs │ │ ├── cosmos.group.module.v1.rs │ │ ├── cosmos.group.module.v1.serde.rs │ │ ├── cosmos.group.v1.rs │ │ ├── cosmos.group.v1.serde.rs │ │ ├── cosmos.group.v1.tonic.rs │ │ ├── cosmos.mint.module.v1.rs │ │ ├── cosmos.mint.module.v1.serde.rs │ │ ├── cosmos.mint.v1beta1.rs │ │ ├── cosmos.mint.v1beta1.serde.rs │ │ ├── cosmos.mint.v1beta1.tonic.rs │ │ ├── cosmos.msg.textual.v1.rs │ │ ├── cosmos.msg.v1.rs │ │ ├── cosmos.nft.module.v1.rs │ │ ├── cosmos.nft.module.v1.serde.rs │ │ ├── cosmos.nft.v1beta1.rs │ │ ├── cosmos.nft.v1beta1.serde.rs │ │ ├── cosmos.nft.v1beta1.tonic.rs │ │ ├── cosmos.orm.module.v1alpha1.rs │ │ ├── cosmos.orm.module.v1alpha1.serde.rs │ │ ├── cosmos.orm.query.v1alpha1.rs │ │ ├── cosmos.orm.query.v1alpha1.serde.rs │ │ ├── cosmos.orm.query.v1alpha1.tonic.rs │ │ ├── cosmos.orm.v1.rs │ │ ├── cosmos.orm.v1.serde.rs │ │ ├── cosmos.orm.v1alpha1.rs │ │ ├── cosmos.orm.v1alpha1.serde.rs │ │ ├── cosmos.params.module.v1.rs │ │ ├── cosmos.params.module.v1.serde.rs │ │ ├── cosmos.params.v1beta1.rs │ │ ├── cosmos.params.v1beta1.serde.rs │ │ ├── cosmos.params.v1beta1.tonic.rs │ │ ├── cosmos.query.v1.rs │ │ ├── cosmos.reflection.v1.rs │ │ ├── cosmos.reflection.v1.serde.rs │ │ ├── cosmos.reflection.v1.tonic.rs │ │ ├── cosmos.slashing.module.v1.rs │ │ ├── cosmos.slashing.module.v1.serde.rs │ │ ├── cosmos.slashing.v1beta1.rs │ │ ├── cosmos.slashing.v1beta1.serde.rs │ │ ├── cosmos.slashing.v1beta1.tonic.rs │ │ ├── cosmos.staking.module.v1.rs │ │ ├── cosmos.staking.module.v1.serde.rs │ │ ├── cosmos.staking.v1beta1.rs │ │ ├── cosmos.staking.v1beta1.serde.rs │ │ ├── cosmos.staking.v1beta1.tonic.rs │ │ ├── cosmos.store.internal.kv.v1beta1.rs │ │ ├── cosmos.store.internal.kv.v1beta1.serde.rs │ │ ├── cosmos.store.snapshots.v1.rs │ │ ├── cosmos.store.snapshots.v1.serde.rs │ │ ├── cosmos.store.streaming.abci.rs │ │ ├── cosmos.store.streaming.abci.serde.rs │ │ ├── cosmos.store.streaming.abci.tonic.rs │ │ ├── cosmos.store.v1beta1.rs │ │ ├── cosmos.store.v1beta1.serde.rs │ │ ├── cosmos.tx.config.v1.rs │ │ ├── cosmos.tx.config.v1.serde.rs │ │ ├── cosmos.tx.signing.v1beta1.rs │ │ ├── cosmos.tx.signing.v1beta1.serde.rs │ │ ├── cosmos.tx.v1beta1.rs │ │ ├── cosmos.tx.v1beta1.serde.rs │ │ ├── cosmos.tx.v1beta1.tonic.rs │ │ ├── cosmos.upgrade.module.v1.rs │ │ ├── cosmos.upgrade.module.v1.serde.rs │ │ ├── cosmos.upgrade.v1beta1.rs │ │ ├── cosmos.upgrade.v1beta1.serde.rs │ │ ├── cosmos.upgrade.v1beta1.tonic.rs │ │ ├── cosmos.vesting.module.v1.rs │ │ ├── cosmos.vesting.module.v1.serde.rs │ │ ├── cosmos.vesting.v1beta1.rs │ │ ├── cosmos.vesting.v1beta1.serde.rs │ │ ├── cosmos.vesting.v1beta1.tonic.rs │ │ ├── cosmos_proto.rs │ │ └── cosmos_proto.serde.rs │ └── wasmd │ │ ├── WASMD_COMMIT │ │ ├── amino.rs │ │ ├── cosmos.base.query.v1beta1.rs │ │ ├── cosmos.base.query.v1beta1.serde.rs │ │ ├── cosmos.base.v1beta1.rs │ │ ├── cosmos.base.v1beta1.serde.rs │ │ ├── cosmos.msg.v1.rs │ │ ├── cosmos.query.v1.rs │ │ ├── cosmos_proto.rs │ │ ├── cosmos_proto.serde.rs │ │ ├── cosmwasm.wasm.v1.rs │ │ ├── cosmwasm.wasm.v1.serde.rs │ │ └── cosmwasm.wasm.v1.tonic.rs │ └── traits.rs ├── cosmrs ├── .idea │ └── workspace.xml ├── CHANGELOG.md ├── Cargo.toml ├── README.md ├── src │ ├── abci.rs │ ├── abci │ │ ├── gas_info.rs │ │ └── msg_data.rs │ ├── auth.rs │ ├── auth │ │ ├── base_account.rs │ │ └── module_account.rs │ ├── bank.rs │ ├── bank │ │ ├── msg_multi_send.rs │ │ ├── msg_send.rs │ │ └── multi_send_io.rs │ ├── base.rs │ ├── base │ │ ├── account_id.rs │ │ ├── coin.rs │ │ ├── denom.rs │ │ ├── query.rs │ │ └── query │ │ │ └── pagination.rs │ ├── cosmwasm.rs │ ├── cosmwasm │ │ ├── absolute_tx_position.rs │ │ ├── access_config.rs │ │ ├── code_info_response.rs │ │ ├── contract_code_history_entry.rs │ │ ├── contract_info.rs │ │ ├── msg_clear_admin.rs │ │ ├── msg_execute_contract.rs │ │ ├── msg_initiate_contract.rs │ │ ├── msg_migrate_contract.rs │ │ ├── msg_store_code.rs │ │ ├── msg_update_admin.rs │ │ └── query_code_response.rs │ ├── crypto.rs │ ├── crypto │ │ ├── compact_bit_array.rs │ │ ├── legacy_amino.rs │ │ ├── public_key.rs │ │ ├── secp256k1.rs │ │ └── secp256k1 │ │ │ └── signing_key.rs │ ├── dev.rs │ ├── distribution.rs │ ├── distribution │ │ ├── msg_fund_community_pool.rs │ │ ├── msg_set_withdraw_address.rs │ │ ├── msg_withdraw_delegator_reward.rs │ │ └── msg_withdraw_validator_commission.rs │ ├── error.rs │ ├── feegrant.rs │ ├── feegrant │ │ ├── allowed_msg_allowance.rs │ │ ├── basic_allowance.rs │ │ ├── msg_grant_allowance.rs │ │ ├── msg_revoke_allowance.rs │ │ └── periodic_allowance.rs │ ├── lib.rs │ ├── slashing.rs │ ├── slashing │ │ ├── genesis_state.rs │ │ ├── missed_block.rs │ │ ├── msg_unjail.rs │ │ ├── params.rs │ │ ├── query_params_request.rs │ │ ├── query_params_response.rs │ │ ├── query_signing_info_request.rs │ │ ├── query_signing_info_response.rs │ │ ├── query_signing_infos_request.rs │ │ ├── query_signing_infos_response.rs │ │ ├── signing_info.rs │ │ ├── validator_missed_blocks.rs │ │ └── validator_signing_info.rs │ ├── staking.rs │ ├── staking │ │ ├── commission.rs │ │ ├── commission_rates.rs │ │ ├── description.rs │ │ ├── historical_info.rs │ │ ├── msg_begin_redelegate.rs │ │ ├── msg_delegate.rs │ │ ├── msg_undelegate.rs │ │ ├── query_historical_info_request.rs │ │ ├── query_historical_info_response.rs │ │ ├── query_validator_request.rs │ │ ├── query_validator_response.rs │ │ ├── query_validators_request.rs │ │ ├── query_validators_response.rs │ │ └── validator.rs │ ├── tx.rs │ ├── tx │ │ ├── auth_info.rs │ │ ├── body.rs │ │ ├── builder.rs │ │ ├── fee.rs │ │ ├── mode_info.rs │ │ ├── msg.rs │ │ ├── raw.rs │ │ ├── sign_doc.rs │ │ └── signer_info.rs │ ├── vesting.rs │ └── vesting │ │ ├── base_vesting_account.rs │ │ ├── continuous_vesting_account.rs │ │ ├── delayed_vesting_account.rs │ │ ├── period.rs │ │ ├── periodic_vesting_account.rs │ │ └── permanent_locked_account.rs └── tests │ └── integration.rs ├── proto-build ├── Cargo.toml ├── buf.sdk.gen.yaml ├── buf.wasmd.gen.yaml └── src │ └── main.rs └── rust-toolchain /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.images/cosmos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cosmos/cosmos-rust/a3e110b6ce6c0e74fd8ac3406ddc4d1813334d08/.images/cosmos.png -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "proto-build", 5 | "cosmos-sdk-proto", 6 | "cosmrs" 7 | ] 8 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/COSMOS_SDK_COMMIT: -------------------------------------------------------------------------------- 1 | v0.50.9 -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/amino.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.auth.module.v1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Module is the config object for the auth module. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct Module { 6 | /// bech32_prefix is the bech32 account prefix for the app. 7 | #[prost(string, tag = "1")] 8 | pub bech32_prefix: ::prost::alloc::string::String, 9 | /// module_account_permissions are module account permissions. 10 | #[prost(message, repeated, tag = "2")] 11 | pub module_account_permissions: ::prost::alloc::vec::Vec, 12 | /// authority defines the custom module authority. If not set, defaults to the governance module. 13 | #[prost(string, tag = "3")] 14 | pub authority: ::prost::alloc::string::String, 15 | } 16 | impl ::prost::Name for Module { 17 | const NAME: &'static str = "Module"; 18 | const PACKAGE: &'static str = "cosmos.auth.module.v1"; 19 | fn full_name() -> ::prost::alloc::string::String { 20 | ::prost::alloc::format!("cosmos.auth.module.v1.{}", Self::NAME) 21 | } 22 | } 23 | /// ModuleAccountPermission represents permissions for a module account. 24 | #[allow(clippy::derive_partial_eq_without_eq)] 25 | #[derive(Clone, PartialEq, ::prost::Message)] 26 | pub struct ModuleAccountPermission { 27 | /// account is the name of the module. 28 | #[prost(string, tag = "1")] 29 | pub account: ::prost::alloc::string::String, 30 | /// permissions are the permissions this module has. Currently recognized 31 | /// values are minter, burner and staking. 32 | #[prost(string, repeated, tag = "2")] 33 | pub permissions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, 34 | } 35 | impl ::prost::Name for ModuleAccountPermission { 36 | const NAME: &'static str = "ModuleAccountPermission"; 37 | const PACKAGE: &'static str = "cosmos.auth.module.v1"; 38 | fn full_name() -> ::prost::alloc::string::String { 39 | ::prost::alloc::format!("cosmos.auth.module.v1.{}", Self::NAME) 40 | } 41 | } 42 | include!("cosmos.auth.module.v1.serde.rs"); 43 | // @@protoc_insertion_point(module) 44 | -------------------------------------------------------------------------------- /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.authz.module.v1.serde.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | #[cfg(feature = "serde")] 3 | impl serde::Serialize for Module { 4 | #[allow(deprecated)] 5 | fn serialize(&self, serializer: S) -> core::result::Result 6 | where 7 | S: serde::Serializer, 8 | { 9 | use serde::ser::SerializeStruct; 10 | let len = 0; 11 | let struct_ser = serializer.serialize_struct("cosmos.authz.module.v1.Module", len)?; 12 | struct_ser.end() 13 | } 14 | } 15 | #[cfg(feature = "serde")] 16 | impl<'de> serde::Deserialize<'de> for Module { 17 | #[allow(deprecated)] 18 | fn deserialize(deserializer: D) -> core::result::Result 19 | where 20 | D: serde::Deserializer<'de>, 21 | { 22 | const FIELDS: &[&str] = &[]; 23 | 24 | #[allow(clippy::enum_variant_names)] 25 | enum GeneratedField {} 26 | #[cfg(feature = "serde")] 27 | impl<'de> serde::Deserialize<'de> for GeneratedField { 28 | fn deserialize(deserializer: D) -> core::result::Result 29 | where 30 | D: serde::Deserializer<'de>, 31 | { 32 | struct GeneratedVisitor; 33 | 34 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 35 | type Value = GeneratedField; 36 | 37 | fn expecting( 38 | &self, 39 | formatter: &mut core::fmt::Formatter<'_>, 40 | ) -> core::fmt::Result { 41 | write!(formatter, "expected one of: {:?}", &FIELDS) 42 | } 43 | 44 | #[allow(unused_variables)] 45 | fn visit_str(self, value: &str) -> core::result::Result 46 | where 47 | E: serde::de::Error, 48 | { 49 | Err(serde::de::Error::unknown_field(value, FIELDS)) 50 | } 51 | } 52 | deserializer.deserialize_identifier(GeneratedVisitor) 53 | } 54 | } 55 | struct GeneratedVisitor; 56 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 57 | type Value = Module; 58 | 59 | fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 60 | formatter.write_str("struct cosmos.authz.module.v1.Module") 61 | } 62 | 63 | fn visit_map(self, mut map_: V) -> core::result::Result 64 | where 65 | V: serde::de::MapAccess<'de>, 66 | { 67 | while map_.next_key::()?.is_some() { 68 | let _ = map_.next_value::()?; 69 | } 70 | Ok(Module {}) 71 | } 72 | } 73 | deserializer.deserialize_struct("cosmos.authz.module.v1.Module", FIELDS, GeneratedVisitor) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.base.reflection.v1beta1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// ListAllInterfacesRequest is the request type of the ListAllInterfaces RPC. 3 | #[allow(clippy::derive_partial_eq_without_eq)] 4 | #[derive(Clone, PartialEq, ::prost::Message)] 5 | pub struct ListAllInterfacesRequest {} 6 | impl ::prost::Name for ListAllInterfacesRequest { 7 | const NAME: &'static str = "ListAllInterfacesRequest"; 8 | const PACKAGE: &'static str = "cosmos.base.reflection.v1beta1"; 9 | fn full_name() -> ::prost::alloc::string::String { 10 | ::prost::alloc::format!("cosmos.base.reflection.v1beta1.{}", Self::NAME) 11 | } 12 | } 13 | /// ListAllInterfacesResponse is the response type of the ListAllInterfaces RPC. 14 | #[allow(clippy::derive_partial_eq_without_eq)] 15 | #[derive(Clone, PartialEq, ::prost::Message)] 16 | pub struct ListAllInterfacesResponse { 17 | /// interface_names is an array of all the registered interfaces. 18 | #[prost(string, repeated, tag = "1")] 19 | pub interface_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, 20 | } 21 | impl ::prost::Name for ListAllInterfacesResponse { 22 | const NAME: &'static str = "ListAllInterfacesResponse"; 23 | const PACKAGE: &'static str = "cosmos.base.reflection.v1beta1"; 24 | fn full_name() -> ::prost::alloc::string::String { 25 | ::prost::alloc::format!("cosmos.base.reflection.v1beta1.{}", Self::NAME) 26 | } 27 | } 28 | /// ListImplementationsRequest is the request type of the ListImplementations 29 | /// RPC. 30 | #[allow(clippy::derive_partial_eq_without_eq)] 31 | #[derive(Clone, PartialEq, ::prost::Message)] 32 | pub struct ListImplementationsRequest { 33 | /// interface_name defines the interface to query the implementations for. 34 | #[prost(string, tag = "1")] 35 | pub interface_name: ::prost::alloc::string::String, 36 | } 37 | impl ::prost::Name for ListImplementationsRequest { 38 | const NAME: &'static str = "ListImplementationsRequest"; 39 | const PACKAGE: &'static str = "cosmos.base.reflection.v1beta1"; 40 | fn full_name() -> ::prost::alloc::string::String { 41 | ::prost::alloc::format!("cosmos.base.reflection.v1beta1.{}", Self::NAME) 42 | } 43 | } 44 | /// ListImplementationsResponse is the response type of the ListImplementations 45 | /// RPC. 46 | #[allow(clippy::derive_partial_eq_without_eq)] 47 | #[derive(Clone, PartialEq, ::prost::Message)] 48 | pub struct ListImplementationsResponse { 49 | #[prost(string, repeated, tag = "1")] 50 | pub implementation_message_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, 51 | } 52 | impl ::prost::Name for ListImplementationsResponse { 53 | const NAME: &'static str = "ListImplementationsResponse"; 54 | const PACKAGE: &'static str = "cosmos.base.reflection.v1beta1"; 55 | fn full_name() -> ::prost::alloc::string::String { 56 | ::prost::alloc::format!("cosmos.base.reflection.v1beta1.{}", Self::NAME) 57 | } 58 | } 59 | include!("cosmos.base.reflection.v1beta1.serde.rs"); 60 | include!("cosmos.base.reflection.v1beta1.tonic.rs"); 61 | // @@protoc_insertion_point(module) 62 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.base.v1beta1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Coin defines a token with a denomination and an amount. 3 | /// 4 | /// NOTE: The amount field is an Int which implements the custom method 5 | /// signatures required by gogoproto. 6 | #[allow(clippy::derive_partial_eq_without_eq)] 7 | #[derive(Clone, PartialEq, ::prost::Message)] 8 | pub struct Coin { 9 | #[prost(string, tag = "1")] 10 | pub denom: ::prost::alloc::string::String, 11 | #[prost(string, tag = "2")] 12 | pub amount: ::prost::alloc::string::String, 13 | } 14 | impl ::prost::Name for Coin { 15 | const NAME: &'static str = "Coin"; 16 | const PACKAGE: &'static str = "cosmos.base.v1beta1"; 17 | fn full_name() -> ::prost::alloc::string::String { 18 | ::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME) 19 | } 20 | } 21 | /// DecCoin defines a token with a denomination and a decimal amount. 22 | /// 23 | /// NOTE: The amount field is an Dec which implements the custom method 24 | /// signatures required by gogoproto. 25 | #[allow(clippy::derive_partial_eq_without_eq)] 26 | #[derive(Clone, PartialEq, ::prost::Message)] 27 | pub struct DecCoin { 28 | #[prost(string, tag = "1")] 29 | pub denom: ::prost::alloc::string::String, 30 | #[prost(string, tag = "2")] 31 | pub amount: ::prost::alloc::string::String, 32 | } 33 | impl ::prost::Name for DecCoin { 34 | const NAME: &'static str = "DecCoin"; 35 | const PACKAGE: &'static str = "cosmos.base.v1beta1"; 36 | fn full_name() -> ::prost::alloc::string::String { 37 | ::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME) 38 | } 39 | } 40 | /// IntProto defines a Protobuf wrapper around an Int object. 41 | /// Deprecated: Prefer to use math.Int directly. It supports binary Marshal and Unmarshal. 42 | #[allow(clippy::derive_partial_eq_without_eq)] 43 | #[derive(Clone, PartialEq, ::prost::Message)] 44 | pub struct IntProto { 45 | #[prost(string, tag = "1")] 46 | pub int: ::prost::alloc::string::String, 47 | } 48 | impl ::prost::Name for IntProto { 49 | const NAME: &'static str = "IntProto"; 50 | const PACKAGE: &'static str = "cosmos.base.v1beta1"; 51 | fn full_name() -> ::prost::alloc::string::String { 52 | ::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME) 53 | } 54 | } 55 | /// DecProto defines a Protobuf wrapper around a Dec object. 56 | /// Deprecated: Prefer to use math.LegacyDec directly. It supports binary Marshal and Unmarshal. 57 | #[allow(clippy::derive_partial_eq_without_eq)] 58 | #[derive(Clone, PartialEq, ::prost::Message)] 59 | pub struct DecProto { 60 | #[prost(string, tag = "1")] 61 | pub dec: ::prost::alloc::string::String, 62 | } 63 | impl ::prost::Name for DecProto { 64 | const NAME: &'static str = "DecProto"; 65 | const PACKAGE: &'static str = "cosmos.base.v1beta1"; 66 | fn full_name() -> ::prost::alloc::string::String { 67 | ::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME) 68 | } 69 | } 70 | include!("cosmos.base.v1beta1.serde.rs"); 71 | // @@protoc_insertion_point(module) 72 | -------------------------------------------------------------------------------- /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.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 | -------------------------------------------------------------------------------- /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.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.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.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.evidence.module.v1.serde.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | #[cfg(feature = "serde")] 3 | impl serde::Serialize for Module { 4 | #[allow(deprecated)] 5 | fn serialize(&self, serializer: S) -> core::result::Result 6 | where 7 | S: serde::Serializer, 8 | { 9 | use serde::ser::SerializeStruct; 10 | let len = 0; 11 | let struct_ser = serializer.serialize_struct("cosmos.evidence.module.v1.Module", len)?; 12 | struct_ser.end() 13 | } 14 | } 15 | #[cfg(feature = "serde")] 16 | impl<'de> serde::Deserialize<'de> for Module { 17 | #[allow(deprecated)] 18 | fn deserialize(deserializer: D) -> core::result::Result 19 | where 20 | D: serde::Deserializer<'de>, 21 | { 22 | const FIELDS: &[&str] = &[]; 23 | 24 | #[allow(clippy::enum_variant_names)] 25 | enum GeneratedField {} 26 | #[cfg(feature = "serde")] 27 | impl<'de> serde::Deserialize<'de> for GeneratedField { 28 | fn deserialize(deserializer: D) -> core::result::Result 29 | where 30 | D: serde::Deserializer<'de>, 31 | { 32 | struct GeneratedVisitor; 33 | 34 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 35 | type Value = GeneratedField; 36 | 37 | fn expecting( 38 | &self, 39 | formatter: &mut core::fmt::Formatter<'_>, 40 | ) -> core::fmt::Result { 41 | write!(formatter, "expected one of: {:?}", &FIELDS) 42 | } 43 | 44 | #[allow(unused_variables)] 45 | fn visit_str(self, value: &str) -> core::result::Result 46 | where 47 | E: serde::de::Error, 48 | { 49 | Err(serde::de::Error::unknown_field(value, FIELDS)) 50 | } 51 | } 52 | deserializer.deserialize_identifier(GeneratedVisitor) 53 | } 54 | } 55 | struct GeneratedVisitor; 56 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 57 | type Value = Module; 58 | 59 | fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 60 | formatter.write_str("struct cosmos.evidence.module.v1.Module") 61 | } 62 | 63 | fn visit_map(self, mut map_: V) -> core::result::Result 64 | where 65 | V: serde::de::MapAccess<'de>, 66 | { 67 | while map_.next_key::()?.is_some() { 68 | let _ = map_.next_value::()?; 69 | } 70 | Ok(Module {}) 71 | } 72 | } 73 | deserializer.deserialize_struct( 74 | "cosmos.evidence.module.v1.Module", 75 | FIELDS, 76 | GeneratedVisitor, 77 | ) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.feegrant.module.v1.serde.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | #[cfg(feature = "serde")] 3 | impl serde::Serialize for Module { 4 | #[allow(deprecated)] 5 | fn serialize(&self, serializer: S) -> core::result::Result 6 | where 7 | S: serde::Serializer, 8 | { 9 | use serde::ser::SerializeStruct; 10 | let len = 0; 11 | let struct_ser = serializer.serialize_struct("cosmos.feegrant.module.v1.Module", len)?; 12 | struct_ser.end() 13 | } 14 | } 15 | #[cfg(feature = "serde")] 16 | impl<'de> serde::Deserialize<'de> for Module { 17 | #[allow(deprecated)] 18 | fn deserialize(deserializer: D) -> core::result::Result 19 | where 20 | D: serde::Deserializer<'de>, 21 | { 22 | const FIELDS: &[&str] = &[]; 23 | 24 | #[allow(clippy::enum_variant_names)] 25 | enum GeneratedField {} 26 | #[cfg(feature = "serde")] 27 | impl<'de> serde::Deserialize<'de> for GeneratedField { 28 | fn deserialize(deserializer: D) -> core::result::Result 29 | where 30 | D: serde::Deserializer<'de>, 31 | { 32 | struct GeneratedVisitor; 33 | 34 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 35 | type Value = GeneratedField; 36 | 37 | fn expecting( 38 | &self, 39 | formatter: &mut core::fmt::Formatter<'_>, 40 | ) -> core::fmt::Result { 41 | write!(formatter, "expected one of: {:?}", &FIELDS) 42 | } 43 | 44 | #[allow(unused_variables)] 45 | fn visit_str(self, value: &str) -> core::result::Result 46 | where 47 | E: serde::de::Error, 48 | { 49 | Err(serde::de::Error::unknown_field(value, FIELDS)) 50 | } 51 | } 52 | deserializer.deserialize_identifier(GeneratedVisitor) 53 | } 54 | } 55 | struct GeneratedVisitor; 56 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 57 | type Value = Module; 58 | 59 | fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 60 | formatter.write_str("struct cosmos.feegrant.module.v1.Module") 61 | } 62 | 63 | fn visit_map(self, mut map_: V) -> core::result::Result 64 | where 65 | V: serde::de::MapAccess<'de>, 66 | { 67 | while map_.next_key::()?.is_some() { 68 | let _ = map_.next_value::()?; 69 | } 70 | Ok(Module {}) 71 | } 72 | } 73 | deserializer.deserialize_struct( 74 | "cosmos.feegrant.module.v1.Module", 75 | FIELDS, 76 | GeneratedVisitor, 77 | ) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /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.genutil.module.v1.serde.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | #[cfg(feature = "serde")] 3 | impl serde::Serialize for Module { 4 | #[allow(deprecated)] 5 | fn serialize(&self, serializer: S) -> core::result::Result 6 | where 7 | S: serde::Serializer, 8 | { 9 | use serde::ser::SerializeStruct; 10 | let len = 0; 11 | let struct_ser = serializer.serialize_struct("cosmos.genutil.module.v1.Module", len)?; 12 | struct_ser.end() 13 | } 14 | } 15 | #[cfg(feature = "serde")] 16 | impl<'de> serde::Deserialize<'de> for Module { 17 | #[allow(deprecated)] 18 | fn deserialize(deserializer: D) -> core::result::Result 19 | where 20 | D: serde::Deserializer<'de>, 21 | { 22 | const FIELDS: &[&str] = &[]; 23 | 24 | #[allow(clippy::enum_variant_names)] 25 | enum GeneratedField {} 26 | #[cfg(feature = "serde")] 27 | impl<'de> serde::Deserialize<'de> for GeneratedField { 28 | fn deserialize(deserializer: D) -> core::result::Result 29 | where 30 | D: serde::Deserializer<'de>, 31 | { 32 | struct GeneratedVisitor; 33 | 34 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 35 | type Value = GeneratedField; 36 | 37 | fn expecting( 38 | &self, 39 | formatter: &mut core::fmt::Formatter<'_>, 40 | ) -> core::fmt::Result { 41 | write!(formatter, "expected one of: {:?}", &FIELDS) 42 | } 43 | 44 | #[allow(unused_variables)] 45 | fn visit_str(self, value: &str) -> core::result::Result 46 | where 47 | E: serde::de::Error, 48 | { 49 | Err(serde::de::Error::unknown_field(value, FIELDS)) 50 | } 51 | } 52 | deserializer.deserialize_identifier(GeneratedVisitor) 53 | } 54 | } 55 | struct GeneratedVisitor; 56 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 57 | type Value = Module; 58 | 59 | fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 60 | formatter.write_str("struct cosmos.genutil.module.v1.Module") 61 | } 62 | 63 | fn visit_map(self, mut map_: V) -> core::result::Result 64 | where 65 | V: serde::de::MapAccess<'de>, 66 | { 67 | while map_.next_key::()?.is_some() { 68 | let _ = map_.next_value::()?; 69 | } 70 | Ok(Module {}) 71 | } 72 | } 73 | deserializer.deserialize_struct("cosmos.genutil.module.v1.Module", FIELDS, GeneratedVisitor) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /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.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.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 | -------------------------------------------------------------------------------- /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.msg.textual.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/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.nft.module.v1.serde.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | #[cfg(feature = "serde")] 3 | impl serde::Serialize for Module { 4 | #[allow(deprecated)] 5 | fn serialize(&self, serializer: S) -> core::result::Result 6 | where 7 | S: serde::Serializer, 8 | { 9 | use serde::ser::SerializeStruct; 10 | let len = 0; 11 | let struct_ser = serializer.serialize_struct("cosmos.nft.module.v1.Module", len)?; 12 | struct_ser.end() 13 | } 14 | } 15 | #[cfg(feature = "serde")] 16 | impl<'de> serde::Deserialize<'de> for Module { 17 | #[allow(deprecated)] 18 | fn deserialize(deserializer: D) -> core::result::Result 19 | where 20 | D: serde::Deserializer<'de>, 21 | { 22 | const FIELDS: &[&str] = &[]; 23 | 24 | #[allow(clippy::enum_variant_names)] 25 | enum GeneratedField {} 26 | #[cfg(feature = "serde")] 27 | impl<'de> serde::Deserialize<'de> for GeneratedField { 28 | fn deserialize(deserializer: D) -> core::result::Result 29 | where 30 | D: serde::Deserializer<'de>, 31 | { 32 | struct GeneratedVisitor; 33 | 34 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 35 | type Value = GeneratedField; 36 | 37 | fn expecting( 38 | &self, 39 | formatter: &mut core::fmt::Formatter<'_>, 40 | ) -> core::fmt::Result { 41 | write!(formatter, "expected one of: {:?}", &FIELDS) 42 | } 43 | 44 | #[allow(unused_variables)] 45 | fn visit_str(self, value: &str) -> core::result::Result 46 | where 47 | E: serde::de::Error, 48 | { 49 | Err(serde::de::Error::unknown_field(value, FIELDS)) 50 | } 51 | } 52 | deserializer.deserialize_identifier(GeneratedVisitor) 53 | } 54 | } 55 | struct GeneratedVisitor; 56 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 57 | type Value = Module; 58 | 59 | fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 60 | formatter.write_str("struct cosmos.nft.module.v1.Module") 61 | } 62 | 63 | fn visit_map(self, mut map_: V) -> core::result::Result 64 | where 65 | V: serde::de::MapAccess<'de>, 66 | { 67 | while map_.next_key::()?.is_some() { 68 | let _ = map_.next_value::()?; 69 | } 70 | Ok(Module {}) 71 | } 72 | } 73 | deserializer.deserialize_struct("cosmos.nft.module.v1.Module", FIELDS, GeneratedVisitor) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /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.orm.module.v1alpha1.serde.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | #[cfg(feature = "serde")] 3 | impl serde::Serialize for Module { 4 | #[allow(deprecated)] 5 | fn serialize(&self, serializer: S) -> core::result::Result 6 | where 7 | S: serde::Serializer, 8 | { 9 | use serde::ser::SerializeStruct; 10 | let len = 0; 11 | let struct_ser = serializer.serialize_struct("cosmos.orm.module.v1alpha1.Module", len)?; 12 | struct_ser.end() 13 | } 14 | } 15 | #[cfg(feature = "serde")] 16 | impl<'de> serde::Deserialize<'de> for Module { 17 | #[allow(deprecated)] 18 | fn deserialize(deserializer: D) -> core::result::Result 19 | where 20 | D: serde::Deserializer<'de>, 21 | { 22 | const FIELDS: &[&str] = &[]; 23 | 24 | #[allow(clippy::enum_variant_names)] 25 | enum GeneratedField {} 26 | #[cfg(feature = "serde")] 27 | impl<'de> serde::Deserialize<'de> for GeneratedField { 28 | fn deserialize(deserializer: D) -> core::result::Result 29 | where 30 | D: serde::Deserializer<'de>, 31 | { 32 | struct GeneratedVisitor; 33 | 34 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 35 | type Value = GeneratedField; 36 | 37 | fn expecting( 38 | &self, 39 | formatter: &mut core::fmt::Formatter<'_>, 40 | ) -> core::fmt::Result { 41 | write!(formatter, "expected one of: {:?}", &FIELDS) 42 | } 43 | 44 | #[allow(unused_variables)] 45 | fn visit_str(self, value: &str) -> core::result::Result 46 | where 47 | E: serde::de::Error, 48 | { 49 | Err(serde::de::Error::unknown_field(value, FIELDS)) 50 | } 51 | } 52 | deserializer.deserialize_identifier(GeneratedVisitor) 53 | } 54 | } 55 | struct GeneratedVisitor; 56 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 57 | type Value = Module; 58 | 59 | fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 60 | formatter.write_str("struct cosmos.orm.module.v1alpha1.Module") 61 | } 62 | 63 | fn visit_map(self, mut map_: V) -> core::result::Result 64 | where 65 | V: serde::de::MapAccess<'de>, 66 | { 67 | while map_.next_key::()?.is_some() { 68 | let _ = map_.next_value::()?; 69 | } 70 | Ok(Module {}) 71 | } 72 | } 73 | deserializer.deserialize_struct( 74 | "cosmos.orm.module.v1alpha1.Module", 75 | FIELDS, 76 | GeneratedVisitor, 77 | ) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /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.params.module.v1.serde.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | #[cfg(feature = "serde")] 3 | impl serde::Serialize for Module { 4 | #[allow(deprecated)] 5 | fn serialize(&self, serializer: S) -> core::result::Result 6 | where 7 | S: serde::Serializer, 8 | { 9 | use serde::ser::SerializeStruct; 10 | let len = 0; 11 | let struct_ser = serializer.serialize_struct("cosmos.params.module.v1.Module", len)?; 12 | struct_ser.end() 13 | } 14 | } 15 | #[cfg(feature = "serde")] 16 | impl<'de> serde::Deserialize<'de> for Module { 17 | #[allow(deprecated)] 18 | fn deserialize(deserializer: D) -> core::result::Result 19 | where 20 | D: serde::Deserializer<'de>, 21 | { 22 | const FIELDS: &[&str] = &[]; 23 | 24 | #[allow(clippy::enum_variant_names)] 25 | enum GeneratedField {} 26 | #[cfg(feature = "serde")] 27 | impl<'de> serde::Deserialize<'de> for GeneratedField { 28 | fn deserialize(deserializer: D) -> core::result::Result 29 | where 30 | D: serde::Deserializer<'de>, 31 | { 32 | struct GeneratedVisitor; 33 | 34 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 35 | type Value = GeneratedField; 36 | 37 | fn expecting( 38 | &self, 39 | formatter: &mut core::fmt::Formatter<'_>, 40 | ) -> core::fmt::Result { 41 | write!(formatter, "expected one of: {:?}", &FIELDS) 42 | } 43 | 44 | #[allow(unused_variables)] 45 | fn visit_str(self, value: &str) -> core::result::Result 46 | where 47 | E: serde::de::Error, 48 | { 49 | Err(serde::de::Error::unknown_field(value, FIELDS)) 50 | } 51 | } 52 | deserializer.deserialize_identifier(GeneratedVisitor) 53 | } 54 | } 55 | struct GeneratedVisitor; 56 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 57 | type Value = Module; 58 | 59 | fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 60 | formatter.write_str("struct cosmos.params.module.v1.Module") 61 | } 62 | 63 | fn visit_map(self, mut map_: V) -> core::result::Result 64 | where 65 | V: serde::de::MapAccess<'de>, 66 | { 67 | while map_.next_key::()?.is_some() { 68 | let _ = map_.next_value::()?; 69 | } 70 | Ok(Module {}) 71 | } 72 | } 73 | deserializer.deserialize_struct("cosmos.params.module.v1.Module", FIELDS, GeneratedVisitor) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /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.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 | -------------------------------------------------------------------------------- /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.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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.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.vesting.module.v1.serde.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | #[cfg(feature = "serde")] 3 | impl serde::Serialize for Module { 4 | #[allow(deprecated)] 5 | fn serialize(&self, serializer: S) -> core::result::Result 6 | where 7 | S: serde::Serializer, 8 | { 9 | use serde::ser::SerializeStruct; 10 | let len = 0; 11 | let struct_ser = serializer.serialize_struct("cosmos.vesting.module.v1.Module", len)?; 12 | struct_ser.end() 13 | } 14 | } 15 | #[cfg(feature = "serde")] 16 | impl<'de> serde::Deserialize<'de> for Module { 17 | #[allow(deprecated)] 18 | fn deserialize(deserializer: D) -> core::result::Result 19 | where 20 | D: serde::Deserializer<'de>, 21 | { 22 | const FIELDS: &[&str] = &[]; 23 | 24 | #[allow(clippy::enum_variant_names)] 25 | enum GeneratedField {} 26 | #[cfg(feature = "serde")] 27 | impl<'de> serde::Deserialize<'de> for GeneratedField { 28 | fn deserialize(deserializer: D) -> core::result::Result 29 | where 30 | D: serde::Deserializer<'de>, 31 | { 32 | struct GeneratedVisitor; 33 | 34 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 35 | type Value = GeneratedField; 36 | 37 | fn expecting( 38 | &self, 39 | formatter: &mut core::fmt::Formatter<'_>, 40 | ) -> core::fmt::Result { 41 | write!(formatter, "expected one of: {:?}", &FIELDS) 42 | } 43 | 44 | #[allow(unused_variables)] 45 | fn visit_str(self, value: &str) -> core::result::Result 46 | where 47 | E: serde::de::Error, 48 | { 49 | Err(serde::de::Error::unknown_field(value, FIELDS)) 50 | } 51 | } 52 | deserializer.deserialize_identifier(GeneratedVisitor) 53 | } 54 | } 55 | struct GeneratedVisitor; 56 | impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { 57 | type Value = Module; 58 | 59 | fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 60 | formatter.write_str("struct cosmos.vesting.module.v1.Module") 61 | } 62 | 63 | fn visit_map(self, mut map_: V) -> core::result::Result 64 | where 65 | V: serde::de::MapAccess<'de>, 66 | { 67 | while map_.next_key::()?.is_some() { 68 | let _ = map_.next_value::()?; 69 | } 70 | Ok(Module {}) 71 | } 72 | } 73 | deserializer.deserialize_struct("cosmos.vesting.module.v1.Module", FIELDS, GeneratedVisitor) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/wasmd/WASMD_COMMIT: -------------------------------------------------------------------------------- 1 | v0.52.0 -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/wasmd/amino.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | // @@protoc_insertion_point(module) 3 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/wasmd/cosmos.base.v1beta1.rs: -------------------------------------------------------------------------------- 1 | // @generated 2 | /// Coin defines a token with a denomination and an amount. 3 | /// 4 | /// NOTE: The amount field is an Int which implements the custom method 5 | /// signatures required by gogoproto. 6 | #[allow(clippy::derive_partial_eq_without_eq)] 7 | #[derive(Clone, PartialEq, ::prost::Message)] 8 | pub struct Coin { 9 | #[prost(string, tag = "1")] 10 | pub denom: ::prost::alloc::string::String, 11 | #[prost(string, tag = "2")] 12 | pub amount: ::prost::alloc::string::String, 13 | } 14 | impl ::prost::Name for Coin { 15 | const NAME: &'static str = "Coin"; 16 | const PACKAGE: &'static str = "cosmos.base.v1beta1"; 17 | fn full_name() -> ::prost::alloc::string::String { 18 | ::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME) 19 | } 20 | } 21 | /// DecCoin defines a token with a denomination and a decimal amount. 22 | /// 23 | /// NOTE: The amount field is an Dec which implements the custom method 24 | /// signatures required by gogoproto. 25 | #[allow(clippy::derive_partial_eq_without_eq)] 26 | #[derive(Clone, PartialEq, ::prost::Message)] 27 | pub struct DecCoin { 28 | #[prost(string, tag = "1")] 29 | pub denom: ::prost::alloc::string::String, 30 | #[prost(string, tag = "2")] 31 | pub amount: ::prost::alloc::string::String, 32 | } 33 | impl ::prost::Name for DecCoin { 34 | const NAME: &'static str = "DecCoin"; 35 | const PACKAGE: &'static str = "cosmos.base.v1beta1"; 36 | fn full_name() -> ::prost::alloc::string::String { 37 | ::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME) 38 | } 39 | } 40 | /// IntProto defines a Protobuf wrapper around an Int object. 41 | #[allow(clippy::derive_partial_eq_without_eq)] 42 | #[derive(Clone, PartialEq, ::prost::Message)] 43 | pub struct IntProto { 44 | #[prost(string, tag = "1")] 45 | pub int: ::prost::alloc::string::String, 46 | } 47 | impl ::prost::Name for IntProto { 48 | const NAME: &'static str = "IntProto"; 49 | const PACKAGE: &'static str = "cosmos.base.v1beta1"; 50 | fn full_name() -> ::prost::alloc::string::String { 51 | ::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME) 52 | } 53 | } 54 | /// DecProto defines a Protobuf wrapper around a Dec object. 55 | #[allow(clippy::derive_partial_eq_without_eq)] 56 | #[derive(Clone, PartialEq, ::prost::Message)] 57 | pub struct DecProto { 58 | #[prost(string, tag = "1")] 59 | pub dec: ::prost::alloc::string::String, 60 | } 61 | impl ::prost::Name for DecProto { 62 | const NAME: &'static str = "DecProto"; 63 | const PACKAGE: &'static str = "cosmos.base.v1beta1"; 64 | fn full_name() -> ::prost::alloc::string::String { 65 | ::prost::alloc::format!("cosmos.base.v1beta1.{}", Self::NAME) 66 | } 67 | } 68 | include!("cosmos.base.v1beta1.serde.rs"); 69 | // @@protoc_insertion_point(module) 70 | -------------------------------------------------------------------------------- /cosmos-sdk-proto/src/prost/wasmd/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/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/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/README.md: -------------------------------------------------------------------------------- 1 | # CosmRS: Cosmos Wallet and SDK for Rust 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 | Framework for building [Cosmos] blockchain applications in Rust, modeled off 10 | of the [Cosmos SDK for Golang]. 11 | 12 | ## About 13 | 14 | This library is presently designed to serve as a *client* for interacting 15 | with the Golang implementation of the Cosmos SDK, providing things like wallet 16 | functionality such as transaction signing, and a builder/parser for Cosmos SDK 17 | formatted transaction messages. 18 | 19 | It does not implement server-side functionality (yet), such as hooks 20 | and message passing. 21 | 22 | ## Features 23 | 24 | - [CosmWasm]: messages used by smart contracts written using CosmWasm 25 | - [Staking]: support for staking with validators 26 | - [Transactions]: build, sign, and/or parse Cosmos SDK transactions 27 | 28 | [Cosmos]: https://cosmos.network/ 29 | [Cosmos SDK for Golang]: https://github.com/cosmos/cosmos-sdk 30 | 31 | ## Minimum Supported Rust Version 32 | 33 | This crate is supported on Rust **1.75** or newer. 34 | 35 | [//]: # "badges" 36 | [crate-image]: https://img.shields.io/crates/v/cosmrs?logo=rust 37 | [crate-link]: https://crates.io/crates/cosmrs 38 | [docs-image]: https://docs.rs/cosmrs/badge.svg 39 | [docs-link]: https://docs.rs/cosmrs/ 40 | [build-image]: https://github.com/cosmos/cosmos-rust/workflows/cosmrs/badge.svg 41 | [build-link]: https://github.com/cosmos/cosmos-rust/actions/workflows/cosmrs.yml 42 | [license-image]: https://img.shields.io/badge/license-Apache2.0-blue.svg 43 | [license-link]: https://github.com/cosmos/cosmos-rust/blob/master/LICENSE 44 | [rustc-image]: https://img.shields.io/badge/rustc-1.75+-blue.svg 45 | 46 | [//]: # "links" 47 | [Cosmos]: https://cosmos.network/ 48 | [Cosmos SDK for Golang]: https://github.com/cosmos/cosmos-sdk 49 | [CosmWasm]: https://cosmwasm.com/ 50 | [Staking]: https://docs.cosmos.network/master/modules/staking/ 51 | [Transactions]: https://docs.cosmos.network/v0.50/learn/advanced/transactions 52 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/bank/msg_multi_send.rs: -------------------------------------------------------------------------------- 1 | use super::MultiSendIo; 2 | use crate::{proto, tx::Msg, ErrorReport, Result}; 3 | 4 | /// MsgMultiSend represents an arbitrary multi-in, multi-out send message. 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct MsgMultiSend { 7 | /// Sender account/amount pairs. 8 | pub inputs: Vec, 9 | 10 | /// Recipient account/amount pairs. 11 | pub outputs: Vec, 12 | } 13 | 14 | impl Msg for MsgMultiSend { 15 | type Proto = proto::cosmos::bank::v1beta1::MsgMultiSend; 16 | } 17 | 18 | impl TryFrom for MsgMultiSend { 19 | type Error = ErrorReport; 20 | 21 | fn try_from(proto: proto::cosmos::bank::v1beta1::MsgMultiSend) -> Result { 22 | MsgMultiSend::try_from(&proto) 23 | } 24 | } 25 | 26 | impl TryFrom<&proto::cosmos::bank::v1beta1::MsgMultiSend> for MsgMultiSend { 27 | type Error = ErrorReport; 28 | 29 | fn try_from(proto: &proto::cosmos::bank::v1beta1::MsgMultiSend) -> Result { 30 | Ok(MsgMultiSend { 31 | inputs: proto 32 | .inputs 33 | .iter() 34 | .map(TryFrom::try_from) 35 | .collect::>()?, 36 | outputs: proto 37 | .outputs 38 | .iter() 39 | .map(TryFrom::try_from) 40 | .collect::>()?, 41 | }) 42 | } 43 | } 44 | 45 | impl From for proto::cosmos::bank::v1beta1::MsgMultiSend { 46 | fn from(coin: MsgMultiSend) -> proto::cosmos::bank::v1beta1::MsgMultiSend { 47 | proto::cosmos::bank::v1beta1::MsgMultiSend::from(&coin) 48 | } 49 | } 50 | 51 | impl From<&MsgMultiSend> for proto::cosmos::bank::v1beta1::MsgMultiSend { 52 | fn from(msg: &MsgMultiSend) -> proto::cosmos::bank::v1beta1::MsgMultiSend { 53 | proto::cosmos::bank::v1beta1::MsgMultiSend { 54 | inputs: msg.inputs.iter().map(Into::into).collect(), 55 | outputs: msg.outputs.iter().map(Into::into).collect(), 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /cosmrs/src/bank/msg_send.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, Coin, ErrorReport, Result}; 2 | 3 | /// MsgSend represents a message to send coins from one account to another. 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MsgSend { 6 | /// Sender's address. 7 | pub from_address: AccountId, 8 | 9 | /// Recipient's address. 10 | pub to_address: AccountId, 11 | 12 | /// Amount to send 13 | pub amount: Vec, 14 | } 15 | 16 | impl Msg for MsgSend { 17 | type Proto = proto::cosmos::bank::v1beta1::MsgSend; 18 | } 19 | 20 | impl TryFrom for MsgSend { 21 | type Error = ErrorReport; 22 | 23 | fn try_from(proto: proto::cosmos::bank::v1beta1::MsgSend) -> Result { 24 | MsgSend::try_from(&proto) 25 | } 26 | } 27 | 28 | impl TryFrom<&proto::cosmos::bank::v1beta1::MsgSend> for MsgSend { 29 | type Error = ErrorReport; 30 | 31 | fn try_from(proto: &proto::cosmos::bank::v1beta1::MsgSend) -> Result { 32 | Ok(MsgSend { 33 | from_address: proto.from_address.parse()?, 34 | to_address: proto.to_address.parse()?, 35 | amount: proto 36 | .amount 37 | .iter() 38 | .map(TryFrom::try_from) 39 | .collect::>()?, 40 | }) 41 | } 42 | } 43 | 44 | impl From for proto::cosmos::bank::v1beta1::MsgSend { 45 | fn from(coin: MsgSend) -> proto::cosmos::bank::v1beta1::MsgSend { 46 | proto::cosmos::bank::v1beta1::MsgSend::from(&coin) 47 | } 48 | } 49 | 50 | impl From<&MsgSend> for proto::cosmos::bank::v1beta1::MsgSend { 51 | fn from(msg: &MsgSend) -> proto::cosmos::bank::v1beta1::MsgSend { 52 | proto::cosmos::bank::v1beta1::MsgSend { 53 | from_address: msg.from_address.to_string(), 54 | to_address: msg.to_address.to_string(), 55 | amount: msg.amount.iter().map(Into::into).collect(), 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /cosmrs/src/bank/multi_send_io.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, AccountId, Coin, ErrorReport, Result}; 2 | 3 | /// Represents a MultiSend Input or Output 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MultiSendIo { 6 | /// The address that `coins` will be sent to/from 7 | pub address: AccountId, 8 | 9 | /// The coins to send to/from `address` 10 | pub coins: Vec, 11 | } 12 | 13 | impl TryFrom for MultiSendIo { 14 | type Error = ErrorReport; 15 | 16 | fn try_from(proto: proto::cosmos::bank::v1beta1::Input) -> Result { 17 | MultiSendIo::try_from(&proto) 18 | } 19 | } 20 | 21 | impl TryFrom<&proto::cosmos::bank::v1beta1::Input> for MultiSendIo { 22 | type Error = ErrorReport; 23 | 24 | fn try_from(proto: &proto::cosmos::bank::v1beta1::Input) -> Result { 25 | Ok(MultiSendIo { 26 | address: proto.address.parse()?, 27 | coins: proto 28 | .coins 29 | .iter() 30 | .map(TryFrom::try_from) 31 | .collect::>()?, 32 | }) 33 | } 34 | } 35 | 36 | impl TryFrom for MultiSendIo { 37 | type Error = ErrorReport; 38 | 39 | fn try_from(proto: proto::cosmos::bank::v1beta1::Output) -> Result { 40 | MultiSendIo::try_from(&proto) 41 | } 42 | } 43 | 44 | impl TryFrom<&proto::cosmos::bank::v1beta1::Output> for MultiSendIo { 45 | type Error = ErrorReport; 46 | 47 | fn try_from(proto: &proto::cosmos::bank::v1beta1::Output) -> Result { 48 | Ok(MultiSendIo { 49 | address: proto.address.parse()?, 50 | coins: proto 51 | .coins 52 | .iter() 53 | .map(TryFrom::try_from) 54 | .collect::>()?, 55 | }) 56 | } 57 | } 58 | 59 | impl From for proto::cosmos::bank::v1beta1::Output { 60 | fn from(output: MultiSendIo) -> proto::cosmos::bank::v1beta1::Output { 61 | proto::cosmos::bank::v1beta1::Output::from(&output) 62 | } 63 | } 64 | 65 | impl From<&MultiSendIo> for proto::cosmos::bank::v1beta1::Output { 66 | fn from(output: &MultiSendIo) -> proto::cosmos::bank::v1beta1::Output { 67 | proto::cosmos::bank::v1beta1::Output { 68 | address: output.address.to_string(), 69 | coins: output.coins.iter().map(Into::into).collect(), 70 | } 71 | } 72 | } 73 | 74 | impl From for proto::cosmos::bank::v1beta1::Input { 75 | fn from(input: MultiSendIo) -> proto::cosmos::bank::v1beta1::Input { 76 | proto::cosmos::bank::v1beta1::Input::from(&input) 77 | } 78 | } 79 | 80 | impl From<&MultiSendIo> for proto::cosmos::bank::v1beta1::Input { 81 | fn from(input: &MultiSendIo) -> proto::cosmos::bank::v1beta1::Input { 82 | proto::cosmos::bank::v1beta1::Input { 83 | address: input.address.to_string(), 84 | coins: input.coins.iter().map(Into::into).collect(), 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cosmrs/src/base/coin.rs: -------------------------------------------------------------------------------- 1 | use super::{Amount, Denom}; 2 | use crate::{proto, ErrorReport, Result}; 3 | use serde::{Deserialize, Serialize}; 4 | use std::fmt; 5 | 6 | /// Coin defines a token with a denomination and an amount. 7 | #[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] 8 | pub struct Coin { 9 | /// Denomination 10 | pub denom: Denom, 11 | 12 | /// Amount 13 | pub amount: Amount, 14 | } 15 | 16 | impl Coin { 17 | /// Constructor 18 | pub fn new(amount: Amount, denom: &str) -> Result { 19 | Ok(Coin { 20 | amount, 21 | denom: denom.parse()?, 22 | }) 23 | } 24 | } 25 | 26 | impl TryFrom for Coin { 27 | type Error = ErrorReport; 28 | 29 | fn try_from(proto: proto::cosmos::base::v1beta1::Coin) -> Result { 30 | Coin::try_from(&proto) 31 | } 32 | } 33 | 34 | impl TryFrom<&proto::cosmos::base::v1beta1::Coin> for Coin { 35 | type Error = ErrorReport; 36 | 37 | fn try_from(proto: &proto::cosmos::base::v1beta1::Coin) -> Result { 38 | // Support an empty denom when the amount is `0`. See cosmos/cosmos-rust#477 39 | if proto.denom.is_empty() && proto.amount == "0" { 40 | Ok(Coin::default()) 41 | } else { 42 | Ok(Coin { 43 | denom: proto.denom.parse()?, 44 | amount: proto.amount.parse()?, 45 | }) 46 | } 47 | } 48 | } 49 | 50 | impl From for proto::cosmos::base::v1beta1::Coin { 51 | fn from(coin: Coin) -> proto::cosmos::base::v1beta1::Coin { 52 | proto::cosmos::base::v1beta1::Coin::from(&coin) 53 | } 54 | } 55 | 56 | impl From<&Coin> for proto::cosmos::base::v1beta1::Coin { 57 | fn from(coin: &Coin) -> proto::cosmos::base::v1beta1::Coin { 58 | proto::cosmos::base::v1beta1::Coin { 59 | denom: coin.denom.to_string(), 60 | amount: coin.amount.to_string(), 61 | } 62 | } 63 | } 64 | 65 | impl fmt::Display for Coin { 66 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 67 | // See: https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/types/coin.go#L643-L645 68 | write!(f, "{}{}", self.amount, self.denom) 69 | } 70 | } 71 | 72 | #[cfg(test)] 73 | mod tests { 74 | use super::Coin; 75 | use crate::proto; 76 | 77 | #[test] 78 | fn new() { 79 | Coin::new(1000, "uatom").unwrap(); 80 | } 81 | 82 | #[test] 83 | fn zero_value_coin_with_empty_denom() { 84 | let zero_proto = proto::cosmos::base::v1beta1::Coin::from(Coin::default()); 85 | assert_eq!(&zero_proto.denom, ""); 86 | assert_eq!(&zero_proto.amount, "0"); 87 | 88 | let zero_coin = Coin::try_from(zero_proto).unwrap(); 89 | assert_eq!(zero_coin, Coin::default()) 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /cosmrs/src/base/denom.rs: -------------------------------------------------------------------------------- 1 | use crate::{Error, ErrorReport, Result}; 2 | use serde::{de, de::Error as _, ser, Deserialize, Serialize}; 3 | use std::{fmt, str::FromStr}; 4 | 5 | /// Denomination. 6 | #[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)] 7 | pub struct Denom(String); 8 | 9 | impl Denom { 10 | /// Minimum length of a [`Denom`]. 11 | pub const MIN_LENGTH: usize = 3; 12 | 13 | /// Maximum length of a [`Denom`]. 14 | pub const MAX_LENGTH: usize = 128; 15 | } 16 | 17 | impl AsRef for Denom { 18 | fn as_ref(&self) -> &str { 19 | self.0.as_ref() 20 | } 21 | } 22 | 23 | impl fmt::Display for Denom { 24 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 25 | f.write_str(self.as_ref()) 26 | } 27 | } 28 | 29 | impl FromStr for Denom { 30 | type Err = ErrorReport; 31 | 32 | /// NOTE: implements the same checks as the `MatchDenom` function from the upstream Cosmos SDK. 33 | /// 34 | fn from_str(s: &str) -> Result { 35 | if s.len() < Self::MIN_LENGTH || s.len() > Self::MAX_LENGTH { 36 | return Err(Error::Denom { name: s.to_owned() }.into()); 37 | } 38 | 39 | if !s.chars().all(is_valid_denom_char) { 40 | return Err(Error::Denom { name: s.to_owned() }.into()); 41 | } 42 | 43 | Ok(Denom(s.to_owned())) 44 | } 45 | } 46 | 47 | impl<'de> Deserialize<'de> for Denom { 48 | fn deserialize>(deserializer: D) -> Result { 49 | String::deserialize(deserializer)? 50 | .parse() 51 | .map_err(D::Error::custom) 52 | } 53 | } 54 | 55 | impl Serialize for Denom { 56 | fn serialize(&self, serializer: S) -> Result { 57 | self.0.serialize(serializer) 58 | } 59 | } 60 | 61 | /// Check if a given character is allowed in a `Denom` name. 62 | /// 63 | /// NOTE: implements the same checks as the `isValidRune` function from the upstream Cosmos SDK. 64 | /// 65 | #[inline] 66 | fn is_valid_denom_char(c: char) -> bool { 67 | matches!(c, 'A'..='Z' | 'a'..='z' | '0'..='9' | '/' | ':' | '.' | '_' | '-') 68 | } 69 | 70 | #[cfg(test)] 71 | mod tests { 72 | use super::Denom; 73 | 74 | #[test] 75 | fn parse() { 76 | assert!( 77 | "ibc/9F53D255F5320A4BE124FF20C29D46406E126CE8A09B00CA8D3CFF7905119728" 78 | .parse::() 79 | .is_ok() 80 | ); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /cosmrs/src/base/query.rs: -------------------------------------------------------------------------------- 1 | mod pagination; 2 | 3 | pub use pagination::{PageRequest, PageResponse}; 4 | -------------------------------------------------------------------------------- /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/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/cosmwasm/access_config.rs: -------------------------------------------------------------------------------- 1 | use super::AccessType; 2 | use crate::{proto, AccountId, Error, ErrorReport, Result}; 3 | 4 | /// AccessConfig access control type. 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct AccessConfig { 7 | /// Access type granted. 8 | pub permission: AccessType, 9 | 10 | /// Account addresses with the associated permission. 11 | pub addresses: Vec, 12 | } 13 | 14 | impl TryFrom for AccessConfig { 15 | type Error = ErrorReport; 16 | 17 | fn try_from(proto: proto::cosmwasm::wasm::v1::AccessConfig) -> Result { 18 | AccessConfig::try_from(&proto) 19 | } 20 | } 21 | 22 | impl TryFrom<&proto::cosmwasm::wasm::v1::AccessConfig> for AccessConfig { 23 | type Error = ErrorReport; 24 | 25 | fn try_from(proto: &proto::cosmwasm::wasm::v1::AccessConfig) -> Result { 26 | let permission = 27 | AccessType::try_from(proto.permission).map_err(|_| Error::InvalidEnumValue { 28 | name: "permission", 29 | found_value: proto.permission, 30 | })?; 31 | 32 | let mut addresses = Vec::with_capacity(proto.addresses.len()); 33 | 34 | for address in &proto.addresses { 35 | addresses.push(address.parse()?); 36 | } 37 | 38 | Ok(AccessConfig { 39 | permission, 40 | addresses, 41 | }) 42 | } 43 | } 44 | 45 | impl From for proto::cosmwasm::wasm::v1::AccessConfig { 46 | fn from(config: AccessConfig) -> proto::cosmwasm::wasm::v1::AccessConfig { 47 | proto::cosmwasm::wasm::v1::AccessConfig::from(&config) 48 | } 49 | } 50 | 51 | impl From<&AccessConfig> for proto::cosmwasm::wasm::v1::AccessConfig { 52 | fn from(config: &AccessConfig) -> proto::cosmwasm::wasm::v1::AccessConfig { 53 | proto::cosmwasm::wasm::v1::AccessConfig { 54 | permission: config.permission as i32, 55 | addresses: config.addresses.iter().map(ToString::to_string).collect(), 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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/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/cosmwasm/contract_info.rs: -------------------------------------------------------------------------------- 1 | use super::{AbsoluteTxPosition, ContractCodeId}; 2 | use crate::{ 3 | proto::{self, traits::ParseOptional}, 4 | AccountId, ErrorReport, Result, 5 | }; 6 | 7 | /// ContractInfo stores a WASM contract instance 8 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 9 | pub struct ContractInfo { 10 | /// Reference to the stored Wasm code. 11 | pub code_id: ContractCodeId, 12 | 13 | /// Creator address who initially instantiated the contract. 14 | pub creator: AccountId, 15 | 16 | /// Admin is an optional address that can execute migrations. 17 | pub admin: Option, 18 | 19 | /// Label is optional metadata to be stored with a contract instance. 20 | pub label: String, 21 | 22 | /// Created Tx position when the contract was instantiated. 23 | // Note that this data should kept internal and not be exposed via query results. 24 | // Just use for sorting. 25 | pub created: Option, 26 | 27 | /// The IBC port ID assigned to this contract by wasmd. 28 | /// This is set for all IBC contracts (). 29 | pub ibc_port_id: String, 30 | } 31 | 32 | impl TryFrom for ContractInfo { 33 | type Error = ErrorReport; 34 | 35 | fn try_from(proto: proto::cosmwasm::wasm::v1::ContractInfo) -> Result { 36 | Ok(ContractInfo { 37 | code_id: proto.code_id, 38 | creator: proto.creator.parse()?, 39 | admin: proto.admin.parse_optional()?, 40 | label: proto.label, 41 | created: proto.created.map(TryFrom::try_from).transpose()?, 42 | ibc_port_id: proto.ibc_port_id, 43 | }) 44 | } 45 | } 46 | 47 | impl From for proto::cosmwasm::wasm::v1::ContractInfo { 48 | fn from(info: ContractInfo) -> Self { 49 | proto::cosmwasm::wasm::v1::ContractInfo { 50 | code_id: info.code_id, 51 | creator: info.creator.to_string(), 52 | admin: info 53 | .admin 54 | .map(|admin| admin.to_string()) 55 | .unwrap_or_default(), 56 | label: info.label, 57 | created: info.created.map(Into::into), 58 | ibc_port_id: info.ibc_port_id, 59 | extension: None, 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/msg_clear_admin.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, ErrorReport, Result}; 2 | 3 | /// MsgClearAdmin removes any admin stored for a smart contract 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MsgClearAdmin { 6 | /// Sender is the that actor that signed the messages 7 | pub sender: AccountId, 8 | 9 | /// Contract is the address of the smart contract 10 | pub contract: AccountId, 11 | } 12 | 13 | impl Msg for MsgClearAdmin { 14 | type Proto = proto::cosmwasm::wasm::v1::MsgClearAdmin; 15 | } 16 | 17 | impl TryFrom for MsgClearAdmin { 18 | type Error = ErrorReport; 19 | 20 | fn try_from(proto: proto::cosmwasm::wasm::v1::MsgClearAdmin) -> Result { 21 | MsgClearAdmin::try_from(&proto) 22 | } 23 | } 24 | 25 | impl TryFrom<&proto::cosmwasm::wasm::v1::MsgClearAdmin> for MsgClearAdmin { 26 | type Error = ErrorReport; 27 | 28 | fn try_from(proto: &proto::cosmwasm::wasm::v1::MsgClearAdmin) -> Result { 29 | Ok(MsgClearAdmin { 30 | sender: proto.sender.parse()?, 31 | contract: proto.contract.parse()?, 32 | }) 33 | } 34 | } 35 | 36 | impl From for proto::cosmwasm::wasm::v1::MsgClearAdmin { 37 | fn from(msg: MsgClearAdmin) -> proto::cosmwasm::wasm::v1::MsgClearAdmin { 38 | proto::cosmwasm::wasm::v1::MsgClearAdmin::from(&msg) 39 | } 40 | } 41 | 42 | impl From<&MsgClearAdmin> for proto::cosmwasm::wasm::v1::MsgClearAdmin { 43 | fn from(msg: &MsgClearAdmin) -> proto::cosmwasm::wasm::v1::MsgClearAdmin { 44 | proto::cosmwasm::wasm::v1::MsgClearAdmin { 45 | sender: msg.sender.to_string(), 46 | contract: msg.contract.to_string(), 47 | } 48 | } 49 | } 50 | 51 | /// MsgClearAdminResponse returns empty data 52 | #[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)] 53 | pub struct MsgClearAdminResponse {} 54 | 55 | impl Msg for MsgClearAdminResponse { 56 | type Proto = proto::cosmwasm::wasm::v1::MsgClearAdminResponse; 57 | } 58 | 59 | impl TryFrom for MsgClearAdminResponse { 60 | type Error = ErrorReport; 61 | 62 | fn try_from( 63 | _proto: proto::cosmwasm::wasm::v1::MsgClearAdminResponse, 64 | ) -> Result { 65 | Ok(MsgClearAdminResponse {}) 66 | } 67 | } 68 | 69 | impl From for proto::cosmwasm::wasm::v1::MsgClearAdminResponse { 70 | fn from(_msg: MsgClearAdminResponse) -> proto::cosmwasm::wasm::v1::MsgClearAdminResponse { 71 | proto::cosmwasm::wasm::v1::MsgClearAdminResponse {} 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/msg_execute_contract.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, Coin, ErrorReport, Result}; 2 | use std::convert::TryFrom; 3 | 4 | /// MsgExecuteContract submits the given message data to a smart contract 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct MsgExecuteContract { 7 | /// Sender is the that actor that signed the messages 8 | pub sender: AccountId, 9 | 10 | /// Contract is the address of the smart contract 11 | pub contract: AccountId, 12 | 13 | /// Msg json encoded message to be passed to the contract 14 | pub msg: Vec, 15 | 16 | /// Funds coins that are transferred to the contract on execution 17 | pub funds: Vec, 18 | } 19 | 20 | impl Msg for MsgExecuteContract { 21 | type Proto = proto::cosmwasm::wasm::v1::MsgExecuteContract; 22 | } 23 | 24 | impl TryFrom for MsgExecuteContract { 25 | type Error = ErrorReport; 26 | 27 | fn try_from( 28 | proto: proto::cosmwasm::wasm::v1::MsgExecuteContract, 29 | ) -> Result { 30 | Ok(MsgExecuteContract { 31 | sender: proto.sender.parse()?, 32 | contract: proto.contract.parse()?, 33 | msg: proto.msg.into_iter().map(Into::into).collect(), 34 | funds: proto 35 | .funds 36 | .iter() 37 | .map(TryFrom::try_from) 38 | .collect::>()?, 39 | }) 40 | } 41 | } 42 | 43 | impl From for proto::cosmwasm::wasm::v1::MsgExecuteContract { 44 | fn from(msg: MsgExecuteContract) -> proto::cosmwasm::wasm::v1::MsgExecuteContract { 45 | proto::cosmwasm::wasm::v1::MsgExecuteContract { 46 | sender: msg.sender.to_string(), 47 | contract: msg.contract.to_string(), 48 | msg: msg.msg, 49 | funds: msg.funds.iter().map(Into::into).collect(), 50 | } 51 | } 52 | } 53 | 54 | /// MsgExecuteContractResponse returns execution result data. 55 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 56 | pub struct MsgExecuteContractResponse { 57 | /// Data contains base64-encoded bytes to returned from the contract 58 | pub data: Vec, 59 | } 60 | 61 | impl Msg for MsgExecuteContractResponse { 62 | type Proto = proto::cosmwasm::wasm::v1::MsgExecuteContractResponse; 63 | } 64 | 65 | impl TryFrom for MsgExecuteContractResponse { 66 | type Error = ErrorReport; 67 | 68 | fn try_from( 69 | proto: proto::cosmwasm::wasm::v1::MsgExecuteContractResponse, 70 | ) -> Result { 71 | Ok(MsgExecuteContractResponse { data: proto.data }) 72 | } 73 | } 74 | 75 | impl From for proto::cosmwasm::wasm::v1::MsgExecuteContractResponse { 76 | fn from( 77 | msg: MsgExecuteContractResponse, 78 | ) -> proto::cosmwasm::wasm::v1::MsgExecuteContractResponse { 79 | proto::cosmwasm::wasm::v1::MsgExecuteContractResponse { data: msg.data } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/msg_migrate_contract.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, ErrorReport, Result}; 2 | use std::convert::TryFrom; 3 | 4 | /// MsgMigrateContract runs a code upgrade/ downgrade for a smart contract 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct MsgMigrateContract { 7 | /// Sender is the that actor that signed the messages 8 | pub sender: AccountId, 9 | 10 | /// Contract is the address of the smart contract 11 | pub contract: AccountId, 12 | 13 | /// CodeID references the new WASM code 14 | pub code_id: u64, 15 | 16 | /// Msg json encoded message to be passed to the contract on migration 17 | pub msg: Vec, 18 | } 19 | 20 | impl Msg for MsgMigrateContract { 21 | type Proto = proto::cosmwasm::wasm::v1::MsgMigrateContract; 22 | } 23 | 24 | impl TryFrom for MsgMigrateContract { 25 | type Error = ErrorReport; 26 | 27 | fn try_from( 28 | proto: proto::cosmwasm::wasm::v1::MsgMigrateContract, 29 | ) -> Result { 30 | Ok(MsgMigrateContract { 31 | sender: proto.sender.parse()?, 32 | contract: proto.contract.parse()?, 33 | code_id: proto.code_id, 34 | msg: proto.msg, 35 | }) 36 | } 37 | } 38 | 39 | impl From for proto::cosmwasm::wasm::v1::MsgMigrateContract { 40 | fn from(msg: MsgMigrateContract) -> proto::cosmwasm::wasm::v1::MsgMigrateContract { 41 | proto::cosmwasm::wasm::v1::MsgMigrateContract { 42 | sender: msg.sender.to_string(), 43 | contract: msg.contract.to_string(), 44 | code_id: msg.code_id, 45 | msg: msg.msg, 46 | } 47 | } 48 | } 49 | 50 | /// MsgMigrateContractResponse returns contract migration result data. 51 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 52 | pub struct MsgMigrateContractResponse { 53 | /// Data contains same raw bytes returned as data from the wasm contract. 54 | /// (May be empty) 55 | pub data: Vec, 56 | } 57 | 58 | impl Msg for MsgMigrateContractResponse { 59 | type Proto = proto::cosmwasm::wasm::v1::MsgMigrateContractResponse; 60 | } 61 | 62 | impl TryFrom for MsgMigrateContractResponse { 63 | type Error = ErrorReport; 64 | 65 | fn try_from( 66 | proto: proto::cosmwasm::wasm::v1::MsgMigrateContractResponse, 67 | ) -> Result { 68 | Ok(MsgMigrateContractResponse { data: proto.data }) 69 | } 70 | } 71 | 72 | impl From for proto::cosmwasm::wasm::v1::MsgMigrateContractResponse { 73 | fn from( 74 | msg: MsgMigrateContractResponse, 75 | ) -> proto::cosmwasm::wasm::v1::MsgMigrateContractResponse { 76 | proto::cosmwasm::wasm::v1::MsgMigrateContractResponse { data: msg.data } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/msg_store_code.rs: -------------------------------------------------------------------------------- 1 | use super::AccessConfig; 2 | use crate::{proto, tx::Msg, AccountId, Error, ErrorReport, Result}; 3 | use tendermint::Hash; 4 | 5 | /// MsgStoreCode submit Wasm code to the system 6 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 7 | pub struct MsgStoreCode { 8 | /// Sender is the that actor that signed the messages 9 | pub sender: AccountId, 10 | 11 | /// WASMByteCode can be raw or gzip compressed 12 | pub wasm_byte_code: Vec, 13 | 14 | /// InstantiatePermission access control to apply on contract creation, 15 | /// optional 16 | pub instantiate_permission: Option, 17 | } 18 | 19 | impl Msg for MsgStoreCode { 20 | type Proto = proto::cosmwasm::wasm::v1::MsgStoreCode; 21 | } 22 | 23 | impl TryFrom for MsgStoreCode { 24 | type Error = ErrorReport; 25 | 26 | fn try_from(proto: proto::cosmwasm::wasm::v1::MsgStoreCode) -> Result { 27 | Ok(MsgStoreCode { 28 | sender: proto.sender.parse()?, 29 | wasm_byte_code: proto.wasm_byte_code, 30 | instantiate_permission: proto 31 | .instantiate_permission 32 | .map(TryFrom::try_from) 33 | .transpose()?, 34 | }) 35 | } 36 | } 37 | 38 | impl From for proto::cosmwasm::wasm::v1::MsgStoreCode { 39 | fn from(msg: MsgStoreCode) -> proto::cosmwasm::wasm::v1::MsgStoreCode { 40 | proto::cosmwasm::wasm::v1::MsgStoreCode { 41 | sender: msg.sender.to_string(), 42 | wasm_byte_code: msg.wasm_byte_code, 43 | instantiate_permission: msg.instantiate_permission.map(Into::into), 44 | } 45 | } 46 | } 47 | 48 | /// MsgStoreCodeResponse returns store result data. 49 | #[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)] 50 | pub struct MsgStoreCodeResponse { 51 | /// CodeID is the reference to the stored WASM code 52 | pub code_id: u64, 53 | 54 | /// Checksum is the sha256 hash of the stored code 55 | pub checksum: Hash, 56 | } 57 | 58 | impl Msg for MsgStoreCodeResponse { 59 | type Proto = proto::cosmwasm::wasm::v1::MsgStoreCodeResponse; 60 | } 61 | 62 | impl TryFrom for MsgStoreCodeResponse { 63 | type Error = ErrorReport; 64 | 65 | fn try_from( 66 | proto: proto::cosmwasm::wasm::v1::MsgStoreCodeResponse, 67 | ) -> Result { 68 | Ok(MsgStoreCodeResponse { 69 | code_id: proto.code_id, 70 | checksum: Hash::Sha256(proto.checksum.try_into().map_err(|_| Error::Crypto)?), 71 | }) 72 | } 73 | } 74 | 75 | impl From for proto::cosmwasm::wasm::v1::MsgStoreCodeResponse { 76 | fn from(msg: MsgStoreCodeResponse) -> proto::cosmwasm::wasm::v1::MsgStoreCodeResponse { 77 | proto::cosmwasm::wasm::v1::MsgStoreCodeResponse { 78 | code_id: msg.code_id, 79 | checksum: msg.checksum.as_bytes().into(), 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /cosmrs/src/cosmwasm/msg_update_admin.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, ErrorReport, Result}; 2 | 3 | /// MsgUpdateAdmin sets a new admin for a smart contract 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MsgUpdateAdmin { 6 | /// Sender is the that actor that signed the messages 7 | pub sender: AccountId, 8 | 9 | /// NewAdmin address to be set 10 | pub new_admin: AccountId, 11 | 12 | /// Contract is the address of the smart contract 13 | pub contract: AccountId, 14 | } 15 | 16 | impl Msg for MsgUpdateAdmin { 17 | type Proto = proto::cosmwasm::wasm::v1::MsgUpdateAdmin; 18 | } 19 | 20 | impl TryFrom for MsgUpdateAdmin { 21 | type Error = ErrorReport; 22 | 23 | fn try_from(proto: proto::cosmwasm::wasm::v1::MsgUpdateAdmin) -> Result { 24 | MsgUpdateAdmin::try_from(&proto) 25 | } 26 | } 27 | 28 | impl TryFrom<&proto::cosmwasm::wasm::v1::MsgUpdateAdmin> for MsgUpdateAdmin { 29 | type Error = ErrorReport; 30 | 31 | fn try_from(proto: &proto::cosmwasm::wasm::v1::MsgUpdateAdmin) -> Result { 32 | Ok(MsgUpdateAdmin { 33 | sender: proto.sender.parse()?, 34 | new_admin: proto.new_admin.parse()?, 35 | contract: proto.contract.parse()?, 36 | }) 37 | } 38 | } 39 | 40 | impl From for proto::cosmwasm::wasm::v1::MsgUpdateAdmin { 41 | fn from(msg: MsgUpdateAdmin) -> proto::cosmwasm::wasm::v1::MsgUpdateAdmin { 42 | proto::cosmwasm::wasm::v1::MsgUpdateAdmin::from(&msg) 43 | } 44 | } 45 | 46 | impl From<&MsgUpdateAdmin> for proto::cosmwasm::wasm::v1::MsgUpdateAdmin { 47 | fn from(msg: &MsgUpdateAdmin) -> proto::cosmwasm::wasm::v1::MsgUpdateAdmin { 48 | proto::cosmwasm::wasm::v1::MsgUpdateAdmin { 49 | sender: msg.sender.to_string(), 50 | new_admin: msg.new_admin.to_string(), 51 | contract: msg.contract.to_string(), 52 | } 53 | } 54 | } 55 | 56 | /// MsgUpdateAdminResponse returns empty data 57 | #[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord)] 58 | pub struct MsgUpdateAdminResponse {} 59 | 60 | impl Msg for MsgUpdateAdminResponse { 61 | type Proto = proto::cosmwasm::wasm::v1::MsgUpdateAdminResponse; 62 | } 63 | 64 | impl TryFrom for MsgUpdateAdminResponse { 65 | type Error = ErrorReport; 66 | 67 | fn try_from( 68 | _proto: proto::cosmwasm::wasm::v1::MsgUpdateAdminResponse, 69 | ) -> Result { 70 | Ok(MsgUpdateAdminResponse {}) 71 | } 72 | } 73 | 74 | impl From for proto::cosmwasm::wasm::v1::MsgUpdateAdminResponse { 75 | fn from(_msg: MsgUpdateAdminResponse) -> proto::cosmwasm::wasm::v1::MsgUpdateAdminResponse { 76 | proto::cosmwasm::wasm::v1::MsgUpdateAdminResponse {} 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cosmrs/src/distribution/msg_fund_community_pool.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, Coin, ErrorReport, Result}; 2 | 3 | /// MsgFundCommunityPool represents a message to send coins from depositor to the community pool. 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MsgFundCommunityPool { 6 | /// Depositor's address. 7 | pub depositor: AccountId, 8 | 9 | /// Amount to deposit. 10 | pub amount: Vec, 11 | } 12 | 13 | impl Msg for MsgFundCommunityPool { 14 | type Proto = proto::cosmos::distribution::v1beta1::MsgFundCommunityPool; 15 | } 16 | 17 | impl TryFrom for MsgFundCommunityPool { 18 | type Error = ErrorReport; 19 | 20 | fn try_from( 21 | proto: proto::cosmos::distribution::v1beta1::MsgFundCommunityPool, 22 | ) -> Result { 23 | MsgFundCommunityPool::try_from(&proto) 24 | } 25 | } 26 | 27 | impl TryFrom<&proto::cosmos::distribution::v1beta1::MsgFundCommunityPool> for MsgFundCommunityPool { 28 | type Error = ErrorReport; 29 | 30 | fn try_from( 31 | proto: &proto::cosmos::distribution::v1beta1::MsgFundCommunityPool, 32 | ) -> Result { 33 | let mut amounts = Vec::with_capacity(proto.amount.len()); 34 | for amount in &proto.amount { 35 | amounts.push(Coin { 36 | denom: amount.denom.parse()?, 37 | amount: amount.amount.parse()?, 38 | }) 39 | } 40 | Ok(MsgFundCommunityPool { 41 | depositor: proto.depositor.parse()?, 42 | amount: amounts, 43 | }) 44 | } 45 | } 46 | 47 | impl From for proto::cosmos::distribution::v1beta1::MsgFundCommunityPool { 48 | fn from( 49 | coin: MsgFundCommunityPool, 50 | ) -> proto::cosmos::distribution::v1beta1::MsgFundCommunityPool { 51 | proto::cosmos::distribution::v1beta1::MsgFundCommunityPool::from(&coin) 52 | } 53 | } 54 | 55 | impl From<&MsgFundCommunityPool> for proto::cosmos::distribution::v1beta1::MsgFundCommunityPool { 56 | fn from( 57 | msg: &MsgFundCommunityPool, 58 | ) -> proto::cosmos::distribution::v1beta1::MsgFundCommunityPool { 59 | let mut amounts = Vec::with_capacity(msg.amount.len()); 60 | for amount in &msg.amount { 61 | amounts.push(proto::cosmos::base::v1beta1::Coin { 62 | denom: amount.denom.to_string(), 63 | amount: amount.amount.to_string(), 64 | }) 65 | } 66 | proto::cosmos::distribution::v1beta1::MsgFundCommunityPool { 67 | depositor: "".to_string(), 68 | amount: amounts, 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /cosmrs/src/distribution/msg_set_withdraw_address.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, ErrorReport, Result}; 2 | 3 | /// MsgSetWithdrawAddress represents a message to set a withdraw address for staking rewards. 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MsgSetWithdrawAddress { 6 | /// Delegator's address. 7 | pub delegator_address: AccountId, 8 | 9 | /// withdraw address. 10 | pub withdraw_address: AccountId, 11 | } 12 | 13 | impl Msg for MsgSetWithdrawAddress { 14 | type Proto = proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress; 15 | } 16 | 17 | impl TryFrom 18 | for MsgSetWithdrawAddress 19 | { 20 | type Error = ErrorReport; 21 | 22 | fn try_from( 23 | proto: proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress, 24 | ) -> Result { 25 | MsgSetWithdrawAddress::try_from(&proto) 26 | } 27 | } 28 | 29 | impl TryFrom<&proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress> 30 | for MsgSetWithdrawAddress 31 | { 32 | type Error = ErrorReport; 33 | 34 | fn try_from( 35 | proto: &proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress, 36 | ) -> Result { 37 | Ok(MsgSetWithdrawAddress { 38 | delegator_address: proto.delegator_address.parse()?, 39 | withdraw_address: proto.withdraw_address.parse()?, 40 | }) 41 | } 42 | } 43 | 44 | impl From for proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress { 45 | fn from( 46 | coin: MsgSetWithdrawAddress, 47 | ) -> proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress { 48 | proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress::from(&coin) 49 | } 50 | } 51 | 52 | impl From<&MsgSetWithdrawAddress> for proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress { 53 | fn from( 54 | msg: &MsgSetWithdrawAddress, 55 | ) -> proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress { 56 | proto::cosmos::distribution::v1beta1::MsgSetWithdrawAddress { 57 | delegator_address: msg.delegator_address.to_string(), 58 | withdraw_address: msg.withdraw_address.to_string(), 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /cosmrs/src/distribution/msg_withdraw_delegator_reward.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, ErrorReport, Result}; 2 | 3 | /// MsgWithdrawDelegatorReward represents a message to withdraw a delegator's reward from a validator. 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MsgWithdrawDelegatorReward { 6 | /// Delegator's address. 7 | pub delegator_address: AccountId, 8 | 9 | /// Validator's address. 10 | pub validator_address: AccountId, 11 | } 12 | 13 | impl Msg for MsgWithdrawDelegatorReward { 14 | type Proto = proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward; 15 | } 16 | 17 | impl TryFrom 18 | for MsgWithdrawDelegatorReward 19 | { 20 | type Error = ErrorReport; 21 | 22 | fn try_from( 23 | proto: proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward, 24 | ) -> Result { 25 | MsgWithdrawDelegatorReward::try_from(&proto) 26 | } 27 | } 28 | 29 | impl TryFrom<&proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward> 30 | for MsgWithdrawDelegatorReward 31 | { 32 | type Error = ErrorReport; 33 | 34 | fn try_from( 35 | proto: &proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward, 36 | ) -> Result { 37 | Ok(MsgWithdrawDelegatorReward { 38 | delegator_address: proto.delegator_address.parse()?, 39 | validator_address: proto.validator_address.parse()?, 40 | }) 41 | } 42 | } 43 | 44 | impl From 45 | for proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward 46 | { 47 | fn from( 48 | coin: MsgWithdrawDelegatorReward, 49 | ) -> proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward { 50 | proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward::from(&coin) 51 | } 52 | } 53 | 54 | impl From<&MsgWithdrawDelegatorReward> 55 | for proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward 56 | { 57 | fn from( 58 | msg: &MsgWithdrawDelegatorReward, 59 | ) -> proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward { 60 | proto::cosmos::distribution::v1beta1::MsgWithdrawDelegatorReward { 61 | delegator_address: msg.delegator_address.to_string(), 62 | validator_address: msg.validator_address.to_string(), 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /cosmrs/src/distribution/msg_withdraw_validator_commission.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, ErrorReport, Result}; 2 | 3 | /// WithdrawValidatorCommission represents a message to withdraw a validator's staking commission. 4 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 5 | pub struct MsgWithdrawValidatorCommission { 6 | /// Validator's address. 7 | pub validator_address: AccountId, 8 | } 9 | 10 | impl Msg for MsgWithdrawValidatorCommission { 11 | type Proto = proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission; 12 | } 13 | 14 | impl TryFrom 15 | for MsgWithdrawValidatorCommission 16 | { 17 | type Error = ErrorReport; 18 | 19 | fn try_from( 20 | proto: proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission, 21 | ) -> Result { 22 | MsgWithdrawValidatorCommission::try_from(&proto) 23 | } 24 | } 25 | 26 | impl TryFrom<&proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission> 27 | for MsgWithdrawValidatorCommission 28 | { 29 | type Error = ErrorReport; 30 | 31 | fn try_from( 32 | proto: &proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission, 33 | ) -> Result { 34 | Ok(MsgWithdrawValidatorCommission { 35 | validator_address: proto.validator_address.parse()?, 36 | }) 37 | } 38 | } 39 | 40 | impl From 41 | for proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission 42 | { 43 | fn from( 44 | coin: MsgWithdrawValidatorCommission, 45 | ) -> proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission { 46 | proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission::from(&coin) 47 | } 48 | } 49 | 50 | impl From<&MsgWithdrawValidatorCommission> 51 | for proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission 52 | { 53 | fn from( 54 | msg: &MsgWithdrawValidatorCommission, 55 | ) -> proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission { 56 | proto::cosmos::distribution::v1beta1::MsgWithdrawValidatorCommission { 57 | validator_address: msg.validator_address.to_string(), 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /cosmrs/src/feegrant/allowed_msg_allowance.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, Any, ErrorReport, Result}; 2 | 3 | /// AllowedMsgAllowance creates allowance only for specified message types. 4 | #[derive(Clone, Debug, PartialEq)] 5 | pub struct AllowedMsgAllowance { 6 | /// allowance can be any of basic and filtered fee allowance. 7 | pub allowance: Option, 8 | 9 | /// allowed_messages are the messages for which the grantee has the access. 10 | pub allowed_messages: Vec, 11 | } 12 | 13 | impl Msg for AllowedMsgAllowance { 14 | type Proto = proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance; 15 | } 16 | 17 | impl TryFrom for AllowedMsgAllowance { 18 | type Error = ErrorReport; 19 | 20 | fn try_from( 21 | proto: proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance, 22 | ) -> Result { 23 | AllowedMsgAllowance::try_from(&proto) 24 | } 25 | } 26 | 27 | impl TryFrom<&proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance> for AllowedMsgAllowance { 28 | type Error = ErrorReport; 29 | 30 | fn try_from( 31 | proto: &proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance, 32 | ) -> Result { 33 | Ok(AllowedMsgAllowance { 34 | allowance: proto.allowance.clone(), 35 | allowed_messages: proto 36 | .allowed_messages 37 | .iter() 38 | .map(TryFrom::try_from) 39 | .collect::>()?, 40 | }) 41 | } 42 | } 43 | 44 | impl From for proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance { 45 | fn from( 46 | allowance: AllowedMsgAllowance, 47 | ) -> proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance { 48 | proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance::from(&allowance) 49 | } 50 | } 51 | 52 | impl From<&AllowedMsgAllowance> for proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance { 53 | fn from( 54 | allowance: &AllowedMsgAllowance, 55 | ) -> proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance { 56 | proto::cosmos::feegrant::v1beta1::AllowedMsgAllowance { 57 | allowance: allowance.allowance.clone().map(Into::into), 58 | allowed_messages: allowance.allowed_messages.iter().map(Into::into).collect(), 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /cosmrs/src/feegrant/basic_allowance.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, Coin, ErrorReport, Result}; 2 | use std::time::SystemTime; 3 | 4 | /// BasicAllowance implements Allowance with a one-time grant of tokens 5 | /// that optionally expires. The grantee can use up to SpendLimit to cover fees. 6 | #[derive(Clone, Debug, Eq, PartialEq)] 7 | pub struct BasicAllowance { 8 | /// spend_limit specifies the maximum amount of tokens that can be spent 9 | /// by this allowance and will be updated as tokens are spent. If it is 10 | /// empty, there is no spend limit and any amount of coins can be spent. 11 | pub spend_limit: Vec, 12 | 13 | /// expiration specifies an optional time when this allowance expires 14 | pub expiration: Option, 15 | } 16 | 17 | impl Msg for BasicAllowance { 18 | type Proto = proto::cosmos::feegrant::v1beta1::BasicAllowance; 19 | } 20 | 21 | impl TryFrom for BasicAllowance { 22 | type Error = ErrorReport; 23 | 24 | fn try_from(proto: proto::cosmos::feegrant::v1beta1::BasicAllowance) -> Result { 25 | BasicAllowance::try_from(&proto) 26 | } 27 | } 28 | 29 | impl TryFrom<&proto::cosmos::feegrant::v1beta1::BasicAllowance> for BasicAllowance { 30 | type Error = ErrorReport; 31 | 32 | fn try_from( 33 | proto: &proto::cosmos::feegrant::v1beta1::BasicAllowance, 34 | ) -> Result { 35 | Ok(BasicAllowance { 36 | spend_limit: proto 37 | .spend_limit 38 | .iter() 39 | .map(TryFrom::try_from) 40 | .collect::>()?, 41 | expiration: proto.expiration.map(TryFrom::try_from).transpose()?, 42 | }) 43 | } 44 | } 45 | 46 | impl From for proto::cosmos::feegrant::v1beta1::BasicAllowance { 47 | fn from(allowance: BasicAllowance) -> proto::cosmos::feegrant::v1beta1::BasicAllowance { 48 | proto::cosmos::feegrant::v1beta1::BasicAllowance::from(&allowance) 49 | } 50 | } 51 | 52 | impl From<&BasicAllowance> for proto::cosmos::feegrant::v1beta1::BasicAllowance { 53 | fn from(allowance: &BasicAllowance) -> proto::cosmos::feegrant::v1beta1::BasicAllowance { 54 | proto::cosmos::feegrant::v1beta1::BasicAllowance { 55 | spend_limit: allowance.spend_limit.iter().map(Into::into).collect(), 56 | expiration: allowance.expiration.map(Into::into), 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /cosmrs/src/feegrant/msg_grant_allowance.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, Any, ErrorReport, Result}; 2 | 3 | /// MsgGrantAllowance adds permission for Grantee to spend up to Allowance 4 | /// of fees from the account of Granter. 5 | #[derive(Clone, Debug, PartialEq)] 6 | pub struct MsgGrantAllowance { 7 | /// granter is the address of the user granting an allowance of their funds. 8 | pub granter: AccountId, 9 | 10 | /// grantee is the address of the user being granted an allowance of another user's funds. 11 | pub grantee: AccountId, 12 | 13 | /// allowance can be any of basic and filtered fee allowance. 14 | pub allowance: Option, 15 | } 16 | 17 | impl Msg for MsgGrantAllowance { 18 | type Proto = proto::cosmos::feegrant::v1beta1::MsgGrantAllowance; 19 | } 20 | 21 | impl TryFrom for MsgGrantAllowance { 22 | type Error = ErrorReport; 23 | 24 | fn try_from( 25 | proto: proto::cosmos::feegrant::v1beta1::MsgGrantAllowance, 26 | ) -> Result { 27 | MsgGrantAllowance::try_from(&proto) 28 | } 29 | } 30 | 31 | impl TryFrom<&proto::cosmos::feegrant::v1beta1::MsgGrantAllowance> for MsgGrantAllowance { 32 | type Error = ErrorReport; 33 | 34 | fn try_from( 35 | proto: &proto::cosmos::feegrant::v1beta1::MsgGrantAllowance, 36 | ) -> Result { 37 | Ok(MsgGrantAllowance { 38 | granter: proto.granter.parse()?, 39 | grantee: proto.grantee.parse()?, 40 | allowance: proto.allowance.clone(), 41 | }) 42 | } 43 | } 44 | 45 | impl From for proto::cosmos::feegrant::v1beta1::MsgGrantAllowance { 46 | fn from(coin: MsgGrantAllowance) -> proto::cosmos::feegrant::v1beta1::MsgGrantAllowance { 47 | proto::cosmos::feegrant::v1beta1::MsgGrantAllowance::from(&coin) 48 | } 49 | } 50 | 51 | impl From<&MsgGrantAllowance> for proto::cosmos::feegrant::v1beta1::MsgGrantAllowance { 52 | fn from(msg: &MsgGrantAllowance) -> proto::cosmos::feegrant::v1beta1::MsgGrantAllowance { 53 | proto::cosmos::feegrant::v1beta1::MsgGrantAllowance { 54 | granter: msg.granter.to_string(), 55 | grantee: msg.grantee.to_string(), 56 | allowance: msg.allowance.clone(), 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /cosmrs/src/feegrant/msg_revoke_allowance.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, tx::Msg, AccountId, ErrorReport, Result}; 2 | 3 | /// MsgRevokeAllowance removes any existing Allowance from Granter to Grantee. 4 | #[derive(Clone, Debug, Eq, PartialEq)] 5 | pub struct MsgRevokeAllowance { 6 | /// granter is the address of the user granting an allowance of their funds. 7 | pub granter: AccountId, 8 | 9 | /// grantee is the address of the user being granted an allowance of another user's funds. 10 | pub grantee: AccountId, 11 | } 12 | 13 | impl Msg for MsgRevokeAllowance { 14 | type Proto = proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance; 15 | } 16 | 17 | impl TryFrom for MsgRevokeAllowance { 18 | type Error = ErrorReport; 19 | 20 | fn try_from( 21 | proto: proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance, 22 | ) -> Result { 23 | MsgRevokeAllowance::try_from(&proto) 24 | } 25 | } 26 | 27 | impl TryFrom<&proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance> for MsgRevokeAllowance { 28 | type Error = ErrorReport; 29 | 30 | fn try_from( 31 | proto: &proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance, 32 | ) -> Result { 33 | Ok(MsgRevokeAllowance { 34 | granter: proto.granter.parse()?, 35 | grantee: proto.grantee.parse()?, 36 | }) 37 | } 38 | } 39 | 40 | impl From for proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance { 41 | fn from(allowance: MsgRevokeAllowance) -> proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance { 42 | proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance::from(&allowance) 43 | } 44 | } 45 | 46 | impl From<&MsgRevokeAllowance> for proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance { 47 | fn from(msg: &MsgRevokeAllowance) -> proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance { 48 | proto::cosmos::feegrant::v1beta1::MsgRevokeAllowance { 49 | granter: msg.granter.to_string(), 50 | grantee: msg.grantee.to_string(), 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/slashing/genesis_state.rs: -------------------------------------------------------------------------------- 1 | use crate::slashing::{Params, SigningInfo, ValidatorMissedBlocks}; 2 | use crate::{proto, ErrorReport, Result}; 3 | 4 | /// GenesisState defines the slashing module's genesis state. 5 | #[derive(Clone, Debug, Eq, PartialEq)] 6 | pub struct GenesisState { 7 | /// params defines all the paramaters of related to deposit. 8 | pub params: Option, 9 | 10 | /// signing_infos represents a map between validator addresses and their 11 | /// signing infos. 12 | pub signing_infos: Vec, 13 | 14 | /// missed_blocks represents a map between validator addresses and their 15 | /// missed blocks. 16 | pub missed_blocks: Vec, 17 | } 18 | 19 | impl TryFrom for GenesisState { 20 | type Error = ErrorReport; 21 | 22 | fn try_from(proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::GenesisState) -> Result { 23 | Ok(GenesisState { 24 | params: proto.params.map(TryInto::try_into).transpose()?, 25 | signing_infos: proto 26 | .signing_infos 27 | .into_iter() 28 | .map(TryInto::try_into) 29 | .collect::>()?, 30 | missed_blocks: proto.missed_blocks.into_iter().map(Into::into).collect(), 31 | }) 32 | } 33 | } 34 | 35 | impl From for cosmos_sdk_proto::cosmos::slashing::v1beta1::GenesisState { 36 | fn from(genesis_state: GenesisState) -> Self { 37 | cosmos_sdk_proto::cosmos::slashing::v1beta1::GenesisState { 38 | params: genesis_state.params.map(Into::into), 39 | signing_infos: genesis_state 40 | .signing_infos 41 | .into_iter() 42 | .map(Into::into) 43 | .collect(), 44 | missed_blocks: genesis_state 45 | .missed_blocks 46 | .into_iter() 47 | .map(Into::into) 48 | .collect(), 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/slashing/params.rs: -------------------------------------------------------------------------------- 1 | use crate::{proto, ErrorReport, Result}; 2 | use std::time::Duration; 3 | 4 | /// Params represents the parameters used for by the slashing module. 5 | #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] 6 | pub struct Params { 7 | /// Signed blocks window 8 | pub signed_blocks_window: i64, 9 | 10 | /// Minimum signed per window 11 | pub min_signed_per_window: Vec, 12 | 13 | /// Downtime jail duration 14 | pub downtime_jail_duration: Option, 15 | 16 | /// Slash fraction for double sign 17 | pub slash_fraction_double_sign: Vec, 18 | 19 | /// Slash fraction for downtime 20 | pub slash_fraction_downtime: Vec, 21 | } 22 | 23 | impl TryFrom for Params { 24 | type Error = ErrorReport; 25 | 26 | fn try_from(proto: cosmos_sdk_proto::cosmos::slashing::v1beta1::Params) -> Result { 27 | Ok(Params { 28 | signed_blocks_window: proto.signed_blocks_window, 29 | min_signed_per_window: proto.min_signed_per_window, 30 | downtime_jail_duration: proto 31 | .downtime_jail_duration 32 | .map(TryFrom::try_from) 33 | .transpose()?, 34 | slash_fraction_double_sign: proto.slash_fraction_double_sign, 35 | slash_fraction_downtime: proto.slash_fraction_downtime, 36 | }) 37 | } 38 | } 39 | 40 | impl From for proto::cosmos::slashing::v1beta1::Params { 41 | fn from(params: Params) -> Self { 42 | proto::cosmos::slashing::v1beta1::Params { 43 | signed_blocks_window: params.signed_blocks_window, 44 | min_signed_per_window: params.min_signed_per_window, 45 | downtime_jail_duration: params 46 | .downtime_jail_duration 47 | .map(TryInto::try_into) 48 | .transpose() 49 | .expect("invalid downtime jail duration"), // same fallible serialisation concern as with feegrant::PeriodicAllowance 50 | slash_fraction_double_sign: params.slash_fraction_double_sign, 51 | slash_fraction_downtime: params.slash_fraction_downtime, 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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_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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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