diff --git a/contracts/modules/reference/FollowerOnlyReferenceModule.sol b/contracts/modules/reference/FollowerOnlyReferenceModule.sol index f6966ba..447b17c 100644 --- a/contracts/modules/reference/FollowerOnlyReferenceModule.sol +++ b/contracts/modules/reference/FollowerOnlyReferenceModule.sol @@ -23,9 +23,9 @@ contract FollowerOnlyReferenceModule is HubRestricted, IReferenceModule { * @dev There is nothing needed at initialization. */ function initializeReferenceModule( - uint256, /* profileId */ - uint256, /* pubId */ - address, /* transactionExecutor */ + uint256 /* profileId */, + uint256 /* pubId */, + address /* transactionExecutor */, bytes calldata /* data */ ) external pure returns (bytes memory) { return ''; @@ -34,57 +34,55 @@ contract FollowerOnlyReferenceModule is HubRestricted, IReferenceModule { /** * @inheritdoc IReferenceModule * - * @dev Validates that the commenting profile's owner is a follower. + * @dev Validates that the commenting profile is the original author or a follower of it. */ - function processComment(Types.ProcessCommentParams calldata processCommentParams) - external - view - override - returns (bytes memory) - { - FollowValidationLib.validateIsFollowing({ - hub: HUB, - followerProfileId: processCommentParams.profileId, - followedProfileId: processCommentParams.pointedProfileId - }); - return ''; + function processComment( + Types.ProcessCommentParams calldata processCommentParams + ) external view override returns (bytes memory) { + return + _performFollowerOnlyCheck({ + followerProfileId: processCommentParams.profileId, + followedProfileId: processCommentParams.pointedProfileId + }); } /** * @inheritdoc IReferenceModule * - * @dev Validates that the quoting profile's owner is a follower. + * @dev Validates that the quoting profile is the original author or a follower of it. */ - function processQuote(Types.ProcessQuoteParams calldata processQuoteParams) - external - view - override - returns (bytes memory) - { - FollowValidationLib.validateIsFollowing({ - hub: HUB, - followerProfileId: processQuoteParams.profileId, - followedProfileId: processQuoteParams.pointedProfileId - }); - return ''; + function processQuote( + Types.ProcessQuoteParams calldata processQuoteParams + ) external view override returns (bytes memory) { + return + _performFollowerOnlyCheck({ + followerProfileId: processQuoteParams.profileId, + followedProfileId: processQuoteParams.pointedProfileId + }); } /** * @inheritdoc IReferenceModule * - * @dev Validates that the mirroring profile's owner is a follower. + * @dev Validates that the mirroring profile is the original author or a follower of it. */ - function processMirror(Types.ProcessMirrorParams calldata processMirrorParams) - external - view - override - returns (bytes memory) - { - FollowValidationLib.validateIsFollowing({ - hub: HUB, - followerProfileId: processMirrorParams.profileId, - followedProfileId: processMirrorParams.pointedProfileId - }); + function processMirror( + Types.ProcessMirrorParams calldata processMirrorParams + ) external view override returns (bytes memory) { + return + _performFollowerOnlyCheck({ + followerProfileId: processMirrorParams.profileId, + followedProfileId: processMirrorParams.pointedProfileId + }); + } + + function _performFollowerOnlyCheck( + uint256 followerProfileId, + uint256 followedProfileId + ) internal view returns (bytes memory) { + if (followedProfileId != followedProfileId) { + FollowValidationLib.validateIsFollowing(HUB, followerProfileId, followedProfileId); + } return ''; } } diff --git a/contracts/modules/reference/TokenGatedReferenceModule.sol b/contracts/modules/reference/TokenGatedReferenceModule.sol index 8d2303a..0e47db1 100644 --- a/contracts/modules/reference/TokenGatedReferenceModule.sol +++ b/contracts/modules/reference/TokenGatedReferenceModule.sol @@ -149,7 +149,7 @@ contract TokenGatedReferenceModule is HubRestricted, IReferenceModule { ) internal view returns (uint256) { GateParams memory gateParams = _gateParams[pointedProfileId][pointedPubId]; uint256 balance = IToken(gateParams.tokenAddress).balanceOf(IERC721(HUB).ownerOf(profileId)); - if (balance < gateParams.minThreshold) { + if (profileId != pointedProfileId && balance < gateParams.minThreshold) { revert NotEnoughBalance(); } return balance;