Apply suggestions from code review

Co-Authored-By: Denali Marsh <denali@kava.io>
Co-Authored-By: Kevin Davis <karzak@users.noreply.github.com>
This commit is contained in:
Ruaridh 2020-04-24 19:15:57 +01:00 committed by GitHub
parent 5dcbe73c62
commit 73dc488239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 12 additions and 12 deletions

View File

@ -40,7 +40,7 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
return govQueryCmd return govQueryCmd
} }
// GetCmdQueryProposals implements a query proposals command. // GetCmdQueryCommittees implements a query committees command.
func GetCmdQueryCommittees(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryCommittees(queryRoute string, cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "committees", Use: "committees",

View File

@ -189,7 +189,7 @@ func mustGetExampleCommitteeChangeProposal(cdc *codec.Codec) string {
types.NewCommittee( types.NewCommittee(
1, 1,
"The description of this committee.", "The description of this committee.",
[]sdk.AccAddress{sdk.AccAddress(crypto.AddressHash([]byte("exampleAddres")))}, []sdk.AccAddress{sdk.AccAddress(crypto.AddressHash([]byte("exampleAddress")))},
[]types.Permission{ []types.Permission{
types.ParamChangePermission{ types.ParamChangePermission{
AllowedParams: types.AllowedParams{{Subspace: "cdp", Key: "CircuitBreaker"}}, AllowedParams: types.AllowedParams{{Subspace: "cdp", Key: "CircuitBreaker"}},

View File

@ -190,6 +190,7 @@ func queryProposerHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
} }
// Write response // Write response
cliCtx = cliCtx.WithHeight(height)
rest.PostProcessResponse(w, cliCtx, res) rest.PostProcessResponse(w, cliCtx, res)
} }
} }
@ -209,7 +210,7 @@ func queryVotesOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// Prepare params for querier // Prepare params for querier
vars := mux.Vars(r) vars := mux.Vars(r)
if len(vars[RestProposalID]) == 0 { if len(vars[RestProposalID]) == 0 {
err := errors.New("proposalID required but not specified") err := errors.New(fmt.Sprintf("%s required but not specified", RestProposalID))
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return return
} }
@ -247,7 +248,7 @@ func queryTallyOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// Prepare params for querier // Prepare params for querier
vars := mux.Vars(r) vars := mux.Vars(r)
if len(vars[RestProposalID]) == 0 { if len(vars[RestProposalID]) == 0 {
err := errors.New("proposalID required but not specified") err := errors.New(fmt.Sprintf("%s required but not specified", RestProposalID))
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return return
} }

View File

@ -34,7 +34,7 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// Parse and validate url params // Parse and validate url params
vars := mux.Vars(r) vars := mux.Vars(r)
if len(vars[RestCommitteeID]) == 0 { if len(vars[RestCommitteeID]) == 0 {
rest.WriteErrorResponse(w, http.StatusBadRequest, "committeeID required but not specified") rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("%s required but not specified", RestCommitteeID))
return return
} }
committeeID, ok := rest.ParseUint64OrReturnBadRequest(w, vars[RestCommitteeID]) committeeID, ok := rest.ParseUint64OrReturnBadRequest(w, vars[RestCommitteeID])
@ -78,7 +78,7 @@ func postVoteHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// Parse and validate url params // Parse and validate url params
vars := mux.Vars(r) vars := mux.Vars(r)
if len(vars[RestProposalID]) == 0 { if len(vars[RestProposalID]) == 0 {
rest.WriteErrorResponse(w, http.StatusBadRequest, "proposalID required but not specified") rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("%s required but not specified", RestProposalID))
return return
} }
proposalID, ok := rest.ParseUint64OrReturnBadRequest(w, vars[RestProposalID]) proposalID, ok := rest.ParseUint64OrReturnBadRequest(w, vars[RestProposalID])

View File

@ -61,7 +61,7 @@ func (suite *KeeperTestSuite) TestGetSetDeleteCommittee() {
suite.False(found) suite.False(found)
} }
func (suite *KeeperTestSuite) TestGetSetProposal() { func (suite *KeeperTestSuite) TestGetSetDeleteProposal() {
// test setup // test setup
prop := types.Proposal{ prop := types.Proposal{
ID: 12, ID: 12,
@ -86,7 +86,7 @@ func (suite *KeeperTestSuite) TestGetSetProposal() {
suite.False(found) suite.False(found)
} }
func (suite *KeeperTestSuite) TestGetSetVote() { func (suite *KeeperTestSuite) TestGetSetDeleteVote() {
// test setup // test setup
vote := types.Vote{ vote := types.Vote{
ProposalID: 12, ProposalID: 12,

View File

@ -29,7 +29,7 @@ func RegisterModuleCodec(cdc *codec.Codec) {
RegisterAppCodec(cdc) RegisterAppCodec(cdc)
} }
// RegisterCodec registers the necessary types for the module // RegisterAppCodec registers the necessary types for the module
func RegisterAppCodec(cdc *codec.Codec) { func RegisterAppCodec(cdc *codec.Codec) {
// Proposals // Proposals
// The app codec needs the gov.Content type registered. This is done by the gov module. // The app codec needs the gov.Content type registered. This is done by the gov module.

View File

@ -41,7 +41,7 @@ func (ccp CommitteeChangeProposal) GetTitle() string { return ccp.Title }
// GetDescription returns the description of the proposal. // GetDescription returns the description of the proposal.
func (ccp CommitteeChangeProposal) GetDescription() string { return ccp.Description } func (ccp CommitteeChangeProposal) GetDescription() string { return ccp.Description }
// GetDescription returns the routing key of the proposal. // ProposalRoute returns the routing key of the proposal.
func (ccp CommitteeChangeProposal) ProposalRoute() string { return RouterKey } func (ccp CommitteeChangeProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of the proposal. // ProposalType returns the type of the proposal.
@ -93,7 +93,7 @@ func (cdp CommitteeDeleteProposal) GetTitle() string { return cdp.Title }
// GetDescription returns the description of the proposal. // GetDescription returns the description of the proposal.
func (cdp CommitteeDeleteProposal) GetDescription() string { return cdp.Description } func (cdp CommitteeDeleteProposal) GetDescription() string { return cdp.Description }
// GetDescription returns the routing key of the proposal. // ProposalRoute returns the routing key of the proposal.
func (cdp CommitteeDeleteProposal) ProposalRoute() string { return RouterKey } func (cdp CommitteeDeleteProposal) ProposalRoute() string { return RouterKey }
// ProposalType returns the type of the proposal. // ProposalType returns the type of the proposal.

View File

@ -6,7 +6,6 @@ import (
// Query endpoints supported by the Querier // Query endpoints supported by the Querier
const ( const (
//QueryParams = "params"
QueryCommittees = "committees" QueryCommittees = "committees"
QueryCommittee = "committee" QueryCommittee = "committee"
QueryProposals = "proposals" QueryProposals = "proposals"