feat: validateNotBlocked moved to GeneralHelpers

This commit is contained in:
donosonaumczuk
2023-01-09 22:54:45 -03:00
parent ded7f35f5a
commit b6d04d2d5d
2 changed files with 16 additions and 16 deletions

View File

@@ -229,4 +229,19 @@ library GeneralHelpers {
}
return originator;
}
function validateNotBlocked(uint256 profile, uint256 byProfile) internal view {
bool isBlocked;
assembly {
mstore(0, byProfile)
mstore(32, BLOCK_STATUS_MAPPING_SLOT)
let blockStatusByProfileSlot := keccak256(0, 64)
mstore(0, profile)
mstore(32, blockStatusByProfileSlot)
isBlocked := sload(keccak256(0, 64))
}
if (isBlocked) {
revert Errors.Blocked();
}
}
}

View File

@@ -51,7 +51,7 @@ library InteractionHelpers {
while (i < idsOfProfilesToFollow.length) {
_validateProfileExists(idsOfProfilesToFollow[i]);
_validateNotBlocked(followerProfileId, idsOfProfilesToFollow[i]);
GeneralHelpers.validateNotBlocked(followerProfileId, idsOfProfilesToFollow[i]);
if (followerProfileId == idsOfProfilesToFollow[i]) {
revert Errors.SelfFollow();
@@ -420,19 +420,4 @@ library InteractionHelpers {
if (GeneralHelpers.unsafeOwnerOf(profileId) == address(0))
revert Errors.TokenDoesNotExist();
}
function _validateNotBlocked(uint256 profile, uint256 byProfile) private view {
bool isBlocked;
assembly {
mstore(0, byProfile)
mstore(32, BLOCK_STATUS_MAPPING_SLOT)
let blockStatusByProfileSlot := keccak256(0, 64)
mstore(0, profile)
mstore(32, blockStatusByProfileSlot)
isBlocked := sload(keccak256(0, 64))
}
if (isBlocked) {
revert Errors.Blocked();
}
}
}