package keeper

import (
	"cosmos-test/x/cosmostest/types"
	"github.com/cosmos/cosmos-sdk/store/prefix"
	sdk "github.com/cosmos/cosmos-sdk/types"
)

// SetNextAuction set nextAuction in the store
func (k Keeper) SetNextAuction(ctx sdk.Context, nextAuction types.NextAuction) {
	store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.NextAuctionKey))
	b := k.cdc.MustMarshal(&nextAuction)
	store.Set([]byte{0}, b)
}

// GetNextAuction returns nextAuction
func (k Keeper) GetNextAuction(ctx sdk.Context) (val types.NextAuction, found bool) {
	store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.NextAuctionKey))

	b := store.Get([]byte{0})
	if b == nil {
		return val, false
	}

	k.cdc.MustUnmarshal(b, &val)
	return val, true
}

// RemoveNextAuction removes nextAuction from the store
func (k Keeper) RemoveNextAuction(ctx sdk.Context) {
	store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.NextAuctionKey))
	store.Delete([]byte{0})
}
