Created
October 28, 2023 13:08
-
-
Save nekofar/96a540edcf359f1a62556640768972d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
function _createAuction() internal { | |
uint256 nounId; | |
// Check if the auction contract itself has any Noun tokens | |
uint256 auctionContractNounCount = nouns.balanceOf(address(this)); | |
if (auctionContractNounCount > 0) { | |
// Use the first Noun token found in the auction contract | |
nounId = nouns.tokenOfOwnerByIndex(address(this), 0); | |
} else { | |
// Mint a new Noun token if the auction contract has none | |
try nouns.mint() returns (uint256 _nounId) { | |
nounId = _nounId; | |
} catch Error(string memory) { | |
_pause(); | |
return; | |
} | |
} | |
uint256 startTime = block.timestamp; | |
uint256 endTime = startTime + duration; | |
auction = Auction({ | |
nounId: nounId, | |
amount: 0, | |
startTime: startTime, | |
endTime: endTime, | |
bidder: payable(0), | |
settled: false | |
}); | |
emit AuctionCreated(nounId, startTime, endTime); | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment