Mumbai Testnet

Contract

0x4F0c856b2FA2c1e0E1AC971B462FCCF4654E8045

Overview

MATIC Balance

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
Comment300420412022-12-23 9:05:23522 days ago1671786323IN
0x4F0c856b...4654E8045
0 MATIC0.000585720
Create Profile253742672022-03-04 13:22:55816 days ago1646400175IN
0x4F0c856b...4654E8045
0 MATIC0.000059442.00000001
Whitelist Profil...253742272022-03-04 13:19:35816 days ago1646399975IN
0x4F0c856b...4654E8045
0 MATIC0.000048452.00000001
Follow253491232022-03-02 17:27:43818 days ago1646242063IN
0x4F0c856b...4654E8045
0 MATIC0.000034811.00000005
Follow249479892022-02-15 4:15:39833 days ago1644898539IN
0x4F0c856b...4654E8045
0 MATIC0.0003479410
Whitelist Profil...247220652022-02-08 12:28:26840 days ago1644323306IN
0x4F0c856b...4654E8045
0 MATIC0.000048451.99999999
Whitelist Profil...247156492022-02-08 8:13:37840 days ago1644308017IN
0x4F0c856b...4654E8045
0 MATIC0.000048451.99999998
Whitelist Profil...247031782022-02-08 0:43:31840 days ago1644281011IN
0x4F0c856b...4654E8045
0 MATIC0.000048451.99999999
Create Profile247031202022-02-08 0:41:31840 days ago1644280891IN
0x4F0c856b...4654E8045
0 MATIC0.000055971.99999999
Create Profile247029782022-02-08 0:36:39840 days ago1644280599IN
0x4F0c856b...4654E8045
0 MATIC0.000055971.99999999
Create Profile247018172022-02-07 23:48:09840 days ago1644277689IN
0x4F0c856b...4654E8045
0 MATIC0.000083953
Whitelist Profil...247014242022-02-07 23:32:31840 days ago1644276751IN
0x4F0c856b...4654E8045
0 MATIC0.000096914
Whitelist Profil...247013782022-02-07 23:30:59840 days ago1644276659IN
0x4F0c856b...4654E8045
0 MATIC0.000048451.99999999
0x60e06040246655292022-02-06 21:23:40841 days ago1644182620IN
 Create: LensHub
0 MATIC0.010333222

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LensHub

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 32 : LensHub.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {ILensHub} from '../interfaces/ILensHub.sol';
import {Events} from '../libraries/Events.sol';
import {Helpers} from '../libraries/Helpers.sol';
import {DataTypes} from '../libraries/DataTypes.sol';
import {Errors} from '../libraries/Errors.sol';
import {PublishingLogic} from '../libraries/PublishingLogic.sol';
import {InteractionLogic} from '../libraries/InteractionLogic.sol';
import {LensNFTBase} from './base/LensNFTBase.sol';
import {LensMultiState} from './base/LensMultiState.sol';
import {LensHubStorage} from './storage/LensHubStorage.sol';
import {VersionedInitializable} from '../upgradeability/VersionedInitializable.sol';

/**
 * @title LensHub
 * @author Lens Protocol
 *
 * @notice This is the main entrypoint of the Lens Protocol. It contains governance functionality as well as
 * publishing and profile interaction functionality.
 *
 * NOTE: The Lens Protocol is unique in that frontend operators need to track a potentially overwhelming
 * number of NFT contracts and interactions at once. For that reason, we've made two quirky design decisions:
 *      1. Both Follow & Collect NFTs invoke an LensHub callback on transfer with the sole purpose of emitting an event.
 *      2. Almost every event in the protocol emits the current block timestamp, reducing the need to fetch it manually.
 */
