2024-02-09 08:44:45 +00:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
2024-02-12 08:34:40 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2024-02-15 07:08:32 +00:00
|
|
|
|
2024-04-01 09:57:26 +00:00
|
|
|
"git.vdb.to/cerc-io/laconicd/x/auction"
|
2024-02-09 08:44:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// InitGenesis initializes the module state from a genesis state.
|
2024-02-12 08:34:40 +00:00
|
|
|
func (k *Keeper) InitGenesis(ctx sdk.Context, data *auction.GenesisState) error {
|
2024-02-09 08:44:45 +00:00
|
|
|
if err := k.Params.Set(ctx, data.Params); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save auctions in store.
|
2024-02-12 08:34:40 +00:00
|
|
|
for _, auction := range data.Auctions.Auctions {
|
|
|
|
if err := k.Auctions.Set(ctx, auction.Id, auction); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2024-02-09 08:44:45 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExportGenesis exports the module state to a genesis state.
|
2024-02-12 08:34:40 +00:00
|
|
|
func (k *Keeper) ExportGenesis(ctx sdk.Context) (*auction.GenesisState, error) {
|
2024-02-09 08:44:45 +00:00
|
|
|
params, err := k.Params.Get(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2024-02-12 08:34:40 +00:00
|
|
|
auctions, err := k.ListAuctions(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2024-02-09 08:44:45 +00:00
|
|
|
|
|
|
|
return &auction.GenesisState{
|
2024-02-12 08:34:40 +00:00
|
|
|
Params: params,
|
|
|
|
Auctions: &auction.Auctions{Auctions: auctions},
|
2024-02-09 08:44:45 +00:00
|
|
|
}, nil
|
|
|
|
}
|