Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Soulmate token gets only minted for the second soulmate

Description: The mint of the token takes place only if the else if statement is true as it can be seen in Soulmate.sol::mintSoulmateToken():

if (soulmate1 == address(0)) {
idToOwners[nextID][0] = msg.sender;
ownerToId[msg.sender] = nextID;
emit SoulmateIsWaiting(msg.sender);
} else if (soulmate2 == address(0)) {
idToOwners[nextID][1] = msg.sender;
// Once 2 soulmates are reunited, the token is minted
ownerToId[msg.sender] = nextID;
soulmateOf[msg.sender] = soulmate1;
soulmateOf[soulmate1] = msg.sender;
idToCreationTimestamp[nextID] = block.timestamp;
emit SoulmateAreReunited(soulmate1, soulmate2, nextID);
emit SoulmateAreReunited(soulmate1, msg.sender, nextID);
@> _mint(msg.sender, nextID++);
}

Impact: The first soulmate won't receive the NFT.

Proof of Concept: Add the following two lines to SulmateTest.t.sol::test_MintNewToken:

assertTrue(soulmateContract.balanceOf(soulmate1) == 0);
assertTrue(soulmateContract.balanceOf(soulmate2) == 1);

Recommended Mitigation: Place the _mint() function in the first part of the if as well.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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