Skip to content

Commit

Permalink
Merge pull request #1 from 0xalpharush/master
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankieIsLost authored Apr 11, 2022
2 parents dccadf0 + deb65e1 commit 41f3174
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions contracts/BatchAuction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ contract BatchAuction is BatchRevealBase {
for(uint256 i = 0; i < winningBidIds.length; i++) {
uint256 curBidId = winningBidIds[i];
Bid storage curBid = bidPriorityQueue.bidIdToBidMap[curBidId];
for(uint256 j = 0; j < curBid.quantity; j++) {
_safeMint(msg.sender, ++nftCount);
}
//cache quantity in memory for price calc and minting
uint256 qty = curBid.quantity;
//charge user quantity times clearing price
balance -= curBid.quantity * clearingPrice;
//update balance and quantity before minting to prevent reentrant claims
balance -= qty * clearingPrice;
curBid.quantity = 0;
for(uint256 j = 0; j < qty; j++) {
_safeMint(msg.sender, ++nftCount);
}
}
//refund any contributions not spent on mint
(bool sent, ) = payable(msg.sender).call{value: balance}("");
Expand Down Expand Up @@ -154,4 +157,4 @@ contract BatchAuction is BatchRevealBase {
function getBidById(uint256 id) public view returns (Bid memory) {
return bidPriorityQueue.bidIdToBidMap[id];
}
}
}

0 comments on commit 41f3174

Please sign in to comment.