Skip to content

Commit

Permalink
feat(billboard): skip if auction is already cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 committed Nov 23, 2023
1 parent ff9409a commit e2975f1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
44 changes: 22 additions & 22 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ ACLManagerTest:testTransferRole() (gas: 21528)
BillboardTest:testAddToWhitelist() (gas: 37205)
BillboardTest:testApproveAndTransfer() (gas: 162735)
BillboardTest:testCalculateTax() (gas: 29439)
BillboardTest:testCannnotWithdrawTaxIfSmallAmount(uint8) (runs: 256, μ: 419677, ~: 433681)
BillboardTest:testCannnotWithdrawTaxIfZero() (gas: 385862)
BillboardTest:testCannnotWithdrawTaxIfSmallAmount(uint8) (runs: 256, μ: 419891, ~: 433722)
BillboardTest:testCannnotWithdrawTaxIfZero() (gas: 385903)
BillboardTest:testCannotAddToWhitelistByAttacker() (gas: 11137)
BillboardTest:testCannotApproveByAttacker() (gas: 130388)
BillboardTest:testCannotClearAuctionIfAuctionNotEnded() (gas: 604134)
BillboardTest:testCannotClearAuctionIfAuctionNotEnded() (gas: 585072)
BillboardTest:testCannotClearAuctionOnNewBoard() (gas: 136029)
BillboardTest:testCannotMintBoardByAttacker() (gas: 13332)
BillboardTest:testCannotPlaceBidByAttacker() (gas: 141747)
BillboardTest:testCannotPlaceBidTwice(uint96) (runs: 256, μ: 650687, ~: 656918)
BillboardTest:testCannotPlaceBidTwice(uint96) (runs: 256, μ: 631625, ~: 637856)
BillboardTest:testCannotRemoveToWhitelistByAttacker() (gas: 11204)
BillboardTest:testCannotSafeTransferByAttacker() (gas: 127555)
BillboardTest:testCannotSetBoardProprtiesByAttacker() (gas: 156298)
Expand All @@ -29,35 +29,35 @@ BillboardTest:testCannotSetTaxRateByAttacker() (gas: 11106)
BillboardTest:testCannotTransferByOperator() (gas: 132888)
BillboardTest:testCannotTransferToZeroAddress() (gas: 128375)
BillboardTest:testCannotUpgradeRegistryByAttacker() (gas: 11228)
BillboardTest:testCannotWithBidTwice(uint96) (runs: 256, μ: 934036, ~: 934036)
BillboardTest:testCannotWithdrawBidIfAuctionNotCleared(uint96) (runs: 256, μ: 770628, ~: 770628)
BillboardTest:testCannotWithdrawBidIfAuctionNotEnded(uint96) (runs: 256, μ: 645425, ~: 645425)
BillboardTest:testCannotWithdrawBidIfNotFound() (gas: 419086)
BillboardTest:testCannotWithdrawBidIfWon(uint96) (runs: 256, μ: 740484, ~: 740484)
BillboardTest:testCannotWithBidTwice(uint96) (runs: 256, μ: 915015, ~: 915015)
BillboardTest:testCannotWithdrawBidIfAuctionNotCleared(uint96) (runs: 256, μ: 751566, ~: 751566)
BillboardTest:testCannotWithdrawBidIfAuctionNotEnded(uint96) (runs: 256, μ: 626363, ~: 626363)
BillboardTest:testCannotWithdrawBidIfNotFound() (gas: 419127)
BillboardTest:testCannotWithdrawBidIfWon(uint96) (runs: 256, μ: 721463, ~: 721463)
BillboardTest:testCannotWithdrawTaxByAttacker() (gas: 21053)
BillboardTest:testClearAuctionIfAuctionEnded() (gas: 649619)
BillboardTest:testClearAuctionsIfAuctionEnded() (gas: 1206340)
BillboardTest:testGetBids(uint8,uint8,uint8) (runs: 256, μ: 2871675, ~: 1453869)
BillboardTest:testClearAuctionIfAuctionEnded() (gas: 630598)
BillboardTest:testClearAuctionsIfAuctionEnded() (gas: 1168298)
BillboardTest:testGetBids(uint8,uint8,uint8) (runs: 256, μ: 2724918, ~: 1356638)
BillboardTest:testGetTokenURI() (gas: 155303)
BillboardTest:testMintBoard() (gas: 225987)
BillboardTest:testMintBoardByWhitelist() (gas: 157167)
BillboardTest:testMintBoardIfOpened() (gas: 130861)
BillboardTest:testPlaceBidByWhitelist() (gas: 470026)
BillboardTest:testPlaceBidIfAuctionEnded() (gas: 937087)
BillboardTest:testPlaceBidOnNewBoard(uint96) (runs: 256, μ: 519419, ~: 529745)
BillboardTest:testPlaceBidWithHigherPrice(uint96) (runs: 256, μ: 766815, ~: 774045)
BillboardTest:testPlaceBidWithSamePrices(uint96) (runs: 256, μ: 764942, ~: 776618)
BillboardTest:testPlaceBidZeroPrice() (gas: 357801)
BillboardTest:testPlaceBidByWhitelist() (gas: 470067)
BillboardTest:testPlaceBidIfAuctionEnded() (gas: 918066)
BillboardTest:testPlaceBidOnNewBoard(uint96) (runs: 256, μ: 519460, ~: 529786)
BillboardTest:testPlaceBidWithHigherPrice(uint96) (runs: 256, μ: 747753, ~: 754983)
BillboardTest:testPlaceBidWithSamePrices(uint96) (runs: 256, μ: 745880, ~: 757556)
BillboardTest:testPlaceBidZeroPrice() (gas: 357842)
BillboardTest:testRemoveToWhitelist() (gas: 24957)
BillboardTest:testSafeTransferByOperator() (gas: 141354)
BillboardTest:testSetBoardProperties() (gas: 305524)
BillboardTest:testSetBoardPropertiesAfterTransfer() (gas: 334252)
BillboardTest:testSetIsOpened() (gas: 15978)
BillboardTest:testSetTaxRate() (gas: 27263)
BillboardTest:testSomethin() (gas: 1698254)
BillboardTest:testUpgradeRegistry() (gas: 2725063)
BillboardTest:testWithdrawBid(uint96) (runs: 256, μ: 935332, ~: 935332)
BillboardTest:testWithdrawTax(uint96) (runs: 256, μ: 509539, ~: 509539)
BillboardTest:testSomethin() (gas: 1641191)
BillboardTest:testUpgradeRegistry() (gas: 2729870)
BillboardTest:testWithdrawBid(uint96) (runs: 256, μ: 916311, ~: 916311)
BillboardTest:testWithdrawTax(uint96) (runs: 256, μ: 509580, ~: 509580)
CurationTest:testCannotCurateERC20CurateZeroAmount() (gas: 12194)
CurationTest:testCannotCurateERC20EmptyURI() (gas: 15797)
CurationTest:testCannotCurateERC20IfNotApproval() (gas: 21624)
Expand Down
9 changes: 8 additions & 1 deletion src/Billboard/Billboard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,20 @@ contract Billboard is IBillboard {

function _clearAuction(uint256 tokenId_, address boardCreator_, uint256 nextAuctionId_) private {
IBillboardRegistry.Auction memory _nextAuction = registry.getAuction(tokenId_, nextAuctionId_);

// skip if auction is already cleared
if (_nextAuction.leaseEndAt != 0) {
return;
}

address _prevOwner = registry.ownerOf(tokenId_);

IBillboardRegistry.Bid memory _highestBid = registry.getBid(
tokenId_,
nextAuctionId_,
_nextAuction.highestBidder
);

address _prevOwner = registry.ownerOf(tokenId_);
if (_highestBid.price > 0) {
// transfer bid price to board owner (previous tenant or creator)
registry.transferAmount(_prevOwner, _highestBid.price);
Expand Down

0 comments on commit e2975f1

Please sign in to comment.