contract LensHub is ILensHub, LensNFTBase, VersionedInitializable, LensMultiState, LensHubStorage {
    uint256 internal constant REVISION = 1;

    address internal immutable FOLLOW_NFT_IMPL;
    address internal immutable COLLECT_NFT_IMPL;

    /**
     * @dev This modifier reverts if the caller is not the configured governance address.
     */
    modifier onlyGov() {
        _validateCallerIsGovernance();
        _;
    }

    /**
     * @dev This modifier reverts if the caller is not a whitelisted profile creator address.
     */
    modifier onlyWhitelistedProfileCreator() {
        _validateCallerIsWhitelistedProfileCreator();
        _;
    }

    /**
     * @dev The constructor sets the immutable follow & collect NFT implementations.
     *
     * @param followNFTImpl The follow NFT implementation address.
     * @param collectNFTImpl The collect NFT implementation address.
     */
    constructor(address followNFTImpl, address collectNFTImpl) {
        FOLLOW_NFT_IMPL = followNFTImpl;
        COLLECT_NFT_IMPL = collectNFTImpl;
    }

    /// @inheritdoc ILensHub
    function initialize(
        string calldata name,
        string calldata symbol,
        address newGovernance
    ) external override initializer {
        super._initialize(name, symbol);
        _setState(DataTypes.ProtocolState.Paused);
        _setGovernance(newGovernance);
    }

    /// ***********************
    /// *****GOV FUNCTIONS*****
    /// ***********************

    /// @inheritdoc ILensHub
    function setGovernance(address newGovernance) external override onlyGov {
        _setGovernance(newGovernance);
    }

    /// @inheritdoc ILensHub
    function setEmergencyAdmin(address newEmergencyAdmin) external override onlyGov {
        address prevEmergencyAdmin = _emergencyAdmin;
        _emergencyAdmin = newEmergencyAdmin;
        emit Events.EmergencyAdminSet(
            msg.sender,
            prevEmergencyAdmin,
            newEmergencyAdmin,
            block.timestamp
        );
    }

    /// @inheritdoc ILensHub
    function setState(DataTypes.ProtocolState newState) external override {
        if (msg.sender != _governance && msg.sender != _emergencyAdmin)
            revert Errors.NotGovernanceOrEmergencyAdmin();
        _setState(newState);
    }

    ///@inheritdoc ILensHub
    function whitelistProfileCreator(address profileCreator, bool whitelist)
        external
        override
        onlyGov
    {
        _profileCreatorWhitelisted[profileCreator] = whitelist;
        emit Events.ProfileCreatorWhitelisted(profileCreator, whitelist, block.timestamp);
    }

    /// @inheritdoc ILensHub
    function whitelistFollowModule(address followModule, bool whitelist) external override onlyGov {
        _followModuleWhitelisted[followModule] = whitelist;
        emit Events.FollowModuleWhitelisted(followModule, whitelist, block.timestamp);
    }

    /// @inheritdoc ILensHub
    function whitelistReferenceModule(address referenceModule, bool whitelist)
        external
        override
        onlyGov
    {
        _referenceModuleWhitelisted[referenceModule] = whitelist;
        emit Events.ReferenceModuleWhitelisted(referenceModule, whitelist, block.timestamp);
    }

    /// @inheritdoc ILensHub
    function whitelistCollectModule(address collectModule, bool whitelist)
        external
        override
        onlyGov
    {
        _collectModuleWhitelisted[collectModule] = whitelist;
        emit Events.CollectModuleWhitelisted(collectModule, whitelist, block.timestamp);
    }

    /// *********************************
    /// *****PROFILE OWNER FUNCTIONS*****
    /// *********************************

    /// @inheritdoc ILensHub
    function createProfile(DataTypes.CreateProfileData calldata vars)
        external
        override
        whenNotPaused
        onlyWhitelistedProfileCreator
    {
        uint256 profileId = ++_profileCounter;
        _mint(vars.to, profileId);
        PublishingLogic.createProfile(
            vars,
            profileId,
            _profileIdByHandleHash,
            _profileById,
            _followModuleWhitelisted
        );
    }

    /// @inheritdoc ILensHub
    function setFollowModule(
        uint256 profileId,
        address followModule,
        bytes calldata followModuleData
    ) external override whenNotPaused {
        _validateCallerIsProfileOwner(profileId);
        PublishingLogic.setFollowModule(
            profileId,
            followModule,
            followModuleData,
            _profileById[profileId],
            _followModuleWhitelisted
        );
    }

    /// @inheritdoc ILensHub
    function setFollowModuleWithSig(DataTypes.SetFollowModuleWithSigData calldata vars)
        external
        override
        whenNotPaused
    {
        address owner = ownerOf(vars.profileId);
        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            SET_FOLLOW_MODULE_WITH_SIG_TYPEHASH,
                            vars.profileId,
                            vars.followModule,
                            keccak256(vars.followModuleData),
                            sigNonces[owner]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, vars.sig);
        PublishingLogic.setFollowModule(
            vars.profileId,
            vars.followModule,
            vars.followModuleData,
            _profileById[vars.profileId],
            _followModuleWhitelisted
        );
    }

    /// @inheritdoc ILensHub
    function setDispatcher(uint256 profileId, address dispatcher) external override whenNotPaused {
        _validateCallerIsProfileOwner(profileId);
        _setDispatcher(profileId, dispatcher);
    }

    /// @inheritdoc ILensHub
    function setDispatcherWithSig(DataTypes.SetDispatcherWithSigData calldata vars)
        external
        override
        whenNotPaused
    {
        address owner = ownerOf(vars.profileId);
        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            SET_DISPATCHER_WITH_SIG_TYPEHASH,
                            vars.profileId,
                            vars.dispatcher,
                            sigNonces[owner]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, vars.sig);
        _setDispatcher(vars.profileId, vars.dispatcher);
    }

    /// @inheritdoc ILensHub
    function setProfileImageURI(uint256 profileId, string calldata imageURI)
        external
        override
        whenNotPaused
    {
        _validateCallerIsProfileOwnerOrDispatcher(profileId);
        _setProfileImageURI(profileId, imageURI);
    }

    /// @inheritdoc ILensHub
    function setProfileImageURIWithSig(DataTypes.SetProfileImageURIWithSigData calldata vars)
        external
        override
        whenNotPaused
    {
        address owner = ownerOf(vars.profileId);
        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            SET_PROFILE_IMAGE_URI_WITH_SIG_TYPEHASH,
                            vars.profileId,
                            keccak256(bytes(vars.imageURI)),
                            sigNonces[owner]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, vars.sig);
        _setProfileImageURI(vars.profileId, vars.imageURI);
    }

    /// @inheritdoc ILensHub
    function setFollowNFTURI(uint256 profileId, string calldata followNFTURI)
        external
        override
        whenNotPaused
    {
        _validateCallerIsProfileOwnerOrDispatcher(profileId);
        _setFollowNFTURI(profileId, followNFTURI);
    }

    /// @inheritdoc ILensHub
    function setFollowNFTURIWithSig(DataTypes.SetFollowNFTURIWithSigData calldata vars)
        external
        override
        whenNotPaused
    {
        address owner = ownerOf(vars.profileId);
        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            SET_FOLLOW_NFT_URI_WITH_SIG_TYPEHASH,
                            vars.profileId,
                            keccak256(bytes(vars.followNFTURI)),
                            sigNonces[owner]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, vars.sig);
        _setFollowNFTURI(vars.profileId, vars.followNFTURI);
    }

    /// @inheritdoc ILensHub
    function post(DataTypes.PostData calldata vars) external override whenPublishingEnabled {
        _validateCallerIsProfileOwnerOrDispatcher(vars.profileId);
        _createPost(
            vars.profileId,
            vars.contentURI,
            vars.collectModule,
            vars.collectModuleData,
            vars.referenceModule,
            vars.referenceModuleData
        );
    }

    /// @inheritdoc ILensHub
    function postWithSig(DataTypes.PostWithSigData calldata vars)
        external
        override
        whenPublishingEnabled
    {
        address owner = ownerOf(vars.profileId);
        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            POST_WITH_SIG_TYPEHASH,
                            vars.profileId,
                            keccak256(bytes(vars.contentURI)),
                            vars.collectModule,
                            keccak256(vars.collectModuleData),
                            vars.referenceModule,
                            keccak256(vars.referenceModuleData),
                            sigNonces[owner]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, vars.sig);
        _createPost(
            vars.profileId,
            vars.contentURI,
            vars.collectModule,
            vars.collectModuleData,
            vars.referenceModule,
            vars.referenceModuleData
        );
    }

    /// @inheritdoc ILensHub
    function comment(DataTypes.CommentData calldata vars) external override whenPublishingEnabled {
        _validateCallerIsProfileOwnerOrDispatcher(vars.profileId);
        _createComment(vars);
    }

    /// @inheritdoc ILensHub
    function commentWithSig(DataTypes.CommentWithSigData calldata vars)
        external
        override
        whenPublishingEnabled
    {
        address owner = ownerOf(vars.profileId);
        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            COMMENT_WITH_SIG_TYPEHASH,
                            vars.profileId,
                            keccak256(bytes(vars.contentURI)),
                            vars.profileIdPointed,
                            vars.pubIdPointed,
                            vars.collectModule,
                            keccak256(vars.collectModuleData),
                            vars.referenceModule,
                            keccak256(vars.referenceModuleData),
                            sigNonces[owner]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, vars.sig);
        _createComment(
            DataTypes.CommentData(
                vars.profileId,
                vars.contentURI,
                vars.profileIdPointed,
                vars.pubIdPointed,
                vars.collectModule,
                vars.collectModuleData,
                vars.referenceModule,
                vars.referenceModuleData
            )
        );
    }

    /// @inheritdoc ILensHub
    function mirror(DataTypes.MirrorData calldata vars) external override whenPublishingEnabled {
        _validateCallerIsProfileOwnerOrDispatcher(vars.profileId);
        _createMirror(
            vars.profileId,
            vars.profileIdPointed,
            vars.pubIdPointed,
            vars.referenceModule,
            vars.referenceModuleData
        );
    }

    /// @inheritdoc ILensHub
    function mirrorWithSig(DataTypes.MirrorWithSigData calldata vars)
        external
        override
        whenPublishingEnabled
    {
        address owner = ownerOf(vars.profileId);
        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            MIRROR_WITH_SIG_TYPEHASH,
                            vars.profileId,
                            vars.profileIdPointed,
                            vars.pubIdPointed,
                            vars.referenceModule,
                            keccak256(vars.referenceModuleData),
                            sigNonces[owner]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, vars.sig);
        _createMirror(
            vars.profileId,
            vars.profileIdPointed,
            vars.pubIdPointed,
            vars.referenceModule,
            vars.referenceModuleData
        );
    }

    /**
     * @notice Burns a profile, this maintains the profile data struct, but deletes the
     * handle hash to profile ID mapping value.
     *
     * NOTE: This overrides the LensNFTBase contract's `burn()` function and calls it to fully burn
     * the NFT.
     */
    function burn(uint256 tokenId) public override whenNotPaused {
        super.burn(tokenId);
        _clearHandleHash(tokenId);
    }

    /**
     * @notice Burns a profile with a signature, this maintains the profile data struct, but deletes the
     * handle hash to profile ID mapping value.
     *
     * NOTE: This overrides the LensNFTBase contract's `burnWithSig()` function and calls it to fully burn
     * the NFT.
     */
    function burnWithSig(uint256 tokenId, DataTypes.EIP712Signature calldata sig)
        public
        override
        whenNotPaused
    {
        super.burnWithSig(tokenId, sig);
        _clearHandleHash(tokenId);
    }

    /// ***************************************
    /// *****PROFILE INTERACTION FUNCTIONS*****
    /// ***************************************

    /// @inheritdoc ILensHub
    function follow(uint256[] calldata profileIds, bytes[] calldata datas)
        external
        override
        whenNotPaused
    {
        InteractionLogic.follow(
            msg.sender,
            profileIds,
            datas,
            FOLLOW_NFT_IMPL,
            _profileById,
            _profileIdByHandleHash
        );
    }

    /// @inheritdoc ILensHub
    function followWithSig(DataTypes.FollowWithSigData calldata vars)
        external
        override
        whenNotPaused
    {
        bytes32[] memory dataHashes = new bytes32[](vars.datas.length);
        for (uint256 i = 0; i < vars.datas.length; i++) {
            dataHashes[i] = keccak256(vars.datas[i]);
        }

        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            FOLLOW_WITH_SIG_TYPEHASH,
                            keccak256(abi.encodePacked(vars.profileIds)),
                            keccak256(abi.encodePacked(dataHashes)),
                            sigNonces[vars.follower]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, vars.follower, vars.sig);
        InteractionLogic.follow(
            vars.follower,
            vars.profileIds,
            vars.datas,
            FOLLOW_NFT_IMPL,
            _profileById,
            _profileIdByHandleHash
        );
    }

    /// @inheritdoc ILensHub
    function collect(
        uint256 profileId,
        uint256 pubId,
        bytes calldata data
    ) external override whenNotPaused {
        InteractionLogic.collect(
            msg.sender,
            profileId,
            pubId,
            data,
            COLLECT_NFT_IMPL,
            _pubByIdByProfile,
            _profileById
        );
    }

    /// @inheritdoc ILensHub
    function collectWithSig(DataTypes.CollectWithSigData calldata vars)
        external
        override
        whenNotPaused
    {
        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            COLLECT_WITH_SIG_TYPEHASH,
                            vars.profileId,
                            vars.pubId,
                            keccak256(vars.data),
                            sigNonces[vars.collector]++,
                            vars.sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, vars.collector, vars.sig);
        InteractionLogic.collect(
            vars.collector,
            vars.profileId,
            vars.pubId,
            vars.data,
            COLLECT_NFT_IMPL,
            _pubByIdByProfile,
            _profileById
        );
    }

    /// @inheritdoc ILensHub
    function emitFollowNFTTransferEvent(
        uint256 profileId,
        uint256 followNFTId,
        address from,
        address to
    ) external override {
        address expectedFollowNFT = _profileById[profileId].followNFT;
        if (msg.sender != expectedFollowNFT) revert Errors.CallerNotFollowNFT();
        emit Events.FollowNFTTransferred(profileId, followNFTId, from, to, block.timestamp);
    }

    /// @inheritdoc ILensHub
    function emitCollectNFTTransferEvent(
        uint256 profileId,
        uint256 pubId,
        uint256 collectNFTId,
        address from,
        address to
    ) external override {
        address expectedCollectNFT = _pubByIdByProfile[profileId][pubId].collectNFT;
        if (msg.sender != expectedCollectNFT) revert Errors.CallerNotCollectNFT();
        emit Events.CollectNFTTransferred(
            profileId,
            pubId,
            collectNFTId,
            from,
            to,
            block.timestamp
        );
    }

    /// *********************************
    /// *****EXTERNAL VIEW FUNCTIONS*****
    /// *********************************

    /// @inheritdoc ILensHub
    function isProfileCreatorWhitelisted(address profileCreator)
        external
        view
        override
        returns (bool)
    {
        return _profileCreatorWhitelisted[profileCreator];
    }

    /// @inheritdoc ILensHub
    function isFollowModuleWhitelisted(address followModule) external view override returns (bool) {
        return _followModuleWhitelisted[followModule];
    }

    /// @inheritdoc ILensHub
    function isReferenceModuleWhitelisted(address referenceModule)
        external
        view
        override
        returns (bool)
    {
        return _referenceModuleWhitelisted[referenceModule];
    }

    /// @inheritdoc ILensHub
    function isCollectModuleWhitelisted(address collectModule)
        external
        view
        override
        returns (bool)
    {
        return _collectModuleWhitelisted[collectModule];
    }

    /// @inheritdoc ILensHub
    function getGovernance() external view override returns (address) {
        return _governance;
    }

    /// @inheritdoc ILensHub
    function getDispatcher(uint256 profileId) external view override returns (address) {
        return _dispatcherByProfile[profileId];
    }

    /// @inheritdoc ILensHub
    function getPubCount(uint256 profileId) external view override returns (uint256) {
        return _profileById[profileId].pubCount;
    }

    /// @inheritdoc ILensHub
    function getFollowNFT(uint256 profileId) external view override returns (address) {
        return _profileById[profileId].followNFT;
    }

    /// @inheritdoc ILensHub
    function getFollowNFTURI(uint256 profileId) external view override returns (string memory) {
        return _profileById[profileId].followNFTURI;
    }

    /// @inheritdoc ILensHub
    function getCollectNFT(uint256 profileId, uint256 pubId)
        external
        view
        override
        returns (address)
    {
        return _pubByIdByProfile[profileId][pubId].collectNFT;
    }

    /// @inheritdoc ILensHub
    function getFollowModule(uint256 profileId) external view override returns (address) {
        return _profileById[profileId].followModule;
    }

    /// @inheritdoc ILensHub
    function getCollectModule(uint256 profileId, uint256 pubId)
        external
        view
        override
        returns (address)
    {
        return _pubByIdByProfile[profileId][pubId].collectModule;
    }

    /// @inheritdoc ILensHub
    function getReferenceModule(uint256 profileId, uint256 pubId)
        external
        view
        override
        returns (address)
    {
        return _pubByIdByProfile[profileId][pubId].referenceModule;
    }

    /// @inheritdoc ILensHub
    function getHandle(uint256 profileId) external view override returns (string memory) {
        return _profileById[profileId].handle;
    }

    /// @inheritdoc ILensHub
    function getPubPointer(uint256 profileId, uint256 pubId)
        external
        view
        override
        returns (uint256, uint256)
    {
        uint256 profileIdPointed = _pubByIdByProfile[profileId][pubId].profileIdPointed;
        uint256 pubIdPointed = _pubByIdByProfile[profileId][pubId].pubIdPointed;
        return (profileIdPointed, pubIdPointed);
    }

    /// @inheritdoc ILensHub
    function getContentURI(uint256 profileId, uint256 pubId)
        external
        view
        override
        returns (string memory)
    {
        (uint256 rootProfileId, uint256 rootPubId, ) = Helpers.getPointedIfMirror(
            profileId,
            pubId,
            _pubByIdByProfile
        );
        return _pubByIdByProfile[rootProfileId][rootPubId].contentURI;
    }

    /// @inheritdoc ILensHub
    function getProfileIdByHandle(string calldata handle) external view override returns (uint256) {
        bytes32 handleHash = keccak256(bytes(handle));
        return _profileIdByHandleHash[handleHash];
    }

    /// @inheritdoc ILensHub
    function getProfile(uint256 profileId)
        external
        view
        override
        returns (DataTypes.ProfileStruct memory)
    {
        return _profileById[profileId];
    }

    /// @inheritdoc ILensHub
    function getPub(uint256 profileId, uint256 pubId)
        external
        view
        override
        returns (DataTypes.PublicationStruct memory)
    {
        return _pubByIdByProfile[profileId][pubId];
    }

    /// @inheritdoc ILensHub
    function getPubType(uint256 profileId, uint256 pubId)
        external
        view
        override
        returns (DataTypes.PubType)
    {
        if (pubId == 0 || _profileById[profileId].pubCount < pubId) {
            return DataTypes.PubType.Nonexistent;
        } else if (_pubByIdByProfile[profileId][pubId].collectModule == address(0)) {
            return DataTypes.PubType.Mirror;
        } else {
            if (_pubByIdByProfile[profileId][pubId].profileIdPointed == 0) {
                return DataTypes.PubType.Post;
            } else {
                return DataTypes.PubType.Comment;
            }
        }
    }

    /**
     * @dev Overrides the ERC721 tokenURI function to return the associated URI with a given profile.
     */
    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        return _profileById[tokenId].imageURI; // temp
    }

    /// ****************************
    /// *****INTERNAL FUNCTIONS*****
    /// ****************************

    function _setGovernance(address newGovernance) internal {
        address prevGovernance = _governance;
        _governance = newGovernance;
        emit Events.GovernanceSet(msg.sender, prevGovernance, newGovernance, block.timestamp);
    }

    function _createPost(
        uint256 profileId,
        string memory contentURI,
        address collectModule,
        bytes memory collectModuleData,
        address referenceModule,
        bytes memory referenceModuleData
    ) internal {
        PublishingLogic.createPost(
            profileId,
            contentURI,
            collectModule,
            collectModuleData,
            referenceModule,
            referenceModuleData,
            ++_profileById[profileId].pubCount,
            _pubByIdByProfile,
            _collectModuleWhitelisted,
            _referenceModuleWhitelisted
        );
    }

    function _createComment(DataTypes.CommentData memory vars) internal {
        PublishingLogic.createComment(
            vars,
            _profileById[vars.profileId].pubCount + 1,
            _profileById,
            _pubByIdByProfile,
            _collectModuleWhitelisted,
            _referenceModuleWhitelisted
        );
        _profileById[vars.profileId].pubCount++;
    }

    function _createMirror(
        uint256 profileId,
        uint256 profileIdPointed,
        uint256 pubIdPointed,
        address referenceModule,
        bytes calldata referenceModuleData
    ) internal {
        PublishingLogic.createMirror(
            profileId,
            profileIdPointed,
            pubIdPointed,
            referenceModule,
            referenceModuleData,
            ++_profileById[profileId].pubCount,
            _pubByIdByProfile,
            _referenceModuleWhitelisted
        );
    }

    function _setDispatcher(uint256 profileId, address dispatcher) internal {
        _dispatcherByProfile[profileId] = dispatcher;
        emit Events.DispatcherSet(profileId, dispatcher, block.timestamp);
    }

    function _setProfileImageURI(uint256 profileId, string memory imageURI) internal {
        _profileById[profileId].imageURI = imageURI;
        emit Events.ProfileImageURISet(profileId, imageURI, block.timestamp);
    }

    function _setFollowNFTURI(uint256 profileId, string memory followNFTURI) internal {
        _profileById[profileId].followNFTURI = followNFTURI;
        emit Events.FollowNFTURISet(profileId, followNFTURI, block.timestamp);
    }

    function _clearHandleHash(uint256 profileId) internal {
        bytes32 handleHash = keccak256(bytes(_profileById[profileId].handle));
        _profileIdByHandleHash[handleHash] = 0;
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal override {
        if (_dispatcherByProfile[tokenId] != address(0)) {
            _setDispatcher(tokenId, address(0));
        }
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function _validateCallerIsProfileOwnerOrDispatcher(uint256 profileId) internal view {
        if (msg.sender != ownerOf(profileId) && msg.sender != _dispatcherByProfile[profileId])
            revert Errors.NotProfileOwnerOrDispatcher();
    }

    function _validateCallerIsProfileOwner(uint256 profileId) internal view {
        if (msg.sender != ownerOf(profileId)) revert Errors.NotProfileOwner();
    }

    function _validateCallerIsGovernance() internal view {
        if (msg.sender != _governance) revert Errors.NotGovernance();
    }

    function _validateCallerIsWhitelistedProfileCreator() internal view {
        if (!_profileCreatorWhitelisted[msg.sender]) revert Errors.ProfileCreatorNotWhitelisted();
    }

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

File 2 of 32 : ILensHub.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {DataTypes} from '../libraries/DataTypes.sol';

/**
 * @title ILensHub
 * @author Lens Protocol
 *
 * @notice This is the interface for the LensHub contract, the main entry point for the Lens Protocol.
 * You'll find all the events and external functions, as well as the reasoning behind them here.
 */
interface ILensHub {
    /**
     * @notice Initializes the LensHub NFT, setting the initial governance address as well as the name and symbol in
     * the LensNFTBase contract.
     *
     * @param name The name to set for the hub NFT.
     * @param symbol The symbol to set for the hub NFT.
     * @param newGovernance The governance address to set.
     */
    function initialize(
        string calldata name,
        string calldata symbol,
        address newGovernance
    ) external;

    /**
     * @notice Sets the privileged governance role. This function can only be called by the current governance
     * address.
     *
     * @param newGovernance The new governance address to set.
     */
    function setGovernance(address newGovernance) external;

    /**
     * @notice Sets the emergency admin, which is a permissioned role able to set the protocol state. This function
     * can only be called by the governance address.
     *
     * @param newEmergencyAdmin The new emergency admin address to set.
     */
    function setEmergencyAdmin(address newEmergencyAdmin) external;

    /**
     * @notice Sets the protocol state to either a global pause, a publishing pause or an unpaused state. This function
     * can only be called by the governance address or the emergency admin address.
     *
     * @param state The state to set, as a member of the ProtocolState enum.
     */
    function setState(DataTypes.ProtocolState state) external;

    /**
     * @notice Adds or removes a profile creator from the whitelist. This function can only be called by the current
     * governance address.
     *
     * @param profileCreator The profile creator address to add or remove from the whitelist.
     * @param whitelist Whether or not the profile creator should be whitelisted.
     */
    function whitelistProfileCreator(address profileCreator, bool whitelist) external;

    /**
     * @notice Adds or removes a follow module from the whitelist. This function can only be called by the current
     * governance address.
     *
     * @param followModule The follow module contract address to add or remove from the whitelist.
     * @param whitelist Whether or not the follow module should be whitelisted.
     */
    function whitelistFollowModule(address followModule, bool whitelist) external;

    /**
     * @notice Adds or removes a reference module from the whitelist. This function can only be called by the current
     * governance address.
     *
     * @param referenceModule The reference module contract to add or remove from the whitelist.
     * @param whitelist Whether or not the reference module should be whitelisted.
     */
    function whitelistReferenceModule(address referenceModule, bool whitelist) external;

    /**
     * @notice Adds or removes a collect module from the whitelist. This function can only be called by the current
     * governance address.
     *
     * @param collectModule The collect module contract address to add or remove from the whitelist.
     * @param whitelist Whether or not the collect module should be whitelisted.
     */
    function whitelistCollectModule(address collectModule, bool whitelist) external;

    /**
     * @notice Creates a profile with the specified parameters, minting a profile NFT to the given recipient. This
     * function must be called by a whitelisted profile creator.
     *
     * @param vars A CreateProfileData struct containing the following params:
     *      to: The address receiving the profile.
     *      handle: The handle to set for the profile, must be unique and non-empty.
     *      imageURI: The URI to set for the profile image.
     *      followModule: The follow module to use, can be the zero address.
     *      followModuleData: The follow module initialization data, if any
     */
    function createProfile(DataTypes.CreateProfileData calldata vars) external;

    /**
     * @notice Sets a profile's follow module, must be called by the profile owner.
     *
     * @param profileId The token ID of the profile to set the follow module for.
     * @param followModule The follow module to set for the given profile, must be whitelisted.
     * @param followModuleData The data to be passed to the follow module for initialization.
     */
    function setFollowModule(
        uint256 profileId,
        address followModule,
        bytes calldata followModuleData
    ) external;

    /**
     * @notice Sets a profile's follow module via signature with the specified parameters.
     *
     * @param vars A SetFollowModuleWithSigData struct, including the regular parameters and an EIP712Signature struct.
     */
    function setFollowModuleWithSig(DataTypes.SetFollowModuleWithSigData calldata vars) external;

    /**
     * @notice Sets a profile's dispatcher, giving that dispatcher rights to publish to that profile.
     *
     * @param profileId The token ID of the profile of the profile to set the dispatcher for.
     * @param dispatcher The dispatcher address to set for the given profile ID.
     */
    function setDispatcher(uint256 profileId, address dispatcher) external;

    /**
     * @notice Sets a profile's dispatcher via signature with the specified parameters.
     *
     * @param vars A SetDispatcherWithSigData struct, including the regular parameters and an EIP712Signature struct.
     */
    function setDispatcherWithSig(DataTypes.SetDispatcherWithSigData calldata vars) external;

    /**
     * @notice Sets a profile's URI, which is reflected in the `tokenURI()` function.
     *
     * @param profileId The token ID of the profile of the profile to set the URI for.
     * @param imageURI The URI to set for the given profile.
     */
    function setProfileImageURI(uint256 profileId, string calldata imageURI) external;

    /**
     * @notice Sets a profile's URI via signature with the specified parameters.
     *
     * @param vars A SetProfileImageURIWithSigData struct, including the regular parameters and an EIP712Signature struct.
     */
    function setProfileImageURIWithSig(DataTypes.SetProfileImageURIWithSigData calldata vars)
        external;

    /**
     * @notice Sets a followNFT URI for a given profile's follow NFT.
     *
     * @param profileId The token ID of the profile for which to set the followNFT URI.
     * @param followNFTURI The follow NFT URI to set.
     */
    function setFollowNFTURI(uint256 profileId, string calldata followNFTURI) external;

    /**
     * @notice Sets a followNFT URI via signature with the specified parameters.
     *
     * @param vars A SetFollowNFTURIWithSigData struct, including the regular parameters and an EIP712Signature struct.
     */
    function setFollowNFTURIWithSig(DataTypes.SetFollowNFTURIWithSigData calldata vars) external;

    /**
     * @notice Publishes a post to a given profile, must be called by the profile owner.
     *
     * @param vars A PostData struct containing the needed parameters.
     */
    function post(DataTypes.PostData calldata vars) external;

    /**
     * @notice Publishes a post to a given profile via signature with the specified parameters.
     *
     * @param vars A PostWithSigData struct containing the regular parameters and an EIP712Signature struct.
     */
    function postWithSig(DataTypes.PostWithSigData calldata vars) external;

    /**
     * @notice Publishes a comment to a given profile, must be called by the profile owner.
     *
     * @param vars A CommentData struct containing the needed parameters.
     */
    function comment(DataTypes.CommentData calldata vars) external;

    /**
     * @notice Publishes a comment to a given profile via signature with the specified parameters.
     *
     *@param vars A CommentWithSigData struct containing the regular parameters and an EIP712Signature struct.
     *
     */
    function commentWithSig(DataTypes.CommentWithSigData calldata vars) external;

    /**
     * @notice Publishes a mirror to a given profile, must be called by the profile owner.
     *
     * @param vars A MirrorData struct containing the necessary parameters.
     */
    function mirror(DataTypes.MirrorData calldata vars) external;

    /**
     * @notice Publishes a mirror to a given profile via signature with the specified parameters.
     *
     * @param vars A MirrorWithSigData struct containing the regular parameters and an EIP712Signature struct.
     */
    function mirrorWithSig(DataTypes.MirrorWithSigData calldata vars) external;

    /**
     * @notice Follows the given profiles, executing each profile's follow module logic (if any) and minting followNFTs to the caller.
     *
     * NOTE: Both the `profileIds` and `datas` arrays must be of the same length, regardless if the profiles do not have a follow module set.
     *
     * @param profileIds The token ID array of the profiles to follow.
     * @param datas The arbitrary data array to pass to the follow module for each profile if needed.
     */
    function follow(uint256[] calldata profileIds, bytes[] calldata datas) external;

    /**
     * @notice Follows a given profile via signature with the specified parameters.
     *
     * @param vars A FollowWithSigData struct containing the regular parameters as well as the signing follower's address
     * and an EIP712Signature struct.
     */
    function followWithSig(DataTypes.FollowWithSigData calldata vars) external;

    /**
     * @notice Collects a given publication, executing collect module logic and minting a collectNFT to the caller.
     *
     * @param profileId The token ID of the profile that published the publication to collect.
     * @param pubId The publication to collect's publication ID.
     * @param data The arbitrary data to pass to the collect module if needed.
     */
    function collect(
        uint256 profileId,
        uint256 pubId,
        bytes calldata data
    ) external;

    /**
     * @notice Collects a given publication via signature with the specified parameters.
     *
     * @param vars A CollectWithSigData struct containing the regular parameters as well as the collector's address and
     * an EIP712Signature struct.
     */
    function collectWithSig(DataTypes.CollectWithSigData calldata vars) external;

    /**
     * @dev Helper function to emit a detailed followNFT transfer event from the hub, to be consumed by frontends to track
     * followNFT transfers.
     *
     * @param profileId The token ID of the profile associated with the followNFT being transferred.
     * @param followNFTId The followNFT being transferred's token ID.
     * @param from The address the followNFT is being transferred from.
     * @param to The address the followNFT is being transferred to.
     */
    function emitFollowNFTTransferEvent(
        uint256 profileId,
        uint256 followNFTId,
        address from,
        address to
    ) external;

    /**
     * @dev Helper function to emit a detailed collectNFT transfer event from the hub, to be consumed by frontends to track
     * collectNFT transfers.
     *
     * @param profileId The token ID of the profile associated with the collect NFT being transferred.
     * @param pubId The publication ID associated with the collect NFT being transferred.
     * @param collectNFTId The collectNFT being transferred's token ID.
     * @param from The address the collectNFT is being transferred from.
     * @param to The address the collectNFT is being transferred to.
     */
    function emitCollectNFTTransferEvent(
        uint256 profileId,
        uint256 pubId,
        uint256 collectNFTId,
        address from,
        address to
    ) external;

    /// ************************
    /// *****VIEW FUNCTIONS*****
    /// ************************

    /**
     * @notice Returns whether or not a profile creator is whitelisted.
     *
     * @param profileCreator The address of the profile creator to check.
     *
     * @return A boolean, true if the profile creator is whitelisted.
     */
    function isProfileCreatorWhitelisted(address profileCreator) external view returns (bool);

    /**
     * @notice Returns whether or not a follow module is whitelisted.
     *
     * @param followModule The address of the follow module to check.
     *
     * @return A boolean, true if the the follow module is whitelisted.
     */
    function isFollowModuleWhitelisted(address followModule) external view returns (bool);

    /**
     * @notice Returns whether or not a reference module is whitelisted.
     *
     * @param referenceModule The address of the reference module to check.
     *
     * @return A boolean, true if the the reference module is whitelisted.
     */
    function isReferenceModuleWhitelisted(address referenceModule) external view returns (bool);

    /**
     * @notice Returns whether or not a collect module is whitelisted.
     *
     * @param collectModule The address of the collect module to check.
     *
     * @return A boolean, true if the the collect module is whitelisted.
     */
    function isCollectModuleWhitelisted(address collectModule) external view returns (bool);

    /**
     * @notice Returns the currently configured governance address.
     *
     * @return The address of the currently configured governance.
     */
    function getGovernance() external view returns (address);

    /**
     * @notice Returns the dispatcher associated with a profile.
     *
     * @param profileId The token ID of the profile to query the dispatcher for.
     *
     * @return The dispatcher address associated with the profile.
     */
    function getDispatcher(uint256 profileId) external view returns (address);

    /**
     * @notice Returns the publication count for a given profile.
     *
     * @param profileId The token ID of the profile to query.
     *
     * @return The number of publications associated with the queried profile.
     */
    function getPubCount(uint256 profileId) external view returns (uint256);

    /**
     * @notice Returns the followNFT associated with a given profile, if any.
     *
     * @param profileId The token ID of the profile to query the followNFT for.
     *
     * @return The followNFT associated with the given profile.
     */
    function getFollowNFT(uint256 profileId) external view returns (address);

    /**
     * @notice Returns the followNFT URI associated with a given profile.
     *
     * @param profileId The token ID of the profile to query the followNFT URI for.
     *
     * @return The followNFT URI associated with the given profile.
     */
    function getFollowNFTURI(uint256 profileId) external view returns (string memory);

    /**
     * @notice Returns the collectNFT associated with a given publication, if any.
     *
     * @param profileId The token ID of the profile that published the publication to query.
     * @param pubId The publication ID of the publication to query.
     *
     * @return The address of the collectNFT associated with the queried publication.
     */
    function getCollectNFT(uint256 profileId, uint256 pubId) external view returns (address);

    /**
     * @notice Returns the follow module associated witha  given profile, if any.
     *
     * @param profileId The token ID of the profile to query the follow module for.
     *
     * @return The address of the follow module associated with the given profile.
     */
    function getFollowModule(uint256 profileId) external view returns (address);

    /**
     * @notice Returns the collect module associated with a given publication.
     *
     * @param profileId The token ID of the profile that published the publication to query.
     * @param pubId The publication ID of the publication to query.
     *
     * @return The address of the collect module associated with the queried publication.
     */
    function getCollectModule(uint256 profileId, uint256 pubId) external view returns (address);

    /**
     * @notice Returns the reference module associated witha  given profile, if any.
     *
     * @param profileId The token ID of the profile that published the publication to querythe reference module for.
     * @param pubId The publication ID of the publication to query the reference module for.
     *
     * @return The address of the reference module associated with the given profile.
     */
    function getReferenceModule(uint256 profileId, uint256 pubId) external view returns (address);

    /**
     * @notice Returns the handle associated with a profile.
     *
     * @param profileId The token ID of the profile to query the handle for.
     *
     * @return The handle associated with the profile.
     */
    function getHandle(uint256 profileId) external view returns (string memory);

    /**
     * @notice Returns the publication pointer (profileId & pubId) associated with a given publication.
     *
     * @param profileId The token ID of the profile that published the publication to query the pointer for.
     * @param pubId The publication ID of the publication to query the pointer for.
     *
     * @return
     *          First, the profile ID of the profile the current publication is pointing to.
     *          Second, the publication ID of the publication the current publication is pointing to.
     */
    function getPubPointer(uint256 profileId, uint256 pubId)
        external
        view
        returns (uint256, uint256);

    /**
     * @notice Returns the URI associated with a given publication.
     *
     * @param profileId The token ID of the profile that published the publication to query.
     * @param pubId The publication ID of the publication to query.
     *
     * @return The URI associated with a given publication.
     */
    function getContentURI(uint256 profileId, uint256 pubId) external view returns (string memory);

    /**
     * @notice Returns the profile token ID according to a given handle.
     *
     * @param handle The handle to resolve the profile token ID with.
     *
     * @return The profile ID the passed handle points to.
     */
    function getProfileIdByHandle(string calldata handle) external view returns (uint256);

    /**
     * @notice Returns the full profile struct associated with a given profile token ID.
     *
     * @param profileId The token ID of the profile to query.
     */
    function getProfile(uint256 profileId) external view returns (DataTypes.ProfileStruct memory);

    /**
     * @notice Returns the full publication struct for a given publication.
     *
     * @param profileId The token ID of the profile that published the publication to query.
     * @param pubId The publication ID of the publication to query.
     *
     * @return The PublicationStruct associated with the queried publication.
     */
    function getPub(uint256 profileId, uint256 pubId)
        external
        view
        returns (DataTypes.PublicationStruct memory);

    /**
     * @notice Returns the publication type associated with a given publication.
     *
     * @param profileId The token ID of the profile that published the publication to query.
     * @param pubId The publication ID of the publication to query.
     *
     * @return The publication type, as a member of an enum (either "post," "comment" or "mirror").
     */
    function getPubType(uint256 profileId, uint256 pubId) external view returns (DataTypes.PubType);
}

File 2 of 32 : Events.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {DataTypes} from './DataTypes.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,
        DataTypes.ProtocolState indexed prevState,
        DataTypes.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 follow module is added to or removed from the whitelist.
     *
     * @param followModule The address of the follow module.
     * @param whitelisted Whether or not the follow module is being added to the whitelist.
     * @param timestamp The current block timestamp.
     */
    event FollowModuleWhitelisted(
        address indexed followModule,
        bool indexed whitelisted,
        uint256 timestamp
    );

    /**
     * @dev Emitted when a reference module is added to or removed from the whitelist.
     *
     * @param referenceModule The address of the reference module.
     * @param whitelisted Whether or not the reference module is being added to the whitelist.
     * @param timestamp The current block timestamp.
     */
    event ReferenceModuleWhitelisted(
        address indexed referenceModule,
        bool indexed whitelisted,
        uint256 timestamp
    );

    /**
     * @dev Emitted when a collect module is added to or removed from the whitelist.
     *
     * @param collectModule The address of the collect module.
     * @param whitelisted Whether or not the collect module is being added to the whitelist.
     * @param timestamp The current block timestamp.
     */
    event CollectModuleWhitelisted(
        address indexed collectModule,
        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 handle The handle set for the profile.
     * @param imageURI The image uri set for the profile.
     * @param followModule The profile's newly set follow module. This CAN be the zero address.
     * @param followModuleReturnData The data returned from the follow module's initialization. This is abi encoded
     * and totally depends on the follow module chosen.
     * @param timestamp The current block timestamp.
     */
    event ProfileCreated(
        uint256 indexed profileId,
        address indexed creator,
        address indexed to,
        string handle,
        string imageURI,
        address followModule,
        bytes followModuleReturnData,
        string followNFTURI,
        uint256 timestamp
    );

    /**
     * @dev Emitted when a dispatcher is set for a specific profile.
     *
     * @param profileId The token ID of the profile for which the dispatcher is set.
     * @param dispatcher The dispatcher set for the given profile.
     * @param timestamp The current block timestamp.
     */
    event DispatcherSet(uint256 indexed profileId, address indexed dispatcher, uint256 timestamp);

    /**
     * @dev Emitted when a profile's URI is set.
     *
     * @param profileId The token ID of the profile for which the URI is set.
     * @param imageURI The URI set for the given profile.
     * @param timestamp The current block timestamp.
     */
    event ProfileImageURISet(uint256 indexed profileId, string imageURI, uint256 timestamp);

    /**
     * @dev Emitted when a follow NFT's URI is set.
     *
     * @param profileId The token ID of the profile for which the followNFT URI is set.
     * @param followNFTURI The follow NFT URI set.
     * @param timestamp The current block timestamp.
     */
    event FollowNFTURISet(uint256 indexed profileId, string followNFTURI, 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 followModuleReturnData The data returned from the follow module's initialization. This is abi encoded
     * and totally depends on the follow module chosen.
     * @param timestamp The current block timestamp.
     */
    event FollowModuleSet(
        uint256 indexed profileId,
        address followModule,
        bytes followModuleReturnData,
        uint256 timestamp
    );

    /**
     * @dev Emitted when a "post" is published.
     *
     * @param profileId The profile's token ID.
     * @param pubId The new publication's ID.
     * @param contentURI The URI mapped to this new publication.
     * @param collectModule The collect module mapped to this new publication. This CANNOT be the zero address.
     * @param collectModuleReturnData The data returned from the collect module's initialization for this given
     * publication. This is abi encoded and totally depends on the collect module chosen.
     * @param referenceModule The reference module set for this publication.
     * @param referenceModuleReturnData The data returned from the reference module at initialization. This is abi
     * encoded and totally depends on the reference module chosen.
     * @param timestamp The current block timestamp.
     */
    event PostCreated(
        uint256 indexed profileId,
        uint256 indexed pubId,
        string contentURI,
        address collectModule,
        bytes collectModuleReturnData,
        address referenceModule,
        bytes referenceModuleReturnData,
        uint256 timestamp
    );

    /**
     * @dev Emitted when a "comment" is published.
     *
     * @param profileId The profile's token ID.
     * @param pubId The new publication's ID.
     * @param contentURI The URI mapped to this new publication.
     * @param profileIdPointed The profile token ID that this comment points to.
     * @param pubIdPointed The publication ID that this comment points to.
     * @param collectModule The collect module mapped to this new publication. This CANNOT be the zero address.
     * @param collectModuleReturnData The data returned from the collect module's initialization for this given
     * publication. This is abi encoded and totally depends on the collect module chosen.
     * @param referenceModule The reference module set for this publication.
     * @param referenceModuleReturnData The data returned from the reference module at initialization. This is abi
     * encoded and totally depends on the reference module chosen.
     * @param timestamp The current block timestamp.
     */
    event CommentCreated(
        uint256 indexed profileId,
        uint256 indexed pubId,
        string contentURI,
        uint256 profileIdPointed,
        uint256 pubIdPointed,
        address collectModule,
        bytes collectModuleReturnData,
        address referenceModule,
        bytes referenceModuleReturnData,
        uint256 timestamp
    );

    /**
     * @dev Emitted when a "mirror" is published.
     *
     * @param profileId The profile's token ID.
     * @param pubId The new publication's ID.
     * @param profileIdPointed The profile token ID that this mirror points to.
     * @param pubIdPointed The publication ID that this mirror points to.
     * @param referenceModule The reference module set for this publication.
     * @param referenceModuleReturnData The data returned from the reference module at initialization. This is abi
     * encoded and totally depends on the reference module chosen.
     * @param timestamp The current block timestamp.
     */
    event MirrorCreated(
        uint256 indexed profileId,
        uint256 indexed pubId,
        uint256 profileIdPointed,
        uint256 pubIdPointed,
        address referenceModule,
        bytes referenceModuleReturnData,
        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 upon a successful follow action.
     *
     * @param follower The address following the profile.
     * @param profileIds The profile token ID array of the profiles being followed.
     * @param timestamp The current block timestamp.
     */
    event Followed(address indexed follower, uint256[] profileIds, 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 CollectNFTDeployed(
        uint256 indexed profileId,
        uint256 indexed pubId,
        address indexed collectNFT,
        uint256 timestamp
    );

    /**
     * @dev Emitted upon a successful collect action.
     *
     * @param collector The address collecting the publication.
     * @param profileId The token ID of the profile that the collect was initiated towards, useful to differentiate mirrors.
     * @param pubId The publication ID that the collect was initiated towards, useful to differentiate mirrors.
     * @param rootProfileId The profile token ID of the profile whose publication is being collected.
     * @param rootPubId The publication ID of the publication being collected.
     * @param timestamp The current block timestamp.
     */
    event Collected(
        address indexed collector,
        uint256 indexed profileId,
        uint256 indexed pubId,
        uint256 rootProfileId,
        uint256 rootPubId,
        uint256 timestamp
    );

    /**
     * @dev Emitted via callback when a followNFT is transferred.
     *
     * @param profileId The token ID of the profile associated with the followNFT being transferred.
     * @param followNFTId The followNFT being transferred's token ID.
     * @param from The address the followNFT is being transferred from.
     * @param to The address the followNFT is being transferred to.
     * @param timestamp The current block timestamp.
     */
    event FollowNFTTransferred(
        uint256 indexed profileId,
        uint256 indexed followNFTId,
        address from,
        address to,
        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
    );

    // Collect/Follow NFT-Specific

    /**
     * @dev Emitted when a newly deployed follow NFT is initialized.
     *
     * @param profileId The token ID of the profile connected to this follow NFT.
     * @param timestamp The current block timestamp.
     */
    event FollowNFTInitialized(uint256 indexed profileId, uint256 timestamp);

    /**
     * @dev Emitted when delegation power in a FollowNFT is changed.
     *
     * @param delegate The delegate whose power has been changed.
     * @param newPower The new governance power mapped to the delegate.
     * @param timestamp The current block timestamp.
     */
    event FollowNFTDelegatedPowerChanged(
        address indexed delegate,
        uint256 indexed newPower,
        uint256 timestamp
    );

    /**
     * @dev Emitted when a newly deployed collect NFT is initialized.
     *
     * @param profileId The token ID of the profile connected to the publication mapped to this collect NFT.
     * @param pubId The publication ID connected to the publication mapped to this collect NFT.
     * @param timestamp The current block timestamp.
     */
    event CollectNFTInitialized(
        uint256 indexed profileId,
        uint256 indexed pubId,
        uint256 timestamp
    );

    // Module-Specific

    /**
     * @notice Emitted when the ModuleGlobals governance address is set.
     *
     * @param prevGovernance The previous governance address.
     * @param newGovernance The new governance address set.
     * @param timestamp The current block timestamp.
     */
    event ModuleGlobalsGovernanceSet(
        address indexed prevGovernance,
        address indexed newGovernance,
        uint256 timestamp
    );

    /**
     * @notice Emitted when the ModuleGlobals treasury address is set.
     *
     * @param prevTreasury The previous treasury address.
     * @param newTreasury The new treasury address set.
     * @param timestamp The current block timestamp.
     */
    event ModuleGlobalsTreasurySet(
        address indexed prevTreasury,
        address indexed newTreasury,
        uint256 timestamp
    );

    /**
     * @notice Emitted when the ModuleGlobals 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 ModuleGlobalsTreasuryFeeSet(
        uint16 indexed prevTreasuryFee,
        uint16 indexed newTreasuryFee,
        uint256 timestamp
    );

    /**
     * @notice Emitted when a currency is added to or removed from the ModuleGlobals whitelist.
     *
     * @param currency The currency address.
     * @param prevWhitelisted Whether or not the currency was previously whitelisted.
     * @param whitelisted Whether or not the currency is whitelisted.
     * @param timestamp The current block timestamp.
     */
    event ModuleGlobalsCurrencyWhitelisted(
        address indexed currency,
        bool indexed prevWhitelisted,
        bool indexed whitelisted,
        uint256 timestamp
    );

    /**
     * @notice Emitted when a module inheriting from the `FeeModuleBase` is constructed.
     *
     * @param moduleGlobals The ModuleGlobals contract address used.
     * @param timestamp The current block timestamp.
     */
    event FeeModuleBaseConstructed(address indexed moduleGlobals, uint256 timestamp);

    /**
     * @notice Emitted when a module inheriting from the `ModuleBase` is constructed.
     *
     * @param hub The LensHub contract address used.
     * @param timestamp The current block timestamp.
     */
    event ModuleBaseConstructed(address indexed hub, uint256 timestamp);

    /**
     * @notice Emitted when one or multiple addresses are approved (or disapproved) for following in
     * the `ApprovalFollowModule`.
     *
     * @param owner The profile owner who executed the approval.
     * @param profileId The profile ID that the follow approvals are granted/revoked for.
     * @param addresses The addresses that have had the follow approvals grnated/revoked.
     * @param approved Whether each corresponding address is now approved or disapproved.
     * @param timestamp The current block timestamp.
     */
    event FollowsApproved(
        address indexed owner,
        uint256 indexed profileId,
        address[] addresses,
        bool[] approved,
        uint256 timestamp
    );
}

File 2 of 32 : Helpers.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {DataTypes} from './DataTypes.sol';
import {Errors} from './Errors.sol';

/**
 * @title Helpers
 * @author Lens Protocol
 *
 * @notice This is a library that only contains a single function that is used in the hub contract as well as in
 * both the publishing logic and interaction logic libraries.
 */
library Helpers {
    /**
     * @notice This helper function just returns the pointed publication if the passed publication is a mirror,
     * otherwise it returns the passed publication.
     *
     * @param profileId The token ID of the profile that published the given publication.
     * @param pubId The publication ID of the given publication.
     * @param _pubByIdByProfile A pointer to the storage mapping of publications by pubId by profile ID.
     *
     * @return The pointed publication identifier if the the given publication is a mirror, otherwise, the given publication.
     * This is a tuple of (profileId, pubId, collectModule)
     */
    function getPointedIfMirror(
        uint256 profileId,
        uint256 pubId,
        mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
            storage _pubByIdByProfile
    )
        internal
        view
        returns (
            uint256,
            uint256,
            address
        )
    {
        address collectModule = _pubByIdByProfile[profileId][pubId].collectModule;
        if (collectModule != address(0)) {
            return (profileId, pubId, collectModule);
        } else {
            uint256 pointedTokenId = _pubByIdByProfile[profileId][pubId].profileIdPointed;
            // We validate existence here as an optimization, so validating in calling contracts is unnecessary
            if (pointedTokenId == 0) revert Errors.PublicationDoesNotExist();

            uint256 pointedPubId = _pubByIdByProfile[profileId][pubId].pubIdPointed;

            address pointedCollectModule = _pubByIdByProfile[pointedTokenId][pointedPubId]
                .collectModule;

            return (pointedTokenId, pointedPubId, pointedCollectModule);
        }
    }
}

File 2 of 32 : DataTypes.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

/**
 * @title DataTypes
 * @author Lens Protocol
 *
 * @notice A standard library of data types used throughout the Lens Protocol.
 */
library DataTypes {
    /**
     * @notice An enum containing the different states the protocol can be in, limiting certain actions.
     *
     * @param Unpaused The fully unpaused state.
     * @param PublishingPaused The state where only publication creation functions are paused.
     * @param Paused The fully paused state.
     */
    enum ProtocolState {
        Unpaused,
        PublishingPaused,
        Paused
    }

    /**
     * @notice An enum specifically used in a helper function to easily retrieve the publication type for integrations.
     *
     * @param Post A standard post, having a URI, a collect module but no pointer to another publication.
     * @param Comment A comment, having a URI, a collect module and a pointer to another publication.
     * @param Mirror A mirror, having a pointer to another publication, but no URI or collect module.
     * @param Nonexistent An indicator showing the queried publication does not exist.
     */
    enum PubType {
        Post,
        Comment,
        Mirror,
        Nonexistent
    }

    /**
     * @notice A struct containing the necessary information to reconstruct an EIP-712 typed data signature.
     *
     * @param v The signature's recovery parameter.
     * @param r The signature's r parameter.
     * @param s The signature's s parameter
     * @param deadline The signature's deadline
     */
    struct EIP712Signature {
        uint8 v;
        bytes32 r;
        bytes32 s;
        uint256 deadline;
    }

    /**
     * @notice A struct containing profile data.
     *
     * @param pubCount The number of publications made to this profile.
     * @param followModule The address of the current follow module in use by this profile, can be empty.
     * @param followNFT The address of the followNFT associated with this profile, can be empty..
     * @param handle The profile's associated handle.
     * @param imageURI The URI to be used for the profile's image.
     * @param followNFTURI The URI to be used for the follow NFT.
     */
    struct ProfileStruct {
        uint256 pubCount;
        address followModule;
        address followNFT;
        string handle;
        string imageURI;
        string followNFTURI;
    }

    /**
     * @notice A struct containing data associated with each new publication.
     *
     * @param profileIdPointed The profile token ID this publication points to, for mirrors and comments.
     * @param pubIdPointed The publication ID this publication points to, for mirrors and comments.
     * @param contentURI The URI associated with this publication.
     * @param referenceModule The address of the current reference module in use by this profile, can be empty.
     * @param collectModule The address of the collect module associated with this publication, this exists for all publication.
     * @param collectNFT The address of the collectNFT associated with this publication, if any.
     */
    struct PublicationStruct {
        uint256 profileIdPointed;
        uint256 pubIdPointed;
        string contentURI;
        address referenceModule;
        address collectModule;
        address collectNFT;
    }

    /**
     * @notice A struct containing the parameters required for the `createProfile()` function.
     *
     * @param to The address receiving the profile.
     * @param handle The handle to set for the profile, must be unique and non-empty.
     * @param imageURI The URI to set for the profile image.
     * @param followModule The follow module to use, can be the zero address.
     * @param followModuleData The follow module initialization data, if any.
     * @param followNFTURI The URI to use for the follow NFT.
     */
    struct CreateProfileData {
        address to;
        string handle;
        string imageURI;
        address followModule;
        bytes followModuleData;
        string followNFTURI;
    }

    /**
     * @notice A struct containing the parameters required for the `setFollowModuleWithSig()` function. Parameters are
     * the same as the regular `setFollowModule()` function, with an added EIP712Signature.
     *
     * @param profileId The token ID of the profile to change the followModule for.
     * @param followModule The followModule to set for the given profile, must be whitelisted.
     * @param followModuleData The data to be passed to the followModule for initialization.
     * @param sig The EIP712Signature struct containing the profile owner's signature.
     */
    struct SetFollowModuleWithSigData {
        uint256 profileId;
        address followModule;
        bytes followModuleData;
        EIP712Signature sig;
    }

    /**
     * @notice A struct containing the parameters required for the `setDispatcherWithSig()` function. Parameters are the same
     * as the regular `setDispatcher()` function, with an added EIP712Signature.
     *
     * @param profileId The token ID of the profile to set the dispatcher for.
     * @param dispatcher The dispatcher address to set for the profile.
     * @param sig The EIP712Signature struct containing the profile owner's signature.
     */
    struct SetDispatcherWithSigData {
        uint256 profileId;
        address dispatcher;
        EIP712Signature sig;
    }

    /**
     * @notice A struct containing the parameters required for the `setProfileImageURIWithSig()` function. Parameters are the same
     * as the regular `setProfileImageURI()` function, with an added EIP712Signature.
     *
     * @param profileId The token ID of the profile to set the URI for.
     * @param imageURI The URI to set for the given profile image.
     * @param sig The EIP712Signature struct containing the profile owner's signature.
     */
    struct SetProfileImageURIWithSigData {
        uint256 profileId;
        string imageURI;
        EIP712Signature sig;
    }

    /**
     * @notice A struct containing the parameters required for the `setFollowNFTURIWithSig()` function. Parameters are the same
     * as the regular `setFollowNFTURI()` function, with an added EIP712Signature.
     *
     * @param profileId The token ID of the profile for which to set the followNFT URI.
     * @param followNFTURI The follow NFT URI to set.
     * @param sig The EIP712Signature struct containing the followNFT's associated profile owner's signature.
     */
    struct SetFollowNFTURIWithSigData {
        uint256 profileId;
        string followNFTURI;
        EIP712Signature sig;
    }

    /**
     * @notice A struct containing the parameters required for the `post()` function.
     *
     * @param profileId The token ID of the profile to publish to.
     * @param contentURI The URI to set for this new publication.
     * @param collectModule The collect module to set for this new publication.
     * @param collectModuleData The data to pass to the collect module's initialization.
     * @param referenceModule The reference module to set for the given publication, must be whitelisted.
     * @param referenceModuleData The data to be passed to the reference module for initialization.
     */
    struct PostData {
        uint256 profileId;
        string contentURI;
        address collectModule;
        bytes collectModuleData;
        address referenceModule;
        bytes referenceModuleData;
    }

    /**
     * @notice A struct containing the parameters required for the `postWithSig()` function. Parameters are the same as
     * the regular `post()` function, with an added EIP712Signature.
     *
     * @param profileId The token ID of the profile to publish to.
     * @param contentURI The URI to set for this new publication.
     * @param collectModule The collectModule to set for this new publication.
     * @param collectModuleData The data to pass to the collectModule's initialization.
     * @param referenceModule The reference module to set for the given publication, must be whitelisted.
     * @param referenceModuleData The data to be passed to the reference module for initialization.
     * @param sig The EIP712Signature struct containing the profile owner's signature.
     */
    struct PostWithSigData {
        uint256 profileId;
        string contentURI;
        address collectModule;
        bytes collectModuleData;
        address referenceModule;
        bytes referenceModuleData;
        EIP712Signature sig;
    }

    /**
     * @notice A struct containing the parameters required for the `comment()` function.
     *
     * @param profileId The token ID of the profile to publish to.
     * @param contentURI The URI to set for this new publication.
     * @param profileIdPointed The profile token ID to point the comment to.
     * @param pubIdPointed The publication ID to point the comment to.
     * @param collectModule The collect module to set for this new publication.
     * @param collectModuleData The data to pass to the collect module's initialization.
     * @param referenceModule The reference module to set for the given publication, must be whitelisted.
     * @param referenceModuleData The data to be passed to the reference module for initialization.
     */
    struct CommentData {
        uint256 profileId;
        string contentURI;
        uint256 profileIdPointed;
        uint256 pubIdPointed;
        address collectModule;
        bytes collectModuleData;
        address referenceModule;
        bytes referenceModuleData;
    }

    /**
     * @notice A struct containing the parameters required for the `commentWithSig()` function. Parameters are the same as
     * the regular `comment()` function, with an added EIP712Signature.
     *
     * @param profileId The token ID of the profile to publish to.
     * @param contentURI The URI to set for this new publication.
     * @param profileIdPointed The profile token ID to point the comment to.
     * @param pubIdPointed The publication ID to point the comment to.
     * @param collectModule The collectModule to set for this new publication.
     * @param collectModuleData The data to pass to the collectModule's initialization.
     * @param referenceModule The reference module to set for the given publication, must be whitelisted.
     * @param referenceModuleData The data to be passed to the reference module for initialization.
     * @param sig The EIP712Signature struct containing the profile owner's signature.
     */
    struct CommentWithSigData {
        uint256 profileId;
        string contentURI;
        uint256 profileIdPointed;
        uint256 pubIdPointed;
        address collectModule;
        bytes collectModuleData;
        address referenceModule;
        bytes referenceModuleData;
        EIP712Signature sig;
    }

    /**
     * @notice A struct containing the parameters required for the `mirror()` function.
     *
     * @param profileId The token ID of the profile to publish to.
     * @param profileIdPointed The profile token ID to point the mirror to.
     * @param pubIdPointed The publication ID to point the mirror to.
     * @param referenceModule The reference module to set for the given publication, must be whitelisted.
     * @param referenceModuleData The data to be passed to the reference module for initialization.
     */
    struct MirrorData {
        uint256 profileId;
        uint256 profileIdPointed;
        uint256 pubIdPointed;
        address referenceModule;
        bytes referenceModuleData;
    }

    /**
     * @notice A struct containing the parameters required for the `mirrorWithSig()` function. Parameters are the same as
     * the regular `mirror()` function, with an added EIP712Signature.
     *
     * @param profileId The token ID of the profile to publish to.
     * @param profileIdPointed The profile token ID to point the mirror to.
     * @param pubIdPointed The publication ID to point the mirror to.
     * @param referenceModule The reference module to set for the given publication, must be whitelisted.
     * @param referenceModuleData The data to be passed to the reference module for initialization.
     * @param sig The EIP712Signature struct containing the profile owner's signature.
     */
    struct MirrorWithSigData {
        uint256 profileId;
        uint256 profileIdPointed;
        uint256 pubIdPointed;
        address referenceModule;
        bytes referenceModuleData;
        EIP712Signature sig;
    }

    /**
     * @notice A struct containing the parameters required for the `followWithSig()` function. Parameters are the same
     * as the regular `follow()` function, with the follower's (signer) address and an EIP712Signature added.
     *
     * @param follower The follower which is the message signer.
     * @param profileIds The array of token IDs of the profiles to follow.
     * @param datas The array of arbitrary data to pass to the followModules if needed.
     * @param sig The EIP712Signature struct containing the follower's signature.
     */
    struct FollowWithSigData {
        address follower;
        uint256[] profileIds;
        bytes[] datas;
        EIP712Signature sig;
    }

    /**
     * @notice A struct containing the parameters required for the `collectWithSig()` function. Parameters are the same as
     * the regular `collect()` function, with the collector's (signer) address and an EIP712Signature added.
     *
     * @param collector The collector which is the message signer.
     * @param profileId The token ID of the profile that published the publication to collect.
     * @param pubId The publication to collect's publication ID.
     * @param data The arbitrary data to pass to the collectModule if needed.
     * @param sig The EIP712Signature struct containing the collector's signature.
     */
    struct CollectWithSigData {
        address collector;
        uint256 profileId;
        uint256 pubId;
        bytes data;
        EIP712Signature sig;
    }
}

File 2 of 32 : Errors.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

library Errors {
    error CannotInitImplementation();
    error Initialized();
    error SignatureExpired();
    error ZeroSpender();
    error SignatureInvalid();
    error NotOwnerOrApproved();
    error NotHub();
    error TokenDoesNotExist();
    error NotGovernance();
    error NotGovernanceOrEmergencyAdmin();
    error CallerNotWhitelistedModule();
    error CollectModuleNotWhitelisted();
    error FollowModuleNotWhitelisted();
    error ReferenceModuleNotWhitelisted();
    error ProfileCreatorNotWhitelisted();
    error NotProfileOwner();
    error NotProfileOwnerOrDispatcher();
    error PublicationDoesNotExist();
    error HandleTaken();
    error HandleLengthInvalid();
    error HandleContainsInvalidCharacters();
    error CallerNotFollowNFT();
    error CallerNotCollectNFT();
    error BlockNumberInvalid();
    error ArrayMismatch();

    // Module Errors
    error InitParamsInvalid();
    error ZeroCurrency();
    error CollectExpired();
    error FollowInvalid();
    error ModuleDataMismatch();
    error FollowNotApproved();
    error MintLimitExceeded();
    error CollectNotAllowed();

    // MultiState Errors
    error Paused();
    error PublishingPaused();
}

File 2 of 32 : PublishingLogic.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {Helpers} from './Helpers.sol';
import {DataTypes} from './DataTypes.sol';
import {Errors} from './Errors.sol';
import {Events} from './Events.sol';
import {Constants} from './Constants.sol';
import {IFollowModule} from '../interfaces/IFollowModule.sol';
import {ICollectModule} from '../interfaces/ICollectModule.sol';
import {IReferenceModule} from '../interfaces/IReferenceModule.sol';

/**
 * @title PublishingLogic
 * @author Lens Protocol
 *
 * @notice This is the library that contains the logic for profile creation & publication.
 *
 * @dev The functions are external, so they are called from the hub via `delegateCall` under the hood. Furthermore,
 * expected events are emitted from this library instead of from the hub to alleviate code size concerns.
 */
library PublishingLogic {
    /**
     * @notice Executes the logic to create a profile with the given parameters to the given address.
     *
     * @param vars The CreateProfileData struct containing the following parameters:
     *      to: The address receiving the profile.
     *      handle: The handle to set for the profile, must be unique and non-empty.
     *      imageURI: The URI to set for the profile image.
     *      followModule: The follow module to use, can be the zero address.
     *      followModuleData: The follow module initialization data, if any
     *      followNFTURI: The URI to set for the follow NFT.
     * @param profileId The profile ID to associate with this profile NFT (token ID).
     * @param _profileIdByHandleHash The storage reference to the mapping of profile IDs by handle hash.
     * @param _profileById The storage reference to the mapping of profile structs by IDs.
     * @param _followModuleWhitelisted The storage reference to the mapping of whitelist status by follow module address.
     */
    function createProfile(
        DataTypes.CreateProfileData calldata vars,
        uint256 profileId,
        mapping(bytes32 => uint256) storage _profileIdByHandleHash,
        mapping(uint256 => DataTypes.ProfileStruct) storage _profileById,
        mapping(address => bool) storage _followModuleWhitelisted
    ) external {
        _validateHandle(vars.handle);

        bytes32 handleHash = keccak256(bytes(vars.handle));

        if (_profileIdByHandleHash[handleHash] != 0) revert Errors.HandleTaken();
        _profileIdByHandleHash[handleHash] = profileId;

        _profileById[profileId].handle = vars.handle;
        _profileById[profileId].imageURI = vars.imageURI;
        _profileById[profileId].followNFTURI = vars.followNFTURI;

        if (vars.followModule != address(0)) {
            _profileById[profileId].followModule = vars.followModule;
        }

        bytes memory followModuleReturnData = _initFollowModule(
            profileId,
            vars.followModule,
            vars.followModuleData,
            _followModuleWhitelisted
        );

        _emitProfileCreated(profileId, vars, followModuleReturnData);
    }

    /**
     * @notice Sets the follow module for a given profile.
     *
     * @param profileId The profile ID to set the follow module for.
     * @param followModule The follow module to set for the given profile, if any.
     * @param followModuleData The data to pass to the follow module for profile initialization.
     * @param _profile The storage reference to the profile struct associated with the given profile ID.
     * @param _followModuleWhitelisted The storage reference to the mapping of whitelist status by follow module address.
     */
    function setFollowModule(
        uint256 profileId,
        address followModule,
        bytes calldata followModuleData,
        DataTypes.ProfileStruct storage _profile,
        mapping(address => bool) storage _followModuleWhitelisted
    ) external {
        address prevFollowModule = _profile.followModule;
        if (followModule != prevFollowModule) {
            _profile.followModule = followModule;
        }

        bytes memory followModuleReturnData = _initFollowModule(
            profileId,
            followModule,
            followModuleData,
            _followModuleWhitelisted
        );
        emit Events.FollowModuleSet(
            profileId,
            followModule,
            followModuleReturnData,
            block.timestamp
        );
    }

    /**
     * @notice Creates a post publication mapped to the given profile.
     *
     * @dev To avoid a stack too deep error, reference parameters are passed in memory rather than calldata.
     *
     * @param profileId The profile ID to associate this publication to.
     * @param contentURI The URI to set for this publication.
     * @param collectModule The collect module to set for this publication.
     * @param collectModuleData The data to pass to the collect module for publication initialization.
     * @param referenceModule The reference module to set for this publication, if any.
     * @param referenceModuleData The data to pass to the reference module for publication initialization.
     * @param pubId The publication ID to associate with this publication.
     * @param _pubByIdByProfile The storage reference to the mapping of publications by publication ID by profile ID.
     * @param _collectModuleWhitelisted The storage reference to the mapping of whitelist status by collect module address.
     * @param _referenceModuleWhitelisted The storage reference to the mapping of whitelist status by reference module address.
     */
    function createPost(
        uint256 profileId,
        string memory contentURI,
        address collectModule,
        bytes memory collectModuleData,
        address referenceModule,
        bytes memory referenceModuleData,
        uint256 pubId,
        mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
            storage _pubByIdByProfile,
        mapping(address => bool) storage _collectModuleWhitelisted,
        mapping(address => bool) storage _referenceModuleWhitelisted
    ) external {
        _pubByIdByProfile[profileId][pubId].contentURI = contentURI;

        // Collect module initialization
        bytes memory collectModuleReturnData = _initPubCollectModule(
            profileId,
            pubId,
            collectModule,
            collectModuleData,
            _pubByIdByProfile,
            _collectModuleWhitelisted
        );

        // Reference module initialization
        bytes memory referenceModuleReturnData = _initPubReferenceModule(
            profileId,
            pubId,
            referenceModule,
            referenceModuleData,
            _pubByIdByProfile,
            _referenceModuleWhitelisted
        );

        emit Events.PostCreated(
            profileId,
            pubId,
            contentURI,
            collectModule,
            collectModuleReturnData,
            referenceModule,
            referenceModuleReturnData,
            block.timestamp
        );
    }

    /**
     * @notice Creates a comment publication mapped to the given profile.
     *
     * @dev This function is unique in that it requires many variables, so, unlike the other publishing functions,
     * we need to pass the full CommentData struct in memory to avoid a stack too deep error.
     *
     * @param vars The CommentData struct to use to create the comment.
     * @param pubId The publication ID to associate with this publication.
     * @param _profileById The storage reference to the mapping of profile structs by IDs.
     * @param _pubByIdByProfile The storage reference to the mapping of publications by publication ID by profile ID.
     * @param _collectModuleWhitelisted The storage reference to the mapping of whitelist status by collect module address.
     * @param _referenceModuleWhitelisted The storage reference to the mapping of whitelist status by reference module address.
     */
    function createComment(
        DataTypes.CommentData memory vars,
        uint256 pubId,
        mapping(uint256 => DataTypes.ProfileStruct) storage _profileById,
        mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
            storage _pubByIdByProfile,
        mapping(address => bool) storage _collectModuleWhitelisted,
        mapping(address => bool) storage _referenceModuleWhitelisted
    ) external {
        // Validate existence of the pointed publication
        uint256 pubCount = _profileById[vars.profileIdPointed].pubCount;
        if (pubCount < vars.pubIdPointed || vars.pubIdPointed == 0)
            revert Errors.PublicationDoesNotExist();

        _pubByIdByProfile[vars.profileId][pubId].contentURI = vars.contentURI;
        _pubByIdByProfile[vars.profileId][pubId].profileIdPointed = vars.profileIdPointed;
        _pubByIdByProfile[vars.profileId][pubId].pubIdPointed = vars.pubIdPointed;

        // Collect Module Initialization
        bytes memory collectModuleReturnData = _initPubCollectModule(
            vars.profileId,
            pubId,
            vars.collectModule,
            vars.collectModuleData,
            _pubByIdByProfile,
            _collectModuleWhitelisted
        );

        // Reference module initialization
        bytes memory referenceModuleReturnData = _initPubReferenceModule(
            vars.profileId,
            pubId,
            vars.referenceModule,
            vars.referenceModuleData,
            _pubByIdByProfile,
            _referenceModuleWhitelisted
        );

        // Reference module validation
        address refModule = _pubByIdByProfile[vars.profileIdPointed][vars.pubIdPointed]
            .referenceModule;
        if (refModule != address(0)) {
            IReferenceModule(refModule).processComment(
                vars.profileId,
                vars.profileIdPointed,
                vars.pubIdPointed
            );
        }

        // Prevents a stack too deep error
        _emitCommentCreated(vars, pubId, collectModuleReturnData, referenceModuleReturnData);
    }

    /**
     * @notice Creates a mirror publication mapped to the given profile.
     *
     * @param profileId The profile ID to associate this publication to.
     * @param profileIdPointed The profile ID of the pointed publication's publisher.
     * @param pubIdPointed The pointed publication's publication ID.
     * @param referenceModule The reference module to set for this publication, if any.
     * @param referenceModuleData The data to pass to the reference module for publication initialization.
     * @param pubId The publication ID to associate with this publication.
     * @param _pubByIdByProfile The storage reference to the mapping of publications by publication ID by profile ID.
     * @param _referenceModuleWhitelisted The storage reference to the mapping of whitelist status by reference module address.
     */
    function createMirror(
        uint256 profileId,
        uint256 profileIdPointed,
        uint256 pubIdPointed,
        address referenceModule,
        bytes calldata referenceModuleData,
        uint256 pubId,
        mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
            storage _pubByIdByProfile,
        mapping(address => bool) storage _referenceModuleWhitelisted
    ) external {
        (uint256 rootProfileIdPointed, uint256 rootPubIdPointed, ) = Helpers.getPointedIfMirror(
            profileIdPointed,
            pubIdPointed,
            _pubByIdByProfile
        );

        _pubByIdByProfile[profileId][pubId].profileIdPointed = rootProfileIdPointed;
        _pubByIdByProfile[profileId][pubId].pubIdPointed = rootPubIdPointed;

        // Reference module initialization
        bytes memory referenceModuleReturnData = _initPubReferenceModule(
            profileId,
            pubId,
            referenceModule,
            referenceModuleData,
            _pubByIdByProfile,
            _referenceModuleWhitelisted
        );

        // Reference module validation
        address refModule = _pubByIdByProfile[rootProfileIdPointed][rootPubIdPointed]
            .referenceModule;
        if (refModule != address(0)) {
            IReferenceModule(refModule).processMirror(
                profileId,
                rootProfileIdPointed,
                rootPubIdPointed
            );
        }

        emit Events.MirrorCreated(
            profileId,
            pubId,
            rootProfileIdPointed,
            rootPubIdPointed,
            referenceModule,
            referenceModuleReturnData,
            block.timestamp
        );
    }

    function _initPubCollectModule(
        uint256 profileId,
        uint256 pubId,
        address collectModule,
        bytes memory collectModuleData,
        mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
            storage _pubByIdByProfile,
        mapping(address => bool) storage _collectModuleWhitelisted
    ) private returns (bytes memory) {
        if (!_collectModuleWhitelisted[collectModule]) revert Errors.CollectModuleNotWhitelisted();
        _pubByIdByProfile[profileId][pubId].collectModule = collectModule;
        return
            ICollectModule(collectModule).initializePublicationCollectModule(
                profileId,
                pubId,
                collectModuleData
            );
    }

    function _initPubReferenceModule(
        uint256 profileId,
        uint256 pubId,
        address referenceModule,
        bytes memory referenceModuleData,
        mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
            storage _pubByIdByProfile,
        mapping(address => bool) storage _referenceModuleWhitelisted
    ) private returns (bytes memory) {
        if (referenceModule != address(0)) {
            if (!_referenceModuleWhitelisted[referenceModule])
                revert Errors.ReferenceModuleNotWhitelisted();
            _pubByIdByProfile[profileId][pubId].referenceModule = referenceModule;
            return
                IReferenceModule(referenceModule).initializeReferenceModule(
                    profileId,
                    pubId,
                    referenceModuleData
                );
        } else {
            return new bytes(0);
        }
    }

    function _initFollowModule(
        uint256 profileId,
        address followModule,
        bytes memory followModuleData,
        mapping(address => bool) storage _followModuleWhitelisted
    ) private returns (bytes memory) {
        if (followModule != address(0)) {
            if (!_followModuleWhitelisted[followModule]) revert Errors.FollowModuleNotWhitelisted();
            bytes memory returnData = IFollowModule(followModule).initializeFollowModule(
                profileId,
                followModuleData
            );
            return returnData;
        } else {
            return new bytes(0);
        }
    }

    function _emitCommentCreated(
        DataTypes.CommentData memory vars,
        uint256 pubId,
        bytes memory collectModuleReturnData,
        bytes memory referenceModuleReturnData
    ) private {
        emit Events.CommentCreated(
            vars.profileId,
            pubId,
            vars.contentURI,
            vars.profileIdPointed,
            vars.pubIdPointed,
            vars.collectModule,
            collectModuleReturnData,
            vars.referenceModule,
            referenceModuleReturnData,
            block.timestamp
        );
    }

    function _emitProfileCreated(
        uint256 profileId,
        DataTypes.CreateProfileData calldata vars,
        bytes memory followModuleReturnData
    ) internal {
        emit Events.ProfileCreated(
            profileId,
            msg.sender, // Creator is always the msg sender
            vars.to,
            vars.handle,
            vars.imageURI,
            vars.followModule,
            followModuleReturnData,
            vars.followNFTURI,
            block.timestamp
        );
    }

    function _validateHandle(string calldata handle) private pure {
        bytes memory byteHandle = bytes(handle);
        if (byteHandle.length == 0 || byteHandle.length > Constants.MAX_HANDLE_LENGTH)
            revert Errors.HandleLengthInvalid();

        for (uint256 i = 0; i < byteHandle.length; i++) {
            if (
                (byteHandle[i] < '0' ||
                    byteHandle[i] > 'z' ||
                    (byteHandle[i] > '9' && byteHandle[i] < 'a')) && byteHandle[i] != '.'
            ) revert Errors.HandleContainsInvalidCharacters();
        }
    }
}

File 2 of 32 : InteractionLogic.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {Helpers} from './Helpers.sol';
import {DataTypes} from './DataTypes.sol';
import {Errors} from './Errors.sol';
import {Events} from './Events.sol';
import {Constants} from './Constants.sol';
import {IFollowNFT} from '../interfaces/IFollowNFT.sol';
import {ICollectNFT} from '../interfaces/ICollectNFT.sol';
import {IFollowModule} from '../interfaces/IFollowModule.sol';
import {ICollectModule} from '../interfaces/ICollectModule.sol';
import {Clones} from '@openzeppelin/contracts/proxy/Clones.sol';
import {Strings} from '@openzeppelin/contracts/utils/Strings.sol';

/**
 * @title InteractionLogic
 * @author Lens Protocol
 *
 * @notice This is the library that contains the logic for follows & collects. 
 
 * @dev The functions are external, so they are called from the hub via `delegateCall` under the hood.
 */
library InteractionLogic {
    using Strings for uint256;

    /**
     * @notice Follows the given profiles, executing the necessary logic and module calls before minting the follow
     * NFT(s) to the follower.
     *
     * @param follower The address executing the follow.
     * @param profileIds The array of profile token IDs to follow.
     * @param followModuleDatas The array of follow module data parameters to pass to each profile's follow module.
     * @param followNFTImpl The address of the follow NFT implementation, which has to be passed because it's an immutable in the hub.
     * @param _profileById A pointer to the storage mapping of profile structs by profile ID.
     */
    function follow(
        address follower,
        uint256[] calldata profileIds,
        bytes[] calldata followModuleDatas,
        address followNFTImpl,
        mapping(uint256 => DataTypes.ProfileStruct) storage _profileById,
        mapping(bytes32 => uint256) storage _profileIdByHandleHash
    ) external {
        if (profileIds.length != followModuleDatas.length) revert Errors.ArrayMismatch();
        for (uint256 i = 0; i < profileIds.length; i++) {
            string memory handle = _profileById[profileIds[i]].handle;
            if (_profileIdByHandleHash[keccak256(bytes(handle))] == 0) revert Errors.TokenDoesNotExist();

            address followModule = _profileById[profileIds[i]].followModule;

            address followNFT = _profileById[profileIds[i]].followNFT;

            if (followNFT == address(0)) {
                followNFT = Clones.clone(followNFTImpl);
                _profileById[profileIds[i]].followNFT = followNFT;

                bytes4 firstBytes = bytes4(bytes(handle));

                string memory followNFTName = string(
                    abi.encodePacked(handle, Constants.FOLLOW_NFT_NAME_SUFFIX)
                );
                string memory followNFTSymbol = string(
                    abi.encodePacked(firstBytes, Constants.FOLLOW_NFT_SYMBOL_SUFFIX)
                );

                IFollowNFT(followNFT).initialize(profileIds[i], followNFTName, followNFTSymbol);
                emit Events.FollowNFTDeployed(profileIds[i], followNFT, block.timestamp);
            }

            IFollowNFT(followNFT).mint(follower);

            if (followModule != address(0)) {
                IFollowModule(followModule).processFollow(
                    follower,
                    profileIds[i],
                    followModuleDatas[i]
                );
            }
        }
        emit Events.Followed(follower, profileIds, block.timestamp);
    }

    /**
     * @notice Collects the given publication, executing the necessary logic and module call before minting the
     * collect NFT to the collector.
     *
     * @param collector The address executing the collect.
     * @param profileId The token ID of the publication being collected's parent profile.
     * @param pubId The publication ID of the publication being collected.
     * @param collectModuleData The data to pass to the publication's collect module.
     * @param collectNFTImpl The address of the collect NFT implementation, which has to be passed because it's an immutable in the hub.
     * @param _pubByIdByProfile A pointer to the storage mapping of publications by pubId by profile ID.
     * @param _profileById A pointer to the storage mapping of profile structs by profile ID.
     */
    function collect(
        address collector,
        uint256 profileId,
        uint256 pubId,
        bytes calldata collectModuleData,
        address collectNFTImpl,
        mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))
            storage _pubByIdByProfile,
        mapping(uint256 => DataTypes.ProfileStruct) storage _profileById
    ) external {
        (uint256 rootProfileId, uint256 rootPubId, address rootCollectModule) = Helpers
            .getPointedIfMirror(profileId, pubId, _pubByIdByProfile);

        address collectNFT = _pubByIdByProfile[rootProfileId][rootPubId].collectNFT;

        if (collectNFT == address(0)) {
            collectNFT = Clones.clone(collectNFTImpl);
            _pubByIdByProfile[rootProfileId][rootPubId].collectNFT = collectNFT;

            string memory handle = _profileById[rootProfileId].handle;
            bytes4 firstBytes = bytes4(bytes(handle));

            string memory collectNFTName = string(
                abi.encodePacked(handle, Constants.COLLECT_NFT_NAME_INFIX, rootPubId.toString())
            );
            string memory collectNFTSymbol = string(
                abi.encodePacked(
                    firstBytes,
                    Constants.COLLECT_NFT_SYMBOL_INFIX,
                    rootPubId.toString()
                )
            );

            ICollectNFT(collectNFT).initialize(
                rootProfileId,
                rootPubId,
                collectNFTName,
                collectNFTSymbol
            );
            emit Events.CollectNFTDeployed(rootProfileId, rootPubId, collectNFT, block.timestamp);
        }

        ICollectNFT(collectNFT).mint(collector);

        ICollectModule(rootCollectModule).processCollect(
            profileId,
            collector,
            rootProfileId,
            rootPubId,
            collectModuleData
        );
        emit Events.Collected(
            collector,
            profileId,
            pubId,
            rootProfileId,
            rootPubId,
            block.timestamp
        );
    }
}

File 2 of 32 : LensNFTBase.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {ILensNFTBase} from '../../interfaces/ILensNFTBase.sol';
import {Errors} from '../../libraries/Errors.sol';
import {DataTypes} from '../../libraries/DataTypes.sol';
import {Events} from '../../libraries/Events.sol';
import {ERC721Time} from './ERC721Time.sol';
import {ERC721Enumerable} from './ERC721Enumerable.sol';

abstract contract LensNFTBase is ILensNFTBase, ERC721Enumerable {
    bytes32 internal constant EIP712_REVISION_HASH =
        0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6;
    // keccak256('1');
    bytes32 internal constant PERMIT_TYPEHASH =
        0x49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad;
    // keccak256('Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline)');
    bytes32 internal constant PERMIT_FOR_ALL_TYPEHASH =
        0x47ab88482c90e4bb94b82a947ae78fa91fb25de1469ab491f4c15b9a0a2677ee;
    // keccak256(
    // 'PermitForAll(address owner,address operator,bool approved,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant BURN_WITH_SIG_TYPEHASH =
        0x108ccda6d7331b00561a3eea66a2ae331622356585681c62731e4a01aae2261a;
    // keccak256('BurnWithSig(uint256 tokenId,uint256 nonce,uint256 deadline)');
    bytes32 internal constant EIP712_DOMAIN_TYPEHASH =
        0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
    // keccak256(
    // 'EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'
    // )

    mapping(address => uint256) public sigNonces;

    /**
     * @notice Initializer sets the name, symbol and the cached domain separator.
     *
     * NOTE: Inheritor contracts *must* call this function to initialize the name & symbol in the
     * inherited ERC721 contract.
     *
     * @param name The name to set in the ERC721 contract.
     * @param symbol The symbol to set in the ERC721 contract.
     */
    function _initialize(string calldata name, string calldata symbol) internal {
        ERC721Time.__ERC721_Init(name, symbol);

        emit Events.BaseInitialized(name, symbol, block.timestamp);
    }

    /// @inheritdoc ILensNFTBase
    function permit(
        address spender,
        uint256 tokenId,
        DataTypes.EIP712Signature calldata sig
    ) external override {
        if (spender == address(0)) revert Errors.ZeroSpender();
        address owner = ownerOf(tokenId);

        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            PERMIT_TYPEHASH,
                            spender,
                            tokenId,
                            sigNonces[owner]++,
                            sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, sig);
        _approve(spender, tokenId);
    }

    /// @inheritdoc ILensNFTBase
    function permitForAll(
        address owner,
        address operator,
        bool approved,
        DataTypes.EIP712Signature calldata sig
    ) external override {
        if (operator == address(0)) revert Errors.ZeroSpender();

        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            PERMIT_FOR_ALL_TYPEHASH,
                            owner,
                            operator,
                            approved,
                            sigNonces[owner]++,
                            sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, sig);
        _setOperatorApproval(owner, operator, approved);
    }

    /// @inheritdoc ILensNFTBase
    function getDomainSeparator() external view override returns (bytes32) {
        return _calculateDomainSeparator();
    }

    /// @inheritdoc ILensNFTBase
    function burn(uint256 tokenId) public virtual override {
        if (!_isApprovedOrOwner(msg.sender, tokenId)) revert Errors.NotOwnerOrApproved();
        _burn(tokenId);
    }

    /// @inheritdoc ILensNFTBase
    function burnWithSig(uint256 tokenId, DataTypes.EIP712Signature calldata sig)
        public
        virtual
        override
    {
        address owner = ownerOf(tokenId);

        bytes32 digest;
        unchecked {
            digest = keccak256(
                abi.encodePacked(
                    '\x19\x01',
                    _calculateDomainSeparator(),
                    keccak256(
                        abi.encode(
                            BURN_WITH_SIG_TYPEHASH,
                            tokenId,
                            sigNonces[owner]++,
                            sig.deadline
                        )
                    )
                )
            );
        }

        _validateRecoveredAddress(digest, owner, sig);
        _burn(tokenId);
    }

    /**
     * @dev Wrapper for ecrecover to reduce code size, used in meta-tx specific functions.
     */
    function _validateRecoveredAddress(
        bytes32 digest,
        address expectedAddress,
        DataTypes.EIP712Signature memory sig
    ) internal view {
        if (sig.deadline < block.timestamp) revert Errors.SignatureExpired();
        address recoveredAddress = ecrecover(digest, sig.v, sig.r, sig.s);
        if (recoveredAddress == address(0) || recoveredAddress != expectedAddress)
            revert Errors.SignatureInvalid();
    }

    /**
     * @dev Calculates EIP712 DOMAIN_SEPARATOR based on the current contract and chain ID.
     */
    function _calculateDomainSeparator() internal view returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    EIP712_DOMAIN_TYPEHASH,
                    keccak256(bytes(name())),
                    EIP712_REVISION_HASH,
                    block.chainid,
                    address(this)
                )
            );
    }
}

