when calling KittyConnect::safeTransferFrom the NFT is supposed to transfer between users but the function _updateOwnershipInfo not correctly removing previous owner NFT tokenId, thus making tokenId transferred have multiple owner: the one who send and the one who receive the tokenId.
when calling safeTransferFrom function, _updateOwnershipInfo only update the mapping s_ownerToCatsTokenId with newOwner data, but forget to delete the currCatOwner from corresponding mappings.
KittyConnect.sol:
add the following code to KittyTest.t.sol:
then run the following command forge test --mt test_safetransferCatCorrectlyUpdateOwnerMappings.
the result should FAIL:
it only affect mapping s_ownerToCatsTokenId and making confusion who own who.
manual review and foundry
we can implement the ERC721::ownerOf as a reliable way to get who own the tokenId.
or we can fix the code base and use mapping s_ownerToCatsTokenId as intended.
add this code to KittyConnect.sol:
to verify this fix, run the following forge test --mt test_safetransferCatCorrectlyUpdateOwnerMappings the result should PASS:
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.