Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
vuong177 committed Nov 6, 2024
1 parent 97faecd commit 799bfa1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion x/auction/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
if err := k.SetParams(ctx, genState.Params); err != nil {
panic(err)
}
err := k.LastestAuctionPeriods.Set(ctx, "LastestAuctionPeriods", ctx.BlockTime().Unix())
err := k.LastestAuctionPeriods.Set(ctx, ctx.BlockTime().Unix())
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions x/auction/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type (
authority string

// timestamp of lastest auction period (Unix timestamp)
LastestAuctionPeriods collections.Map[string, int64]
LastestAuctionPeriods collections.Item[int64]

AuctionIdSeq collections.Sequence

Expand Down Expand Up @@ -75,7 +75,7 @@ func NewKeeper(
vaultKeeper: vk,
OracleKeeper: ok,
AuctionIdSeq: collections.NewSequence(sb, types.AuctionIdSeqPrefix, "auction_id_sequence"),
LastestAuctionPeriods: collections.NewMap(sb, types.LastestAuctionPeriodPrefix, "lastestAuctionPeriods", collections.StringKey, collections.Int64Value),
LastestAuctionPeriods: collections.NewItem(sb, types.LastestAuctionPeriodPrefix, "lastestAuctionPeriods", collections.Int64Value),
BidIdSeq: collections.NewMap(sb, types.BidIdSeqPrefix, "bid_id_sequence", collections.Uint64Key, collections.Uint64Value),
Auctions: collections.NewMap(sb, types.AuctionsPrefix, "auctions", collections.Uint64Key, codec.CollValue[types.Auction](cdc)),
Bids: collections.NewMap(sb, types.BidsPrefix, "bids", collections.Uint64Key, codec.CollValue[types.BidQueue](cdc)),
Expand Down
4 changes: 2 additions & 2 deletions x/auction/keeper/liquidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error {
params := k.GetParams(ctx)

currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time
lastestAuctionPeriod, err := k.LastestAuctionPeriods.Get(ctx, "LastestAuctionPeriods")
lastestAuctionPeriod, err := k.LastestAuctionPeriods.Get(ctx)
if err != nil {
return err
}
lastAuctionPeriods := time.Unix(lastestAuctionPeriod, 0)
// check if has reached the next auction periods
if lastAuctionPeriods.Add(params.AuctionPeriods).Before(currentTime) {
// update latest auction period
err = k.LastestAuctionPeriods.Set(ctx, "LastestAuctionPeriods", lastAuctionPeriods.Add(params.AuctionPeriods).Unix())
err = k.LastestAuctionPeriods.Set(ctx, lastAuctionPeriods.Add(params.AuctionPeriods).Unix())
if err != nil {
return err
}
Expand Down

0 comments on commit 799bfa1

Please sign in to comment.