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

Missing Events for `collectPresent()` and `buyPresent()`

Summary

The collectPresent and buyPresent functions are missing corresponding events, which would allow off-chain monitoring of present collection and present purchases.

Vulnerability Details

Currently, the collectPresent and buyPresent functions do not emit any events to notify external systems or off-chain applications about the actions being performed. This absence of events makes it difficult to track and monitor present collection and purchases.

Impact

The absence of events for the collectPresent and buyPresent functions limits the ability to track and monitor present collection and purchases. Adding these events will greatly enhance the transparency and observability of these actions.

Tools Used

Manual review

Recommendations

It is recommended to add the following events to the contract:

  1. PresentCollected event: Emits when a user successfully collects their present. Includes the address of the person and their present status.

  2. PresentPurchased event: Emits when a user buys a present. Includes the address of the buyer and the recipient of the present.

Here is an example of how the events can be added to the contract:

event PresentCollected(address indexed person, Status status);
event PresentPurchased(address indexed buyer, address indexed recipient);
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 PresentCollected(msg.sender, s_theListCheckedTwice[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 PresentCollected(msg.sender, s_theListCheckedTwice[msg.sender]);
return;
}
revert SantasList__NotNice();
}
function buyPresent(address presentReceiver) external {
i_santaToken.burn(presentReceiver);
_mintAndIncrement();
emit PresentPurchased(msg.sender, recipient);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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