client: rename CliContext to Context (#6290)
* Refactor CliContext as Context * Fix lint issues * Fix goimports * Fix gov tests * Resolved ci-lint issues * Add changelog * Rename cliCtx to clientCtx * Fix mocks and routes * Add changelog * Update changelog * Apply suggestions from code review Co-authored-by: Alessio Treglia <alessio@tendermint.com> * merge client/rpc/ro{ot,utes}.go * Update docs * client/rpc: remove redundant client/rpc.RegisterRPCRoutes * regenerate mocks * Update ADRs Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Alessio Treglia
Federico Kunze
mergify[bot]
parent
654b2fdd10
commit
39f53ac22f
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -48,7 +47,7 @@ $ <appcli> query slashing signing-info cosmosvalconspub1zcjduepqfhvwcmt7p06fvdge
|
||||
`),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
pk, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, args[0])
|
||||
if err != nil {
|
||||
@@ -58,7 +57,7 @@ $ <appcli> query slashing signing-info cosmosvalconspub1zcjduepqfhvwcmt7p06fvdge
|
||||
consAddr := sdk.ConsAddress(pk.Address())
|
||||
key := types.ValidatorSigningInfoKey(consAddr)
|
||||
|
||||
res, _, err := cliCtx.QueryStore(key, storeName)
|
||||
res, _, err := clientCtx.QueryStore(key, storeName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -73,7 +72,7 @@ $ <appcli> query slashing signing-info cosmosvalconspub1zcjduepqfhvwcmt7p06fvdge
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(signingInfo)
|
||||
return clientCtx.PrintOutput(signingInfo)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -89,17 +88,17 @@ func GetCmdQueryParams(cdc *codec.Codec) *cobra.Command {
|
||||
$ <appcli> query slashing params
|
||||
`),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
route := fmt.Sprintf("custom/%s/parameters", types.QuerierRoute)
|
||||
res, _, err := cliCtx.QueryWithData(route, nil)
|
||||
res, _, err := clientCtx.QueryWithData(route, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var params types.Params
|
||||
cdc.MustUnmarshalJSON(res, ¶ms)
|
||||
return cliCtx.PrintOutput(params)
|
||||
return clientCtx.PrintOutput(params)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -12,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// NewTxCmd returns a root CLI command handler for all x/slashing transaction commands.
|
||||
func NewTxCmd(ctx context.CLIContext) *cobra.Command {
|
||||
func NewTxCmd(clientCtx client.Context) *cobra.Command {
|
||||
slashingTxCmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "Slashing transaction subcommands",
|
||||
@@ -21,11 +20,11 @@ func NewTxCmd(ctx context.CLIContext) *cobra.Command {
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
slashingTxCmd.AddCommand(NewUnjailTxCmd(ctx))
|
||||
slashingTxCmd.AddCommand(NewUnjailTxCmd(clientCtx))
|
||||
return slashingTxCmd
|
||||
}
|
||||
|
||||
func NewUnjailTxCmd(ctx context.CLIContext) *cobra.Command {
|
||||
func NewUnjailTxCmd(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "unjail",
|
||||
Args: cobra.NoArgs,
|
||||
@@ -35,15 +34,15 @@ func NewUnjailTxCmd(ctx context.CLIContext) *cobra.Command {
|
||||
$ <appcli> tx slashing unjail --from mykey
|
||||
`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := ctx.InitWithInput(cmd.InOrStdin())
|
||||
clientCtx := clientCtx.InitWithInput(cmd.InOrStdin())
|
||||
|
||||
valAddr := cliCtx.GetFromAddress()
|
||||
valAddr := clientCtx.GetFromAddress()
|
||||
msg := types.NewMsgUnjail(sdk.ValAddress(valAddr))
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.GenerateOrBroadcastTx(cliCtx, msg)
|
||||
return tx.GenerateOrBroadcastTx(clientCtx, msg)
|
||||
},
|
||||
}
|
||||
return flags.PostCommands(cmd)[0]
|
||||
|
||||
Reference in New Issue
Block a user