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:
Aaron Craelius
2020-08-11 03:19:49 -04:00
committed by GitHub
co-authored by Anil Kumar Kammari Federico Kunze
parent 20c80cfd44
commit 7de8ef75b3
19 changed files with 95 additions and 99 deletions
+7 -5
View File
@@ -48,7 +48,7 @@ func (s *IntegrationTestSuite) SetupTest() {
mintData.Params.InflationMin = inflation
mintData.Params.InflationMax = inflation
mintDataBz, err := cfg.Codec.MarshalJSON(mintData)
mintDataBz, err := cfg.Codec.MarshalJSON(&mintData)
s.Require().NoError(err)
genesisState[minttypes.ModuleName] = mintDataBz
cfg.GenesisState = genesisState
@@ -389,7 +389,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
},
false,
`[{"denom":"stake","amount":"387.100000000000000000"}]`,
`{"rewards":[{"denom":"stake","amount":"387.100000000000000000"}]}`,
},
{
"text output",
@@ -416,7 +416,8 @@ total:
addr.String(), valAddr.String(),
},
false,
`- amount: "387.100000000000000000"
`rewards:
- amount: "387.100000000000000000"
denom: stake`,
},
}
@@ -461,12 +462,13 @@ func (s *IntegrationTestSuite) TestGetCmdQueryCommunityPool() {
{
"json output",
[]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",
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag), fmt.Sprintf("--%s=3", flags.FlagHeight)},
`- amount: "4.740000000000000000"
`pool:
- amount: "4.740000000000000000"
denom: stake`,
},
}
+5 -5
View File
@@ -56,7 +56,7 @@ func GetCmdQueryParams() *cobra.Command {
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 clientCtx.PrintOutput(res.GetRewards())
return clientCtx.PrintOutput(&res.Rewards)
},
}
@@ -145,7 +145,7 @@ $ %s query distribution commission cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9l
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 clientCtx.PrintOutput(res.GetRewards())
return clientCtx.PrintOutput(res)
}
res, err := queryClient.DelegationTotalRewards(
@@ -309,7 +309,7 @@ $ %s query distribution community-pool
return err
}
return clientCtx.PrintOutput(res.GetPool())
return clientCtx.PrintOutput(res)
},
}
+1 -1
View File
@@ -287,7 +287,7 @@ Where proposal.json contains:
return err
}
proposal, err := ParseCommunityPoolSpendProposalJSON(clientCtx.JSONMarshaler, args[0])
proposal, err := ParseCommunityPoolSpendProposalJSON(clientCtx.LegacyAmino, args[0])
if err != nil {
return err
}
+2 -1
View File
@@ -19,7 +19,8 @@ type (
)
// 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{}
contents, err := ioutil.ReadFile(proposalFile)