Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added query for provider parameters #1605

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added query for current values of all provider parameters
([\#1605](https://github.com/cosmos/interchain-security/pull/1605))
16 changes: 15 additions & 1 deletion proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ service Query {
returns (QueryAllPairsValConAddrByConsumerChainIDResponse) {
option (google.api.http).get =
"/interchain_security/ccv/provider/consumer_chain_id";
}
}

// QueryParams returns all current values of provider parameters
rpc QueryParams(QueryParamsRequest)
returns (QueryParamsResponse) {
option (google.api.http).get =
"/interchain_security/ccv/provider/params";
}
}

message QueryConsumerGenesisRequest { string chain_id = 1; }
Expand Down Expand Up @@ -198,3 +205,10 @@ message PairValConAddrProviderAndConsumer {
string consumer_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
tendermint.crypto.PublicKey consumer_key = 3;
}

message QueryParamsRequest {}

message QueryParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}

37 changes: 36 additions & 1 deletion x/ccv/provider/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewQueryCmd() *cobra.Command {
cmd.AddCommand(CmdRegisteredConsumerRewardDenoms())
cmd.AddCommand(CmdProposedConsumerChains())
cmd.AddCommand(CmdAllPairsValConAddrByConsumerChainID())

cmd.AddCommand(CmdProviderParameters())
return cmd
}

Expand Down Expand Up @@ -375,3 +375,38 @@ func CmdAllPairsValConAddrByConsumerChainID() *cobra.Command {

return cmd
}

// Command to query provider parameters
func CmdProviderParameters() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query provider parameters information",
Long: strings.TrimSpace(
fmt.Sprintf(`Query parameter values of provider.
Example:
$ %s query provider params
`, version.AppName),
),
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.QueryParams(cmd.Context(),
&types.QueryParamsRequest{})
if err != nil {
return err
}

return clientCtx.PrintProto(&res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd

}
8 changes: 8 additions & 0 deletions x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,11 @@ func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context,
PairValConAddr: pairValConAddrs,
}, nil
}

// QueryParams returns all parameters and current values of provider
func (k Keeper) QueryParams(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
params := k.GetParams(ctx)

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