address TODOs

This commit is contained in:
rhuairahrighairigh 2020-03-29 21:05:08 +01:00
parent 058e3981c5
commit ace9a2363e
7 changed files with 11 additions and 45 deletions

View File

@ -35,7 +35,7 @@ func (suite *ModuleTestSuite) SetupTest() {
func (suite *ModuleTestSuite) TestBeginBlock() { func (suite *ModuleTestSuite) TestBeginBlock() {
suite.app.InitializeFromGenesisStates() suite.app.InitializeFromGenesisStates()
// TODO replace below with genesis state
normalCom := committee.Committee{ normalCom := committee.Committee{
ID: 12, ID: 12,
Members: suite.addresses[:2], Members: suite.addresses[:2],

View File

@ -27,14 +27,13 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
} }
govQueryCmd.AddCommand(client.GetCommands( govQueryCmd.AddCommand(client.GetCommands(
// GetCmdQueryCommittee(queryRoute, cdc), // TODO is this needed?
GetCmdQueryCommittees(queryRoute, cdc), GetCmdQueryCommittees(queryRoute, cdc),
GetCmdQueryProposal(queryRoute, cdc), GetCmdQueryProposal(queryRoute, cdc),
GetCmdQueryProposals(queryRoute, cdc), GetCmdQueryProposals(queryRoute, cdc),
GetCmdQueryVotes(queryRoute, cdc), GetCmdQueryVotes(queryRoute, cdc),
//TODO GetCmdQueryParams(queryRoute, cdc),
GetCmdQueryProposer(queryRoute, cdc), GetCmdQueryProposer(queryRoute, cdc),
GetCmdQueryTally(queryRoute, cdc))...) GetCmdQueryTally(queryRoute, cdc))...)
@ -167,7 +166,7 @@ func GetCmdQueryVotes(queryRoute string, cdc *codec.Codec) *cobra.Command {
} }
// Decode and print results // Decode and print results
votes := []types.Vote{} // using empty (not nil) slice so json returns [] instead of null when there's no data // TODO check votes := []types.Vote{} // using empty (not nil) slice so json returns [] instead of null when there's no data
err = cdc.UnmarshalJSON(res, &votes) err = cdc.UnmarshalJSON(res, &votes)
if err != nil { if err != nil {
return err return err

View File

@ -10,9 +10,11 @@ import (
"github.com/kava-labs/kava/x/committee/types" "github.com/kava-labs/kava/x/committee/types"
) )
// Note: QueryProposer is copied in from the gov module
const ( const (
defaultPage = 1 defaultPage = 1
defaultLimit = 30 // should be consistent with tendermint/tendermint/rpc/core/pipe.go:19 // TODO what is this? defaultLimit = 30 // should be consistent with tendermint/tendermint/rpc/core/pipe.go:19
) )
// Proposer contains metadata of a governance proposal used for querying a proposer. // Proposer contains metadata of a governance proposal used for querying a proposer.

View File

@ -22,7 +22,6 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) {
r.HandleFunc(fmt.Sprintf("/%s/proposals/{%s}/proposer", types.ModuleName, RestProposalID), queryProposerHandlerFn(cliCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/proposals/{%s}/proposer", types.ModuleName, RestProposalID), queryProposerHandlerFn(cliCtx)).Methods("GET")
r.HandleFunc(fmt.Sprintf("/%s/proposals/{%s}/tally", types.ModuleName, RestProposalID), queryTallyOnProposalHandlerFn(cliCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/proposals/{%s}/tally", types.ModuleName, RestProposalID), queryTallyOnProposalHandlerFn(cliCtx)).Methods("GET")
r.HandleFunc(fmt.Sprintf("/%s/proposals/{%s}/votes", types.ModuleName, RestProposalID), queryVotesOnProposalHandlerFn(cliCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/proposals/{%s}/votes", types.ModuleName, RestProposalID), queryVotesOnProposalHandlerFn(cliCtx)).Methods("GET")
// TODO r.HandleFunc(fmt.Sprintf("/%s/parameters/{%s}", types.ModuleName, RestParamsType), queryParamsHandlerFn(cliCtx)).Methods("GET")
} }
// ---------- Committees ---------- // ---------- Committees ----------
@ -289,27 +288,3 @@ func queryTallyOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
rest.PostProcessResponse(w, cliCtx, res) rest.PostProcessResponse(w, cliCtx, res)
} }
} }
// ---------- Params ----------
// TODO
// func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
// return func(w http.ResponseWriter, r *http.Request) {
// vars := mux.Vars(r)
// paramType := vars[RestParamsType]
// cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r)
// if !ok {
// return
// }
// res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/gov/%s/%s", types.QueryParams, paramType), nil)
// if err != nil {
// rest.WriteErrorResponse(w, http.StatusNotFound, err.Error())
// return
// }
// cliCtx = cliCtx.WithHeight(height)
// rest.PostProcessResponse(w, cliCtx, res)
// }
// }

View File

@ -60,7 +60,7 @@ func (ccp CommitteeChangeProposal) ValidateBasic() sdk.Error {
// String implements the Stringer interface. // String implements the Stringer interface.
func (ccp CommitteeChangeProposal) String() string { func (ccp CommitteeChangeProposal) String() string {
bz, _ := yaml.Marshal(ccp) // TODO test bz, _ := yaml.Marshal(ccp)
return string(bz) return string(bz)
} }
@ -109,6 +109,6 @@ func (cdp CommitteeDeleteProposal) ValidateBasic() sdk.Error {
// String implements the Stringer interface. // String implements the Stringer interface.
func (cdp CommitteeDeleteProposal) String() string { func (cdp CommitteeDeleteProposal) String() string {
bz, _ := yaml.Marshal(cdp) // TODO test bz, _ := yaml.Marshal(cdp)
return string(bz) return string(bz)
} }

View File

@ -16,7 +16,6 @@ func init() {
} }
// GodPermission allows any governance proposal. It is used mainly for testing. // GodPermission allows any governance proposal. It is used mainly for testing.
// TODO better name?
type GodPermission struct{} type GodPermission struct{}
var _ Permission = GodPermission{} var _ Permission = GodPermission{}

View File

@ -2,11 +2,11 @@ package types
import ( import (
"fmt" "fmt"
"strings"
"time" "time"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
"gopkg.in/yaml.v2"
) )
const MaxCommitteeDescriptionLength int = 5000 const MaxCommitteeDescriptionLength int = 5000
@ -114,17 +114,8 @@ func (p Proposal) HasExpiredBy(time time.Time) bool {
// String implements the fmt.Stringer interface, and importantly overrides the String methods inherited from the embedded PubProposal type. // String implements the fmt.Stringer interface, and importantly overrides the String methods inherited from the embedded PubProposal type.
func (p Proposal) String() string { func (p Proposal) String() string {
return strings.TrimSpace(fmt.Sprintf(`Proposal: bz, _ := yaml.Marshal(p)
PubProposal: return string(bz)
%s
ID: %d
Committee ID: %d
Deadline: %s`,
p.PubProposal,
p.ID,
p.CommitteeID,
p.Deadline,
))
} }
type Vote struct { type Vote struct {