diff --git a/docs/MIGRATING.md b/docs/MIGRATING.md index f243eee01..aa699bdbf 100644 --- a/docs/MIGRATING.md +++ b/docs/MIGRATING.md @@ -21,6 +21,8 @@ two `VM` instances operate on the same directory in parallel. This was unsupported before already but now leads to an error early on. When doing parallel testing, use a different directory for each instance. +- `QueryRequest.Grpc` was added. It is similar to `QueryRequest.Stargate` but + unlike that, it should always return protobuf encoded responses on all chains. - `VM.StoreCode` now returns a `uint64` containing the gas cost in CosmWasm gas and takes a gas limit as argument. This was previously calculated in wasmd. The change brings consistency with the other functions that cause gas usage. diff --git a/types/queries.go b/types/queries.go index 51c067ba8..32ee88dbe 100644 --- a/types/queries.go +++ b/types/queries.go @@ -106,6 +106,7 @@ type QueryRequest struct { Staking *StakingQuery `json:"staking,omitempty"` Distribution *DistributionQuery `json:"distribution,omitempty"` Stargate *StargateQuery `json:"stargate,omitempty"` + Grpc *GrpcQuery `json:"grpc,omitempty"` Wasm *WasmQuery `json:"wasm,omitempty"` } @@ -435,14 +436,29 @@ type BondedDenomResponse struct { // StargateQuery is encoded the same way as abci_query, with path and protobuf encoded request 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 protobuf encoded data directly without a JSON response wrapper. -// The caller is responsible for compiling the proper protobuf definitions for both requests and responses. +// The response is supposed to always be protobuf encoded data, but is JSON encoded on some chains. +// The caller is responsible for compiling the proper type definitions for both requests and responses. type StargateQuery struct { - // this is the fully qualified service path used for routing, - // eg. custom/cosmos_sdk.x.bank.v1.Query/QueryBalance + // The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded + Data []byte `json:"data"` + // The fully qualified endpoint path used for routing. + // It follows the format `/service_path/method_name`, + // eg. "/cosmos.authz.v1beta1.Query/Grants" Path string `json:"path"` - // this is the expected protobuf message type (not any), binary encoded +} + +// GrpcQuery queries the chain using a grpc query. +// This allows to query information that is not exposed in our API. +// The chain needs to allowlist the supported queries. +// +// The returned data is protobuf encoded. The protobuf type depends on the query. +type GrpcQuery struct { + // The expected protobuf message type (not [Any](https://protobuf.dev/programming-guides/proto3/#any)), binary encoded Data []byte `json:"data"` + // The fully qualified endpoint path used for routing. + // It follows the format `/service_path/method_name`, + // eg. "/cosmos.authz.v1beta1.Query/Grants" + Path string `json:"path"` } type WasmQuery struct {