Skip to content

Commit

Permalink
add interchain security consumer QueryParams (#746)
Browse files Browse the repository at this point in the history
add QueryParams
  • Loading branch information
MSalopek authored and sainoe committed Apr 13, 2023
1 parent 31481fa commit a718095
Show file tree
Hide file tree
Showing 4 changed files with 459 additions and 29 deletions.
15 changes: 14 additions & 1 deletion proto/interchain_security/ccv/consumer/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ syntax = "proto3";
package interchain_security.ccv.consumer.v1;
option go_package = "github.com/cosmos/interchain-security/x/ccv/consumer/types";

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";

import "interchain_security/ccv/consumer/v1/consumer.proto";

service Query {
// ConsumerGenesis queries the genesis state needed to start a consumer chain
Expand All @@ -14,6 +15,10 @@ service Query {
option (google.api.http).get =
"/interchain_security/ccv/consumer/next-fee-distribution";
}
// QueryParams queries the ccv/consumer module parameters.
rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/interchain_security/ccv/consumer/params";
}
}

// NextFeeDistributionEstimate holds information about next fee distribution
Expand All @@ -39,3 +44,11 @@ message QueryNextFeeDistributionEstimateRequest { }
message QueryNextFeeDistributionEstimateResponse {
NextFeeDistributionEstimate data = 1;
}

message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}
14 changes: 14 additions & 0 deletions x/ccv/consumer/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,17 @@ func (k Keeper) QueryNextFeeDistribution(c context.Context,

return &types.QueryNextFeeDistributionEstimateResponse{Data: &nextDist}, nil
}

func (k Keeper) QueryParams(c context.Context,
req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {

ctx := sdk.UnwrapSDKContext(c)

if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}

p := k.GetParams(ctx)

return &types.QueryParamsResponse{Params: p}, nil
}
Loading

0 comments on commit a718095

Please sign in to comment.