Require proto.Message in client.Context.PrintOutput (#6999)
* Enable proto JSON json for cli tx & query * WIP on tests * Test fixes, cleanup * Cleanup * Address review comments * Update client/context.go Co-authored-by: Anil Kumar Kammari <anil@vitwit.com> * Fixes Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
This commit is contained in:
parent
20c80cfd44
commit
7de8ef75b3
|
@ -5,6 +5,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/gogo/protobuf/proto"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||||
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
|
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
|
||||||
|
@ -209,7 +211,17 @@ func (ctx Context) PrintString(str string) error {
|
||||||
// PrintOutput outputs toPrint to the ctx.Output based on ctx.OutputFormat which is
|
// PrintOutput outputs toPrint to the ctx.Output based on ctx.OutputFormat which is
|
||||||
// either text or json. If text, toPrint will be YAML encoded. Otherwise, toPrint
|
// either text or json. If text, toPrint will be YAML encoded. Otherwise, toPrint
|
||||||
// will be JSON encoded using ctx.JSONMarshaler. An error is returned upon failure.
|
// will be JSON encoded using ctx.JSONMarshaler. An error is returned upon failure.
|
||||||
func (ctx Context) PrintOutput(toPrint interface{}) error {
|
func (ctx Context) PrintOutput(toPrint proto.Message) error {
|
||||||
|
return ctx.printOutput(toPrint)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintOutputLegacy is a variant of PrintOutput that doesn't require a proto type
|
||||||
|
// and uses amino JSON encoding. It will be removed in the near future!
|
||||||
|
func (ctx Context) PrintOutputLegacy(toPrint interface{}) error {
|
||||||
|
return ctx.WithJSONMarshaler(ctx.LegacyAmino).printOutput(toPrint)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx Context) printOutput(toPrint interface{}) error {
|
||||||
// always serialize JSON initially because proto json can't be directly YAML encoded
|
// always serialize JSON initially because proto json can't be directly YAML encoded
|
||||||
out, err := ctx.JSONMarshaler.MarshalJSON(toPrint)
|
out, err := ctx.JSONMarshaler.MarshalJSON(toPrint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -50,7 +50,7 @@ func ValidatorCommand() *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(result)
|
return clientCtx.PrintOutputLegacy(result)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ $ <appcli> query auth params
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Params)
|
return clientCtx.PrintOutput(&res.Params)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,13 +98,7 @@ func GetAccountCmd() *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var account types.AccountI
|
return clientCtx.PrintOutput(res.Account)
|
||||||
err = clientCtx.InterfaceRegistry.UnpackAny(res.Account, &account)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return clientCtx.PrintOutput(account)
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gogo/protobuf/proto"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||||
|
|
||||||
|
@ -128,43 +130,41 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
expectErr bool
|
expectErr bool
|
||||||
respType fmt.Stringer
|
respType proto.Message
|
||||||
expected fmt.Stringer
|
expected proto.Message
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"total supply",
|
name: "total supply",
|
||||||
[]string{
|
args: []string{
|
||||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
false,
|
respType: &types.QueryTotalSupplyResponse{},
|
||||||
&sdk.Coins{},
|
expected: &types.QueryTotalSupplyResponse{
|
||||||
sdk.NewCoins(
|
Supply: sdk.NewCoins(
|
||||||
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens),
|
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens),
|
||||||
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
|
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
|
||||||
),
|
)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"total supply of a specific denomination",
|
name: "total supply of a specific denomination",
|
||||||
[]string{
|
args: []string{
|
||||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||||
fmt.Sprintf("--%s=%s", cli.FlagDenom, s.cfg.BondDenom),
|
fmt.Sprintf("--%s=%s", cli.FlagDenom, s.cfg.BondDenom),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
false,
|
respType: &sdk.Coin{},
|
||||||
&sdk.Coin{},
|
expected: &sdk.Coin{s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))},
|
||||||
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"total supply of a bogus denom",
|
name: "total supply of a bogus denom",
|
||||||
[]string{
|
args: []string{
|
||||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||||
fmt.Sprintf("--%s=foobar", cli.FlagDenom),
|
fmt.Sprintf("--%s=foobar", cli.FlagDenom),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
false,
|
respType: &sdk.Coin{},
|
||||||
&sdk.Coin{},
|
expected: &sdk.Coin{"foobar", sdk.ZeroInt()},
|
||||||
sdk.NewCoin("foobar", sdk.ZeroInt()),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,8 +188,8 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() {
|
||||||
s.Require().Error(err)
|
s.Require().Error(err)
|
||||||
} else {
|
} else {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType), out.String())
|
s.Require().NoError(clientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), tc.respType))
|
||||||
s.Require().Equal(tc.expected.String(), tc.respType.String())
|
s.Require().Equal(tc.expected, tc.respType)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ To query for the total supply of a specific coin denomination use:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Supply)
|
return clientCtx.PrintOutput(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := queryClient.SupplyOf(context.Background(), &types.QuerySupplyOfRequest{Denom: denom})
|
res, err := queryClient.SupplyOf(context.Background(), &types.QuerySupplyOfRequest{Denom: denom})
|
||||||
|
@ -148,7 +148,7 @@ To query for the total supply of a specific coin denomination use:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Amount)
|
return clientCtx.PrintOutput(&res.Amount)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (s *IntegrationTestSuite) SetupTest() {
|
||||||
mintData.Params.InflationMin = inflation
|
mintData.Params.InflationMin = inflation
|
||||||
mintData.Params.InflationMax = inflation
|
mintData.Params.InflationMax = inflation
|
||||||
|
|
||||||
mintDataBz, err := cfg.Codec.MarshalJSON(mintData)
|
mintDataBz, err := cfg.Codec.MarshalJSON(&mintData)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
genesisState[minttypes.ModuleName] = mintDataBz
|
genesisState[minttypes.ModuleName] = mintDataBz
|
||||||
cfg.GenesisState = genesisState
|
cfg.GenesisState = genesisState
|
||||||
|
@ -389,7 +389,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
`[{"denom":"stake","amount":"387.100000000000000000"}]`,
|
`{"rewards":[{"denom":"stake","amount":"387.100000000000000000"}]}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text output",
|
"text output",
|
||||||
|
@ -416,7 +416,8 @@ total:
|
||||||
addr.String(), valAddr.String(),
|
addr.String(), valAddr.String(),
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
`- amount: "387.100000000000000000"
|
`rewards:
|
||||||
|
- amount: "387.100000000000000000"
|
||||||
denom: stake`,
|
denom: stake`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -461,12 +462,13 @@ func (s *IntegrationTestSuite) TestGetCmdQueryCommunityPool() {
|
||||||
{
|
{
|
||||||
"json output",
|
"json output",
|
||||||
[]string{fmt.Sprintf("--%s=3", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
[]string{fmt.Sprintf("--%s=3", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||||
`[{"denom":"stake","amount":"4.740000000000000000"}]`,
|
`{"pool":[{"denom":"stake","amount":"4.740000000000000000"}]}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text output",
|
"text output",
|
||||||
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag), fmt.Sprintf("--%s=3", flags.FlagHeight)},
|
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag), fmt.Sprintf("--%s=3", flags.FlagHeight)},
|
||||||
`- amount: "4.740000000000000000"
|
`pool:
|
||||||
|
- amount: "4.740000000000000000"
|
||||||
denom: stake`,
|
denom: stake`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ func GetCmdQueryParams() *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetParams())
|
return clientCtx.PrintOutput(&res.Params)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ $ %s query distribution validator-outstanding-rewards cosmosvaloper1lwjmdnks33xw
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetRewards())
|
return clientCtx.PrintOutput(&res.Rewards)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ $ %s query distribution commission cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9l
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetCommission())
|
return clientCtx.PrintOutput(&res.Commission)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ $ %s query distribution rewards cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetRewards())
|
return clientCtx.PrintOutput(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := queryClient.DelegationTotalRewards(
|
res, err := queryClient.DelegationTotalRewards(
|
||||||
|
@ -309,7 +309,7 @@ $ %s query distribution community-pool
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetPool())
|
return clientCtx.PrintOutput(res)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ Where proposal.json contains:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
proposal, err := ParseCommunityPoolSpendProposalJSON(clientCtx.JSONMarshaler, args[0])
|
proposal, err := ParseCommunityPoolSpendProposalJSON(clientCtx.LegacyAmino, args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseCommunityPoolSpendProposalJSON reads and parses a CommunityPoolSpendProposalJSON from a file.
|
// ParseCommunityPoolSpendProposalJSON reads and parses a CommunityPoolSpendProposalJSON from a file.
|
||||||
func ParseCommunityPoolSpendProposalJSON(cdc codec.JSONMarshaler, proposalFile string) (CommunityPoolSpendProposalJSON, error) {
|
// TODO: migrate this to protobuf
|
||||||
|
func ParseCommunityPoolSpendProposalJSON(cdc *codec.LegacyAmino, proposalFile string) (CommunityPoolSpendProposalJSON, error) {
|
||||||
proposal := CommunityPoolSpendProposalJSON{}
|
proposal := CommunityPoolSpendProposalJSON{}
|
||||||
|
|
||||||
contents, err := ioutil.ReadFile(proposalFile)
|
contents, err := ioutil.ReadFile(proposalFile)
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/types/query"
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,13 +85,7 @@ func queryEvidence(clientCtx client.Context, hash string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var evidence exported.Evidence
|
return clientCtx.PrintOutput(res.Evidence)
|
||||||
err = clientCtx.InterfaceRegistry.UnpackAny(res.Evidence, &evidence)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return clientCtx.PrintOutput(evidence)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func queryAllEvidence(clientCtx client.Context, pageReq *query.PageRequest) error {
|
func queryAllEvidence(clientCtx client.Context, pageReq *query.PageRequest) error {
|
||||||
|
@ -103,21 +96,9 @@ func queryAllEvidence(clientCtx client.Context, pageReq *query.PageRequest) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := queryClient.AllEvidence(context.Background(), params)
|
res, err := queryClient.AllEvidence(context.Background(), params)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
evidence := make([]exported.Evidence, 0, len(res.Evidence))
|
return clientCtx.PrintOutput(res)
|
||||||
for _, eviAny := range res.Evidence {
|
|
||||||
var evi exported.Evidence
|
|
||||||
err = clientCtx.InterfaceRegistry.UnpackAny(eviAny, &evi)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
evidence = append(evidence, evi)
|
|
||||||
}
|
|
||||||
|
|
||||||
return clientCtx.PrintOutput(evidence)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ $ %s query gov proposal 1
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetProposal())
|
return clientCtx.PrintOutput(&res.Proposal)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetVote())
|
return clientCtx.PrintOutput(&res.Vote)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
|
||||||
|
|
||||||
var votes types.Votes
|
var votes types.Votes
|
||||||
clientCtx.JSONMarshaler.MustUnmarshalJSON(resByTxQuery, &votes)
|
clientCtx.JSONMarshaler.MustUnmarshalJSON(resByTxQuery, &votes)
|
||||||
return clientCtx.PrintOutput(votes)
|
return clientCtx.PrintOutputLegacy(votes)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
|
||||||
clientCtx.JSONMarshaler.MustUnmarshalJSON(resByTxQuery, &deposit)
|
clientCtx.JSONMarshaler.MustUnmarshalJSON(resByTxQuery, &deposit)
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(deposit)
|
return clientCtx.PrintOutput(&deposit)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +447,8 @@ $ %s query gov deposits 1
|
||||||
|
|
||||||
var dep types.Deposits
|
var dep types.Deposits
|
||||||
clientCtx.JSONMarshaler.MustUnmarshalJSON(resByTxQuery, &dep)
|
clientCtx.JSONMarshaler.MustUnmarshalJSON(resByTxQuery, &dep)
|
||||||
return clientCtx.PrintOutput(dep)
|
|
||||||
|
return clientCtx.PrintOutputLegacy(dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
||||||
|
@ -522,7 +523,7 @@ $ %s query gov tally 1
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetTally())
|
return clientCtx.PrintOutput(&res.Tally)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,11 +580,13 @@ $ %s query gov params
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(types.NewParams(
|
params := types.NewParams(
|
||||||
votingRes.GetVotingParams(),
|
votingRes.GetVotingParams(),
|
||||||
tallyRes.GetTallyParams(),
|
tallyRes.GetTallyParams(),
|
||||||
depositRes.GetDepositParams(),
|
depositRes.GetDepositParams(),
|
||||||
))
|
)
|
||||||
|
|
||||||
|
return clientCtx.PrintOutputLegacy(params)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +641,7 @@ $ %s query gov param deposit
|
||||||
return fmt.Errorf("argument must be one of (voting|tallying|deposit), was %s", args[0])
|
return fmt.Errorf("argument must be one of (voting|tallying|deposit), was %s", args[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(out)
|
return clientCtx.PrintOutputLegacy(out)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,7 +683,7 @@ $ %s query gov proposer 1
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(prop)
|
return clientCtx.PrintOutputLegacy(prop)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ func GetCmdQueryClientStates() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
clientCtx = clientCtx.WithHeight(height)
|
clientCtx = clientCtx.WithHeight(height)
|
||||||
return clientCtx.PrintOutput(clientStates)
|
|
||||||
|
return clientCtx.PrintOutputLegacy(clientStates)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ func GetCmdQueryClientState() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
clientCtx = clientCtx.WithHeight(int64(clientStateRes.ProofHeight))
|
clientCtx = clientCtx.WithHeight(int64(clientStateRes.ProofHeight))
|
||||||
return clientCtx.PrintOutput(clientStateRes)
|
return clientCtx.PrintOutputLegacy(clientStateRes)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ func GetCmdQueryConsensusState() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
clientCtx = clientCtx.WithHeight(int64(csRes.ProofHeight))
|
clientCtx = clientCtx.WithHeight(int64(csRes.ProofHeight))
|
||||||
return clientCtx.PrintOutput(csRes)
|
return clientCtx.PrintOutputLegacy(csRes)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ func GetCmdQueryHeader() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
clientCtx = clientCtx.WithHeight(height)
|
clientCtx = clientCtx.WithHeight(height)
|
||||||
return clientCtx.PrintOutput(header)
|
return clientCtx.PrintOutputLegacy(header)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,8 @@ func GetCmdQueryChannelClientState() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
clientCtx = clientCtx.WithHeight(height)
|
clientCtx = clientCtx.WithHeight(height)
|
||||||
return clientCtx.PrintOutput(clientStateRes)
|
|
||||||
|
return clientCtx.PrintOutputLegacy(clientStateRes)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,12 +114,12 @@ func (s *IntegrationTestSuite) TestGetCmdQueryInflation() {
|
||||||
{
|
{
|
||||||
"json output",
|
"json output",
|
||||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||||
`"1.000000000000000000"`,
|
`1.000000000000000000`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text output",
|
"text output",
|
||||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||||
`"1.000000000000000000"`,
|
`1.000000000000000000`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,12 +155,12 @@ func (s *IntegrationTestSuite) TestGetCmdQueryAnnualProvisions() {
|
||||||
{
|
{
|
||||||
"json output",
|
"json output",
|
||||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||||
`"500000000.000000000000000000"`,
|
`500000000.000000000000000000`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text output",
|
"text output",
|
||||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||||
`"500000000.000000000000000000"`,
|
`500000000.000000000000000000`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ func GetCmdQueryParams() *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetParams())
|
return clientCtx.PrintOutput(&res.Params)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ func GetCmdQueryInflation() *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Inflation)
|
return clientCtx.PrintString(fmt.Sprintf("%s\n", res.Inflation))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ func GetCmdQueryAnnualProvisions() *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.AnnualProvisions)
|
return clientCtx.PrintString(fmt.Sprintf("%s\n", res.AnnualProvisions))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ func NewQuerySubspaceParamsCmd() *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.GetParam())
|
return clientCtx.PrintOutput(&res.Param)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ $ <appcli> query slashing signing-info cosmosvalconspub1zcjduepqfhvwcmt7p06fvdge
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.ValSigningInfo)
|
return clientCtx.PrintOutput(&res.ValSigningInfo)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ $ <appcli> query slashing params
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Params)
|
return clientCtx.PrintOutput(&res.Params)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ $ %s query staking validator cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhff
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Validator)
|
return clientCtx.PrintOutput(&res.Validator)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ $ %s query staking validators
|
||||||
validators = append(validators, validator)
|
validators = append(validators, validator)
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(validators)
|
return clientCtx.PrintOutputLegacy(validators)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Unbond)
|
return clientCtx.PrintOutput(&res.Unbond)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,7 +567,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.RedelegationResponses)
|
return clientCtx.PrintOutput(res)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,7 +705,7 @@ $ %s query staking pool
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Pool)
|
return clientCtx.PrintOutput(&res.Pool)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,7 +743,7 @@ $ %s query staking params
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintOutput(res.Params)
|
return clientCtx.PrintOutput(&res.Params)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ func GetAppliedPlanCmd() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return clientCtx.PrintOutput(string(bz))
|
return clientCtx.PrintString(fmt.Sprintf("%s\n", string(bz)))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue