-
Notifications
You must be signed in to change notification settings - Fork 40
/
genesis.go
64 lines (58 loc) · 2 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
60
61
62
63
64
package types
import (
sdkerrors "cosmossdk.io/errors"
deposittypes "github.com/sentinel-official/hub/v12/x/deposit/types"
nodetypes "github.com/sentinel-official/hub/v12/x/node/types"
plantypes "github.com/sentinel-official/hub/v12/x/plan/types"
providertypes "github.com/sentinel-official/hub/v12/x/provider/types"
sessiontypes "github.com/sentinel-official/hub/v12/x/session/types"
subscriptiontypes "github.com/sentinel-official/hub/v12/x/subscription/types"
)
func NewGenesisState(
deposits deposittypes.GenesisState,
providers *providertypes.GenesisState,
nodes *nodetypes.GenesisState,
plans plantypes.GenesisState,
subscriptions *subscriptiontypes.GenesisState,
sessions *sessiontypes.GenesisState,
) *GenesisState {
return &GenesisState{
Deposits: deposits,
Providers: providers,
Nodes: nodes,
Plans: plans,
Subscriptions: subscriptions,
Sessions: sessions,
}
}
func DefaultGenesisState() *GenesisState {
return NewGenesisState(
deposittypes.DefaultGenesisState(),
providertypes.DefaultGenesisState(),
nodetypes.DefaultGenesisState(),
plantypes.DefaultGenesisState(),
subscriptiontypes.DefaultGenesisState(),
sessiontypes.DefaultGenesisState(),
)
}
func (m *GenesisState) Validate() error {
if err := deposittypes.ValidateGenesisState(m.Deposits); err != nil {
return sdkerrors.Wrapf(err, "invalid deposit genesis")
}
if err := providertypes.ValidateGenesis(m.Providers); err != nil {
return sdkerrors.Wrapf(err, "invalid provider genesis")
}
if err := nodetypes.ValidateGenesis(m.Nodes); err != nil {
return sdkerrors.Wrapf(err, "invalid node genesis")
}
if err := plantypes.ValidateGenesis(m.Plans); err != nil {
return sdkerrors.Wrapf(err, "invalid plan genesis")
}
if err := subscriptiontypes.ValidateGenesis(m.Subscriptions); err != nil {
return sdkerrors.Wrapf(err, "invalid subscription genesis")
}
if err := sessiontypes.ValidateGenesis(m.Sessions); err != nil {
return sdkerrors.Wrapf(err, "invalid session genesis")
}
return nil
}