-
Notifications
You must be signed in to change notification settings - Fork 28
/
genesis.go
41 lines (38 loc) · 944 Bytes
/
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
package types
import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
func NewGenesisState(campaigns []Campaign,
claims []Claim,
nextCampaignNumber uint64,
params Params,
) *GenesisState {
return &GenesisState{
Campaigns: campaigns,
Claims: claims,
Params: params,
NextCampaignNumber: nextCampaignNumber,
}
}
func (m *GenesisState) ValidateGenesis() error {
for _, c := range m.Campaigns {
if c.GetCreator().Empty() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing campaign creator address")
}
if err := ValidateCampaign(c); err != nil {
return err
}
}
for _, claim := range m.Claims {
if err := ValidateClaim(claim); err != nil {
return err
}
}
if err := m.Params.ValidateBasic(); err != nil {
return err
}
if m.NextCampaignNumber <= 0 {
return sdkerrors.Wrap(ErrNonPositiveNumber, "must be a number and greater than 0.")
}
return nil
}