* 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>
63 lines
1.7 KiB
Go
63 lines
1.7 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/x/params/types"
|
|
)
|
|
|
|
// NewQueryCmd returns a root CLI command handler for all x/params query commands.
|
|
func NewQueryCmd(m codec.JSONMarshaler) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: types.ModuleName,
|
|
Short: "Querying commands for the params module",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: client.ValidateCmd,
|
|
}
|
|
|
|
cmd.AddCommand(NewQuerySubspaceParamsCmd(m))
|
|
|
|
return cmd
|
|
}
|
|
|
|
// NewQuerySubspaceParamsCmd returns a CLI command handler for querying subspace
|
|
// parameters managed by the x/params module.
|
|
func NewQuerySubspaceParamsCmd(m codec.JSONMarshaler) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "subspace [subspace] [key]",
|
|
Short: "Query for raw parameters by subspace and key",
|
|
Args: cobra.ExactArgs(2),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx := client.NewContext().WithJSONMarshaler(m)
|
|
|
|
params := types.NewQuerySubspaceParams(args[0], args[1])
|
|
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParams)
|
|
|
|
bz, err := m.MarshalJSON(params)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to marshal params: %w", err)
|
|
}
|
|
|
|
bz, _, err = clientCtx.QueryWithData(route, bz)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var resp types.SubspaceParamsResponse
|
|
if err := m.UnmarshalJSON(bz, &resp); err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintOutput(resp)
|
|
},
|
|
}
|
|
|
|
return flags.GetCommands(cmd)[0]
|
|
}
|