misc: Missing natspec added

This commit is contained in:
donosonaumczuk
2022-12-06 16:28:19 +00:00
parent 4cbbbd6d48
commit e16d168282
4 changed files with 198 additions and 48 deletions

View File

@@ -81,15 +81,7 @@ contract FollowNFT is HubRestricted, LensNFTBase, ERC2981CollectionRoyalties, IF
emit Events.FollowNFTInitialized(profileId, block.timestamp);
}
/**
* @param followerProfileId The ID of the profile acting as the follower.
* @param executor The address executing the operation.
* @param followerProfileOwner The address holding the follower profile.
* @param isExecutorApproved A boolean indicading whether the executor is an approved delegated executor of the
* follower profile's owner.
* @param followTokenId The follow token ID to be used for this follow operation. Use zero if a new follow token should
* be minted.
*/
/// @inheritdoc IFollowNFT
function follow(
uint256 followerProfileId,
address executor,
@@ -148,13 +140,7 @@ contract FollowNFT is HubRestricted, LensNFTBase, ERC2981CollectionRoyalties, IF
return followTokenIdAssigned;
}
/**
* @param unfollowerProfileId The ID of the profile that is perfrorming the unfollow operation.
* @param executor The address executing the operation.
* @param isExecutorApproved A boolean indicading whether the executor is an approved delegated executor of the
* unfollower profile's owner.
* @param unfollowerProfileOwner The address holding the unfollower profile.
*/
/// @inheritdoc IFollowNFT
function unfollow(
uint256 unfollowerProfileId,
address executor,
@@ -181,8 +167,7 @@ contract FollowNFT is HubRestricted, LensNFTBase, ERC2981CollectionRoyalties, IF
}
}
// Get the follower profile from a given follow token.
// Zero if not being used as a follow.
/// @inheritdoc IFollowNFT
function getFollowerProfileId(uint256 followTokenId) external view override returns (uint256) {
if (_tokenData[followTokenId].mintTimestamp == 0) {
revert FollowTokenDoesNotExist();
@@ -190,16 +175,17 @@ contract FollowNFT is HubRestricted, LensNFTBase, ERC2981CollectionRoyalties, IF
return _followDataByFollowTokenId[followTokenId].followerProfileId;
}
/// @inheritdoc IFollowNFT
function isFollowing(uint256 followerProfileId) external view override returns (bool) {
return _followTokenIdByFollowerProfileId[followerProfileId] != 0;
}
/// @inheritdoc IFollowNFT
function getFollowTokenId(uint256 followerProfileId) external view override returns (uint256) {
return _followTokenIdByFollowerProfileId[followerProfileId];
}
// Approve someone to set me as follower on a specific asset.
// For any asset you must use delegated execution feature with a contract adding restrictions.
/// @inheritdoc IFollowNFT
function approveFollowWithToken(uint256 followerProfileId, uint256 followTokenId)
external
override
@@ -213,7 +199,7 @@ contract FollowNFT is HubRestricted, LensNFTBase, ERC2981CollectionRoyalties, IF
_approveFollowWithToken(followerProfileId, followTokenId);
}
// Approve someone to set any follower on one of my wrapped tokens.
/// @inheritdoc IFollowNFT
function approveSetFollowerInToken(address operator, uint256 followTokenId) external override {
TokenData memory followToken = _tokenData[followTokenId];
if (followToken.mintTimestamp == 0) {
@@ -228,10 +214,7 @@ contract FollowNFT is HubRestricted, LensNFTBase, ERC2981CollectionRoyalties, IF
_approveSetFollowerInToken(operator, followTokenId);
}
/**
* @dev Unties the follow token from the follower's profile token, and wrapps it into the ERC-721 untied follow
* collection.
*/
/// @inheritdoc IFollowNFT
function untieAndWrap(uint256 followTokenId) external override {
TokenData memory followToken = _tokenData[followTokenId];
if (followToken.mintTimestamp == 0) {
@@ -246,10 +229,7 @@ contract FollowNFT is HubRestricted, LensNFTBase, ERC2981CollectionRoyalties, IF
);
}
/**
* @dev Unwrapps the follow token from the ERC-721 untied follow collection, and ties it to the follower's profile
* token.
*/
/// @inheritdoc IFollowNFT
function unwrapAndTie(uint256 followerProfileId) external override {
uint256 followTokenId = _followTokenIdByFollowerProfileId[followerProfileId];
if (followTokenId == 0) {
@@ -261,6 +241,7 @@ contract FollowNFT is HubRestricted, LensNFTBase, ERC2981CollectionRoyalties, IF
_burnWithoutClearingApprovals(followTokenId);
}
/// @inheritdoc IFollowNFT
function block(uint256 followerProfileId) external override onlyHub {
uint256 followTokenId = _followTokenIdByFollowerProfileId[followerProfileId];
if (followTokenId != 0) {

View File

@@ -12,12 +12,30 @@ import {DataTypes} from '../libraries/DataTypes.sol';
*/
interface IFollowNFT {
/**
* @notice Initializes the follow NFT, setting the hub as the privileged minter and storing the associated profile ID.
* @notice Initializes the follow NFT.
*
* @param profileId The token ID of the profile in the hub associated with this followNFT, used for transfer hooks.
* @dev Sets the hub as priviliged sender, the targeted profile, and the token royalties.
*
* @param profileId The ID of the profile targeted by the follow tokens minted by this collection.
*/
function initialize(uint256 profileId) external;
/**
* @notice Makes the passed profile to follow the profile targetted in this contract.
*
* @dev This must be only callable by the LensHub contract.
*
* @param followerProfileId The ID of the profile acting as the follower.
* @param executor The address executing the operation, which is the signer in case of using meta-transactions or
* the sender otherwise.
* @param followerProfileOwner The address holding the follower profile.
* @param isExecutorApproved A boolean indicading whether the executor is an approved delegated executor of the
* follower profile's owner.
* @param followTokenId The ID of the follow token to be used for this follow operation. Zero if a new follow token
* should be minted.
*
* @return uint256 The ID of the token used to follow.
*/
function follow(
uint256 followerProfileId,
address executor,
@@ -26,6 +44,18 @@ interface IFollowNFT {
uint256 followTokenId
) external returns (uint256);
/**
* @notice Makes the passed profile to unfollow the profile targetted in this contract.
*
* @dev This must be only callable by the LensHub contract.
*
* @param unfollowerProfileId The ID of the profile that is perfrorming the unfollow operation.
* @param executor The address executing the operation, which is the signer in case of using meta-transactions or
* the sender otherwise.
* @param isExecutorApproved A boolean indicading whether the executor is an approved delegated executor of the
* unfollower profile's owner.
* @param unfollowerProfileOwner The address holding the unfollower profile.
*/
function unfollow(
uint256 unfollowerProfileId,
address executor,
@@ -33,24 +63,93 @@ interface IFollowNFT {
address unfollowerProfileOwner
) external;
/**
* @notice Gets the ID of the profile following with the given follow token.
*
* @param followTokenId The ID of the follow token whose follower should be queried.
*
* @return uint256 The ID of the profile set as follower in the given token, zero if it is not being used to follow.
*/
function getFollowerProfileId(uint256 followTokenId) external view returns (uint256);
/**
* @notice Tells if the given profile is following the profile targeted in this contract.
*
* @param followerProfileId The ID of the profile whose following state should be queried.
*
* @return uint256 The ID of the profile set as follower in the given token, zero if it is not being used to follow.
*/
function isFollowing(uint256 followerProfileId) external view returns (bool);
/**
* @notice Tells if the given profile is following the profile targeted in this contract.
*
* @param followerProfileId The ID of the profile whose following state should be queried.
*
* @return uint256 The ID of the profile set as follower in the given token, zero if it is not being used to follow.
*/
function getFollowTokenId(uint256 followerProfileId) external view returns (uint256);
function approveFollowWithToken(uint256 followerProfileId, uint256 followTokenId) external;
/**
* @notice Approves the given profile to follow with the given follow token.
*
* @param followerProfileId The ID of the profile to approve to follow.
* @param followTokenId The ID of the follow token to approve to follow with.
*/
function approveFollowWithToken(uint256 followerProfileId, uint256 followTokenId) external; // TODO: maybe rename to approveProfileToFollowWithToken
function approveSetFollowerInToken(address operator, uint256 followTokenId) external;
/**
* @notice Approves the given address to set a follower on a given wrapped token.
*
* @param operator The address to approve to set the follower in the token.
* @param followTokenId The ID of the follow token to approve for the follower to be set in.
*/
function approveSetFollowerInToken(address operator, uint256 followTokenId) external; // TODO: maybe rename to approveTokenToBeUsedToFollowByProfile
/**
* @notice Unties the follow token from the follower's profile token, and wrapps it into the ERC-721 untied follow
* tokens collection.
*
* @param followTokenId The ID of the follow token to untie and wrap.
*/
function untieAndWrap(uint256 followTokenId) external;
/**
* @notice Unwrapps the follow token from the ERC-721 untied follow tokens collection, and ties it to the follower's
* profile token.
*
* @param followerProfileId The ID of the profile whose token being used to follow should be unwrapped and tied.
*/
function unwrapAndTie(uint256 followerProfileId) external;
/**
* @notice Blocks the given profile. If it was following the targetted profile, this will make it to unfollow.
*
* @dev This must be only callable by the LensHub contract.
*
* @param followerProfileId The ID of the follow token to unwrap and tie.
*/
function block(uint256 followerProfileId) external;
/**
* @notice Delegates voting power from the given profile to the given address.
*
* @dev The profile must be following to be able to have or delegate voting power.
*
* @param delegatorProfileId The ID of the profile delegating voting power.
* @param delegatee The address which voting power is delegated to.
*/
function delegate(uint256 delegatorProfileId, address delegatee) external;
/**
* @notice Delegates voting power from the given profile to the given address through meta-transactions.
*
* @dev The profile must be following to be able to have or delegate voting power.
*
* @param delegatorProfileId The ID of the profile delegating voting power.
* @param delegatee The address which voting power is delegated to.
* @param sig An EIP712Signature struct containing the signature for the `DelegateBySig` message.
*/
function delegateBySig(
uint256 delegatorProfileId,
address delegatee,

View File

@@ -283,16 +283,17 @@ interface ILensHub {
function mirrorWithSig(DataTypes.MirrorWithSigData calldata vars) external returns (uint256);
/**
* @notice Follows the given profiles, executing each profile's follow module logic (if any) and minting followNFTs to the caller.
* @notice Follows the given profiles, executing each profile's follow module logic (if any).
*
* NOTE: Both the `profileIds` and `datas` arrays must be of the same length, regardless if the profiles do not have a follow module set.
* @dev Both the `idsOfProfilesToFollow`, `followTokenIds`, and `datas` arrays must be of the same length,
* regardless if the profiles do not have a follow module set.
*
* @param followerProfileId The profile the follow is being executed for.
* @param idsOfProfilesToFollow The token ID array of the profiles to follow.
* @param followerProfileId The ID of the profile the follows are being executed for.
* @param idsOfProfilesToFollow The array of IDs of profiles to follow.
* @param followTokenIds The array of follow token IDs to use for each follow.
* @param datas The arbitrary data array to pass to the follow module for each profile if needed.
*
* @return uint256[] An array of integers representing the minted follow NFTs token IDs.
* @return uint256[] An array follow token IDs used for each follow operation.
*/
function follow(
uint256 followerProfileId,
@@ -302,29 +303,59 @@ interface ILensHub {
) external returns (uint256[] memory);
/**
* @notice Follows a given profile via signature with the specified parameters. The signer must either be the follower
* or a delegated executor.
* @notice Follows the given profiles via signature with the specified parameters. The signer must either be the
* follower or a delegated executor.
*
* @param vars A FollowWithSigData struct containing the regular parameters as well as the signing follower's address
* and an EIP712Signature struct.
* @param vars A FollowWithSigData struct containing the regular parameters as well as the signing follower's
* address and an EIP712Signature struct.
*
* @return uint256[] An array of integers representing the minted follow NFTs token IDs.
* @return uint256[] An array follow token IDs used for each follow operation.
*/
function followWithSig(DataTypes.FollowWithSigData calldata vars)
external
returns (uint256[] memory);
/**
* @notice Unfollows the given profiles.
*
* @param unfollowerProfileId The ID of the profile the unfollows are being executed for.
* @param idsOfProfilesToUnfollow The array of IDs of profiles to unfollow.
*/
function unfollow(uint256 unfollowerProfileId, uint256[] calldata idsOfProfilesToUnfollow)
external;
/**
* @notice Unfollows the given profiles via signature with the specified parameters. The signer must either be the
* unfollower or a delegated executor.
*
* @param vars An UnollowWithSigData struct containing the regular parameters as well as the signing unfollower's
* address and an EIP712Signature struct.
*/
function unfollowWithSig(DataTypes.UnfollowWithSigData calldata vars) external;
/**
* @notice Sets the block status for the given profiles. Changing a profile's block status to `true` (i.e. blocked),
* when it was following, will make it unfollow.
*
* @dev Both the `idsOfProfilesToSetBlockStatus` and `blockStatus` arrays must be of the same length.
*
* @param blockerProfileId The ID of the profile the block status sets are being executed for.
* @param idsOfProfilesToSetBlockStatus The array of IDs of profiles to set block status.
* @param blockStatus The array of block status to use for each setting.
*/
function setBlockStatus(
uint256 blockerProfileId,
uint256[] calldata idsOfProfilesToSetBlockStatus,
bool[] calldata blockStatus
) external;
/**
* @notice Blocks the given profiles via signature with the specified parameters. The signer must either be the
* blocker or a delegated executor.
*
* @param vars An SetBlockStatusWithSigData struct containing the regular parameters as well as the signing
* blocker's address and an EIP712Signature struct.
*/
function setBlockStatusWithSig(DataTypes.SetBlockStatusWithSigData calldata vars) external;
/**
@@ -356,8 +387,8 @@ interface ILensHub {
function collectWithSig(DataTypes.CollectWithSigData calldata vars) external returns (uint256);
/**
* @dev Helper function to emit a detailed followNFT transfer event from the hub, to be consumed by frontends to track
* followNFT transfers.
* @dev Helper function to emit a detailed followNFT transfer event from the hub, to be consumed by indexers to
* track followNFT transfers.
*
* @param profileId The token ID of the profile associated with the followNFT being transferred.
* @param followNFTId The followNFT being transferred's token ID.
@@ -372,8 +403,8 @@ interface ILensHub {
) external;
/**
* @dev Helper function to emit a detailed collectNFT transfer event from the hub, to be consumed by frontends to track
* collectNFT transfers.
* @dev Helper function to emit a detailed collectNFT transfer event from the hub, to be consumed by indexers to
* track collectNFT transfers.
*
* @param profileId The token ID of the profile associated with the collect NFT being transferred.
* @param pubId The publication ID associated with the collect NFT being transferred.
@@ -389,6 +420,13 @@ interface ILensHub {
address to
) external;
/**
* @dev Helper function to emit an `Unfollowed` event from the hub, to be consumed by indexers to track unfollows.
*
* @param unfollowerProfileId The ID of the profile that executed the unfollow.
* @param idOfProfileUnfollowed The ID of the profile that was unfollowed.
* @param followTokenId The ID of the token that was used to follow before unfollowing.
*/
function emitUnfollowedEvent(
uint256 unfollowerProfileId,
uint256 idOfProfileUnfollowed,
@@ -399,6 +437,14 @@ interface ILensHub {
/// *****VIEW FUNCTIONS*****
/// ************************
/**
* @notice Returns whether or not `followerProfileId` is following `followedProfileId`.
*
* @param followerProfileId The ID of the profile whose following state should be queried.
* @param followedProfileId The ID of the profile whose followed state should be queried.
*
* @return bool True if `followerProfileId` is following `followedProfileId`, false otherwise.
*/
function isFollowing(uint256 followerProfileId, uint256 followedProfileId)
external
view

View File

@@ -331,6 +331,15 @@ library Events {
uint256 timestamp
);
/**
* @dev Emitted upon a successful follow operation.
*
* @param followerProfileId The ID of the profile that executed the follow.
* @param idOfProfileFollowed The ID of the profile that was followed.
* @param followTokenIdAssigned The ID of the follow token assigned to the follower.
* @param followModuleData The data to passed to the follow module, if any.
* @param followTimestamp The timestamp of the follow operation.
*/
event Followed(
uint256 indexed followerProfileId,
uint256 idOfProfileFollowed,
@@ -339,13 +348,28 @@ library Events {
uint256 followTimestamp
);
/**
* @dev Emitted upon a successful unfollow operation.
*
* @param unfollowerProfileId The ID of the profile that executed the unfollow.
* @param idOfProfileUnfollowed The ID of the profile that was unfollowed.
* @param followTokenId The ID of the token that was used to follow before unfollowing.
* @param unfollowTimestamp The timestamp of the unfollow operation.
*/
event Unfollowed(
uint256 indexed unfollowerProfileId,
uint256 idOfProfileUnfollowed,
uint256 followTokenId,
uint256 followTimestamp
uint256 unfollowTimestamp
);
/**
* @dev Emitted upon a successful block status setting operation.
*
* @param blockerProfileId The ID of the profile that executed the blocks.
* @param idsOfProfilesToSetBlockStatus The IDs of the profiles whose block status have been set.
* @param blockStatus The block status that have been set for each profile.
*/
event BlockStatusSet(
uint256 indexed blockerProfileId,
uint256[] idsOfProfilesToSetBlockStatus,