When we read thing from storage in Blockchain it will cost more, when we have some values which are going to used multiple time it is better to store them into one variable then used it
* @notice Collect your present if you are nice or extra nice. You get extra presents if you are extra nice.
* - Nice: Collect an NFT
* - Extra Nice: Collect an NFT and a SantaToken
* This should not be callable until Christmas 2023 (give or take 24 hours), and addresses should not be able to collect more than once.
*/
function collectPresent() external {
if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
revert SantasList__NotChristmasYet();
}
address userAddress =msg.sender;
if (balanceOf(userAddress) > 0) {
revert SantasList__AlreadyCollected();
}
Status checkFirstStatus =s_theListCheckedOnce[userAddress];
Status checkTwiceStatus =s_theListCheckedTwice[userAddress];
if (checkFirstStatus == Status.NICE && checkTwiceStatus == Status.NICE) {
_mintAndIncrement();
return;
} else if (
checkFirstStatus == Status.EXTRA_NICE
&& checkTwiceStatus == Status.EXTRA_NICE
) {
_mintAndIncrement();
i_santaToken.mint(userAddress);
return;
}
revert SantasList__NotNice();
}