function test_t0x1c_CollectPresentIfAlreadyCollected() public {
vm.startPrank(santa);
santasList.checkList(user, SantasList.Status.NICE);
santasList.checkTwice(user, SantasList.Status.NICE);
vm.stopPrank();
vm.warp(santasList.CHRISTMAS_2023_BLOCK_TIME() + 1);
address userAlternateWallet = makeAddr("userAlternateWallet");
vm.startPrank(user);
santasList.collectPresent();
assertEq(santasList.balanceOf(user), 1);
*
*
* | Name | Type | Slot | Offset | Bytes | Contract |
* |-----------------------|----------------------------------------------|------|--------|-------|-------------------------------|
* | _name | string | 0 | 0 | 32 | src/SantasList.sol:SantasList |
* | _symbol | string | 1 | 0 | 32 | src/SantasList.sol:SantasList |
* | _owners | mapping(uint256 => address) | 2 | 0 | 32 | src/SantasList.sol:SantasList |
* | _balances | mapping(address => uint256) | 3 | 0 | 32 | src/SantasList.sol:SantasList |
* | _tokenApprovals | mapping(uint256 => address) | 4 | 0 | 32 | src/SantasList.sol:SantasList |
* | _operatorApprovals | mapping(address => mapping(address => bool)) | 5 | 0 | 32 | src/SantasList.sol:SantasList |
* | s_theListCheckedOnce | mapping(address => enum SantasList.Status) | 6 | 0 | 32 | src/SantasList.sol:SantasList |
* | s_theListCheckedTwice | mapping(address => enum SantasList.Status) | 7 | 0 | 32 | src/SantasList.sol:SantasList |
* | s_tokenCounter | uint256 | 8 | 0 | 32 | src/SantasList.sol:SantasList |
*
*
*/
bytes32 slot8 = vm.load(address(santasList), bytes32(uint256(8)));
uint256 tokenID = uint256(slot8);
santasList.transferFrom(user, userAlternateWallet, tokenID - 1);
assertEq(santasList.balanceOf(user), 0);
santasList.collectPresent();
assertEq(santasList.balanceOf(user), 1);
}
Unlimited NFT collection by a user.
function collectPresent() external {
if (block.timestamp < CHRISTMAS_2023_BLOCK_TIME) {
revert SantasList__NotChristmasYet();
}
- if (balanceOf(msg.sender) > 0) {
+ if (claimed[msg.sender]) {
revert SantasList__AlreadyCollected();
}
if (s_theListCheckedOnce[msg.sender] == Status.NICE && s_theListCheckedTwice[msg.sender] == Status.NICE) {
+ claimed[msg.sender] = true;
_mintAndIncrement();
return;
} else if (
s_theListCheckedOnce[msg.sender] == Status.EXTRA_NICE
&& s_theListCheckedTwice[msg.sender] == Status.EXTRA_NICE
) {
+ claimed[msg.sender] = true;
_mintAndIncrement();
i_santaToken.mint(msg.sender);
return;
}
revert SantasList__NotNice();
}