From 699ee59bd1c92ec17d2b4bf07b839ac5319bf7df Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Mon, 30 Mar 2020 14:38:57 +0100 Subject: [PATCH] move shutdown permission to own branch --- x/committee/types/codec.go | 2 +- x/committee/types/permissions.go | 37 ++------------------------------ 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/x/committee/types/codec.go b/x/committee/types/codec.go index 8da0a9d3..95c0e7f2 100644 --- a/x/committee/types/codec.go +++ b/x/committee/types/codec.go @@ -20,7 +20,7 @@ func init() { func RegisterModuleCodec(cdc *codec.Codec) { cdc.RegisterInterface((*gov.Content)(nil), nil) // registering the Content interface on the ModuleCdc will not conflict with gov. - // Ideally dist and params would register their proposals on here at their init. However can't change them so: + // Ideally dist and params would register their proposals on here at their init. However don't want to fork them so: cdc.RegisterConcrete(distribution.CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil) cdc.RegisterConcrete(params.ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) cdc.RegisterConcrete(gov.TextProposal{}, "cosmos-sdk/TextProposal", nil) diff --git a/x/committee/types/permissions.go b/x/committee/types/permissions.go index 28a1d534..fcb1c0a4 100644 --- a/x/committee/types/permissions.go +++ b/x/committee/types/permissions.go @@ -3,16 +3,14 @@ package types import ( "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/params" - sdtypes "github.com/kava-labs/kava/x/shutdown/types" ) func init() { - // Gov proposals need to be registered on gov's ModuleCdc. - // But since proposals contain Permissions, those types also need registering. + // CommitteeChange/Delete proposals need to be registered on gov's ModuleCdc. + // But since these proposals contain Permissions, these types also need registering: gov.ModuleCdc.RegisterInterface((*Permission)(nil), nil) gov.RegisterProposalTypeCodec(GodPermission{}, "kava/GodPermission") gov.RegisterProposalTypeCodec(ParamChangePermission{}, "kava/ParamChangePermission") - gov.RegisterProposalTypeCodec(ShutdownPermission{}, "kava/ShutdownPermission") } // GodPermission allows any governance proposal. It is used mainly for testing. @@ -78,37 +76,6 @@ func (allowed AllowedParams) Contains(paramChange params.ParamChange) bool { return false } -// ShutdownPermission allows certain message types to be disabled -type ShutdownPermission struct { - MsgRoute sdtypes.MsgRoute `json:"msg_route" yaml:"msg_route"` -} - -var _ Permission = ShutdownPermission{} - -func (perm ShutdownPermission) Allows(p gov.Content) bool { - proposal, ok := p.(sdtypes.ShutdownProposal) - if !ok { - return false - } - for _, r := range proposal.MsgRoutes { - if r == perm.MsgRoute { - return true - } - } - return false -} - -func (perm ShutdownPermission) MarshalYAML() (interface{}, error) { - valueToMarshal := struct { - Type string `yaml:"type"` - MsgRoute sdtypes.MsgRoute `yaml:"msg_route"` - }{ - Type: "shutdown_permission", - MsgRoute: perm.MsgRoute, - } - return valueToMarshal, nil -} - // TODO add more permissions? // - limit parameter changes to be within small ranges // - allow community spend proposals