File 2 of 32 : LensMultiState.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.10;

import {Events} from '../../libraries/Events.sol';
import {DataTypes} from '../../libraries/DataTypes.sol';
import {Errors} from '../../libraries/Errors.sol';

/**
 * @title LensMultiState
 *
 * @notice This is an abstract contract that implements internal LensHub state setting and
 * validation.
 */
abstract contract LensMultiState {
    DataTypes.ProtocolState private _state;

    modifier whenNotPaused() {
        _validateNotPaused();
        _;
    }

    modifier whenPublishingEnabled() {
        _validatePublishingEnabled();
        _;
    }

    /**
     * @dev Returns the current protocol state.
     */
    function getState() external view returns (DataTypes.ProtocolState) {
        return _state;
    }

    function _setState(DataTypes.ProtocolState newState) internal {
        DataTypes.ProtocolState prevState = _state;
        _state = newState;
        emit Events.StateSet(msg.sender, prevState, newState, block.timestamp);
    }

    function _validatePublishingEnabled() internal view {
        if (_state == DataTypes.ProtocolState.Paused) {
            revert Errors.Paused();
        } else if (_state == DataTypes.ProtocolState.PublishingPaused) {
            revert Errors.PublishingPaused();
        }
    }

    function _validateNotPaused() internal view {
        if (_state == DataTypes.ProtocolState.Paused) revert Errors.Paused();
    }
}

