-
Notifications
You must be signed in to change notification settings - Fork 45
/
genesis.go
59 lines (49 loc) · 1.39 KB
/
genesis.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
package types
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
microtxtypes "github.com/althea-net/althea-L1/x/microtx/types"
)
// DefaultGenesisState creates a simple GenesisState suitible for testing
func DefaultGenesisState() *GenesisState {
return &GenesisState{
Params: DefaultParams(),
}
}
func DefaultParams() *Params {
return &Params{
GasFreeMessageTypes: []string{
// nolint: exhaustruct
sdk.MsgTypeURL(µtxtypes.MsgMicrotx{}),
},
}
}
func (s GenesisState) ValidateBasic() error {
if s.Params == nil {
return ErrInvalidParams
}
if err := ValidateGasFreeMessageTypes(s.Params.GasFreeMessageTypes); err != nil {
return sdkerrors.Wrap(err, "Invalid GasFreeMessageTypes GenesisState")
}
return nil
}
func ValidateGasFreeMessageTypes(i interface{}) error {
_, ok := i.([]string)
if !ok {
return fmt.Errorf("invalid gas free message types type: %T", i)
}
return nil
}
// ParamKeyTable for auth module
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{
GasFreeMessageTypes: []string{},
})
}
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(GasFreeMessageTypesKey, &p.GasFreeMessageTypes, ValidateGasFreeMessageTypes),
}
}