Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Missing Event in `buyPresent` Function and `collectPresent` Function

Summary

  • SantasList::buyPresent function and SantasList::collectPresent function do not emit any event. This may cause the user to not be able to know whether the transaction is successful or not and not able to view off-chain.

Vulnerability Details

  • when the user calls SantasList::buyPresent function and SantasList::collectPresent function, the user will not be able to know whether the transaction is successful or not and not able to view off-chain. So, the user and off-chain application will not be able to know the transaction is successful or not.

Click to see collectPresent function
function collectPresent() external {
if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
revert SantasList__NotChristmasYet();
}
if (balanceOf(msg.sender) > 0) {
revert SantasList__AlreadyCollected();
}
if (s_theListCheckedOnce[msg.sender] == Status.NICE && s_theListCheckedTwice[msg.sender] == Status.NICE) {
_mintAndIncrement();
@> return;
} else if (
s_theListCheckedOnce[msg.sender] == Status.EXTRA_NICE
&& s_theListCheckedTwice[msg.sender] == Status.EXTRA_NICE
) {
_mintAndIncrement();
i_santaToken.mint(msg.sender);
@> return;
}
revert SantasList__NotNice();
}
Click to see buyPresent function
function buyPresent(address presentReceiver) external {
i_santaToken.burn(presentReceiver);
_mintAndIncrement();
@> }

Impact

  • Off-chain application and user will not be able to know the transaction is successful or not

Tools Used

  • Manual Review

Recommendations

  • Emit an event in buyPresent function and collectPresent function.

+ event CollectNftPresent(address person);
+ event CollectNftAndSantaTokenPresent(address person);
function collectPresent() external {
if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
revert SantasList__NotChristmasYet();
}
if (balanceOf(msg.sender) > 0) {
revert SantasList__AlreadyCollected();
}
if (s_theListCheckedOnce[msg.sender] == Status.NICE && s_theListCheckedTwice[msg.sender] == Status.NICE) {
_mintAndIncrement();
+ emit CollectNftPresent(msg.sender);
return;
} else if (
s_theListCheckedOnce[msg.sender] == Status.EXTRA_NICE
&& s_theListCheckedTwice[msg.sender] == Status.EXTRA_NICE
) {
_mintAndIncrement();
i_santaToken.mint(msg.sender);
+ emit CollectNftAndSantaTokenPresent(msg.sender);
return;
}
revert SantasList__NotNice();
}
+ event BuyPresent(address buyer, address receiver);
function buyPresent(address presentReceiver) external {
i_santaToken.burn(presentReceiver);
_mintAndIncrement();
+ emit BuyPresent(msg.sender, presentReceiver);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.