diff --git a/x/market/keeper/drop.go b/x/market/keeper/drop.go index 0ffcc77..f7b8c3a 100644 --- a/x/market/keeper/drop.go +++ b/x/market/keeper/drop.go @@ -23,6 +23,16 @@ func (k Keeper) SetDrop(ctx sdk.Context, drop types.Drop) { ), a) } +// SetDrops set a specific drops in the store from its index +func (k Keeper) SetDrops(ctx sdk.Context, drops types.Drops, owner string, pair string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DropsKeyPrefix)) + a := k.cdc.MustMarshal(&drops) + store.Set(types.DropsKey( + owner, + pair, + ), a) +} + // GetDrop returns a drop from its index func (k Keeper) GetDrop( ctx sdk.Context, @@ -41,7 +51,7 @@ func (k Keeper) GetDrop( return val, true } -// GetDrop returns a drop from its index +// GetDropPairs returns all pairs that an address owns drops func (k Keeper) GetDropPairs( ctx sdk.Context, address string, @@ -268,6 +278,22 @@ func (k Keeper) GetAllDrop(ctx sdk.Context) (list []types.Drop) { return } +// GetAllDrops returns all drops +func (k Keeper) GetAllDrops(ctx sdk.Context) (list []types.Drops) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DropsKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Drops + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + // GetOwnerDrops returns drops from a single owner func (k Keeper) GetPairs( ctx sdk.Context,