From cae6cb196cdfa6f9dc7c395df72903a7c068cd6a Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Tue, 10 Mar 2020 21:41:10 +0000 Subject: [PATCH] make builds pass --- x/committee/abci.go | 18 ++++++++--------- x/committee/handler.go | 4 +++- x/committee/keeper/keeper.go | 33 +++++++++++++++++++++++++++----- x/committee/types/permissions.go | 14 +++++++------- x/committee/types/types.go | 7 ++++++- 5 files changed, 53 insertions(+), 23 deletions(-) diff --git a/x/committee/abci.go b/x/committee/abci.go index 50bb9dc2..54e706d8 100644 --- a/x/committee/abci.go +++ b/x/committee/abci.go @@ -1,12 +1,12 @@ package committee -func BeginBlocker() { - // TODO much the same as the current gov endblocker does +// func BeginBlocker() { +// // TODO much the same as the current gov endblocker does - // Get all active proposals - // If voting periods are over, tally up the results - // If a proposal passes run it through the correct handler - // Handler need to be registered in app.go as they are for the current gov module - handler := keeper.Router().GetRoute(proposal.ProposalRoute()) - err := handler(ctx, proposal.Content) -} +// // Get all active proposals +// // If voting periods are over, tally up the results +// // If a proposal passes run it through the correct handler +// // Handler need to be registered in app.go as they are for the current gov module +// handler := keeper.Router().GetRoute(proposal.ProposalRoute()) +// err := handler(ctx, proposal.Content) +// } diff --git a/x/committee/handler.go b/x/committee/handler.go index bc23eb5a..f3f9b03f 100644 --- a/x/committee/handler.go +++ b/x/committee/handler.go @@ -1,13 +1,14 @@ package committee // committee, subcommittee, council, caucus, commission, synod, board - +/* import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/kava-labs/kava/x/committee/keeper" + "github.com/kava-labs/kava/x/committee/types" ) @@ -45,3 +46,4 @@ func handleMsgVote(ctx sdk.Context, k keeper.Keeper, msg types.MsgVote) sdk.Resu return sdk.Result{} } +*/ diff --git a/x/committee/keeper/keeper.go b/x/committee/keeper/keeper.go index 8dc5158d..3952f0e1 100644 --- a/x/committee/keeper/keeper.go +++ b/x/committee/keeper/keeper.go @@ -1,4 +1,4 @@ -package types +package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" @@ -29,20 +29,20 @@ type Keeper struct { */ -func (k Keeper) SubmitProposal(ctx sdk.Context, msg types.MsgSubmitProposal) sdk.Error { +func (k Keeper) SubmitProposal(ctx sdk.Context, proposal types.Proposal) sdk.Error { // TODO Limit proposals to only be submitted by group members // Check group has permissions to enact proposal. As long as one permission allows the proposal then it goes through. Its the OR of all permissions. - committee, _ := k.GetCommittee(ctx, msg.CommitteeID) + committee, _ := k.GetCommittee(ctx, proposal.CommitteeID) hasPermissions := false for _, p := range committee.Permissions { - if p.Allows(msg.Proposal) { + if p.Allows(proposal) { hasPermissions = true break } } if !hasPermissions { - return sdk.ErrInternal("committee does not have permissions to enact proposal").Result() + return sdk.ErrInternal("committee does not have permissions to enact proposal") } // TODO validate proposal by running it with cached context like how gov does it @@ -59,3 +59,26 @@ func (k Keeper) AddVote(ctx sdk.Context, msg types.MsgVote) sdk.Error { */ return nil } + +// -------------------- + +func (k Keeper) GetCommittee(ctx sdk.Context, committeeID uint64) (types.Committee, bool) { + return types.Committee{}, false +} +func (k Keeper) SetCommittee(ctx sdk.Context, committee types.Committee) { + +} + +func (k Keeper) GetVote(ctx sdk.Context, voteID uint64) (types.Vote, bool) { + return types.Vote{}, false +} +func (k Keeper) SetVote(ctx sdk.Context, vote types.Vote) { + +} + +func (k Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Proposal, bool) { + return types.Proposal{}, false +} +func (k Keeper) SetProposal(ctx sdk.Context, proposal types.Proposal) { + +} diff --git a/x/committee/types/permissions.go b/x/committee/types/permissions.go index d560296d..8338ea1d 100644 --- a/x/committee/types/permissions.go +++ b/x/committee/types/permissions.go @@ -11,10 +11,10 @@ import ( // Allow only changes to inflation_rate type InflationRateChangePermission struct{} -var _ types.Permission = InflationRateChangePermission +var _ Permission = InflationRateChangePermission{} -func (InflationRateChangePermission) Allows(p gov.Proposal) bool { - pcp, ok := p.Content.(params.ParameterChangeProposal) +func (InflationRateChangePermission) Allows(p gov.Content) bool { + pcp, ok := p.(params.ParameterChangeProposal) if !ok { return false } @@ -29,7 +29,7 @@ func (InflationRateChangePermission) Allows(p gov.Proposal) bool { // Allow only shutdown of the CDP Deposit msg type ShutdownCDPDepsitPermission struct{} -var _ types.Permission = ShutdownCDPDepsitPermission +var _ Permission = ShutdownCDPDepsitPermission{} func (ShutdownCDPDepsitPermission) Allows(p gov.Content) bool { sdp, ok := p.(sdtypes.ShutdownProposal) @@ -46,13 +46,13 @@ func (ShutdownCDPDepsitPermission) Allows(p gov.Content) bool { // Same as above but the route isn't static type GeneralShutdownPermission struct { - MsgRoute cbtypes.MsgRoute + MsgRoute sdtypes.MsgRoute } -var _ types.Permission = GeneralShutdownPermission +var _ Permission = GeneralShutdownPermission{} func (perm GeneralShutdownPermission) Allows(p gov.Content) bool { - sdp, ok := p.Content.(sdtypes.ShutdownProposal) + sdp, ok := p.(sdtypes.ShutdownProposal) if !ok { return false } diff --git a/x/committee/types/types.go b/x/committee/types/types.go index 2994a179..0aac38b7 100644 --- a/x/committee/types/types.go +++ b/x/committee/types/types.go @@ -22,8 +22,9 @@ type Permission interface { type Proposal struct { gov.Content ID uint64 - committeeID uint64 + CommitteeID uint64 // TODO + // could store votes on the proposal object } type Vote struct { @@ -31,3 +32,7 @@ type Vote struct { Voter sdk.AccAddress Option byte } + +// Genesis ------------------- +// Ok just to dump everything to json and reload - if time involved then begin blocker will take care of closing expired proposals. And it won't enact proposals because they would've been immediately enacted before the halt if they passed. +// committee, proposals, votes