diff --git a/CHANGELOG.md b/CHANGELOG.md index f1e871464d68..d09ca5d2450f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (server) [#17177](https://github.com/cosmos/cosmos-sdk/pull/17177) Remove `iavl-lazy-loading` configuration. * (rosetta) [#16276](https://github.com/cosmos/cosmos-sdk/issues/16276) Rosetta migration to standalone repo. +* (cli) [#17184](https://github.com/cosmos/cosmos-sdk/pull/17184) All json keys returned by the `status` command are now snake case instead of pascal case. ### State Machine Breaking diff --git a/client/rpc/status.go b/client/rpc/status.go index 30f59d7c8657..5f50ae36af14 100644 --- a/client/rpc/status.go +++ b/client/rpc/status.go @@ -3,32 +3,14 @@ package rpc import ( "context" - "github.com/cometbft/cometbft/p2p" + cmtjson "github.com/cometbft/cometbft/libs/json" coretypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) -// ValidatorInfo is info about the node's validator, same as CometBFT, -// except that we use our own PubKey. -type validatorInfo struct { - Address []byte - PubKey cryptotypes.PubKey - VotingPower int64 -} - -// ResultStatus is node's info, same as CometBFT, except that we use our own -// PubKey. -type resultStatus struct { - NodeInfo p2p.DefaultNodeInfo - SyncInfo coretypes.SyncInfo - ValidatorInfo validatorInfo -} - // StatusCommand returns the command to return the status of the network. func StatusCommand() *cobra.Command { cmd := &cobra.Command{ @@ -45,35 +27,23 @@ func StatusCommand() *cobra.Command { return err } - var pk cryptotypes.PubKey - // `status` has TM pubkeys, we need to convert them to our pubkeys. - if status.ValidatorInfo.PubKey != nil { - pk, err = cryptocodec.FromCmtPubKeyInterface(status.ValidatorInfo.PubKey) - if err != nil { - return err - } - } - statusWithPk := resultStatus{ - NodeInfo: status.NodeInfo, - SyncInfo: status.SyncInfo, - ValidatorInfo: validatorInfo{ - Address: status.ValidatorInfo.Address, - PubKey: pk, - VotingPower: status.ValidatorInfo.VotingPower, - }, - } - - output, err := clientCtx.LegacyAmino.MarshalJSON(statusWithPk) + output, err := cmtjson.Marshal(status) if err != nil { return err } - cmd.Println(string(output)) - return nil + // In order to maintain backwards compatibility, the default json format output + outputFormat, _ := cmd.Flags().GetString(flags.FlagOutput) + if outputFormat == flags.OutputFormatJSON { + clientCtx = clientCtx.WithOutputFormat(flags.OutputFormatJSON) + } + + return clientCtx.PrintRaw(output) }, } cmd.Flags().StringP(flags.FlagNode, "n", "tcp://localhost:26657", "Node to connect to") + cmd.Flags().StringP(flags.FlagOutput, "o", "json", "Output format (text|json)") return cmd }