-
Notifications
You must be signed in to change notification settings - Fork 338
/
genesis.go
36 lines (30 loc) · 1.12 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
// Copyright (c) 2016-2021 Shanghai Bianjie AI Technology Inc. (licensed under the Apache License, Version 2.0)
// Modifications Copyright (c) 2021-present Crypto.org (licensed under the Apache License, Version 2.0)
package nft
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/crypto-org-chain/chain-main/v4/x/nft/keeper"
"github.com/crypto-org-chain/chain-main/v4/x/nft/types"
)
// InitGenesis stores the NFT genesis.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) {
if err := types.ValidateGenesis(data); err != nil {
panic(err.Error())
}
for _, c := range data.Collections {
if err := k.SetDenom(ctx, c.Denom); err != nil {
panic(err)
}
if err := k.SetGenesisCollection(ctx, c); err != nil {
panic(err)
}
}
}
// ExportGenesis returns a GenesisState for a given context and keeper.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
return types.NewGenesisState(k.GetCollections(ctx))
}
// DefaultGenesisState returns a default genesis state
func DefaultGenesisState() *types.GenesisState {
return types.NewGenesisState([]types.Collection{})
}