File 2 of 32 : LensHubStorage.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {DataTypes} from '../../libraries/DataTypes.sol';

contract LensHubStorage {
    bytes32 internal constant CREATE_PROFILE_WITH_SIG_TYPEHASH =
        0x9ac3269d9abd6f8c5e850e07f21b199079e8a5cc4a55466d8c96ab0c4a5be403;
    // keccak256(
    // 'CreateProfileWithSig(string handle,string uri,address followModule,bytes followModuleData,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant SET_FOLLOW_MODULE_WITH_SIG_TYPEHASH =
        0x6f3f6455a608af1cc57ef3e5c0a49deeb88bba264ec8865b798ff07358859d4b;
    // keccak256(
    // 'SetFollowModuleWithSig(uint256 profileId,address followModule,bytes followModuleData,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant SET_FOLLOW_NFT_URI_WITH_SIG_TYPEHASH =
        0xd8d76e8b2b26e1ebe72def13fb559a68561ef064055b0de01f955bc26e25d42f;
    // keccak256(
    // 'SetFollowNFTURIWithSig(uint256 profileId,string followNFTURI,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant SET_DISPATCHER_WITH_SIG_TYPEHASH =
        0x77ba3e9f5fa75343bbad1241fb539a0064de97694b47d463d1eb5c54aba11f0f;
    // keccak256(
    // 'SetDispatcherWithSig(uint256 profileId,address dispatcher,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant SET_PROFILE_IMAGE_URI_WITH_SIG_TYPEHASH =
        0x5b9860bd835e648945b22d053515bc1f53b7d9fab4b23b1b49db15722e945d14;
    // keccak256(
    // 'SetProfileImageURIWithSig(uint256 profileId,string imageURI,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant POST_WITH_SIG_TYPEHASH =
        0xfb8f057542e7551386ead0b891a45f102af78c47f8cc58b4a919c7cfeccd0e1e;
    // keccak256(
    // 'PostWithSig(uint256 profileId,string contentURI,address collectModule,bytes collectModuleData,address referenceModule,bytes referenceModuleData,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant COMMENT_WITH_SIG_TYPEHASH =
        0xb30910150df56294e05b2d03e181803697a2b935abb1b9bdddde9310f618fe9b;
    // keccak256(
    // 'CommentWithSig(uint256 profileId,string contentURI,uint256 profileIdPointed,uint256 pubIdPointed,address collectModule,bytes collectModuleData,address referenceModule,bytes referenceModuleData,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant MIRROR_WITH_SIG_TYPEHASH =
        0x64f4578fc098f96a2450fbe601cb8c5318ebeb2ff72d2031a36be1ff6932d5ee;
    // keccak256(
    // 'MirrorWithSig(uint256 profileId,uint256 profileIdPointed,uint256 pubIdPointed,address referenceModule,bytes referenceModuleData,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant FOLLOW_WITH_SIG_TYPEHASH =
        0xfb6b7f1cd1b38daf3822aff0abbe78124db5d62a4748bcff007c15ccd6d30bc5;
    // keccak256(
    // 'FollowWithSig(uint256[] profileIds,bytes[] datas,uint256 nonce,uint256 deadline)'
    // );
    bytes32 internal constant COLLECT_WITH_SIG_TYPEHASH =
        0x7f9b4ea1fc678b4fda1611ac5cbd28f339e235d89b1540635e9b2e0223a3c101;
    // keccak256(
    // 'CollectWithSig(uint256 profileId,uint256 pubId,bytes data,uint256 nonce,uint256 deadline)'
    // );

    mapping(address => bool) internal _profileCreatorWhitelisted;
    mapping(address => bool) internal _followModuleWhitelisted;
    mapping(address => bool) internal _collectModuleWhitelisted;
    mapping(address => bool) internal _referenceModuleWhitelisted;

    mapping(uint256 => address) internal _dispatcherByProfile;
    mapping(bytes32 => uint256) internal _profileIdByHandleHash;
    mapping(uint256 => DataTypes.ProfileStruct) internal _profileById;
    mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct)) internal _pubByIdByProfile;

    uint256 internal _profileCounter;
    address internal _governance;
    address internal _emergencyAdmin;
}

File 2 of 32 : VersionedInitializable.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.10;

import {Errors} from '../libraries/Errors.sol';

/**
 * @title VersionedInitializable
 *
 * @dev Helper contract to implement initializer functions. To use it, replace
 * the constructor with a function that has the `initializer` modifier.
 * WARNING: Unlike constructors, initializer functions must be manually
 * invoked. This applies both to deploying an Initializable contract, as well
 * as extending an Initializable contract via inheritance.
 * WARNING: When used with inheritance, manual care must be taken to not invoke
 * a parent initializer twice, or ensure that all initializers are idempotent,
 * because this is not dealt with automatically as with constructors.
 *
 * This is slightly modified from [Aave's version.](https://github.com/aave/protocol-v2/blob/6a503eb0a897124d8b9d126c915ffdf3e88343a9/contracts/protocol/libraries/aave-upgradeability/VersionedInitializable.sol)
 *
 * @author Lens Protocol, inspired by Aave's implementation, which is in turn inspired by OpenZeppelin's
 * Initializable contract
 */
abstract contract VersionedInitializable {
    address private immutable originalImpl;

    /**
     * @dev Indicates that the contract has been initialized.
     */
    uint256 private lastInitializedRevision = 0;

    /**
     * @dev Modifier to use in the initializer function of a contract.
     */
    modifier initializer() {
        uint256 revision = getRevision();
        if (address(this) == originalImpl) revert Errors.CannotInitImplementation();
        if (revision <= lastInitializedRevision) revert Errors.Initialized();
        lastInitializedRevision = revision;
        _;
    }

    constructor() {
        originalImpl = address(this);
    }

    /**
     * @dev returns the revision number of the contract
     * Needs to be defined in the inherited class as a constant.
     **/
    function getRevision() internal pure virtual returns (uint256);
}

File 2 of 32 : Constants.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

library Constants {
    string internal constant FOLLOW_NFT_NAME_SUFFIX = '-Follower';
    string internal constant FOLLOW_NFT_SYMBOL_SUFFIX = '-Fl';
    string internal constant COLLECT_NFT_NAME_INFIX = '-Collect-';
    string internal constant COLLECT_NFT_SYMBOL_INFIX = '-Cl-';
    uint8 internal constant MAX_HANDLE_LENGTH = 31;
}

File 2 of 32 : IFollowModule.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

/**
 * @title IFollowModule
 * @author Lens Protocol
 *
 * @notice This is the standard interface for all Lens-compatible FollowModules.
 */
interface IFollowModule {
    /**
     * @notice Initializes a follow module for a given Lens profile. This can only be called by the hub contract.
     *
     * @param profileId The token ID of the profile to initialize this follow module for.
     * @param data Arbitrary data passed by the profile creator.
     */
    function initializeFollowModule(uint256 profileId, bytes calldata data)
        external
        returns (bytes memory);

    /**
     * @notice Processes a given follow, this can only be called from the LensHub contract.
     *
     * @param follower The follower address.
     * @param profileId The token ID of the profile being followed.
     * @param data Arbitrary data passed by the follower.
     */
    function processFollow(
        address follower,
        uint256 profileId,
        bytes calldata data
    ) external;

    /**
     * @notice This is a transfer hook that is called upon follow NFT transfer in `beforeTokenTransfer. This can
     * only be called from the LensHub contract.
     *
     * NOTE: Special care needs to be taken here: It is possible that follow NFTs were issued before this module
     * was initialized if the profile's follow module was previously different. This transfer hook should take this
     * into consideration, especially when the module holds state associated with individual follow NFTs.
     *
     * @param profileId The token ID of the profile associated with the follow NFT being transferred.
     * @param from The address sending the follow NFT.
     * @param to The address receiving the follow NFT.
     * @param followNFTTokenId The token ID of the follow NFT being transferred.
     */
    function followModuleTransferHook(
        uint256 profileId,
        address from,
        address to,
        uint256 followNFTTokenId
    ) external;

    /**
     * @notice This is a helper function that could be used in conjunction with specific collect modules.
     *
     * NOTE: This function IS meant to replace a check on follower NFT ownership.
     *
     * NOTE: It is assumed that not all collect modules are aware of the token ID to pass. In these cases,
     * this should receive a `followNFTTokenId` of 0, which is impossible regardless.
     *
     * One example of a use case for this would be a subscription-based following system:
     *      1. The collect module:
     *          - Decodes a follower NFT token ID from user-passed data.
     *          - Fetches the follow module from the hub.
     *          - Calls `validateFollow` passing the profile ID, follower & follower token ID.
     *      2. The follow module:
     *          - Validates the subscription status for that given NFT, reverting on an invalid subscription.
     *
     * @param profileId The token ID of the profile to validate the follow for.
     * @param follower The follower address to validate the follow for.
     * @param followNFTTokenId The followNFT token ID to validate the follow for.
     */
    function validateFollow(
        uint256 profileId,
        address follower,
        uint256 followNFTTokenId
    ) external view;
}

File 2 of 32 : ICollectModule.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

/**
 * @title ICollectModule
 * @author Lens Protocol
 *
 * @notice This is the standard interface for all Lens-compatible CollectModules.
 */
interface ICollectModule {
    /**
     * @notice Initializes data for a given publication being published. This can only be called by the hub.
     *
     * @param profileId The token ID of the profile publishing the publication.
     * @param pubId The associated publication's LensHub publication ID.
     * @param data Arbitrary data __passed from the user!__ to be decoded.
     *
     * @return An abi encoded byte array encapsulating the execution's state changes. This will be emitted by the
     * hub alongside the collect module's address and should be consumed by front ends.
     */
    function initializePublicationCollectModule(
        uint256 profileId,
        uint256 pubId,
        bytes calldata data
    ) external returns (bytes memory);

    /**
     * @notice Processes a collect action for a given publication, this can only be called by the hub.
     *
     * @param referrerProfileId The LensHub profile token ID of the referrer's profile (only different in case of mirrors).
     * @param collector The collector address.
     * @param profileId The token ID of the profile associated with the publication being collected.
     * @param pubId The LensHub publication ID associated with the publication being collected.
     * @param data Arbitrary data __passed from the collector!__ to be decoded.
     */
    function processCollect(
        uint256 referrerProfileId,
        address collector,
        uint256 profileId,
        uint256 pubId,
        bytes calldata data
    ) external;
}

File 2 of 32 : IReferenceModule.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

/**
 * @title IReferenceModule
 * @author Lens Protocol
 *
 * @notice This is the standard interface for all Lens-compatible ReferenceModules.
 */
interface IReferenceModule {
    /**
     * @notice Initializes data for a given publication being published. This can only be called by the hub.
     * @param profileId The token ID of the profile publishing the publication.
     * @param pubId The associated publication's LensHub publication ID.
     * @param data Arbitrary data passed from the user to be decoded.
     *
     * @return An abi encoded byte array encapsulating the execution's state changes. This will be emitted by the
     * hub alongside the collect module's address and should be consumed by front ends.
     */
    function initializeReferenceModule(
        uint256 profileId,
        uint256 pubId,
        bytes calldata data
    ) external returns (bytes memory);

    /**
     * @notice Processes a comment action referencing a given publication. This can only be called by the hub.
     *
     * @param profileId The token ID of the profile associated with the publication being published.
     * @param profileIdPointed The profile ID of the profile associated the publication being referenced.
     * @param pubIdPointed The publication ID of the publication being referenced.
     */
    function processComment(
        uint256 profileId,
        uint256 profileIdPointed,
        uint256 pubIdPointed
    ) external;

    /**
     * @notice Processes a mirror action referencing a given publication. This can only be called by the hub.
     *
     * @param profileId The token ID of the profile associated with the publication being published.
     * @param profileIdPointed The profile ID of the profile associated the publication being referenced.
     * @param pubIdPointed The publication ID of the publication being referenced.
     */
    function processMirror(
        uint256 profileId,
        uint256 profileIdPointed,
        uint256 pubIdPointed
    ) external;
}

