mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
move shutdown permission to own branch
This commit is contained in:
parent
98a044d7af
commit
699ee59bd1
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user