cryptozombies-lesson-code
cryptozombies-lesson-code copied to clipboard
Update zombieownership.sol
For our specified use cases, this should help in preventing honest mistakes of users of the contract.
I may invoke transferFrom(A, B, Z) and be the owner of Z, but if A is not my correct address, the code will reduce someone else's zombieCount and also emit a Transfer event that's not accurate in what it says.
👍 I noticed this bug as well while completing the lesson.
I noticed this also and came to see if it was discussed. I think the best place to verify the ownership is in the _transfer function, that way developers don't have to remember to check before calling it:
require(zombieToOwner[_tokenId] == _from)
then for transferFrom, you just need _from == msg.sender
in the first half