2019-11-25 19:46:02 +00:00
|
|
|
package auction
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// InitGenesis - initializes the store state from genesis data
|
|
|
|
func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState) {
|
2019-12-28 17:16:08 +00:00
|
|
|
keeper.SetNextAuctionID(ctx, data.NextAuctionID)
|
|
|
|
|
2020-01-07 17:17:27 +00:00
|
|
|
keeper.SetParams(ctx, data.Params)
|
2019-11-25 19:46:02 +00:00
|
|
|
|
|
|
|
for _, a := range data.Auctions {
|
|
|
|
keeper.SetAuction(ctx, a)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExportGenesis returns a GenesisState for a given context and keeper.
|
|
|
|
func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState {
|
2019-12-28 17:16:08 +00:00
|
|
|
nextAuctionID, err := keeper.GetNextAuctionID(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2019-11-25 19:46:02 +00:00
|
|
|
params := keeper.GetParams(ctx)
|
|
|
|
|
2020-01-07 17:17:27 +00:00
|
|
|
var genAuctions Auctions
|
2019-12-21 01:04:04 +00:00
|
|
|
keeper.IterateAuctions(ctx, func(a Auction) bool {
|
|
|
|
genAuctions = append(genAuctions, a)
|
|
|
|
return false
|
|
|
|
})
|
2019-11-25 19:46:02 +00:00
|
|
|
|
2019-12-28 17:16:08 +00:00
|
|
|
return NewGenesisState(nextAuctionID, params, genAuctions)
|
2019-11-25 19:46:02 +00:00
|
|
|
}
|