2022-04-05 07:09:27 +00:00
|
|
|
package auction
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
|
2022-09-07 06:36:11 +00:00
|
|
|
"github.com/cerc-io/laconicd/x/auction/keeper"
|
|
|
|
"github.com/cerc-io/laconicd/x/auction/types"
|
2022-04-05 07:09:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// func NewGenesisState(params types.Params, auctions []types.Auction) types.GenesisState {
|
|
|
|
// return types.GenesisState{Params: params, Auctions: &types.Auctions{Auctions: auctions}}
|
|
|
|
// }
|
|
|
|
|
|
|
|
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate {
|
|
|
|
keeper.SetParams(ctx, data.Params)
|
|
|
|
|
|
|
|
for _, auction := range data.Auctions {
|
|
|
|
keeper.SaveAuction(ctx, auction)
|
|
|
|
}
|
|
|
|
|
|
|
|
return []abci.ValidatorUpdate{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
|
|
|
|
params := keeper.GetParams(ctx)
|
|
|
|
auctions := keeper.ListAuctions(ctx)
|
|
|
|
|
|
|
|
var genesisAuctions []*types.Auction
|
|
|
|
for _, auction := range auctions {
|
|
|
|
genesisAuctions = append(genesisAuctions, &auction)
|
|
|
|
}
|
|
|
|
return types.GenesisState{Params: params, Auctions: genesisAuctions}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ValidateGenesis(data types.GenesisState) error {
|
|
|
|
err := data.Params.Validate()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|