Users who already own SantasList
ERC721 tokens cannot collect present.
SantasList::collectPresent()
doesn't allow a user to collect present more than once. To reenforce this rule, it reverts if the SantasList
ERC721 balance of the caller exceeds zero. Which means a SantasList
ERC721 tokens holder who already have an asset is not allowed to collect present even if they have not yet collected any present and their status is NICE
or EXTRA_NICE
.
Create a new file: test/libraries/harnesses/SantasListHarness.sol
. Copy the following code and paste it in the new created SantasListHarness.sol
.
In test/unit/SantasListTest.t.sol
import SantasListHarness
from ../libraries/harnesses/SantasListHarness.sol
and update the setUp
method as follows:
Place the code for the following test functions in test/unit/SantasListTest.t.sol
.
In the terminal, run the following command:
forge test --mt test_CantCollectPresent_IfAlreadyHoldToken
Users who already have SantasList
ERC721 tokens cannot collect a present, even if they are entitled to do so.
Manual review, Foundry
Add a state variable that maps address to bool, in order to keep track of addresses that have already collected presents.
Move from balance check to collected check
. And update s_collected
before the return
instruction in if-else statements
Relying on balanceOf > 0 in collectPresent() allows the msg.sender to send their present to another address and then collect again.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.