Snowman Merkle Airdrop

First Flight #42
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: low
Likelihood: medium
Invalid

[L-2] earnSnow() does not emit the SnowEarned() event and event listeners will never know when a Snow is earned

[L-2] Snow::earnSnow() does not emit the SnowEarned() event and event listeners will never know when a Snow is earned

Description

  • The earnSnow() function allows user to earn Snow every week. However, no events are emitted when the function is called.

function earnSnow() external canFarmSnow {
if (s_earnTimer != 0 && block.timestamp < (s_earnTimer + 1 weeks)) {
revert S__Timer();
}
_mint(msg.sender, 1);
s_earnTimer = block.timestamp;
}

Risk

Likelihood:

  • Whenever the earnSnow() event is called

Impact:

  • Frontends depending on event emission to detect when a Snow is earned by a user will never be able to update because no events are emitted

Proof of Concept

The SnowEarned event is defined in the contract like the following:

event SnowEarned(address indexed earner, uint256 indexed amount);

However, it has never been used

Recommended Mitigation:

Modify the earnSnow() function to be like this

function earnSnow() external canFarmSnow {
if (s_earnTimer != 0 && block.timestamp < (s_earnTimer + 1 weeks)) {
revert S__Timer();
}
_mint(msg.sender, 1);
+ emit SnowEarned(msg.sender, 1);
s_earnTimer = block.timestamp;
}

Now, every time a Snow is earned using this function, an event will be emitted

Updates

Lead Judging Commences

yeahchibyke Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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