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
@@ -8,7 +8,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"
|
||||
@@ -60,14 +59,14 @@ $ %s query staking validator cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhff
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
addr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res, _, err := cliCtx.QueryStore(types.GetValidatorKey(addr), storeName)
|
||||
res, _, err := clientCtx.QueryStore(types.GetValidatorKey(addr), storeName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -81,7 +80,7 @@ $ %s query staking validator cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhff
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(validator)
|
||||
return clientCtx.PrintOutput(validator)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -102,9 +101,9 @@ $ %s query staking validators
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
resKVs, _, err := cliCtx.QuerySubspace(types.ValidatorsKey, storeName)
|
||||
resKVs, _, err := clientCtx.QuerySubspace(types.ValidatorsKey, storeName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -119,7 +118,7 @@ $ %s query staking validators
|
||||
validators = append(validators, validator)
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(validators)
|
||||
return clientCtx.PrintOutput(validators)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -140,7 +139,7 @@ $ %s query staking unbonding-delegations-from cosmosvaloper1gghjut3ccd8ay0zduzj6
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
valAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@@ -153,14 +152,14 @@ $ %s query staking unbonding-delegations-from cosmosvaloper1gghjut3ccd8ay0zduzj6
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryValidatorUnbondingDelegations)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var ubds types.UnbondingDelegations
|
||||
cdc.MustUnmarshalJSON(res, &ubds)
|
||||
return cliCtx.PrintOutput(ubds)
|
||||
return clientCtx.PrintOutput(ubds)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -182,7 +181,7 @@ $ %s query staking redelegations-from cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
valSrcAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@@ -195,7 +194,7 @@ $ %s query staking redelegations-from cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryRedelegations)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -205,7 +204,7 @@ $ %s query staking redelegations-from cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(resp)
|
||||
return clientCtx.PrintOutput(resp)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -226,7 +225,7 @@ $ %s query staking delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p cosm
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
delAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@@ -244,7 +243,7 @@ $ %s query staking delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p cosm
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegation)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -254,7 +253,7 @@ $ %s query staking delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p cosm
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(resp)
|
||||
return clientCtx.PrintOutput(resp)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -276,7 +275,7 @@ $ %s query staking delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
delAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@@ -289,7 +288,7 @@ $ %s query staking delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegatorDelegations)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -299,7 +298,7 @@ $ %s query staking delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(resp)
|
||||
return clientCtx.PrintOutput(resp)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -321,7 +320,7 @@ $ %s query staking delegations-to cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ld
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
valAddr, err := sdk.ValAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@@ -334,7 +333,7 @@ $ %s query staking delegations-to cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ld
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryValidatorDelegations)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -344,7 +343,7 @@ $ %s query staking delegations-to cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ld
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(resp)
|
||||
return clientCtx.PrintOutput(resp)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -366,7 +365,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
valAddr, err := sdk.ValAddressFromBech32(args[1])
|
||||
if err != nil {
|
||||
@@ -384,7 +383,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryUnbondingDelegation)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -394,7 +393,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(ubd)
|
||||
return clientCtx.PrintOutput(ubd)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -416,7 +415,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
|
||||
),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
delegatorAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@@ -429,7 +428,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegatorUnbondingDelegations)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -439,7 +438,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(ubds)
|
||||
return clientCtx.PrintOutput(ubds)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -461,7 +460,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
|
||||
),
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
delAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@@ -484,7 +483,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryRedelegations)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -494,7 +493,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(resp)
|
||||
return clientCtx.PrintOutput(resp)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -516,7 +515,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
delAddr, err := sdk.AccAddressFromBech32(args[0])
|
||||
if err != nil {
|
||||
@@ -529,7 +528,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryRedelegations)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -539,7 +538,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(resp)
|
||||
return clientCtx.PrintOutput(resp)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -560,7 +559,7 @@ $ %s query staking historical-info 5
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
height, err := strconv.ParseInt(args[0], 10, 64)
|
||||
if err != nil || height < 0 {
|
||||
@@ -573,7 +572,7 @@ $ %s query staking historical-info 5
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryHistoricalInfo)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, _, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -583,7 +582,7 @@ $ %s query staking historical-info 5
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(resp)
|
||||
return clientCtx.PrintOutput(resp)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -604,9 +603,9 @@ $ %s query staking pool
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
bz, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/pool", storeName), nil)
|
||||
bz, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/pool", storeName), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -616,7 +615,7 @@ $ %s query staking pool
|
||||
return err
|
||||
}
|
||||
|
||||
return cliCtx.PrintOutput(pool)
|
||||
return clientCtx.PrintOutput(pool)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -637,17 +636,17 @@ $ %s query staking params
|
||||
),
|
||||
),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
clientCtx := client.NewContext().WithCodec(cdc)
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", storeName, types.QueryParameters)
|
||||
bz, _, err := cliCtx.QueryWithData(route, nil)
|
||||
bz, _, err := clientCtx.QueryWithData(route, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var params types.Params
|
||||
cdc.MustUnmarshalJSON(bz, ¶ms)
|
||||
return cliCtx.PrintOutput(params)
|
||||
return clientCtx.PrintOutput(params)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user