mirror of
https://github.com/lens-protocol/core.git
synced 2026-01-10 14:48:15 -05:00
misc: C4-168-N04 Allow to unfollow() for burnt target profiles T-16806
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user