0g-chain/x/auction/genesis.go

28 lines
680 B
Go
Raw Normal View History

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) {
keeper.SetParams(ctx, data.AuctionParams)
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 {
params := keeper.GetParams(ctx)
var genAuctions GenesisAuctions
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
return NewGenesisState(params, genAuctions)
}