-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathrestrictions.go
More file actions
67 lines (61 loc) · 2.54 KB
/
restrictions.go
File metadata and controls
67 lines (61 loc) · 2.54 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package restrictions
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/dfinance/dnode/cmd/config/genesis/defaults"
"github.com/dfinance/dnode/x/currencies"
)
// Custom restriction params for application
type AppRestrictions struct {
CustomMsgVerifiers func(msg sdk.Msg) error
MsgDeniedList map[string][]string
ParamsProposal params.RestrictedParams
DisabledTxCmd []string
DisabledQueryCmd []string
}
// GetEmptyAppRestriction returns AppRestrictions with no restrictions.
func GetEmptyAppRestriction() AppRestrictions {
return AppRestrictions{
DisabledTxCmd: []string{},
DisabledQueryCmd: []string{},
MsgDeniedList: map[string][]string{},
ParamsProposal: params.RestrictedParams{},
CustomMsgVerifiers: func(msg sdk.Msg) error { return nil },
}
}
//GetAppRestrictions returns predefined parameter for remove or restrict standard app parameters.
func GetAppRestrictions() AppRestrictions {
return AppRestrictions{
DisabledTxCmd: []string{},
DisabledQueryCmd: []string{},
MsgDeniedList: map[string][]string{
currencies.ModuleName: {
currencies.MsgWithdrawCurrency{}.Type(),
},
},
ParamsProposal: params.RestrictedParams{
params.RestrictedParam{Subspace: distribution.ModuleName, Key: string(distribution.ParamKeyValidatorsPoolTax)},
params.RestrictedParam{Subspace: distribution.ModuleName, Key: string(distribution.ParamKeyLiquidityProvidersPoolTax)},
params.RestrictedParam{Subspace: distribution.ModuleName, Key: string(distribution.ParamKeyPublicTreasuryPoolTax)},
params.RestrictedParam{Subspace: distribution.ModuleName, Key: string(distribution.ParamKeyHARPTax)},
params.RestrictedParam{Subspace: distribution.ModuleName, Key: string(distribution.ParamKeyFoundationNominees)},
params.RestrictedParam{Subspace: mint.ModuleName, Key: string(mint.KeyFoundationAllocationRatio)},
params.RestrictedParam{Subspace: mint.ModuleName, Key: string(mint.KeyStakingTotalSupplyShift)},
},
CustomMsgVerifiers: func(msg sdk.Msg) error {
switch msg := msg.(type) {
case bank.MsgSend:
for i := range msg.Amount {
if msg.Amount.GetDenomByIndex(i) == defaults.LiquidityProviderDenom {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "bank transactions are disallowed for %s token", msg.Amount.GetDenomByIndex(i))
}
}
}
return nil
},
}
}