File 2 of 32 : IFollowNFT.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {DataTypes} from '../libraries/DataTypes.sol';

/**
 * @title IFollowNFT
 * @author Lens Protocol
 *
 * @notice This is the interface for the FollowNFT contract, which is cloned upon the first follow for any profile.
 */
interface IFollowNFT {
    /**
     * @notice Initializes the follow NFT, setting the feed as the privileged minter, initializing the name and
     * symbol in the LensNFTBase contract.
     *
     * @param profileId The token ID of the profile in the hub associated with this followNFT, used for transfer hooks.
     * @param name The name to set for this NFT.
     * @param symbol The symbol to set for this NFT.
     */
    function initialize(
        uint256 profileId,
        string calldata name,
        string calldata symbol
    ) external;

    /**
     * @notice Mints a follow NFT to the specified address. This can only be called by the hub, and is called
     * upon follow.
     *
     * @param to The address to mint the NFT to.
     */
    function mint(address to) external;

    /**
     * @notice Delegates the caller's governance power to the given delegatee address.
     *
     * @param delegatee The delegatee address to delegate governance power to.
     */
    function delegate(address delegatee) external;

    /**
     * @notice Delegates the delegator's governance power via meta-tx to the given delegatee address.
     *
     * @param delegator The delegator address, who is the signer.
     * @param delegatee The delegatee address, who is receiving the governance power delegation.
     * @param sig The EIP712Signature struct containing the necessary parameters to recover the delegator's signature.
     */
    function delegateBySig(
        address delegator,
        address delegatee,
        DataTypes.EIP712Signature calldata sig
    ) external;

    /**
     * @notice Returns the governance power for a given user at a specified block number.
     *
     * @param user The user to query governance power for.
     * @param blockNumber The block number to query the user's governance power at.
     */
    function getPowerByBlockNumber(address user, uint256 blockNumber) external returns (uint256);

    /**
     * @notice Returns the total delegated supply at a specified block number. This is the sum of all
     * current available voting power at a given block.
     *
     * @param blockNumber The block number to query the delegated supply at.
     */
    function getDelegatedSupplyByBlockNumber(uint256 blockNumber) external returns (uint256);

}

File 2 of 32 : ICollectNFT.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

/**
 * @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.
     *
     * @param profileId The token ID of the profile in the hub that this collectNFT points to.
     * @param pubId The profile publication ID in the hub that this collectNFT points to.
     * @param name The name to set for this NFT.
     * @param symbol The symbol to set for this NFT.
     */
    function initialize(
        uint256 profileId,
        uint256 pubId,
        string calldata name,
        string calldata symbol
    ) external;

    /**
     * @notice Mints a collect NFT to the specified address. This can only be called by the hub, and is called
     * upon collection.
     *
     * @param to The address to mint the NFT to.
     */
    function mint(address to) external;

    /**
     * @notice Returns the source publication pointer mapped to this collect NFT.
     *
     * @return First the profile ID uint256, and second the pubId uint256.
     */
    function getSourcePublicationPointer() external view returns (uint256, uint256);
}

File 2 of 32 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 2 of 32 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 2 of 32 : ILensNFTBase.sol
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity 0.8.10;

import {DataTypes} from '../libraries/DataTypes.sol';

/**
 * @title ILensNFTBase
 * @author Lens Protocol
 *
 * @notice This is the interface for the LensNFTBase contract, from which all Lens NFTs inherit.
 * It is an expansion of a very slightly modified ERC721Enumerable contract, which allows expanded
 * meta-transaction functionality.
 */
interface ILensNFTBase {
    /**
     * @notice Implementation of an EIP-712 permit function for an ERC-721 NFT. We don't need to check
     * if the tokenId exists, since the function calls ownerOf(tokenId), which reverts if the tokenId does
     * not exist.
     *
     * @param spender The NFT spender.
     * @param tokenId The NFT token ID to approve.
     * @param sig The EIP712 signature struct.
     */
    function permit(
        address spender,
        uint256 tokenId,
        DataTypes.EIP712Signature calldata sig
    ) external;

    /**
     * @notice Implementation of an EIP-712 permit-style function for ERC-721 operator approvals. Allows
     * an operator address to control all NFTs a given owner owns.
     *
     * @param owner The owner to set operator approvals for.
     * @param operator The operator to approve.
     * @param approved Whether to approve or revoke approval from the operator.
     * @param sig The EIP712 signature struct.
     */
    function permitForAll(
        address owner,
        address operator,
        bool approved,
        DataTypes.EIP712Signature calldata sig
    ) external;

    /**
     * @notice Burns an NFT, removing it from circulation and essentially destroying it. This function can only
     * be called by the NFT to burn's owner.
     *
     * @param tokenId The token ID of the token to burn.
     */
    function burn(uint256 tokenId) external;

    /**
     * @notice Implementation of an EIP-712 permit-style function for token burning. Allows anyone to burn
     * a token on behalf of the owner with a signature.
     *
     * @param tokenId The token ID of the token to burn.
     * @param sig The EIP712 signature struct.
     */
    function burnWithSig(uint256 tokenId, DataTypes.EIP712Signature calldata sig) external;

    /**
     * @notice Returns the domain separator for this NFT contract.
     *
     * @return The domain separator.
     */
    function getDomainSeparator() external view returns (bytes32);
}

File 2 of 32 : ERC721Time.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
import './IERC721Time.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 ERC721Time is Context, ERC165, IERC721Time, IERC721Metadata {
    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 => IERC721Time.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;

    /**
     * @dev Initializes the ERC721 name and symbol.
     *
     * @param name The name to set.
     * @param symbol The symbol to set.
     */
    function __ERC721_Init(string calldata name, string calldata symbol) internal {
        _name = name;
        _symbol = symbol;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(ERC165, IERC165)
        returns (bool)
    {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), 'ERC721: balance query for the zero address');
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _tokenData[tokenId].owner;
        require(owner != address(0), 'ERC721: owner query for nonexistent token');
        return owner;
    }

    /**
     * @dev See {IERC721Time-mintTimestampOf}
     */
    function mintTimestampOf(uint256 tokenId) public view virtual override returns (uint256) {
        uint96 mintTimestamp = _tokenData[tokenId].mintTimestamp;
        require(mintTimestamp != 0, 'ERC721: mint timestamp query for nonexistent token');
        return mintTimestamp;
    }

    /**
     * @dev See {IERC721Time-mintTimestampOf}
     */
    function tokenDataOf(uint256 tokenId)
        public
        view
        virtual
        override
        returns (IERC721Time.TokenData memory)
    {
        require(_exists(tokenId), 'ERC721: token data query for nonexistent token');
        return _tokenData[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;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');

        string memory baseURI = _baseURI();
        return
            bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return '';
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721Time.ownerOf(tokenId);
        require(to != owner, 'ERC721: approval to current owner');

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            'ERC721: approve caller is not owner nor approved for all'
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), 'ERC721: approved query for nonexistent token');

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), 'ERC721: approve to caller');

        _setOperatorApproval(_msgSender(), 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
        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            'ERC721: transfer caller is not owner nor approved'
        );

        _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 {
        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            'ERC721: transfer caller is not owner nor approved'
        );
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @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 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);
        require(
            _checkOnERC721Received(from, to, tokenId, _data),
            'ERC721: transfer to non ERC721Receiver implementer'
        );
    }

    /**
     * @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)
    {
        require(_exists(tokenId), 'ERC721: operator query for nonexistent token');
        address owner = ERC721Time.ownerOf(tokenId);
        return (spender == owner ||
            getApproved(tokenId) == spender ||
            isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, '');
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            'ERC721: transfer to non ERC721Receiver implementer'
        );
    }

    /**
     * @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 {
        require(to != address(0), 'ERC721: mint to the zero address');
        require(!_exists(tokenId), 'ERC721: token already minted');

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _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 = ERC721Time.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        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 {
        require(ERC721Time.ownerOf(tokenId) == from, 'ERC721: transfer of token that is not own');
        require(to != address(0), 'ERC721: transfer to the zero address');

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _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(ERC721Time.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 Internal 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(_msgSender(), from, tokenId, _data) returns (
                bytes4 retval
            ) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert('ERC721: transfer to non ERC721Receiver implementer');
                } 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 {}
}

File 2 of 32 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import './ERC721Time.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 *
 * NOTE: Modified from Openzeppelin to inherit from a modified ERC721 contract.
 */
abstract contract ERC721Enumerable is ERC721Time, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(IERC165, ERC721Time)
        returns (bool)
    {
        return
            interfaceId == type(IERC721Enumerable).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index)
        public
        view
        virtual
        override
        returns (uint256)
    {
        require(index < ERC721Time.balanceOf(owner), 'ERC721Enumerable: owner index out of bounds');
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(
            index < ERC721Enumerable.totalSupply(),
            'ERC721Enumerable: global index out of bounds'
        );
        return _allTokens[index];
    }

    /**
     * @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` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * 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 override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721Time.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721Time.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 2 of 32 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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 `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 2 of 32 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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);
}

File 2 of 32 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 2 of 32 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 2 of 32 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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;
    }
}

File 2 of 32 : IERC721Time.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';

/**
 * @title IERC721Time
 * @author Lens Protocol
 *
 * @notice This is an expansion of the IERC721 interface that includes a struct for token data,
 * which contains the token owner and the mint timestamp as well as associated getters.
 */
interface IERC721Time is IERC721 {
    /**
     * @notice 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 unchanging mintTimestamp.
     *
     * @param owner The token owner.
     * @param mintTimestamp The mint timestamp.
     */
    struct TokenData {
        address owner;
        uint96 mintTimestamp;
    }

    /**
     * @notice Returns the mint timestamp associated with a given NFT, stored only once upon initial mint.
     *
     * @param tokenId The token ID of the NFT to query the mint timestamp for.
     *
     * @return The 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 The token data struct containing both the owner address and the mint timestamp.
     */
    function tokenDataOf(uint256 tokenId) external view returns (TokenData memory);
}

