mirror of
https://github.com/lens-protocol/core.git
synced 2026-01-10 14:48:15 -05:00
feat: Reference modules allow self-comment
This commit is contained in:
@@ -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 '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user