Skip to content

Commit

Permalink
Merge branch 'main' into hieu/mnemonic_from_file
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvubk committed Jun 17, 2024
2 parents e0a3735 + 1ed018a commit 6d7a634
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 24 deletions.
2 changes: 1 addition & 1 deletion api/cosmos/app/v1alpha1/query.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/cosmos/staking/v1beta1/staking.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/cosmos/app/v1alpha1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
54 changes: 35 additions & 19 deletions server/v2/cometbft/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}

Expand Down Expand Up @@ -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)
},
}

Expand Down Expand Up @@ -282,15 +276,12 @@ $ %s query block --%s=%s <hash>
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:

Expand All @@ -308,14 +299,12 @@ $ %s query block --%s=%s <hash>
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)
Expand Down Expand Up @@ -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)
},
}

Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion x/staking/proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion x/staking/types/staking.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6d7a634

Please sign in to comment.