File 2 of 32 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @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 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);

    /**
     * @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;
}

File 2 of 32 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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);
}

File 2 of 32 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200,
    "details": {
      "yul": true
    }
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {
    "contracts/libraries/InteractionLogic.sol": {
      "InteractionLogic": "0x28ce33b49ec8836aa6f0199cf764b82b9bedb5ea"
    },
    "contracts/libraries/PublishingLogic.sol": {
      "PublishingLogic": "0xbfe82126b2f18918842dbe03d5d81a7b35b69821"
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"followNFTImpl","type":"address"},{"internalType":"address","name":"collectNFTImpl","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CallerNotCollectNFT","type":"error"},{"inputs":[],"name":"CallerNotFollowNFT","type":"error"},{"inputs":[],"name":"CannotInitImplementation","type":"error"},{"inputs":[],"name":"Initialized","type":"error"},{"inputs":[],"name":"NotGovernance","type":"error"},{"inputs":[],"name":"NotGovernanceOrEmergencyAdmin","type":"error"},{"inputs":[],"name":"NotOwnerOrApproved","type":"error"},{"inputs":[],"name":"NotProfileOwner","type":"error"},{"inputs":[],"name":"NotProfileOwnerOrDispatcher","type":"error"},{"inputs":[],"name":"Paused","type":"error"},{"inputs":[],"name":"ProfileCreatorNotWhitelisted","type":"error"},{"inputs":[],"name":"PublicationDoesNotExist","type":"error"},{"inputs":[],"name":"PublishingPaused","type":"error"},{"inputs":[],"name":"SignatureExpired","type":"error"},{"inputs":[],"name":"SignatureInvalid","type":"error"},{"inputs":[],"name":"ZeroSpender","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":[{"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"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"name":"burnWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"collect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"collector","type":"address"},{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.CollectWithSigData","name":"vars","type":"tuple"}],"name":"collectWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bytes","name":"collectModuleData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"}],"internalType":"struct DataTypes.CommentData","name":"vars","type":"tuple"}],"name":"comment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bytes","name":"collectModuleData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.CommentWithSigData","name":"vars","type":"tuple"}],"name":"commentWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"string","name":"handle","type":"string"},{"internalType":"string","name":"imageURI","type":"string"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bytes","name":"followModuleData","type":"bytes"},{"internalType":"string","name":"followNFTURI","type":"string"}],"internalType":"struct DataTypes.CreateProfileData","name":"vars","type":"tuple"}],"name":"createProfile","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"},{"internalType":"uint256","name":"collectNFTId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"emitCollectNFTTransferEvent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"followNFTId","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"emitFollowNFTTransferEvent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"profileIds","type":"uint256[]"},{"internalType":"bytes[]","name":"datas","type":"bytes[]"}],"name":"follow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"follower","type":"address"},{"internalType":"uint256[]","name":"profileIds","type":"uint256[]"},{"internalType":"bytes[]","name":"datas","type":"bytes[]"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.FollowWithSigData","name":"vars","type":"tuple"}],"name":"followWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getCollectModule","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getCollectNFT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getContentURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getDispatcher","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDomainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getFollowModule","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getFollowNFT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getFollowNFTURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGovernance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getHandle","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getProfile","outputs":[{"components":[{"internalType":"uint256","name":"pubCount","type":"uint256"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"address","name":"followNFT","type":"address"},{"internalType":"string","name":"handle","type":"string"},{"internalType":"string","name":"imageURI","type":"string"},{"internalType":"string","name":"followNFTURI","type":"string"}],"internalType":"struct DataTypes.ProfileStruct","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"handle","type":"string"}],"name":"getProfileIdByHandle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getPub","outputs":[{"components":[{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"address","name":"collectNFT","type":"address"}],"internalType":"struct DataTypes.PublicationStruct","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"}],"name":"getPubCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getPubPointer","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":"getPubType","outputs":[{"internalType":"enum DataTypes.PubType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"pubId","type":"uint256"}],"name":"getReferenceModule","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getState","outputs":[{"internalType":"enum DataTypes.ProtocolState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"newGovernance","type":"address"}],"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":"collectModule","type":"address"}],"name":"isCollectModuleWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"followModule","type":"address"}],"name":"isFollowModuleWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"profileCreator","type":"address"}],"name":"isProfileCreatorWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"referenceModule","type":"address"}],"name":"isReferenceModuleWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"mintTimestampOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"}],"internalType":"struct DataTypes.MirrorData","name":"vars","type":"tuple"}],"name":"mirror","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"uint256","name":"profileIdPointed","type":"uint256"},{"internalType":"uint256","name":"pubIdPointed","type":"uint256"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.MirrorWithSigData","name":"vars","type":"tuple"}],"name":"mirrorWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"name":"permitForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bytes","name":"collectModuleData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"}],"internalType":"struct DataTypes.PostData","name":"vars","type":"tuple"}],"name":"post","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"contentURI","type":"string"},{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bytes","name":"collectModuleData","type":"bytes"},{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bytes","name":"referenceModuleData","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.PostWithSigData","name":"vars","type":"tuple"}],"name":"postWithSig","outputs":[],"stateMutability":"nonpayable","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":"profileId","type":"uint256"},{"internalType":"address","name":"dispatcher","type":"address"}],"name":"setDispatcher","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"address","name":"dispatcher","type":"address"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetDispatcherWithSigData","name":"vars","type":"tuple"}],"name":"setDispatcherWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newEmergencyAdmin","type":"address"}],"name":"setEmergencyAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bytes","name":"followModuleData","type":"bytes"}],"name":"setFollowModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bytes","name":"followModuleData","type":"bytes"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetFollowModuleWithSigData","name":"vars","type":"tuple"}],"name":"setFollowModuleWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"followNFTURI","type":"string"}],"name":"setFollowNFTURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"followNFTURI","type":"string"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetFollowNFTURIWithSigData","name":"vars","type":"tuple"}],"name":"setFollowNFTURIWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGovernance","type":"address"}],"name":"setGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"imageURI","type":"string"}],"name":"setProfileImageURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"profileId","type":"uint256"},{"internalType":"string","name":"imageURI","type":"string"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct DataTypes.EIP712Signature","name":"sig","type":"tuple"}],"internalType":"struct DataTypes.SetProfileImageURIWithSigData","name":"vars","type":"tuple"}],"name":"setProfileImageURIWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum DataTypes.ProtocolState","name":"newState","type":"uint8"}],"name":"setState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"sigNonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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 IERC721Time.TokenData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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"},{"inputs":[{"internalType":"address","name":"collectModule","type":"address"},{"internalType":"bool","name":"whitelist","type":"bool"}],"name":"whitelistCollectModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"followModule","type":"address"},{"internalType":"bool","name":"whitelist","type":"bool"}],"name":"whitelistFollowModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"profileCreator","type":"address"},{"internalType":"bool","name":"whitelist","type":"bool"}],"name":"whitelistProfileCreator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"referenceModule","type":"address"},{"internalType":"bool","name":"whitelist","type":"bool"}],"name":"whitelistReferenceModule","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60e06040526000600b553480156200001657600080fd5b5060405162005d4d38038062005d4d833981016040819052620000399162000072565b306080526001600160a01b0391821660a0521660c052620000aa565b80516001600160a01b03811681146200006d57600080fd5b919050565b600080604083850312156200008657600080fd5b620000918362000055565b9150620000a16020840162000055565b90509250929050565b60805160a05160c051615c65620000e860003960008181611c2701526126dd01526000818161207f01526133e001526000610cb40152615c656000f3fe608060405234801561001057600080fd5b506004361061043e5760003560e01c806386e2947b11610236578063b88d4fde1161013b578063d923d20c116100c3578063ed24911d11610087578063ed24911d14610b2f578063f08f4f6414610b37578063f990ccd714610b57578063fb78ae6c14610b77578063ffea138e14610b8a57600080fd5b8063d923d20c14610a8e578063dd69cdb114610aba578063e985e9c514610acd578063ec81d19414610b09578063ecfab8fa14610b1c57600080fd5b8063bfd24f471161010a578063bfd24f47146109f5578063c0da9bcd14610a08578063c6b5d06c14610a48578063c736c99014610a5b578063c87b56dd14610a7b57600080fd5b8063b88d4fde146109a9578063bd12d3f0146109bc578063bdfdd4bc146109cf578063bfbf0b4b146109e257600080fd5b8063a2c79772116101be578063ad3e72bf1161018d578063ad3e72bf146108f4578063af05dd2214610920578063b48951e41461094c578063b5a314961461095f578063b7984c051461097257600080fd5b8063a2c797721461088f578063a6d8e1e4146108a2578063a9ec6563146108b5578063ab033ea9146108e157600080fd5b80638f14b45f116102055780638f14b45f1461083b57806395d89b411461084e578063963ff141146108565780639b84a14c14610869578063a22cb4651461087c57600080fd5b806386e2947b146107d657806389028a13146107e95780638e204fb4146107fc5780638e4fd6a91461082857600080fd5b80633a15ff0711610347578063540528b9116102cf5780636a4e66d2116102935780636a4e66d2146107775780636dea40b31461078a57806370a082311461079d5780637ef67f99146107b057806384114ad4146107c357600080fd5b8063540528b9146106c957806356de96db146106f257806357ff49f6146107055780635ca3eebf1461073c5780636352211e1461076457600080fd5b806342842e0e1161031657806342842e0e1461064657806342966c68146106595780634f6ccce71461066c57806350ddf35c1461067f57806352aaef551461069257600080fd5b80633a15ff07146105ed5780633b28b89f1461060d5780633b508132146106205780634187e4c51461063357600080fd5b806320905506116103ca5780632f745c59116103995780632f745c591461058157806331dcebe31461059457806331fff07c146105a757806335da3394146105c7578063374c9473146105da57600080fd5b8063209055061461053757806320fa728a1461054a57806323b872dd1461055d578063289b3c0d1461057057600080fd5b8063081812fc11610411578063081812fc146104a8578063095ea7b3146104d357806318160ddd146104e65780631865c57d146104f85780631cbb26201461050b57600080fd5b806301ffc9a714610443578063054871b81461046b57806306fdde0314610480578063077f224a14610495575b600080fd5b610456610451366004614870565b610b9d565b60405190151581526020015b60405180910390f35b61047e6104793660046148d5565b610bc8565b005b610488610c1e565b604051610462919061496d565b61047e6104a336600461499c565b610cb0565b6104bb6104b6366004614a1c565b610d4a565b6040516001600160a01b039091168152602001610462565b61047e6104e1366004614a35565b610de4565b6008545b604051908152602001610462565b600c5460ff166040516104629190614a75565b610456610519366004614a8f565b6001600160a01b03166000908152600e602052604090205460ff1690565b61047e610545366004614aba565b610ef5565b6104ea610558366004614aed565b610f60565b61047e61056b366004614b2e565b610f92565b6016546001600160a01b03166104bb565b6104ea61058f366004614a35565b610fc3565b61047e6105a2366004614aba565b611059565b6105ba6105b5366004614b6a565b6110bc565b6040516104629190614b8c565b61047e6105d5366004614a8f565b611145565b6104886105e8366004614a1c565b6111b2565b6104ea6105fb366004614a1c565b60009081526013602052604090205490565b61047e61061b366004614bb8565b611257565b61047e61062e366004614bec565b611438565b61047e610641366004614aba565b6116c4565b61047e610654366004614b2e565b611727565b61047e610667366004614a1c565b611742565b6104ea61067a366004614a1c565b61175f565b6104ea61068d366004614a1c565b6117f2565b6104bb6106a0366004614b6a565b60009182526014602090815260408084209284529190529020600501546001600160a01b031690565b6104bb6106d7366004614a1c565b6000908152601160205260409020546001600160a01b031690565b61047e610700366004614c27565b611888565b6104bb610713366004614b6a565b60009182526014602090815260408084209284529190529020600401546001600160a01b031690565b61074f61074a366004614b6a565b6118d5565b60408051928352602083019190915201610462565b6104bb610772366004614a1c565b6118fe565b61047e610785366004614c48565b611975565b61047e610798366004614c82565b6119b8565b6104ea6107ab366004614a8f565b611a4f565b61047e6107be366004614ced565b611ad6565b61047e6107d1366004614d2a565b611be6565b61047e6107e4366004614d64565b611c55565b61047e6107f7366004614da8565b611cf3565b61045661080a366004614a8f565b6001600160a01b031660009081526010602052604090205460ff1690565b61047e610836366004614bb8565b611e03565b61047e610849366004614dfd565b6120c5565b610488612241565b61047e610864366004614e4a565b612250565b61047e610877366004614e4a565b612318565b61047e61088a366004614aba565b612472565b61047e61089d366004614e91565b6124da565b61047e6108b0366004614aba565b6124fd565b6104bb6108c3366004614a1c565b6000908152601360205260409020600201546001600160a01b031690565b61047e6108ef366004614a8f565b612560565b610456610902366004614a8f565b6001600160a01b03166000908152600f602052604090205460ff1690565b61045661092e366004614a8f565b6001600160a01b03166000908152600d602052604090205460ff1690565b61047e61095a366004614e91565b612571565b61048861096d366004614b6a565b61274f565b6104bb610980366004614b6a565b60009182526014602090815260408084209284529190529020600301546001600160a01b031690565b61047e6109b7366004614f90565b612817565b61047e6109ca366004614e4a565b61284f565b61047e6109dd366004614ff7565b6129a9565b61047e6109f0366004615032565b612a38565b61047e610a0336600461504e565b612b4e565b610a1b610a16366004614a1c565b612b69565b6040805182516001600160a01b031681526020928301516001600160601b03169281019290925201610462565b61047e610a563660046148d5565b612c37565b610a6e610a69366004614b6a565b612c88565b6040516104629190615071565b610488610a89366004614a1c565b612de7565b6104bb610a9c366004614a1c565b6000908152601360205260409020600101546001600160a01b031690565b61047e610ac83660046150db565b612e07565b610456610adb3660046150ff565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610488610b17366004614a1c565b612e22565b61047e610b2a366004615129565b612e42565b6104ea61313c565b610b4a610b45366004614a1c565b61314b565b6040516104629190615164565b6104ea610b65366004614a8f565b600a6020526000908152604090205481565b61047e610b85366004615235565b61339f565b61047e610b98366004614e4a565b61340e565b60006001600160e01b0319821663780e9d6360e01b1480610bc25750610bc28261348e565b92915050565b610bd06134de565b610bd983613518565b610c198383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061357792505050565b505050565b606060008054610c2d90615294565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5990615294565b8015610ca65780601f10610c7b57610100808354040283529160200191610ca6565b820191906000526020600020905b815481529060010190602001808311610c8957829003601f168201915b5050505050905090565b60017f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316301415610cfc576040516325c7410560e21b815260040160405180910390fd5b600b548111610d1e576040516302ed543d60e51b815260040160405180910390fd5b600b819055610d2f868686866135db565b610d39600261362c565b610d42826136aa565b505050505050565b6000818152600260205260408120546001600160a01b0316610dc85760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610def826118fe565b9050806001600160a01b0316836001600160a01b03161415610e5d5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610dbf565b336001600160a01b0382161480610e795750610e798133610adb565b610eeb5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610dbf565b610c198383613703565b610efd613771565b6001600160a01b0382166000818152600d6020908152604091829020805460ff191685151590811790915591514281529192917f8f617843889b94892bd44852d36ca6a7f49ecf4350a01e7b68e22d80f4ed95bc91015b60405180910390a35050565b6000808383604051610f739291906152c9565b6040805191829003909120600090815260126020522054949350505050565b610f9c338261379c565b610fb85760405162461bcd60e51b8152600401610dbf906152d9565b610c19838383613893565b6000610fce83611a4f565b82106110305760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610dbf565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b611061613771565b6001600160a01b0382166000818152600f6020908152604091829020805460ff191685151590811790915591514281529192917f6cc19a794d6a439023150cd58748eed4353190c0bb060d2e6250e2df4a68b6739101610f54565b60008115806110d8575060008381526013602052604090205482115b156110e557506003610bc2565b60008381526014602090815260408083208584529091529020600401546001600160a01b031661111757506002610bc2565b600083815260146020908152604080832085845290915290205461113d57506000610bc2565b506001610bc2565b61114d613771565b601780546001600160a01b038381166001600160a01b03198316811790935560405191169190829033907f676c0801b0f400762e958ee31cfbb10870e70786f6761f57c8647e766b0db3d9906111a69042815260200190565b60405180910390a45050565b60008181526013602052604090206005018054606091906111d290615294565b80601f01602080910402602001604051908101604052809291908181526020018280546111fe90615294565b801561124b5780601f106112205761010080835404028352916020019161124b565b820191906000526020600020905b81548152906001019060200180831161122e57829003601f168201915b50505050509050919050565b61125f6134de565b600061126b82356118fe565b90506000611277613a3e565b7f6f3f6455a608af1cc57ef3e5c0a49deeb88bba264ec8865b798ff07358859d4b84356112aa6040870160208801614a8f565b6112b7604088018861532a565b6040516112c59291906152c9565b604080519182900382206001600160a01b0389166000908152600a6020908152929020805460018101909155611334969594939192909160c08c0135910195865260208601949094526001600160a01b039290921660408501526060840152608083015260a082015260c00190565b6040516020818303038152906040528051906020012060405160200161135b929190615370565b60405160208183030381529060405280519060200120905061139181838560600180360381019061138c919061538b565b613ad3565b73bfe82126b2f18918842dbe03d5d81a7b35b69821636a7ecf1384356113bd6040870160208801614a8f565b6113ca604088018861532a565b88356000908152601360205260409081902090516001600160e01b031960e088901b168152611403959493929190600e90600401615428565b60006040518083038186803b15801561141b57600080fd5b505af415801561142f573d6000803e3d6000fd5b50505050505050565b611440613bb7565b600061144c82356118fe565b90506000611458613a3e565b7ffb8f057542e7551386ead0b891a45f102af78c47f8cc58b4a919c7cfeccd0e1e8435611488602087018761532a565b6040516114969291906152c9565b60405180910390208660400160208101906114b19190614a8f565b6114be606089018961532a565b6040516114cc9291906152c9565b6040519081900390206114e560a08a0160808b01614a8f565b6114f260a08b018b61532a565b6040516115009291906152c9565b604080519182900382206001600160a01b038c81166000908152600a6020908152908490208054600181019091559085019a909a52918301979097526060820195909552928416608084015260a083019190915290911660c082015260e0810191909152610100810191909152610120858101359082015261014001604051602081830303815290604052805190602001206040516020016115a3929190615370565b6040516020818303038152906040528051906020012090506115d481838560c00180360381019061138c919061538b565b610c1983356115e6602086018661532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061162b925050506060870160408801614a8f565b611638606088018861532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061167d9250505060a0890160808a01614a8f565b61168a60a08a018a61532a565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613c2792505050565b6116cc613771565b6001600160a01b038216600081815260106020908152604091829020805460ff191685151590811790915591514281529192917f37872a053ef20cb52defb7c9ec20e1a87cb8dd5098ac9e76a144be263dfef5729101610f54565b610c1983838360405180602001604052806000815250612817565b61174a6134de565b61175381613cd3565b61175c81613d03565b50565b600061176a60085490565b82106117cd5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610dbf565b600882815481106117e0576117e0615468565b90600052602060002001549050919050565b600081815260026020526040812054600160a01b90046001600160601b0316806118795760405162461bcd60e51b815260206004820152603260248201527f4552433732313a206d696e742074696d657374616d7020717565727920666f72604482015271103737b732bc34b9ba32b73a103a37b5b2b760711b6064820152608401610dbf565b6001600160601b031692915050565b6016546001600160a01b031633148015906118ae57506017546001600160a01b03163314155b156118cc57604051635010559960e11b815260040160405180910390fd5b61175c8161362c565b6000828152601460209081526040808320848452909152902080546001909101545b9250929050565b6000818152600260205260408120546001600160a01b031680610bc25760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610dbf565b61197d613bb7565b6119878135613518565b61175c8135602083013560408401356119a66080860160608701614a8f565b6119b3608087018761532a565b613d3e565b6119c06134de565b6119c984613daf565b600084815260136020526040908190209051636a7ecf1360e01b815273bfe82126b2f18918842dbe03d5d81a7b35b6982191636a7ecf1391611a1991889188918891889190600e90600401615428565b60006040518083038186803b158015611a3157600080fd5b505af4158015611a45573d6000803e3d6000fd5b5050505050505050565b60006001600160a01b038216611aba5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610dbf565b506001600160a01b031660009081526003602052604090205490565b6001600160a01b038316611afd576040516307eb16dd60e21b815260040160405180910390fd5b6000611b08836118fe565b90506000611b14613a3e565b6001600160a01b038381166000908152600a602090815260409182902080546001810190915582517f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad81840152938a168484015260608085018a9052608085019190915287013560a0808501919091528251808503909101815260c084019092528151910120611ba7929160e001615370565b604051602081830303815290604052805190602001209050611bd581838580360381019061138c919061538b565b611bdf8585613703565b5050505050565b611bee6134de565b60405163334ce6f160e21b81527328ce33b49ec8836aa6f0199cf764b82b9bedb5ea9063cd339bc490611a1990339088908890889088907f00000000000000000000000000000000000000000000000000000000000000009060149060139060040161547e565b60008581526014602090815260408083208784529091529020600501546001600160a01b0316338114611c9b5760405163c6d1651b60e01b815260040160405180910390fd5b604080516001600160a01b03858116825284166020820152428183015290518591879189917f68edb7ec2c37d21b3b72233960b487f2966f4ac82b7430d39f24d1f8d6f99106919081900360600190a4505050505050565b6001600160a01b038316611d1a576040516307eb16dd60e21b815260040160405180910390fd5b6000611d24613a3e565b6001600160a01b038681166000818152600a602090815260409182902080546001810190915582517f47ab88482c90e4bb94b82a947ae78fa91fb25de1469ab491f4c15b9a0a2677ee9281019290925291810192909252918716606080830191909152861515608083015260a08201929092529084013560c082015260e00160405160208183030381529060405280519060200120604051602001611dca929190615370565b604051602081830303815290604052805190602001209050611df881868480360381019061138c919061538b565b611bdf858585613de9565b611e0b6134de565b6000611e1a60408301836154cc565b90506001600160401b03811115611e3357611e33614ec5565b604051908082528060200260200182016040528015611e5c578160200160208202803683370190505b50905060005b611e6f60408401846154cc565b9050811015611eec57611e8560408401846154cc565b82818110611e9557611e95615468565b9050602002810190611ea7919061532a565b604051611eb59291906152c9565b6040518091039020828281518110611ecf57611ecf615468565b602090810291909101015280611ee48161552b565b915050611e62565b506000611ef7613a3e565b7ffb6b7f1cd1b38daf3822aff0abbe78124db5d62a4748bcff007c15ccd6d30bc5611f2560208601866154cc565b604051602001611f36929190615546565b6040516020818303038152906040528051906020012084604051602001611f5d9190615572565b60405160208183030381529060405280519060200120600a6000886000016020810190611f8a9190614a8f565b6001600160a01b0316815260208082019290925260409081016000208054600181019091558151928301959095528101929092526060820152608081019190915260c08581013560a08301520160405160208183030381529060405280519060200120604051602001611ffe929190615370565b60408051601f198184030181529190528051602091820120915061203c90829061202a90860186614a8f565b61138c3687900387016060880161538b565b7328ce33b49ec8836aa6f0199cf764b82b9bedb5ea63bccbaefd6120636020860186614a8f565b61207060208701876154cc565b61207d60408901896154cc565b7f0000000000000000000000000000000000000000000000000000000000000000601360126040518963ffffffff1660e01b81526004016114039897969594939291906155ed565b6120cd613bb7565b60006120d982356118fe565b905060006120e5613a3e565b7f64f4578fc098f96a2450fbe601cb8c5318ebeb2ff72d2031a36be1ff6932d5ee8435602086013560408701356121226080890160608a01614a8f565b61212f60808a018a61532a565b60405161213d9291906152c9565b604080519182900382206001600160a01b038b166000908152600a60209081529290208054600181019091556121bd989796959493919290916101008e013591019788526020880196909652604087019490945260608601929092526001600160a01b0316608085015260a084015260c083015260e08201526101000190565b604051602081830303815290604052805190602001206040516020016121e4929190615370565b60405160208183030381529060405280519060200120905061221581838560a00180360381019061138c919061538b565b610c198335602085013560408601356122346080880160608901614a8f565b6119b3608089018961532a565b606060018054610c2d90615294565b612258613bb7565b6122628135613518565b61175c8135612274602084018461532a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506122b9925050506060850160408601614a8f565b6122c6606086018661532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061230b9250505060a0870160808801614a8f565b61168a60a088018861532a565b6123206134de565b600061232c82356118fe565b90506000612338613a3e565b7f5b9860bd835e648945b22d053515bc1f53b7d9fab4b23b1b49db15722e945d148435612368602087018761532a565b6040516123769291906152c9565b604080519182900382206001600160a01b0388166000908152600a60209081529083902080546001810190915590840195909552908201929092526060810191909152608081019190915260a0858101359082015260c001604051602081830303815290604052805190602001206040516020016123f5929190615370565b60405160208183030381529060405280519060200120905061242681838560400180360381019061138c919061538b565b610c198335612438602086018661532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061357792505050565b6001600160a01b0382163314156124cb5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610dbf565b6124d6338383613de9565b5050565b6124e2613bb7565b6124ec8135613518565b61175c6124f8826156bf565b613e56565b612505613771565b6001600160a01b0382166000818152600e6020908152604091829020805460ff191685151590811790915591514281529192917f52c5b7889df9f12f84ec3da051e854e5876678370d8357959c23ef59dd6486df9101610f54565b612568613771565b61175c816136aa565b6125796134de565b6000612583613a3e565b7f7f9b4ea1fc678b4fda1611ac5cbd28f339e235d89b1540635e9b2e0223a3c101602084013560408501356125bb606087018761532a565b6040516125c99291906152c9565b604051908190039020600a60006125e360208a018a614a8f565b6001600160a01b0316815260208082019290925260409081016000208054600181019091558151928301969096528101939093526060830191909152608082015260a081019190915260e08481013560c0830152016040516020818303038152906040528051906020012060405160200161265f929190615370565b60408051601f198184030181529190528051602091820120915061269d90829061268b90850185614a8f565b61138c3686900386016080870161538b565b7328ce33b49ec8836aa6f0199cf764b82b9bedb5ea63cd339bc46126c46020850185614a8f565b602085013560408601356126db606088018861532a565b7f0000000000000000000000000000000000000000000000000000000000000000601460136040518963ffffffff1660e01b815260040161272398979695949392919061547e565b60006040518083038186803b15801561273b57600080fd5b505af4158015610d42573d6000803e3d6000fd5b606060008061276085856014613f0e565b506000828152601460209081526040808320848452909152902060020180549294509092509061278f90615294565b80601f01602080910402602001604051908101604052809291908181526020018280546127bb90615294565b80156128085780601f106127dd57610100808354040283529160200191612808565b820191906000526020600020905b8154815290600101906020018083116127eb57829003601f168201915b50505050509250505092915050565b612821338361379c565b61283d5760405162461bcd60e51b8152600401610dbf906152d9565b61284984848484613fd0565b50505050565b6128576134de565b600061286382356118fe565b9050600061286f613a3e565b7fd8d76e8b2b26e1ebe72def13fb559a68561ef064055b0de01f955bc26e25d42f843561289f602087018761532a565b6040516128ad9291906152c9565b604080519182900382206001600160a01b0388166000908152600a60209081529083902080546001810190915590840195909552908201929092526060810191909152608081019190915260a0858101359082015260c0016040516020818303038152906040528051906020012060405160200161292c929190615370565b60405160208183030381529060405280519060200120905061295d81838560400180360381019061138c919061538b565b610c19833561296f602086018661532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061400392505050565b6000848152601360205260409020600201546001600160a01b03163381146129e45760405163646785d560e11b815260040160405180910390fd5b604080516001600160a01b0385811682528416602082015242818301529051859187917f4996ad2257e7db44908136c43128cc10ca988096f67dc6bb0bcee11d151368fb9181900360600190a35050505050565b612a406134de565b6000612a4c82356118fe565b90506000612a58613a3e565b7f77ba3e9f5fa75343bbad1241fb539a0064de97694b47d463d1eb5c54aba11f0f8435612a8b6040870160208801614a8f565b6001600160a01b038681166000908152600a602090815260409182902080546001810190915582519182019690965290810193909352166060820152608081019190915260a0858101359082015260c00160405160208183030381529060405280519060200120604051602001612b03929190615370565b604051602081830303815290604052805190602001209050612b3481838560400180360381019061138c919061538b565b610c198335612b496040860160208701614a8f565b61405b565b612b566134de565b612b5f82613daf565b6124d6828261405b565b60408051808201909152600080825260208201526000828152600260205260409020546001600160a01b0316612bf85760405162461bcd60e51b815260206004820152602e60248201527f4552433732313a20746f6b656e206461746120717565727920666f72206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610dbf565b506000908152600260209081526040918290208251808401909352546001600160a01b0381168352600160a01b90046001600160601b03169082015290565b612c3f6134de565b612c4883613518565b610c198383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061400392505050565b612cdc6040518060c0016040528060008152602001600081526020016060815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b6014600084815260200190815260200160002060008381526020019081526020016000206040518060c00160405290816000820154815260200160018201548152602001600282018054612d2f90615294565b80601f0160208091040260200160405190810160405280929190818152602001828054612d5b90615294565b8015612da85780601f10612d7d57610100808354040283529160200191612da8565b820191906000526020600020905b815481529060010190602001808311612d8b57829003601f168201915b505050918352505060038201546001600160a01b0390811660208301526004830154811660408301526005909201549091166060909101529392505050565b60008181526013602052604090206004018054606091906111d290615294565b612e0f6134de565b612e1982826140b8565b6124d682613d03565b60008181526013602052604090206003018054606091906111d290615294565b612e4a613bb7565b6000612e5682356118fe565b90506000612e62613a3e565b7fb30910150df56294e05b2d03e181803697a2b935abb1b9bdddde9310f618fe9b8435612e92602087018761532a565b604051612ea09291906152c9565b604051809103902086604001358760600135886080016020810190612ec59190614a8f565b612ed260a08b018b61532a565b604051612ee09291906152c9565b604051908190039020612ef960e08c0160c08d01614a8f565b612f0660e08d018d61532a565b604051612f149291906152c9565b604080519182900382206001600160a01b03808f166000908152600a6020908152908490208054600181019091559085019c909c52918301999099526060820197909752608081019590955260a085019390935290841660c084015260e083015290911661010082015261012081019190915261014081019190915261016080860135908201526101800160405160208183030381529060405280519060200120604051602001612fc6929190615370565b604051602081830303815290604052805190602001209050612ff88183856101000180360381019061138c919061538b565b610c1960405180610100016040528085600001358152602001858060200190613021919061532a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506040808701356020830152606080880135918301919091520161308160a0870160808801614a8f565b6001600160a01b0316815260200161309c60a087018761532a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020016130e660e0870160c08801614a8f565b6001600160a01b0316815260200161310160e087018761532a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250613e56565b6000613146613a3e565b905090565b6131966040518060c001604052806000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016060815260200160608152602001606081525090565b600082815260136020908152604091829020825160c0810184528154815260018201546001600160a01b03908116938201939093526002820154909216928201929092526003820180549192916060840191906131f290615294565b80601f016020809104026020016040519081016040528092919081815260200182805461321e90615294565b801561326b5780601f106132405761010080835404028352916020019161326b565b820191906000526020600020905b81548152906001019060200180831161324e57829003601f168201915b5050505050815260200160048201805461328490615294565b80601f01602080910402602001604051908101604052809291908181526020018280546132b090615294565b80156132fd5780601f106132d2576101008083540402835291602001916132fd565b820191906000526020600020905b8154815290600101906020018083116132e057829003601f168201915b5050505050815260200160058201805461331690615294565b80601f016020809104026020016040519081016040528092919081815260200182805461334290615294565b801561338f5780601f106133645761010080835404028352916020019161338f565b820191906000526020600020905b81548152906001019060200180831161337257829003601f168201915b5050505050815250509050919050565b6133a76134de565b60405163bccbaefd60e01b81527328ce33b49ec8836aa6f0199cf764b82b9bedb5ea9063bccbaefd90611a1990339088908890889088907f0000000000000000000000000000000000000000000000000000000000000000906013906012906004016155ed565b6134166134de565b61341e61419e565b600060156000815461342f9061552b565b9182905550905061344c6134466020840184614a8f565b826141ce565b604051633f67a66f60e11b815273bfe82126b2f18918842dbe03d5d81a7b35b6982190637ecf4cde906127239085908590601290601390600e90600401615791565b60006001600160e01b031982166380ac58cd60e01b14806134bf57506001600160e01b03198216635b5e139f60e01b145b80610bc257506301ffc9a760e01b6001600160e01b0319831614610bc2565b6002600c5460ff1660028111156134f7576134f7614a5f565b1415613516576040516313d0ff5960e31b815260040160405180910390fd5b565b613521816118fe565b6001600160a01b0316336001600160a01b03161415801561355957506000818152601160205260409020546001600160a01b03163314155b1561175c5760405163f33ac98f60e01b815260040160405180910390fd5b6000828152601360209081526040909120825161359c9260049092019184019061474d565b50817fd5a5879cad33c830cc1432c1850107029a09c80c60e9bce1ecd08d24880bd46c82426040516135cf929190615888565b60405180910390a25050565b6135e78484848461431f565b7f414cd0b34676984f09a5f76ce9718d4062e50283abe0e7e274a9a5b4e0c99c30848484844260405161361e9594939291906158aa565b60405180910390a150505050565b600c805460ff811691839160ff1916600183600281111561364f5761364f614a5f565b021790555081600281111561366657613666614a5f565b81600281111561367857613678614a5f565b60405142815233907fa2f9a1499fc1f9b7796d21fe5761290ccb7e0ef6ccf35fa58b668f304a62a1ca906020016111a6565b601680546001600160a01b038381166001600160a01b03198316811790935560405191169190829033907fe552a55455b740845a5c07ed445d1724142fc997b389835495a29b30cddc1ccd906111a69042815260200190565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190613738826118fe565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6016546001600160a01b0316331461351657604051632d5be4cb60e21b815260040160405180910390fd5b6000818152600260205260408120546001600160a01b03166138155760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610dbf565b6000613820836118fe565b9050806001600160a01b0316846001600160a01b0316148061385b5750836001600160a01b031661385084610d4a565b6001600160a01b0316145b8061388b57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166138a6826118fe565b6001600160a01b03161461390e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610dbf565b6001600160a01b0382166139705760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610dbf565b61397b838383614338565b613986600082613703565b6001600160a01b03831660009081526003602052604081208054600192906139af9084906158e4565b90915550506001600160a01b03821660009081526003602052604081208054600192906139dd9084906158fb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f613a69610c1e565b80516020918201206040805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b4281606001511015613af857604051630819bdcd60e01b815260040160405180910390fd5b600060018483600001518460200151856040015160405160008152602001604052604051613b42949392919093845260ff9290921660208401526040830152606082015260800190565b6020604051602081039080840390855afa158015613b64573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381161580613b995750826001600160a01b0316816001600160a01b031614155b15612849576040516337e8456b60e01b815260040160405180910390fd5b6002600c5460ff166002811115613bd057613bd0614a5f565b1415613bef576040516313d0ff5960e31b815260040160405180910390fd5b6001600c5460ff166002811115613c0857613c08614a5f565b141561351657604051630f392a3b60e31b815260040160405180910390fd5b73bfe82126b2f18918842dbe03d5d81a7b35b69821639dbf0510878787878787601360008f815260200190815260200160002060000160008154613c6a9061552b565b9190508190556014600f60106040518b63ffffffff1660e01b8152600401613c9b9a99989796959493929190615913565b60006040518083038186803b158015613cb357600080fd5b505af4158015613cc7573d6000803e3d6000fd5b50505050505050505050565b613cdd338261379c565b613cfa57604051636d8a29e760e11b815260040160405180910390fd5b61175c8161436b565b6000818152601360205260408082209051613d21916003019061599a565b604080519182900390912060009081526012602052908120555050565b73bfe82126b2f18918842dbe03d5d81a7b35b69821638588c2ff878787878787601360008f815260200190815260200160002060000160008154613d819061552b565b919050819055601460106040518a63ffffffff1660e01b8152600401613c9b99989796959493929190615a36565b613db8816118fe565b6001600160a01b0316336001600160a01b03161461175c5760405163f194fae560e01b815260040160405180910390fd5b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b805160009081526013602052604090205473bfe82126b2f18918842dbe03d5d81a7b35b698219063e63aa93e908390613e909060016158fb565b60136014600f60106040518763ffffffff1660e01b8152600401613eb996959493929190615a8d565b60006040518083038186803b158015613ed157600080fd5b505af4158015613ee5573d6000803e3d6000fd5b505082516000908152601360205260408120805493509150613f068361552b565b919050555050565b600083815260208281526040808320858452909152812060040154819081906001600160a01b03168015613f49578693508592509050613fc7565b60008781526020868152604080832089845290915290205480613f7f5760405163a43d2a7160e01b815260040160405180910390fd5b6000888152602087815260408083208a84528252808320600101548484528983528184208185529092529091206004015491955093506001600160a01b03169150613fc79050565b93509350939050565b613fdb848484613893565b613fe784848484614407565b6128495760405162461bcd60e51b8152600401610dbf90615b6d565b600082815260136020908152604090912082516140289260059092019184019061474d565b50817fe82886e1af6fcab5caef13815b22f51384e970c367a785f265d13860a7d6966d82426040516135cf929190615888565b60008281526011602090815260409182902080546001600160a01b0319166001600160a01b038516908117909155915142815284917f22baaec4952f35f59e45bd2ddb287e1ccc6d319375770c09428eb8f8d604e0659101610f54565b60006140c3836118fe565b905060006140cf613a3e565b6001600160a01b0383166000908152600a60209081526040918290208054600181019091559151614140927f108ccda6d7331b00561a3eea66a2ae331622356585681c62731e4a01aae2261a92899260608a0135910193845260208401929092526040830152606082015260800190565b60405160208183030381529060405280519060200120604051602001614167929190615370565b60405160208183030381529060405280519060200120905061419581838580360381019061138c919061538b565b6128498461436b565b336000908152600d602052604090205460ff166135165760405163561a858760e01b815260040160405180910390fd5b6001600160a01b0382166142245760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610dbf565b6000818152600260205260409020546001600160a01b0316156142895760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610dbf565b61429560008383614338565b6001600160a01b03821660009081526003602052604081208054600192906142be9084906158fb565b90915550506000818152600260205260408082206001600160a01b038516600160a01b426001600160601b031602811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b61432b600085856147d1565b50611bdf600183836147d1565b6000818152601160205260409020546001600160a01b0316156143605761436081600061405b565b610c19838383614505565b6000614376826118fe565b905061438481600084614338565b61438f600083613703565b6001600160a01b03811660009081526003602052604081208054600192906143b89084906158e4565b9091555050600082815260026020526040808220829055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60006001600160a01b0384163b156144fa57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061444b903390899088908890600401615bbf565b6020604051808303816000875af1925050508015614486575060408051601f3d908101601f1916820190925261448391810190615bfc565b60015b6144e0573d8080156144b4576040519150601f19603f3d011682016040523d82523d6000602084013e6144b9565b606091505b5080516144d85760405162461bcd60e51b8152600401610dbf90615b6d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061388b565b506001949350505050565b6001600160a01b0383166145605761455b81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b614583565b816001600160a01b0316836001600160a01b0316146145835761458383826145bd565b6001600160a01b03821661459a57610c198161465a565b826001600160a01b0316826001600160a01b031614610c1957610c198282614709565b600060016145ca84611a4f565b6145d491906158e4565b600083815260076020526040902054909150808214614627576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061466c906001906158e4565b6000838152600960205260408120546008805493945090928490811061469457614694615468565b9060005260206000200154905080600883815481106146b5576146b5615468565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806146ed576146ed615c19565b6001900381819060005260206000200160009055905550505050565b600061471483611a4f565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b82805461475990615294565b90600052602060002090601f01602090048101928261477b57600085556147c1565b82601f1061479457805160ff19168380011785556147c1565b828001600101855582156147c1579182015b828111156147c15782518255916020019190600101906147a6565b506147cd929150614845565b5090565b8280546147dd90615294565b90600052602060002090601f0160209004810192826147ff57600085556147c1565b82601f106148185782800160ff198235161785556147c1565b828001600101855582156147c1579182015b828111156147c157823582559160200191906001019061482a565b5b808211156147cd5760008155600101614846565b6001600160e01b03198116811461175c57600080fd5b60006020828403121561488257600080fd5b813561488d8161485a565b9392505050565b60008083601f8401126148a657600080fd5b5081356001600160401b038111156148bd57600080fd5b6020830191508360208285010111156118f757600080fd5b6000806000604084860312156148ea57600080fd5b8335925060208401356001600160401b0381111561490757600080fd5b61491386828701614894565b9497909650939450505050565b6000815180845260005b818110156149465760208185018101518683018201520161492a565b81811115614958576000602083870101525b50601f01601f19169290920160200192915050565b60208152600061488d6020830184614920565b80356001600160a01b038116811461499757600080fd5b919050565b6000806000806000606086880312156149b457600080fd5b85356001600160401b03808211156149cb57600080fd5b6149d789838a01614894565b909750955060208801359150808211156149f057600080fd5b506149fd88828901614894565b9094509250614a10905060408701614980565b90509295509295909350565b600060208284031215614a2e57600080fd5b5035919050565b60008060408385031215614a4857600080fd5b614a5183614980565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6020810160038310614a8957614a89614a5f565b91905290565b600060208284031215614aa157600080fd5b61488d82614980565b8035801515811461499757600080fd5b60008060408385031215614acd57600080fd5b614ad683614980565b9150614ae460208401614aaa565b90509250929050565b60008060208385031215614b0057600080fd5b82356001600160401b03811115614b1657600080fd5b614b2285828601614894565b90969095509350505050565b600080600060608486031215614b4357600080fd5b614b4c84614980565b9250614b5a60208501614980565b9150604084013590509250925092565b60008060408385031215614b7d57600080fd5b50508035926020909101359150565b6020810160048310614a8957614a89614a5f565b600060e08284031215614bb257600080fd5b50919050565b600060208284031215614bca57600080fd5b81356001600160401b03811115614be057600080fd5b61388b84828501614ba0565b600060208284031215614bfe57600080fd5b81356001600160401b03811115614c1457600080fd5b8201610140818503121561488d57600080fd5b600060208284031215614c3957600080fd5b81356003811061488d57600080fd5b600060208284031215614c5a57600080fd5b81356001600160401b03811115614c7057600080fd5b820160a0818503121561488d57600080fd5b60008060008060608587031215614c9857600080fd5b84359350614ca860208601614980565b925060408501356001600160401b03811115614cc357600080fd5b614ccf87828801614894565b95989497509550505050565b600060808284031215614bb257600080fd5b600080600060c08486031215614d0257600080fd5b614d0b84614980565b925060208401359150614d218560408601614cdb565b90509250925092565b60008060008060608587031215614d4057600080fd5b843593506020850135925060408501356001600160401b03811115614cc357600080fd5b600080600080600060a08688031215614d7c57600080fd5b853594506020860135935060408601359250614d9a60608701614980565b9150614a1060808701614980565b60008060008060e08587031215614dbe57600080fd5b614dc785614980565b9350614dd560208601614980565b9250614de360408601614aaa565b9150614df28660608701614cdb565b905092959194509250565b600060208284031215614e0f57600080fd5b81356001600160401b03811115614e2557600080fd5b8201610120818503121561488d57600080fd5b600060c08284031215614bb257600080fd5b600060208284031215614e5c57600080fd5b81356001600160401b03811115614e7257600080fd5b61388b84828501614e38565b60006101008284031215614bb257600080fd5b600060208284031215614ea357600080fd5b81356001600160401b03811115614eb957600080fd5b61388b84828501614e7e565b634e487b7160e01b600052604160045260246000fd5b60405161010081016001600160401b0381118282101715614efe57614efe614ec5565b60405290565b600082601f830112614f1557600080fd5b81356001600160401b0380821115614f2f57614f2f614ec5565b604051601f8301601f19908116603f01168101908282118183101715614f5757614f57614ec5565b81604052838152866020858801011115614f7057600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215614fa657600080fd5b614faf85614980565b9350614fbd60208601614980565b92506040850135915060608501356001600160401b03811115614fdf57600080fd5b614feb87828801614f04565b91505092959194509250565b6000806000806080858703121561500d57600080fd5b843593506020850135925061502460408601614980565b9150614df260608601614980565b600060c0828403121561504457600080fd5b61488d8383614e38565b6000806040838503121561506157600080fd5b82359150614ae460208401614980565b6020815281516020820152602082015160408201526000604083015160c060608401526150a160e0840182614920565b9050606084015160018060a01b0380821660808601528060808701511660a08601528060a08701511660c086015250508091505092915050565b60008060a083850312156150ee57600080fd5b82359150614ae48460208501614cdb565b6000806040838503121561511257600080fd5b61511b83614980565b9150614ae460208401614980565b60006020828403121561513b57600080fd5b81356001600160401b0381111561515157600080fd5b8201610180818503121561488d57600080fd5b60208152815160208201526000602083015160018060a01b0380821660408501528060408601511660608501525050606083015160c060808401526151ac60e0840182614920565b90506080840151601f19808584030160a08601526151ca8383614920565b925060a08601519150808584030160c0860152506151e88282614920565b95945050505050565b60008083601f84011261520357600080fd5b5081356001600160401b0381111561521a57600080fd5b6020830191508360208260051b85010111156118f757600080fd5b6000806000806040858703121561524b57600080fd5b84356001600160401b038082111561526257600080fd5b61526e888389016151f1565b9096509450602087013591508082111561528757600080fd5b50614ccf878288016151f1565b600181811c908216806152a857607f821691505b60208210811415614bb257634e487b7160e01b600052602260045260246000fd5b8183823760009101908152919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000808335601e1984360301811261534157600080fd5b8301803591506001600160401b0382111561535b57600080fd5b6020019150368190038213156118f757600080fd5b61190160f01b81526002810192909252602282015260420190565b60006080828403121561539d57600080fd5b604051608081018181106001600160401b03821117156153bf576153bf614ec5565b604052823560ff811681146153d357600080fd5b808252506020830135602082015260408301356040820152606083013560608201528091505092915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8681526001600160a01b038616602082015260a06040820181905260009061545390830186886153ff565b60608301949094525060800152949350505050565b634e487b7160e01b600052603260045260246000fd5b600060018060a01b03808b16835289602084015288604084015260e060608401526154ad60e08401888a6153ff565b951660808301525060a081019290925260c09091015295945050505050565b6000808335601e198436030181126154e357600080fd5b8301803591506001600160401b038211156154fd57600080fd5b6020019150600581901b36038213156118f757600080fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561553f5761553f615515565b5060010190565b60006001600160fb1b0383111561555c57600080fd5b8260051b80858437600092019182525092915050565b815160009082906020808601845b8381101561559c57815185529382019390820190600101615580565b50929695505050505050565b6000808335601e198436030181126155bf57600080fd5b83016020810192503590506001600160401b038111156155de57600080fd5b8036038313156118f757600080fd5b6001600160a01b038916815260c060208083018290529082018890526000906001600160fb1b0389111561562057600080fd5b8860051b808b60e0860137830183810360e090810160408601528101889052600588901b81016101009081019082018a60005b8b81101561568d5784840360ff1901835261566e828e6155a8565b6156798682846153ff565b955050509185019190850190600101615653565b5050506001600160a01b038816606086015292506156a9915050565b608082019390935260a001529695505050505050565b600061010082360312156156d257600080fd5b6156da614edb565b8235815260208301356001600160401b03808211156156f857600080fd5b61570436838701614f04565b6020840152604085013560408401526060850135606084015261572960808601614980565b608084015260a085013591508082111561574257600080fd5b61574e36838701614f04565b60a084015261575f60c08601614980565b60c084015260e085013591508082111561577857600080fd5b5061578536828601614f04565b60e08301525092915050565b60a0815260006001600160a01b03806157a989614980565b1660a08401526157bc60208901896155a8565b60c0808601526157d1610160860182846153ff565b9150506157e160408a018a6155a8565b609f19808785030160e08801526157f98483856153ff565b93508461580860608e01614980565b1661010088015261581c60808d018d6155a8565b9550925080878503016101208801526158368486856153ff565b945061584560a08d018d6155a8565b94509250808786030161014088015250506158618383836153ff565b93505050508560208301528460408301528360608301528260808301529695505050505050565b60408152600061589b6040830185614920565b90508260208301529392505050565b6060815260006158be6060830187896153ff565b82810360208401526158d18186886153ff565b9150508260408301529695505050505050565b6000828210156158f6576158f6615515565b500390565b6000821982111561590e5761590e615515565b500190565b60006101408c835280602084015261592d8184018d614920565b6001600160a01b038c811660408601528482036060860152909150615952828c614920565b908a16608085015283810360a0850152905061596e8189614920565b9150508560c08301528460e083015283610100830152826101208301529b9a5050505050505050505050565b600080835481600182811c9150808316806159b657607f831692505b60208084108214156159d657634e487b7160e01b86526022600452602486fd5b8180156159ea57600181146159fb57615a28565b60ff19861689528489019650615a28565b60008a81526020902060005b86811015615a205781548b820152908501908301615a07565b505084890196505b509498975050505050505050565b60006101008b83528a602084015289604084015260018060a01b0389166060840152806080840152615a6b818401888a6153ff565b60a0840196909652505060c081019290925260e0909101529695505050505050565b60c08152865160c0820152600060208801516101008060e0850152615ab66101c0850183614920565b915060408a0151818501525060608901516101208401526080890151615ae86101408501826001600160a01b03169052565b5060a089015160bf198085840301610160860152615b068383614920565b925060c08b01519150615b256101808601836001600160a01b03169052565b60e08b0151915080858403016101a086015250615b428282614920565b602085019990995250505060408101949094526060840192909252608083015260a090910152919050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615bf290830184614920565b9695505050505050565b600060208284031215615c0e57600080fd5b815161488d8161485a565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220f3c0f4b4d18b9b2f5702bef4b47b20167acc083d554e812db0ed8df265fdfba264736f6c634300080a0033000000000000000000000000b7141ba444bef189cdf8cef52f8dabab3bfcfb6900000000000000000000000051063d3a1c677b6b02fa2b478799f9d160894ccb

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061043e5760003560e01c806386e2947b11610236578063b88d4fde1161013b578063d923d20c116100c3578063ed24911d11610087578063ed24911d14610b2f578063f08f4f6414610b37578063f990ccd714610b57578063fb78ae6c14610b77578063ffea138e14610b8a57600080fd5b8063d923d20c14610a8e578063dd69cdb114610aba578063e985e9c514610acd578063ec81d19414610b09578063ecfab8fa14610b1c57600080fd5b8063bfd24f471161010a578063bfd24f47146109f5578063c0da9bcd14610a08578063c6b5d06c14610a48578063c736c99014610a5b578063c87b56dd14610a7b57600080fd5b8063b88d4fde146109a9578063bd12d3f0146109bc578063bdfdd4bc146109cf578063bfbf0b4b146109e257600080fd5b8063a2c79772116101be578063ad3e72bf1161018d578063ad3e72bf146108f4578063af05dd2214610920578063b48951e41461094c578063b5a314961461095f578063b7984c051461097257600080fd5b8063a2c797721461088f578063a6d8e1e4146108a2578063a9ec6563146108b5578063ab033ea9146108e157600080fd5b80638f14b45f116102055780638f14b45f1461083b57806395d89b411461084e578063963ff141146108565780639b84a14c14610869578063a22cb4651461087c57600080fd5b806386e2947b146107d657806389028a13146107e95780638e204fb4146107fc5780638e4fd6a91461082857600080fd5b80633a15ff0711610347578063540528b9116102cf5780636a4e66d2116102935780636a4e66d2146107775780636dea40b31461078a57806370a082311461079d5780637ef67f99146107b057806384114ad4146107c357600080fd5b8063540528b9146106c957806356de96db146106f257806357ff49f6146107055780635ca3eebf1461073c5780636352211e1461076457600080fd5b806342842e0e1161031657806342842e0e1461064657806342966c68146106595780634f6ccce71461066c57806350ddf35c1461067f57806352aaef551461069257600080fd5b80633a15ff07146105ed5780633b28b89f1461060d5780633b508132146106205780634187e4c51461063357600080fd5b806320905506116103ca5780632f745c59116103995780632f745c591461058157806331dcebe31461059457806331fff07c146105a757806335da3394146105c7578063374c9473146105da57600080fd5b8063209055061461053757806320fa728a1461054a57806323b872dd1461055d578063289b3c0d1461057057600080fd5b8063081812fc11610411578063081812fc146104a8578063095ea7b3146104d357806318160ddd146104e65780631865c57d146104f85780631cbb26201461050b57600080fd5b806301ffc9a714610443578063054871b81461046b57806306fdde0314610480578063077f224a14610495575b600080fd5b610456610451366004614870565b610b9d565b60405190151581526020015b60405180910390f35b61047e6104793660046148d5565b610bc8565b005b610488610c1e565b604051610462919061496d565b61047e6104a336600461499c565b610cb0565b6104bb6104b6366004614a1c565b610d4a565b6040516001600160a01b039091168152602001610462565b61047e6104e1366004614a35565b610de4565b6008545b604051908152602001610462565b600c5460ff166040516104629190614a75565b610456610519366004614a8f565b6001600160a01b03166000908152600e602052604090205460ff1690565b61047e610545366004614aba565b610ef5565b6104ea610558366004614aed565b610f60565b61047e61056b366004614b2e565b610f92565b6016546001600160a01b03166104bb565b6104ea61058f366004614a35565b610fc3565b61047e6105a2366004614aba565b611059565b6105ba6105b5366004614b6a565b6110bc565b6040516104629190614b8c565b61047e6105d5366004614a8f565b611145565b6104886105e8366004614a1c565b6111b2565b6104ea6105fb366004614a1c565b60009081526013602052604090205490565b61047e61061b366004614bb8565b611257565b61047e61062e366004614bec565b611438565b61047e610641366004614aba565b6116c4565b61047e610654366004614b2e565b611727565b61047e610667366004614a1c565b611742565b6104ea61067a366004614a1c565b61175f565b6104ea61068d366004614a1c565b6117f2565b6104bb6106a0366004614b6a565b60009182526014602090815260408084209284529190529020600501546001600160a01b031690565b6104bb6106d7366004614a1c565b6000908152601160205260409020546001600160a01b031690565b61047e610700366004614c27565b611888565b6104bb610713366004614b6a565b60009182526014602090815260408084209284529190529020600401546001600160a01b031690565b61074f61074a366004614b6a565b6118d5565b60408051928352602083019190915201610462565b6104bb610772366004614a1c565b6118fe565b61047e610785366004614c48565b611975565b61047e610798366004614c82565b6119b8565b6104ea6107ab366004614a8f565b611a4f565b61047e6107be366004614ced565b611ad6565b61047e6107d1366004614d2a565b611be6565b61047e6107e4366004614d64565b611c55565b61047e6107f7366004614da8565b611cf3565b61045661080a366004614a8f565b6001600160a01b031660009081526010602052604090205460ff1690565b61047e610836366004614bb8565b611e03565b61047e610849366004614dfd565b6120c5565b610488612241565b61047e610864366004614e4a565b612250565b61047e610877366004614e4a565b612318565b61047e61088a366004614aba565b612472565b61047e61089d366004614e91565b6124da565b61047e6108b0366004614aba565b6124fd565b6104bb6108c3366004614a1c565b6000908152601360205260409020600201546001600160a01b031690565b61047e6108ef366004614a8f565b612560565b610456610902366004614a8f565b6001600160a01b03166000908152600f602052604090205460ff1690565b61045661092e366004614a8f565b6001600160a01b03166000908152600d602052604090205460ff1690565b61047e61095a366004614e91565b612571565b61048861096d366004614b6a565b61274f565b6104bb610980366004614b6a565b60009182526014602090815260408084209284529190529020600301546001600160a01b031690565b61047e6109b7366004614f90565b612817565b61047e6109ca366004614e4a565b61284f565b61047e6109dd366004614ff7565b6129a9565b61047e6109f0366004615032565b612a38565b61047e610a0336600461504e565b612b4e565b610a1b610a16366004614a1c565b612b69565b6040805182516001600160a01b031681526020928301516001600160601b03169281019290925201610462565b61047e610a563660046148d5565b612c37565b610a6e610a69366004614b6a565b612c88565b6040516104629190615071565b610488610a89366004614a1c565b612de7565b6104bb610a9c366004614a1c565b6000908152601360205260409020600101546001600160a01b031690565b61047e610ac83660046150db565b612e07565b610456610adb3660046150ff565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610488610b17366004614a1c565b612e22565b61047e610b2a366004615129565b612e42565b6104ea61313c565b610b4a610b45366004614a1c565b61314b565b6040516104629190615164565b6104ea610b65366004614a8f565b600a6020526000908152604090205481565b61047e610b85366004615235565b61339f565b61047e610b98366004614e4a565b61340e565b60006001600160e01b0319821663780e9d6360e01b1480610bc25750610bc28261348e565b92915050565b610bd06134de565b610bd983613518565b610c198383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061357792505050565b505050565b606060008054610c2d90615294565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5990615294565b8015610ca65780601f10610c7b57610100808354040283529160200191610ca6565b820191906000526020600020905b815481529060010190602001808311610c8957829003601f168201915b5050505050905090565b60017f0000000000000000000000004f0c856b2fa2c1e0e1ac971b462fccf4654e80456001600160a01b0316301415610cfc576040516325c7410560e21b815260040160405180910390fd5b600b548111610d1e576040516302ed543d60e51b815260040160405180910390fd5b600b819055610d2f868686866135db565b610d39600261362c565b610d42826136aa565b505050505050565b6000818152600260205260408120546001600160a01b0316610dc85760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610def826118fe565b9050806001600160a01b0316836001600160a01b03161415610e5d5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610dbf565b336001600160a01b0382161480610e795750610e798133610adb565b610eeb5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610dbf565b610c198383613703565b610efd613771565b6001600160a01b0382166000818152600d6020908152604091829020805460ff191685151590811790915591514281529192917f8f617843889b94892bd44852d36ca6a7f49ecf4350a01e7b68e22d80f4ed95bc91015b60405180910390a35050565b6000808383604051610f739291906152c9565b6040805191829003909120600090815260126020522054949350505050565b610f9c338261379c565b610fb85760405162461bcd60e51b8152600401610dbf906152d9565b610c19838383613893565b6000610fce83611a4f565b82106110305760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610dbf565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b611061613771565b6001600160a01b0382166000818152600f6020908152604091829020805460ff191685151590811790915591514281529192917f6cc19a794d6a439023150cd58748eed4353190c0bb060d2e6250e2df4a68b6739101610f54565b60008115806110d8575060008381526013602052604090205482115b156110e557506003610bc2565b60008381526014602090815260408083208584529091529020600401546001600160a01b031661111757506002610bc2565b600083815260146020908152604080832085845290915290205461113d57506000610bc2565b506001610bc2565b61114d613771565b601780546001600160a01b038381166001600160a01b03198316811790935560405191169190829033907f676c0801b0f400762e958ee31cfbb10870e70786f6761f57c8647e766b0db3d9906111a69042815260200190565b60405180910390a45050565b60008181526013602052604090206005018054606091906111d290615294565b80601f01602080910402602001604051908101604052809291908181526020018280546111fe90615294565b801561124b5780601f106112205761010080835404028352916020019161124b565b820191906000526020600020905b81548152906001019060200180831161122e57829003601f168201915b50505050509050919050565b61125f6134de565b600061126b82356118fe565b90506000611277613a3e565b7f6f3f6455a608af1cc57ef3e5c0a49deeb88bba264ec8865b798ff07358859d4b84356112aa6040870160208801614a8f565b6112b7604088018861532a565b6040516112c59291906152c9565b604080519182900382206001600160a01b0389166000908152600a6020908152929020805460018101909155611334969594939192909160c08c0135910195865260208601949094526001600160a01b039290921660408501526060840152608083015260a082015260c00190565b6040516020818303038152906040528051906020012060405160200161135b929190615370565b60405160208183030381529060405280519060200120905061139181838560600180360381019061138c919061538b565b613ad3565b73bfe82126b2f18918842dbe03d5d81a7b35b69821636a7ecf1384356113bd6040870160208801614a8f565b6113ca604088018861532a565b88356000908152601360205260409081902090516001600160e01b031960e088901b168152611403959493929190600e90600401615428565b60006040518083038186803b15801561141b57600080fd5b505af415801561142f573d6000803e3d6000fd5b50505050505050565b611440613bb7565b600061144c82356118fe565b90506000611458613a3e565b7ffb8f057542e7551386ead0b891a45f102af78c47f8cc58b4a919c7cfeccd0e1e8435611488602087018761532a565b6040516114969291906152c9565b60405180910390208660400160208101906114b19190614a8f565b6114be606089018961532a565b6040516114cc9291906152c9565b6040519081900390206114e560a08a0160808b01614a8f565b6114f260a08b018b61532a565b6040516115009291906152c9565b604080519182900382206001600160a01b038c81166000908152600a6020908152908490208054600181019091559085019a909a52918301979097526060820195909552928416608084015260a083019190915290911660c082015260e0810191909152610100810191909152610120858101359082015261014001604051602081830303815290604052805190602001206040516020016115a3929190615370565b6040516020818303038152906040528051906020012090506115d481838560c00180360381019061138c919061538b565b610c1983356115e6602086018661532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061162b925050506060870160408801614a8f565b611638606088018861532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061167d9250505060a0890160808a01614a8f565b61168a60a08a018a61532a565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613c2792505050565b6116cc613771565b6001600160a01b038216600081815260106020908152604091829020805460ff191685151590811790915591514281529192917f37872a053ef20cb52defb7c9ec20e1a87cb8dd5098ac9e76a144be263dfef5729101610f54565b610c1983838360405180602001604052806000815250612817565b61174a6134de565b61175381613cd3565b61175c81613d03565b50565b600061176a60085490565b82106117cd5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610dbf565b600882815481106117e0576117e0615468565b90600052602060002001549050919050565b600081815260026020526040812054600160a01b90046001600160601b0316806118795760405162461bcd60e51b815260206004820152603260248201527f4552433732313a206d696e742074696d657374616d7020717565727920666f72604482015271103737b732bc34b9ba32b73a103a37b5b2b760711b6064820152608401610dbf565b6001600160601b031692915050565b6016546001600160a01b031633148015906118ae57506017546001600160a01b03163314155b156118cc57604051635010559960e11b815260040160405180910390fd5b61175c8161362c565b6000828152601460209081526040808320848452909152902080546001909101545b9250929050565b6000818152600260205260408120546001600160a01b031680610bc25760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610dbf565b61197d613bb7565b6119878135613518565b61175c8135602083013560408401356119a66080860160608701614a8f565b6119b3608087018761532a565b613d3e565b6119c06134de565b6119c984613daf565b600084815260136020526040908190209051636a7ecf1360e01b815273bfe82126b2f18918842dbe03d5d81a7b35b6982191636a7ecf1391611a1991889188918891889190600e90600401615428565b60006040518083038186803b158015611a3157600080fd5b505af4158015611a45573d6000803e3d6000fd5b5050505050505050565b60006001600160a01b038216611aba5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610dbf565b506001600160a01b031660009081526003602052604090205490565b6001600160a01b038316611afd576040516307eb16dd60e21b815260040160405180910390fd5b6000611b08836118fe565b90506000611b14613a3e565b6001600160a01b038381166000908152600a602090815260409182902080546001810190915582517f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad81840152938a168484015260608085018a9052608085019190915287013560a0808501919091528251808503909101815260c084019092528151910120611ba7929160e001615370565b604051602081830303815290604052805190602001209050611bd581838580360381019061138c919061538b565b611bdf8585613703565b5050505050565b611bee6134de565b60405163334ce6f160e21b81527328ce33b49ec8836aa6f0199cf764b82b9bedb5ea9063cd339bc490611a1990339088908890889088907f00000000000000000000000051063d3a1c677b6b02fa2b478799f9d160894ccb9060149060139060040161547e565b60008581526014602090815260408083208784529091529020600501546001600160a01b0316338114611c9b5760405163c6d1651b60e01b815260040160405180910390fd5b604080516001600160a01b03858116825284166020820152428183015290518591879189917f68edb7ec2c37d21b3b72233960b487f2966f4ac82b7430d39f24d1f8d6f99106919081900360600190a4505050505050565b6001600160a01b038316611d1a576040516307eb16dd60e21b815260040160405180910390fd5b6000611d24613a3e565b6001600160a01b038681166000818152600a602090815260409182902080546001810190915582517f47ab88482c90e4bb94b82a947ae78fa91fb25de1469ab491f4c15b9a0a2677ee9281019290925291810192909252918716606080830191909152861515608083015260a08201929092529084013560c082015260e00160405160208183030381529060405280519060200120604051602001611dca929190615370565b604051602081830303815290604052805190602001209050611df881868480360381019061138c919061538b565b611bdf858585613de9565b611e0b6134de565b6000611e1a60408301836154cc565b90506001600160401b03811115611e3357611e33614ec5565b604051908082528060200260200182016040528015611e5c578160200160208202803683370190505b50905060005b611e6f60408401846154cc565b9050811015611eec57611e8560408401846154cc565b82818110611e9557611e95615468565b9050602002810190611ea7919061532a565b604051611eb59291906152c9565b6040518091039020828281518110611ecf57611ecf615468565b602090810291909101015280611ee48161552b565b915050611e62565b506000611ef7613a3e565b7ffb6b7f1cd1b38daf3822aff0abbe78124db5d62a4748bcff007c15ccd6d30bc5611f2560208601866154cc565b604051602001611f36929190615546565b6040516020818303038152906040528051906020012084604051602001611f5d9190615572565b60405160208183030381529060405280519060200120600a6000886000016020810190611f8a9190614a8f565b6001600160a01b0316815260208082019290925260409081016000208054600181019091558151928301959095528101929092526060820152608081019190915260c08581013560a08301520160405160208183030381529060405280519060200120604051602001611ffe929190615370565b60408051601f198184030181529190528051602091820120915061203c90829061202a90860186614a8f565b61138c3687900387016060880161538b565b7328ce33b49ec8836aa6f0199cf764b82b9bedb5ea63bccbaefd6120636020860186614a8f565b61207060208701876154cc565b61207d60408901896154cc565b7f000000000000000000000000b7141ba444bef189cdf8cef52f8dabab3bfcfb69601360126040518963ffffffff1660e01b81526004016114039897969594939291906155ed565b6120cd613bb7565b60006120d982356118fe565b905060006120e5613a3e565b7f64f4578fc098f96a2450fbe601cb8c5318ebeb2ff72d2031a36be1ff6932d5ee8435602086013560408701356121226080890160608a01614a8f565b61212f60808a018a61532a565b60405161213d9291906152c9565b604080519182900382206001600160a01b038b166000908152600a60209081529290208054600181019091556121bd989796959493919290916101008e013591019788526020880196909652604087019490945260608601929092526001600160a01b0316608085015260a084015260c083015260e08201526101000190565b604051602081830303815290604052805190602001206040516020016121e4929190615370565b60405160208183030381529060405280519060200120905061221581838560a00180360381019061138c919061538b565b610c198335602085013560408601356122346080880160608901614a8f565b6119b3608089018961532a565b606060018054610c2d90615294565b612258613bb7565b6122628135613518565b61175c8135612274602084018461532a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506122b9925050506060850160408601614a8f565b6122c6606086018661532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061230b9250505060a0870160808801614a8f565b61168a60a088018861532a565b6123206134de565b600061232c82356118fe565b90506000612338613a3e565b7f5b9860bd835e648945b22d053515bc1f53b7d9fab4b23b1b49db15722e945d148435612368602087018761532a565b6040516123769291906152c9565b604080519182900382206001600160a01b0388166000908152600a60209081529083902080546001810190915590840195909552908201929092526060810191909152608081019190915260a0858101359082015260c001604051602081830303815290604052805190602001206040516020016123f5929190615370565b60405160208183030381529060405280519060200120905061242681838560400180360381019061138c919061538b565b610c198335612438602086018661532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061357792505050565b6001600160a01b0382163314156124cb5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610dbf565b6124d6338383613de9565b5050565b6124e2613bb7565b6124ec8135613518565b61175c6124f8826156bf565b613e56565b612505613771565b6001600160a01b0382166000818152600e6020908152604091829020805460ff191685151590811790915591514281529192917f52c5b7889df9f12f84ec3da051e854e5876678370d8357959c23ef59dd6486df9101610f54565b612568613771565b61175c816136aa565b6125796134de565b6000612583613a3e565b7f7f9b4ea1fc678b4fda1611ac5cbd28f339e235d89b1540635e9b2e0223a3c101602084013560408501356125bb606087018761532a565b6040516125c99291906152c9565b604051908190039020600a60006125e360208a018a614a8f565b6001600160a01b0316815260208082019290925260409081016000208054600181019091558151928301969096528101939093526060830191909152608082015260a081019190915260e08481013560c0830152016040516020818303038152906040528051906020012060405160200161265f929190615370565b60408051601f198184030181529190528051602091820120915061269d90829061268b90850185614a8f565b61138c3686900386016080870161538b565b7328ce33b49ec8836aa6f0199cf764b82b9bedb5ea63cd339bc46126c46020850185614a8f565b602085013560408601356126db606088018861532a565b7f00000000000000000000000051063d3a1c677b6b02fa2b478799f9d160894ccb601460136040518963ffffffff1660e01b815260040161272398979695949392919061547e565b60006040518083038186803b15801561273b57600080fd5b505af4158015610d42573d6000803e3d6000fd5b606060008061276085856014613f0e565b506000828152601460209081526040808320848452909152902060020180549294509092509061278f90615294565b80601f01602080910402602001604051908101604052809291908181526020018280546127bb90615294565b80156128085780601f106127dd57610100808354040283529160200191612808565b820191906000526020600020905b8154815290600101906020018083116127eb57829003601f168201915b50505050509250505092915050565b612821338361379c565b61283d5760405162461bcd60e51b8152600401610dbf906152d9565b61284984848484613fd0565b50505050565b6128576134de565b600061286382356118fe565b9050600061286f613a3e565b7fd8d76e8b2b26e1ebe72def13fb559a68561ef064055b0de01f955bc26e25d42f843561289f602087018761532a565b6040516128ad9291906152c9565b604080519182900382206001600160a01b0388166000908152600a60209081529083902080546001810190915590840195909552908201929092526060810191909152608081019190915260a0858101359082015260c0016040516020818303038152906040528051906020012060405160200161292c929190615370565b60405160208183030381529060405280519060200120905061295d81838560400180360381019061138c919061538b565b610c19833561296f602086018661532a565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061400392505050565b6000848152601360205260409020600201546001600160a01b03163381146129e45760405163646785d560e11b815260040160405180910390fd5b604080516001600160a01b0385811682528416602082015242818301529051859187917f4996ad2257e7db44908136c43128cc10ca988096f67dc6bb0bcee11d151368fb9181900360600190a35050505050565b612a406134de565b6000612a4c82356118fe565b90506000612a58613a3e565b7f77ba3e9f5fa75343bbad1241fb539a0064de97694b47d463d1eb5c54aba11f0f8435612a8b6040870160208801614a8f565b6001600160a01b038681166000908152600a602090815260409182902080546001810190915582519182019690965290810193909352166060820152608081019190915260a0858101359082015260c00160405160208183030381529060405280519060200120604051602001612b03929190615370565b604051602081830303815290604052805190602001209050612b3481838560400180360381019061138c919061538b565b610c198335612b496040860160208701614a8f565b61405b565b612b566134de565b612b5f82613daf565b6124d6828261405b565b60408051808201909152600080825260208201526000828152600260205260409020546001600160a01b0316612bf85760405162461bcd60e51b815260206004820152602e60248201527f4552433732313a20746f6b656e206461746120717565727920666f72206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610dbf565b506000908152600260209081526040918290208251808401909352546001600160a01b0381168352600160a01b90046001600160601b03169082015290565b612c3f6134de565b612c4883613518565b610c198383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061400392505050565b612cdc6040518060c0016040528060008152602001600081526020016060815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b6014600084815260200190815260200160002060008381526020019081526020016000206040518060c00160405290816000820154815260200160018201548152602001600282018054612d2f90615294565b80601f0160208091040260200160405190810160405280929190818152602001828054612d5b90615294565b8015612da85780601f10612d7d57610100808354040283529160200191612da8565b820191906000526020600020905b815481529060010190602001808311612d8b57829003601f168201915b505050918352505060038201546001600160a01b0390811660208301526004830154811660408301526005909201549091166060909101529392505050565b60008181526013602052604090206004018054606091906111d290615294565b612e0f6134de565b612e1982826140b8565b6124d682613d03565b60008181526013602052604090206003018054606091906111d290615294565b612e4a613bb7565b6000612e5682356118fe565b90506000612e62613a3e565b7fb30910150df56294e05b2d03e181803697a2b935abb1b9bdddde9310f618fe9b8435612e92602087018761532a565b604051612ea09291906152c9565b604051809103902086604001358760600135886080016020810190612ec59190614a8f565b612ed260a08b018b61532a565b604051612ee09291906152c9565b604051908190039020612ef960e08c0160c08d01614a8f565b612f0660e08d018d61532a565b604051612f149291906152c9565b604080519182900382206001600160a01b03808f166000908152600a6020908152908490208054600181019091559085019c909c52918301999099526060820197909752608081019590955260a085019390935290841660c084015260e083015290911661010082015261012081019190915261014081019190915261016080860135908201526101800160405160208183030381529060405280519060200120604051602001612fc6929190615370565b604051602081830303815290604052805190602001209050612ff88183856101000180360381019061138c919061538b565b610c1960405180610100016040528085600001358152602001858060200190613021919061532a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506040808701356020830152606080880135918301919091520161308160a0870160808801614a8f565b6001600160a01b0316815260200161309c60a087018761532a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020016130e660e0870160c08801614a8f565b6001600160a01b0316815260200161310160e087018761532a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250613e56565b6000613146613a3e565b905090565b6131966040518060c001604052806000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016060815260200160608152602001606081525090565b600082815260136020908152604091829020825160c0810184528154815260018201546001600160a01b03908116938201939093526002820154909216928201929092526003820180549192916060840191906131f290615294565b80601f016020809104026020016040519081016040528092919081815260200182805461321e90615294565b801561326b5780601f106132405761010080835404028352916020019161326b565b820191906000526020600020905b81548152906001019060200180831161324e57829003601f168201915b5050505050815260200160048201805461328490615294565b80601f01602080910402602001604051908101604052809291908181526020018280546132b090615294565b80156132fd5780601f106132d2576101008083540402835291602001916132fd565b820191906000526020600020905b8154815290600101906020018083116132e057829003601f168201915b5050505050815260200160058201805461331690615294565b80601f016020809104026020016040519081016040528092919081815260200182805461334290615294565b801561338f5780601f106133645761010080835404028352916020019161338f565b820191906000526020600020905b81548152906001019060200180831161337257829003601f168201915b5050505050815250509050919050565b6133a76134de565b60405163bccbaefd60e01b81527328ce33b49ec8836aa6f0199cf764b82b9bedb5ea9063bccbaefd90611a1990339088908890889088907f000000000000000000000000b7141ba444bef189cdf8cef52f8dabab3bfcfb69906013906012906004016155ed565b6134166134de565b61341e61419e565b600060156000815461342f9061552b565b9182905550905061344c6134466020840184614a8f565b826141ce565b604051633f67a66f60e11b815273bfe82126b2f18918842dbe03d5d81a7b35b6982190637ecf4cde906127239085908590601290601390600e90600401615791565b60006001600160e01b031982166380ac58cd60e01b14806134bf57506001600160e01b03198216635b5e139f60e01b145b80610bc257506301ffc9a760e01b6001600160e01b0319831614610bc2565b6002600c5460ff1660028111156134f7576134f7614a5f565b1415613516576040516313d0ff5960e31b815260040160405180910390fd5b565b613521816118fe565b6001600160a01b0316336001600160a01b03161415801561355957506000818152601160205260409020546001600160a01b03163314155b1561175c5760405163f33ac98f60e01b815260040160405180910390fd5b6000828152601360209081526040909120825161359c9260049092019184019061474d565b50817fd5a5879cad33c830cc1432c1850107029a09c80c60e9bce1ecd08d24880bd46c82426040516135cf929190615888565b60405180910390a25050565b6135e78484848461431f565b7f414cd0b34676984f09a5f76ce9718d4062e50283abe0e7e274a9a5b4e0c99c30848484844260405161361e9594939291906158aa565b60405180910390a150505050565b600c805460ff811691839160ff1916600183600281111561364f5761364f614a5f565b021790555081600281111561366657613666614a5f565b81600281111561367857613678614a5f565b60405142815233907fa2f9a1499fc1f9b7796d21fe5761290ccb7e0ef6ccf35fa58b668f304a62a1ca906020016111a6565b601680546001600160a01b038381166001600160a01b03198316811790935560405191169190829033907fe552a55455b740845a5c07ed445d1724142fc997b389835495a29b30cddc1ccd906111a69042815260200190565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190613738826118fe565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6016546001600160a01b0316331461351657604051632d5be4cb60e21b815260040160405180910390fd5b6000818152600260205260408120546001600160a01b03166138155760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610dbf565b6000613820836118fe565b9050806001600160a01b0316846001600160a01b0316148061385b5750836001600160a01b031661385084610d4a565b6001600160a01b0316145b8061388b57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166138a6826118fe565b6001600160a01b03161461390e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610dbf565b6001600160a01b0382166139705760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610dbf565b61397b838383614338565b613986600082613703565b6001600160a01b03831660009081526003602052604081208054600192906139af9084906158e4565b90915550506001600160a01b03821660009081526003602052604081208054600192906139dd9084906158fb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f613a69610c1e565b80516020918201206040805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b4281606001511015613af857604051630819bdcd60e01b815260040160405180910390fd5b600060018483600001518460200151856040015160405160008152602001604052604051613b42949392919093845260ff9290921660208401526040830152606082015260800190565b6020604051602081039080840390855afa158015613b64573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381161580613b995750826001600160a01b0316816001600160a01b031614155b15612849576040516337e8456b60e01b815260040160405180910390fd5b6002600c5460ff166002811115613bd057613bd0614a5f565b1415613bef576040516313d0ff5960e31b815260040160405180910390fd5b6001600c5460ff166002811115613c0857613c08614a5f565b141561351657604051630f392a3b60e31b815260040160405180910390fd5b73bfe82126b2f18918842dbe03d5d81a7b35b69821639dbf0510878787878787601360008f815260200190815260200160002060000160008154613c6a9061552b565b9190508190556014600f60106040518b63ffffffff1660e01b8152600401613c9b9a99989796959493929190615913565b60006040518083038186803b158015613cb357600080fd5b505af4158015613cc7573d6000803e3d6000fd5b50505050505050505050565b613cdd338261379c565b613cfa57604051636d8a29e760e11b815260040160405180910390fd5b61175c8161436b565b6000818152601360205260408082209051613d21916003019061599a565b604080519182900390912060009081526012602052908120555050565b73bfe82126b2f18918842dbe03d5d81a7b35b69821638588c2ff878787878787601360008f815260200190815260200160002060000160008154613d819061552b565b919050819055601460106040518a63ffffffff1660e01b8152600401613c9b99989796959493929190615a36565b613db8816118fe565b6001600160a01b0316336001600160a01b03161461175c5760405163f194fae560e01b815260040160405180910390fd5b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b805160009081526013602052604090205473bfe82126b2f18918842dbe03d5d81a7b35b698219063e63aa93e908390613e909060016158fb565b60136014600f60106040518763ffffffff1660e01b8152600401613eb996959493929190615a8d565b60006040518083038186803b158015613ed157600080fd5b505af4158015613ee5573d6000803e3d6000fd5b505082516000908152601360205260408120805493509150613f068361552b565b919050555050565b600083815260208281526040808320858452909152812060040154819081906001600160a01b03168015613f49578693508592509050613fc7565b60008781526020868152604080832089845290915290205480613f7f5760405163a43d2a7160e01b815260040160405180910390fd5b6000888152602087815260408083208a84528252808320600101548484528983528184208185529092529091206004015491955093506001600160a01b03169150613fc79050565b93509350939050565b613fdb848484613893565b613fe784848484614407565b6128495760405162461bcd60e51b8152600401610dbf90615b6d565b600082815260136020908152604090912082516140289260059092019184019061474d565b50817fe82886e1af6fcab5caef13815b22f51384e970c367a785f265d13860a7d6966d82426040516135cf929190615888565b60008281526011602090815260409182902080546001600160a01b0319166001600160a01b038516908117909155915142815284917f22baaec4952f35f59e45bd2ddb287e1ccc6d319375770c09428eb8f8d604e0659101610f54565b60006140c3836118fe565b905060006140cf613a3e565b6001600160a01b0383166000908152600a60209081526040918290208054600181019091559151614140927f108ccda6d7331b00561a3eea66a2ae331622356585681c62731e4a01aae2261a92899260608a0135910193845260208401929092526040830152606082015260800190565b60405160208183030381529060405280519060200120604051602001614167929190615370565b60405160208183030381529060405280519060200120905061419581838580360381019061138c919061538b565b6128498461436b565b336000908152600d602052604090205460ff166135165760405163561a858760e01b815260040160405180910390fd5b6001600160a01b0382166142245760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610dbf565b6000818152600260205260409020546001600160a01b0316156142895760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610dbf565b61429560008383614338565b6001600160a01b03821660009081526003602052604081208054600192906142be9084906158fb565b90915550506000818152600260205260408082206001600160a01b038516600160a01b426001600160601b031602811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b61432b600085856147d1565b50611bdf600183836147d1565b6000818152601160205260409020546001600160a01b0316156143605761436081600061405b565b610c19838383614505565b6000614376826118fe565b905061438481600084614338565b61438f600083613703565b6001600160a01b03811660009081526003602052604081208054600192906143b89084906158e4565b9091555050600082815260026020526040808220829055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60006001600160a01b0384163b156144fa57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061444b903390899088908890600401615bbf565b6020604051808303816000875af1925050508015614486575060408051601f3d908101601f1916820190925261448391810190615bfc565b60015b6144e0573d8080156144b4576040519150601f19603f3d011682016040523d82523d6000602084013e6144b9565b606091505b5080516144d85760405162461bcd60e51b8152600401610dbf90615b6d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061388b565b506001949350505050565b6001600160a01b0383166145605761455b81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b614583565b816001600160a01b0316836001600160a01b0316146145835761458383826145bd565b6001600160a01b03821661459a57610c198161465a565b826001600160a01b0316826001600160a01b031614610c1957610c198282614709565b600060016145ca84611a4f565b6145d491906158e4565b600083815260076020526040902054909150808214614627576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061466c906001906158e4565b6000838152600960205260408120546008805493945090928490811061469457614694615468565b9060005260206000200154905080600883815481106146b5576146b5615468565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806146ed576146ed615c19565b6001900381819060005260206000200160009055905550505050565b600061471483611a4f565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b82805461475990615294565b90600052602060002090601f01602090048101928261477b57600085556147c1565b82601f1061479457805160ff19168380011785556147c1565b828001600101855582156147c1579182015b828111156147c15782518255916020019190600101906147a6565b506147cd929150614845565b5090565b8280546147dd90615294565b90600052602060002090601f0160209004810192826147ff57600085556147c1565b82601f106148185782800160ff198235161785556147c1565b828001600101855582156147c1579182015b828111156147c157823582559160200191906001019061482a565b5b808211156147cd5760008155600101614846565b6001600160e01b03198116811461175c57600080fd5b60006020828403121561488257600080fd5b813561488d8161485a565b9392505050565b60008083601f8401126148a657600080fd5b5081356001600160401b038111156148bd57600080fd5b6020830191508360208285010111156118f757600080fd5b6000806000604084860312156148ea57600080fd5b8335925060208401356001600160401b0381111561490757600080fd5b61491386828701614894565b9497909650939450505050565b6000815180845260005b818110156149465760208185018101518683018201520161492a565b81811115614958576000602083870101525b50601f01601f19169290920160200192915050565b60208152600061488d6020830184614920565b80356001600160a01b038116811461499757600080fd5b919050565b6000806000806000606086880312156149b457600080fd5b85356001600160401b03808211156149cb57600080fd5b6149d789838a01614894565b909750955060208801359150808211156149f057600080fd5b506149fd88828901614894565b9094509250614a10905060408701614980565b90509295509295909350565b600060208284031215614a2e57600080fd5b5035919050565b60008060408385031215614a4857600080fd5b614a5183614980565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6020810160038310614a8957614a89614a5f565b91905290565b600060208284031215614aa157600080fd5b61488d82614980565b8035801515811461499757600080fd5b60008060408385031215614acd57600080fd5b614ad683614980565b9150614ae460208401614aaa565b90509250929050565b60008060208385031215614b0057600080fd5b82356001600160401b03811115614b1657600080fd5b614b2285828601614894565b90969095509350505050565b600080600060608486031215614b4357600080fd5b614b4c84614980565b9250614b5a60208501614980565b9150604084013590509250925092565b60008060408385031215614b7d57600080fd5b50508035926020909101359150565b6020810160048310614a8957614a89614a5f565b600060e08284031215614bb257600080fd5b50919050565b600060208284031215614bca57600080fd5b81356001600160401b03811115614be057600080fd5b61388b84828501614ba0565b600060208284031215614bfe57600080fd5b81356001600160401b03811115614c1457600080fd5b8201610140818503121561488d57600080fd5b600060208284031215614c3957600080fd5b81356003811061488d57600080fd5b600060208284031215614c5a57600080fd5b81356001600160401b03811115614c7057600080fd5b820160a0818503121561488d57600080fd5b60008060008060608587031215614c9857600080fd5b84359350614ca860208601614980565b925060408501356001600160401b03811115614cc357600080fd5b614ccf87828801614894565b95989497509550505050565b600060808284031215614bb257600080fd5b600080600060c08486031215614d0257600080fd5b614d0b84614980565b925060208401359150614d218560408601614cdb565b90509250925092565b60008060008060608587031215614d4057600080fd5b843593506020850135925060408501356001600160401b03811115614cc357600080fd5b600080600080600060a08688031215614d7c57600080fd5b853594506020860135935060408601359250614d9a60608701614980565b9150614a1060808701614980565b60008060008060e08587031215614dbe57600080fd5b614dc785614980565b9350614dd560208601614980565b9250614de360408601614aaa565b9150614df28660608701614cdb565b905092959194509250565b600060208284031215614e0f57600080fd5b81356001600160401b03811115614e2557600080fd5b8201610120818503121561488d57600080fd5b600060c08284031215614bb257600080fd5b600060208284031215614e5c57600080fd5b81356001600160401b03811115614e7257600080fd5b61388b84828501614e38565b60006101008284031215614bb257600080fd5b600060208284031215614ea357600080fd5b81356001600160401b03811115614eb957600080fd5b61388b84828501614e7e565b634e487b7160e01b600052604160045260246000fd5b60405161010081016001600160401b0381118282101715614efe57614efe614ec5565b60405290565b600082601f830112614f1557600080fd5b81356001600160401b0380821115614f2f57614f2f614ec5565b604051601f8301601f19908116603f01168101908282118183101715614f5757614f57614ec5565b81604052838152866020858801011115614f7057600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215614fa657600080fd5b614faf85614980565b9350614fbd60208601614980565b92506040850135915060608501356001600160401b03811115614fdf57600080fd5b614feb87828801614f04565b91505092959194509250565b6000806000806080858703121561500d57600080fd5b843593506020850135925061502460408601614980565b9150614df260608601614980565b600060c0828403121561504457600080fd5b61488d8383614e38565b6000806040838503121561506157600080fd5b82359150614ae460208401614980565b6020815281516020820152602082015160408201526000604083015160c060608401526150a160e0840182614920565b9050606084015160018060a01b0380821660808601528060808701511660a08601528060a08701511660c086015250508091505092915050565b60008060a083850312156150ee57600080fd5b82359150614ae48460208501614cdb565b6000806040838503121561511257600080fd5b61511b83614980565b9150614ae460208401614980565b60006020828403121561513b57600080fd5b81356001600160401b0381111561515157600080fd5b8201610180818503121561488d57600080fd5b60208152815160208201526000602083015160018060a01b0380821660408501528060408601511660608501525050606083015160c060808401526151ac60e0840182614920565b90506080840151601f19808584030160a08601526151ca8383614920565b925060a08601519150808584030160c0860152506151e88282614920565b95945050505050565b60008083601f84011261520357600080fd5b5081356001600160401b0381111561521a57600080fd5b6020830191508360208260051b85010111156118f757600080fd5b6000806000806040858703121561524b57600080fd5b84356001600160401b038082111561526257600080fd5b61526e888389016151f1565b9096509450602087013591508082111561528757600080fd5b50614ccf878288016151f1565b600181811c908216806152a857607f821691505b60208210811415614bb257634e487b7160e01b600052602260045260246000fd5b8183823760009101908152919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000808335601e1984360301811261534157600080fd5b8301803591506001600160401b0382111561535b57600080fd5b6020019150368190038213156118f757600080fd5b61190160f01b81526002810192909252602282015260420190565b60006080828403121561539d57600080fd5b604051608081018181106001600160401b03821117156153bf576153bf614ec5565b604052823560ff811681146153d357600080fd5b808252506020830135602082015260408301356040820152606083013560608201528091505092915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8681526001600160a01b038616602082015260a06040820181905260009061545390830186886153ff565b60608301949094525060800152949350505050565b634e487b7160e01b600052603260045260246000fd5b600060018060a01b03808b16835289602084015288604084015260e060608401526154ad60e08401888a6153ff565b951660808301525060a081019290925260c09091015295945050505050565b6000808335601e198436030181126154e357600080fd5b8301803591506001600160401b038211156154fd57600080fd5b6020019150600581901b36038213156118f757600080fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561553f5761553f615515565b5060010190565b60006001600160fb1b0383111561555c57600080fd5b8260051b80858437600092019182525092915050565b815160009082906020808601845b8381101561559c57815185529382019390820190600101615580565b50929695505050505050565b6000808335601e198436030181126155bf57600080fd5b83016020810192503590506001600160401b038111156155de57600080fd5b8036038313156118f757600080fd5b6001600160a01b038916815260c060208083018290529082018890526000906001600160fb1b0389111561562057600080fd5b8860051b808b60e0860137830183810360e090810160408601528101889052600588901b81016101009081019082018a60005b8b81101561568d5784840360ff1901835261566e828e6155a8565b6156798682846153ff565b955050509185019190850190600101615653565b5050506001600160a01b038816606086015292506156a9915050565b608082019390935260a001529695505050505050565b600061010082360312156156d257600080fd5b6156da614edb565b8235815260208301356001600160401b03808211156156f857600080fd5b61570436838701614f04565b6020840152604085013560408401526060850135606084015261572960808601614980565b608084015260a085013591508082111561574257600080fd5b61574e36838701614f04565b60a084015261575f60c08601614980565b60c084015260e085013591508082111561577857600080fd5b5061578536828601614f04565b60e08301525092915050565b60a0815260006001600160a01b03806157a989614980565b1660a08401526157bc60208901896155a8565b60c0808601526157d1610160860182846153ff565b9150506157e160408a018a6155a8565b609f19808785030160e08801526157f98483856153ff565b93508461580860608e01614980565b1661010088015261581c60808d018d6155a8565b9550925080878503016101208801526158368486856153ff565b945061584560a08d018d6155a8565b94509250808786030161014088015250506158618383836153ff565b93505050508560208301528460408301528360608301528260808301529695505050505050565b60408152600061589b6040830185614920565b90508260208301529392505050565b6060815260006158be6060830187896153ff565b82810360208401526158d18186886153ff565b9150508260408301529695505050505050565b6000828210156158f6576158f6615515565b500390565b6000821982111561590e5761590e615515565b500190565b60006101408c835280602084015261592d8184018d614920565b6001600160a01b038c811660408601528482036060860152909150615952828c614920565b908a16608085015283810360a0850152905061596e8189614920565b9150508560c08301528460e083015283610100830152826101208301529b9a5050505050505050505050565b600080835481600182811c9150808316806159b657607f831692505b60208084108214156159d657634e487b7160e01b86526022600452602486fd5b8180156159ea57600181146159fb57615a28565b60ff19861689528489019650615a28565b60008a81526020902060005b86811015615a205781548b820152908501908301615a07565b505084890196505b509498975050505050505050565b60006101008b83528a602084015289604084015260018060a01b0389166060840152806080840152615a6b818401888a6153ff565b60a0840196909652505060c081019290925260e0909101529695505050505050565b60c08152865160c0820152600060208801516101008060e0850152615ab66101c0850183614920565b915060408a0151818501525060608901516101208401526080890151615ae86101408501826001600160a01b03169052565b5060a089015160bf198085840301610160860152615b068383614920565b925060c08b01519150615b256101808601836001600160a01b03169052565b60e08b0151915080858403016101a086015250615b428282614920565b602085019990995250505060408101949094526060840192909252608083015260a090910152919050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615bf290830184614920565b9695505050505050565b600060208284031215615c0e57600080fd5b815161488d8161485a565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220f3c0f4b4d18b9b2f5702bef4b47b20167acc083d554e812db0ed8df265fdfba264736f6c634300080a0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000b7141ba444bef189cdf8cef52f8dabab3bfcfb6900000000000000000000000051063d3a1c677b6b02fa2b478799f9d160894ccb

-----Decoded View---------------
Arg [0] : followNFTImpl (address): 0xB7141BA444bEf189Cdf8CeF52F8DaBAB3bFCFB69
Arg [1] : collectNFTImpl (address): 0x51063D3A1c677b6B02FA2b478799F9D160894cCB

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000b7141ba444bef189cdf8cef52f8dabab3bfcfb69
Arg [1] : 00000000000000000000000051063d3a1c677b6b02fa2b478799f9d160894ccb


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.