The EggstravaganzaNFT contract allows its owner to update the associated game contract used for token minting. However, if a game has already been played and tokens have been minted, updating the game contract prevents any further token minting. As a result, the game can no longer function as intended, until the original game contract is not set again.
As players discover more eggs, tokens are minted with sequential tokenId values (1, 2, 3, ...). If the EggstravaganzaNFT contract is updated in a new game contract that uses the same tokenId generation logic as the original EggHuntGame contract, it will attempt to mint tokens with tokenId values that already exist, leading to conflicts or errors.
Minting new tokens is not possible through a newly set game contract.
Add the following code to the EggHuntGameTest.t.sol file within the EggGameTest contract.
Manual Review
Foundry
To resolve this issue, the definition of tokenId can be moved from the EggHuntGame contract to the EggstravaganzaNFT contract. The EggstravaganzaNFT::mintEgg function can then be modified to assign tokenId values based on the current total number of tokens minted. This ensures each new token receives a unique tokenId that increments with every minting.
File EggstravaganzaNFT.sol:
File EggHuntGame.sol:
File EggHuntGameTest.t.sol:
line 58:
line 68:
line 77:
line 197:
line 253:
This approach ensures that the NFT contract (EggstravaganzaNFT) retains full control over the generation of new tokenId values.
Lack of game state validation checks
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.