mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +00:00
make builds pass
This commit is contained in:
parent
54c2e44a2d
commit
cae6cb196c
@ -1,12 +1,12 @@
|
|||||||
package committee
|
package committee
|
||||||
|
|
||||||
func BeginBlocker() {
|
// func BeginBlocker() {
|
||||||
// TODO much the same as the current gov endblocker does
|
// // TODO much the same as the current gov endblocker does
|
||||||
|
|
||||||
// Get all active proposals
|
// // Get all active proposals
|
||||||
// If voting periods are over, tally up the results
|
// // If voting periods are over, tally up the results
|
||||||
// If a proposal passes run it through the correct handler
|
// // 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 need to be registered in app.go as they are for the current gov module
|
||||||
handler := keeper.Router().GetRoute(proposal.ProposalRoute())
|
// handler := keeper.Router().GetRoute(proposal.ProposalRoute())
|
||||||
err := handler(ctx, proposal.Content)
|
// err := handler(ctx, proposal.Content)
|
||||||
}
|
// }
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package committee
|
package committee
|
||||||
|
|
||||||
// committee, subcommittee, council, caucus, commission, synod, board
|
// committee, subcommittee, council, caucus, commission, synod, board
|
||||||
|
/*
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/committee/keeper"
|
"github.com/kava-labs/kava/x/committee/keeper"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/committee/types"
|
"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{}
|
return sdk.Result{}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package types
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
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
|
// 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.
|
// 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
|
hasPermissions := false
|
||||||
for _, p := range committee.Permissions {
|
for _, p := range committee.Permissions {
|
||||||
if p.Allows(msg.Proposal) {
|
if p.Allows(proposal) {
|
||||||
hasPermissions = true
|
hasPermissions = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !hasPermissions {
|
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
|
// 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
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -11,10 +11,10 @@ import (
|
|||||||
// Allow only changes to inflation_rate
|
// Allow only changes to inflation_rate
|
||||||
type InflationRateChangePermission struct{}
|
type InflationRateChangePermission struct{}
|
||||||
|
|
||||||
var _ types.Permission = InflationRateChangePermission
|
var _ Permission = InflationRateChangePermission{}
|
||||||
|
|
||||||
func (InflationRateChangePermission) Allows(p gov.Proposal) bool {
|
func (InflationRateChangePermission) Allows(p gov.Content) bool {
|
||||||
pcp, ok := p.Content.(params.ParameterChangeProposal)
|
pcp, ok := p.(params.ParameterChangeProposal)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ func (InflationRateChangePermission) Allows(p gov.Proposal) bool {
|
|||||||
// Allow only shutdown of the CDP Deposit msg
|
// Allow only shutdown of the CDP Deposit msg
|
||||||
type ShutdownCDPDepsitPermission struct{}
|
type ShutdownCDPDepsitPermission struct{}
|
||||||
|
|
||||||
var _ types.Permission = ShutdownCDPDepsitPermission
|
var _ Permission = ShutdownCDPDepsitPermission{}
|
||||||
|
|
||||||
func (ShutdownCDPDepsitPermission) Allows(p gov.Content) bool {
|
func (ShutdownCDPDepsitPermission) Allows(p gov.Content) bool {
|
||||||
sdp, ok := p.(sdtypes.ShutdownProposal)
|
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
|
// Same as above but the route isn't static
|
||||||
type GeneralShutdownPermission struct {
|
type GeneralShutdownPermission struct {
|
||||||
MsgRoute cbtypes.MsgRoute
|
MsgRoute sdtypes.MsgRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ types.Permission = GeneralShutdownPermission
|
var _ Permission = GeneralShutdownPermission{}
|
||||||
|
|
||||||
func (perm GeneralShutdownPermission) Allows(p gov.Content) bool {
|
func (perm GeneralShutdownPermission) Allows(p gov.Content) bool {
|
||||||
sdp, ok := p.Content.(sdtypes.ShutdownProposal)
|
sdp, ok := p.(sdtypes.ShutdownProposal)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,9 @@ type Permission interface {
|
|||||||
type Proposal struct {
|
type Proposal struct {
|
||||||
gov.Content
|
gov.Content
|
||||||
ID uint64
|
ID uint64
|
||||||
committeeID uint64
|
CommitteeID uint64
|
||||||
// TODO
|
// TODO
|
||||||
|
// could store votes on the proposal object
|
||||||
}
|
}
|
||||||
|
|
||||||
type Vote struct {
|
type Vote struct {
|
||||||
@ -31,3 +32,7 @@ type Vote struct {
|
|||||||
Voter sdk.AccAddress
|
Voter sdk.AccAddress
|
||||||
Option byte
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user