Skip to content

Commit

Permalink
Merge pull request #706 from CosmWasm/add-stargate-msg
Browse files Browse the repository at this point in the history
Add stargate msg
  • Loading branch information
mergify[bot] authored Jan 12, 2021
2 parents 18dfdbf + 09b7880 commit 969bb8b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ staking = []
# at the cost of a bit of code size and performance.
# This feature requires Rust nightly because it depends on the unstable backtrace feature.
backtraces = []
# stargate enables stargate-dependent messages and queries, like raw protobuf messages
# as well as ibc-related functionality
stargate = []

[dependencies]
base64 = "0.13.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/std/src/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ use crate::{Deps, DepsMut, MessageInfo};
#[no_mangle]
extern "C" fn requires_staking() -> () {}

#[cfg(feature = "stargate")]
#[no_mangle]
extern "C" fn requires_stargate() -> () {}

/// cosmwasm_vm_version_* exports mark which Wasm VM interface level this contract is compiled for.
/// They can be checked by cosmwasm_vm.
/// Update this whenever the Wasm VM interface breaks.
Expand Down
11 changes: 11 additions & 0 deletions packages/std/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ pub enum QueryRequest<C: CustomQuery> {
Bank(BankQuery),
Custom(C),
Staking(StakingQuery),
/// A Stargate query encoded the same way as abci_query, with path and protobuf encoded Data.
/// The format is defined in [ADR-21](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-021-protobuf-query-encoding.md)
/// The response is also protobuf encoded. The caller is responsible for compiling the proper protobuf definitions
#[cfg(feature = "stargate")]
Stargate {
/// this is the fully qualified service path used for routing,
/// eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance
path: String,
/// this is the expected protobuf message type (not any), binary encoded
data: Binary,
},
Wasm(WasmQuery),
}

Expand Down
7 changes: 7 additions & 0 deletions packages/std/src/results/cosmos_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ where
// to call into more app-specific code (whatever they define)
Custom(T),
Staking(StakingMsg),
/// A Stargate message encoded the same way as a protobof [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto).
/// This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)
#[cfg(feature = "stargate")]
Stargate {
type_url: String,
data: Binary,
},
Wasm(WasmMsg),
}

Expand Down

0 comments on commit 969bb8b

Please sign in to comment.