misc: C4-168-N04 Allow to unfollow() for burnt target profiles T-16806

This commit is contained in:
vicnaum
2023-10-13 19:00:09 +02:00
parent 5a22a606da
commit 46a964e603
2 changed files with 21 additions and 7 deletions

View File

@@ -63,10 +63,11 @@ library FollowLib {
uint256 i;
while (i < idsOfProfilesToUnfollow.length) {
uint256 idOfProfileToUnfollow = idsOfProfilesToUnfollow[i];
ValidationLib.validateProfileExists(idOfProfileToUnfollow);
address followNFT = StorageLib.getProfile(idOfProfileToUnfollow).followNFT;
// We don't validate the profile exists because we want to allow unfollowing a burnt profile.
// Because, if the profile never existed, followNFT will be address(0) and the call will revert.
if (followNFT == address(0)) {
revert Errors.NotFollowing();
}

View File

@@ -78,7 +78,7 @@ contract UnfollowTest is BaseTest {
assertTrue(hub.isFollowing(testUnfollowerProfileId, targetProfileId));
vm.expectRevert(Errors.TokenDoesNotExist.selector);
vm.expectRevert(Errors.NotFollowing.selector);
_unfollow({
pk: testUnfollowerProfileOwnerPk,
@@ -190,6 +190,23 @@ contract UnfollowTest is BaseTest {
assertFalse(hub.isFollowing(testUnfollowerProfileId, targetProfileId));
}
function testUnfollowIfTargetProfileWasBurned() public {
assertTrue(hub.isFollowing(testUnfollowerProfileId, targetProfileId));
_effectivelyDisableProfileGuardian(targetProfileOwner);
vm.prank(targetProfileOwner);
hub.burn(targetProfileId);
_unfollow({
pk: testUnfollowerProfileOwnerPk,
unfollowerProfileId: testUnfollowerProfileId,
idsOfProfilesToUnfollow: _toUint256Array(targetProfileId)
});
// Asserts that the unfollow operation was still a success.
assertFalse(hub.isFollowing(testUnfollowerProfileId, targetProfileId));
}
function _unfollow(
uint256 pk,
uint256 unfollowerProfileId,
@@ -238,11 +255,7 @@ contract UnfollowMetaTxTest is UnfollowTest, MetaTxNegatives {
});
}
function _executeMetaTx(
uint256 signerPk,
uint256 nonce,
uint256 deadline
) internal virtual override {
function _executeMetaTx(uint256 signerPk, uint256 nonce, uint256 deadline) internal virtual override {
hub.unfollowWithSig({
unfollowerProfileId: testUnfollowerProfileId,
idsOfProfilesToUnfollow: _toUint256Array(targetProfileId),