-
Notifications
You must be signed in to change notification settings - Fork 0
/
proposals_whitelisting.go
48 lines (42 loc) · 1.44 KB
/
proposals_whitelisting.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package app
import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
)
func IsProposalWhitelisted(content govtypes.Content) bool {
switch c := content.(type) {
case *proposal.ParameterChangeProposal:
return isParamChangeWhitelisted(c.Changes)
case *upgradetypes.SoftwareUpgradeProposal,
*upgradetypes.CancelSoftwareUpgradeProposal:
return true
default:
return false
}
}
func isParamChangeWhitelisted(paramChanges []proposal.ParamChange) bool {
for _, paramChange := range paramChanges {
_, found := WhitelistedParams[paramChangeKey{Subspace: paramChange.Subspace, Key: paramChange.Key}]
if !found {
return false
}
}
return true
}
type paramChangeKey struct {
Subspace, Key string
}
var WhitelistedParams = map[paramChangeKey]struct{}{
// bank
{Subspace: banktypes.ModuleName, Key: "SendEnabled"}: {},
// ibc transfer
{Subspace: ibctransfertypes.ModuleName, Key: "SendEnabled"}: {},
{Subspace: ibctransfertypes.ModuleName, Key: "ReceiveEnabled"}: {},
// ica
{Subspace: icahosttypes.SubModuleName, Key: "HostEnabled"}: {},
{Subspace: icahosttypes.SubModuleName, Key: "AllowMessages"}: {},
}