-
Notifications
You must be signed in to change notification settings - Fork 28
/
genesis.go
47 lines (44 loc) · 1.14 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
package types
import (
errorsmod "cosmossdk.io/errors"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
func NewGenesisState(listings []Listing, listingCount uint64, params Params,
auctions []AuctionListing, bids []Bid, nextAuctionNumber uint64,
) *GenesisState {
return &GenesisState{
Listings: listings,
ListingCount: listingCount,
Params: params,
Auctions: auctions,
Bids: bids,
NextAuctionNumber: nextAuctionNumber,
}
}
func (m *GenesisState) ValidateGenesis() error {
for _, l := range m.Listings {
if l.GetOwner().Empty() {
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "missing nft owner")
}
if err := ValidateListing(l); err != nil {
return err
}
}
if err := m.Params.ValidateBasic(); err != nil {
return err
}
for _, auction := range m.Auctions {
if err := ValidateAuctionListing(auction); err != nil {
return err
}
}
for _, bid := range m.Bids {
if err := ValidateBid(bid); err != nil {
return err
}
}
if m.NextAuctionNumber <= 0 {
return errorsmod.Wrap(ErrNonPositiveNumber, "must be a number and greater than 0.")
}
return nil
}