380 lines
16 KiB
Solidity
380 lines
16 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.17;
|
|
|
|
/**
|
|
* @title DataTypes
|
|
* @author Lens Protocol
|
|
*
|
|
* @notice A standard library of data types used throughout the Lens Protocol.
|
|
*/
|
|
library DataTypes {
|
|
/**
|
|
* @notice An enum containing the different states the protocol can be in, limiting certain actions.
|
|
*
|
|
* @param Unpaused The fully unpaused state.
|
|
* @param PublishingPaused The state where only publication creation functions are paused.
|
|
* @param Paused The fully paused state.
|
|
*/
|
|
enum ProtocolState {
|
|
Unpaused,
|
|
PublishingPaused,
|
|
Paused
|
|
}
|
|
|
|
/**
|
|
* @notice An enum specifically used in a helper function to easily retrieve the publication type for integrations.
|
|
*
|
|
* @param Post A standard post, having a URI, a collect module but no pointer to another publication.
|
|
* @param Comment A comment, having a URI, a collect module and a pointer to another publication.
|
|
* @param Mirror A mirror, having a pointer to another publication, but no URI or collect module.
|
|
* @param Nonexistent An indicator showing the queried publication does not exist.
|
|
*/
|
|
enum PubType {
|
|
Post,
|
|
Comment,
|
|
Mirror,
|
|
Nonexistent
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the necessary information to reconstruct an EIP-712 typed data signature.
|
|
*
|
|
* @param v The signature's recovery parameter.
|
|
* @param r The signature's r parameter.
|
|
* @param s The signature's s parameter
|
|
* @param deadline The signature's deadline
|
|
*/
|
|
struct EIP712Signature {
|
|
uint8 v;
|
|
bytes32 r;
|
|
bytes32 s;
|
|
uint256 deadline;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing profile data.
|
|
*
|
|
* @param pubCount The number of publications made to this profile.
|
|
* @param followModule The address of the current follow module in use by this profile, can be empty.
|
|
* @param followNFT The address of the followNFT associated with this profile, can be empty..
|
|
* @param handle The profile's associated handle.
|
|
* @param imageURI The URI to be used for the profile's image.
|
|
* @param followNFTURI The URI to be used for the follow NFT.
|
|
*/
|
|
struct ProfileStruct {
|
|
uint256 pubCount;
|
|
address followModule;
|
|
address followNFT;
|
|
string handle;
|
|
string imageURI;
|
|
string followNFTURI;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing data associated with each new publication.
|
|
*
|
|
* @param profileIdPointed The profile token ID this publication points to, for mirrors and comments.
|
|
* @param pubIdPointed The publication ID this publication points to, for mirrors and comments.
|
|
* @param contentURI The URI associated with this publication.
|
|
* @param referenceModule The address of the current reference module in use by this publication, can be empty.
|
|
* @param collectModule The address of the collect module associated with this publication, this exists for all publication.
|
|
* @param collectNFT The address of the collectNFT associated with this publication, if any.
|
|
*/
|
|
struct PublicationStruct {
|
|
uint256 profileIdPointed;
|
|
uint256 pubIdPointed;
|
|
string contentURI;
|
|
address referenceModule;
|
|
address collectModule;
|
|
address collectNFT;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `createProfile()` function.
|
|
*
|
|
* @param to The address receiving the profile.
|
|
* @param handle The handle to set for the profile, must be unique and non-empty.
|
|
* @param imageURI The URI to set for the profile image.
|
|
* @param followModule The follow module to use, can be the zero address.
|
|
* @param followModuleInitData The follow module initialization data, if any.
|
|
* @param followNFTURI The URI to use for the follow NFT.
|
|
*/
|
|
struct CreateProfileData {
|
|
address to;
|
|
string handle;
|
|
string imageURI;
|
|
address followModule;
|
|
bytes followModuleInitData;
|
|
string followNFTURI;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `setDefaultProfileWithSig()` function. Parameters are
|
|
* the same as the regular `setDefaultProfile()` function, with an added EIP712Signature.
|
|
*
|
|
* @param wallet The address of the wallet setting the default profile.
|
|
* @param profileId The token ID of the profile which will be set as default, or zero.
|
|
* @param sig The EIP712Signature struct containing the profile owner's signature.
|
|
*/
|
|
struct SetDefaultProfileWithSigData {
|
|
address wallet;
|
|
uint256 profileId;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `setFollowModuleWithSig()` function. Parameters are
|
|
* the same as the regular `setFollowModule()` function, with an added EIP712Signature.
|
|
*
|
|
* @param profileId The token ID of the profile to change the followModule for.
|
|
* @param followModule The followModule to set for the given profile, must be whitelisted.
|
|
* @param followModuleInitData The data to be passed to the followModule for initialization.
|
|
* @param sig The EIP712Signature struct containing the profile owner's signature.
|
|
*/
|
|
struct SetFollowModuleWithSigData {
|
|
uint256 profileId;
|
|
address followModule;
|
|
bytes followModuleInitData;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `setDispatcherWithSig()` function. Parameters are the same
|
|
* as the regular `setDispatcher()` function, with an added EIP712Signature.
|
|
*
|
|
* @param profileId The token ID of the profile to set the dispatcher for.
|
|
* @param dispatcher The dispatcher address to set for the profile.
|
|
* @param sig The EIP712Signature struct containing the profile owner's signature.
|
|
*/
|
|
struct SetDispatcherWithSigData {
|
|
uint256 profileId;
|
|
address dispatcher;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `setProfileImageURIWithSig()` function. Parameters are the same
|
|
* as the regular `setProfileImageURI()` function, with an added EIP712Signature.
|
|
*
|
|
* @param profileId The token ID of the profile to set the URI for.
|
|
* @param imageURI The URI to set for the given profile image.
|
|
* @param sig The EIP712Signature struct containing the profile owner's signature.
|
|
*/
|
|
struct SetProfileImageURIWithSigData {
|
|
uint256 profileId;
|
|
string imageURI;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `setFollowNFTURIWithSig()` function. Parameters are the same
|
|
* as the regular `setFollowNFTURI()` function, with an added EIP712Signature.
|
|
*
|
|
* @param profileId The token ID of the profile for which to set the followNFT URI.
|
|
* @param followNFTURI The follow NFT URI to set.
|
|
* @param sig The EIP712Signature struct containing the followNFT's associated profile owner's signature.
|
|
*/
|
|
struct SetFollowNFTURIWithSigData {
|
|
uint256 profileId;
|
|
string followNFTURI;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `post()` function.
|
|
*
|
|
* @param profileId The token ID of the profile to publish to.
|
|
* @param contentURI The URI to set for this new publication.
|
|
* @param collectModule The collect module to set for this new publication.
|
|
* @param collectModuleInitData The data to pass to the collect module's initialization.
|
|
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
|
|
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
|
|
*/
|
|
struct PostData {
|
|
uint256 profileId;
|
|
string contentURI;
|
|
address collectModule;
|
|
bytes collectModuleInitData;
|
|
address referenceModule;
|
|
bytes referenceModuleInitData;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `postWithSig()` function. Parameters are the same as
|
|
* the regular `post()` function, with an added EIP712Signature.
|
|
*
|
|
* @param profileId The token ID of the profile to publish to.
|
|
* @param contentURI The URI to set for this new publication.
|
|
* @param collectModule The collectModule to set for this new publication.
|
|
* @param collectModuleInitData The data to pass to the collectModule's initialization.
|
|
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
|
|
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
|
|
* @param sig The EIP712Signature struct containing the profile owner's signature.
|
|
*/
|
|
struct PostWithSigData {
|
|
uint256 profileId;
|
|
string contentURI;
|
|
address collectModule;
|
|
bytes collectModuleInitData;
|
|
address referenceModule;
|
|
bytes referenceModuleInitData;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `comment()` function.
|
|
*
|
|
* @param profileId The token ID of the profile to publish to.
|
|
* @param contentURI The URI to set for this new publication.
|
|
* @param profileIdPointed The profile token ID to point the comment to.
|
|
* @param pubIdPointed The publication ID to point the comment to.
|
|
* @param referenceModuleData The data passed to the reference module.
|
|
* @param collectModule The collect module to set for this new publication.
|
|
* @param collectModuleInitData The data to pass to the collect module's initialization.
|
|
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
|
|
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
|
|
*/
|
|
struct CommentData {
|
|
uint256 profileId;
|
|
string contentURI;
|
|
uint256 profileIdPointed;
|
|
uint256 pubIdPointed;
|
|
bytes referenceModuleData;
|
|
address collectModule;
|
|
bytes collectModuleInitData;
|
|
address referenceModule;
|
|
bytes referenceModuleInitData;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `commentWithSig()` function. Parameters are the same as
|
|
* the regular `comment()` function, with an added EIP712Signature.
|
|
*
|
|
* @param profileId The token ID of the profile to publish to.
|
|
* @param contentURI The URI to set for this new publication.
|
|
* @param profileIdPointed The profile token ID to point the comment to.
|
|
* @param pubIdPointed The publication ID to point the comment to.
|
|
* @param referenceModuleData The data passed to the reference module.
|
|
* @param collectModule The collectModule to set for this new publication.
|
|
* @param collectModuleInitData The data to pass to the collectModule's initialization.
|
|
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
|
|
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
|
|
* @param sig The EIP712Signature struct containing the profile owner's signature.
|
|
*/
|
|
struct CommentWithSigData {
|
|
uint256 profileId;
|
|
string contentURI;
|
|
uint256 profileIdPointed;
|
|
uint256 pubIdPointed;
|
|
bytes referenceModuleData;
|
|
address collectModule;
|
|
bytes collectModuleInitData;
|
|
address referenceModule;
|
|
bytes referenceModuleInitData;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `mirror()` function.
|
|
*
|
|
* @param profileId The token ID of the profile to publish to.
|
|
* @param profileIdPointed The profile token ID to point the mirror to.
|
|
* @param pubIdPointed The publication ID to point the mirror to.
|
|
* @param referenceModuleData The data passed to the reference module.
|
|
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
|
|
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
|
|
*/
|
|
struct MirrorData {
|
|
uint256 profileId;
|
|
uint256 profileIdPointed;
|
|
uint256 pubIdPointed;
|
|
bytes referenceModuleData;
|
|
address referenceModule;
|
|
bytes referenceModuleInitData;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `mirrorWithSig()` function. Parameters are the same as
|
|
* the regular `mirror()` function, with an added EIP712Signature.
|
|
*
|
|
* @param profileId The token ID of the profile to publish to.
|
|
* @param profileIdPointed The profile token ID to point the mirror to.
|
|
* @param pubIdPointed The publication ID to point the mirror to.
|
|
* @param referenceModuleData The data passed to the reference module.
|
|
* @param referenceModule The reference module to set for the given publication, must be whitelisted.
|
|
* @param referenceModuleInitData The data to be passed to the reference module for initialization.
|
|
* @param sig The EIP712Signature struct containing the profile owner's signature.
|
|
*/
|
|
struct MirrorWithSigData {
|
|
uint256 profileId;
|
|
uint256 profileIdPointed;
|
|
uint256 pubIdPointed;
|
|
bytes referenceModuleData;
|
|
address referenceModule;
|
|
bytes referenceModuleInitData;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `followWithSig()` function. Parameters are the same
|
|
* as the regular `follow()` function, with the follower's (signer) address and an EIP712Signature added.
|
|
*
|
|
* @param follower The follower which is the message signer.
|
|
* @param profileIds The array of token IDs of the profiles to follow.
|
|
* @param datas The array of arbitrary data to pass to the followModules if needed.
|
|
* @param sig The EIP712Signature struct containing the follower's signature.
|
|
*/
|
|
struct FollowWithSigData {
|
|
address follower;
|
|
uint256[] profileIds;
|
|
bytes[] datas;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `collectWithSig()` function. Parameters are the same as
|
|
* the regular `collect()` function, with the collector's (signer) address and an EIP712Signature added.
|
|
*
|
|
* @param collector The collector which is the message signer.
|
|
* @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 collectModule if needed.
|
|
* @param sig The EIP712Signature struct containing the collector's signature.
|
|
*/
|
|
struct CollectWithSigData {
|
|
address collector;
|
|
uint256 profileId;
|
|
uint256 pubId;
|
|
bytes data;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `setProfileMetadataWithSig()` function.
|
|
*
|
|
* @param profileId The profile ID for which to set the metadata.
|
|
* @param metadata The metadata string to set for the profile and user.
|
|
* @param sig The EIP712Signature struct containing the user's signature.
|
|
*/
|
|
struct SetProfileMetadataWithSigData {
|
|
uint256 profileId;
|
|
string metadata;
|
|
EIP712Signature sig;
|
|
}
|
|
|
|
/**
|
|
* @notice A struct containing the parameters required for the `toggleFollowWithSig()` function.
|
|
*
|
|
* @param follower The follower which is the message signer.
|
|
* @param profileIds The token ID array of the profiles.
|
|
* @param enables The array of booleans to enable/disable follows.
|
|
* @param sig The EIP712Signature struct containing the follower's signature.
|
|
*/
|
|
struct ToggleFollowWithSigData {
|
|
address follower;
|
|
uint256[] profileIds;
|
|
bool[] enables;
|
|
EIP712Signature sig;
|
|
}
|
|
}
|