fix: zero token approveFollow allowed as a way to clear approval

This commit is contained in:
donosonaumczuk
2023-10-16 13:55:54 -03:00
parent 7cc03e4f48
commit 3acb3d9a4f
2 changed files with 3 additions and 2 deletions

View File

@@ -137,8 +137,8 @@ contract FollowNFT is HubRestricted, LensBaseERC721, ERC2981CollectionRoyalties,
if (!IERC721Timestamped(HUB).exists(followerProfileId)) {
revert Errors.TokenDoesNotExist();
}
address followTokenOwner = _unsafeOwnerOf(followTokenId);
if (followTokenOwner == address(0)) {
// `followTokenId` allowed to be zero as a way to clear the approval.
if (followTokenId != 0 && _unsafeOwnerOf(followTokenId) == address(0)) {
revert OnlyWrappedFollowTokens();
}
if (_isApprovedOrOwner(msg.sender, followTokenId)) {

View File

@@ -1643,6 +1643,7 @@ contract FollowNFTTest is BaseTest, LensBaseERC721Test {
}
function testCannotApproveFollowForUnexistentFollowToken(uint256 unexistentFollowTokenId) public {
vm.assume(unexistentFollowTokenId != 0);
vm.assume(!followNFT.exists(unexistentFollowTokenId));
vm.assume(followNFT.getFollowerProfileId(unexistentFollowTokenId) == 0);