Files
core/contracts/interfaces/ILensHub.sol

527 lines
22 KiB
Solidity

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.10;
import {DataTypes} from '../libraries/DataTypes.sol';
/**
* @title ILensHub
* @author Lens Protocol
*
* @notice This is the interface for the LensHub contract, the main entry point for the Lens Protocol.
* You'll find all the events and external functions, as well as the reasoning behind them here.
*/
interface ILensHub {
/**
* @notice Initializes the LensHub NFT, setting the initial governance address as well as the name and symbol in
* the LensNFTBase contract.
*
* @param name The name to set for the hub NFT.
* @param symbol The symbol to set for the hub NFT.
* @param newGovernance The governance address to set.
*/
function initialize(
string calldata name,
string calldata symbol,
address newGovernance
) external;
/**
* @notice Sets the privileged governance role. This function can only be called by the current governance
* address.
*
* @param newGovernance The new governance address to set.
*/
function setGovernance(address newGovernance) external;
/**
* @notice Sets the emergency admin, which is a permissioned role able to set the protocol state. This function
* can only be called by the governance address.
*
* @param newEmergencyAdmin The new emergency admin address to set.
*/
function setEmergencyAdmin(address newEmergencyAdmin) external;
/**
* @notice Sets the protocol state to either a global pause, a publishing pause or an unpaused state. This function
* can only be called by the governance address or the emergency admin address.
*
* @param newState The state to set, as a member of the ProtocolState enum.
*/
function setState(DataTypes.ProtocolState newState) external;
/**
* @notice Adds or removes a profile creator from the whitelist. This function can only be called by the current
* governance address.
*
* @param profileCreator The profile creator address to add or remove from the whitelist.
* @param whitelist Whether or not the profile creator should be whitelisted.
*/
function whitelistProfileCreator(address profileCreator, bool whitelist) external;
/**
* @notice Adds or removes a follow module from the whitelist. This function can only be called by the current
* governance address.
*
* @param followModule The follow module contract address to add or remove from the whitelist.
* @param whitelist Whether or not the follow module should be whitelisted.
*/
function whitelistFollowModule(address followModule, bool whitelist) external;
/**
* @notice Adds or removes a reference module from the whitelist. This function can only be called by the current
* governance address.
*
* @param referenceModule The reference module contract to add or remove from the whitelist.
* @param whitelist Whether or not the reference module should be whitelisted.
*/
function whitelistReferenceModule(address referenceModule, bool whitelist) external;
/**
* @notice Adds or removes a collect module from the whitelist. This function can only be called by the current
* governance address.
*
* @param collectModule The collect module contract address to add or remove from the whitelist.
* @param whitelist Whether or not the collect module should be whitelisted.
*/
function whitelistCollectModule(address collectModule, bool whitelist) external;
/**
* @notice Creates a profile with the specified parameters, minting a profile NFT to the given recipient. This
* function must be called by a whitelisted profile creator.
*
* @param vars A CreateProfileData struct containing the following params:
* to: The address receiving the profile.
* handle: The handle to set for the profile, must be unique and non-empty.
* imageURI: The URI to set for the profile image.
* followModule: The follow module to use, can be the zero address.
* followModuleData: The follow module initialization data, if any.
*/
function createProfile(DataTypes.CreateProfileData calldata vars) external returns (uint256);
/**
* @notice Sets the mapping between wallet and its main profile identity.
*
* @param profileId The token ID of the profile to set as the main profile identity.
*/
function setDefaultProfile(uint256 profileId) external;
/**
* @notice Sets the mapping between wallet and its main profile identity via signature with the specified parameters.
*
* @param vars A SetDefaultProfileWithSigData struct, including the regular parameters and an EIP712Signature struct.
*/
function setDefaultProfileWithSig(DataTypes.SetDefaultProfileWithSigData calldata vars)
external;
/**
* @notice Sets a profile's follow module, must be called by the profile owner.
*
* @param profileId The token ID of the profile to set the follow module for.
* @param followModule The follow module to set for the given profile, must be whitelisted.
* @param followModuleData The data to be passed to the follow module for initialization.
*/
function setFollowModule(
uint256 profileId,
address followModule,
bytes calldata followModuleData
) external;
/**
* @notice Sets a profile's follow module via signature with the specified parameters.
*
* @param vars A SetFollowModuleWithSigData struct, including the regular parameters and an EIP712Signature struct.
*/
function setFollowModuleWithSig(DataTypes.SetFollowModuleWithSigData calldata vars) external;
/**
* @notice Sets a profile's dispatcher, giving that dispatcher rights to publish to that profile.
*
* @param profileId The token ID of the profile of the profile to set the dispatcher for.
* @param dispatcher The dispatcher address to set for the given profile ID.
*/
function setDispatcher(uint256 profileId, address dispatcher) external;
/**
* @notice Sets a profile's dispatcher via signature with the specified parameters.
*
* @param vars A SetDispatcherWithSigData struct, including the regular parameters and an EIP712Signature struct.
*/
function setDispatcherWithSig(DataTypes.SetDispatcherWithSigData calldata vars) external;
/**
* @notice Sets a profile's URI, which is reflected in the `tokenURI()` function.
*
* @param profileId The token ID of the profile of the profile to set the URI for.
* @param imageURI The URI to set for the given profile.
*/
function setProfileImageURI(uint256 profileId, string calldata imageURI) external;
/**
* @notice Sets a profile's URI via signature with the specified parameters.
*
* @param vars A SetProfileImageURIWithSigData struct, including the regular parameters and an EIP712Signature struct.
*/
function setProfileImageURIWithSig(DataTypes.SetProfileImageURIWithSigData calldata vars)
external;
/**
* @notice Sets a followNFT URI for a given profile's follow NFT.
*
* @param profileId The token ID of the profile for which to set the followNFT URI.
* @param followNFTURI The follow NFT URI to set.
*/
function setFollowNFTURI(uint256 profileId, string calldata followNFTURI) external;
/**
* @notice Sets a followNFT URI via signature with the specified parameters.
*
* @param vars A SetFollowNFTURIWithSigData struct, including the regular parameters and an EIP712Signature struct.
*/
function setFollowNFTURIWithSig(DataTypes.SetFollowNFTURIWithSigData calldata vars) external;
/**
* @notice Publishes a post to a given profile, must be called by the profile owner.
*
* @param vars A PostData struct containing the needed parameters.
*
* @return uint256 An integer representing the post's publication ID.
*/
function post(DataTypes.PostData calldata vars) external returns (uint256);
/**
* @notice Publishes a post to a given profile via signature with the specified parameters.
*
* @param vars A PostWithSigData struct containing the regular parameters and an EIP712Signature struct.
*
* @return uint256 An integer representing the post's publication ID.
*/
function postWithSig(DataTypes.PostWithSigData calldata vars) external returns (uint256);
/**
* @notice Publishes a comment to a given profile, must be called by the profile owner.
*
* @param vars A CommentData struct containing the needed parameters.
*
* @return uint256 An integer representing the comment's publication ID.
*/
function comment(DataTypes.CommentData calldata vars) external returns (uint256);
/**
* @notice Publishes a comment to a given profile via signature with the specified parameters.
*
* @param vars A CommentWithSigData struct containing the regular parameters and an EIP712Signature struct.
*
* @return uint256 An integer representing the comment's publication ID.
*/
function commentWithSig(DataTypes.CommentWithSigData calldata vars) external returns (uint256);
/**
* @notice Publishes a mirror to a given profile, must be called by the profile owner.
*
* @param vars A MirrorData struct containing the necessary parameters.
*
* @return uint256 An integer representing the mirror's publication ID.
*/
function mirror(DataTypes.MirrorData calldata vars) external returns (uint256);
/**
* @notice Publishes a mirror to a given profile via signature with the specified parameters.
*
* @param vars A MirrorWithSigData struct containing the regular parameters and an EIP712Signature struct.
*
* @return uint256 An integer representing the mirror's publication ID.
*/
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.
*
* NOTE: Both the `profileIds` and `datas` arrays must be of the same length, regardless if the profiles do not have a follow module set.
*
* @param profileIds The token ID array of the profiles to 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.
*/
function follow(uint256[] calldata profileIds, bytes[] calldata datas)
external
returns (uint256[] memory);
/**
* @notice Follows a given profile via signature with the specified parameters.
*
* @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.
*/
function followWithSig(DataTypes.FollowWithSigData calldata vars)
external
returns (uint256[] memory);
/**
* @notice Collects a given publication, executing collect module logic and minting a collectNFT to the caller.
*
* @param profileId The token ID of the profile that published the publication to collect.
* @param pubId The publication to collect's publication ID.
* @param data The arbitrary data to pass to the collect module if needed.
*
* @return uint256 An integer representing the minted token ID.
*/
function collect(
uint256 profileId,
uint256 pubId,
bytes calldata data
) external returns (uint256);
/**
* @notice Collects a given publication via signature with the specified parameters.
*
* @param vars A CollectWithSigData struct containing the regular parameters as well as the collector's address and
* an EIP712Signature struct.
*
* @return uint256 An integer representing the minted token ID.
*/
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.
*
* @param profileId The token ID of the profile associated with the followNFT being transferred.
* @param followNFTId The followNFT being transferred's token ID.
* @param from The address the followNFT is being transferred from.
* @param to The address the followNFT is being transferred to.
*/
function emitFollowNFTTransferEvent(
uint256 profileId,
uint256 followNFTId,
address from,
address to
) external;
/**
* @dev Helper function to emit a detailed collectNFT transfer event from the hub, to be consumed by frontends 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.
* @param collectNFTId The collectNFT being transferred's token ID.
* @param from The address the collectNFT is being transferred from.
* @param to The address the collectNFT is being transferred to.
*/
function emitCollectNFTTransferEvent(
uint256 profileId,
uint256 pubId,
uint256 collectNFTId,
address from,
address to
) external;
/// ************************
/// *****VIEW FUNCTIONS*****
/// ************************
/**
* @notice Returns whether or not a profile creator is whitelisted.
*
* @param profileCreator The address of the profile creator to check.
*
* @return bool True if the profile creator is whitelisted, false otherwise.
*/
function isProfileCreatorWhitelisted(address profileCreator) external view returns (bool);
/**
* @notice Returns default profile for a given wallet address
*
* @param wallet The address to find the default mapping
*
* @return uint256 The default profile id, which will be 0 if not mapped.
*/
function defaultProfile(address wallet) external view returns (uint256);
/**
* @notice Returns whether or not a follow module is whitelisted.
*
* @param followModule The address of the follow module to check.
*
* @return bool True if the the follow module is whitelisted, false otherwise.
*/
function isFollowModuleWhitelisted(address followModule) external view returns (bool);
/**
* @notice Returns whether or not a reference module is whitelisted.
*
* @param referenceModule The address of the reference module to check.
*
* @return bool True if the the reference module is whitelisted, false otherwise.
*/
function isReferenceModuleWhitelisted(address referenceModule) external view returns (bool);
/**
* @notice Returns whether or not a collect module is whitelisted.
*
* @param collectModule The address of the collect module to check.
*
* @return bool True if the the collect module is whitelisted, false otherwise.
*/
function isCollectModuleWhitelisted(address collectModule) external view returns (bool);
/**
* @notice Returns the currently configured governance address.
*
* @return address The address of the currently configured governance.
*/
function getGovernance() external view returns (address);
/**
* @notice Returns the dispatcher associated with a profile.
*
* @param profileId The token ID of the profile to query the dispatcher for.
*
* @return address The dispatcher address associated with the profile.
*/
function getDispatcher(uint256 profileId) external view returns (address);
/**
* @notice Returns the publication count for a given profile.
*
* @param profileId The token ID of the profile to query.
*
* @return uint256 The number of publications associated with the queried profile.
*/
function getPubCount(uint256 profileId) external view returns (uint256);
/**
* @notice Returns the followNFT associated with a given profile, if any.
*
* @param profileId The token ID of the profile to query the followNFT for.
*
* @return address The followNFT associated with the given profile.
*/
function getFollowNFT(uint256 profileId) external view returns (address);
/**
* @notice Returns the followNFT URI associated with a given profile.
*
* @param profileId The token ID of the profile to query the followNFT URI for.
*
* @return string The followNFT URI associated with the given profile.
*/
function getFollowNFTURI(uint256 profileId) external view returns (string memory);
/**
* @notice Returns the collectNFT associated with a given publication, if any.
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return address The address of the collectNFT associated with the queried publication.
*/
function getCollectNFT(uint256 profileId, uint256 pubId) external view returns (address);
/**
* @notice Returns the follow module associated witha given profile, if any.
*
* @param profileId The token ID of the profile to query the follow module for.
*
* @return address The address of the follow module associated with the given profile.
*/
function getFollowModule(uint256 profileId) external view returns (address);
/**
* @notice Returns the collect module associated with a given publication.
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return address The address of the collect module associated with the queried publication.
*/
function getCollectModule(uint256 profileId, uint256 pubId) external view returns (address);
/**
* @notice Returns the reference module associated witha given profile, if any.
*
* @param profileId The token ID of the profile that published the publication to querythe reference module for.
* @param pubId The publication ID of the publication to query the reference module for.
*
* @return address The address of the reference module associated with the given profile.
*/
function getReferenceModule(uint256 profileId, uint256 pubId) external view returns (address);
/**
* @notice Returns the handle associated with a profile.
*
* @param profileId The token ID of the profile to query the handle for.
*
* @return string The handle associated with the profile.
*/
function getHandle(uint256 profileId) external view returns (string memory);
/**
* @notice Returns the publication pointer (profileId & pubId) associated with a given publication.
*
* @param profileId The token ID of the profile that published the publication to query the pointer for.
* @param pubId The publication ID of the publication to query the pointer for.
*
* @return tuple First, the profile ID of the profile the current publication is pointing to, second, the
* publication ID of the publication the current publication is pointing to.
*/
function getPubPointer(uint256 profileId, uint256 pubId)
external
view
returns (uint256, uint256);
/**
* @notice Returns the URI associated with a given publication.
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return string The URI associated with a given publication.
*/
function getContentURI(uint256 profileId, uint256 pubId) external view returns (string memory);
/**
* @notice Returns the profile token ID according to a given handle.
*
* @param handle The handle to resolve the profile token ID with.
*
* @return uint256 The profile ID the passed handle points to.
*/
function getProfileIdByHandle(string calldata handle) external view returns (uint256);
/**
* @notice Returns the full profile struct associated with a given profile token ID.
*
* @param profileId The token ID of the profile to query.
*
* @return ProfileStruct The profile struct of the given profile.
*/
function getProfile(uint256 profileId) external view returns (DataTypes.ProfileStruct memory);
/**
* @notice Returns the full publication struct for a given publication.
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return PublicationStruct The publication struct associated with the queried publication.
*/
function getPub(uint256 profileId, uint256 pubId)
external
view
returns (DataTypes.PublicationStruct memory);
/**
* @notice Returns the publication type associated with a given publication.
*
* @param profileId The token ID of the profile that published the publication to query.
* @param pubId The publication ID of the publication to query.
*
* @return PubType The publication type, as a member of an enum (either "post," "comment" or "mirror").
*/
function getPubType(uint256 profileId, uint256 pubId) external view returns (DataTypes.PubType);
}