Polygon Sponsored slots available. Book your slot here!
ERC-721
Overview
Max Total Supply
2 LENS-COLLECT
Holders
2
Total Transfers
-
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
This contract contains unverified libraries: ActionLib, GovernanceLib
Minimal Proxy Contract for 0x0c2a7761e2971d906338f5da1ecf0027e4247fd7
Contract Name:
CollectNFT
Compiler Version
v0.8.21+commit.d9974bed
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import {ERC2981CollectionRoyalties} from 'contracts/base/ERC2981CollectionRoyalties.sol'; import {Errors} from 'contracts/libraries/constants/Errors.sol'; import {ICollectNFT} from 'contracts/interfaces/ICollectNFT.sol'; import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import {ILensHub} from 'contracts/interfaces/ILensHub.sol'; import {LensBaseERC721} from 'contracts/base/LensBaseERC721.sol'; import {ActionRestricted} from 'contracts/modules/ActionRestricted.sol'; import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; /** * @title CollectNFT * @author Lens Protocol * * @dev This is the CollectNFT for Lens V2, it differs from LegacyCollectNFT that it's restricted to be called by an * action module instead of LensHub. * * @notice This is the NFT contract that is minted upon collecting a given publication. It is cloned upon * the first collect for a given publication, and the token URI points to the original publication's contentURI. */ contract CollectNFT is LensBaseERC721, ERC2981CollectionRoyalties, ActionRestricted, ICollectNFT { using Strings for uint256; address public immutable HUB; uint256 internal _profileId; uint256 internal _pubId; uint256 internal _tokenIdCounter; bool private _initialized; uint256 internal _royaltiesInBasisPoints; // We create the CollectNFT with the pre-computed HUB address before deploying the hub proxy in order // to initialize the hub proxy at construction. constructor(address hub, address actionModule) ActionRestricted(actionModule) { HUB = hub; _initialized = true; } /// @inheritdoc ICollectNFT function initialize(uint256 profileId, uint256 pubId) external override { if (_initialized) revert Errors.Initialized(); _initialized = true; _setRoyalty(1000); // 10% of royalties _profileId = profileId; _pubId = pubId; // _name and _symbol remain uninitialized because we override the getters below } /// @inheritdoc ICollectNFT function mint(address to) external override onlyActionModule returns (uint256) { unchecked { uint256 tokenId = ++_tokenIdCounter; _mint(to, tokenId); return tokenId; } } /// @inheritdoc ICollectNFT function getSourcePublicationPointer() external view override returns (uint256, uint256) { return (_profileId, _pubId); } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!_exists(tokenId)) revert Errors.TokenDoesNotExist(); return ILensHub(HUB).getContentURI(_profileId, _pubId); } /** * @dev See {IERC721Metadata-name}. */ function name() public view override returns (string memory) { return string.concat('Lens Collect | Profile #', _profileId.toString(), ' - Publication #', _pubId.toString()); } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public pure override returns (string memory) { return 'LENS-COLLECT'; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC2981CollectionRoyalties, LensBaseERC721) returns (bool) { return ERC2981CollectionRoyalties.supportsInterface(interfaceId) || LensBaseERC721.supportsInterface(interfaceId); } function _getReceiver( uint256 /* tokenId */ ) internal view override returns (address) { if (!ILensHub(HUB).exists(_profileId)) { return address(0); } return IERC721(HUB).ownerOf(_profileId); } function _beforeRoyaltiesSet( uint256 /* royaltiesInBasisPoints */ ) internal view override { if (IERC721(HUB).ownerOf(_profileId) != msg.sender) { revert Errors.NotProfileOwner(); } } function _getRoyaltiesInBasisPointsSlot() internal pure override returns (uint256) { uint256 slot; assembly { slot := _royaltiesInBasisPoints.slot } return slot; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Errors} from 'contracts/libraries/constants/Errors.sol'; import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol'; import {IERC2981} from '@openzeppelin/contracts/interfaces/IERC2981.sol'; abstract contract ERC2981CollectionRoyalties is IERC2981 { uint16 internal constant BASIS_POINTS = 10000; // bytes4(keccak256('royaltyInfo(uint256,uint256)')) == 0x2a55205a bytes4 internal constant INTERFACE_ID_ERC2981 = 0x2a55205a; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == INTERFACE_ID_ERC2981 || interfaceId == type(IERC165).interfaceId; } /** * @notice Changes the royalty percentage for secondary sales. * * @param royaltiesInBasisPoints The royalty percentage (measured in basis points). */ function setRoyalty(uint256 royaltiesInBasisPoints) external { _beforeRoyaltiesSet(royaltiesInBasisPoints); _setRoyalty(royaltiesInBasisPoints); } /** * @notice Called with the sale price to determine how much royalty is owed and to whom. * * @param tokenId The ID of the token queried for royalty information. * @param salePrice The sale price of the token specified. * @return A tuple with the address that should receive the royalties and the royalty * payment amount for the given sale price. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address, uint256) { return (_getReceiver(tokenId), _getRoyaltyAmount(tokenId, salePrice)); } function _setRoyalty(uint256 royaltiesInBasisPoints) internal virtual { if (royaltiesInBasisPoints > BASIS_POINTS) { revert Errors.InvalidParameter(); } _storeRoyaltiesInBasisPoints(royaltiesInBasisPoints); } function _getRoyaltyAmount(uint256 /* tokenId */, uint256 salePrice) internal view virtual returns (uint256) { return (salePrice * _loadRoyaltiesInBasisPoints()) / BASIS_POINTS; } function _storeRoyaltiesInBasisPoints(uint256 royaltiesInBasisPoints) internal virtual { uint256 royaltiesInBasisPointsSlot = _getRoyaltiesInBasisPointsSlot(); assembly { sstore(royaltiesInBasisPointsSlot, royaltiesInBasisPoints) } } function _loadRoyaltiesInBasisPoints() internal view virtual returns (uint256) { uint256 royaltiesInBasisPointsSlot = _getRoyaltiesInBasisPointsSlot(); uint256 royaltyAmount; assembly { royaltyAmount := sload(royaltiesInBasisPointsSlot) } return royaltyAmount; } function _beforeRoyaltiesSet(uint256 royaltiesInBasisPoints) internal view virtual; function _getRoyaltiesInBasisPointsSlot() internal view virtual returns (uint256); function _getReceiver(uint256 tokenId) internal view virtual returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Errors} from 'contracts/libraries/constants/Errors.sol'; import {Types} from 'contracts/libraries/constants/Types.sol'; import {MetaTxLib} from 'contracts/libraries/MetaTxLib.sol'; import {ILensERC721} from 'contracts/interfaces/ILensERC721.sol'; import {IERC721Timestamped} from 'contracts/interfaces/IERC721Timestamped.sol'; import {IERC721Burnable} from 'contracts/interfaces/IERC721Burnable.sol'; import {IERC721MetaTx} from 'contracts/interfaces/IERC721MetaTx.sol'; import {IERC721Receiver} from '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; import {IERC721Metadata} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import {Address} from '@openzeppelin/contracts/utils/Address.sol'; import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; import {ERC165} from '@openzeppelin/contracts/utils/introspection/ERC165.sol'; import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol'; import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol'; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. * * Modifications: * 1. Refactored _operatorApprovals setter into an internal function to allow meta-transactions. * 2. Constructor replaced with an initializer. * 3. Mint timestamp is now stored in a TokenData struct alongside the owner address. */ abstract contract LensBaseERC721 is ERC165, ILensERC721 { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to token Data (owner address and mint timestamp uint96), this // replaces the original mapping(uint256 => address) private _owners; mapping(uint256 => Types.TokenData) private _tokenData; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Deprecated in V2 after removing ERC712Enumerable logic. mapping(address => mapping(uint256 => uint256)) private __DEPRECATED__ownedTokens; mapping(uint256 => uint256) private __DEPRECATED__ownedTokensIndex; // Dirty hack on a deprecated slot: uint256 private _totalSupply; // uint256[] private __DEPRECATED__allTokens; // Deprecated in V2 after removing ERC712Enumerable logic. mapping(uint256 => uint256) private __DEPRECATED__allTokensIndex; mapping(address => uint256) private _nonces; /** * @dev Initializes the ERC721 name and symbol. * * @param name_ The name to set. * @param symbol_ The symbol to set. */ function _initialize(string calldata name_, string calldata symbol_) internal { _name = name_; _symbol = symbol_; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view virtual returns (string memory); /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Timestamped).interfaceId || interfaceId == type(IERC721Burnable).interfaceId || interfaceId == type(IERC721MetaTx).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function nonces(address signer) public view override returns (uint256) { return _nonces[signer]; } /// @inheritdoc IERC721MetaTx function getDomainSeparator() external view virtual override returns (bytes32) { return MetaTxLib.calculateDomainSeparator(); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { if (owner == address(0)) { revert Errors.InvalidParameter(); } return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _tokenData[tokenId].owner; if (owner == address(0)) { revert Errors.TokenDoesNotExist(); } return owner; } /** * @dev See {IERC721Timestamped-mintTimestampOf} */ function mintTimestampOf(uint256 tokenId) public view virtual override returns (uint256) { uint96 mintTimestamp = _tokenData[tokenId].mintTimestamp; if (mintTimestamp == 0) { revert Errors.TokenDoesNotExist(); } return mintTimestamp; } /** * @dev See {IERC721Timestamped-tokenDataOf} */ function tokenDataOf(uint256 tokenId) public view virtual override returns (Types.TokenData memory) { if (!_exists(tokenId)) { revert Errors.TokenDoesNotExist(); } return _tokenData[tokenId]; } /** * @dev See {IERC721Timestamped-exists} */ function exists(uint256 tokenId) public view virtual override returns (bool) { return _exists(tokenId); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } function totalSupply() external view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); if (to == owner) { revert Errors.InvalidParameter(); } if (msg.sender != owner && !isApprovedForAll(owner, msg.sender)) { revert Errors.NotOwnerOrApproved(); } _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { if (!_exists(tokenId)) { revert Errors.TokenDoesNotExist(); } return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == msg.sender) { revert Errors.InvalidParameter(); } _setOperatorApproval(msg.sender, operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length if (!_isApprovedOrOwner(msg.sender, tokenId)) { revert Errors.NotOwnerOrApproved(); } _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { if (!_isApprovedOrOwner(msg.sender, tokenId)) { revert Errors.NotOwnerOrApproved(); } _safeTransfer(from, to, tokenId, _data); } /** * @dev Burns `tokenId`. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual override { if (!_isApprovedOrOwner(msg.sender, tokenId)) { revert Errors.NotOwnerOrApproved(); } _burn(tokenId); } /** * @notice Returns the owner of the `tokenId` token. * * @dev It is prefixed as `unsafe` as it does not revert when the token does not exist. * * @param tokenId The token whose owner is being queried. * * @return address The address owning the given token, zero address if the token does not exist. */ function _unsafeOwnerOf(uint256 tokenId) internal view returns (address) { return _tokenData[tokenId].owner; } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform a token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); if (!_checkOnERC721Received(from, to, tokenId, _data)) { revert Errors.NonERC721ReceiverImplementer(); } } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenData[tokenId].owner != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ownerOf(tokenId); // We don't check owner for != address(0) cause it's done inside ownerOf() return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { if (to == address(0) || _exists(tokenId)) { revert Errors.InvalidParameter(); } _beforeTokenTransfer(address(0), to, tokenId); unchecked { ++_balances[to]; ++_totalSupply; } _tokenData[tokenId].owner = to; _tokenData[tokenId].mintTimestamp = uint96(block.timestamp); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); unchecked { --_balances[owner]; --_totalSupply; } delete _tokenData[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { if (ownerOf(tokenId) != from) { revert Errors.InvalidOwner(); } if (to == address(0)) { revert Errors.InvalidParameter(); } _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); unchecked { --_balances[from]; ++_balances[to]; } _tokenData[tokenId].owner = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } /** * @dev Refactored from the original OZ ERC721 implementation: approve or revoke approval from * `operator` to operate on all tokens owned by `owner`. * * Emits a {ApprovalForAll} event. */ function _setOperatorApproval( address owner, address operator, bool approved ) internal virtual { _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert Errors.NonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title ICollectNFT * @author Lens Protocol * * @notice This is the interface for the CollectNFT contract. Which is cloned upon the first collect for any given * publication. */ interface ICollectNFT { /** * @notice Initializes the collect NFT, setting the feed as the privileged minter, storing the collected publication pointer * and initializing the name and symbol in the LensNFTBase contract. * @custom:permissions CollectPublicationAction. * * @param profileId The token ID of the profile in the hub that this Collect NFT points to. * @param pubId The profile publication ID in the hub that this Collect NFT points to. */ function initialize(uint256 profileId, uint256 pubId) external; /** * @notice Mints a collect NFT to the specified address. This can only be called by the hub and is called * upon collection. * @custom:permissions CollectPublicationAction. * * @param to The address to mint the NFT to. * * @return uint256 An integer representing the minted token ID. */ function mint(address to) external returns (uint256); /** * @notice Returns the source publication of this collect NFT. * * @return tuple First is the profile ID, and second is the publication ID. */ function getSourcePublicationPointer() external view returns (uint256, uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title IERC721Burnable * @author Lens Protocol * * @notice Extension of ERC-721 including a function that allows the token to be burned. */ interface IERC721Burnable { /** * @notice Burns an NFT, removing it from circulation and essentially destroying it. * @custom:permission Owner of the NFT. * * @param tokenId The token ID of the token to burn. */ function burn(uint256 tokenId) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title IERC721MetaTx * @author Lens Protocol * * @notice Extension of ERC-721 including meta-tx signatures related functions. */ interface IERC721MetaTx { /** * @notice Returns the current signature nonce of the given signer. * * @param signer The address for which to query the nonce. * * @return uint256 The current nonce of the given signer. */ function nonces(address signer) external view returns (uint256); /** * @notice Returns the EIP-712 domain separator for this contract. * * @return bytes32 The domain separator. */ function getDomainSeparator() external view returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import {Types} from 'contracts/libraries/constants/Types.sol'; /** * @title IERC721Timestamped * @author Lens Protocol * * @notice Extension of ERC-721 including a struct for token data, which contains the owner and the mint timestamp, as * well as their associated getters. */ interface IERC721Timestamped { /** * @notice Returns the mint timestamp associated with a given NFT. * * @param tokenId The token ID of the NFT to query the mint timestamp for. * * @return uint256 Mint timestamp, this is stored as a uint96 but returned as a uint256 to reduce unnecessary * padding. */ function mintTimestampOf(uint256 tokenId) external view returns (uint256); /** * @notice Returns the token data associated with a given NFT. This allows fetching the token owner and * mint timestamp in a single call. * * @param tokenId The token ID of the NFT to query the token data for. * * @return TokenData A struct containing both the owner address and the mint timestamp. */ function tokenDataOf(uint256 tokenId) external view returns (Types.TokenData memory); /** * @notice Returns whether a token with the given token ID exists. * * @param tokenId The token ID of the NFT to check existence for. * * @return bool True if the token exists. */ function exists(uint256 tokenId) external view returns (bool); /** * @notice Returns the amount of tokens in circulation. * * @return uint256 The current total supply of tokens. */ function totalSupply() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import {IERC721Timestamped} from 'contracts/interfaces/IERC721Timestamped.sol'; import {IERC721Burnable} from 'contracts/interfaces/IERC721Burnable.sol'; import {IERC721MetaTx} from 'contracts/interfaces/IERC721MetaTx.sol'; import {IERC721Metadata} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; interface ILensERC721 is IERC721, IERC721Timestamped, IERC721Burnable, IERC721MetaTx, IERC721Metadata {}
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import {Types} from 'contracts/libraries/constants/Types.sol'; /** * @title ILensGovernable * @author Lens Protocol * * @notice This is the interface for the Lens Protocol main governance functions. */ interface ILensGovernable { /** * @notice Sets the privileged governance role. * @custom:permissions Governance. * * @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. * @custom:permissions Governance. * * @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. * @custom:permissions Governance or Emergency Admin. Emergency Admin can only restrict more. * * @param newState The state to set. It can be one of the following: * - Unpaused: The protocol is fully operational. * - PublishingPaused: The protocol is paused for publishing, but it is still operational for others operations. * - Paused: The protocol is paused for all operations. */ function setState(Types.ProtocolState newState) external; /** * @notice Adds or removes a profile creator from the whitelist. * @custom:permissions Governance. * * @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 Sets the treasury address. * @custom:permissions Governance * * @param newTreasury The new treasury address to set. */ function setTreasury(address newTreasury) external; /** * @notice Sets the treasury fee. * @custom:permissions Governance * * @param newTreasuryFee The new treasury fee to set. */ function setTreasuryFee(uint16 newTreasuryFee) external; /** * @notice Returns the currently configured governance address. * * @return address The address of the currently configured governance. */ function getGovernance() external view returns (address); /** * @notice Gets the state currently set in the protocol. It could be a global pause, a publishing pause or an * unpaused state. * @custom:permissions Anyone. * * @return Types.ProtocolState The state currently set in the protocol. */ function getState() external view returns (Types.ProtocolState); /** * @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 the treasury address. * * @return address The treasury address. */ function getTreasury() external view returns (address); /** * @notice Returns the treasury fee. * * @return uint16 The treasury fee. */ function getTreasuryFee() external view returns (uint16); /** * @notice Returns the treasury address and treasury fee in a single call. * * @return tuple First, the treasury address, second, the treasury fee. */ function getTreasuryData() external view returns (address, uint16); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import {ILensProtocol} from 'contracts/interfaces/ILensProtocol.sol'; import {ILensGovernable} from 'contracts/interfaces/ILensGovernable.sol'; import {ILensHubEventHooks} from 'contracts/interfaces/ILensHubEventHooks.sol'; import {ILensImplGetters} from 'contracts/interfaces/ILensImplGetters.sol'; import {ILensProfiles} from 'contracts/interfaces/ILensProfiles.sol'; import {ILensVersion} from 'contracts/interfaces/ILensVersion.sol'; interface ILensHub is ILensProfiles, ILensProtocol, ILensGovernable, ILensHubEventHooks, ILensImplGetters, ILensVersion {}
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title ILensHubEventHooks * @author Lens Protocol * * @notice This is the interface for the LensHub contract's event hooks. As we want most of the core events to be * emitted by the LensHub contract, event hooks are needed for core events generated by pheripheral contracts. */ interface ILensHubEventHooks { /** * @dev Helper function to emit an `Unfollowed` event from the hub, to be consumed by indexers to track unfollows. * @custom:permissions FollowNFT of the Profile unfollowed. * * @param unfollowerProfileId The ID of the profile that executed the unfollow. * @param idOfProfileUnfollowed The ID of the profile that was unfollowed. * @param transactionExecutor The address of the account executing the unfollow operation. */ function emitUnfollowedEvent( uint256 unfollowerProfileId, uint256 idOfProfileUnfollowed, address transactionExecutor ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title ILensImplGetters * @author Lens Protocol * * @notice This is the interface for the LensHub contract's implementation getters. These implementations will be used * for deploying each respective contract for each profile. */ interface ILensImplGetters { /** * @notice Returns the Follow NFT implementation address that is used for all deployed Follow NFTs. * * @return address The Follow NFT implementation address. */ function getFollowNFTImpl() external view returns (address); /** * @notice Returns the Collect NFT implementation address that is used for each new deployed Collect NFT. * @custom:pending-deprecation * * @return address The Collect NFT implementation address. */ function getLegacyCollectNFTImpl() external view returns (address); /** * @notice Returns the address of the registry that stores all modules that are used by the Lens Protocol. * * @return address The address of the Module Registry contract. */ function getModuleRegistry() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import {ILensERC721} from 'contracts/interfaces/ILensERC721.sol'; interface ILensProfiles is ILensERC721 { /** * @notice DANGER: Triggers disabling the profile protection mechanism for the msg.sender, which will allow * transfers or approvals over profiles held by it. * Disabling the mechanism will have a timelock before it becomes effective, allowing the owner to re-enable * the protection back in case of being under attack. * The protection layer only applies to EOA wallets. */ function DANGER__disableTokenGuardian() external; /** * @notice Enables back the profile protection mechanism for the msg.sender, preventing profile transfers or * approvals (except when revoking them). * The protection layer only applies to EOA wallets. */ function enableTokenGuardian() external; /** * @notice Returns the timestamp at which the Token Guardian will become effectively disabled. * * @param wallet The address to check the timestamp for. * * @return uint256 The timestamp at which the Token Guardian will become effectively disabled. Zero if enabled. */ function getTokenGuardianDisablingTimestamp(address wallet) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import {Types} from 'contracts/libraries/constants/Types.sol'; /** * @title ILensProtocol * @author Lens Protocol * * @notice This is the interface for Lens Protocol's core functions. It contains all the entry points for performing * social operations. */ interface ILensProtocol { /** * @notice Creates a profile with the specified parameters, minting a Profile NFT to the given recipient. * @custom:permissions Any whitelisted profile creator. * * @param createProfileParams A CreateProfileParams struct containing the needed params. */ function createProfile(Types.CreateProfileParams calldata createProfileParams) external returns (uint256); /** * @notice Sets the metadata URI for the given profile. * @custom:permissions Profile Owner or Delegated Executor. * * @param profileId The token ID of the profile to set the metadata URI for. * @param metadataURI The metadata URI to set for the given profile. */ function setProfileMetadataURI(uint256 profileId, string calldata metadataURI) external; /** * @custom:meta-tx setProfileMetadataURI. */ function setProfileMetadataURIWithSig( uint256 profileId, string calldata metadataURI, Types.EIP712Signature calldata signature ) external; /** * @notice Sets the follow module for the given profile. * @custom:permissions Profile Owner or Delegated Executor. * * @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 followModuleInitData The data to be passed to the follow module for initialization. */ function setFollowModule(uint256 profileId, address followModule, bytes calldata followModuleInitData) external; /** * @custom:meta-tx setFollowModule. */ function setFollowModuleWithSig( uint256 profileId, address followModule, bytes calldata followModuleInitData, Types.EIP712Signature calldata signature ) external; /** * @notice Changes the delegated executors configuration for the given profile. It allows setting the approvals for * delegated executors in the specified configuration, as well as switching to it. * @custom:permissions Profile Owner. * * @param delegatorProfileId The ID of the profile to which the delegated executor is being changed for. * @param delegatedExecutors The array of delegated executors to set the approval for. * @param approvals The array of booleans indicating the corresponding executor's new approval status. * @param configNumber The number of the configuration where the executor approval state is being set. * @param switchToGivenConfig A boolean indicating if the configuration must be switched to the one with the given * number. */ function changeDelegatedExecutorsConfig( uint256 delegatorProfileId, address[] calldata delegatedExecutors, bool[] calldata approvals, uint64 configNumber, bool switchToGivenConfig ) external; /** * @notice Changes the delegated executors configuration for the given profile under the current configuration. * @custom:permissions Profile Owner. * * @param delegatorProfileId The ID of the profile to which the delegated executor is being changed for. * @param delegatedExecutors The array of delegated executors to set the approval for. * @param approvals The array of booleans indicating the corresponding executor's new approval status. */ function changeDelegatedExecutorsConfig( uint256 delegatorProfileId, address[] calldata delegatedExecutors, bool[] calldata approvals ) external; /** * @custom:meta-tx changeDelegatedExecutorsConfig. */ function changeDelegatedExecutorsConfigWithSig( uint256 delegatorProfileId, address[] calldata delegatedExecutors, bool[] calldata approvals, uint64 configNumber, bool switchToGivenConfig, Types.EIP712Signature calldata signature ) external; /** * @notice Publishes a post. * Post is the most basic publication type, and can be used to publish any kind of content. * Posts can have these types of modules initialized: * - Action modules: any number of publication actions (e.g. collect, tip, etc.) * - Reference module: a module handling the rules when referencing this post (e.g. token-gated comments) * @custom:permissions Profile Owner or Delegated Executor. * * @param postParams A PostParams struct containing the needed parameters. * * @return uint256 An integer representing the post's publication ID. */ function post(Types.PostParams calldata postParams) external returns (uint256); /** * @custom:meta-tx post. */ function postWithSig( Types.PostParams calldata postParams, Types.EIP712Signature calldata signature ) external returns (uint256); /** * @notice Publishes a comment on the given publication. * Comment is a type of reference publication that points to another publication. * Comments can have these types of modules initialized: * - Action modules: any number of publication actions (e.g. collect, tip, etc.) * - Reference module: a module handling the rules when referencing this comment (e.g. token-gated mirrors) * Comments can have referrers (e.g. publications or profiles that helped to discover the pointed publication). * @custom:permissions Profile Owner or Delegated Executor. * * @param commentParams A CommentParams struct containing the needed parameters. * * @return uint256 An integer representing the comment's publication ID. */ function comment(Types.CommentParams calldata commentParams) external returns (uint256); /** * @custom:meta-tx comment. */ function commentWithSig( Types.CommentParams calldata commentParams, Types.EIP712Signature calldata signature ) external returns (uint256); /** * @notice Publishes a mirror of the given publication. * Mirror is a type of reference publication that points to another publication but doesn't have content. * Mirrors don't have any modules initialized. * Mirrors can have referrers (e.g. publications or profiles that allowed to discover the pointed publication). * You cannot mirror a mirror, comment on a mirror, or quote a mirror. * @custom:permissions Profile Owner or Delegated Executor. * * @param mirrorParams A MirrorParams struct containing the necessary parameters. * * @return uint256 An integer representing the mirror's publication ID. */ function mirror(Types.MirrorParams calldata mirrorParams) external returns (uint256); /** * @custom:meta-tx mirror. */ function mirrorWithSig( Types.MirrorParams calldata mirrorParams, Types.EIP712Signature calldata signature ) external returns (uint256); /** * @notice Publishes a quote of the given publication. * Quote is a type of reference publication similar to mirror, but it has content and modules. * Quotes can have these types of modules initialized: * - Action modules: any number of publication actions (e.g. collect, tip, etc.) * - Reference module: a module handling the rules when referencing this quote (e.g. token-gated comments on quote) * Quotes can have referrers (e.g. publications or profiles that allowed to discover the pointed publication). * Unlike mirrors, you can mirror a quote, comment on a quote, or quote a quote. * @custom:permissions Profile Owner or Delegated Executor. * * @param quoteParams A QuoteParams struct containing the needed parameters. * * @return uint256 An integer representing the quote's publication ID. */ function quote(Types.QuoteParams calldata quoteParams) external returns (uint256); /** * @custom:meta-tx quote. */ function quoteWithSig( Types.QuoteParams calldata quoteParams, Types.EIP712Signature calldata signature ) external returns (uint256); /** * @notice Follows given profiles, executing each profile's follow module logic (if any). * @custom:permissions Profile Owner or Delegated Executor. * * @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 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 (0 if you don't own a follow token). * @param datas The arbitrary data array to pass to the follow module for each profile if needed. * * @return uint256[] An array of follow token IDs representing the follow tokens created for each follow. */ function follow( uint256 followerProfileId, uint256[] calldata idsOfProfilesToFollow, uint256[] calldata followTokenIds, bytes[] calldata datas ) external returns (uint256[] memory); /** * @custom:meta-tx follow. */ function followWithSig( uint256 followerProfileId, uint256[] calldata idsOfProfilesToFollow, uint256[] calldata followTokenIds, bytes[] calldata datas, Types.EIP712Signature calldata signature ) external returns (uint256[] memory); /** * @notice Unfollows given profiles. * @custom:permissions Profile Owner or Delegated Executor. * * @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; /** * @custom:meta-tx unfollow. */ function unfollowWithSig( uint256 unfollowerProfileId, uint256[] calldata idsOfProfilesToUnfollow, Types.EIP712Signature calldata signature ) external; /** * @notice Sets the block status for the given profiles. Changing a profile's block status to `true` (i.e. blocked), * when will also force them to unfollow. * Blocked profiles cannot perform any actions with the profile that blocked them: they cannot comment or mirror * their publications, they cannot follow them, they cannot collect, tip them, etc. * @custom:permissions Profile Owner or Delegated Executor. * * @dev Both the `idsOfProfilesToSetBlockStatus` and `blockStatus` arrays must be of the same length. * * @param byProfileId The ID of the profile that is blocking/unblocking somebody. * @param idsOfProfilesToSetBlockStatus The array of IDs of profiles to set block status. * @param blockStatus The array of block statuses to use for each (true is blocked). */ function setBlockStatus( uint256 byProfileId, uint256[] calldata idsOfProfilesToSetBlockStatus, bool[] calldata blockStatus ) external; /** * @custom:meta-tx setBlockStatus. */ function setBlockStatusWithSig( uint256 byProfileId, uint256[] calldata idsOfProfilesToSetBlockStatus, bool[] calldata blockStatus, Types.EIP712Signature calldata signature ) external; /** * @notice Collects a given publication via signature with the specified parameters. * Collect can have referrers (e.g. publications or profiles that allowed to discover the pointed publication). * @custom:permissions Collector Profile Owner or its Delegated Executor. * @custom:pending-deprecation Collect modules were replaced by PublicationAction Collect modules in V2. This method * is left here for backwards compatibility with posts made in V1 that had Collect modules. * * @param collectParams A CollectParams struct containing the parameters. * * @return uint256 An integer representing the minted token ID. */ function collectLegacy(Types.LegacyCollectParams calldata collectParams) external returns (uint256); /** * @custom:meta-tx collect. * @custom:pending-deprecation */ function collectLegacyWithSig( Types.LegacyCollectParams calldata collectParams, Types.EIP712Signature calldata signature ) external returns (uint256); /** * @notice Acts on a given publication with the specified parameters. * You can act on a publication except a mirror (if it has at least one action module initialized). * Actions can have referrers (e.g. publications or profiles that allowed to discover the pointed publication). * @custom:permissions Actor Profile Owner or its Delegated Executor. * * @param publicationActionParams A PublicationActionParams struct containing the parameters. * * @return bytes Arbitrary data the action module returns. */ function act(Types.PublicationActionParams calldata publicationActionParams) external returns (bytes memory); /** * @custom:meta-tx act. */ function actWithSig( Types.PublicationActionParams calldata publicationActionParams, Types.EIP712Signature calldata signature ) external returns (bytes memory); /** * @dev This function is used to invalidate signatures by incrementing the nonce of the signer. * @param increment The amount to increment the nonce by (max 255). */ function incrementNonce(uint8 increment) external; ///////////////////////////////// /// 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 returns (bool); /** * @notice Returns whether the given address is approved as delegated executor, in the configuration with the given * number, to act on behalf of the given profile. * * @param delegatorProfileId The ID of the profile to check the delegated executor approval for. * @param delegatedExecutor The address to query the delegated executor approval for. * @param configNumber The number of the configuration where the executor approval state is being queried. * * @return bool True if the address is approved as a delegated executor to act on behalf of the profile in the * given configuration, false otherwise. */ function isDelegatedExecutorApproved( uint256 delegatorProfileId, address delegatedExecutor, uint64 configNumber ) external view returns (bool); /** * @notice Returns whether the given address is approved as delegated executor, in the current configuration, to act * on behalf of the given profile. * * @param delegatorProfileId The ID of the profile to check the delegated executor approval for. * @param delegatedExecutor The address to query the delegated executor approval for. * * @return bool True if the address is approved as a delegated executor to act on behalf of the profile in the * current configuration, false otherwise. */ function isDelegatedExecutorApproved( uint256 delegatorProfileId, address delegatedExecutor ) external view returns (bool); /** * @notice Returns the current delegated executor config number for the given profile. * * @param delegatorProfileId The ID of the profile from which the delegated executors config number is being queried * * @return uint256 The current delegated executor configuration number. */ function getDelegatedExecutorsConfigNumber(uint256 delegatorProfileId) external view returns (uint64); /** * @notice Returns the previous used delegated executor config number for the given profile. * * @param delegatorProfileId The ID of the profile from which the delegated executors' previous configuration number * set is being queried. * * @return uint256 The delegated executor configuration number previously set. It will coincide with the current * configuration set if it was never switched from the default one. */ function getDelegatedExecutorsPrevConfigNumber(uint256 delegatorProfileId) external view returns (uint64); /** * @notice Returns the maximum delegated executor config number for the given profile. * This is the maximum config number that was ever used by this profile. * When creating a new clean configuration, you can only use a number that is maxConfigNumber + 1. * * @param delegatorProfileId The ID of the profile from which the delegated executors' maximum configuration number * set is being queried. * * @return uint256 The delegated executor maximum configuration number set. */ function getDelegatedExecutorsMaxConfigNumberSet(uint256 delegatorProfileId) external view returns (uint64); /** * @notice Returns whether `profileId` is blocked by `byProfileId`. * See setBlockStatus() for more information on how blocking works on the platform. * * @param profileId The ID of the profile whose blocked status should be queried. * @param byProfileId The ID of the profile whose blocker status should be queried. * * @return bool True if `profileId` is blocked by `byProfileId`, false otherwise. */ function isBlocked(uint256 profileId, uint256 byProfileId) external view returns (bool); /** * @notice Returns the URI associated with a given publication. * This is used to store the publication's metadata, e.g.: content, images, etc. * * @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 full profile struct associated with a given profile token ID. * * @param profileId The token ID of the profile to query. * * @return Profile The profile struct of the given profile. */ function getProfile(uint256 profileId) external view returns (Types.Profile 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 Publication The publication struct associated with the queried publication. */ function getPublication(uint256 profileId, uint256 pubId) external view returns (Types.PublicationMemory memory); /** * @notice Returns the type of a given publication. * The type can be one of the following (see PublicationType enum): * - Nonexistent * - Post * - Comment * - Mirror * - Quote * * @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 PublicationType The publication type of the queried publication. */ function getPublicationType(uint256 profileId, uint256 pubId) external view returns (Types.PublicationType); /** * @notice Returns wether a given Action Module is enabled 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. * @param module The address of the Action Module to query. * * @return bool True if the Action Module is enabled for the queried publication, false if not. */ function isActionModuleEnabledInPublication( uint256 profileId, uint256 pubId, address module ) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title ILensVersion * @author Lens Protocol * * @notice This is the interface for the LensHub Version getters and emitter. * It allows to emit a LensHub version during an upgrade, and also to get the current version. */ interface ILensVersion { /** * @notice Returns the LensHub current Version. * * @return version The LensHub current Version. */ function getVersion() external view returns (string memory); /** * @notice Returns the LensHub current Git Commit. * * @return gitCommit The LensHub current Git Commit. */ function getGitCommit() external view returns (bytes20); /** * @notice Emits the LensHub current Version. Used in upgradeAndCall(). */ function emitVersion() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import {IERC1271} from '@openzeppelin/contracts/interfaces/IERC1271.sol'; import {ILensERC721} from 'contracts/interfaces/ILensERC721.sol'; import {Types} from 'contracts/libraries/constants/Types.sol'; import {Errors} from 'contracts/libraries/constants/Errors.sol'; import {Typehash} from 'contracts/libraries/constants/Typehash.sol'; import {StorageLib} from 'contracts/libraries/StorageLib.sol'; import {Events} from 'contracts/libraries/constants/Events.sol'; /** * @title MetaTxLib * @author Lens Protocol * * NOTE: the functions in this contract operate under the assumption that the passed signer is already validated * to either be the originator or one of their delegated executors. * * @dev User nonces are incremented from this library as well. */ library MetaTxLib { string constant EIP712_DOMAIN_VERSION = '2'; bytes32 constant EIP712_DOMAIN_VERSION_HASH = keccak256(bytes(EIP712_DOMAIN_VERSION)); bytes4 constant EIP1271_MAGIC_VALUE = 0x1626ba7e; /** * @dev We store the domain separator and LensHub Proxy address as constants to save gas. * * keccak256( * abi.encode( * keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), * keccak256('Lens Protocol Profiles'), // Contract Name * keccak256('2'), // Version Hash * 137, // Polygon Chain ID * address(0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d) // Verifying Contract Address - LensHub Address * ) * ); */ bytes32 constant LENS_HUB_CACHED_POLYGON_DOMAIN_SEPARATOR = 0xbf9544cf7d7a0338fc4f071be35409a61e51e9caef559305410ad74e16a05f2d; address constant LENS_HUB_ADDRESS = 0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d; uint256 constant POLYGON_CHAIN_ID = 137; function validateSetProfileMetadataURISignature( Types.EIP712Signature calldata signature, uint256 profileId, string calldata metadataURI ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.SET_PROFILE_METADATA_URI, profileId, _encodeUsingEip712Rules(metadataURI), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } function validateSetFollowModuleSignature( Types.EIP712Signature calldata signature, uint256 profileId, address followModule, bytes calldata followModuleInitData ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.SET_FOLLOW_MODULE, profileId, followModule, _encodeUsingEip712Rules(followModuleInitData), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } function validateChangeDelegatedExecutorsConfigSignature( Types.EIP712Signature calldata signature, uint256 delegatorProfileId, address[] calldata delegatedExecutors, bool[] calldata approvals, uint64 configNumber, bool switchToGivenConfig ) external { address signer = signature.signer; uint256 deadline = signature.deadline; _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.CHANGE_DELEGATED_EXECUTORS_CONFIG, delegatorProfileId, _encodeUsingEip712Rules(delegatedExecutors), _encodeUsingEip712Rules(approvals), configNumber, switchToGivenConfig, _getNonceIncrementAndEmitEvent(signer), deadline ) ) ), signature ); } function validatePostSignature( Types.EIP712Signature calldata signature, Types.PostParams calldata postParams ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.POST, postParams.profileId, _encodeUsingEip712Rules(postParams.contentURI), _encodeUsingEip712Rules(postParams.actionModules), _encodeUsingEip712Rules(postParams.actionModulesInitDatas), postParams.referenceModule, _encodeUsingEip712Rules(postParams.referenceModuleInitData), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } function validateCommentSignature( Types.EIP712Signature calldata signature, Types.CommentParams calldata commentParams ) external { bytes memory encodedAbi = abi.encode( Typehash.COMMENT, commentParams.profileId, _encodeUsingEip712Rules(commentParams.contentURI), commentParams.pointedProfileId, commentParams.pointedPubId, _encodeUsingEip712Rules(commentParams.referrerProfileIds), _encodeUsingEip712Rules(commentParams.referrerPubIds), _encodeUsingEip712Rules(commentParams.referenceModuleData), _encodeUsingEip712Rules(commentParams.actionModules), _encodeUsingEip712Rules(commentParams.actionModulesInitDatas), commentParams.referenceModule, _encodeUsingEip712Rules(commentParams.referenceModuleInitData), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ); _validateRecoveredAddress(_calculateDigest(keccak256(encodedAbi)), signature); } function validateQuoteSignature( Types.EIP712Signature calldata signature, Types.QuoteParams calldata quoteParams ) external { bytes memory encodedAbi = abi.encode( Typehash.QUOTE, quoteParams.profileId, _encodeUsingEip712Rules(quoteParams.contentURI), quoteParams.pointedProfileId, quoteParams.pointedPubId, _encodeUsingEip712Rules(quoteParams.referrerProfileIds), _encodeUsingEip712Rules(quoteParams.referrerPubIds), _encodeUsingEip712Rules(quoteParams.referenceModuleData), _encodeUsingEip712Rules(quoteParams.actionModules), _encodeUsingEip712Rules(quoteParams.actionModulesInitDatas), quoteParams.referenceModule, _encodeUsingEip712Rules(quoteParams.referenceModuleInitData), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ); _validateRecoveredAddress(_calculateDigest(keccak256(encodedAbi)), signature); } function validateMirrorSignature( Types.EIP712Signature calldata signature, Types.MirrorParams calldata mirrorParams ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.MIRROR, mirrorParams.profileId, _encodeUsingEip712Rules(mirrorParams.metadataURI), mirrorParams.pointedProfileId, mirrorParams.pointedPubId, _encodeUsingEip712Rules(mirrorParams.referrerProfileIds), _encodeUsingEip712Rules(mirrorParams.referrerPubIds), _encodeUsingEip712Rules(mirrorParams.referenceModuleData), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } function validateFollowSignature( Types.EIP712Signature calldata signature, uint256 followerProfileId, uint256[] calldata idsOfProfilesToFollow, uint256[] calldata followTokenIds, bytes[] calldata datas ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.FOLLOW, followerProfileId, _encodeUsingEip712Rules(idsOfProfilesToFollow), _encodeUsingEip712Rules(followTokenIds), _encodeUsingEip712Rules(datas), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } function validateUnfollowSignature( Types.EIP712Signature calldata signature, uint256 unfollowerProfileId, uint256[] calldata idsOfProfilesToUnfollow ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.UNFOLLOW, unfollowerProfileId, _encodeUsingEip712Rules(idsOfProfilesToUnfollow), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } function validateSetBlockStatusSignature( Types.EIP712Signature calldata signature, uint256 byProfileId, uint256[] calldata idsOfProfilesToSetBlockStatus, bool[] calldata blockStatus ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.SET_BLOCK_STATUS, byProfileId, _encodeUsingEip712Rules(idsOfProfilesToSetBlockStatus), _encodeUsingEip712Rules(blockStatus), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } function validateLegacyCollectSignature( Types.EIP712Signature calldata signature, Types.LegacyCollectParams calldata collectParams ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.COLLECT_LEGACY, collectParams.publicationCollectedProfileId, collectParams.publicationCollectedId, collectParams.collectorProfileId, collectParams.referrerProfileId, collectParams.referrerPubId, _encodeUsingEip712Rules(collectParams.collectModuleData), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } function validateActSignature( Types.EIP712Signature calldata signature, Types.PublicationActionParams calldata publicationActionParams ) external { _validateRecoveredAddress( _calculateDigest( keccak256( abi.encode( Typehash.ACT, publicationActionParams.publicationActedProfileId, publicationActionParams.publicationActedId, publicationActionParams.actorProfileId, _encodeUsingEip712Rules(publicationActionParams.referrerProfileIds), _encodeUsingEip712Rules(publicationActionParams.referrerPubIds), publicationActionParams.actionModuleAddress, _encodeUsingEip712Rules(publicationActionParams.actionModuleData), _getNonceIncrementAndEmitEvent(signature.signer), signature.deadline ) ) ), signature ); } /// @dev This function is used to invalidate signatures by incrementing the nonce function incrementNonce(uint8 increment) external { uint256 currentNonce = StorageLib.nonces()[msg.sender]; StorageLib.nonces()[msg.sender] = currentNonce + increment; emit Events.NonceUpdated(msg.sender, currentNonce + increment, block.timestamp); } function calculateDomainSeparator() internal view returns (bytes32) { if (address(this) == LENS_HUB_ADDRESS && block.chainid == POLYGON_CHAIN_ID) { return LENS_HUB_CACHED_POLYGON_DOMAIN_SEPARATOR; } return keccak256( abi.encode( Typehash.EIP712_DOMAIN, keccak256(bytes(ILensERC721(address(this)).name())), EIP712_DOMAIN_VERSION_HASH, block.chainid, address(this) ) ); } /** * @dev Wrapper for ecrecover to reduce code size, used in meta-tx specific functions. */ function _validateRecoveredAddress(bytes32 digest, Types.EIP712Signature calldata signature) private view { if (block.timestamp > signature.deadline) revert Errors.SignatureExpired(); // If the expected address is a contract, check the signature there. if (signature.signer.code.length != 0) { bytes memory concatenatedSig = abi.encodePacked(signature.r, signature.s, signature.v); if (IERC1271(signature.signer).isValidSignature(digest, concatenatedSig) != EIP1271_MAGIC_VALUE) { revert Errors.SignatureInvalid(); } } else { address recoveredAddress = ecrecover(digest, signature.v, signature.r, signature.s); if (recoveredAddress == address(0) || recoveredAddress != signature.signer) { revert Errors.SignatureInvalid(); } } } /** * @dev Calculates EIP712 digest based on the current DOMAIN_SEPARATOR. * * @param hashedMessage The message hash from which the digest should be calculated. * * @return bytes32 A 32-byte output representing the EIP712 digest. */ function _calculateDigest(bytes32 hashedMessage) private view returns (bytes32) { return keccak256(abi.encodePacked('\x19\x01', calculateDomainSeparator(), hashedMessage)); } /** * @dev This fetches a signer's current nonce and increments it so it's ready for the next meta-tx. Also emits * the `NonceUpdated` event. * * @param signer The address to get and increment the nonce for. * * @return uint256 The current nonce for the given signer prior to being incremented. */ function _getNonceIncrementAndEmitEvent(address signer) private returns (uint256) { uint256 currentNonce; unchecked { currentNonce = StorageLib.nonces()[signer]++; } emit Events.NonceUpdated(signer, currentNonce + 1, block.timestamp); return currentNonce; } function _encodeUsingEip712Rules(bytes[] memory bytesArray) private pure returns (bytes32) { bytes32[] memory bytesArrayEncodedElements = new bytes32[](bytesArray.length); uint256 i; while (i < bytesArray.length) { // A `bytes` type is encoded as its keccak256 hash. bytesArrayEncodedElements[i] = _encodeUsingEip712Rules(bytesArray[i]); unchecked { ++i; } } // An array is encoded as the keccak256 hash of the concatenation of their encoded elements. return _encodeUsingEip712Rules(bytesArrayEncodedElements); } function _encodeUsingEip712Rules(bool[] memory boolArray) private pure returns (bytes32) { return keccak256(abi.encodePacked(boolArray)); } function _encodeUsingEip712Rules(address[] memory addressArray) private pure returns (bytes32) { return keccak256(abi.encodePacked(addressArray)); } function _encodeUsingEip712Rules(uint256[] memory uint256Array) private pure returns (bytes32) { return keccak256(abi.encodePacked(uint256Array)); } function _encodeUsingEip712Rules(bytes32[] memory bytes32Array) private pure returns (bytes32) { return keccak256(abi.encodePacked(bytes32Array)); } function _encodeUsingEip712Rules(string memory stringValue) private pure returns (bytes32) { return keccak256(bytes(stringValue)); } function _encodeUsingEip712Rules(bytes memory bytesValue) private pure returns (bytes32) { return keccak256(bytesValue); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import {Types} from 'contracts/libraries/constants/Types.sol'; import {Errors} from 'contracts/libraries/constants/Errors.sol'; library StorageLib { // uint256 constant NAME_SLOT = 0; // uint256 constant SYMBOL_SLOT = 1; uint256 constant TOKEN_DATA_MAPPING_SLOT = 2; // uint256 constant BALANCES_SLOT = 3; // uint256 constant TOKEN_APPROVAL_MAPPING_SLOT = 4; // uint256 constant OPERATOR_APPROVAL_MAPPING_SLOT = 5; // Slot 6 is deprecated in Lens V2. In V1 it was used for ERC-721 Enumerable's `ownedTokens`. // Slot 7 is deprecated in Lens V2. In V1 it was used for ERC-721 Enumerable's `ownedTokensIndex`. // uint256 constant TOTAL_SUPPLY_SLOT = 8; // Slot 9 is deprecated in Lens V2. In V1 it was used for ERC-721 Enumerable's `allTokensIndex`. uint256 constant SIG_NONCES_MAPPING_SLOT = 10; uint256 constant LAST_INITIALIZED_REVISION_SLOT = 11; // VersionedInitializable's `lastInitializedRevision` field. uint256 constant PROTOCOL_STATE_SLOT = 12; uint256 constant PROFILE_CREATOR_WHITELIST_MAPPING_SLOT = 13; // Slot 14 is deprecated in Lens V2. In V1 it was used for the follow module address whitelist. // Slot 15 is deprecated in Lens V2. In V1 it was used for the collect module address whitelist. // Slot 16 is deprecated in Lens V2. In V1 it was used for the reference module address whitelist. // Slot 17 is deprecated in Lens V2. In V1 it was used for the dispatcher address by profile ID. uint256 constant PROFILE_ID_BY_HANDLE_HASH_MAPPING_SLOT = 18; // Deprecated slot, but still needed for V2 migration. uint256 constant PROFILES_MAPPING_SLOT = 19; uint256 constant PUBLICATIONS_MAPPING_SLOT = 20; // Slot 21 is deprecated in Lens V2. In V1 it was used for the default profile ID by address. uint256 constant PROFILE_COUNTER_SLOT = 22; uint256 constant GOVERNANCE_SLOT = 23; uint256 constant EMERGENCY_ADMIN_SLOT = 24; ////////////////////////////////// /// Introduced in Lens V1.3: /// ////////////////////////////////// uint256 constant TOKEN_GUARDIAN_DISABLING_TIMESTAMP_MAPPING_SLOT = 25; ////////////////////////////////// /// Introduced in Lens V2: /// ////////////////////////////////// uint256 constant DELEGATED_EXECUTOR_CONFIG_MAPPING_SLOT = 26; uint256 constant BLOCKED_STATUS_MAPPING_SLOT = 27; uint256 constant PROFILE_ROYALTIES_BPS_SLOT = 28; uint256 constant MIGRATION_ADMINS_WHITELISTED_MAPPING_SLOT = 29; uint256 constant TREASURY_DATA_SLOT = 30; function getPublication( uint256 profileId, uint256 pubId ) internal pure returns (Types.Publication storage _publication) { assembly { mstore(0, profileId) mstore(32, PUBLICATIONS_MAPPING_SLOT) mstore(32, keccak256(0, 64)) mstore(0, pubId) _publication.slot := keccak256(0, 64) } } function getPublicationMemory( uint256 profileId, uint256 pubId ) internal pure returns (Types.PublicationMemory memory) { Types.PublicationMemory storage _publicationStorage; assembly { mstore(0, profileId) mstore(32, PUBLICATIONS_MAPPING_SLOT) mstore(32, keccak256(0, 64)) mstore(0, pubId) _publicationStorage.slot := keccak256(0, 64) } Types.PublicationMemory memory _publicationMemory; _publicationMemory = _publicationStorage; return _publicationMemory; } function getProfile(uint256 profileId) internal pure returns (Types.Profile storage _profiles) { assembly { mstore(0, profileId) mstore(32, PROFILES_MAPPING_SLOT) _profiles.slot := keccak256(0, 64) } } function getDelegatedExecutorsConfig( uint256 delegatorProfileId ) internal pure returns (Types.DelegatedExecutorsConfig storage _delegatedExecutorsConfig) { assembly { mstore(0, delegatorProfileId) mstore(32, DELEGATED_EXECUTOR_CONFIG_MAPPING_SLOT) _delegatedExecutorsConfig.slot := keccak256(0, 64) } } function tokenGuardianDisablingTimestamp() internal pure returns (mapping(address => uint256) storage _tokenGuardianDisablingTimestamp) { assembly { _tokenGuardianDisablingTimestamp.slot := TOKEN_GUARDIAN_DISABLING_TIMESTAMP_MAPPING_SLOT } } function getTokenData(uint256 tokenId) internal pure returns (Types.TokenData storage _tokenData) { assembly { mstore(0, tokenId) mstore(32, TOKEN_DATA_MAPPING_SLOT) _tokenData.slot := keccak256(0, 64) } } function blockedStatus( uint256 blockerProfileId ) internal pure returns (mapping(uint256 => bool) storage _blockedStatus) { assembly { mstore(0, blockerProfileId) mstore(32, BLOCKED_STATUS_MAPPING_SLOT) _blockedStatus.slot := keccak256(0, 64) } } function nonces() internal pure returns (mapping(address => uint256) storage _nonces) { assembly { _nonces.slot := SIG_NONCES_MAPPING_SLOT } } function profileIdByHandleHash() internal pure returns (mapping(bytes32 => uint256) storage _profileIdByHandleHash) { assembly { _profileIdByHandleHash.slot := PROFILE_ID_BY_HANDLE_HASH_MAPPING_SLOT } } function profileCreatorWhitelisted() internal pure returns (mapping(address => bool) storage _profileCreatorWhitelisted) { assembly { _profileCreatorWhitelisted.slot := PROFILE_CREATOR_WHITELIST_MAPPING_SLOT } } function migrationAdminWhitelisted() internal pure returns (mapping(address => bool) storage _migrationAdminWhitelisted) { assembly { _migrationAdminWhitelisted.slot := MIGRATION_ADMINS_WHITELISTED_MAPPING_SLOT } } function getGovernance() internal view returns (address _governance) { assembly { _governance := sload(GOVERNANCE_SLOT) } } function setGovernance(address newGovernance) internal { assembly { sstore(GOVERNANCE_SLOT, newGovernance) } } function getEmergencyAdmin() internal view returns (address _emergencyAdmin) { assembly { _emergencyAdmin := sload(EMERGENCY_ADMIN_SLOT) } } function setEmergencyAdmin(address newEmergencyAdmin) internal { assembly { sstore(EMERGENCY_ADMIN_SLOT, newEmergencyAdmin) } } function getState() internal view returns (Types.ProtocolState _state) { assembly { _state := sload(PROTOCOL_STATE_SLOT) } } function setState(Types.ProtocolState newState) internal { assembly { sstore(PROTOCOL_STATE_SLOT, newState) } } function getLastInitializedRevision() internal view returns (uint256 _lastInitializedRevision) { assembly { _lastInitializedRevision := sload(LAST_INITIALIZED_REVISION_SLOT) } } function setLastInitializedRevision(uint256 newLastInitializedRevision) internal { assembly { sstore(LAST_INITIALIZED_REVISION_SLOT, newLastInitializedRevision) } } function getTreasuryData() internal pure returns (Types.TreasuryData storage _treasuryData) { assembly { _treasuryData.slot := TREASURY_DATA_SLOT } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; library Errors { error CannotInitImplementation(); error Initialized(); error SignatureExpired(); error SignatureInvalid(); error InvalidOwner(); error NotOwnerOrApproved(); error NotHub(); error TokenDoesNotExist(); error NotGovernance(); error NotGovernanceOrEmergencyAdmin(); error EmergencyAdminCanOnlyPauseFurther(); error NotProfileOwner(); error PublicationDoesNotExist(); error CallerNotFollowNFT(); error CallerNotCollectNFT(); // Legacy error ArrayMismatch(); error NotWhitelisted(); error NotRegistered(); error InvalidParameter(); error ExecutorInvalid(); error Blocked(); error SelfBlock(); error NotFollowing(); error SelfFollow(); error InvalidReferrer(); error InvalidPointedPub(); error NonERC721ReceiverImplementer(); error AlreadyEnabled(); // Module Errors error InitParamsInvalid(); error ActionNotAllowed(); error CollectNotAllowed(); // Used in LegacyCollectLib (pending deprecation) // MultiState Errors error Paused(); error PublishingPaused(); // Profile Guardian Errors error GuardianEnabled(); error NotEOA(); error DisablingAlreadyTriggered(); // Migration Errors error NotMigrationAdmin(); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; import {Types} from 'contracts/libraries/constants/Types.sol'; library Events { /** * @dev Emitted when the NFT contract's name and symbol are set at initialization. * * @param name The NFT name set. * @param symbol The NFT symbol set. * @param timestamp The current block timestamp. */ event BaseInitialized(string name, string symbol, uint256 timestamp); /** * @dev Emitted when the hub state is set. * * @param caller The caller who set the state. * @param prevState The previous protocol state, an enum of either `Paused`, `PublishingPaused` or `Unpaused`. * @param newState The newly set state, an enum of either `Paused`, `PublishingPaused` or `Unpaused`. * @param timestamp The current block timestamp. */ event StateSet( address indexed caller, Types.ProtocolState indexed prevState, Types.ProtocolState indexed newState, uint256 timestamp ); /** * @dev Emitted when the governance address is changed. We emit the caller even though it should be the previous * governance address, as we cannot guarantee this will always be the case due to upgradeability. * * @param caller The caller who set the governance address. * @param prevGovernance The previous governance address. * @param newGovernance The new governance address set. * @param timestamp The current block timestamp. */ event GovernanceSet( address indexed caller, address indexed prevGovernance, address indexed newGovernance, uint256 timestamp ); /** * @dev Emitted when the emergency admin is changed. We emit the caller even though it should be the previous * governance address, as we cannot guarantee this will always be the case due to upgradeability. * * @param caller The caller who set the emergency admin address. * @param oldEmergencyAdmin The previous emergency admin address. * @param newEmergencyAdmin The new emergency admin address set. * @param timestamp The current block timestamp. */ event EmergencyAdminSet( address indexed caller, address indexed oldEmergencyAdmin, address indexed newEmergencyAdmin, uint256 timestamp ); /** * @dev Emitted when a profile creator is added to or removed from the whitelist. * * @param profileCreator The address of the profile creator. * @param whitelisted Whether or not the profile creator is being added to the whitelist. * @param timestamp The current block timestamp. */ event ProfileCreatorWhitelisted(address indexed profileCreator, bool indexed whitelisted, uint256 timestamp); /** * @dev Emitted when a profile is created. * * @param profileId The newly created profile's token ID. * @param creator The profile creator, who created the token with the given profile ID. * @param to The address receiving the profile with the given profile ID. * @param timestamp The current block timestamp. */ event ProfileCreated(uint256 indexed profileId, address indexed creator, address indexed to, uint256 timestamp); /** * @dev Emitted when a delegated executors configuration is changed. * * @param delegatorProfileId The ID of the profile for which the delegated executor was changed. * @param configNumber The number of the configuration where the executor approval state was set. * @param delegatedExecutors The array of delegated executors whose approval was set for. * @param approvals The array of booleans indicating the corresponding executor new approval status. * @param timestamp The current block timestamp. */ event DelegatedExecutorsConfigChanged( uint256 indexed delegatorProfileId, uint256 indexed configNumber, address[] delegatedExecutors, bool[] approvals, uint256 timestamp ); /** * @dev Emitted when a delegated executors configuration is applied. * * @param delegatorProfileId The ID of the profile applying the configuration. * @param configNumber The number of the configuration applied. * @param timestamp The current block timestamp. */ event DelegatedExecutorsConfigApplied( uint256 indexed delegatorProfileId, uint256 indexed configNumber, uint256 timestamp ); /** * @dev Emitted when a profile's follow module is set. * * @param profileId The profile's token ID. * @param followModule The profile's newly set follow module. This CAN be the zero address. * @param followModuleInitData The data passed to the follow module, if any. * @param followModuleReturnData The data returned from the follow module's initialization. This is ABI-encoded * and depends on the follow module chosen. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The current block timestamp. */ event FollowModuleSet( uint256 indexed profileId, address followModule, bytes followModuleInitData, bytes followModuleReturnData, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted when a post is successfully published. * * @param postParams The parameters passed to create the post publication. * @param pubId The publication ID assigned to the created post. * @param actionModulesInitReturnDatas The data returned from the action modules' initialization for this given * publication. This is ABI-encoded and depends on the action module chosen. * @param referenceModuleInitReturnData The data returned from the reference module at initialization. This is * ABI-encoded and depends on the reference module chosen. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The current block timestamp. */ event PostCreated( Types.PostParams postParams, uint256 indexed pubId, bytes[] actionModulesInitReturnDatas, bytes referenceModuleInitReturnData, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted when a comment is successfully published. * * @param commentParams The parameters passed to create the comment publication. * @param pubId The publication ID assigned to the created comment. * @param referenceModuleReturnData The data returned by the commented publication reference module's * processComment function, if the commented publication has a reference module set. * @param actionModulesInitReturnDatas The data returned from the action modules' initialization for this given * publication. This is ABI-encoded and depends on the action module chosen. * @param referenceModuleInitReturnData The data returned from the reference module at initialization. This is * ABI-encoded and depends on the reference module chosen. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The current block timestamp. */ event CommentCreated( Types.CommentParams commentParams, uint256 indexed pubId, bytes referenceModuleReturnData, bytes[] actionModulesInitReturnDatas, bytes referenceModuleInitReturnData, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted when a mirror is successfully published. * * @param mirrorParams The parameters passed to create the mirror publication. * @param pubId The publication ID assigned to the created mirror. * @param referenceModuleReturnData The data returned by the mirrored publication reference module's * processMirror function, if the mirrored publication has a reference module set. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The current block timestamp. */ event MirrorCreated( Types.MirrorParams mirrorParams, uint256 indexed pubId, bytes referenceModuleReturnData, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted when a quote is successfully published. * * @param quoteParams The parameters passed to create the quote publication. * @param pubId The publication ID assigned to the created quote. * @param referenceModuleReturnData The data returned by the quoted publication reference module's * processQuote function, if the quoted publication has a reference module set. * @param actionModulesInitReturnDatas The data returned from the action modules' initialization for this given * publication. This is ABI-encoded and depends on the action module chosen. * @param referenceModuleInitReturnData The data returned from the reference module at initialization. This is * ABI-encoded and depends on the reference module chosen. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The current block timestamp. */ event QuoteCreated( Types.QuoteParams quoteParams, uint256 indexed pubId, bytes referenceModuleReturnData, bytes[] actionModulesInitReturnDatas, bytes referenceModuleInitReturnData, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted when a followNFT clone is deployed using a lazy deployment pattern. * * @param profileId The token ID of the profile to which this followNFT is associated. * @param followNFT The address of the newly deployed followNFT clone. * @param timestamp The current block timestamp. */ event FollowNFTDeployed(uint256 indexed profileId, address indexed followNFT, uint256 timestamp); /** * @dev Emitted when a collectNFT clone is deployed using a lazy deployment pattern. * * @param profileId The publisher's profile token ID. * @param pubId The publication associated with the newly deployed collectNFT clone's ID. * @param collectNFT The address of the newly deployed collectNFT clone. * @param timestamp The current block timestamp. */ event LegacyCollectNFTDeployed( uint256 indexed profileId, uint256 indexed pubId, address indexed collectNFT, uint256 timestamp ); /** * @dev Emitted upon a successful action. * * @param publicationActionParams The parameters passed to act on a publication. * @param actionModuleReturnData The data returned from the action modules. This is ABI-encoded and the format * depends on the action module chosen. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The current block timestamp. */ event Acted( Types.PublicationActionParams publicationActionParams, bytes actionModuleReturnData, address transactionExecutor, 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 pass to the follow module, if any. * @param processFollowModuleReturnData The data returned by the followed profile follow module's processFollow * function, if the followed profile has a reference module set. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The timestamp of the follow operation. */ event Followed( uint256 indexed followerProfileId, uint256 idOfProfileFollowed, uint256 followTokenIdAssigned, bytes followModuleData, bytes processFollowModuleReturnData, address transactionExecutor, uint256 timestamp ); /** * @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 transactionExecutor The address of the account that executed this operation. * @param timestamp The timestamp of the unfollow operation. */ event Unfollowed( uint256 indexed unfollowerProfileId, uint256 idOfProfileUnfollowed, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted upon a successful block, through a block status setting operation. * * @param byProfileId The ID of the profile that executed the block status change. * @param idOfProfileBlocked The ID of the profile whose block status have been set to blocked. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The timestamp of the block operation. */ event Blocked( uint256 indexed byProfileId, uint256 idOfProfileBlocked, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted upon a successful unblock, through a block status setting operation. * * @param byProfileId The ID of the profile that executed the block status change. * @param idOfProfileUnblocked The ID of the profile whose block status have been set to unblocked. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The timestamp of the unblock operation. */ event Unblocked( uint256 indexed byProfileId, uint256 idOfProfileUnblocked, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted via callback when a collectNFT is transferred. * * @param profileId The token ID of the profile associated with the collectNFT being transferred. * @param pubId The publication ID associated with the collectNFT 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. * @param timestamp The current block timestamp. */ event CollectNFTTransferred( uint256 indexed profileId, uint256 indexed pubId, uint256 indexed collectNFTId, address from, address to, uint256 timestamp ); /** * @notice Emitted when the treasury address is set. * * @param prevTreasury The previous treasury address. * @param newTreasury The new treasury address set. * @param timestamp The current block timestamp. */ event TreasurySet(address indexed prevTreasury, address indexed newTreasury, uint256 timestamp); /** * @notice Emitted when the treasury fee is set. * * @param prevTreasuryFee The previous treasury fee in BPS. * @param newTreasuryFee The new treasury fee in BPS. * @param timestamp The current block timestamp. */ event TreasuryFeeSet(uint16 indexed prevTreasuryFee, uint16 indexed newTreasuryFee, uint256 timestamp); /** * @dev Emitted when the metadata associated with a profile is set in the `LensPeriphery`. * * @param profileId The profile ID the metadata is set for. * @param metadata The metadata set for the profile and user. * @param transactionExecutor The address of the account that executed this operation. * @param timestamp The current block timestamp. */ event ProfileMetadataSet( uint256 indexed profileId, string metadata, address transactionExecutor, uint256 timestamp ); /** * @dev Emitted when an address' Profile Guardian state change is triggered. * * @param wallet The address whose Token Guardian state change is being triggered. * @param enabled True if the Token Guardian is being enabled, false if it is being disabled. * @param tokenGuardianDisablingTimestamp The UNIX timestamp when disabling the Token Guardian will take effect, * if disabling it. Zero if the protection is being enabled. * @param timestamp The UNIX timestamp of the change being triggered. */ event TokenGuardianStateChanged( address indexed wallet, bool indexed enabled, uint256 tokenGuardianDisablingTimestamp, uint256 timestamp ); /** * @dev Emitted when a signer's nonce is used and, as a consequence, the next available nonce is updated. * * @param signer The signer whose next available nonce was updated. * @param nonce The next available nonce that can be used to execute a meta-tx successfully. * @param timestamp The UNIX timestamp of the nonce being used. */ event NonceUpdated(address indexed signer, uint256 nonce, uint256 timestamp); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; library Typehash { bytes32 constant ACT = keccak256('Act(uint256 publicationActedProfileId,uint256 publicationActedId,uint256 actorProfileId,uint256[] referrerProfileIds,uint256[] referrerPubIds,address actionModuleAddress,bytes actionModuleData,uint256 nonce,uint256 deadline)'); bytes32 constant CHANGE_DELEGATED_EXECUTORS_CONFIG = keccak256('ChangeDelegatedExecutorsConfig(uint256 delegatorProfileId,address[] delegatedExecutors,bool[] approvals,uint64 configNumber,bool switchToGivenConfig,uint256 nonce,uint256 deadline)'); bytes32 constant COLLECT_LEGACY = keccak256('CollectLegacy(uint256 publicationCollectedProfileId,uint256 publicationCollectedId,uint256 collectorProfileId,uint256 referrerProfileId,uint256 referrerPubId,bytes collectModuleData,uint256 nonce,uint256 deadline)'); bytes32 constant COMMENT = keccak256('Comment(uint256 profileId,string contentURI,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileIds,uint256[] referrerPubIds,bytes referenceModuleData,address[] actionModules,bytes[] actionModulesInitDatas,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)'); bytes32 constant EIP712_DOMAIN = keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'); bytes32 constant FOLLOW = keccak256('Follow(uint256 followerProfileId,uint256[] idsOfProfilesToFollow,uint256[] followTokenIds,bytes[] datas,uint256 nonce,uint256 deadline)'); bytes32 constant MIRROR = keccak256('Mirror(uint256 profileId,string metadataURI,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileIds,uint256[] referrerPubIds,bytes referenceModuleData,uint256 nonce,uint256 deadline)'); bytes32 constant POST = keccak256('Post(uint256 profileId,string contentURI,address[] actionModules,bytes[] actionModulesInitDatas,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)'); bytes32 constant QUOTE = keccak256('Quote(uint256 profileId,string contentURI,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileIds,uint256[] referrerPubIds,bytes referenceModuleData,address[] actionModules,bytes[] actionModulesInitDatas,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)'); bytes32 constant SET_BLOCK_STATUS = keccak256('SetBlockStatus(uint256 byProfileId,uint256[] idsOfProfilesToSetBlockStatus,bool[] blockStatus,uint256 nonce,uint256 deadline)'); bytes32 constant SET_FOLLOW_MODULE = keccak256('SetFollowModule(uint256 profileId,address followModule,bytes followModuleInitData,uint256 nonce,uint256 deadline)'); bytes32 constant SET_PROFILE_METADATA_URI = keccak256('SetProfileMetadataURI(uint256 profileId,string metadataURI,uint256 nonce,uint256 deadline)'); bytes32 constant UNFOLLOW = keccak256('Unfollow(uint256 unfollowerProfileId,uint256[] idsOfProfilesToUnfollow,uint256 nonce,uint256 deadline)'); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title Types * @author Lens Protocol * * @notice A standard library of data types used throughout the Lens Protocol. */ library Types { /** * @notice ERC721Timestamped storage. Contains the owner address and the mint timestamp for every NFT. * * Note: Instead of the owner address in the _tokenOwners private mapping, we now store it in the * _tokenData mapping, alongside the mint timestamp. * * @param owner The token owner. * @param mintTimestamp The mint timestamp. */ struct TokenData { address owner; uint96 mintTimestamp; } /** * @notice A struct containing token follow-related data. * * @param followerProfileId The ID of the profile using the token to follow. * @param originalFollowTimestamp The timestamp of the first follow performed with the token. * @param followTimestamp The timestamp of the current follow, if a profile is using the token to follow. * @param profileIdAllowedToRecover The ID of the profile allowed to recover the follow ID, if any. */ struct FollowData { uint160 followerProfileId; uint48 originalFollowTimestamp; uint48 followTimestamp; uint256 profileIdAllowedToRecover; } /** * @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 Nonexistent An indicator showing the queried publication does not exist. * @param Post A standard post, having an URI, action modules and no pointer to another publication. * @param Comment A comment, having an URI, action modules and a pointer to another publication. * @param Mirror A mirror, having a pointer to another publication, but no URI or action modules. * @param Quote A quote, having an URI, action modules, and a pointer to another publication. */ enum PublicationType { Nonexistent, Post, Comment, Mirror, Quote } /** * @notice A struct containing the necessary information to reconstruct an EIP-712 typed data signature. * * @param signer The address of the signer. Specially needed as a parameter to support EIP-1271. * @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 { address signer; 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 address(0) in none. * @param followNFT The address of the followNFT associated with this profile. It can be address(0) if the * profile has not been followed yet, as the collection is lazy-deployed upon the first follow. * @param __DEPRECATED__handle DEPRECATED in V2: handle slot, was replaced with LensHandles. * @param __DEPRECATED__imageURI DEPRECATED in V2: The URI to be used for the profile image. * @param __DEPRECATED__followNFTURI DEPRECATED in V2: The URI used for the follow NFT image. * @param metadataURI MetadataURI is used to store the profile's metadata, for example: displayed name, description, * interests, etc. */ struct Profile { uint256 pubCount; // offset 0 address followModule; // offset 1 address followNFT; // offset 2 string __DEPRECATED__handle; // offset 3 string __DEPRECATED__imageURI; // offset 4 string __DEPRECATED__followNFTURI; // Deprecated in V2 as we have a common tokenURI for all Follows, offset 5 string metadataURI; // offset 6 } /** * @notice A struct containing publication data. * * @param pointedProfileId The profile token ID to point the publication to. * @param pointedPubId The publication ID to point the publication to. * These are used to implement the "reference" feature of the platform and is used in: * - Mirrors * - Comments * - Quotes * There are (0,0) if the publication is not pointing to any other publication (i.e. the publication is a Post). * @param contentURI The URI to set for the content of publication (can be ipfs, arweave, http, etc). * @param referenceModule Reference module associated with this profile, if any. * @param __DEPRECATED__collectModule Collect module associated with this publication, if any. Deprecated in V2. * @param __DEPRECATED__collectNFT Collect NFT associated with this publication, if any. Deprecated in V2. * @param pubType The type of publication, can be Nonexistent, Post, Comment, Mirror or Quote. * @param rootProfileId The profile ID of the root post (to determine if comments/quotes and mirrors come from it). * Posts, V1 publications and publications rooted in V1 publications don't have it set. * @param rootPubId The publication ID of the root post (to determine if comments/quotes and mirrors come from it). * Posts, V1 publications and publications rooted in V1 publications don't have it set. * @param actionModuleEnabled The action modules enabled in a given publication. */ struct Publication { uint256 pointedProfileId; uint256 pointedPubId; string contentURI; address referenceModule; address __DEPRECATED__collectModule; // Deprecated in V2 address __DEPRECATED__collectNFT; // Deprecated in V2 // Added in Lens V2, so these will be zero for old publications: PublicationType pubType; uint256 rootProfileId; uint256 rootPubId; mapping(address => bool) actionModuleEnabled; } struct PublicationMemory { uint256 pointedProfileId; uint256 pointedPubId; string contentURI; address referenceModule; address __DEPRECATED__collectModule; // Deprecated in V2 address __DEPRECATED__collectNFT; // Deprecated in V2 // Added in Lens V2, so these will be zero for old publications: PublicationType pubType; uint256 rootProfileId; uint256 rootPubId; // bytes32 __ACTION_MODULE_ENABLED_MAPPING; // Mappings are not supported in memory. } /** * @notice A struct containing the parameters required for the `createProfile()` function. * * @param to The address receiving the profile. * @param followModule The follow module to use, can be the zero address. * @param followModuleInitData The follow module initialization data, if any. */ struct CreateProfileParams { address to; address followModule; bytes followModuleInitData; } /** * @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 actionModules The action modules to set for this new publication. * @param actionModulesInitDatas The data to pass to the action modules' 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 PostParams { uint256 profileId; string contentURI; address[] actionModules; bytes[] actionModulesInitDatas; address referenceModule; bytes referenceModuleInitData; } /** * @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 pointedProfileId The profile token ID to point the comment to. * @param pointedPubId The publication ID to point the comment to. * @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted. * @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted. * @param referenceModuleData The data passed to the reference module. * @param actionModules The action modules to set for this new publication. * @param actionModulesInitDatas The data to pass to the action modules' 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 CommentParams { uint256 profileId; string contentURI; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; bytes referenceModuleData; address[] actionModules; bytes[] actionModulesInitDatas; address referenceModule; bytes referenceModuleInitData; } /** * @notice A struct containing the parameters required for the `quote()` function. * * @param profileId The token ID of the profile to publish to. * @param contentURI The URI to set for this new publication. * @param pointedProfileId The profile token ID of the publication author that is quoted. * @param pointedPubId The publication ID that is quoted. * @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted. * @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted. * @param referenceModuleData The data passed to the reference module. * @param actionModules The action modules to set for this new publication. * @param actionModulesInitDatas The data to pass to the action modules' 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 QuoteParams { uint256 profileId; string contentURI; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; bytes referenceModuleData; address[] actionModules; bytes[] actionModulesInitDatas; address referenceModule; bytes referenceModuleInitData; } /** * @notice A struct containing the parameters required for the `comment()` or `quote()` internal functions. * * @param profileId The token ID of the profile to publish to. * @param contentURI The URI to set for this new publication. * @param pointedProfileId The profile token ID of the publication author that is commented on/quoted. * @param pointedPubId The publication ID that is commented on/quoted. * @param referrerProfileId The profile token ID of the publication that referred to the publication being commented on/quoted. * @param referrerPubId The ID of the publication that referred to the publication being commented on/quoted. * @param referenceModuleData The data passed to the reference module. * @param actionModules The action modules to set for this new publication. * @param actionModulesInitDatas The data to pass to the action modules' 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 ReferencePubParams { uint256 profileId; string contentURI; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; bytes referenceModuleData; address[] actionModules; bytes[] actionModulesInitDatas; address referenceModule; bytes referenceModuleInitData; } /** * @notice A struct containing the parameters required for the `mirror()` function. * * @param profileId The token ID of the profile to publish to. * @param metadataURI the URI containing metadata attributes to attach to this mirror publication. * @param pointedProfileId The profile token ID to point the mirror to. * @param pointedPubId The publication ID to point the mirror to. * @param referenceModuleData The data passed to the reference module. */ struct MirrorParams { uint256 profileId; string metadataURI; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; bytes referenceModuleData; } /** * Deprecated in V2: Will be removed after some time after upgrading to V2. * @notice A struct containing the parameters required for the legacy `collect()` function. * @dev The referrer can only be a mirror of the publication being collected. * * @param publicationCollectedProfileId The token ID of the profile that published the publication to collect. * @param publicationCollectedId The publication to collect's publication ID. * @param collectorProfileId The collector profile. * @param referrerProfileId The ID of a profile that authored a mirror that helped discovering the collected pub. * @param referrerPubId The ID of the mirror that helped discovering the collected pub. * @param collectModuleData The arbitrary data to pass to the collectModule if needed. */ struct LegacyCollectParams { uint256 publicationCollectedProfileId; uint256 publicationCollectedId; uint256 collectorProfileId; uint256 referrerProfileId; uint256 referrerPubId; bytes collectModuleData; } /** * @notice A struct containing the parameters required for the `action()` function. * * @param publicationActedProfileId The token ID of the profile that published the publication to action. * @param publicationActedId The publication to action's publication ID. * @param actorProfileId The actor profile. * @param referrerProfileId * @param referrerPubId * @param actionModuleAddress * @param actionModuleData The arbitrary data to pass to the actionModule if needed. */ struct PublicationActionParams { uint256 publicationActedProfileId; uint256 publicationActedId; uint256 actorProfileId; uint256[] referrerProfileIds; uint256[] referrerPubIds; address actionModuleAddress; bytes actionModuleData; } struct ProcessActionParams { uint256 publicationActedProfileId; uint256 publicationActedId; uint256 actorProfileId; address actorProfileOwner; address transactionExecutor; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes actionModuleData; } struct ProcessCommentParams { uint256 profileId; uint256 pubId; address transactionExecutor; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes data; } struct ProcessQuoteParams { uint256 profileId; uint256 pubId; address transactionExecutor; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes data; } struct ProcessMirrorParams { uint256 profileId; uint256 pubId; address transactionExecutor; uint256 pointedProfileId; uint256 pointedPubId; uint256[] referrerProfileIds; uint256[] referrerPubIds; Types.PublicationType[] referrerPubTypes; bytes data; } /** * @notice A struct containing a profile's delegated executors configuration. * * @param isApproved Tells when an address is approved as delegated executor in the given configuration number. * @param configNumber Current configuration number in use. * @param prevConfigNumber Previous configuration number set, before switching to the current one. * @param maxConfigNumberSet Maximum configuration number ever used. */ struct DelegatedExecutorsConfig { mapping(uint256 => mapping(address => bool)) isApproved; // isApproved[configNumber][delegatedExecutor] uint64 configNumber; uint64 prevConfigNumber; uint64 maxConfigNumberSet; } struct TreasuryData { address treasury; uint16 treasuryFeeBPS; } struct MigrationParams { address lensHandlesAddress; address tokenHandleRegistryAddress; address legacyFeeFollowModule; address legacyProfileFollowModule; address newFeeFollowModule; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.15; import {Errors} from 'contracts/modules/constants/Errors.sol'; /** * @title ActionRestricted * @author Lens Protocol * * @notice This abstract contract adds a public `ACTION_MODULE` immutable field, and `onlyActionModule` modifier, * to inherit from contracts that have functions restricted to be only called by the Action Modules. */ abstract contract ActionRestricted { address public immutable ACTION_MODULE; modifier onlyActionModule() { if (msg.sender != ACTION_MODULE) { revert Errors.NotActionModule(); } _; } constructor(address actionModule) { ACTION_MODULE = actionModule; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; library Errors { error FollowInvalid(); error ModuleDataMismatch(); error NotHub(); error InitParamsInvalid(); error InvalidParams(); error MintLimitExceeded(); error CollectExpired(); error NotActionModule(); error CollectNotAllowed(); error AlreadyInitialized(); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
{ "remappings": [ "@ensdomains/=node_modules/@ensdomains/", "@openzeppelin/=lib/openzeppelin-contracts/", "@seadrop/=lib/seadrop/src/", "ERC721A-Upgradeable/=lib/seadrop/lib/ERC721A-Upgradeable/contracts/", "ERC721A/=lib/seadrop/lib/ERC721A/contracts/", "create2-helpers/=lib/seadrop/lib/create2-helpers/", "create2-scripts/=lib/seadrop/lib/create2-helpers/script/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/seadrop/lib/operator-filter-registry/lib/openzeppelin-contracts/lib/erc4626-tests/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "forge-std/=lib/forge-std/src/", "hardhat/=node_modules/hardhat/", "murky/=lib/seadrop/lib/murky/src/", "openzeppelin-contracts-upgradeable/=lib/seadrop/lib/openzeppelin-contracts-upgradeable/contracts/", "openzeppelin-contracts/=lib/seadrop/lib/openzeppelin-contracts/contracts/", "operator-filter-registry/=lib/seadrop/lib/operator-filter-registry/src/", "seadrop/=lib/seadrop/", "solady/=lib/solady/src/", "solmate/=lib/seadrop/lib/solmate/src/", "utility-contracts/=lib/seadrop/lib/utility-contracts/src/" ], "optimizer": { "enabled": true, "runs": 10 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": true, "libraries": { "contracts/libraries/ActionLib.sol": { "ActionLib": "0x7990dac84e3241fe314b980bba1466ac08715c4f" }, "contracts/libraries/FollowLib.sol": { "FollowLib": "0xe280cb21fb36b6b2d584428b809a6b822a5c2260" }, "contracts/libraries/GovernanceLib.sol": { "GovernanceLib": "0x5268512d20bf7653cf6d54b7c485ae3fbc658451" }, "contracts/libraries/LegacyCollectLib.sol": { "LegacyCollectLib": "0x5f0f24377c00f1517b4de496cf49eec8beb4ecb4" }, "contracts/libraries/MetaTxLib.sol": { "MetaTxLib": "0xf191c489e4ba0f448ea08a5fd27e9c928643f5c7" }, "contracts/libraries/MigrationLib.sol": { "MigrationLib": "0x0deced9ac3833b687d69d4eac6655f0f1279acee" }, "contracts/libraries/ProfileLib.sol": { "ProfileLib": "0x3fce2475a92c185f9634f5638f6b33306d77bb10" }, "contracts/libraries/PublicationLib.sol": { "PublicationLib": "0x90654f24a2c164a4da8f763ac8bc032d3d083a1b" }, "contracts/libraries/ValidationLib.sol": { "ValidationLib": "0x9cafd24d2851d9eb56e5a8fd394ab2ac0ef99849" }, "contracts/libraries/token-uris/FollowTokenURILib.sol": { "FollowTokenURILib": "0xc58f0e2a361e35c08619ef5f6122dc15180d783e" }, "contracts/libraries/token-uris/HandleTokenURILib.sol": { "HandleTokenURILib": "0x0e20f112689c7894ab8142108574e45d2650f529" }, "contracts/libraries/token-uris/ProfileTokenURILib.sol": { "ProfileTokenURILib": "0xf167835e74eecfe4bc571701d34fd38f4b61a830" } } }
[{"inputs":[{"internalType":"address","name":"hub","type":"address"},{"internalType":"address","name":"actionModule","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Initialized","type":"error"},{"inputs":[],"name":"InvalidOwner","type":"error"},{"inputs":[],"name":"InvalidParameter","type":"error"},{"inputs":[],"name":"NonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"NotActionModule","type":"error"},{"inputs":[],"name":"NotOwnerOrApproved","type":"error"},{"inputs":[],"name":"NotProfileOwner","type":"error"},{"inputs":[],"name":"TokenDoesNotExist","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"ACTION_MODULE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HUB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDomainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSourcePublicationPointer","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"mintTimestampOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"royaltiesInBasisPoints","type":"uint256"}],"name":"setRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenDataOf","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint96","name":"mintTimestamp","type":"uint96"}],"internalType":"struct Types.TokenData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.