feat(cli): add module-account cli cmd and grpc get api (#13612)

This commit is contained in:
Sai Kumar
2022-10-22 18:23:24 +00:00
committed by GitHub
parent e2792711ba
commit ddf5cf0d8d
10 changed files with 3219 additions and 1515 deletions
+35
View File
@@ -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{