Mystery Box

First Flight #25
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Deleting a reward of address at a specific index from rewardsOwned doesn't actually remove it; it just resets the reward to zero values

Relevant GitHub Links

https://github.com/Cyfrin/2024-09-mystery-box/blob/main/src/MysteryBox.sol#L76

https://github.com/Cyfrin/2024-09-mystery-box/blob/main/src/MysteryBox.sol#L100

Summary

In the MysteryBox::transferReward and MysteryBox::claimSingleReward functions, the line delete rewardsOwned[msg.sender][_index]; doesn't actually remove the reward at the given index; instead, it resets the reward to default values (a reward with an empty name and a value of 0). If a user has multiple rewards and claims the first one, they might expect the remaining rewards to shift to the beginning of the array.

Impact

Users may be confused when the rewards don’t automatically shift after one is claimed or transferred.

Recommendations

Implement a delete function that shifts elements and uses pop (after the shift) to remove the reward from the array.

Updates

Appeal created

inallhonesty Lead Judge 11 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.