You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we have different ways of handling enums as parameter values in gRPC / grpc-gateway queriers.
1) Enum params as ints
As identified in #8808 (see comment), queries to /cosmos/gov/v1beta1/proposals, takes a query parameters ProposalStatus (a protobuf enum) as an int. So in order to query for specific status, you would query like so: /cosmos/gov/v1beta1/proposals?proposal_status=1. See code here, and proto def below:
// QueryProposalsRequest is the request type for the Query/Proposals RPC method.messageQueryProposalsRequest {
option(gogoproto.equal)=false;
option(gogoproto.goproto_getters)=false;
// proposal_status defines the status of the proposals.ProposalStatusproposal_status=1;
// voter defines the voter address for the proposals.stringvoter=2;
// depositor defines the deposit addresses from the proposals.stringdepositor=3;
// pagination defines an optional pagination for the request.cosmos.base.query.v1beta1.PageRequestpagination=4;
}
2) Enum params parsed from strings
On the other hand, when querying validators by BondStatus (via the endpoint /comsos/staking/v1beta1/validators), we actually expect a string equal to the enum's String() value. So in order to query for a specific bond status, you would query like so: `/cosmos/staking/v1beta1/validators?status=BOND_STATUS_BONDED See code here, or proto def below:
// QueryValidatorsRequest is request type for Query/Validators RPC method.messageQueryValidatorsRequest {
// status enables to query for validators matching a given status.stringstatus=1;
// pagination defines an optional pagination for the request.cosmos.base.query.v1beta1.PageRequestpagination=2;
}
Question
We should pick either (1) or (2) and ensure that all grpc queriers adhere to the same standard expectation.
BTW, the QueryValidatorsRequest message should be updated. It should be BondStatus status = 1;
We can try to make this change in a non-breaking way: add a new field, then add some logic to coerce the old string status (if set) into the new BondStatus.
Currently we have different ways of handling enums as parameter values in gRPC / grpc-gateway queriers.
1) Enum params as ints
As identified in #8808 (see comment), queries to
/cosmos/gov/v1beta1/proposals
, takes a query parametersProposalStatus
(a protobuf enum) as an int. So in order to query for specific status, you would query like so:/cosmos/gov/v1beta1/proposals?proposal_status=1
. See code here, and proto def below:2) Enum params parsed from strings
On the other hand, when querying validators by BondStatus (via the endpoint
/comsos/staking/v1beta1/validators
), we actually expect a string equal to the enum'sString()
value. So in order to query for a specific bond status, you would query like so: `/cosmos/staking/v1beta1/validators?status=BOND_STATUS_BONDED See code here, or proto def below:Question
We should pick either (1) or (2) and ensure that all grpc queriers adhere to the same standard expectation.
Thoughts on this @AmauryM @atheeshp, others?
The text was updated successfully, but these errors were encountered: