Skip to content

Commit

Permalink
feat: Added hasCollected and isFollowing to ProfileAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSparksCode committed Oct 27, 2022
1 parent d82b2b8 commit dd06d03
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions contracts/misc/ProfileAccess.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
pragma solidity 0.8.10;

import {VersionedInitializable} from '../upgradeability/VersionedInitializable.sol';
import {ILensHub} from '../interfaces/ILensHub.sol';
import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol';

/**
* @title ProfileAccess
* @title AccessControl
* @author Lens Protocol
*
* @notice This contract enables additional access control for encrypted publications on Lens by reporting whether
* an address owns or has control over a given profile.
*/
contract ProfileAccess is VersionedInitializable {
contract AccessControl is VersionedInitializable {
uint256 internal constant REVISION = 1;

address internal immutable LENS_HUB;
Expand All @@ -39,6 +40,29 @@ contract ProfileAccess is VersionedInitializable {
return IERC721(LENS_HUB).ownerOf(profileId) == requestorAddress;
}

function hasCollected(
address requestorAddress,
uint256 publisherId,
uint256 pubId,
uint256 collectorProfileId,
bytes memory data
) external view returns (bool) {
address collectNFT = ILensHub(LENS_HUB).getCollectNFT(publisherId, pubId);

return collectNFT != address(0) && IERC721(collectNFT).balanceOf(requestorAddress) > 0;
}

function isFollowing(
address requestorAddress,
uint256 profileId,
uint256 followerProfileId,
bytes memory data
) external view returns (bool) {
address followNFT = ILensHub(LENS_HUB).getFollowNFT(profileId);

return followNFT != address(0) && IERC721(followNFT).balanceOf(requestorAddress) > 0;
}

function getRevision() internal pure virtual override returns (uint256) {
return REVISION;
}
Expand Down

0 comments on commit dd06d03

Please sign in to comment.