feat(cli): add module-account cli cmd and grpc get api (#13612)
This commit is contained in:
@@ -46,6 +46,7 @@ func GetQueryCmd() *cobra.Command {
|
||||
GetAccountsCmd(),
|
||||
QueryParamsCmd(),
|
||||
QueryModuleAccountsCmd(),
|
||||
QueryModuleAccountByNameCmd(),
|
||||
)
|
||||
|
||||
return cmd
|
||||
@@ -219,6 +220,40 @@ func QueryModuleAccountsCmd() *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
// QueryModuleAccountByNameCmd returns a command to
|
||||
func QueryModuleAccountByNameCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "module-account [module-name]",
|
||||
Short: "Query module account info by module name",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Example: fmt.Sprintf("%s q auth module-account auth", version.AppName),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
moduleName := args[0]
|
||||
if len(moduleName) == 0 {
|
||||
return fmt.Errorf("module name should not be empty")
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
res, err := queryClient.ModuleAccountByName(context.Background(), &types.QueryModuleAccountByNameRequest{Name: moduleName})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// QueryTxsByEventsCmd returns a command to search through transactions by events.
|
||||
func QueryTxsByEventsCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
|
||||
Reference in New Issue
Block a user