diff --git a/api/cosmos/app/v1alpha1/query.pulsar.go b/api/cosmos/app/v1alpha1/query.pulsar.go index 978824645c58..12bb5b93a7a1 100644 --- a/api/cosmos/app/v1alpha1/query.pulsar.go +++ b/api/cosmos/app/v1alpha1/query.pulsar.go @@ -843,7 +843,7 @@ func (*QueryConfigRequest) Descriptor() ([]byte, []int) { return file_cosmos_app_v1alpha1_query_proto_rawDescGZIP(), []int{0} } -// QueryConfigRequest is the Query/Config response type. +// QueryConfigResponse is the Query/Config response type. type QueryConfigResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/api/cosmos/staking/v1beta1/staking.pulsar.go b/api/cosmos/staking/v1beta1/staking.pulsar.go index bec410e90918..a5bc255e320c 100644 --- a/api/cosmos/staking/v1beta1/staking.pulsar.go +++ b/api/cosmos/staking/v1beta1/staking.pulsar.go @@ -14684,7 +14684,7 @@ func (x *HistoricalInfo) GetValset() []*Validator { return nil } -// Historical contains a set of minimum values needed for evaluating historical validator sets and blocks. +// HistoricalRecord contains a set of minimum values needed for evaluating historical validator sets and blocks. // It is stored as part of staking module's state, which persists the `n` most // recent HistoricalInfo // (`n` is set by the staking module's `historical_entries` parameter). diff --git a/proto/cosmos/app/v1alpha1/query.proto b/proto/cosmos/app/v1alpha1/query.proto index cc611943108b..2a854b18b259 100644 --- a/proto/cosmos/app/v1alpha1/query.proto +++ b/proto/cosmos/app/v1alpha1/query.proto @@ -18,7 +18,7 @@ service Query { // QueryConfigRequest is the Query/Config request type. message QueryConfigRequest {} -// QueryConfigRequest is the Query/Config response type. +// QueryConfigResponse is the Query/Config response type. message QueryConfigResponse { // config is the current app config. diff --git a/server/v2/cometbft/commands.go b/server/v2/cometbft/commands.go index fe3d513feddc..b635ca505c36 100644 --- a/server/v2/cometbft/commands.go +++ b/server/v2/cometbft/commands.go @@ -72,10 +72,7 @@ func (s *CometBFTServer[T]) StatusCommand() *cobra.Command { return err } - cmd.Println(string(output)) - - // TODO: figure out yaml and json output - return nil + return printOutput(cmd, output) }, } @@ -215,15 +212,12 @@ for. Each module documents its respective events under 'xx_events.md'. return err } - // return clientCtx.PrintProto(blocks) // TODO: previously we had this, but I think it can be replaced with a simple json marshal. - // We are missing YAML output tho. bz, err := protojson.Marshal(blocks) if err != nil { return err } - _, err = cmd.OutOrStdout().Write(bz) - return err + return printOutput(cmd, bz) }, } @@ -282,15 +276,12 @@ $ %s query block --%s=%s return fmt.Errorf("no block found with height %s", args[0]) } - // return clientCtx.PrintProto(output) - bz, err := json.Marshal(output) if err != nil { return err } - _, err = cmd.OutOrStdout().Write(bz) - return err + return printOutput(cmd, bz) case auth.TypeHash: @@ -308,14 +299,12 @@ $ %s query block --%s=%s return fmt.Errorf("no block found with hash %s", args[0]) } - // return clientCtx.PrintProto(output) bz, err := json.Marshal(output) if err != nil { return err } - _, err = cmd.OutOrStdout().Write(bz) - return err + return printOutput(cmd, bz) default: return fmt.Errorf("unknown --%s value %s", auth.FlagType, typ) @@ -371,10 +360,7 @@ func (s *CometBFTServer[T]) QueryBlockResultsCmd() *cobra.Command { return err } - cmd.Println(string(blockResStr)) - - // TODO: figure out yaml and json output - return nil + return printOutput(cmd, blockResStr) }, } @@ -425,3 +411,33 @@ func (s *CometBFTServer[T]) BootstrapStateCmd() *cobra.Command { return cmd } + +func printOutput(cmd *cobra.Command, out []byte) error { + // Get flags output + outFlag, err := cmd.Flags().GetString(flags.FlagOutput) + if err != nil { + return err + } + + if outFlag == "text" { + out, err = yaml.JSONToYAML(out) + if err != nil { + return err + } + } + + writer := cmd.OutOrStdout() + _, err = writer.Write(out) + if err != nil { + return err + } + + if outFlag != "text" { + // append new-line for formats besides YAML + _, err = writer.Write([]byte("\n")) + if err != nil { + return err + } + } + return nil +} diff --git a/x/staking/proto/cosmos/staking/v1beta1/staking.proto b/x/staking/proto/cosmos/staking/v1beta1/staking.proto index 9fa7e58ce57b..48203a8d8e3e 100644 --- a/x/staking/proto/cosmos/staking/v1beta1/staking.proto +++ b/x/staking/proto/cosmos/staking/v1beta1/staking.proto @@ -25,7 +25,7 @@ message HistoricalInfo { repeated Validator valset = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } -// Historical contains a set of minimum values needed for evaluating historical validator sets and blocks. +// HistoricalRecord contains a set of minimum values needed for evaluating historical validator sets and blocks. // It is stored as part of staking module's state, which persists the `n` most // recent HistoricalInfo // (`n` is set by the staking module's `historical_entries` parameter). diff --git a/x/staking/types/staking.pb.go b/x/staking/types/staking.pb.go index edd57d145cc2..1f9adaed0b01 100644 --- a/x/staking/types/staking.pb.go +++ b/x/staking/types/staking.pb.go @@ -166,7 +166,7 @@ func (m *HistoricalInfo) GetValset() []Validator { return nil } -// Historical contains a set of minimum values needed for evaluating historical validator sets and blocks. +// HistoricalRecord contains a set of minimum values needed for evaluating historical validator sets and blocks. // It is stored as part of staking module's state, which persists the `n` most // recent HistoricalInfo // (`n` is set by the staking module's `historical_entries` parameter).