mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 08:15:19 +00:00
35 lines
818 B
Go
35 lines
818 B
Go
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) {
|
|
keeper.SetNextAuctionID(ctx, data.NextAuctionID)
|
|
|
|
keeper.SetParams(ctx, data.Params)
|
|
|
|
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 {
|
|
nextAuctionID, err := keeper.GetNextAuctionID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
params := keeper.GetParams(ctx)
|
|
|
|
var genAuctions Auctions
|
|
keeper.IterateAuctions(ctx, func(a Auction) bool {
|
|
genAuctions = append(genAuctions, a)
|
|
return false
|
|
})
|
|
|
|
return NewGenesisState(nextAuctionID, params, genAuctions)
|
|
}
|