Skip to content

Commit

Permalink
Update status if ended auction
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Nov 21, 2023
1 parent 91021ea commit f93c4e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ export class ReindexAuctionStartedHandler {
handle(input: AuctionStartedSummary, marketplaceReindexState: MarketplaceReindexState, paymentToken: Token, paymentNonce: number): void {
const nonce = BinaryUtils.hexToNumber(input.nonce);
const itemsCount = parseInt(input.itemsCount);
let status = AuctionStatusEnum.Running;
const modifiedDate = DateUtils.getUtcDateFromTimestamp(input.timestamp);
const startTime = Number.isNaN(input.startTime) ? input.timestamp : input.startTime;
const endTime = input.endTime > 0 ? input.endTime : 0;
const minBidDenominated = BigNumberUtils.denominateAmount(input.minBid, paymentToken.decimals);
const maxBidDenominated = BigNumberUtils.denominateAmount(input.maxBid !== 'NaN' ? input.maxBid : '0', paymentToken.decimals);
if (endTime > 0 && endTime <= DateUtils.getCurrentTimestamp()) {
status = AuctionStatusEnum.Claimable;
}

const auction = new AuctionEntity({
creationDate: modifiedDate,
Expand All @@ -31,7 +35,7 @@ export class ReindexAuctionStartedHandler {
collection: input.collection,
nonce: nonce,
nrAuctionedTokens: itemsCount,
status: AuctionStatusEnum.Running,
status: status,
type: input.auctionType,
paymentToken: paymentToken.identifier,
paymentNonce,
Expand Down
3 changes: 0 additions & 3 deletions src/modules/marketplaces/models/MarketplaceReindexState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ export class MarketplaceReindexState {
}

public updateAuctionStatus(auction: AuctionEntity, blockHash: string, status: AuctionStatusEnum, timestamp: number): void {
if (auction.endDate > 0 && auction.endDate <= DateUtils.getCurrentTimestamp()) {
status = AuctionStatusEnum.Claimable;
}
auction.status = status;
auction.blockHash = auction.blockHash ?? blockHash;
auction.modifiedDate = DateUtils.getUtcDateFromTimestamp(timestamp);
Expand Down

0 comments on commit f93c4e7

Please sign in to comment.