[ENG-722]: Query x/builder module from CLI (#58)
This commit is contained in:
parent
06812560fc
commit
01d4f7ca71
53
x/builder/client/cli/query.go
Normal file
53
x/builder/client/cli/query.go
Normal file
@ -0,0 +1,53 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/skip-mev/pob/x/builder/types"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the cli query commands for the builder module.
|
||||
func GetQueryCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
CmdQueryParams(),
|
||||
)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// CmdQueryParams implements a command that will return the current parameters of the builder module.
|
||||
func CmdQueryParams() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "params",
|
||||
Short: "Query the current parameters of the builder module",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
request := &types.QueryParamsRequest{}
|
||||
response, err := queryClient.Params(context.Background(), request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(&response.Params)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
@ -13,6 +13,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/skip-mev/pob/x/builder/client/cli"
|
||||
"github.com/skip-mev/pob/x/builder/keeper"
|
||||
"github.com/skip-mev/pob/x/builder/types"
|
||||
"github.com/spf13/cobra"
|
||||
@ -71,8 +72,10 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
|
||||
// GetTxCmd returns the root tx command for the builder module.
|
||||
func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil }
|
||||
|
||||
// GetQueryCmd returns no root query command for the builder module.
|
||||
func (AppModuleBasic) GetQueryCmd() *cobra.Command { return nil }
|
||||
// GetQueryCmd returns the root query command for the builder module.
|
||||
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return cli.GetQueryCmd()
|
||||
}
|
||||
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
|
||||
Loading…
Reference in New Issue
Block a user