/
params.go
68 lines (55 loc) · 1.66 KB
/
params.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package types
import (
"errors"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
const (
// DefaultPoolMigrationLimit is the max number of pools that can be migrated at once.
// Note that 20 was chosen arbitrarily to have a constant bound on the number of pools migrated.
DefaultPoolMigrationLimit = 20
)
// Parameter store keys.
var (
KeyCodeIdWhitelist = []byte("CodeIdWhitelist")
KeyPoolMigrationLimit = []byte("PoolMigrationLimit")
)
// ParamTable for cosmwasmpool module.
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
func NewParams() Params {
return Params{
CodeIdWhitelist: []uint64{},
}
}
// DefaultParams are the default cosmwasmpool module parameters.
func DefaultParams() Params {
return Params{
CodeIdWhitelist: []uint64{},
PoolMigrationLimit: DefaultPoolMigrationLimit,
}
}
// Validate validates params.
func (p Params) Validate() error {
return validateCodeIdWhitelist(p.CodeIdWhitelist)
}
// Implements params.ParamSet.
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyCodeIdWhitelist, &p.CodeIdWhitelist, validateCodeIdWhitelist),
paramtypes.NewParamSetPair(KeyPoolMigrationLimit, &p.PoolMigrationLimit, validatePoolMigrationLimit),
}
}
func validateCodeIdWhitelist(value interface{}) error {
return nil
}
func validatePoolMigrationLimit(value interface{}) error {
poolMigrationLimit, ok := value.(uint64)
if !ok {
return errors.New("invalid type for pool migration limit")
}
if poolMigrationLimit == 0 {
return errors.New("pool migration limit must be greater than 0")
}
return nil
}