Skip to content

Commit

Permalink
fix: slashing cli (#62)
Browse files Browse the repository at this point in the history
* fix oracle prometheus server to be finished properly

* fix slasing cli
  • Loading branch information
beer-1 authored Jan 20, 2024
1 parent 8d69a57 commit e9ecb68
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
58 changes: 58 additions & 0 deletions x/slashing/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package cli

import (
"cosmossdk.io/core/address"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/x/slashing/types"
)

// NewTxCmd returns a root CLI command handler for all x/slashing transaction commands.
func NewTxCmd(vc address.Codec) *cobra.Command {
slashingTxCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Slashing transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

slashingTxCmd.AddCommand(NewUnjailTxCmd(vc))
return slashingTxCmd
}

// NewUnjailTxCmd returns a CLI command handler for creating a MsgUnjail transaction.
func NewUnjailTxCmd(vc address.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "unjail",
Args: cobra.NoArgs,
Short: "unjail validator previously jailed for downtime",
Long: `unjail a jailed validator:
$ <appd> tx slashing unjail --from mykey
`,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

valAddr := clientCtx.GetFromAddress()
valAddrStr, err := vc.BytesToString(valAddr)
if err != nil {
return err

}

msg := types.NewMsgUnjail(valAddrStr)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
12 changes: 12 additions & 0 deletions x/slashing/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"cosmossdk.io/core/appmodule"

Expand All @@ -16,6 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/slashing/types"

"github.com/initia-labs/initia/x/slashing/client/cli"
"github.com/initia-labs/initia/x/slashing/keeper"
)

Expand Down Expand Up @@ -77,6 +79,16 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
}
}

// GetTxCmd returns no root tx command for the mint module.
func (b AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.NewTxCmd(b.cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec())
}

// GetQueryCmd returns the root query command for the mint module.
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
return nil
}

// AppModule implements an application module for the slashing module.
type AppModule struct {
AppModuleBasic
Expand Down

0 comments on commit e9ecb68

Please sign in to comment.