Skip to content

Commit

Permalink
add missing autocli (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 authored Jan 12, 2024
1 parent 1221525 commit 4e94335
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 5 deletions.
55 changes: 55 additions & 0 deletions x/slashing/autocli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package slashing

import (
"fmt"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
slashingv1beta "cosmossdk.io/api/cosmos/slashing/v1beta1"

"github.com/cosmos/cosmos-sdk/version"
)

func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Query: &autocliv1.ServiceCommandDescriptor{
Service: slashingv1beta.Query_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Params",
Use: "params",
Short: "Query the current slashing parameters",
},
{
RpcMethod: "SigningInfo",
Use: "signing-info [validator-conspub/address]",
Short: "Query a validator's signing information",
Long: "Query a validator's signing information, with a pubkey ('<appd> comet show-validator') or a validator consensus address",
Example: fmt.Sprintf(`%s query slashing signing-info '{"@type":"/cosmos.crypto.ed25519.PubKey","key":"OauFcTKbN5Lx3fJL689cikXBqe+hcp6Y+x0rYUdR9Jk="}'`, version.AppName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "cons_address"},
},
},
{
RpcMethod: "SigningInfos",
Use: "signing-infos",
Short: "Query signing information of all validators",
},
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: slashingv1beta.Msg_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Unjail",
Use: "unjail",
Short: "Unjail a jailed validator",
Example: fmt.Sprintf("%s tx slashing unjail --from [validator]", version.AppName),
},
{
RpcMethod: "UpdateParams",
Skip: true, // skipped because authority gated
},
},
},
}
}
10 changes: 5 additions & 5 deletions x/slashing/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func TestGRPCQueryParams(t *testing.T) {
ctx, input := createDefaultTestInput(t)

paramsResp, err := input.SlashingKeeper.Params(sdk.WrapSDKContext(ctx), &types.QueryParamsRequest{})
paramsResp, err := input.SlashingKeeper.Params(ctx, &types.QueryParamsRequest{})

require.NoError(t, err)
require.Equal(t, types.DefaultParams(), paramsResp.Params)
Expand All @@ -23,7 +23,7 @@ func TestGRPCQueryParams(t *testing.T) {
func TestGRPCSigningInfo(t *testing.T) {
ctx, input := createDefaultTestInput(t)

infoResp, err := input.SlashingKeeper.SigningInfo(sdk.WrapSDKContext(ctx), &types.QuerySigningInfoRequest{ConsAddress: ""})
infoResp, err := input.SlashingKeeper.SigningInfo(ctx, &types.QuerySigningInfoRequest{ConsAddress: ""})
require.Error(t, err)
require.Nil(t, infoResp)

Expand All @@ -32,7 +32,7 @@ func TestGRPCSigningInfo(t *testing.T) {
info, err := input.SlashingKeeper.GetValidatorSigningInfo(ctx, sdk.ConsAddress(valPubKey.Address()))
require.NoError(t, err)

infoResp, err = input.SlashingKeeper.SigningInfo(sdk.WrapSDKContext(ctx),
infoResp, err = input.SlashingKeeper.SigningInfo(ctx,
&types.QuerySigningInfoRequest{ConsAddress: sdk.ConsAddress(valPubKey.Address()).String()})
require.NoError(t, err)
require.Equal(t, info, infoResp.ValSigningInfo)
Expand All @@ -59,12 +59,12 @@ func TestGRPCSigningInfos(t *testing.T) {
})

// verify all values are returned without pagination
infoResp, err := input.SlashingKeeper.SigningInfos(sdk.WrapSDKContext(ctx),
infoResp, err := input.SlashingKeeper.SigningInfos(ctx,
&types.QuerySigningInfosRequest{Pagination: nil})
require.NoError(t, err)
require.Equal(t, signingInfos, infoResp.Info)

infoResp, err = input.SlashingKeeper.SigningInfos(sdk.WrapSDKContext(ctx),
infoResp, err = input.SlashingKeeper.SigningInfos(ctx,
&types.QuerySigningInfosRequest{Pagination: &query.PageRequest{Limit: 1, CountTotal: true}})

require.NoError(t, err)
Expand Down

0 comments on commit 4e94335

Please sign in to comment.