/
params.go
62 lines (49 loc) · 1.3 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
package types
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
appparams "github.com/osmosis-labs/osmosis/v7/app/params"
)
// Parameter store keys
var (
KeyPoolCreationFee = []byte("PoolCreationFee")
)
// ParamTable for gamm module.
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
func NewParams(poolCreationFee sdk.Coins) Params {
return Params{
PoolCreationFee: poolCreationFee,
}
}
// default gamm module parameters
func DefaultParams() Params {
return Params{
PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO
}
}
// validate params
func (p Params) Validate() error {
if err := validatePoolCreationFee(p.PoolCreationFee); err != nil {
return err
}
return nil
}
// Implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee),
}
}
func validatePoolCreationFee(i interface{}) error {
v, ok := i.(sdk.Coins)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.Validate() != nil {
return fmt.Errorf("invalid pool creation fee: %+v", i)
}
return nil
}