Contract Address Details

0x14879422c806CE8C4B645fB7aff636A6597158D2

Contract Name
Web3Entry
Creator
0xe01c8d–e085f7 at 0x23bc8d–79fbe0
Balance
0 CSB
Tokens
Fetching tokens...
Transactions
1 Transactions
Transfers
0 Transfers
Gas Used
160,851
Last Balance Update
85529513
Contract name:
Web3Entry




Optimization enabled
true
Compiler version
v0.8.16+commit.07a7930e




Optimization runs
200
Verified at
2023-03-15T09:32:55.603428Z

contracts/Web3Entry.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import {Web3EntryBase} from "./Web3EntryBase.sol";

// solhint-disable-next-line no-empty-blocks
contract Web3Entry is Web3EntryBase {

}
        

contracts/interfaces/ILinkModule4Note.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

interface ILinkModule4Note {
    function initializeLinkModule(
        uint256 characterId,
        uint256 noteId,
        bytes calldata data
    ) external returns (bytes memory);

    function processLink(
        address caller,
        uint256 characterId,
        uint256 noteId,
        bytes calldata data
    ) external;
}
          

contracts/libraries/Events.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

library Events {
    event BaseInitialized(string name, string symbol, uint256 timestamp);

    event Web3EntryInitialized(uint256 timestamp);

    event LinklistNFTInitialized(uint256 timestamp);

    event MintNFTInitialized(uint256 characterId, uint256 noteId, uint256 timestamp);

    event CharacterCreated(
        uint256 indexed characterId,
        address indexed creator,
        address indexed to,
        string handle,
        uint256 timestamp
    );

    event SetPrimaryCharacterId(
        address indexed account,
        uint256 indexed characterId,
        uint256 indexed oldCharacterId
    );

    event SetHandle(address indexed account, uint256 indexed characterId, string newHandle);

    event SetSocialToken(
        address indexed account,
        uint256 indexed characterId,
        address indexed tokenAddress
    );

    event GrantOperatorPermissions(
        uint256 indexed characterId,
        address indexed operator,
        uint256 permissionBitMap
    );

    event GrantOperators4Note(
        uint256 indexed characterId,
        uint256 indexed noteId,
        address[] blocklist,
        address[] allowlist
    );

    event SetCharacterUri(uint256 indexed characterId, string newUri);

    event PostNote(
        uint256 indexed characterId,
        uint256 indexed noteId,
        bytes32 indexed linkKey,
        bytes32 linkItemType,
        bytes data
    );

    event SetNoteUri(uint256 indexed characterId, uint256 noteId, string newUri);

    event DeleteNote(uint256 indexed characterId, uint256 noteId);

    event LockNote(uint256 indexed characterId, uint256 noteId);

    event LinkCharacter(
        address indexed account,
        uint256 indexed fromCharacterId,
        uint256 indexed toCharacterId,
        bytes32 linkType,
        uint256 linklistId
    );

    event UnlinkCharacter(
        address indexed account,
        uint256 indexed fromCharacterId,
        uint256 indexed toCharacterId,
        bytes32 linkType
    );

    event LinkNote(
        uint256 indexed fromCharacterId,
        uint256 indexed toCharacterId,
        uint256 indexed toNoteId,
        bytes32 linkType,
        uint256 linklistId
    );

    event UnlinkNote(
        uint256 indexed fromCharacterId,
        uint256 indexed toCharacterId,
        uint256 indexed toNoteId,
        bytes32 linkType,
        uint256 linklistId
    );

    event LinkERC721(
        uint256 indexed fromCharacterId,
        address indexed tokenAddress,
        uint256 indexed toNoteId,
        bytes32 linkType,
        uint256 linklistId
    );

    event LinkAddress(
        uint256 indexed fromCharacterId,
        address indexed ethAddress,
        bytes32 linkType,
        uint256 linklistId
    );

    event UnlinkAddress(
        uint256 indexed fromCharacterId,
        address indexed ethAddress,
        bytes32 linkType
    );

    event LinkAnyUri(
        uint256 indexed fromCharacterId,
        string toUri,
        bytes32 linkType,
        uint256 linklistId
    );

    event UnlinkAnyUri(uint256 indexed fromCharacterId, string toUri, bytes32 linkType);

    event LinkCharacterLink(
        uint256 indexed fromCharacterId,
        bytes32 indexed linkType,
        uint256 clFromCharacterId,
        uint256 clToCharacterId,
        bytes32 clLinkType
    );

    event UnlinkCharacterLink(
        uint256 indexed fromCharacterId,
        bytes32 indexed linkType,
        uint256 clFromCharactereId,
        uint256 clToCharacterId,
        bytes32 clLinkType
    );

    event UnlinkERC721(
        uint256 indexed fromCharacterId,
        address indexed tokenAddress,
        uint256 indexed toNoteId,
        bytes32 linkType,
        uint256 linklistId
    );

    event LinkLinklist(
        uint256 indexed fromCharacterId,
        uint256 indexed toLinklistId,
        bytes32 linkType,
        uint256 indexed linklistId
    );

    event UnlinkLinklist(
        uint256 indexed fromCharacterId,
        uint256 indexed toLinklistId,
        bytes32 linkType,
        uint256 indexed linklistId
    );

    event MintNote(
        address indexed to,
        uint256 indexed characterId,
        uint256 indexed noteId,
        address tokenAddress,
        uint256 tokenId
    );

    event SetLinkModule4Character(
        uint256 indexed characterId,
        address indexed linkModule,
        bytes linkModuleInitData,
        bytes returnData
    );

    event SetLinkModule4Note(
        uint256 indexed characterId,
        uint256 indexed noteId,
        address indexed linkModule,
        bytes linkModuleInitData,
        bytes returnData
    );

    event SetLinkModule4Address(
        address indexed account,
        address indexed linkModule,
        bytes linkModuleInitData,
        bytes returnData
    );

    event SetLinkModule4ERC721(
        address indexed tokenAddress,
        uint256 indexed tokenId,
        address indexed linkModule,
        bytes linkModuleInitData,
        bytes returnData
    );

    event SetLinkModule4Linklist(
        uint256 indexed linklistId,
        address indexed linkModule,
        bytes linkModuleInitData,
        bytes returnData
    );

    event SetMintModule4Note(
        uint256 indexed characterId,
        uint256 indexed noteId,
        address indexed mintModule,
        bytes mintModuleInitData,
        bytes returnData
    );

    event AttachLinklist(
        uint256 indexed linklistId,
        uint256 indexed characterId,
        bytes32 indexed linkType
    );

    event DetachLinklist(
        uint256 indexed linklistId,
        uint256 indexed characterId,
        bytes32 indexed linkType
    );

    event SetApprovedMintAmount4Addresses(
        uint256 indexed characterId,
        uint256 indexed noteId,
        uint256 indexed amount,
        address[] approvedAddresses
    );
}
          

@openzeppelin/contracts/utils/Strings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}
          

contracts/interfaces/ILinkModule4Linklist.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

interface ILinkModule4Linklist {
    function initializeLinkModule(
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes memory);

    function processLink(address account, uint256 tokenId, bytes calldata data) external;
}
          

@openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
    }
}
          

contracts/interfaces/IMintModule4Note.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

interface IMintModule4Note {
    /**
     * @notice  Initialize the MintModule for a specific note.
     * @param   characterId  The character ID of the note to initialize.
     * @param   noteId  The note ID to initialize.
     * @param   data  The data passed from the user to be decoded.
     * @return  bytes  The returned data of calling initializeMintModule.
     */
    function initializeMintModule(
        uint256 characterId,
        uint256 noteId,
        bytes calldata data
    ) external returns (bytes memory);

    /**
     * @notice Processes the mint logic. <br>
     * Triggered when the `mintNote` of web3Entry is called, if mint module of note is set.
     * @param   to  The receive address of the NFT.
     * @param   characterId  The character ID of the note owner.
     * @param   noteId  The note ID.
     * @param   data  The data passed from the user to be decoded.
     */
    function processMint(
        address to,
        uint256 characterId,
        uint256 noteId,
        bytes calldata data
    ) external;
}
          

contracts/libraries/OperatorLogic.sol

// SPDX-License-Identifier: MIT
// solhint-disable  private-vars-leading-underscore
pragma solidity 0.8.16;

import {Events} from "./Events.sol";
import {DataTypes} from "./DataTypes.sol";
import {OP} from "./OP.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

library OperatorLogic {
    using EnumerableSet for EnumerableSet.AddressSet;

    /**
     * @notice  Grants permission to a given operator for a character.
     * @param   characterId  The ID of the character to set operator for.
     * @param   operator  The operator address to set.
     * @param   permissionBitMap  The permission bitmap for the operator.
     */
    function grantOperatorPermissions(
        uint256 characterId,
        address operator,
        uint256 permissionBitMap,
        mapping(uint256 => EnumerableSet.AddressSet) storage _operatorsByCharacter,
        mapping(uint256 => mapping(address => uint256)) storage _operatorsPermissionBitMap
    ) external {
        if (permissionBitMap == 0) {
            _operatorsByCharacter[characterId].remove(operator);
        } else {
            _operatorsByCharacter[characterId].add(operator);
        }

        uint256 bitmap = _bitmapFilter(permissionBitMap);
        _operatorsPermissionBitMap[characterId][operator] = bitmap;
        emit Events.GrantOperatorPermissions(characterId, operator, bitmap);
    }

    /**
     @notice Sets blocklist and allowlist for a specific note. Blocklist and allowlist are overwritten every time.
     @param characterId The character ID of the note owner.
     @param noteId The note ID to grant.
     @param blocklist The addresses list of blocked operators.
     @param allowlist The addresses list of allowed operators.
     */
    function grantOperators4Note(
        uint256 characterId,
        uint256 noteId,
        address[] calldata blocklist,
        address[] calldata allowlist,
        mapping(uint256 => mapping(uint256 => DataTypes.Operators4Note)) storage _operators4Note
    ) external {
        DataTypes.Operators4Note storage operators4Note = _operators4Note[characterId][noteId];
        // clear all iterms in blocklist and allowlist first
        _clearOperators4Note(operators4Note);

        // update blocklist and allowlist
        _updateOperators4Note(operators4Note, blocklist, allowlist);

        emit Events.GrantOperators4Note(characterId, noteId, blocklist, allowlist);
    }

    function _clearOperators4Note(DataTypes.Operators4Note storage operators4Note) internal {
        uint256 blocklistLength = operators4Note.blocklist.length();
        for (uint256 i = blocklistLength; i > 0; ) {
            operators4Note.blocklist.remove(operators4Note.blocklist.at(i - 1));
            unchecked {
                i--;
            }
        }

        uint256 allowlistLength = operators4Note.allowlist.length();
        for (uint256 i = allowlistLength; i > 0; ) {
            operators4Note.allowlist.remove(operators4Note.allowlist.at(i - 1));
            unchecked {
                i--;
            }
        }
    }

    function _updateOperators4Note(
        DataTypes.Operators4Note storage operators4Note,
        address[] calldata blocklist,
        address[] calldata allowlist
    ) internal {
        // grant blocklist roles
        for (uint256 i = 0; i < blocklist.length; ) {
            operators4Note.blocklist.add(blocklist[i]);
            unchecked {
                i++;
            }
        }
        for (uint256 i = 0; i < allowlist.length; ) {
            operators4Note.allowlist.add(allowlist[i]);
            unchecked {
                i++;
            }
        }
    }

    /**
     * @dev _bitmapFilter unsets bits of non-existent permission IDs to zero. <br>
     * These unset permission IDs are meaningless now, but they are reserved for future use,
     * so it's best to leave them blank and avoid messing up with future methods.
     */
    function _bitmapFilter(uint256 bitmap) internal pure returns (uint256) {
        return bitmap & OP.ALLOWED_PERMISSION_BITMAP_MASK;
    }
}
          

contracts/interfaces/ILinkModule4Address.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

interface ILinkModule4Address {
    function initializeLinkModule(
        address account,
        bytes calldata data
    ) external returns (bytes memory);

    function processLink(address account, uint256 noteId, bytes calldata data) external;
}
          

contracts/interfaces/IMintNFT.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

interface IMintNFT {
    /**
     * @notice Initialize the mint nft.
     * @param characterId_  The character ID of the note to initialize.
     * @param noteId_  The note ID to initialize.
     * @param web3Entry_  The address of web3Entry contract.
     * @param name_ The name to set for this NFT.
     * @param symbol_ The symbol to set for this NFT.
     */
    function initialize(
        uint256 characterId_,
        uint256 noteId_,
        address web3Entry_,
        string calldata name_,
        string calldata symbol_
    ) external;

    /**
     * @notice Mints a note NFT to the specified address.
     * This can only be called by web3Entry, and is called upon note.
     * @param to The address to mint the NFT to.
     * @return uint256 The minted token ID.
     */
    function mint(address to) external returns (uint256);

    /**
     * @notice Changes the royalty percentage of specific token ID for secondary sales.
     * Can only be called by character owner of note.
     * @param tokenId The token ID to set.
     * @param recipient The receive address.
     * @param fraction The royalty percentage measured in basis points. Each basis point represents 0.01%.
     */
    function setTokenRoyalty(uint256 tokenId, address recipient, uint96 fraction) external;

    /**
     * @notice Changes the default royalty percentage for secondary sales.
     * Can only be called by character owner of note.
     * @param recipient The receive address.
     * @param fraction The royalty percentage measured in basis points. Each basis point represents 0.01%.
     */
    function setDefaultRoyalty(address recipient, uint96 fraction) external;

    /**
     * @notice Deletes the default royalty percentage.
     * Can only be called by character owner of note.
     */
    function deleteDefaultRoyalty() external;

    /**
     * @notice Returns the original receiver of specified NFT.
     * @return The address of original receiver.
     */
    function originalReceiver(uint256 tokenId) external view returns (address);

    /**
     * @notice Returns the source note pointer mapped to this note NFT.
     * @return characterId The character ID.
     * @return noteId The note ID.
     */
    function getSourceNotePointer() external view returns (uint256 characterId, uint256 noteId);
}
          

@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}
          

contracts/interfaces/ILinklist.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

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

interface ILinklist {
    function initialize(
        string calldata name_,
        string calldata symbol_,
        address web3Entry_
    ) external;

    function mint(uint256 characterId, bytes32 linkType) external returns (uint256 tokenId);

    /**
     * @notice  Set URI for a linklist. You can set any URI for your linklist, and the functionality of this URI 
     is undetermined and expandable. One scenario that comes to mind is setting a cover for your liked notes 
     or following list in your bookmarks.
     * @param   tokenId  Linklist ID.
     * @param   newUri  Any URI.
     */
    function setUri(uint256 tokenId, string memory newUri) external;

    /////////////////////////////////
    // linking Character
    /////////////////////////////////
    function addLinkingCharacterId(uint256 tokenId, uint256 toCharacterId) external;

    function removeLinkingCharacterId(uint256 tokenId, uint256 toCharacterId) external;

    /////////////////////////////////
    // linking Note
    /////////////////////////////////
    function addLinkingNote(
        uint256 tokenId,
        uint256 toCharacterId,
        uint256 toNoteId
    ) external returns (bytes32);

    function removeLinkingNote(uint256 tokenId, uint256 toCharacterId, uint256 toNoteId) external;

    /////////////////////////////////
    // linking ERC721
    /////////////////////////////////
    function addLinkingERC721(
        uint256 tokenId,
        address tokenAddress,
        uint256 erc721TokenId
    ) external returns (bytes32);

    function removeLinkingERC721(
        uint256 tokenId,
        address tokenAddress,
        uint256 erc721TokenId
    ) external;

    /////////////////////////////////
    // linking Address
    /////////////////////////////////
    function addLinkingAddress(uint256 tokenId, address ethAddress) external;

    function removeLinkingAddress(uint256 tokenId, address ethAddress) external;

    /////////////////////////////////
    // linking Any
    /////////////////////////////////
    function addLinkingAnyUri(uint256 tokenId, string memory toUri) external returns (bytes32);

    function removeLinkingAnyUri(uint256 tokenId, string memory toUri) external;

    /////////////////////////////////
    // linking Linklist
    /////////////////////////////////
    function addLinkingLinklistId(uint256 tokenId, uint256 linklistId) external;

    function removeLinkingLinklistId(uint256 tokenId, uint256 linklistId) external;

    /////////////////////////////////
    // linking CharacterLink
    /////////////////////////////////
    function addLinkingCharacterLink(
        uint256 tokenId,
        DataTypes.CharacterLinkStruct calldata linkData
    ) external;

    function removeLinkingCharacterLink(
        uint256 tokenId,
        DataTypes.CharacterLinkStruct calldata linkData
    ) external;

    function getLinkingCharacterIds(uint256 tokenId) external view returns (uint256[] memory);

    function getLinkingCharacterListLength(uint256 tokenId) external view returns (uint256);

    function getOwnerCharacterId(uint256 tokenId) external view returns (uint256);

    function getLinkingNotes(
        uint256 tokenId
    ) external view returns (DataTypes.NoteStruct[] memory results);

    function getLinkingNote(bytes32 linkKey) external view returns (DataTypes.NoteStruct memory);

    function getLinkingNoteListLength(uint256 tokenId) external view returns (uint256);

    function getLinkingCharacterLinks(
        uint256 tokenId
    ) external view returns (DataTypes.CharacterLinkStruct[] memory results);

    function getLinkingCharacterLink(
        bytes32 linkKey
    ) external view returns (DataTypes.CharacterLinkStruct memory);

    function getLinkingCharacterLinkListLength(uint256 tokenId) external view returns (uint256);

    function getLinkingERC721s(
        uint256 tokenId
    ) external view returns (DataTypes.ERC721Struct[] memory results);

    function getLinkingERC721(
        bytes32 linkKey
    ) external view returns (DataTypes.ERC721Struct memory);

    function getLinkingERC721ListLength(uint256 tokenId) external view returns (uint256);

    function getLinkingAddresses(uint256 tokenId) external view returns (address[] memory);

    function getLinkingAddressListLength(uint256 tokenId) external view returns (uint256);

    function getLinkingAnyUris(uint256 tokenId) external view returns (string[] memory results);

    function getLinkingAnyUri(bytes32 linkKey) external view returns (string memory);

    function getLinkingAnyUriKeys(uint256 tokenId) external view returns (bytes32[] memory);

    function getLinkingAnyListLength(uint256 tokenId) external view returns (uint256);

    function getLinkingLinklistIds(uint256 tokenId) external view returns (uint256[] memory);

    function getLinkingLinklistLength(uint256 tokenId) external view returns (uint256);

    // NOTE: This function is deprecated.
    function getCurrentTakeOver(uint256 tokenId) external view returns (uint256);

    function getLinkType(uint256 tokenId) external view returns (bytes32);

    // slither-disable-start naming-convention
    // solhint-disable func-name-mixedcase
    function Uri(uint256 tokenId) external view returns (string memory);

    // slither-disable-end naming-convention

    function characterOwnerOf(uint256 tokenId) external view returns (uint256);

    function balanceOf(uint256 characterId) external view returns (uint256);
}
          

contracts/libraries/PostLogic.sol

// SPDX-License-Identifier: MIT
// solhint-disable private-vars-leading-underscore
pragma solidity 0.8.16;

import {DataTypes} from "./DataTypes.sol";
import {Events} from "./Events.sol";
import {ILinkModule4Note} from "../interfaces/ILinkModule4Note.sol";
import {IMintModule4Note} from "../interfaces/IMintModule4Note.sol";
import {IMintNFT} from "../interfaces/IMintNFT.sol";
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";

library PostLogic {
    using Strings for uint256;

    function postNoteWithLink(
        DataTypes.PostNoteData calldata vars,
        uint256 noteId,
        bytes32 linkItemType,
        bytes32 linkKey,
        bytes calldata data,
        mapping(uint256 => mapping(uint256 => DataTypes.Note)) storage _noteByIdByCharacter
    ) external {
        uint256 characterId = vars.characterId;
        DataTypes.Note storage note = _noteByIdByCharacter[characterId][noteId];

        // save note
        note.contentUri = vars.contentUri;
        if (linkItemType != bytes32(0)) {
            note.linkItemType = linkItemType;
            note.linkKey = linkKey;
        }

        // init link module
        if (vars.linkModule != address(0)) {
            note.linkModule = vars.linkModule;

            bytes memory linkModuleReturnData = ILinkModule4Note(vars.linkModule)
                .initializeLinkModule(characterId, noteId, vars.linkModuleInitData);

            emit Events.SetLinkModule4Note(
                characterId,
                noteId,
                vars.linkModule,
                vars.linkModuleInitData,
                linkModuleReturnData
            );
        }

        // init mint module
        if (vars.mintModule != address(0)) {
            note.mintModule = vars.mintModule;

            bytes memory mintModuleReturnData = IMintModule4Note(vars.mintModule)
                .initializeMintModule(characterId, noteId, vars.mintModuleInitData);

            emit Events.SetMintModule4Note(
                characterId,
                noteId,
                vars.mintModule,
                vars.mintModuleInitData,
                mintModuleReturnData
            );
        }

        emit Events.PostNote(characterId, noteId, linkKey, linkItemType, data);
    }

    function mintNote(
        uint256 characterId,
        uint256 noteId,
        address to,
        bytes calldata mintModuleData,
        address mintNFTImpl,
        mapping(uint256 => mapping(uint256 => DataTypes.Note)) storage _noteByIdByCharacter
    ) external returns (uint256 tokenId) {
        DataTypes.Note storage note = _noteByIdByCharacter[characterId][noteId];
        address mintNFT = note.mintNFT;
        if (mintNFT == address(0)) {
            mintNFT = _deployMintNFT(characterId, noteId, mintNFTImpl);
            note.mintNFT = mintNFT;
        }

        // mint nft
        tokenId = IMintNFT(mintNFT).mint(to);

        address mintModule = note.mintModule;
        if (mintModule != address(0)) {
            IMintModule4Note(mintModule).processMint(to, characterId, noteId, mintModuleData);
        }

        emit Events.MintNote(to, characterId, noteId, mintNFT, tokenId);
    }

    function setNoteUri(
        uint256 characterId,
        uint256 noteId,
        string calldata newUri,
        mapping(uint256 => mapping(uint256 => DataTypes.Note)) storage _noteByIdByCharacter
    ) external {
        _noteByIdByCharacter[characterId][noteId].contentUri = newUri;

        emit Events.SetNoteUri(characterId, noteId, newUri);
    }

    function _deployMintNFT(
        uint256 characterId,
        uint256 noteId,
        address mintNFTImpl
    ) internal returns (address mintNFT) {
        string memory symbol = string.concat(
            "Note-",
            characterId.toString(),
            "-",
            noteId.toString()
        );

        // deploy nft contract
        mintNFT = Clones.clone(mintNFTImpl);
        // initialize nft
        IMintNFT(mintNFT).initialize(characterId, noteId, address(this), symbol, symbol);
    }
}
          

@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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);

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

@openzeppelin/contracts/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/Address.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}
          

@openzeppelin/contracts/token/ERC721/IERC721.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
          

@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
          

@openzeppelin/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
          

contracts/libraries/Error.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

/// @dev Character ID not exists
error ErrCharacterNotExists(uint256 characterId);

/// @dev Not owner of address
error ErrNotAddressOwner();

/// @dev Caller is not the owner of character
error ErrNotCharacterOwner();

/// @dev Note has been locked
error ErrNoteLocked();

/// @dev Handle does not exist
error ErrHandleExists();

/// @dev Social token address does not exist
error ErrSocialTokenExists();

/// @dev Handle length too long or too short
error ErrHandleLengthInvalid();

/// @dev Handle contains invalid characters
error ErrHandleContainsInvalidCharacters();

/// @dev  Operator has not enough permission for this character
error ErrNotEnoughPermission();

/// @dev Operator has not enough permissions for this note
error ErrNotEnoughPermissionForThisNote();

/// @dev Target address already has primary character
error ErrTargetAlreadyHasPrimaryCharacter();

/// @dev Note has been deleted
error ErrNoteIsDeleted();

/// @dev Note does not exist
error ErrNoteNotExists();

/// @dev Array length mismatch
error ErrArrayLengthMismatch();

/// @dev Caller is not web3Entry contract
error ErrCallerNotWeb3Entry();

/// @dev Caller is not web3Entry contract, and not the owner of character
error ErrCallerNotWeb3EntryOrNotOwner();

/// @dev Token id already exists
error ErrTokenIdAlreadyExists();

/// @dev Character does not exist
error ErrNotExistingCharacter();

/// @dev Token id of linklist does not exist
error ErrNotExistingLinklistToken();

/// @dev Invalid web3Entry address
error ErrInvalidWeb3Entry();

/// @dev Not approved by module
error ErrNotApproved();
          

contracts/base/ERC721Enumerable.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

import {
    IERC721Enumerable
} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import {ERC721} from "./ERC721.sol";
import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.sol";

abstract contract ERC721Enumerable is ERC721, 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, ERC721) 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 < ERC721.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 = ERC721.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 = ERC721.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();
    }
}
          

contracts/libraries/LinkLogic.sol

// SPDX-License-Identifier: MIT
// solhint-disable  private-vars-leading-underscore
pragma solidity 0.8.16;

import {Events} from "./Events.sol";
import {DataTypes} from "./DataTypes.sol";
import {ILinklist} from "../interfaces/ILinklist.sol";
import {ILinkModule4Character} from "../interfaces/ILinkModule4Character.sol";
import {ILinkModule4Note} from "../interfaces/ILinkModule4Note.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

library LinkLogic {
    using EnumerableSet for EnumerableSet.Bytes32Set;

    /**
     * @notice  Links any characterId.
     * @param   fromCharacterId  The character ID to sponsor a link action.
     * @param   toCharacterId  The character ID to be linked.
     * @param   linkType  linkType, like “follow”.
     * @param   data  The data to pass to the link module, if any.
     * @param   linklist  The linklist contract address.
     * @param   linkModule  The linkModule address of the character to link.
     */
    function linkCharacter(
        uint256 fromCharacterId,
        uint256 toCharacterId,
        bytes32 linkType,
        bytes memory data,
        address linklist,
        address linkModule,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) external {
        address linker = IERC721(address(this)).ownerOf(fromCharacterId);
        uint256 linklistId = _mintLinklist(fromCharacterId, linkType, linklist, _attachedLinklists);

        // add to link list
        ILinklist(linklist).addLinkingCharacterId(linklistId, toCharacterId);

        // process link module
        if (linkModule != address(0)) {
            try
                ILinkModule4Character(linkModule).processLink(linker, toCharacterId, data)
            {} catch {} // solhint-disable-line no-empty-blocks
        }

        emit Events.LinkCharacter(linker, fromCharacterId, toCharacterId, linkType, linklistId);
    }

    /**
     * @notice  Unlinks a given character.
     * @param   fromCharacterId  The character ID to sponsor a unlink action.
     * @param   toCharacterId  The character ID to be unlinked.
     * @param   linkType  linkType, like “follow”.
     * @param   linklist  The linklist contract address.
     * @param   linklistId  The ID of the linklist to unlink.
     */
    function unlinkCharacter(
        uint256 fromCharacterId,
        uint256 toCharacterId,
        bytes32 linkType,
        address linklist,
        uint256 linklistId
    ) external {
        address linker = IERC721(address(this)).ownerOf(fromCharacterId);
        // remove from link list
        ILinklist(linklist).removeLinkingCharacterId(linklistId, toCharacterId);

        emit Events.UnlinkCharacter(linker, fromCharacterId, toCharacterId, linkType);
    }

    /**
     * @notice  Links a given note.
     * @param   fromCharacterId  The character ID to sponsor a link action.
     * @param   toCharacterId  The owner characterId of the note to link.
     * @param   toNoteId  The id of the note to link.
     * @param   linkType  The linkType, like “follow”.
     * @param   data  The data to pass to the link module, if any.
     * @param   linklist  The linklist contract address.
     * @param   linkModule  The linkModule address of the note to link
     */
    function linkNote(
        uint256 fromCharacterId,
        uint256 toCharacterId,
        uint256 toNoteId,
        bytes32 linkType,
        bytes calldata data,
        address linklist,
        address linkModule,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) external {
        address linker = IERC721(address(this)).ownerOf(fromCharacterId);
        uint256 linklistId = _mintLinklist(fromCharacterId, linkType, linklist, _attachedLinklists);

        // add to link list
        ILinklist(linklist).addLinkingNote(linklistId, toCharacterId, toNoteId);

        // process link
        if (linkModule != address(0)) {
            try
                ILinkModule4Note(linkModule).processLink(linker, toCharacterId, toNoteId, data)
            {} catch {} // solhint-disable-line no-empty-blocks
        }

        emit Events.LinkNote(fromCharacterId, toCharacterId, toNoteId, linkType, linklistId);
    }

    /**
     * @notice  Unlinks a given note.
     * @param   fromCharacterId  The character ID to sponsor an unlink action.
     * @param   toCharacterId  The character ID of note to unlink.
     * @param   toNoteId  The id of note to unlink.
     * @param   linkType  LinkType, like “follow”.
     * @param   linklist  The linklist contract address.
     */
    function unlinkNote(
        uint256 fromCharacterId,
        uint256 toCharacterId,
        uint256 toNoteId,
        bytes32 linkType,
        address linklist,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) external {
        // do note check note
        // _validateNoteExists(vars.toCharacterId, vars.toNoteId);

        uint256 linklistId = _attachedLinklists[fromCharacterId][linkType];

        // remove from link list
        ILinklist(linklist).removeLinkingNote(linklistId, toCharacterId, toNoteId);

        emit Events.UnlinkNote(fromCharacterId, toCharacterId, toNoteId, linkType, linklistId);
    }

    /**
     * @notice  Links a characterLink.
     * @param   fromCharacterId  The from character ID of characterLink.
     * @param   toCharacterId  The to character ID of characterLink.
     * @param   linkType  The linkType of characterLink.
     * @param   linklist  The linklist contract address.
     */
    function linkCharacterLink(
        uint256 fromCharacterId,
        uint256 toCharacterId,
        bytes32 linkType,
        address linklist,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) external {
        uint256 linklistId = _mintLinklist(fromCharacterId, linkType, linklist, _attachedLinklists);

        // add to link list
        ILinklist(linklist).addLinkingCharacterLink(
            linklistId,
            DataTypes.CharacterLinkStruct(fromCharacterId, toCharacterId, linkType)
        );

        // event
        emit Events.LinkCharacterLink(
            fromCharacterId,
            linkType,
            fromCharacterId,
            toCharacterId,
            linkType
        );
    }

    /**
     * @notice  Unlinks a characterLink.
     * @param   fromCharacterId  The from character ID of characterLink.
     * @param   toCharacterId  The to character ID of characterLink.
     * @param   linkType  The linkType of characterLink.
     * @param   linklist  The linklist contract address.
     * @param   linklistId  The ID of the linklist to unlink.
     */
    function unlinkCharacterLink(
        uint256 fromCharacterId,
        uint256 toCharacterId,
        bytes32 linkType,
        address linklist,
        uint256 linklistId
    ) external {
        // remove from link list
        ILinklist(linklist).removeLinkingCharacterLink(
            linklistId,
            DataTypes.CharacterLinkStruct(fromCharacterId, toCharacterId, linkType)
        );

        // event
        emit Events.UnlinkCharacterLink(
            fromCharacterId,
            linkType,
            fromCharacterId,
            toCharacterId,
            linkType
        );
    }

    /**
     * @notice  Links a linklist.
     * @param   fromCharacterId  The character ID to sponsor an link action.
     * @param   toLinkListId  The linklist if to link.
     * @param   linkType  LinkType, like “follow”.
     * @param   linklist  The linklist contract address.
     */
    function linkLinklist(
        uint256 fromCharacterId,
        uint256 toLinkListId,
        bytes32 linkType,
        address linklist,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) external {
        uint256 linklistId = _mintLinklist(fromCharacterId, linkType, linklist, _attachedLinklists);

        // add to link list
        ILinklist(linklist).addLinkingLinklistId(linklistId, toLinkListId);

        emit Events.LinkLinklist(fromCharacterId, toLinkListId, linkType, linklistId);
    }

    /**
     * @notice  Unlinks a linklist.
     * @param   fromCharacterId  The character ID to sponsor an unlink action.
     * @param   toLinkListId  The linklist if to unlink.
     * @param   linkType  LinkType, like “follow”.
     * @param   linklist  The linklist contract address.
     * @param   linklistId  The ID of the linklist to unlink.
     */
    function unlinkLinklist(
        uint256 fromCharacterId,
        uint256 toLinkListId,
        bytes32 linkType,
        address linklist,
        uint256 linklistId
    ) external {
        // add to link list
        ILinklist(linklist).removeLinkingLinklistId(linklistId, toLinkListId);

        emit Events.UnlinkLinklist(fromCharacterId, toLinkListId, linkType, linklistId);
    }

    /**
     * @notice  Links an ERC721 token.
     * @param   fromCharacterId  The character ID to sponsor an link action.
     * @param   tokenAddress  The token address of ERC721 to link.
     * @param   tokenId  The token ID of ERC721 to link.
     * @param   linkType  linkType, like “follow”.
     * @param   linklist  The linklist contract address.
     */
    function linkERC721(
        uint256 fromCharacterId,
        address tokenAddress,
        uint256 tokenId,
        bytes32 linkType,
        address linklist,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) external {
        uint256 linklistId = _mintLinklist(fromCharacterId, linkType, linklist, _attachedLinklists);

        // add to link list
        ILinklist(linklist).addLinkingERC721(linklistId, tokenAddress, tokenId);

        emit Events.LinkERC721(fromCharacterId, tokenAddress, tokenId, linkType, linklistId);
    }

    /**
     * @notice  Unlinks an ERC721 token.
     * @param   fromCharacterId  The character ID to sponsor an unlink action.
     * @param   tokenAddress  The token address of ERC721 to unlink.
     * @param   tokenId  The token ID of ERC721 to unlink.
     * @param   linkType  LinkType, like “follow”.
     * @param   linklist  The linklist contract address.
     * @param   linklistId  The ID of the linklist to unlink.
     */
    function unlinkERC721(
        uint256 fromCharacterId,
        address tokenAddress,
        uint256 tokenId,
        bytes32 linkType,
        address linklist,
        uint256 linklistId
    ) external {
        // remove from link list
        ILinklist(linklist).removeLinkingERC721(linklistId, tokenAddress, tokenId);

        emit Events.UnlinkERC721(fromCharacterId, tokenAddress, tokenId, linkType, linklistId);
    }

    /**
     * @notice  Creates a link to a given address.
     * @param   fromCharacterId  The character ID to init the link.
     * @param   ethAddress  The address to link.
     * @param   linkType  LinkType, like “follow”.
     * @param   linklist  The linklist contract address.
     */
    function linkAddress(
        uint256 fromCharacterId,
        address ethAddress,
        bytes32 linkType,
        address linklist,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) external {
        uint256 linklistId = _mintLinklist(fromCharacterId, linkType, linklist, _attachedLinklists);

        // add to link list
        ILinklist(linklist).addLinkingAddress(linklistId, ethAddress);

        emit Events.LinkAddress(fromCharacterId, ethAddress, linkType, linklistId);
    }

    /**
     * @notice  Unlinks a given address.
     * @param   fromCharacterId  The character ID to init the unlink.
     * @param   ethAddress  The address to unlink.
     * @param   linkType  LinkType, like “follow”.
     * @param   linklist  The linklist contract address.
     * @param   linklistId  The ID of the linklist to unlink.
     */
    function unlinkAddress(
        uint256 fromCharacterId,
        address ethAddress,
        bytes32 linkType,
        address linklist,
        uint256 linklistId
    ) external {
        // remove from link list
        ILinklist(linklist).removeLinkingAddress(linklistId, ethAddress);

        emit Events.UnlinkAddress(fromCharacterId, ethAddress, linkType);
    }

    /**
     * @notice  Links any uri.
     * @param   fromCharacterId  The character ID to sponsor an link action.
     * @param   toUri  The uri to link.
     * @param   linkType  LinkType, like “follow”.
     * @param   linklist  The linklist contract address.
     */
    function linkAnyUri(
        uint256 fromCharacterId,
        string calldata toUri,
        bytes32 linkType,
        address linklist,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) external {
        uint256 linklistId = _mintLinklist(fromCharacterId, linkType, linklist, _attachedLinklists);

        // add to link list
        ILinklist(linklist).addLinkingAnyUri(linklistId, toUri);

        emit Events.LinkAnyUri(fromCharacterId, toUri, linkType, linklistId);
    }

    /**
     * @notice  Unlinks any uri.
     * @param   fromCharacterId  The character ID to sponsor an unlink action.
     * @param   toUri  The uri to unlink.
     * @param   linkType  LinkType, like “follow”.
     * @param   linklist  The linklist contract address.
     * @param   linklistId  The ID of the linklist to unlink.
     */
    function unlinkAnyUri(
        uint256 fromCharacterId,
        string calldata toUri,
        bytes32 linkType,
        address linklist,
        uint256 linklistId
    ) external {
        // remove from link list
        ILinklist(linklist).removeLinkingAnyUri(linklistId, toUri);

        emit Events.UnlinkAnyUri(fromCharacterId, toUri, linkType);
    }

    /**
     * @notice  Returns the linklistId if the linklist already exists, Otherwise, creates a new 
        linklist and return its ID.
     */
    function _mintLinklist(
        uint256 fromCharacterId,
        bytes32 linkType,
        address linklist,
        mapping(uint256 => mapping(bytes32 => uint256)) storage _attachedLinklists
    ) internal returns (uint256 linklistId) {
        linklistId = _attachedLinklists[fromCharacterId][linkType];
        if (linklistId == 0) {
            // mint linkList nft
            linklistId = ILinklist(linklist).mint(fromCharacterId, linkType);

            // attach linkList
            _attachedLinklists[fromCharacterId][linkType] = linklistId;
            emit Events.AttachLinklist(linklistId, fromCharacterId, linkType);
        }
    }
}
          

@openzeppelin/contracts/utils/Multicall.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)

pragma solidity ^0.8.0;

import "./Address.sol";

/**
 * @dev Provides a function to batch together multiple calls in a single external call.
 *
 * _Available since v4.1._
 */
abstract contract Multicall {
    /**
     * @dev Receives and executes a batch of function calls on this contract.
     */
    function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            results[i] = Address.functionDelegateCall(address(this), data[i]);
        }
        return results;
    }
}
          

contracts/interfaces/IWeb3Entry.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

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

interface IWeb3Entry {
    function initialize(
        string calldata name_,
        string calldata symbol_,
        address linklist_,
        address mintNFTImpl_,
        address periphery_,
        address newbieVilla_
    ) external;

    /**
     * This method creates a character with the given parameters to the given address.
     *
     * @param vars The CreateCharacterData struct containing the following parameters:
     * `to`: The address receiving the character.<br>
     * `handle`: The handle to set for the character.<br>
     * `uri`: The URI to set for the character metadata.<br>
     * `linkModule`: The link module to use, can be the zero address.<br>
     * `linkModuleInitData`: The link module initialization data, if any.<br>
     */
    function createCharacter(
        DataTypes.CreateCharacterData calldata vars
    ) external returns (uint256 characterId);

    /**
     * @notice  Sets new handle for a given character.
     * @dev Owner permission only.
     * @param   characterId  The character id to set new handle for.
     * @param   newHandle  New handle to set.
     */
    function setHandle(uint256 characterId, string calldata newHandle) external;

    /**
     * @notice  Sets a social token for a given character.
     * @dev Owner permission only.
     * @param   characterId  The characterId to set social token for.
     * @param   tokenAddress  Token address to be set.
     */
    function setSocialToken(uint256 characterId, address tokenAddress) external;

    /**
     * @notice  Sets a new URI for a given character.
     * @param   characterId  The characterId to to be set.
     * @param   newUri  New URI to be set.
     */
    function setCharacterUri(uint256 characterId, string calldata newUri) external;

    /**
     * @notice  Sets a given character as primary.
     * @dev Owner permission only.
     * @param   characterId  The character id to to be set.
     */
    function setPrimaryCharacterId(uint256 characterId) external;

    /**
     * @notice Grant an address as an operator and authorize it with custom permissions.
     * @param characterId ID of your character that you want to authorize.
     * @param operator Address to grant operator permissions to.
     * @param permissionBitMap Bitmap used for finer grained operator permissions controls.
     * @dev Every bit in permissionBitMap stands for a corresponding method in Web3Entry. more details in OP.sol.
     */
    function grantOperatorPermissions(
        uint256 characterId,
        address operator,
        uint256 permissionBitMap
    ) external;

    /**
     * @notice Grant operators allowlist and blocklist roles of a note.
     * @param characterId ID of character that you want to set.
     * @param noteId ID of note that you want to set.
     * @param blocklist blocklist addresses that you want to grant.
     * @param allowlist allowlist addresses that you want to grant.
     */
    function grantOperators4Note(
        uint256 characterId,
        uint256 noteId,
        address[] calldata blocklist,
        address[] calldata allowlist
    ) external;

    /**
     * @notice  Sets a new metadataURI for a given link list..
     * @param   linkListId  The linklist id to set for.
     * @param   uri  The metadata uri to set.
     */
    function setLinklistUri(uint256 linkListId, string calldata uri) external;

    function linkAddress(DataTypes.linkAddressData calldata vars) external;

    function unlinkAddress(DataTypes.unlinkAddressData calldata vars) external;

    function linkCharacter(DataTypes.linkCharacterData calldata vars) external;

    function unlinkCharacter(DataTypes.unlinkCharacterData calldata vars) external;

    function createThenLinkCharacter(
        DataTypes.createThenLinkCharacterData calldata vars
    ) external returns (uint256 characterId);

    function linkNote(DataTypes.linkNoteData calldata vars) external;

    function unlinkNote(DataTypes.unlinkNoteData calldata vars) external;

    function linkERC721(DataTypes.linkERC721Data calldata vars) external;

    function unlinkERC721(DataTypes.unlinkERC721Data calldata vars) external;

    function linkAnyUri(DataTypes.linkAnyUriData calldata vars) external;

    function unlinkAnyUri(DataTypes.unlinkAnyUriData calldata vars) external;

    /*
    function linkCharacterLink(
        uint256 fromCharacterId,
        DataTypes.CharacterLinkStruct calldata linkData,
        bytes32 linkType
    ) external;

    function unlinkCharacterLink(
        uint256 fromCharacterId,
        DataTypes.CharacterLinkStruct calldata linkData,
        bytes32 linkType
    ) external;
    */

    function linkLinklist(DataTypes.linkLinklistData calldata vars) external;

    function unlinkLinklist(DataTypes.unlinkLinklistData calldata vars) external;

    /*
     * These functions are temporarily commented out, in order to limit the contract code size within 24K.
     * These functions will be restored when necessary in the future.
     */
    //    function setLinkModule4Character(DataTypes.setLinkModule4CharacterData calldata vars) external;
    //    function setLinkModule4Note(DataTypes.setLinkModule4NoteData calldata vars) external;
    //    function setLinkModule4ERC721(DataTypes.setLinkModule4ERC721Data calldata vars) external;

    function setLinkModule4Linklist(DataTypes.setLinkModule4LinklistData calldata vars) external;

    /**
     * @notice Set linkModule for an address.
     * @dev Operators can't setLinkModule4Address, because this linkModule is for 
     addresses and is irrelevant to characters.
     */
    function setLinkModule4Address(DataTypes.setLinkModule4AddressData calldata vars) external;

    function mintNote(DataTypes.MintNoteData calldata vars) external returns (uint256 tokenId);

    function setMintModule4Note(DataTypes.setMintModule4NoteData calldata vars) external;

    function postNote(
        DataTypes.PostNoteData calldata postNoteData
    ) external returns (uint256 noteId);

    /**
     * @notice  Set URI for a note.
     * @param   characterId  The character ID of the note owner.
     * @param   noteId  The ID of the note to set.
     * @param   newUri  The new URI.
     */
    function setNoteUri(uint256 characterId, uint256 noteId, string calldata newUri) external;

    /**
     * @notice  Lock a note and put it into a immutable state where no modifications are 
     allowed. Locked notes are usually assumed as final versions.
     * @param   characterId  The character ID of the note owner.
     * @param   noteId  The ID of the note to lock.
     */
    function lockNote(uint256 characterId, uint256 noteId) external;

    /**
     * @notice  Delete a note.
     * @dev     Deleting a note doesn't essentially mean that the txs or contents are being removed due to the
      immutability of blockchain itself, but the deleted notes will be tagged as `deleted` after calling `deleteNote`.
     * @param   characterId  The character ID of the note owner.
     * @param   noteId  The ID of the note to delete.
     */
    function deleteNote(uint256 characterId, uint256 noteId) external;

    function postNote4Character(
        DataTypes.PostNoteData calldata vars,
        uint256 toCharacterId
    ) external returns (uint256);

    function postNote4Address(
        DataTypes.PostNoteData calldata vars,
        address ethAddress
    ) external returns (uint256);

    function postNote4Linklist(
        DataTypes.PostNoteData calldata vars,
        uint256 toLinklistId
    ) external returns (uint256);

    function postNote4Note(
        DataTypes.PostNoteData calldata vars,
        DataTypes.NoteStruct calldata note
    ) external returns (uint256);

    function postNote4ERC721(
        DataTypes.PostNoteData calldata vars,
        DataTypes.ERC721Struct calldata erc721
    ) external returns (uint256);

    function postNote4AnyUri(
        DataTypes.PostNoteData calldata vars,
        string calldata uri
    ) external returns (uint256);

    /**
     * @notice Get operator list of a character. This operator list has only a sole purpose, which is
     * keeping records of keys of `operatorsPermissionBitMap`. Thus, addresses queried by this function
     * not always have operator permissions. Keep in mind don't use this function to check
     * authorizations!!!
     * @param characterId ID of your character that you want to check.
     * @return All keys of operatorsPermission4NoteBitMap.
     */
    function getOperators(uint256 characterId) external view returns (address[] memory);

    /**
     * @notice Get permission bitmap of an operator.
     * @param characterId ID of character that you want to check.
     * @param operator Address to grant operator permissions to.
     * @return Permission bitmap of this operator.
     */
    function getOperatorPermissions(
        uint256 characterId,
        address operator
    ) external view returns (uint256);

    /**
     * @notice Get operators blocklist and allowlist for a note.
     * @param characterId ID of character to query.
     * @param noteId ID of note to query.
     */
    function getOperators4Note(
        uint256 characterId,
        uint256 noteId
    ) external view returns (address[] memory blocklist, address[] memory allowlist);

    /**
     * @notice Query if a operator has permission for a note.
     * @param characterId ID of character that you want to query.
     * @param noteId ID of note that you want to query.
     * @param operator Address to query.
     * @return true if Operator has permission for a note, otherwise false.
     */
    function isOperatorAllowedForNote(
        uint256 characterId,
        uint256 noteId,
        address operator
    ) external view returns (bool);

    function getPrimaryCharacterId(address account) external view returns (uint256);

    function isPrimaryCharacter(uint256 characterId) external view returns (bool);

    function getCharacter(uint256 characterId) external view returns (DataTypes.Character memory);

    function getCharacterByHandle(
        string calldata handle
    ) external view returns (DataTypes.Character memory);

    function getHandle(uint256 characterId) external view returns (string memory);

    function getCharacterUri(uint256 characterId) external view returns (string memory);

    function getNote(
        uint256 characterId,
        uint256 noteId
    ) external view returns (DataTypes.Note memory);

    function getLinkModule4Address(address account) external view returns (address);

    function getLinkModule4Linklist(uint256 tokenId) external view returns (address);

    function getLinkModule4ERC721(
        address tokenAddress,
        uint256 tokenId
    ) external view returns (address);

    function getLinklistUri(uint256 tokenId) external view returns (string memory);

    function getLinklistId(uint256 characterId, bytes32 linkType) external view returns (uint256);

    function getLinklistType(uint256 linkListId) external view returns (bytes32);

    function getLinklistContract() external view returns (address);

    function getRevision() external pure returns (uint256);
}
          

contracts/interfaces/ILinkModule4Character.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

interface ILinkModule4Character {
    function initializeLinkModule(
        uint256 characterId,
        bytes calldata data
    ) external returns (bytes memory);

    function processLink(address caller, uint256 characterId, bytes calldata data) external;
}
          

@openzeppelin/contracts/interfaces/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)

pragma solidity ^0.8.0;

import "../utils/introspection/IERC165.sol";
          

@openzeppelin/contracts/utils/math/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}
          

contracts/libraries/CharacterLogic.sol

// SPDX-License-Identifier: MIT
// solhint-disable  private-vars-leading-underscore
pragma solidity 0.8.16;

import {DataTypes} from "./DataTypes.sol";
import {Events} from "./Events.sol";
import {ILinkModule4Character} from "../interfaces/ILinkModule4Character.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

library CharacterLogic {
    using EnumerableSet for EnumerableSet.Bytes32Set;

    /**
     * @notice  Creates a character.
     * @param   to  The address to mint the character to.
     * @param   handle  The handle to set for the new character.
     * @param   uri  The URI to set for the new character’s metadata.
     * @param   linkModule  The link module to set for the new character or the zero address.
     * @param   linkModuleInitData  Arbitrary data to be decoded in the link module for initialization.
     * @param   characterId The ID of the new character.
     */
    function createCharacter(
        address to,
        string memory handle,
        string memory uri,
        address linkModule,
        bytes memory linkModuleInitData,
        uint256 characterId,
        mapping(bytes32 => uint256) storage _characterIdByHandleHash,
        mapping(uint256 => DataTypes.Character) storage _characterById
    ) external {
        bytes32 handleHash = keccak256(bytes(handle));
        _characterIdByHandleHash[handleHash] = characterId;

        _characterById[characterId].characterId = characterId;
        _characterById[characterId].handle = handle;
        _characterById[characterId].uri = uri;

        // init link module
        if (linkModule != address(0)) {
            _characterById[characterId].linkModule = linkModule;

            ILinkModule4Character(linkModule).initializeLinkModule(characterId, linkModuleInitData);
        }

        emit Events.CharacterCreated(characterId, msg.sender, to, handle, block.timestamp);
    }

    /**
     * @notice  Sets a social token for a given character.
     * @param   characterId  	The character ID to set social token for.
     * @param   tokenAddress  Token address to be set.
     */
    function setSocialToken(
        uint256 characterId,
        address tokenAddress,
        mapping(uint256 => DataTypes.Character) storage _characterById
    ) external {
        _characterById[characterId].socialToken = tokenAddress;

        emit Events.SetSocialToken(msg.sender, characterId, tokenAddress);
    }

    /**
     * @notice  Sets link module for a given character.
     * @param   characterId  The character ID to set link module for.
     * @param   linkModule  The link module to set.
     * @param   linkModuleInitData  The data to pass to the link module for initialization, if any.
     */
    function setCharacterLinkModule(
        uint256 characterId,
        address linkModule,
        bytes calldata linkModuleInitData,
        DataTypes.Character storage _character
    ) external {
        _character.linkModule = linkModule;

        bytes memory returnData = "";
        if (linkModule != address(0)) {
            returnData = ILinkModule4Character(linkModule).initializeLinkModule(
                characterId,
                linkModuleInitData
            );
        }
        emit Events.SetLinkModule4Character(
            characterId,
            linkModule,
            linkModuleInitData,
            returnData
        );
    }

    /**
     * @notice  Sets new handle for a given character.
     * @param   characterId  The character ID to set new handle for.
     * @param   newHandle  New handle to set.
     */
    function setHandle(
        uint256 characterId,
        string calldata newHandle,
        mapping(bytes32 => uint256) storage _characterIdByHandleHash,
        mapping(uint256 => DataTypes.Character) storage _characterById
    ) external {
        // remove old handle
        string memory oldHandle = _characterById[characterId].handle;
        bytes32 oldHandleHash = keccak256(bytes(oldHandle));
        delete _characterIdByHandleHash[oldHandleHash];

        // set new handle
        bytes32 handleHash = keccak256(bytes(newHandle));
        _characterIdByHandleHash[handleHash] = characterId;
        _characterById[characterId].handle = newHandle;

        emit Events.SetHandle(msg.sender, characterId, newHandle);
    }
}
          

contracts/libraries/DataTypes.sol

// SPDX-License-Identifier: MIT
// solhint-disable contract-name-camelcase
pragma solidity 0.8.16;

import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

/**
 * @title DataTypes
 * @notice A standard library of data types.
 */
library DataTypes {
    struct MigrateData {
        address account;
        string handle;
        string uri;
        address[] toAddresses;
        bytes32 linkType;
    }

    struct CreateCharacterData {
        address to;
        string handle;
        string uri;
        address linkModule;
        bytes linkModuleInitData;
    }

    struct createThenLinkCharacterData {
        uint256 fromCharacterId;
        address to;
        bytes32 linkType;
    }

    struct linkNoteData {
        uint256 fromCharacterId;
        uint256 toCharacterId;
        uint256 toNoteId;
        bytes32 linkType;
        bytes data;
    }

    struct unlinkNoteData {
        uint256 fromCharacterId;
        uint256 toCharacterId;
        uint256 toNoteId;
        bytes32 linkType;
    }

    struct linkCharacterData {
        uint256 fromCharacterId;
        uint256 toCharacterId;
        bytes32 linkType;
        bytes data;
    }

    struct unlinkCharacterData {
        uint256 fromCharacterId;
        uint256 toCharacterId;
        bytes32 linkType;
    }

    struct linkERC721Data {
        uint256 fromCharacterId;
        address tokenAddress;
        uint256 tokenId;
        bytes32 linkType;
        bytes data;
    }

    struct unlinkERC721Data {
        uint256 fromCharacterId;
        address tokenAddress;
        uint256 tokenId;
        bytes32 linkType;
    }

    struct linkAddressData {
        uint256 fromCharacterId;
        address ethAddress;
        bytes32 linkType;
        bytes data;
    }

    struct unlinkAddressData {
        uint256 fromCharacterId;
        address ethAddress;
        bytes32 linkType;
    }

    struct linkAnyUriData {
        uint256 fromCharacterId;
        string toUri;
        bytes32 linkType;
        bytes data;
    }

    struct unlinkAnyUriData {
        uint256 fromCharacterId;
        string toUri;
        bytes32 linkType;
    }

    struct linkLinklistData {
        uint256 fromCharacterId;
        uint256 toLinkListId;
        bytes32 linkType;
        bytes data;
    }

    struct unlinkLinklistData {
        uint256 fromCharacterId;
        uint256 toLinkListId;
        bytes32 linkType;
    }

    struct setLinkModule4CharacterData {
        uint256 characterId;
        address linkModule;
        bytes linkModuleInitData;
    }

    struct setLinkModule4NoteData {
        uint256 characterId;
        uint256 noteId;
        address linkModule;
        bytes linkModuleInitData;
    }

    struct setLinkModule4LinklistData {
        uint256 linklistId;
        address linkModule;
        bytes linkModuleInitData;
    }

    struct setLinkModule4ERC721Data {
        address tokenAddress;
        uint256 tokenId;
        address linkModule;
        bytes linkModuleInitData;
    }

    struct setLinkModule4AddressData {
        address account;
        address linkModule;
        bytes linkModuleInitData;
    }

    struct setMintModule4NoteData {
        uint256 characterId;
        uint256 noteId;
        address mintModule;
        bytes mintModuleInitData;
    }

    struct linkCharactersInBatchData {
        uint256 fromCharacterId;
        uint256[] toCharacterIds;
        bytes[] data;
        address[] toAddresses;
        bytes32 linkType;
    }

    struct LinkData {
        uint256 linklistId;
        uint256 linkItemType;
        uint256 linkingCharacterId;
        address linkingAddress;
        uint256 linkingLinklistId;
        bytes32 linkKey;
    }

    struct PostNoteData {
        uint256 characterId;
        string contentUri;
        address linkModule;
        bytes linkModuleInitData;
        address mintModule;
        bytes mintModuleInitData;
        bool locked;
    }

    struct MintNoteData {
        uint256 characterId;
        uint256 noteId;
        address to;
        bytes mintModuleData;
    }

    // character struct
    struct Character {
        uint256 characterId;
        string handle;
        string uri;
        uint256 noteCount;
        address socialToken;
        address linkModule;
    }

    /**
     * @dev A struct containing data associated with each new note.
     * @param linkItemType The link type of this note, if the note is a note with link.
     * @param linkKey If linkKey is not empty, it is a note with link(eg.a comment to a character or a note).
     * @param contentURI The URI associated with this note.
     * @param linkModule The address of the current link module of this note, can be empty.
     * @param mintModule  The address of the current mint module of this note, can be empty.
     * @param mintNFT The address of the mintNFT associated with this note, if any.
     * @param deleted Whether the note is deleted.
     * @param locked Whether the note is locked. If the note is locked, its owner can't set not uri anymore.
     */
    struct Note {
        bytes32 linkItemType;
        bytes32 linkKey;
        string contentUri;
        address linkModule;
        address mintModule;
        address mintNFT;
        bool deleted;
        bool locked;
    }

    struct CharacterLinkStruct {
        uint256 fromCharacterId;
        uint256 toCharacterId;
        bytes32 linkType;
    }

    struct NoteStruct {
        uint256 characterId;
        uint256 noteId;
    }

    struct ERC721Struct {
        address tokenAddress;
        uint256 erc721TokenId;
    }

    /**
     @param blocklist The list of blocklist addresses.
     @param allowlist The list of allowlist addresses.
     */
    struct Operators4Note {
        EnumerableSet.AddressSet blocklist;
        EnumerableSet.AddressSet allowlist;
    }
}
          

@openzeppelin/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
          

contracts/libraries/LinkModuleLogic.sol

// SPDX-License-Identifier: MIT
// solhint-disable private-vars-leading-underscore
pragma solidity 0.8.16;

import {Events} from "./Events.sol";
import {DataTypes} from "./DataTypes.sol";
import {IMintModule4Note} from "../interfaces/IMintModule4Note.sol";
import {ILinkModule4Note} from "../interfaces/ILinkModule4Note.sol";
import {ILinkModule4ERC721} from "../interfaces/ILinkModule4ERC721.sol";
import {ILinkModule4Linklist} from "../interfaces/ILinkModule4Linklist.sol";
import {ILinkModule4Address} from "../interfaces/ILinkModule4Address.sol";

library LinkModuleLogic {
    /**
     * @notice  Sets link module for a given note.
     * @param   characterId  The character ID to set link module for.
     * @param   noteId  The note ID to set link module for.
     * @param   linkModule  The link module to set.
     * @param   linkModuleInitData  The data to pass to the link module for initialization, if any.
     */
    function setLinkModule4Note(
        uint256 characterId,
        uint256 noteId,
        address linkModule,
        bytes calldata linkModuleInitData,
        mapping(uint256 => mapping(uint256 => DataTypes.Note)) storage _noteByIdByCharacter
    ) external {
        if (linkModule != address(0)) {
            _noteByIdByCharacter[characterId][noteId].linkModule = linkModule;

            bytes memory returnData = ILinkModule4Note(linkModule).initializeLinkModule(
                characterId,
                noteId,
                linkModuleInitData
            );

            emit Events.SetLinkModule4Note(
                characterId,
                noteId,
                linkModule,
                linkModuleInitData,
                returnData
            );
        }
    }

    /**
     * @notice  Sets link module for a given address.
     * @param   account  The address to set link module for.
     * @param   linkModule  The link module to set.
     * @param   linkModuleInitData  The data to pass to the link module for initialization, if any.
     */
    function setLinkModule4Address(
        address account,
        address linkModule,
        bytes calldata linkModuleInitData,
        mapping(address => address) storage _linkModules4Address
    ) external {
        if (linkModule != address(0)) {
            _linkModules4Address[account] = linkModule;
            bytes memory returnData = ILinkModule4Address(linkModule).initializeLinkModule(
                account,
                linkModuleInitData
            );

            emit Events.SetLinkModule4Address(account, linkModule, linkModuleInitData, returnData);
        }
    }

    /**
     * @notice  Sets the mint module for a given note.
     * @param   characterId  The character ID of note to set the mint module for.
     * @param   noteId  The note ID of note.
     * @param   mintModule  The mint module to set for note.
     * @param   mintModuleInitData  The data to pass to the mint module.
     */
    function setMintModule4Note(
        uint256 characterId,
        uint256 noteId,
        address mintModule,
        bytes calldata mintModuleInitData,
        mapping(uint256 => mapping(uint256 => DataTypes.Note)) storage _noteByIdByCharacter
    ) external {
        if (mintModule != address(0)) {
            _noteByIdByCharacter[characterId][noteId].mintModule = mintModule;

            bytes memory returnData = IMintModule4Note(mintModule).initializeMintModule(
                characterId,
                noteId,
                mintModuleInitData
            );

            emit Events.SetMintModule4Note(
                characterId,
                noteId,
                mintModule,
                mintModuleInitData,
                returnData
            );
        }
    }

    /**
     * @notice  Sets link module for a given linklist.
     * @param   linklistId  The linklist ID to set link module for.
     * @param   linkModule  The link module to set.
     * @param   linkModuleInitData  The data to pass to the link module for initialization, if any.
     */
    function setLinkModule4Linklist(
        uint256 linklistId,
        address linkModule,
        bytes calldata linkModuleInitData,
        mapping(uint256 => address) storage _linkModules4Linklist
    ) external {
        if (linkModule != address(0)) {
            _linkModules4Linklist[linklistId] = linkModule;
            bytes memory linkModuleReturnData = ILinkModule4Linklist(linkModule)
                .initializeLinkModule(linklistId, linkModuleInitData);

            emit Events.SetLinkModule4Linklist(
                linklistId,
                linkModule,
                linkModuleInitData,
                linkModuleReturnData
            );
        }
    }

    /**
     * @notice  Sets link module for a given ERC721 token.
     * @param   tokenAddress  The token address of erc721 to set link module for.
     * @param   tokenId  The token ID of erc721 to set link module for.
     * @param   linkModule  The link module to set.
     * @param   linkModuleInitData  The data to pass to the link module for initialization, if any.
     */
    function setLinkModule4ERC721(
        address tokenAddress,
        uint256 tokenId,
        address linkModule,
        bytes calldata linkModuleInitData,
        mapping(address => mapping(uint256 => address)) storage _linkModules4ERC721
    ) external {
        if (linkModule != address(0)) {
            _linkModules4ERC721[tokenAddress][tokenId] = linkModule;
            bytes memory linkModuleReturnData = ILinkModule4ERC721(linkModule).initializeLinkModule(
                tokenAddress,
                tokenId,
                linkModuleInitData
            );

            emit Events.SetLinkModule4ERC721(
                tokenAddress,
                tokenId,
                linkModule,
                linkModuleInitData,
                linkModuleReturnData
            );
        }
    }
}
          

contracts/base/NFTBase.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

import {ERC721} from "./ERC721.sol";
import {ERC721Enumerable} from "./ERC721Enumerable.sol";
import {Events} from "../libraries/Events.sol";

abstract contract NFTBase is ERC721Enumerable {
    function _initialize(string calldata name, string calldata symbol) internal {
        ERC721.__ERC721_Init(name, symbol);

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

    // solhint-disable ordering
    function burn(uint256 tokenId) public virtual {
        require(_isApprovedOrOwner(msg.sender, tokenId), "NFTBase: NotOwnerOrApproved");
        _burn(tokenId);
    }
}
          

contracts/libraries/OP.sol

// SPDX-License-Identifier: MIT
// solhint-disable private-vars-leading-underscore
pragma solidity 0.8.16;

/**
* In Crossbell's operator system, every uint8 stands for a single method in Web3Entry.sol. <br>
* For most cases, we recommend simply granting operators the `OPERATOR_SIGN_PERMISSION_BITMAP`,
* which gives operator full permissions aside from owner permissions and future permissions, but for
* those who're more aware of access control, the custom permission bitmap is all yours,
* and you can find every customizable methods below. <br>

* `OPERATOR_SIGN_PERMISSION_BITMAP` have access to all methods in `OPERATOR_SYNC_PERMISSION_BITMAP`
* plus more permissions for signing. <br>

* Permissions are laid out in a increasing order of power.
* so the bitmap looks like this:

<table>
    <colgroup>
        <col style="width: 25%">
        <col style="width: 25%">
        <col style="width: 25%">
        <col style="width: 25%">
    </colgroup>
    <tr>
        <td>operator sync</td>
        <td>operator sign</td>
        <td>future reserved</td>
        <td>owner</td>
    <tr>
    <tr>
        <td>[255 - 236]</td>
        <td>[235 - 176]</td>
        <td>[175 - 21]</td>
        <td>[20 - 0]</td>
    <tr>
</table>


*/

library OP {
    uint256 internal constant UINT256_MAX = ~uint256(0);

    // [0,20] for owner permissions
    uint8 internal constant SET_HANDLE = 0;
    uint8 internal constant SET_SOCIAL_TOKEN = 1;
    uint8 internal constant GRANT_OPERATOR_PERMISSIONS = 2;
    // uint8 internal constant GRANT_OPERATOR_PERMISSIONS_FOR_NOTE = 3;
    uint8 internal constant GRANT_OPERATORS_FOR_NOTE = 3;
    // set [0, 3] bit index
    uint256 internal constant OWNER_PERMISSION_BITMAP = ~(UINT256_MAX << 4);

    // [21, 175] are reserved for future

    // [176, 235] for operator sign permissions
    uint8 internal constant SET_CHARACTER_URI = 176;
    uint8 internal constant SET_LINKLIST_URI = 177;
    uint8 internal constant LINK_CHARACTER = 178;
    uint8 internal constant UNLINK_CHARACTER = 179;
    uint8 internal constant CREATE_THEN_LINK_CHARACTER = 180;
    uint8 internal constant LINK_NOTE = 181;
    uint8 internal constant UNLINK_NOTE = 182;
    uint8 internal constant LINK_ERC721 = 183;
    uint8 internal constant UNLINK_ERC721 = 184;
    uint8 internal constant LINK_ADDRESS = 185;
    uint8 internal constant UNLINK_ADDRESS = 186;
    uint8 internal constant LINK_ANYURI = 187;
    uint8 internal constant UNLINK_ANYURI = 188;
    uint8 internal constant LINK_LINKLIST = 189;
    uint8 internal constant UNLINK_LINKLIST = 190;
    uint8 internal constant SET_LINK_MODULE_FOR_CHARACTER = 191;
    uint8 internal constant SET_LINK_MODULE_FOR_NOTE = 192;
    uint8 internal constant SET_LINK_MODULE_FOR_LINKLIST = 193;
    // slither-disable-next-line similar-names
    uint8 internal constant SET_MINT_MODULE_FOR_NOTE = 194;
    uint8 internal constant SET_NOTE_URI = 195;
    uint8 internal constant LOCK_NOTE = 196;
    uint8 internal constant DELETE_NOTE = 197;
    uint8 internal constant POST_NOTE_FOR_CHARACTER = 198;
    uint8 internal constant POST_NOTE_FOR_ADDRESS = 199;
    uint8 internal constant POST_NOTE_FOR_LINKLIST = 200;
    uint8 internal constant POST_NOTE_FOR_NOTE = 201;
    uint8 internal constant POST_NOTE_FOR_ERC721 = 202;
    uint8 internal constant POST_NOTE_FOR_ANYURI = 203;
    // set [176,204] bit index

    // [236, 255] for operator sync permissions
    uint8 internal constant POST_NOTE = 236;
    // set 236 bit index
    uint256 internal constant POST_NOTE_PERMISSION_BITMAP = 1 << POST_NOTE;

    // POST_NOTE_DEFAULT_PERMISSION_BITMAP has post note related permissions
    uint256 internal constant POST_NOTE_DEFAULT_PERMISSION_BITMAP =
        ((UINT256_MAX << 198) & ~(UINT256_MAX << 204)) | POST_NOTE_PERMISSION_BITMAP;

    // DEFAULT_PERMISSION_BITMAP has operator sign permissions and operator sync permissions
    uint256 internal constant DEFAULT_PERMISSION_BITMAP =
        ((UINT256_MAX << 176) & ~(UINT256_MAX << 204)) | POST_NOTE_PERMISSION_BITMAP;

    // bitmap mask with all current-in-use methods to 1
    uint256 internal constant ALLOWED_PERMISSION_BITMAP_MASK =
        OWNER_PERMISSION_BITMAP | DEFAULT_PERMISSION_BITMAP;
}
          

contracts/Web3EntryBase.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

import {IWeb3Entry} from "./interfaces/IWeb3Entry.sol";
import {ILinklist} from "./interfaces/ILinklist.sol";
import {ILinkModule4Note} from "./interfaces/ILinkModule4Note.sol";
import {NFTBase} from "./base/NFTBase.sol";
import {Web3EntryStorage} from "./storage/Web3EntryStorage.sol";
import {Web3EntryExtendStorage} from "./storage/Web3EntryExtendStorage.sol";
import {DataTypes} from "./libraries/DataTypes.sol";
import {Constants} from "./libraries/Constants.sol";
import {Events} from "./libraries/Events.sol";
import {CharacterLogic} from "./libraries/CharacterLogic.sol";
import {PostLogic} from "./libraries/PostLogic.sol";
import {OperatorLogic} from "./libraries/OperatorLogic.sol";
import {LinkModuleLogic} from "./libraries/LinkModuleLogic.sol";
import {LinkLogic} from "./libraries/LinkLogic.sol";
import {OP} from "./libraries/OP.sol";
import {
    ErrSocialTokenExists,
    ErrNotAddressOwner,
    ErrHandleExists,
    ErrNotCharacterOwner,
    ErrNotEnoughPermission,
    ErrNotEnoughPermissionForThisNote,
    ErrCharacterNotExists,
    ErrNoteIsDeleted,
    ErrNoteNotExists,
    ErrNoteLocked,
    ErrHandleLengthInvalid,
    ErrHandleContainsInvalidCharacters
} from "./libraries/Error.sol";
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Multicall} from "@openzeppelin/contracts/utils/Multicall.sol";

contract Web3EntryBase is
    IWeb3Entry,
    Multicall,
    NFTBase,
    Web3EntryStorage,
    Initializable,
    Web3EntryExtendStorage
{
    using EnumerableSet for EnumerableSet.Bytes32Set;
    using EnumerableSet for EnumerableSet.AddressSet;

    // solhint-disable-next-line private-vars-leading-underscore
    uint256 internal constant REVISION = 4;

    /// @inheritdoc IWeb3Entry
    function initialize(
        string calldata name_,
        string calldata symbol_,
        address linklist_,
        address mintNFTImpl_,
        address periphery_,
        address newbieVilla_
    ) external override reinitializer(3) {
        super._initialize(name_, symbol_);
        _linklist = linklist_;
        MINT_NFT_IMPL = mintNFTImpl_;
        _periphery = periphery_;
        _newbieVilla = newbieVilla_;

        emit Events.Web3EntryInitialized(block.timestamp);
    }

    /// @inheritdoc IWeb3Entry
    function grantOperatorPermissions(
        uint256 characterId,
        address operator,
        uint256 permissionBitMap
    ) external override {
        _validateCallerPermission(characterId, OP.GRANT_OPERATOR_PERMISSIONS);
        OperatorLogic.grantOperatorPermissions(
            characterId,
            operator,
            permissionBitMap,
            _operatorsByCharacter,
            _operatorsPermissionBitMap
        );
    }

    /// @inheritdoc IWeb3Entry
    function grantOperators4Note(
        uint256 characterId,
        uint256 noteId,
        address[] calldata blocklist,
        address[] calldata allowlist
    ) external override {
        _validateCallerPermission(characterId, OP.GRANT_OPERATORS_FOR_NOTE);
        _validateNoteExists(characterId, noteId);
        OperatorLogic.grantOperators4Note(
            characterId,
            noteId,
            blocklist,
            allowlist,
            _operators4Note
        );
    }

    /// @inheritdoc IWeb3Entry
    function createCharacter(
        DataTypes.CreateCharacterData calldata vars
    ) external override returns (uint256 characterId) {
        return _createCharacter(vars, true);
    }

    /// @inheritdoc IWeb3Entry
    function setHandle(uint256 characterId, string calldata newHandle) external override {
        _validateCallerPermission(characterId, OP.SET_HANDLE);

        // check if the handle exists
        _checkHandleExists(keccak256(bytes(newHandle)));

        // check if the handle is valid
        _validateHandle(newHandle);

        CharacterLogic.setHandle(characterId, newHandle, _characterIdByHandleHash, _characterById);
    }

    /// @inheritdoc IWeb3Entry
    function setSocialToken(uint256 characterId, address tokenAddress) external override {
        _validateCallerPermission(characterId, OP.SET_SOCIAL_TOKEN);

        // check if the social token exists
        if (_characterById[characterId].socialToken != address(0)) revert ErrSocialTokenExists();

        CharacterLogic.setSocialToken(characterId, tokenAddress, _characterById);
    }

    /// @inheritdoc IWeb3Entry
    function setPrimaryCharacterId(uint256 characterId) external override {
        _validateCallerIsCharacterOwner(characterId);

        uint256 oldCharacterId = _primaryCharacterByAddress[msg.sender];
        _primaryCharacterByAddress[msg.sender] = characterId;

        emit Events.SetPrimaryCharacterId(msg.sender, characterId, oldCharacterId);
    }

    /// @inheritdoc IWeb3Entry
    function setCharacterUri(uint256 characterId, string calldata newUri) external override {
        _validateCallerPermission(characterId, OP.SET_CHARACTER_URI);
        _characterById[characterId].uri = newUri;

        emit Events.SetCharacterUri(characterId, newUri);
    }

    /// @inheritdoc IWeb3Entry
    function setLinklistUri(uint256 linklistId, string calldata uri) external override {
        uint256 ownerCharacterId = ILinklist(_linklist).getOwnerCharacterId(linklistId);
        _validateCallerPermission(ownerCharacterId, OP.SET_LINKLIST_URI);

        ILinklist(_linklist).setUri(linklistId, uri);
    }

    /// @inheritdoc IWeb3Entry
    function linkCharacter(DataTypes.linkCharacterData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.LINK_CHARACTER);
        _validateCharacterExists(vars.toCharacterId);

        LinkLogic.linkCharacter(
            vars.fromCharacterId,
            vars.toCharacterId,
            vars.linkType,
            vars.data,
            _linklist,
            _characterById[vars.toCharacterId].linkModule,
            _attachedLinklists
        );
    }

    /// @inheritdoc IWeb3Entry
    function unlinkCharacter(DataTypes.unlinkCharacterData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.LINK_CHARACTER);

        LinkLogic.unlinkCharacter(
            vars.fromCharacterId,
            vars.toCharacterId,
            vars.linkType,
            _linklist,
            _attachedLinklists[vars.fromCharacterId][vars.linkType]
        );
    }

    /// @inheritdoc IWeb3Entry
    function createThenLinkCharacter(
        DataTypes.createThenLinkCharacterData calldata vars
    ) external override returns (uint256 characterId) {
        _validateCallerPermission(vars.fromCharacterId, OP.CREATE_THEN_LINK_CHARACTER);

        // create character
        characterId = _createCharacter(
            DataTypes.CreateCharacterData({
                to: vars.to,
                handle: _addressToHexString(vars.to),
                uri: "",
                linkModule: address(0),
                linkModuleInitData: ""
            }),
            false
        );

        // link character
        LinkLogic.linkCharacter(
            vars.fromCharacterId,
            characterId,
            vars.linkType,
            "",
            _linklist,
            address(0),
            _attachedLinklists
        );
    }

    /// @inheritdoc IWeb3Entry
    function linkNote(DataTypes.linkNoteData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.LINK_NOTE);
        _validateNoteExists(vars.toCharacterId, vars.toNoteId);

        LinkLogic.linkNote(
            vars.fromCharacterId,
            vars.toCharacterId,
            vars.toNoteId,
            vars.linkType,
            vars.data,
            _linklist,
            _noteByIdByCharacter[vars.toCharacterId][vars.toNoteId].linkModule,
            _attachedLinklists
        );
    }

    /// @inheritdoc IWeb3Entry
    function unlinkNote(DataTypes.unlinkNoteData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.UNLINK_NOTE);

        LinkLogic.unlinkNote(
            vars.fromCharacterId,
            vars.toCharacterId,
            vars.toNoteId,
            vars.linkType,
            _linklist,
            _attachedLinklists
        );
    }

    /// @inheritdoc IWeb3Entry
    function linkERC721(DataTypes.linkERC721Data calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.LINK_ERC721);

        LinkLogic.linkERC721(
            vars.fromCharacterId,
            vars.tokenAddress,
            vars.tokenId,
            vars.linkType,
            _linklist,
            _attachedLinklists
        );
    }

    /// @inheritdoc IWeb3Entry
    function unlinkERC721(DataTypes.unlinkERC721Data calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.UNLINK_ERC721);

        LinkLogic.unlinkERC721(
            vars.fromCharacterId,
            vars.tokenAddress,
            vars.tokenId,
            vars.linkType,
            _linklist,
            _attachedLinklists[vars.fromCharacterId][vars.linkType]
        );
    }

    /// @inheritdoc IWeb3Entry
    function linkAddress(DataTypes.linkAddressData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.LINK_ADDRESS);

        LinkLogic.linkAddress(
            vars.fromCharacterId,
            vars.ethAddress,
            vars.linkType,
            _linklist,
            _attachedLinklists
        );
    }

    /// @inheritdoc IWeb3Entry
    function unlinkAddress(DataTypes.unlinkAddressData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.UNLINK_ADDRESS);

        LinkLogic.unlinkAddress(
            vars.fromCharacterId,
            vars.ethAddress,
            vars.linkType,
            _linklist,
            _attachedLinklists[vars.fromCharacterId][vars.linkType]
        );
    }

    /// @inheritdoc IWeb3Entry
    function linkAnyUri(DataTypes.linkAnyUriData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.LINK_ANYURI);

        LinkLogic.linkAnyUri(
            vars.fromCharacterId,
            vars.toUri,
            vars.linkType,
            _linklist,
            _attachedLinklists
        );
    }

    /// @inheritdoc IWeb3Entry
    function unlinkAnyUri(DataTypes.unlinkAnyUriData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.UNLINK_ANYURI);

        LinkLogic.unlinkAnyUri(
            vars.fromCharacterId,
            vars.toUri,
            vars.linkType,
            _linklist,
            _attachedLinklists[vars.fromCharacterId][vars.linkType]
        );
    }

    /// @inheritdoc IWeb3Entry
    function linkLinklist(DataTypes.linkLinklistData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.LINK_LINKLIST);

        LinkLogic.linkLinklist(
            vars.fromCharacterId,
            vars.toLinkListId,
            vars.linkType,
            _linklist,
            _attachedLinklists
        );
    }

    /// @inheritdoc IWeb3Entry
    function unlinkLinklist(DataTypes.unlinkLinklistData calldata vars) external override {
        _validateCallerPermission(vars.fromCharacterId, OP.UNLINK_LINKLIST);

        LinkLogic.unlinkLinklist(
            vars.fromCharacterId,
            vars.toLinkListId,
            vars.linkType,
            _linklist,
            _attachedLinklists[vars.fromCharacterId][vars.linkType]
        );
    }

    //////////////////////////////////////////////////////////////
    /*
     * These functions are temporarily commented out, in order to limit the contract code size within 24K.
     * These functions will be restored when necessary in the future.
     */
    /**
     * @notice set link module for his character
     */

    /*
    function setLinkModule4Character(DataTypes.setLinkModule4CharacterData calldata vars) external  override {
        _validateCallerPermission(vars.characterId, OP.SET_LINK_MODULE_FOR_CHARACTER);

        CharacterLogic.setCharacterLinkModule(
            vars.characterId,
            vars.linkModule,
            vars.linkModuleInitData,
            _characterById[vars.characterId]
        );
    }

    function setLinkModule4Note(DataTypes.setLinkModule4NoteData calldata vars) external override  {
        _validateCallerPermission(vars.characterId, OP.SET_LINK_MODULE_FOR_NOTE);
        _validateCallerPermission4Note(vars.characterId, vars.noteId);
        _validateNoteExists(vars.characterId, vars.noteId);
        _validateNoteNotLocked(vars.characterId, vars.noteId);

        LinkModuleLogic.setLinkModule4Note(
            vars.characterId,
            vars.noteId,
            vars.linkModule,
            vars.linkModuleInitData,
            _noteByIdByCharacter
        );
    }
    */

    /**
     * @notice Set linkModule for a ERC721 token that you own.
     * @dev Operators can't setLinkModule4ERC721, because operators are set for 
     characters but erc721 tokens belong to address and not characters.
     */
    /*
   function setLinkModule4ERC721(DataTypes.setLinkModule4ERC721Data calldata vars) external  override {
       require(msg.sender == ERC721(vars.tokenAddress).ownerOf(vars.tokenId), "NotERC721Owner");

       LinkModuleLogic.setLinkModule4ERC721(
           vars.tokenAddress,
           vars.tokenId,
           vars.linkModule,
           vars.linkModuleInitData,
           _linkModules4ERC721
       );
   }
     */
    //////////////////////////////////////////////////////////////

    /// @inheritdoc IWeb3Entry
    function setLinkModule4Linklist(
        DataTypes.setLinkModule4LinklistData calldata vars
    ) external override {
        // get character id of the owner of this linklist
        uint256 ownerCharacterId = ILinklist(_linklist).getOwnerCharacterId(vars.linklistId);

        _validateCallerPermission(ownerCharacterId, OP.SET_LINK_MODULE_FOR_LINKLIST);

        LinkModuleLogic.setLinkModule4Linklist(
            vars.linklistId,
            vars.linkModule,
            vars.linkModuleInitData,
            _linkModules4Linklist
        );
    }

    /// @inheritdoc IWeb3Entry
    function setLinkModule4Address(
        DataTypes.setLinkModule4AddressData calldata vars
    ) external override {
        if (msg.sender != vars.account) revert ErrNotAddressOwner();

        LinkModuleLogic.setLinkModule4Address(
            vars.account,
            vars.linkModule,
            vars.linkModuleInitData,
            _linkModules4Address
        );
    }

    /// @inheritdoc IWeb3Entry
    function mintNote(
        DataTypes.MintNoteData calldata vars
    ) external override returns (uint256 tokenId) {
        _validateNoteExists(vars.characterId, vars.noteId);

        tokenId = PostLogic.mintNote(
            vars.characterId,
            vars.noteId,
            vars.to,
            vars.mintModuleData,
            MINT_NFT_IMPL,
            _noteByIdByCharacter
        );
    }

    /// @inheritdoc IWeb3Entry
    function setMintModule4Note(DataTypes.setMintModule4NoteData calldata vars) external override {
        _validateCallerPermission(vars.characterId, OP.SET_MINT_MODULE_FOR_NOTE);
        _validateNoteExists(vars.characterId, vars.noteId);
        _validateNoteNotLocked(vars.characterId, vars.noteId);

        LinkModuleLogic.setMintModule4Note(
            vars.characterId,
            vars.noteId,
            vars.mintModule,
            vars.mintModuleInitData,
            _noteByIdByCharacter
        );
    }

    /// @inheritdoc IWeb3Entry
    function postNote(
        DataTypes.PostNoteData calldata vars
    ) external override returns (uint256 noteId) {
        _validateCallerPermission(vars.characterId, OP.POST_NOTE);

        noteId = _nextNoteId(vars.characterId);
        PostLogic.postNoteWithLink(vars, noteId, 0, 0, "", _noteByIdByCharacter);
    }

    /// @inheritdoc IWeb3Entry
    function setNoteUri(
        uint256 characterId,
        uint256 noteId,
        string calldata newUri
    ) external override {
        _validateCallerPermission4Note(characterId, noteId);
        _validateNoteExists(characterId, noteId);
        _validateNoteNotLocked(characterId, noteId);

        PostLogic.setNoteUri(characterId, noteId, newUri, _noteByIdByCharacter);
    }

    /// @inheritdoc IWeb3Entry
    function lockNote(uint256 characterId, uint256 noteId) external override {
        _validateCallerPermission(characterId, OP.LOCK_NOTE);
        _validateNoteExists(characterId, noteId);

        _noteByIdByCharacter[characterId][noteId].locked = true;

        emit Events.LockNote(characterId, noteId);
    }

    /// @inheritdoc IWeb3Entry
    function deleteNote(uint256 characterId, uint256 noteId) external override {
        _validateCallerPermission(characterId, OP.DELETE_NOTE);
        _validateNoteExists(characterId, noteId);

        _noteByIdByCharacter[characterId][noteId].deleted = true;

        emit Events.DeleteNote(characterId, noteId);
    }

    /// @inheritdoc IWeb3Entry
    function postNote4Character(
        DataTypes.PostNoteData calldata vars,
        uint256 toCharacterId
    ) external override returns (uint256) {
        _validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_CHARACTER);

        bytes32 linkItemType = Constants.LINK_ITEM_TYPE_CHARACTER;
        uint256 noteId = _nextNoteId(vars.characterId);
        bytes32 linkKey = bytes32(toCharacterId);

        PostLogic.postNoteWithLink(
            vars,
            noteId,
            linkItemType,
            linkKey,
            abi.encodePacked(toCharacterId),
            _noteByIdByCharacter
        );

        return noteId;
    }

    /// @inheritdoc IWeb3Entry
    function postNote4Address(
        DataTypes.PostNoteData calldata vars,
        address ethAddress
    ) external override returns (uint256) {
        _validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_ADDRESS);

        bytes32 linkItemType = Constants.LINK_ITEM_TYPE_ADDRESS;
        uint256 noteId = _nextNoteId(vars.characterId);
        bytes32 linkKey = bytes32(uint256(uint160(ethAddress)));

        PostLogic.postNoteWithLink(
            vars,
            noteId,
            linkItemType,
            linkKey,
            abi.encodePacked(ethAddress),
            _noteByIdByCharacter
        );

        return noteId;
    }

    /// @inheritdoc IWeb3Entry
    function postNote4Linklist(
        DataTypes.PostNoteData calldata vars,
        uint256 toLinklistId
    ) external override returns (uint256) {
        _validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_LINKLIST);

        bytes32 linkItemType = Constants.LINK_ITEM_TYPE_LINKLIST;
        uint256 noteId = _nextNoteId(vars.characterId);
        bytes32 linkKey = bytes32(toLinklistId);

        PostLogic.postNoteWithLink(
            vars,
            noteId,
            linkItemType,
            linkKey,
            abi.encodePacked(toLinklistId),
            _noteByIdByCharacter
        );

        return noteId;
    }

    /// @inheritdoc IWeb3Entry
    function postNote4Note(
        DataTypes.PostNoteData calldata vars,
        DataTypes.NoteStruct calldata note
    ) external override returns (uint256) {
        _validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_NOTE);

        bytes32 linkItemType = Constants.LINK_ITEM_TYPE_NOTE;
        uint256 noteId = _nextNoteId(vars.characterId);
        bytes32 linkKey = ILinklist(_linklist).addLinkingNote(0, note.characterId, note.noteId);

        PostLogic.postNoteWithLink(
            vars,
            noteId,
            linkItemType,
            linkKey,
            abi.encodePacked(note.characterId, note.noteId),
            _noteByIdByCharacter
        );

        return noteId;
    }

    /// @inheritdoc IWeb3Entry
    function postNote4ERC721(
        DataTypes.PostNoteData calldata vars,
        DataTypes.ERC721Struct calldata erc721
    ) external override returns (uint256) {
        _validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_ERC721);

        bytes32 linkItemType = Constants.LINK_ITEM_TYPE_ERC721;
        uint256 noteId = _nextNoteId(vars.characterId);
        bytes32 linkKey = ILinklist(_linklist).addLinkingERC721(
            0,
            erc721.tokenAddress,
            erc721.erc721TokenId
        );

        PostLogic.postNoteWithLink(
            vars,
            noteId,
            linkItemType,
            linkKey,
            abi.encodePacked(erc721.tokenAddress, erc721.erc721TokenId),
            _noteByIdByCharacter
        );

        return noteId;
    }

    /// @inheritdoc IWeb3Entry
    function postNote4AnyUri(
        DataTypes.PostNoteData calldata vars,
        string calldata uri
    ) external override returns (uint256) {
        _validateCallerPermission(vars.characterId, OP.POST_NOTE_FOR_ANYURI);

        bytes32 linkItemType = Constants.LINK_ITEM_TYPE_ANYURI;
        uint256 noteId = _nextNoteId(vars.characterId);
        bytes32 linkKey = ILinklist(_linklist).addLinkingAnyUri(0, uri);

        PostLogic.postNoteWithLink(
            vars,
            noteId,
            linkItemType,
            linkKey,
            abi.encodePacked(uri),
            _noteByIdByCharacter
        );

        return noteId;
    }

    /// @inheritdoc IWeb3Entry
    function getOperators(uint256 characterId) external view override returns (address[] memory) {
        return _operatorsByCharacter[characterId].values();
    }

    /// @inheritdoc IWeb3Entry
    function getOperatorPermissions(
        uint256 characterId,
        address operator
    ) external view override returns (uint256) {
        return _operatorsPermissionBitMap[characterId][operator];
    }

    /// @inheritdoc IWeb3Entry
    function getOperators4Note(
        uint256 characterId,
        uint256 noteId
    ) external view override returns (address[] memory blocklist, address[] memory allowlist) {
        blocklist = _operators4Note[characterId][noteId].blocklist.values();
        allowlist = _operators4Note[characterId][noteId].allowlist.values();
    }

    /// @inheritdoc IWeb3Entry
    function isOperatorAllowedForNote(
        uint256 characterId,
        uint256 noteId,
        address operator
    ) external view override returns (bool) {
        return _isOperatorAllowedForNote(characterId, noteId, operator);
    }

    /// @inheritdoc IWeb3Entry
    function getPrimaryCharacterId(address account) external view override returns (uint256) {
        return _primaryCharacterByAddress[account];
    }

    /// @inheritdoc IWeb3Entry
    function isPrimaryCharacter(uint256 characterId) external view override returns (bool) {
        address account = ownerOf(characterId);
        return characterId == _primaryCharacterByAddress[account];
    }

    /// @inheritdoc IWeb3Entry
    function getCharacter(
        uint256 characterId
    ) external view override returns (DataTypes.Character memory) {
        return _characterById[characterId];
    }

    /// @inheritdoc IWeb3Entry
    function getCharacterByHandle(
        string calldata handle
    ) external view override returns (DataTypes.Character memory) {
        bytes32 handleHash = keccak256(bytes(handle));
        uint256 characterId = _characterIdByHandleHash[handleHash];
        return _characterById[characterId];
    }

    /// @inheritdoc IWeb3Entry
    function getHandle(uint256 characterId) external view override returns (string memory) {
        return _characterById[characterId].handle;
    }

    /// @inheritdoc IWeb3Entry
    function getCharacterUri(uint256 characterId) external view override returns (string memory) {
        return tokenURI(characterId);
    }

    /// @inheritdoc IWeb3Entry
    function getNote(
        uint256 characterId,
        uint256 noteId
    ) external view override returns (DataTypes.Note memory) {
        return _noteByIdByCharacter[characterId][noteId];
    }

    /// @inheritdoc IWeb3Entry
    function getLinkModule4Address(address account) external view override returns (address) {
        return _linkModules4Address[account];
    }

    /// @inheritdoc IWeb3Entry
    function getLinkModule4Linklist(uint256 tokenId) external view override returns (address) {
        return _linkModules4Linklist[tokenId];
    }

    /// @inheritdoc IWeb3Entry
    function getLinkModule4ERC721(
        address tokenAddress,
        uint256 tokenId
    ) external view override returns (address) {
        return _linkModules4ERC721[tokenAddress][tokenId];
    }

    /// @inheritdoc IWeb3Entry
    function getLinklistUri(uint256 tokenId) external view override returns (string memory) {
        return ILinklist(_linklist).Uri(tokenId);
    }

    /// @inheritdoc IWeb3Entry
    function getLinklistId(
        uint256 characterId,
        bytes32 linkType
    ) external view override returns (uint256) {
        return _attachedLinklists[characterId][linkType];
    }

    /// @inheritdoc IWeb3Entry
    function getLinklistType(uint256 linkListId) external view override returns (bytes32) {
        return ILinklist(_linklist).getLinkType(linkListId);
    }

    /// @inheritdoc IWeb3Entry
    function getLinklistContract() external view override returns (address) {
        return _linklist;
    }

    /// @inheritdoc IWeb3Entry
    function getRevision() external pure override returns (uint256) {
        return REVISION;
    }

    /**
     * @notice Burns a web3Entry character nft.
     * @param tokenId The token ID to burn.
     */
    function burn(uint256 tokenId) public virtual override {
        // clear handle
        bytes32 handleHash = keccak256(bytes(_characterById[tokenId].handle));
        _characterIdByHandleHash[handleHash] = 0;

        // clear character
        delete _characterById[tokenId];

        // burn token
        super.burn(tokenId);
    }

    /**
     * @notice Returns the associated URI with a given character.
     * @param characterId The character ID to query.
     * @return The token URI.
     */
    function tokenURI(uint256 characterId) public view override returns (string memory) {
        return _characterById[characterId].uri;
    }

    function _createCharacter(
        DataTypes.CreateCharacterData memory vars,
        bool validateHandle
    ) internal returns (uint256 characterId) {
        // check if the handle exists
        _checkHandleExists(keccak256(bytes(vars.handle)));

        // check if the handle is valid
        if (validateHandle) {
            _validateHandle(vars.handle);
        }

        characterId = ++_characterCounter;
        // mint character nft
        _safeMint(vars.to, characterId);

        CharacterLogic.createCharacter(
            vars.to,
            vars.handle,
            vars.uri,
            vars.linkModule,
            vars.linkModuleInitData,
            characterId,
            _characterIdByHandleHash,
            _characterById
        );
    }

    /**
     * @dev Operators will be reset to blank before the characters are transferred in order to grant the
     * whole control power to receivers of character transfers.
     * If character is transferred from newbieVilla contract, don't clear operators.
     *
     * Permissions4Note is left unset, because permissions for notes are always stricter than default.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        //  clear operators if character is transferred from non-newbieVilla contract
        if (from != _newbieVilla) {
            // clear operators
            uint256 len = _operatorsByCharacter[tokenId].length();
            address[] memory operators = _operatorsByCharacter[tokenId].values();
            for (uint256 i = 0; i < len; i++) {
                _clearOperator(tokenId, operators[i]);
            }

            // reset if `tokenId` is primary character of `from` account
            if (_primaryCharacterByAddress[from] == tokenId) {
                _primaryCharacterByAddress[from] = 0;
            }
        }

        super._beforeTokenTransfer(from, to, tokenId);
    }

    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        // set primary character if `to` account has no primary character
        if (_primaryCharacterByAddress[to] == 0) {
            _primaryCharacterByAddress[to] = tokenId;
        }

        super._afterTokenTransfer(from, to, tokenId);
    }

    function _nextNoteId(uint256 characterId) internal returns (uint256) {
        return ++_characterById[characterId].noteCount;
    }

    function _clearOperator(uint256 tokenId, address operator) internal {
        delete _operatorsPermissionBitMap[tokenId][operator];
        // slither-disable-next-line unused-return
        _operatorsByCharacter[tokenId].remove(operator);
    }

    function _isOperatorAllowedForNote(
        uint256 characterId,
        uint256 noteId,
        address operator
    ) internal view returns (bool) {
        DataTypes.Operators4Note storage op = _operators4Note[characterId][noteId];

        // check blocklist
        if (op.blocklist.contains(operator)) {
            return false;
        }
        // check allowlist
        if (op.allowlist.contains(operator)) {
            return true;
        }
        // check character operator permission
        return _checkBit(_operatorsPermissionBitMap[characterId][operator], OP.SET_NOTE_URI);
    }

    // check if the handle exists
    function _checkHandleExists(bytes32 handleHash) internal view {
        if (_characterIdByHandleHash[handleHash] != 0) revert ErrHandleExists();
    }

    function _validateCallerIsCharacterOwner(uint256 characterId) internal view {
        address owner = ownerOf(characterId);

        // tx.origin is character owner, and msg.sender is periphery
        // solhint-disable-next-line avoid-tx-origin
        if (msg.sender == _periphery && tx.origin == owner) {
            return;
        }

        // msg.sender is character owner
        if (msg.sender == owner) {
            return;
        }

        revert ErrNotCharacterOwner();
    }

    function _validateCallerPermission(uint256 characterId, uint256 permissionId) internal view {
        // check character owner
        if (_callerIsCharacterOwner(characterId)) {
            return;
        }

        // check operator permission for tx.origin
        if (msg.sender == _periphery) {
            // solhint-disable-next-line avoid-tx-origin
            if (_checkBit(_operatorsPermissionBitMap[characterId][tx.origin], permissionId)) {
                return;
            }
        }

        //  check operator permission for msg.sender
        if (_checkBit(_operatorsPermissionBitMap[characterId][msg.sender], permissionId)) {
            return;
        }

        revert ErrNotEnoughPermission();
    }

    function _callerIsCharacterOwner(uint256 characterId) internal view returns (bool) {
        address owner = ownerOf(characterId);

        if (msg.sender == owner) {
            // caller is character owner
            return true;
        }

        // solhint-disable-next-line avoid-tx-origin
        if (msg.sender == _periphery && tx.origin == owner) {
            // caller is periphery, and tx.origin is character owner
            return true;
        }

        return false;
    }

    function _validateCallerPermission4Note(uint256 characterId, uint256 noteId) internal view {
        // check character owner
        if (_callerIsCharacterOwner(characterId)) {
            return;
        }

        // check note permission for tx.origin
        if (msg.sender == _periphery) {
            // solhint-disable-next-line avoid-tx-origin
            if (_isOperatorAllowedForNote(characterId, noteId, tx.origin)) {
                return;
            }
        }

        // check note permission for caller
        if (_isOperatorAllowedForNote(characterId, noteId, msg.sender)) {
            return;
        }

        revert ErrNotEnoughPermissionForThisNote();
    }

    function _validateCharacterExists(uint256 characterId) internal view {
        if (!_exists(characterId)) revert ErrCharacterNotExists(characterId);
    }

    function _validateNoteExists(uint256 characterId, uint256 noteId) internal view {
        if (_noteByIdByCharacter[characterId][noteId].deleted) revert ErrNoteIsDeleted();
        if (noteId > _characterById[characterId].noteCount) revert ErrNoteNotExists();
    }

    function _validateNoteNotLocked(uint256 characterId, uint256 noteId) internal view {
        if (_noteByIdByCharacter[characterId][noteId].locked) revert ErrNoteLocked();
    }

    function _validateHandle(string memory handle) internal pure {
        bytes memory byteHandle = bytes(handle);
        uint256 len = byteHandle.length;
        if (len > Constants.MAX_HANDLE_LENGTH || len < Constants.MIN_HANDLE_LENGTH)
            revert ErrHandleLengthInvalid();

        for (uint256 i = 0; i < len; ) {
            _validateChar(byteHandle[i]);

            unchecked {
                ++i;
            }
        }
    }

    function _validateChar(bytes1 c) internal pure {
        // char range: [0,9][a,z][-][_]
        if ((c < "0" || c > "z" || (c > "9" && c < "a")) && c != "-" && c != "_")
            revert ErrHandleContainsInvalidCharacters();
    }

    /**
     * @dev _checkBit checks if the value of the i'th bit of x is 1
     */
    function _checkBit(uint256 x, uint256 i) internal pure returns (bool) {
        return (x >> i) & 1 == 1;
    }

    /**
     * @dev _addressToHexString converts an address to its ASCII `string hexadecimal representation.
     */
    function _addressToHexString(address addr) internal pure returns (string memory) {
        bytes16 symbols = "0123456789abcdef";
        uint256 value = uint256(uint160(addr));

        bytes memory buffer = new bytes(42);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 41; i > 1; ) {
            buffer[i] = symbols[value & 0xf];
            value >>= 4;

            unchecked {
                --i;
            }
        }
        return string(buffer);
    }
}
          

@openzeppelin/contracts/utils/structs/EnumerableSet.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}
          

contracts/interfaces/ILinkModule4ERC721.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

interface ILinkModule4ERC721 {
    function initializeLinkModule(
        address tokenAddress,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes memory);

    function processLink(
        address account,
        address tokenAddress,
        uint256 tokenId,
        bytes calldata data
    ) external;
}
          

contracts/base/ERC721.sol

// SPDX-License-Identifier: MIT
// solhint-disable ordering
pragma solidity 0.8.16;

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IERC165} from "@openzeppelin/contracts/interfaces/IERC165.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}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // 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;

    // slither-disable-start naming-convention
    // solhint-disable-next-line func-name-mixedcase
    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 = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @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 overridden 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 = ERC721.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 {
        _setApprovalForAll(_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 // solhint-disable private-vars-leading-underscore
    ) 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 // solhint-disable private-vars-leading-underscore
    ) 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 _owners[tokenId] != 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 = ERC721.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 // solhint-disable private-vars-leading-underscore
    ) 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;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(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 = ERC721.ownerOf(tokenId);

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

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

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        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;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(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(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _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
     */
    // slither-disable-next-line unused-return
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data // solhint-disable private-vars-leading-underscore
    ) private returns (bool) {
        if (to.isContract()) {
            // slither-disable-start variable-scope
            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 {
                    /* solhint-disable no-inline-assembly */
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                    /* solhint-enable no-inline-assembly */
                }
            }
            // slither-disable-end variable-scope
        } 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].
     */
    // solhint-disable-next-line no-empty-blocks
    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    // solhint-disable-next-line no-empty-blocks
    function _afterTokenTransfer(address from, address to, uint256 tokenId) internal virtual {}
    // slither-disable-end naming-convention
}
          

contracts/storage/Web3EntryExtendStorage.sol

// SPDX-License-Identifier: MIT
// slither-disable-start naming-convention
pragma solidity 0.8.16;

import {DataTypes} from "../libraries/DataTypes.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

contract Web3EntryExtendStorage {
    address internal _periphery; // slot 21
    // slither-disable-next-line unused-state
    mapping(uint256 => address) internal _operatorByCharacter; // unused slot 22
    // slither-disable-next-line constable-states
    address public resolver; // unused slot 23
    mapping(uint256 => EnumerableSet.AddressSet) internal _operatorsByCharacter; //slot 24
    // characterId => operator => permissionsBitMap
    mapping(uint256 => mapping(address => uint256)) internal _operatorsPermissionBitMap; // slot 25
    // characterId => noteId => Operators4Note
    // only for set note uri
    mapping(uint256 => mapping(uint256 => DataTypes.Operators4Note)) internal _operators4Note; // slot 26

    address internal _newbieVilla; // address of newbieVilla contract
}
// slither-disable-end naming-convention
          

contracts/storage/Web3EntryStorage.sol

// SPDX-License-Identifier: MIT
// slither-disable-start naming-convention
pragma solidity 0.8.16;

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

contract Web3EntryStorage {
    // characterId => Character
    mapping(uint256 => DataTypes.Character) internal _characterById;
    // handleHash => characterId
    mapping(bytes32 => uint256) internal _characterIdByHandleHash;
    // address => characterId
    mapping(address => uint256) internal _primaryCharacterByAddress;

    // characterId =>  (linkType => linklistId)
    mapping(uint256 => mapping(bytes32 => uint256)) internal _attachedLinklists;

    // characterId => noteId => Note
    mapping(uint256 => mapping(uint256 => DataTypes.Note)) internal _noteByIdByCharacter; // slot 14

    /////////////////////////////////
    // link modules
    /////////////////////////////////

    // tokenId => linkModule4Linklist
    mapping(uint256 => address) internal _linkModules4Linklist;

    // tokenAddress => tokenId => linkModule4ERC721
    /// @dev disable `uninitialized-state` check, as linkmodule for erc721 is not enabled currently
    // slither-disable-next-line uninitialized-state
    mapping(address => mapping(uint256 => address)) internal _linkModules4ERC721;

    // address => linkModule4Address
    mapping(address => address) internal _linkModules4Address;

    uint256 internal _characterCounter;
    // LinkList NFT token contract
    address internal _linklist;
    // solhint-disable-next-line private-vars-leading-underscore, var-name-mixedcase
    address internal MINT_NFT_IMPL;
}
// slither-disable-end naming-convention
          

@openzeppelin/contracts/proxy/Clones.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create(0, 0x09, 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) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create2(0, 0x09, 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) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(add(ptr, 0x38), deployer)
            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
            mstore(add(ptr, 0x14), implementation)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
            mstore(add(ptr, 0x58), salt)
            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
            predicted := keccak256(add(ptr, 0x43), 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));
    }
}
          

@openzeppelin/contracts/utils/introspection/ERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
          

contracts/libraries/Constants.sol

// SPDX-License-Identifier: MIT

pragma solidity 0.8.16;

library Constants {
    uint8 public constant MAX_HANDLE_LENGTH = 31;
    uint8 public constant MIN_HANDLE_LENGTH = 3;

    // constants for linkItemType of note struct
    bytes32 public constant LINK_ITEM_TYPE_CHARACTER = "Character";
    bytes32 public constant LINK_ITEM_TYPE_ADDRESS = "Address";
    bytes32 public constant LINK_ITEM_TYPE_LINKLIST = "Linklist";
    bytes32 public constant LINK_ITEM_TYPE_NOTE = "Note";
    bytes32 public constant LINK_ITEM_TYPE_ERC721 = "ERC721";
    bytes32 public constant LINK_ITEM_TYPE_ANYURI = "AnyUri";
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{"contracts/libraries/PostLogic.sol":{"PostLogic":"0x32a54aaaff212d2bdca30c9e33976f3a3cd4384c"},"contracts/libraries/OperatorLogic.sol":{"OperatorLogic":"0x214cfd2b39c6edd0e07d3f4534e34d12b18723a8"},"contracts/libraries/LinkModuleLogic.sol":{"LinkModuleLogic":"0xd7ab27d73b2067b8f8c3eb7f48e4120a5148d270"},"contracts/libraries/LinkLogic.sol":{"LinkLogic":"0x039cd40335453e463186c8bde171280fc547b8d7"},"contracts/libraries/CharacterLogic.sol":{"CharacterLogic":"0x45f6e036e8ab5b6bff0406a21e2793ff0cce1aed"}}}
              

Contract ABI

[{"type":"error","name":"ErrCharacterNotExists","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}]},{"type":"error","name":"ErrHandleContainsInvalidCharacters","inputs":[]},{"type":"error","name":"ErrHandleExists","inputs":[]},{"type":"error","name":"ErrHandleLengthInvalid","inputs":[]},{"type":"error","name":"ErrNotAddressOwner","inputs":[]},{"type":"error","name":"ErrNotCharacterOwner","inputs":[]},{"type":"error","name":"ErrNotEnoughPermission","inputs":[]},{"type":"error","name":"ErrNotEnoughPermissionForThisNote","inputs":[]},{"type":"error","name":"ErrNoteIsDeleted","inputs":[]},{"type":"error","name":"ErrNoteLocked","inputs":[]},{"type":"error","name":"ErrNoteNotExists","inputs":[]},{"type":"error","name":"ErrSocialTokenExists","inputs":[]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"approved","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"approve","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"burn","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}],"name":"createCharacter","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.CreateCharacterData","components":[{"type":"address","name":"to","internalType":"address"},{"type":"string","name":"handle","internalType":"string"},{"type":"string","name":"uri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}],"name":"createThenLinkCharacter","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.createThenLinkCharacterData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"address","name":"to","internalType":"address"},{"type":"bytes32","name":"linkType","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deleteNote","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getApproved","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct DataTypes.Character","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"handle","internalType":"string"},{"type":"string","name":"uri","internalType":"string"},{"type":"uint256","name":"noteCount","internalType":"uint256"},{"type":"address","name":"socialToken","internalType":"address"},{"type":"address","name":"linkModule","internalType":"address"}]}],"name":"getCharacter","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct DataTypes.Character","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"handle","internalType":"string"},{"type":"string","name":"uri","internalType":"string"},{"type":"uint256","name":"noteCount","internalType":"uint256"},{"type":"address","name":"socialToken","internalType":"address"},{"type":"address","name":"linkModule","internalType":"address"}]}],"name":"getCharacterByHandle","inputs":[{"type":"string","name":"handle","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getCharacterUri","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getHandle","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getLinkModule4Address","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getLinkModule4ERC721","inputs":[{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getLinkModule4Linklist","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getLinklistContract","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getLinklistId","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getLinklistType","inputs":[{"type":"uint256","name":"linkListId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getLinklistUri","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct DataTypes.Note","components":[{"type":"bytes32","name":"linkItemType","internalType":"bytes32"},{"type":"bytes32","name":"linkKey","internalType":"bytes32"},{"type":"string","name":"contentUri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"address","name":"mintNFT","internalType":"address"},{"type":"bool","name":"deleted","internalType":"bool"},{"type":"bool","name":"locked","internalType":"bool"}]}],"name":"getNote","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getOperatorPermissions","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getOperators","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"blocklist","internalType":"address[]"},{"type":"address[]","name":"allowlist","internalType":"address[]"}],"name":"getOperators4Note","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPrimaryCharacterId","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRevision","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantOperatorPermissions","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"address","name":"operator","internalType":"address"},{"type":"uint256","name":"permissionBitMap","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantOperators4Note","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"},{"type":"address[]","name":"blocklist","internalType":"address[]"},{"type":"address[]","name":"allowlist","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"string","name":"name_","internalType":"string"},{"type":"string","name":"symbol_","internalType":"string"},{"type":"address","name":"linklist_","internalType":"address"},{"type":"address","name":"mintNFTImpl_","internalType":"address"},{"type":"address","name":"periphery_","internalType":"address"},{"type":"address","name":"newbieVilla_","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOperatorAllowedForNote","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isPrimaryCharacter","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"linkAddress","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.linkAddressData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"address","name":"ethAddress","internalType":"address"},{"type":"bytes32","name":"linkType","internalType":"bytes32"},{"type":"bytes","name":"data","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"linkAnyUri","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.linkAnyUriData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"string","name":"toUri","internalType":"string"},{"type":"bytes32","name":"linkType","internalType":"bytes32"},{"type":"bytes","name":"data","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"linkCharacter","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.linkCharacterData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"uint256","name":"toCharacterId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"},{"type":"bytes","name":"data","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"linkERC721","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.linkERC721Data","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"},{"type":"bytes","name":"data","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"linkLinklist","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.linkLinklistData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"uint256","name":"toLinkListId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"},{"type":"bytes","name":"data","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"linkNote","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.linkNoteData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"uint256","name":"toCharacterId","internalType":"uint256"},{"type":"uint256","name":"toNoteId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"},{"type":"bytes","name":"data","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"lockNote","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}],"name":"mintNote","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.MintNoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"},{"type":"address","name":"to","internalType":"address"},{"type":"bytes","name":"mintModuleData","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes[]","name":"results","internalType":"bytes[]"}],"name":"multicall","inputs":[{"type":"bytes[]","name":"data","internalType":"bytes[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ownerOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"noteId","internalType":"uint256"}],"name":"postNote","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.PostNoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"contentUri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"bytes","name":"mintModuleInitData","internalType":"bytes"},{"type":"bool","name":"locked","internalType":"bool"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"postNote4Address","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.PostNoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"contentUri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"bytes","name":"mintModuleInitData","internalType":"bytes"},{"type":"bool","name":"locked","internalType":"bool"}]},{"type":"address","name":"ethAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"postNote4AnyUri","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.PostNoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"contentUri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"bytes","name":"mintModuleInitData","internalType":"bytes"},{"type":"bool","name":"locked","internalType":"bool"}]},{"type":"string","name":"uri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"postNote4Character","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.PostNoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"contentUri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"bytes","name":"mintModuleInitData","internalType":"bytes"},{"type":"bool","name":"locked","internalType":"bool"}]},{"type":"uint256","name":"toCharacterId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"postNote4ERC721","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.PostNoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"contentUri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"bytes","name":"mintModuleInitData","internalType":"bytes"},{"type":"bool","name":"locked","internalType":"bool"}]},{"type":"tuple","name":"erc721","internalType":"struct DataTypes.ERC721Struct","components":[{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"erc721TokenId","internalType":"uint256"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"postNote4Linklist","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.PostNoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"contentUri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"bytes","name":"mintModuleInitData","internalType":"bytes"},{"type":"bool","name":"locked","internalType":"bool"}]},{"type":"uint256","name":"toLinklistId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"postNote4Note","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.PostNoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"contentUri","internalType":"string"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"bytes","name":"mintModuleInitData","internalType":"bytes"},{"type":"bool","name":"locked","internalType":"bool"}]},{"type":"tuple","name":"note","internalType":"struct DataTypes.NoteStruct","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"resolver","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes","name":"_data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCharacterUri","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"newUri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setHandle","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"string","name":"newHandle","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLinkModule4Address","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.setLinkModule4AddressData","components":[{"type":"address","name":"account","internalType":"address"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLinkModule4Linklist","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.setLinkModule4LinklistData","components":[{"type":"uint256","name":"linklistId","internalType":"uint256"},{"type":"address","name":"linkModule","internalType":"address"},{"type":"bytes","name":"linkModuleInitData","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLinklistUri","inputs":[{"type":"uint256","name":"linklistId","internalType":"uint256"},{"type":"string","name":"uri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMintModule4Note","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.setMintModule4NoteData","components":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"},{"type":"address","name":"mintModule","internalType":"address"},{"type":"bytes","name":"mintModuleInitData","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNoteUri","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"uint256","name":"noteId","internalType":"uint256"},{"type":"string","name":"newUri","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPrimaryCharacterId","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSocialToken","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"address","name":"tokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenByIndex","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenOfOwnerByIndex","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"tokenURI","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlinkAddress","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.unlinkAddressData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"address","name":"ethAddress","internalType":"address"},{"type":"bytes32","name":"linkType","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlinkAnyUri","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.unlinkAnyUriData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"string","name":"toUri","internalType":"string"},{"type":"bytes32","name":"linkType","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlinkCharacter","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.unlinkCharacterData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"uint256","name":"toCharacterId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlinkERC721","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.unlinkERC721Data","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlinkLinklist","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.unlinkLinklistData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"uint256","name":"toLinkListId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlinkNote","inputs":[{"type":"tuple","name":"vars","internalType":"struct DataTypes.unlinkNoteData","components":[{"type":"uint256","name":"fromCharacterId","internalType":"uint256"},{"type":"uint256","name":"toCharacterId","internalType":"uint256"},{"type":"uint256","name":"toNoteId","internalType":"uint256"},{"type":"bytes32","name":"linkType","internalType":"bytes32"}]}]}]
              

Contract Creation Code

0x608060405234801561001057600080fd5b50615b5980620000216000396000f3fe608060405234801561001057600080fd5b506004361061043e5760003560e01c8063867884e611610236578063c053f6b81161013b578063dc17b6de116100c3578063ef0828ab11610087578063ef0828ab14610a71578063f2ad807514610a84578063f316bacd14610a97578063f6479d7714610aaa578063fe9299fb14610abd57600080fd5b8063dc17b6de146109e9578063dca27135146109fc578063e56f2fe414610a0f578063e985e9c514610a22578063ec81d19414610a5e57600080fd5b8063cd69fe611161010a578063cd69fe6114610965578063d23b320b14610978578063d70e10c61461098b578063dabb0531146109b6578063db491e80146109c957600080fd5b8063c053f6b81461091b578063c2a6fe3b1461092c578063c87b56dd1461093f578063cb8e757e1461095257600080fd5b80639a4dec18116101be578063a7ccb4bf1161018d578063a7ccb4bf146108af578063ac9650d8146108c2578063af90b112146108e2578063b88d4fde146108f5578063b9d328451461090857600080fd5b80639a4dec18146108565780639a50248d14610869578063a22cb46514610889578063a6e6178d1461089c57600080fd5b806393f057e51161020557806393f057e5146107df578063952be0ef146107f257806395d89b411461082857806395d9fa7d146108305780639864c3071461084357600080fd5b8063867884e6146107935780638734bbfc146107a65780638b4ca06a146107b957806392f7070b146107cc57600080fd5b80632f745c591161034757806347f94de7116102cf578063628b644a11610293578063628b644a146107275780636352211e1461073a5780636bf55d5f1461074d57806370a082311461076d57806374f345cf1461078057600080fd5b806347f94de7146106ba57806349186953146106cd5780634f6ccce7146106ee5780635a936d10146107015780635fb881831461071457600080fd5b8063388f508311610316578063388f50831461065b57806340ad34d81461066e57806342842e0e1461068157806342966c681461069457806344b82a24146106a757600080fd5b80632f745c59146105f657806331b9d08c14610609578063327b2a031461063557806333f06ee61461064857600080fd5b8063144a3e83116103ca5780632209d145116103995780632209d1451461055e57806323b872dd1461059457806328fbb805146105a757806329c301c2146105ba5780632abc6bf6146105cd57600080fd5b8063144a3e831461051d57806318160ddd14610530578063188b04b314610538578063206657f21461054b57600080fd5b806308cb68ff1161041157806308cb68ff146104be578063095ea7b3146104d35780630c4dd5f2146104e65780630ff98244146104f95780631316529d1461050c57600080fd5b806301ffc9a71461044357806304f3bcec1461046b57806306fdde0314610496578063081812fc146104ab575b600080fd5b6104566104513660046145e1565b610ae6565b60405190151581526020015b60405180910390f35b60175461047e906001600160a01b031681565b6040516001600160a01b039091168152602001610462565b61049e610b11565b604051610462919061464e565b61047e6104b9366004614661565b610ba3565b6104d16104cc366004614692565b610c3d565b005b6104d16104e13660046146e2565b610d14565b6104d16104f4366004614692565b610e29565b6104d161050736600461470c565b610f33565b60045b604051908152602001610462565b61049e61052b366004614661565b610fac565b60085461050f565b6104d161054636600461473a565b610fb7565b6104d161055936600461476e565b611055565b61047e61056c3660046146e2565b6001600160a01b03918216600090815260106020908152604080832093835292905220541690565b6104d16105a23660046147a3565b6110ed565b6104566105b53660046147cf565b61111e565b61050f6105c8366004614816565b611135565b61050f6105db36600461484a565b6001600160a01b03166000908152600c602052604090205490565b61050f6106043660046146e2565b6111c6565b61047e61061736600461484a565b6001600160a01b039081166000908152601160205260409020541690565b61050f610643366004614877565b61125c565b6104d1610656366004614904565b6113eb565b6104d161066936600461473a565b6114d2565b6104d161067c36600461494f565b611557565b6104d161068f3660046147a3565b6115d3565b6104d16106a2366004614661565b6115ee565b61050f6106b536600461496b565b61168b565b6104d16106c8366004614904565b6116ec565b6106e06106db3660046149af565b611753565b604051610462929190614a15565b61050f6106fc366004614661565b6117ab565b6104d161070f36600461470c565b61183e565b6104d161072236600461473a565b6118b7565b6104d1610735366004614a3a565b611925565b61047e610748366004614661565b6119b2565b61076061075b366004614661565b611a29565b6040516104629190614a8c565b61050f61077b36600461484a565b611a43565b6104d161078e3660046149af565b611aca565b6104d16107a136600461494f565b611b44565b6104566107b4366004614661565b611bee565b61050f6107c7366004614661565b611c1c565b61050f6107da366004614a9f565b611c88565b6104d16107ed36600461470c565b611d03565b61050f610800366004614ae3565b60009182526019602090815260408084206001600160a01b0393909316845291905290205490565b61049e611da3565b6104d161083e366004614ae3565b611db2565b6104d161085136600461473a565b611e44565b61050f610864366004614877565b611ea5565b61087c610877366004614b06565b611f90565b6040516104629190614b47565b6104d1610897366004614bd3565b61213f565b6104d16108aa366004614904565b61214a565b61050f6108bd36600461473a565b6121f5565b6108d56108d0366004614c41565b612296565b6040516104629190614c76565b61050f6108f036600461496b565b61238a565b6104d1610903366004614dc3565b6123b1565b6104d1610916366004614e3c565b6123e9565b6013546001600160a01b031661047e565b6104d161093a3660046149af565b61249c565b61049e61094d366004614661565b61250e565b6104d1610960366004614e3c565b6125b3565b61050f610973366004614e3c565b612642565b6104d161098636600461473a565b612657565b61050f6109993660046149af565b6000918252600d6020908152604080842092845291905290205490565b61087c6109c4366004614661565b6126e2565b6109dc6109d73660046149af565b612869565b6040516104629190614e70565b6104d16109f7366004614f06565b6129ca565b61049e610a0a366004614661565b612a5b565b6104d1610a1d366004614f88565b612acd565b610456610a30366004615039565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61049e610a6c366004614661565b612c5a565b6104d1610a7f366004614692565b612c7a565b6104d1610a92366004614661565b612d04565b61050f610aa5366004615063565b612d53565b61050f610ab836600461470c565b612e94565b61047e610acb366004614661565b6000908152600f60205260409020546001600160a01b031690565b60006001600160e01b0319821663780e9d6360e01b1480610b0b5750610b0b82612faf565b92915050565b606060008054610b20906150be565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4c906150be565b8015610b995780601f10610b6e57610100808354040283529160200191610b99565b820191906000526020600020905b815481529060010190602001808311610b7c57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610c215760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b610c4a602082018261484a565b6001600160a01b0316336001600160a01b031614610c7b5760405163ca67421960e01b815260040160405180910390fd5b73d7ab27d73b2067b8f8c3eb7f48e4120a5148d27063dfc34f25610ca2602084018461484a565b610cb2604085016020860161484a565b610cbf60408601866150f2565b60116040518663ffffffff1660e01b8152600401610ce1959493929190615161565b60006040518083038186803b158015610cf957600080fd5b505af4158015610d0d573d6000803e3d6000fd5b5050505050565b6000610d1f826119b2565b9050806001600160a01b0316836001600160a01b031603610d8c5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610c18565b336001600160a01b0382161480610da85750610da88133610a30565b610e1a5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610c18565b610e248383612fff565b505050565b6013546040516367880d6160e11b8152823560048201526000916001600160a01b03169063cf101ac290602401602060405180830381865afa158015610e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9791906151a0565b9050610ea48160c161306d565b73d7ab27d73b2067b8f8c3eb7f48e4120a5148d270636252159e8335610ed0604086016020870161484a565b610edd60408701876150f2565b600f6040518663ffffffff1660e01b8152600401610eff9594939291906151b9565b60006040518083038186803b158015610f1757600080fd5b505af4158015610f2b573d6000803e3d6000fd5b505050505050565b610f3f813560b261306d565b60135481356000818152600d6020908152604080832081870135808552908352928190205490516337fb824760e11b815273039cd40335453e463186c8bde171280fc547b8d795636ff7048e95610ce19590948901359390926001600160a01b03909216916004016151e4565b6060610b0b8261250e565b610fc3813560b261306d565b610fd081602001356130fe565b73039cd40335453e463186c8bde171280fc547b8d7639ec52a2382356020840135604085013561100360608701876150f2565b6013546020808a01356000908152600a9091526040908190206005015490516001600160e01b031960e08a901b168152610ce19796959493926001600160a01b03908116921690600d90600401615210565b61106083600261306d565b604051631f8c0b6760e11b8152600481018490526001600160a01b038316602482015260448101829052601860648201526019608482015273214cfd2b39c6edd0e07d3f4534e34d12b18723a890633f1816ce9060a4015b60006040518083038186803b1580156110d057600080fd5b505af41580156110e4573d6000803e3d6000fd5b50505050505050565b6110f73382613139565b6111135760405162461bcd60e51b8152600401610c189061525d565b610e24838383613230565b600061112b8484846133dd565b90505b9392505050565b6000611143823560ec61306d565b61114d8235613467565b6040516342a34a5360e01b81529091507332a54aaaff212d2bdca30c9e33976f3a3cd4384c906342a34a539061119190859085906000908190600e906004016153b5565b60006040518083038186803b1580156111a957600080fd5b505af41580156111bd573d6000803e3d6000fd5b50505050919050565b60006111d183611a43565b82106112335760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610c18565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600061126a833560ca61306d565b6545524337323160d01b60006112808535613467565b6013549091506000906001600160a01b0316632ea24efc826112a5602089018961484a565b6040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152602088013560448201526064016020604051808303816000875af11580156112fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131f91906151a0565b90507332a54aaaff212d2bdca30c9e33976f3a3cd4384c6342a34a538784868561134c60208c018c61484a565b8b6020013560405160200161137f92919060609290921b6bffffffffffffffffffffffff19168252601482015260340190565b604051602081830303815290604052600e6040518763ffffffff1660e01b81526004016113b1969594939291906153fa565b60006040518083038186803b1580156113c957600080fd5b505af41580156113dd573d6000803e3d6000fd5b509398975050505050505050565b6013546040516367880d6160e11b8152600481018590526000916001600160a01b03169063cf101ac290602401602060405180830381865afa158015611435573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145991906151a0565b90506114668160b161306d565b601354604051633c17845760e11b81526001600160a01b039091169063782f08ae9061149a90879087908790600401615445565b600060405180830381600087803b1580156114b457600080fd5b505af11580156114c8573d6000803e3d6000fd5b5050505050505050565b6114de813560b961306d565b73039cd40335453e463186c8bde171280fc547b8d763a4159c6b823561150a604085016020860161484a565b6013546040805160e086901b6001600160e01b031916815260048101949094526001600160a01b0392831660248501528601356044840152166064820152600d608482015260a401610ce1565b611563813560b661306d565b60135460408051631d4deabf60e01b81528335600482015260208401356024820152908301356044820152606083013560648201526001600160a01b039091166084820152600d60a482015273039cd40335453e463186c8bde171280fc547b8d790631d4deabf9060c401610ce1565b610e24838383604051806020016040528060008152506123b1565b6000818152600a6020526040808220905161160c916001019061545f565b60408051918290039091206000818152600b6020908152838220829055858252600a9052918220828155909250906116476001830182614530565b611655600283016000614530565b50600060038201556004810180546001600160a01b031990811690915560059091018054909116905561168782613490565b5050565b6000611699833560c861306d565b67131a5b9adb1a5cdd60c21b60006116b18535613467565b905060008460001b90507332a54aaaff212d2bdca30c9e33976f3a3cd4384c6342a34a53878486858a60405160200161137f91815260200190565b6116f78360b061306d565b6000838152600a6020526040902060020161171382848361551b565b50827f17d7c9f69270ba135480ef16837f38b9d37d3ab291cbd3ba03982290c663199783836040516117469291906155da565b60405180910390a2505050565b6000828152601a602090815260408083208484529091529020606090819061177a906134ef565b6000858152601a6020908152604080832087845290915290209092506117a2906002016134ef565b90509250929050565b60006117b660085490565b82106118195760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610c18565b6008828154811061182c5761182c6155ee565b90600052602060002001549050919050565b61184a813560be61306d565b60135481356000818152600d602090815260408083208187013580855290835292819020549051633fe4fe3960e11b815273039cd40335453e463186c8bde171280fc547b8d795637fc9fc7295610ce19590948901359390926001600160a01b03909216916004016151e4565b6118c3813560bb61306d565b73039cd40335453e463186c8bde171280fc547b8d76348391dcb82356118ec60208501856150f2565b601354604080516001600160e01b031960e088901b168152610ce19594939291890135916001600160a01b031690600d90600401615604565b61192f84846134fc565b6119398484613561565b61194384846135d8565b6040516001626802bf60e01b031981527332a54aaaff212d2bdca30c9e33976f3a3cd4384c9063ff97fd4190611986908790879087908790600e90600401615645565b60006040518083038186803b15801561199e57600080fd5b505af41580156114c8573d6000803e3d6000fd5b6000818152600260205260408120546001600160a01b031680610b0b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610c18565b6000818152601860205260409020606090610b0b906134ef565b60006001600160a01b038216611aae5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610c18565b506001600160a01b031660009081526003602052604090205490565b611ad58260c461306d565b611adf8282613561565b6000828152600e60209081526040808320848452825291829020600501805460ff60a81b1916600160a81b179055905182815283917f036469f3e73c83520cdefa197d7a9c854c2f8bc0164b82e9f2bd4aa7e150fd3091015b60405180910390a25050565b611b50813560b861306d565b73039cd40335453e463186c8bde171280fc547b8d763154246368235611b7c604085016020860161484a565b60135485356000908152600d6020908152604080832060608a013580855292529182902054825160e088901b6001600160e01b031916815260048101969096526001600160a01b03948516602487015291880135604486015260648501529116608483015260a482015260c401610ce1565b600080611bfa836119b2565b6001600160a01b03166000908152600c60205260409020549290921492915050565b60135460405162fba02760e01b8152600481018390526000916001600160a01b03169062fba02790602401602060405180830381865afa158015611c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0b91906151a0565b6000611c96833560c761306d565b664164647265737360c81b6000611cad8535613467565b6040516bffffffffffffffffffffffff19606087901b1660208201529091506001600160a01b038516907332a54aaaff212d2bdca30c9e33976f3a3cd4384c906342a34a5390889085908790869060340161137f565b611d0f813560ba61306d565b73039cd40335453e463186c8bde171280fc547b8d76393c96a528235611d3b604085016020860161484a565b60135485356000908152600d60209081526040808320818a013580855292529182902054915160e087901b6001600160e01b031916815260048101959095526001600160a01b039384166024860152604485015291166064830152608482015260a401610ce1565b606060018054610b20906150be565b611dbd82600161306d565b6000828152600a60205260409020600401546001600160a01b031615611df65760405163fe6f50e560e01b815260040160405180910390fd5b6040516384b44a2f60e01b8152600481018390526001600160a01b0382166024820152600a60448201527345f6e036e8ab5b6bff0406a21e2793ff0cce1aed906384b44a2f90606401610eff565b611e50813560bd61306d565b60135460408051632ca904df60e01b815273039cd40335453e463186c8bde171280fc547b8d792632ca904df92610ce192863592602088013592880135916001600160a01b0390911690600d906004016151e4565b6000611eb3833560c961306d565b634e6f746560e01b6000611ec78535613467565b601354604051635cb46be760e01b815260006004820181905287356024830152602088013560448301529293506001600160a01b0390911690635cb46be7906064016020604051808303816000875af1158015611f28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f4c91906151a0565b90507332a54aaaff212d2bdca30c9e33976f3a3cd4384c6342a34a53878486858a600001358b6020013560405160200161137f929190918252602082015260400190565b611f9861456a565b60008383604051611faa929190615665565b604080519182900382206000818152600b602090815283822054808352600a82529184902060c0860190945283548552600184018054939650919493929084019190611ff5906150be565b80601f0160208091040260200160405190810160405280929190818152602001828054612021906150be565b801561206e5780601f106120435761010080835404028352916020019161206e565b820191906000526020600020905b81548152906001019060200180831161205157829003601f168201915b50505050508152602001600282018054612087906150be565b80601f01602080910402602001604051908101604052809291908181526020018280546120b3906150be565b80156121005780601f106120d557610100808354040283529160200191612100565b820191906000526020600020905b8154815290600101906020018083116120e357829003601f168201915b50505091835250506003820154602082015260048201546001600160a01b03908116604083015260059092015490911660609091015295945050505050565b61168733838361361d565b61215583600061306d565b6121758282604051612168929190615665565b60405180910390206136eb565b6121b482828080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061371892505050565b60405163130f361d60e01b81527345f6e036e8ab5b6bff0406a21e2793ff0cce1aed9063130f361d906110b890869086908690600b90600a90600401615675565b600061220682356020840135613561565b7332a54aaaff212d2bdca30c9e33976f3a3cd4384c639d2e06f083356020850135612237606087016040880161484a565b61224460608801886150f2565b6014546040516001600160e01b031960e089901b1681526122799695949392916001600160a01b031690600e906004016156a3565b602060405180830381865af4158015611c64573d6000803e3d6000fd5b6060816001600160401b038111156122b0576122b0614cd8565b6040519080825280602002602001820160405280156122e357816020015b60608152602001906001900390816122ce5790505b50905060005b828110156123835761235330858584818110612307576123076155ee565b905060200281019061231991906150f2565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061378592505050565b828281518110612365576123656155ee565b6020026020010181905250808061237b906156fd565b9150506122e9565b5092915050565b6000612398833560c661306d565b6821b430b930b1ba32b960b91b60006116b18535613467565b6123bb3383613139565b6123d75760405162461bcd60e51b8152600401610c189061525d565b6123e3848484846137aa565b50505050565b6123f5813560b561306d565b61240781602001358260400135613561565b73039cd40335453e463186c8bde171280fc547b8d76371bd9b06823560208401356040850135606086013561243f60808801886150f2565b6013546020808b01356000908152600e82526040808220818e013583529092528190206003015490516001600160e01b031960e08b901b168152610ce1989796959493926001600160a01b03908116921690600d90600401615716565b6124a78260c561306d565b6124b18282613561565b6000828152600e60209081526040808320848452825291829020600501805460ff60a01b1916600160a01b179055905182815283917f4f1db9708b537c1d26a7af4b235fd079bf2342d92a276e27eb6c8717e8bbcf939101611b38565b6000818152600a6020526040902060020180546060919061252e906150be565b80601f016020809104026020016040519081016040528092919081815260200182805461255a906150be565b80156125a75780601f1061257c576101008083540402835291602001916125a7565b820191906000526020600020905b81548152906001019060200180831161258a57829003601f168201915b50505050509050919050565b6125bf813560b761306d565b73039cd40335453e463186c8bde171280fc547b8d763f35deae182356125eb604085016020860161484a565b6013546040805160e086901b6001600160e01b031916815260048101949094526001600160a01b039283166024850152860135604484015260608601356064840152166084820152600d60a482015260c401610ce1565b6000610b0b6126508361576c565b60016137dd565b612663813560c261306d565b61267281356020830135613561565b612681813560208301356135d8565b73d7ab27d73b2067b8f8c3eb7f48e4120a5148d2706320828a02823560208401356126b2606086016040870161484a565b6126bf60608701876150f2565b600e6040518763ffffffff1660e01b8152600401610ce19695949392919061581f565b6126ea61456a565b600a60008381526020019081526020016000206040518060c001604052908160008201548152602001600182018054612722906150be565b80601f016020809104026020016040519081016040528092919081815260200182805461274e906150be565b801561279b5780601f106127705761010080835404028352916020019161279b565b820191906000526020600020905b81548152906001019060200180831161277e57829003601f168201915b505050505081526020016002820180546127b4906150be565b80601f01602080910402602001604051908101604052809291908181526020018280546127e0906150be565b801561282d5780601f106128025761010080835404028352916020019161282d565b820191906000526020600020905b81548152906001019060200180831161281057829003601f168201915b50505091835250506003820154602082015260048201546001600160a01b03908116604083015260059092015490911660609091015292915050565b60408051610100808201835260008083526020808401829052606084860181905284018290526080840182905260a0840182905260c0840182905260e08401829052868252600e815284822086835281529084902084519283018552805483526001810154918301919091526002810180549394929391928401916128ed906150be565b80601f0160208091040260200160405190810160405280929190818152602001828054612919906150be565b80156129665780601f1061293b57610100808354040283529160200191612966565b820191906000526020600020905b81548152906001019060200180831161294957829003601f168201915b505050918352505060038201546001600160a01b039081166020830152600483015481166040830152600590920154918216606082015260ff600160a01b8304811615156080830152600160a81b909204909116151560a090910152905092915050565b6129d586600361306d565b6129df8686613561565b604051630afb883f60e41b815273214cfd2b39c6edd0e07d3f4534e34d12b18723a89063afb883f090612a2390899089908990899089908990601a9060040161589c565b60006040518083038186803b158015612a3b57600080fd5b505af4158015612a4f573d6000803e3d6000fd5b50505050505050505050565b601354604051632b05429560e21b8152600481018390526060916001600160a01b03169063ac150a5490602401600060405180830381865afa158015612aa5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b0b91908101906158e4565b601454600390600160a81b900460ff16158015612af8575060145460ff808316600160a01b90920416105b612b5b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c18565b6014805460ff60a81b1960ff8416600160a01b021661ffff60a01b1990911617600160a81b179055612b8f898989896138ba565b601380546001600160a01b03199081166001600160a01b0388811691909117909255601480548216878416179055601580548216868416179055601b80549091169184169190911790556040514281527f400175a56dd3710794078f7b9dbe8296ac94c5a248dfd51bb22ed4ab9eaa9fbf9060200160405180910390a16014805460ff60a81b1916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050505050565b6000818152600a6020526040902060010180546060919061252e906150be565b612c86813560bc61306d565b73039cd40335453e463186c8bde171280fc547b8d7631873e2188235612caf60208501856150f2565b60135486356000908152600d60209081526040808320818b01358085529252918290205491516001600160e01b031960e089901b168152610ce19695949391926001600160a01b039092169190600401615604565b612d0d8161390b565b336000818152600c602052604080822080549085905590519092839285927fce95332e6082aebeb8058a7b56d1a109f67d6550552ed04d36aca4a6acd4d7de9190a45050565b6000612d61843560cb61306d565b65416e7955726960d01b6000612d778635613467565b601354604051633610bf0960e11b81529192506000916001600160a01b0390911690636c217e1290612db19084908a908a90600401615445565b6020604051808303816000875af1158015612dd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612df491906151a0565b90507332a54aaaff212d2bdca30c9e33976f3a3cd4384c6342a34a53888486858b8b604051602001612e27929190615665565b604051602081830303815290604052600e6040518763ffffffff1660e01b8152600401612e59969594939291906153fa565b60006040518083038186803b158015612e7157600080fd5b505af4158015612e85573d6000803e3d6000fd5b50939998505050505050505050565b6000612ea2823560b461306d565b612f306040518060a00160405280846020016020810190612ec3919061484a565b6001600160a01b03168152602001612eec856020016020810190612ee7919061484a565b613971565b815260200160405180602001604052806000815250815260200160006001600160a01b031681526020016040518060200160405280600081525081525060006137dd565b60135460408051639ec52a2360e01b8152853560048201526024810184905290850135604482015260e06064820152600060e482018190526001600160a01b03909216608482015260a4810191909152600d60c482015290915073039cd40335453e463186c8bde171280fc547b8d790639ec52a239061010401611191565b60006001600160e01b031982166380ac58cd60e01b1480612fe057506001600160e01b03198216635b5e139f60e01b145b80610b0b57506301ffc9a760e01b6001600160e01b0319831614610b0b565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190613034826119b2565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b61307682613a7a565b1561307f575050565b6015546001600160a01b031633036130bb576000828152601960209081526040808320328452909152902054600190821c8116036130bb575050565b6000828152601960209081526040808320338452909152902054600190821c8116036130e5575050565b604051632c4bc2b960e21b815260040160405180910390fd5b6000818152600260205260409020546001600160a01b0316613136576040516375af0fc960e11b815260048101829052602401610c18565b50565b6000818152600260205260408120546001600160a01b03166131b25760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610c18565b60006131bd836119b2565b9050806001600160a01b0316846001600160a01b031614806131f85750836001600160a01b03166131ed84610ba3565b6001600160a01b0316145b8061322857506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316613243826119b2565b6001600160a01b0316146132a75760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610c18565b6001600160a01b0382166133095760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610c18565b613314838383613ada565b61331f600082612fff565b6001600160a01b0383166000908152600360205260408120805460019290613348908490615951565b90915550506001600160a01b0382166000908152600360205260408120805460019290613376908490615964565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4610e24838383613bac565b6000838152601a6020908152604080832085845290915281206134008184613be9565b1561340f57600091505061112e565b61341c6002820184613be9565b1561342b57600191505061112e565b60008581526019602090815260408083206001600160a01b038716845290915290205461345e9060c31c60019081161490565b95945050505050565b6000818152600a6020526040812060030180548290613485906156fd565b918290555092915050565b61349a3382613139565b6134e65760405162461bcd60e51b815260206004820152601b60248201527f4e4654426173653a204e6f744f776e65724f72417070726f76656400000000006044820152606401610c18565b61313681613c0b565b6060600061112e83613cba565b61350582613a7a565b1561350e575050565b6015546001600160a01b031633036135345761352b8282326133dd565b15613534575050565b61353f8282336133dd565b15613548575050565b604051631a1d1d4760e11b815260040160405180910390fd5b6000828152600e60209081526040808320848452909152902060050154600160a01b900460ff16156135a657604051631f0fc8f560e11b815260040160405180910390fd5b6000828152600a6020526040902060030154811115611687576040516364783acb60e01b815260040160405180910390fd5b6000828152600e60209081526040808320848452909152902060050154600160a81b900460ff161561168757604051630bc06a0f60e21b815260040160405180910390fd5b816001600160a01b0316836001600160a01b03160361367e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610c18565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6000818152600b60205260409020541561313657604051631b659b9f60e21b815260040160405180910390fd5b80518190601f81118061372b5750600381105b1561374957604051636f819c2160e11b815260040160405180910390fd5b60005b818110156123e35761377d838281518110613769576137696155ee565b01602001516001600160f81b031916613d15565b60010161374c565b606061112e8383604051806060016040528060278152602001615afd60279139613dc3565b6137b5848484613230565b6137c184848484613e3b565b6123e35760405162461bcd60e51b8152600401610c1890615977565b60006137f38360200151805190602001206136eb565b8115613806576138068360200151613718565b601260008154613815906156fd565b918290555083519091506138299082613f3c565b7345f6e036e8ab5b6bff0406a21e2793ff0cce1aed634daae5688460000151856020015186604001518760600151886080015187600b600a6040518963ffffffff1660e01b81526004016138849897969594939291906159c9565b60006040518083038186803b15801561389c57600080fd5b505af41580156138b0573d6000803e3d6000fd5b5050505092915050565b6138c684848484613f56565b7f414cd0b34676984f09a5f76ce9718d4062e50283abe0e7e274a9a5b4e0c99c3084848484426040516138fd959493929190615a40565b60405180910390a150505050565b6000613916826119b2565b6015549091506001600160a01b03163314801561393b5750326001600160a01b038216145b15613944575050565b6001600160a01b0381163303613958575050565b604051631b0c476f60e11b815260040160405180910390fd5b60408051602a80825260608281019093526f181899199a1a9b1b9c1cb0b131b232b360811b916001600160a01b0385169160009190602082018180368337019050509050600360fc1b816000815181106139cd576139cd6155ee565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106139fc576139fc6155ee565b60200101906001600160f81b031916908160001a90535060295b6001811115613a71578383600f1660108110613a3457613a346155ee565b1a60f81b828281518110613a4a57613a4a6155ee565b60200101906001600160f81b031916908160001a90535060049290921c9160001901613a16565b50949350505050565b600080613a86836119b2565b90506001600160a01b0381163303613aa15750600192915050565b6015546001600160a01b031633148015613ac35750326001600160a01b038216145b15613ad15750600192915050565b50600092915050565b601b546001600160a01b03848116911614613ba1576000818152601860205260408120613b0690613f71565b600083815260186020526040812091925090613b21906134ef565b905060005b82811015613b6357613b5184838381518110613b4457613b446155ee565b6020026020010151613f7b565b80613b5b816156fd565b915050613b26565b506001600160a01b0385166000908152600c6020526040902054839003613b9e576001600160a01b0385166000908152600c60205260408120555b50505b610e24838383613fb4565b6001600160a01b0382166000908152600c60205260408120549003610e24576001600160a01b03919091166000908152600c602052604090205550565b6001600160a01b0381166000908152600183016020526040812054151561112e565b6000613c16826119b2565b9050613c2481600084613ada565b613c2f600083612fff565b6001600160a01b0381166000908152600360205260408120805460019290613c58908490615951565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a461168781600084613bac565b6060816000018054806020026020016040519081016040528092919081815260200182805480156125a757602002820191906000526020600020905b815481526020019060010190808311613cf65750505050509050919050565b600360fc1b6001600160f81b031982161080613d3e5750603d60f91b6001600160f81b03198216115b80613d6e5750603960f81b6001600160f81b03198216118015613d6e5750606160f81b6001600160f81b03198216105b8015613d885750602d60f81b6001600160f81b0319821614155b8015613da25750605f60f81b6001600160f81b0319821614155b15613136576040516001621693dd60e01b0319815260040160405180910390fd5b6060600080856001600160a01b031685604051613de09190615a7a565b600060405180830381855af49150503d8060008114613e1b576040519150601f19603f3d011682016040523d82523d6000602084013e613e20565b606091505b5091509150613e318683838761406c565b9695505050505050565b60006001600160a01b0384163b15613f3157604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613e7f903390899088908890600401615a96565b6020604051808303816000875af1925050508015613eba575060408051601f3d908101601f19168201909252613eb791810190615ac9565b60015b613f17573d808015613ee8576040519150601f19603f3d011682016040523d82523d6000602084013e613eed565b606091505b508051600003613f0f5760405162461bcd60e51b8152600401610c1890615977565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050613228565b506001949350505050565b6116878282604051806020016040528060008152506140e5565b6000613f6384868361551b565b506001610d0d82848361551b565b6000610b0b825490565b60008281526019602090815260408083206001600160a01b0385168452825280832083905584835260189091529020610e249082614118565b6001600160a01b03831661400f5761400a81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b614032565b816001600160a01b0316836001600160a01b03161461403257614032838261412d565b6001600160a01b03821661404957610e24816141ca565b826001600160a01b0316826001600160a01b031614610e2457610e248282614279565b606083156140db5782516000036140d4576001600160a01b0385163b6140d45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c18565b5081613228565b61322883836142bd565b6140ef83836142e7565b6140fc6000848484613e3b565b610e245760405162461bcd60e51b8152600401610c1890615977565b600061112e836001600160a01b03841661443d565b6000600161413a84611a43565b6141449190615951565b600083815260076020526040902054909150808214614197576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906141dc90600190615951565b60008381526009602052604081205460088054939450909284908110614204576142046155ee565b906000526020600020015490508060088381548110614225576142256155ee565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061425d5761425d615ae6565b6001900381819060005260206000200160009055905550505050565b600061428483611a43565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b8151156142cd5781518083602001fd5b8060405162461bcd60e51b8152600401610c18919061464e565b6001600160a01b03821661433d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c18565b6000818152600260205260409020546001600160a01b0316156143a25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c18565b6143ae60008383613ada565b6001600160a01b03821660009081526003602052604081208054600192906143d7908490615964565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a461168760008383613bac565b60008181526001830160205260408120548015614526576000614461600183615951565b855490915060009061447590600190615951565b90508181146144da576000866000018281548110614495576144956155ee565b90600052602060002001549050808760000184815481106144b8576144b86155ee565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806144eb576144eb615ae6565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b0b565b6000915050610b0b565b50805461453c906150be565b6000825580601f1061454c575050565b601f01602090049060005260206000209081019061313691906145b2565b6040518060c001604052806000815260200160608152602001606081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b5b808211156145c757600081556001016145b3565b5090565b6001600160e01b03198116811461313657600080fd5b6000602082840312156145f357600080fd5b813561112e816145cb565b60005b83811015614619578181015183820152602001614601565b50506000910152565b6000815180845261463a8160208601602086016145fe565b601f01601f19169290920160200192915050565b60208152600061112e6020830184614622565b60006020828403121561467357600080fd5b5035919050565b60006060828403121561468c57600080fd5b50919050565b6000602082840312156146a457600080fd5b81356001600160401b038111156146ba57600080fd5b6132288482850161467a565b80356001600160a01b03811681146146dd57600080fd5b919050565b600080604083850312156146f557600080fd5b6146fe836146c6565b946020939093013593505050565b60006060828403121561471e57600080fd5b61112e838361467a565b60006080828403121561468c57600080fd5b60006020828403121561474c57600080fd5b81356001600160401b0381111561476257600080fd5b61322884828501614728565b60008060006060848603121561478357600080fd5b83359250614793602085016146c6565b9150604084013590509250925092565b6000806000606084860312156147b857600080fd5b6147c1846146c6565b9250614793602085016146c6565b6000806000606084860312156147e457600080fd5b83359250602084013591506147fb604085016146c6565b90509250925092565b600060e0828403121561468c57600080fd5b60006020828403121561482857600080fd5b81356001600160401b0381111561483e57600080fd5b61322884828501614804565b60006020828403121561485c57600080fd5b61112e826146c6565b60006040828403121561468c57600080fd5b6000806060838503121561488a57600080fd5b82356001600160401b038111156148a057600080fd5b6148ac85828601614804565b9250506117a28460208501614865565b60008083601f8401126148ce57600080fd5b5081356001600160401b038111156148e557600080fd5b6020830191508360208285010111156148fd57600080fd5b9250929050565b60008060006040848603121561491957600080fd5b8335925060208401356001600160401b0381111561493657600080fd5b614942868287016148bc565b9497909650939450505050565b60006080828403121561496157600080fd5b61112e8383614728565b6000806040838503121561497e57600080fd5b82356001600160401b0381111561499457600080fd5b6149a085828601614804565b95602094909401359450505050565b600080604083850312156149c257600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b83811015614a0a5781516001600160a01b0316875295820195908201906001016149e5565b509495945050505050565b604081526000614a2860408301856149d1565b828103602084015261345e81856149d1565b60008060008060608587031215614a5057600080fd5b843593506020850135925060408501356001600160401b03811115614a7457600080fd5b614a80878288016148bc565b95989497509550505050565b60208152600061112e60208301846149d1565b60008060408385031215614ab257600080fd5b82356001600160401b03811115614ac857600080fd5b614ad485828601614804565b9250506117a2602084016146c6565b60008060408385031215614af657600080fd5b823591506117a2602084016146c6565b60008060208385031215614b1957600080fd5b82356001600160401b03811115614b2f57600080fd5b614b3b858286016148bc565b90969095509350505050565b60208152815160208201526000602083015160c06040840152614b6d60e0840182614622565b90506040840151601f19848303016060850152614b8a8282614622565b91505060608401516080840152608084015160018060a01b0380821660a08601528060a08701511660c086015250508091505092915050565b803580151581146146dd57600080fd5b60008060408385031215614be657600080fd5b614bef836146c6565b91506117a260208401614bc3565b60008083601f840112614c0f57600080fd5b5081356001600160401b03811115614c2657600080fd5b6020830191508360208260051b85010111156148fd57600080fd5b60008060208385031215614c5457600080fd5b82356001600160401b03811115614c6a57600080fd5b614b3b85828601614bfd565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614ccb57603f19888603018452614cb9858351614622565b94509285019290850190600101614c9d565b5092979650505050505050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b0381118282101715614d1057614d10614cd8565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614d3e57614d3e614cd8565b604052919050565b60006001600160401b03821115614d5f57614d5f614cd8565b50601f01601f191660200190565b600082601f830112614d7e57600080fd5b8135614d91614d8c82614d46565b614d16565b818152846020838601011115614da657600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215614dd957600080fd5b614de2856146c6565b9350614df0602086016146c6565b92506040850135915060608501356001600160401b03811115614e1257600080fd5b614e1e87828801614d6d565b91505092959194509250565b600060a0828403121561468c57600080fd5b600060208284031215614e4e57600080fd5b81356001600160401b03811115614e6457600080fd5b61322884828501614e2a565b60208152815160208201526020820151604082015260006040830151610100806060850152614ea3610120850183614622565b9150606085015160018060a01b0380821660808701528060808801511660a0870152505060a0850151614ee160c08601826001600160a01b03169052565b5060c085015180151560e08601525060e0850151801515858301525090949350505050565b60008060008060008060808789031215614f1f57600080fd5b863595506020870135945060408701356001600160401b0380821115614f4457600080fd5b614f508a838b01614bfd565b90965094506060890135915080821115614f6957600080fd5b50614f7689828a01614bfd565b979a9699509497509295939492505050565b60008060008060008060008060c0898b031215614fa457600080fd5b88356001600160401b0380821115614fbb57600080fd5b614fc78c838d016148bc565b909a50985060208b0135915080821115614fe057600080fd5b50614fed8b828c016148bc565b9097509550615000905060408a016146c6565b935061500e60608a016146c6565b925061501c60808a016146c6565b915061502a60a08a016146c6565b90509295985092959890939650565b6000806040838503121561504c57600080fd5b615055836146c6565b91506117a2602084016146c6565b60008060006040848603121561507857600080fd5b83356001600160401b038082111561508f57600080fd5b61509b87838801614804565b945060208601359150808211156150b157600080fd5b50614942868287016148bc565b600181811c908216806150d257607f821691505b60208210810361468c57634e487b7160e01b600052602260045260246000fd5b6000808335601e1984360301811261510957600080fd5b8301803591506001600160401b0382111561512357600080fd5b6020019150368190038213156148fd57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b0386811682528516602082015260806040820181905260009061518e9083018587615138565b90508260608301529695505050505050565b6000602082840312156151b257600080fd5b5051919050565b8581526001600160a01b038516602082015260806040820181905260009061518e9083018587615138565b948552602085019390935260408401919091526001600160a01b03166060830152608082015260a00190565b88815287602082015286604082015260e06060820152600061523660e083018789615138565b6001600160a01b0395861660808401529390941660a082015260c001529695505050505050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000808335601e198436030181126152c557600080fd5b83016020810192503590506001600160401b038111156152e457600080fd5b8036038213156148fd57600080fd5b80358252600061530660208301836152ae565b60e0602086015261531b60e086018284615138565b91505061532a604084016146c6565b6001600160a01b03818116604087015261534760608601866152ae565b9250868403606088015261535c848483615138565b9350508061536c608087016146c6565b166080870152505061538160a08401846152ae565b85830360a0870152615394838284615138565b925050506153a460c08401614bc3565b151560c08501528091505092915050565b60c0815260006153c860c08301886152f3565b602083810197909752604083019590955250606081019290925281830360808301526000835260a09091015201919050565b60c08152600061540d60c08301896152f3565b87602084015286604084015285606084015282810360808401526154318186614622565b9150508260a0830152979650505050505050565b83815260406020820152600061345e604083018486615138565b600080835461546d816150be565b60018281168015615485576001811461549a576154c9565b60ff19841687528215158302870194506154c9565b8760005260208060002060005b858110156154c05781548a8201529084019082016154a7565b50505082870194505b50929695505050505050565b601f821115610e2457600081815260208120601f850160051c810160208610156154fc5750805b601f850160051c820191505b81811015610f2b57828155600101615508565b6001600160401b0383111561553257615532614cd8565b6155468361554083546150be565b836154d5565b6000601f84116001811461557a57600085156155625750838201355b600019600387901b1c1916600186901b178355610d0d565b600083815260209020601f19861690835b828110156155ab578685013582556020948501946001909201910161558b565b50868210156155c85760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152600061112b602083018486615138565b634e487b7160e01b600052603260045260246000fd5b86815260a06020820152600061561e60a083018789615138565b6040830195909552506001600160a01b039290921660608301526080909101529392505050565b85815284602082015260806040820152600061518e608083018587615138565b8183823760009101908152919050565b85815260806020820152600061568f608083018688615138565b604083019490945250606001529392505050565b878152866020820152600060018060a01b03808816604084015260c060608401526156d260c084018789615138565b941660808301525060a0015295945050505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161570f5761570f6156e7565b5060010190565b60006101008b83528a6020840152896040840152886060840152806080840152615743818401888a615138565b6001600160a01b0396871660a08501529490951660c08301525060e00152979650505050505050565b600060a0823603121561577e57600080fd5b615786614cee565b61578f836146c6565b815260208301356001600160401b03808211156157ab57600080fd5b6157b736838701614d6d565b602084015260408501359150808211156157d057600080fd5b6157dc36838701614d6d565b60408401526157ed606086016146c6565b6060840152608085013591508082111561580657600080fd5b5061581336828601614d6d565b60808301525092915050565b86815285602082015260018060a01b038516604082015260a06060820152600061584d60a083018587615138565b9050826080830152979650505050505050565b8183526000602080850194508260005b85811015614a0a576001600160a01b03615889836146c6565b1687529582019590820190600101615870565b87815286602082015260a0604082015260006158bc60a083018789615860565b82810360608401526158cf818688615860565b91505082608083015298975050505050505050565b6000602082840312156158f657600080fd5b81516001600160401b0381111561590c57600080fd5b8201601f8101841361591d57600080fd5b805161592b614d8c82614d46565b81815285602083850101111561594057600080fd5b61345e8260208301602086016145fe565b81810381811115610b0b57610b0b6156e7565b80820180821115610b0b57610b0b6156e7565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038981168252610100602083018190526000916159ef8483018c614622565b91508382036040850152615a03828b614622565b908916606085015283810360808501529050615a1f8188614622565b60a0840196909652505060c081019290925260e09091015295945050505050565b606081526000615a54606083018789615138565b8281036020840152615a67818688615138565b9150508260408301529695505050505050565b60008251615a8c8184602087016145fe565b9190910192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613e3190830184614622565b600060208284031215615adb57600080fd5b815161112e816145cb565b634e487b7160e01b600052603160045260246000fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212205f0d5e9e498f3a347142a818f072dd61486ac0c193c33456fd6fdad78707584564736f6c63430008100033

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061043e5760003560e01c8063867884e611610236578063c053f6b81161013b578063dc17b6de116100c3578063ef0828ab11610087578063ef0828ab14610a71578063f2ad807514610a84578063f316bacd14610a97578063f6479d7714610aaa578063fe9299fb14610abd57600080fd5b8063dc17b6de146109e9578063dca27135146109fc578063e56f2fe414610a0f578063e985e9c514610a22578063ec81d19414610a5e57600080fd5b8063cd69fe611161010a578063cd69fe6114610965578063d23b320b14610978578063d70e10c61461098b578063dabb0531146109b6578063db491e80146109c957600080fd5b8063c053f6b81461091b578063c2a6fe3b1461092c578063c87b56dd1461093f578063cb8e757e1461095257600080fd5b80639a4dec18116101be578063a7ccb4bf1161018d578063a7ccb4bf146108af578063ac9650d8146108c2578063af90b112146108e2578063b88d4fde146108f5578063b9d328451461090857600080fd5b80639a4dec18146108565780639a50248d14610869578063a22cb46514610889578063a6e6178d1461089c57600080fd5b806393f057e51161020557806393f057e5146107df578063952be0ef146107f257806395d89b411461082857806395d9fa7d146108305780639864c3071461084357600080fd5b8063867884e6146107935780638734bbfc146107a65780638b4ca06a146107b957806392f7070b146107cc57600080fd5b80632f745c591161034757806347f94de7116102cf578063628b644a11610293578063628b644a146107275780636352211e1461073a5780636bf55d5f1461074d57806370a082311461076d57806374f345cf1461078057600080fd5b806347f94de7146106ba57806349186953146106cd5780634f6ccce7146106ee5780635a936d10146107015780635fb881831461071457600080fd5b8063388f508311610316578063388f50831461065b57806340ad34d81461066e57806342842e0e1461068157806342966c681461069457806344b82a24146106a757600080fd5b80632f745c59146105f657806331b9d08c14610609578063327b2a031461063557806333f06ee61461064857600080fd5b8063144a3e83116103ca5780632209d145116103995780632209d1451461055e57806323b872dd1461059457806328fbb805146105a757806329c301c2146105ba5780632abc6bf6146105cd57600080fd5b8063144a3e831461051d57806318160ddd14610530578063188b04b314610538578063206657f21461054b57600080fd5b806308cb68ff1161041157806308cb68ff146104be578063095ea7b3146104d35780630c4dd5f2146104e65780630ff98244146104f95780631316529d1461050c57600080fd5b806301ffc9a71461044357806304f3bcec1461046b57806306fdde0314610496578063081812fc146104ab575b600080fd5b6104566104513660046145e1565b610ae6565b60405190151581526020015b60405180910390f35b60175461047e906001600160a01b031681565b6040516001600160a01b039091168152602001610462565b61049e610b11565b604051610462919061464e565b61047e6104b9366004614661565b610ba3565b6104d16104cc366004614692565b610c3d565b005b6104d16104e13660046146e2565b610d14565b6104d16104f4366004614692565b610e29565b6104d161050736600461470c565b610f33565b60045b604051908152602001610462565b61049e61052b366004614661565b610fac565b60085461050f565b6104d161054636600461473a565b610fb7565b6104d161055936600461476e565b611055565b61047e61056c3660046146e2565b6001600160a01b03918216600090815260106020908152604080832093835292905220541690565b6104d16105a23660046147a3565b6110ed565b6104566105b53660046147cf565b61111e565b61050f6105c8366004614816565b611135565b61050f6105db36600461484a565b6001600160a01b03166000908152600c602052604090205490565b61050f6106043660046146e2565b6111c6565b61047e61061736600461484a565b6001600160a01b039081166000908152601160205260409020541690565b61050f610643366004614877565b61125c565b6104d1610656366004614904565b6113eb565b6104d161066936600461473a565b6114d2565b6104d161067c36600461494f565b611557565b6104d161068f3660046147a3565b6115d3565b6104d16106a2366004614661565b6115ee565b61050f6106b536600461496b565b61168b565b6104d16106c8366004614904565b6116ec565b6106e06106db3660046149af565b611753565b604051610462929190614a15565b61050f6106fc366004614661565b6117ab565b6104d161070f36600461470c565b61183e565b6104d161072236600461473a565b6118b7565b6104d1610735366004614a3a565b611925565b61047e610748366004614661565b6119b2565b61076061075b366004614661565b611a29565b6040516104629190614a8c565b61050f61077b36600461484a565b611a43565b6104d161078e3660046149af565b611aca565b6104d16107a136600461494f565b611b44565b6104566107b4366004614661565b611bee565b61050f6107c7366004614661565b611c1c565b61050f6107da366004614a9f565b611c88565b6104d16107ed36600461470c565b611d03565b61050f610800366004614ae3565b60009182526019602090815260408084206001600160a01b0393909316845291905290205490565b61049e611da3565b6104d161083e366004614ae3565b611db2565b6104d161085136600461473a565b611e44565b61050f610864366004614877565b611ea5565b61087c610877366004614b06565b611f90565b6040516104629190614b47565b6104d1610897366004614bd3565b61213f565b6104d16108aa366004614904565b61214a565b61050f6108bd36600461473a565b6121f5565b6108d56108d0366004614c41565b612296565b6040516104629190614c76565b61050f6108f036600461496b565b61238a565b6104d1610903366004614dc3565b6123b1565b6104d1610916366004614e3c565b6123e9565b6013546001600160a01b031661047e565b6104d161093a3660046149af565b61249c565b61049e61094d366004614661565b61250e565b6104d1610960366004614e3c565b6125b3565b61050f610973366004614e3c565b612642565b6104d161098636600461473a565b612657565b61050f6109993660046149af565b6000918252600d6020908152604080842092845291905290205490565b61087c6109c4366004614661565b6126e2565b6109dc6109d73660046149af565b612869565b6040516104629190614e70565b6104d16109f7366004614f06565b6129ca565b61049e610a0a366004614661565b612a5b565b6104d1610a1d366004614f88565b612acd565b610456610a30366004615039565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61049e610a6c366004614661565b612c5a565b6104d1610a7f366004614692565b612c7a565b6104d1610a92366004614661565b612d04565b61050f610aa5366004615063565b612d53565b61050f610ab836600461470c565b612e94565b61047e610acb366004614661565b6000908152600f60205260409020546001600160a01b031690565b60006001600160e01b0319821663780e9d6360e01b1480610b0b5750610b0b82612faf565b92915050565b606060008054610b20906150be565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4c906150be565b8015610b995780601f10610b6e57610100808354040283529160200191610b99565b820191906000526020600020905b815481529060010190602001808311610b7c57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610c215760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b610c4a602082018261484a565b6001600160a01b0316336001600160a01b031614610c7b5760405163ca67421960e01b815260040160405180910390fd5b73d7ab27d73b2067b8f8c3eb7f48e4120a5148d27063dfc34f25610ca2602084018461484a565b610cb2604085016020860161484a565b610cbf60408601866150f2565b60116040518663ffffffff1660e01b8152600401610ce1959493929190615161565b60006040518083038186803b158015610cf957600080fd5b505af4158015610d0d573d6000803e3d6000fd5b5050505050565b6000610d1f826119b2565b9050806001600160a01b0316836001600160a01b031603610d8c5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610c18565b336001600160a01b0382161480610da85750610da88133610a30565b610e1a5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610c18565b610e248383612fff565b505050565b6013546040516367880d6160e11b8152823560048201526000916001600160a01b03169063cf101ac290602401602060405180830381865afa158015610e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9791906151a0565b9050610ea48160c161306d565b73d7ab27d73b2067b8f8c3eb7f48e4120a5148d270636252159e8335610ed0604086016020870161484a565b610edd60408701876150f2565b600f6040518663ffffffff1660e01b8152600401610eff9594939291906151b9565b60006040518083038186803b158015610f1757600080fd5b505af4158015610f2b573d6000803e3d6000fd5b505050505050565b610f3f813560b261306d565b60135481356000818152600d6020908152604080832081870135808552908352928190205490516337fb824760e11b815273039cd40335453e463186c8bde171280fc547b8d795636ff7048e95610ce19590948901359390926001600160a01b03909216916004016151e4565b6060610b0b8261250e565b610fc3813560b261306d565b610fd081602001356130fe565b73039cd40335453e463186c8bde171280fc547b8d7639ec52a2382356020840135604085013561100360608701876150f2565b6013546020808a01356000908152600a9091526040908190206005015490516001600160e01b031960e08a901b168152610ce19796959493926001600160a01b03908116921690600d90600401615210565b61106083600261306d565b604051631f8c0b6760e11b8152600481018490526001600160a01b038316602482015260448101829052601860648201526019608482015273214cfd2b39c6edd0e07d3f4534e34d12b18723a890633f1816ce9060a4015b60006040518083038186803b1580156110d057600080fd5b505af41580156110e4573d6000803e3d6000fd5b50505050505050565b6110f73382613139565b6111135760405162461bcd60e51b8152600401610c189061525d565b610e24838383613230565b600061112b8484846133dd565b90505b9392505050565b6000611143823560ec61306d565b61114d8235613467565b6040516342a34a5360e01b81529091507332a54aaaff212d2bdca30c9e33976f3a3cd4384c906342a34a539061119190859085906000908190600e906004016153b5565b60006040518083038186803b1580156111a957600080fd5b505af41580156111bd573d6000803e3d6000fd5b50505050919050565b60006111d183611a43565b82106112335760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610c18565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600061126a833560ca61306d565b6545524337323160d01b60006112808535613467565b6013549091506000906001600160a01b0316632ea24efc826112a5602089018961484a565b6040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152602088013560448201526064016020604051808303816000875af11580156112fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131f91906151a0565b90507332a54aaaff212d2bdca30c9e33976f3a3cd4384c6342a34a538784868561134c60208c018c61484a565b8b6020013560405160200161137f92919060609290921b6bffffffffffffffffffffffff19168252601482015260340190565b604051602081830303815290604052600e6040518763ffffffff1660e01b81526004016113b1969594939291906153fa565b60006040518083038186803b1580156113c957600080fd5b505af41580156113dd573d6000803e3d6000fd5b509398975050505050505050565b6013546040516367880d6160e11b8152600481018590526000916001600160a01b03169063cf101ac290602401602060405180830381865afa158015611435573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145991906151a0565b90506114668160b161306d565b601354604051633c17845760e11b81526001600160a01b039091169063782f08ae9061149a90879087908790600401615445565b600060405180830381600087803b1580156114b457600080fd5b505af11580156114c8573d6000803e3d6000fd5b5050505050505050565b6114de813560b961306d565b73039cd40335453e463186c8bde171280fc547b8d763a4159c6b823561150a604085016020860161484a565b6013546040805160e086901b6001600160e01b031916815260048101949094526001600160a01b0392831660248501528601356044840152166064820152600d608482015260a401610ce1565b611563813560b661306d565b60135460408051631d4deabf60e01b81528335600482015260208401356024820152908301356044820152606083013560648201526001600160a01b039091166084820152600d60a482015273039cd40335453e463186c8bde171280fc547b8d790631d4deabf9060c401610ce1565b610e24838383604051806020016040528060008152506123b1565b6000818152600a6020526040808220905161160c916001019061545f565b60408051918290039091206000818152600b6020908152838220829055858252600a9052918220828155909250906116476001830182614530565b611655600283016000614530565b50600060038201556004810180546001600160a01b031990811690915560059091018054909116905561168782613490565b5050565b6000611699833560c861306d565b67131a5b9adb1a5cdd60c21b60006116b18535613467565b905060008460001b90507332a54aaaff212d2bdca30c9e33976f3a3cd4384c6342a34a53878486858a60405160200161137f91815260200190565b6116f78360b061306d565b6000838152600a6020526040902060020161171382848361551b565b50827f17d7c9f69270ba135480ef16837f38b9d37d3ab291cbd3ba03982290c663199783836040516117469291906155da565b60405180910390a2505050565b6000828152601a602090815260408083208484529091529020606090819061177a906134ef565b6000858152601a6020908152604080832087845290915290209092506117a2906002016134ef565b90509250929050565b60006117b660085490565b82106118195760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610c18565b6008828154811061182c5761182c6155ee565b90600052602060002001549050919050565b61184a813560be61306d565b60135481356000818152600d602090815260408083208187013580855290835292819020549051633fe4fe3960e11b815273039cd40335453e463186c8bde171280fc547b8d795637fc9fc7295610ce19590948901359390926001600160a01b03909216916004016151e4565b6118c3813560bb61306d565b73039cd40335453e463186c8bde171280fc547b8d76348391dcb82356118ec60208501856150f2565b601354604080516001600160e01b031960e088901b168152610ce19594939291890135916001600160a01b031690600d90600401615604565b61192f84846134fc565b6119398484613561565b61194384846135d8565b6040516001626802bf60e01b031981527332a54aaaff212d2bdca30c9e33976f3a3cd4384c9063ff97fd4190611986908790879087908790600e90600401615645565b60006040518083038186803b15801561199e57600080fd5b505af41580156114c8573d6000803e3d6000fd5b6000818152600260205260408120546001600160a01b031680610b0b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610c18565b6000818152601860205260409020606090610b0b906134ef565b60006001600160a01b038216611aae5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610c18565b506001600160a01b031660009081526003602052604090205490565b611ad58260c461306d565b611adf8282613561565b6000828152600e60209081526040808320848452825291829020600501805460ff60a81b1916600160a81b179055905182815283917f036469f3e73c83520cdefa197d7a9c854c2f8bc0164b82e9f2bd4aa7e150fd3091015b60405180910390a25050565b611b50813560b861306d565b73039cd40335453e463186c8bde171280fc547b8d763154246368235611b7c604085016020860161484a565b60135485356000908152600d6020908152604080832060608a013580855292529182902054825160e088901b6001600160e01b031916815260048101969096526001600160a01b03948516602487015291880135604486015260648501529116608483015260a482015260c401610ce1565b600080611bfa836119b2565b6001600160a01b03166000908152600c60205260409020549290921492915050565b60135460405162fba02760e01b8152600481018390526000916001600160a01b03169062fba02790602401602060405180830381865afa158015611c64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0b91906151a0565b6000611c96833560c761306d565b664164647265737360c81b6000611cad8535613467565b6040516bffffffffffffffffffffffff19606087901b1660208201529091506001600160a01b038516907332a54aaaff212d2bdca30c9e33976f3a3cd4384c906342a34a5390889085908790869060340161137f565b611d0f813560ba61306d565b73039cd40335453e463186c8bde171280fc547b8d76393c96a528235611d3b604085016020860161484a565b60135485356000908152600d60209081526040808320818a013580855292529182902054915160e087901b6001600160e01b031916815260048101959095526001600160a01b039384166024860152604485015291166064830152608482015260a401610ce1565b606060018054610b20906150be565b611dbd82600161306d565b6000828152600a60205260409020600401546001600160a01b031615611df65760405163fe6f50e560e01b815260040160405180910390fd5b6040516384b44a2f60e01b8152600481018390526001600160a01b0382166024820152600a60448201527345f6e036e8ab5b6bff0406a21e2793ff0cce1aed906384b44a2f90606401610eff565b611e50813560bd61306d565b60135460408051632ca904df60e01b815273039cd40335453e463186c8bde171280fc547b8d792632ca904df92610ce192863592602088013592880135916001600160a01b0390911690600d906004016151e4565b6000611eb3833560c961306d565b634e6f746560e01b6000611ec78535613467565b601354604051635cb46be760e01b815260006004820181905287356024830152602088013560448301529293506001600160a01b0390911690635cb46be7906064016020604051808303816000875af1158015611f28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f4c91906151a0565b90507332a54aaaff212d2bdca30c9e33976f3a3cd4384c6342a34a53878486858a600001358b6020013560405160200161137f929190918252602082015260400190565b611f9861456a565b60008383604051611faa929190615665565b604080519182900382206000818152600b602090815283822054808352600a82529184902060c0860190945283548552600184018054939650919493929084019190611ff5906150be565b80601f0160208091040260200160405190810160405280929190818152602001828054612021906150be565b801561206e5780601f106120435761010080835404028352916020019161206e565b820191906000526020600020905b81548152906001019060200180831161205157829003601f168201915b50505050508152602001600282018054612087906150be565b80601f01602080910402602001604051908101604052809291908181526020018280546120b3906150be565b80156121005780601f106120d557610100808354040283529160200191612100565b820191906000526020600020905b8154815290600101906020018083116120e357829003601f168201915b50505091835250506003820154602082015260048201546001600160a01b03908116604083015260059092015490911660609091015295945050505050565b61168733838361361d565b61215583600061306d565b6121758282604051612168929190615665565b60405180910390206136eb565b6121b482828080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061371892505050565b60405163130f361d60e01b81527345f6e036e8ab5b6bff0406a21e2793ff0cce1aed9063130f361d906110b890869086908690600b90600a90600401615675565b600061220682356020840135613561565b7332a54aaaff212d2bdca30c9e33976f3a3cd4384c639d2e06f083356020850135612237606087016040880161484a565b61224460608801886150f2565b6014546040516001600160e01b031960e089901b1681526122799695949392916001600160a01b031690600e906004016156a3565b602060405180830381865af4158015611c64573d6000803e3d6000fd5b6060816001600160401b038111156122b0576122b0614cd8565b6040519080825280602002602001820160405280156122e357816020015b60608152602001906001900390816122ce5790505b50905060005b828110156123835761235330858584818110612307576123076155ee565b905060200281019061231991906150f2565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061378592505050565b828281518110612365576123656155ee565b6020026020010181905250808061237b906156fd565b9150506122e9565b5092915050565b6000612398833560c661306d565b6821b430b930b1ba32b960b91b60006116b18535613467565b6123bb3383613139565b6123d75760405162461bcd60e51b8152600401610c189061525d565b6123e3848484846137aa565b50505050565b6123f5813560b561306d565b61240781602001358260400135613561565b73039cd40335453e463186c8bde171280fc547b8d76371bd9b06823560208401356040850135606086013561243f60808801886150f2565b6013546020808b01356000908152600e82526040808220818e013583529092528190206003015490516001600160e01b031960e08b901b168152610ce1989796959493926001600160a01b03908116921690600d90600401615716565b6124a78260c561306d565b6124b18282613561565b6000828152600e60209081526040808320848452825291829020600501805460ff60a01b1916600160a01b179055905182815283917f4f1db9708b537c1d26a7af4b235fd079bf2342d92a276e27eb6c8717e8bbcf939101611b38565b6000818152600a6020526040902060020180546060919061252e906150be565b80601f016020809104026020016040519081016040528092919081815260200182805461255a906150be565b80156125a75780601f1061257c576101008083540402835291602001916125a7565b820191906000526020600020905b81548152906001019060200180831161258a57829003601f168201915b50505050509050919050565b6125bf813560b761306d565b73039cd40335453e463186c8bde171280fc547b8d763f35deae182356125eb604085016020860161484a565b6013546040805160e086901b6001600160e01b031916815260048101949094526001600160a01b039283166024850152860135604484015260608601356064840152166084820152600d60a482015260c401610ce1565b6000610b0b6126508361576c565b60016137dd565b612663813560c261306d565b61267281356020830135613561565b612681813560208301356135d8565b73d7ab27d73b2067b8f8c3eb7f48e4120a5148d2706320828a02823560208401356126b2606086016040870161484a565b6126bf60608701876150f2565b600e6040518763ffffffff1660e01b8152600401610ce19695949392919061581f565b6126ea61456a565b600a60008381526020019081526020016000206040518060c001604052908160008201548152602001600182018054612722906150be565b80601f016020809104026020016040519081016040528092919081815260200182805461274e906150be565b801561279b5780601f106127705761010080835404028352916020019161279b565b820191906000526020600020905b81548152906001019060200180831161277e57829003601f168201915b505050505081526020016002820180546127b4906150be565b80601f01602080910402602001604051908101604052809291908181526020018280546127e0906150be565b801561282d5780601f106128025761010080835404028352916020019161282d565b820191906000526020600020905b81548152906001019060200180831161281057829003601f168201915b50505091835250506003820154602082015260048201546001600160a01b03908116604083015260059092015490911660609091015292915050565b60408051610100808201835260008083526020808401829052606084860181905284018290526080840182905260a0840182905260c0840182905260e08401829052868252600e815284822086835281529084902084519283018552805483526001810154918301919091526002810180549394929391928401916128ed906150be565b80601f0160208091040260200160405190810160405280929190818152602001828054612919906150be565b80156129665780601f1061293b57610100808354040283529160200191612966565b820191906000526020600020905b81548152906001019060200180831161294957829003601f168201915b505050918352505060038201546001600160a01b039081166020830152600483015481166040830152600590920154918216606082015260ff600160a01b8304811615156080830152600160a81b909204909116151560a090910152905092915050565b6129d586600361306d565b6129df8686613561565b604051630afb883f60e41b815273214cfd2b39c6edd0e07d3f4534e34d12b18723a89063afb883f090612a2390899089908990899089908990601a9060040161589c565b60006040518083038186803b158015612a3b57600080fd5b505af4158015612a4f573d6000803e3d6000fd5b50505050505050505050565b601354604051632b05429560e21b8152600481018390526060916001600160a01b03169063ac150a5490602401600060405180830381865afa158015612aa5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b0b91908101906158e4565b601454600390600160a81b900460ff16158015612af8575060145460ff808316600160a01b90920416105b612b5b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c18565b6014805460ff60a81b1960ff8416600160a01b021661ffff60a01b1990911617600160a81b179055612b8f898989896138ba565b601380546001600160a01b03199081166001600160a01b0388811691909117909255601480548216878416179055601580548216868416179055601b80549091169184169190911790556040514281527f400175a56dd3710794078f7b9dbe8296ac94c5a248dfd51bb22ed4ab9eaa9fbf9060200160405180910390a16014805460ff60a81b1916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050505050565b6000818152600a6020526040902060010180546060919061252e906150be565b612c86813560bc61306d565b73039cd40335453e463186c8bde171280fc547b8d7631873e2188235612caf60208501856150f2565b60135486356000908152600d60209081526040808320818b01358085529252918290205491516001600160e01b031960e089901b168152610ce19695949391926001600160a01b039092169190600401615604565b612d0d8161390b565b336000818152600c602052604080822080549085905590519092839285927fce95332e6082aebeb8058a7b56d1a109f67d6550552ed04d36aca4a6acd4d7de9190a45050565b6000612d61843560cb61306d565b65416e7955726960d01b6000612d778635613467565b601354604051633610bf0960e11b81529192506000916001600160a01b0390911690636c217e1290612db19084908a908a90600401615445565b6020604051808303816000875af1158015612dd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612df491906151a0565b90507332a54aaaff212d2bdca30c9e33976f3a3cd4384c6342a34a53888486858b8b604051602001612e27929190615665565b604051602081830303815290604052600e6040518763ffffffff1660e01b8152600401612e59969594939291906153fa565b60006040518083038186803b158015612e7157600080fd5b505af4158015612e85573d6000803e3d6000fd5b50939998505050505050505050565b6000612ea2823560b461306d565b612f306040518060a00160405280846020016020810190612ec3919061484a565b6001600160a01b03168152602001612eec856020016020810190612ee7919061484a565b613971565b815260200160405180602001604052806000815250815260200160006001600160a01b031681526020016040518060200160405280600081525081525060006137dd565b60135460408051639ec52a2360e01b8152853560048201526024810184905290850135604482015260e06064820152600060e482018190526001600160a01b03909216608482015260a4810191909152600d60c482015290915073039cd40335453e463186c8bde171280fc547b8d790639ec52a239061010401611191565b60006001600160e01b031982166380ac58cd60e01b1480612fe057506001600160e01b03198216635b5e139f60e01b145b80610b0b57506301ffc9a760e01b6001600160e01b0319831614610b0b565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190613034826119b2565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b61307682613a7a565b1561307f575050565b6015546001600160a01b031633036130bb576000828152601960209081526040808320328452909152902054600190821c8116036130bb575050565b6000828152601960209081526040808320338452909152902054600190821c8116036130e5575050565b604051632c4bc2b960e21b815260040160405180910390fd5b6000818152600260205260409020546001600160a01b0316613136576040516375af0fc960e11b815260048101829052602401610c18565b50565b6000818152600260205260408120546001600160a01b03166131b25760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610c18565b60006131bd836119b2565b9050806001600160a01b0316846001600160a01b031614806131f85750836001600160a01b03166131ed84610ba3565b6001600160a01b0316145b8061322857506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316613243826119b2565b6001600160a01b0316146132a75760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610c18565b6001600160a01b0382166133095760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610c18565b613314838383613ada565b61331f600082612fff565b6001600160a01b0383166000908152600360205260408120805460019290613348908490615951565b90915550506001600160a01b0382166000908152600360205260408120805460019290613376908490615964565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4610e24838383613bac565b6000838152601a6020908152604080832085845290915281206134008184613be9565b1561340f57600091505061112e565b61341c6002820184613be9565b1561342b57600191505061112e565b60008581526019602090815260408083206001600160a01b038716845290915290205461345e9060c31c60019081161490565b95945050505050565b6000818152600a6020526040812060030180548290613485906156fd565b918290555092915050565b61349a3382613139565b6134e65760405162461bcd60e51b815260206004820152601b60248201527f4e4654426173653a204e6f744f776e65724f72417070726f76656400000000006044820152606401610c18565b61313681613c0b565b6060600061112e83613cba565b61350582613a7a565b1561350e575050565b6015546001600160a01b031633036135345761352b8282326133dd565b15613534575050565b61353f8282336133dd565b15613548575050565b604051631a1d1d4760e11b815260040160405180910390fd5b6000828152600e60209081526040808320848452909152902060050154600160a01b900460ff16156135a657604051631f0fc8f560e11b815260040160405180910390fd5b6000828152600a6020526040902060030154811115611687576040516364783acb60e01b815260040160405180910390fd5b6000828152600e60209081526040808320848452909152902060050154600160a81b900460ff161561168757604051630bc06a0f60e21b815260040160405180910390fd5b816001600160a01b0316836001600160a01b03160361367e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610c18565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6000818152600b60205260409020541561313657604051631b659b9f60e21b815260040160405180910390fd5b80518190601f81118061372b5750600381105b1561374957604051636f819c2160e11b815260040160405180910390fd5b60005b818110156123e35761377d838281518110613769576137696155ee565b01602001516001600160f81b031916613d15565b60010161374c565b606061112e8383604051806060016040528060278152602001615afd60279139613dc3565b6137b5848484613230565b6137c184848484613e3b565b6123e35760405162461bcd60e51b8152600401610c1890615977565b60006137f38360200151805190602001206136eb565b8115613806576138068360200151613718565b601260008154613815906156fd565b918290555083519091506138299082613f3c565b7345f6e036e8ab5b6bff0406a21e2793ff0cce1aed634daae5688460000151856020015186604001518760600151886080015187600b600a6040518963ffffffff1660e01b81526004016138849897969594939291906159c9565b60006040518083038186803b15801561389c57600080fd5b505af41580156138b0573d6000803e3d6000fd5b5050505092915050565b6138c684848484613f56565b7f414cd0b34676984f09a5f76ce9718d4062e50283abe0e7e274a9a5b4e0c99c3084848484426040516138fd959493929190615a40565b60405180910390a150505050565b6000613916826119b2565b6015549091506001600160a01b03163314801561393b5750326001600160a01b038216145b15613944575050565b6001600160a01b0381163303613958575050565b604051631b0c476f60e11b815260040160405180910390fd5b60408051602a80825260608281019093526f181899199a1a9b1b9c1cb0b131b232b360811b916001600160a01b0385169160009190602082018180368337019050509050600360fc1b816000815181106139cd576139cd6155ee565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106139fc576139fc6155ee565b60200101906001600160f81b031916908160001a90535060295b6001811115613a71578383600f1660108110613a3457613a346155ee565b1a60f81b828281518110613a4a57613a4a6155ee565b60200101906001600160f81b031916908160001a90535060049290921c9160001901613a16565b50949350505050565b600080613a86836119b2565b90506001600160a01b0381163303613aa15750600192915050565b6015546001600160a01b031633148015613ac35750326001600160a01b038216145b15613ad15750600192915050565b50600092915050565b601b546001600160a01b03848116911614613ba1576000818152601860205260408120613b0690613f71565b600083815260186020526040812091925090613b21906134ef565b905060005b82811015613b6357613b5184838381518110613b4457613b446155ee565b6020026020010151613f7b565b80613b5b816156fd565b915050613b26565b506001600160a01b0385166000908152600c6020526040902054839003613b9e576001600160a01b0385166000908152600c60205260408120555b50505b610e24838383613fb4565b6001600160a01b0382166000908152600c60205260408120549003610e24576001600160a01b03919091166000908152600c602052604090205550565b6001600160a01b0381166000908152600183016020526040812054151561112e565b6000613c16826119b2565b9050613c2481600084613ada565b613c2f600083612fff565b6001600160a01b0381166000908152600360205260408120805460019290613c58908490615951565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a461168781600084613bac565b6060816000018054806020026020016040519081016040528092919081815260200182805480156125a757602002820191906000526020600020905b815481526020019060010190808311613cf65750505050509050919050565b600360fc1b6001600160f81b031982161080613d3e5750603d60f91b6001600160f81b03198216115b80613d6e5750603960f81b6001600160f81b03198216118015613d6e5750606160f81b6001600160f81b03198216105b8015613d885750602d60f81b6001600160f81b0319821614155b8015613da25750605f60f81b6001600160f81b0319821614155b15613136576040516001621693dd60e01b0319815260040160405180910390fd5b6060600080856001600160a01b031685604051613de09190615a7a565b600060405180830381855af49150503d8060008114613e1b576040519150601f19603f3d011682016040523d82523d6000602084013e613e20565b606091505b5091509150613e318683838761406c565b9695505050505050565b60006001600160a01b0384163b15613f3157604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613e7f903390899088908890600401615a96565b6020604051808303816000875af1925050508015613eba575060408051601f3d908101601f19168201909252613eb791810190615ac9565b60015b613f17573d808015613ee8576040519150601f19603f3d011682016040523d82523d6000602084013e613eed565b606091505b508051600003613f0f5760405162461bcd60e51b8152600401610c1890615977565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050613228565b506001949350505050565b6116878282604051806020016040528060008152506140e5565b6000613f6384868361551b565b506001610d0d82848361551b565b6000610b0b825490565b60008281526019602090815260408083206001600160a01b0385168452825280832083905584835260189091529020610e249082614118565b6001600160a01b03831661400f5761400a81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b614032565b816001600160a01b0316836001600160a01b03161461403257614032838261412d565b6001600160a01b03821661404957610e24816141ca565b826001600160a01b0316826001600160a01b031614610e2457610e248282614279565b606083156140db5782516000036140d4576001600160a01b0385163b6140d45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c18565b5081613228565b61322883836142bd565b6140ef83836142e7565b6140fc6000848484613e3b565b610e245760405162461bcd60e51b8152600401610c1890615977565b600061112e836001600160a01b03841661443d565b6000600161413a84611a43565b6141449190615951565b600083815260076020526040902054909150808214614197576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906141dc90600190615951565b60008381526009602052604081205460088054939450909284908110614204576142046155ee565b906000526020600020015490508060088381548110614225576142256155ee565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061425d5761425d615ae6565b6001900381819060005260206000200160009055905550505050565b600061428483611a43565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b8151156142cd5781518083602001fd5b8060405162461bcd60e51b8152600401610c18919061464e565b6001600160a01b03821661433d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c18565b6000818152600260205260409020546001600160a01b0316156143a25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c18565b6143ae60008383613ada565b6001600160a01b03821660009081526003602052604081208054600192906143d7908490615964565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a461168760008383613bac565b60008181526001830160205260408120548015614526576000614461600183615951565b855490915060009061447590600190615951565b90508181146144da576000866000018281548110614495576144956155ee565b90600052602060002001549050808760000184815481106144b8576144b86155ee565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806144eb576144eb615ae6565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b0b565b6000915050610b0b565b50805461453c906150be565b6000825580601f1061454c575050565b601f01602090049060005260206000209081019061313691906145b2565b6040518060c001604052806000815260200160608152602001606081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b5b808211156145c757600081556001016145b3565b5090565b6001600160e01b03198116811461313657600080fd5b6000602082840312156145f357600080fd5b813561112e816145cb565b60005b83811015614619578181015183820152602001614601565b50506000910152565b6000815180845261463a8160208601602086016145fe565b601f01601f19169290920160200192915050565b60208152600061112e6020830184614622565b60006020828403121561467357600080fd5b5035919050565b60006060828403121561468c57600080fd5b50919050565b6000602082840312156146a457600080fd5b81356001600160401b038111156146ba57600080fd5b6132288482850161467a565b80356001600160a01b03811681146146dd57600080fd5b919050565b600080604083850312156146f557600080fd5b6146fe836146c6565b946020939093013593505050565b60006060828403121561471e57600080fd5b61112e838361467a565b60006080828403121561468c57600080fd5b60006020828403121561474c57600080fd5b81356001600160401b0381111561476257600080fd5b61322884828501614728565b60008060006060848603121561478357600080fd5b83359250614793602085016146c6565b9150604084013590509250925092565b6000806000606084860312156147b857600080fd5b6147c1846146c6565b9250614793602085016146c6565b6000806000606084860312156147e457600080fd5b83359250602084013591506147fb604085016146c6565b90509250925092565b600060e0828403121561468c57600080fd5b60006020828403121561482857600080fd5b81356001600160401b0381111561483e57600080fd5b61322884828501614804565b60006020828403121561485c57600080fd5b61112e826146c6565b60006040828403121561468c57600080fd5b6000806060838503121561488a57600080fd5b82356001600160401b038111156148a057600080fd5b6148ac85828601614804565b9250506117a28460208501614865565b60008083601f8401126148ce57600080fd5b5081356001600160401b038111156148e557600080fd5b6020830191508360208285010111156148fd57600080fd5b9250929050565b60008060006040848603121561491957600080fd5b8335925060208401356001600160401b0381111561493657600080fd5b614942868287016148bc565b9497909650939450505050565b60006080828403121561496157600080fd5b61112e8383614728565b6000806040838503121561497e57600080fd5b82356001600160401b0381111561499457600080fd5b6149a085828601614804565b95602094909401359450505050565b600080604083850312156149c257600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b83811015614a0a5781516001600160a01b0316875295820195908201906001016149e5565b509495945050505050565b604081526000614a2860408301856149d1565b828103602084015261345e81856149d1565b60008060008060608587031215614a5057600080fd5b843593506020850135925060408501356001600160401b03811115614a7457600080fd5b614a80878288016148bc565b95989497509550505050565b60208152600061112e60208301846149d1565b60008060408385031215614ab257600080fd5b82356001600160401b03811115614ac857600080fd5b614ad485828601614804565b9250506117a2602084016146c6565b60008060408385031215614af657600080fd5b823591506117a2602084016146c6565b60008060208385031215614b1957600080fd5b82356001600160401b03811115614b2f57600080fd5b614b3b858286016148bc565b90969095509350505050565b60208152815160208201526000602083015160c06040840152614b6d60e0840182614622565b90506040840151601f19848303016060850152614b8a8282614622565b91505060608401516080840152608084015160018060a01b0380821660a08601528060a08701511660c086015250508091505092915050565b803580151581146146dd57600080fd5b60008060408385031215614be657600080fd5b614bef836146c6565b91506117a260208401614bc3565b60008083601f840112614c0f57600080fd5b5081356001600160401b03811115614c2657600080fd5b6020830191508360208260051b85010111156148fd57600080fd5b60008060208385031215614c5457600080fd5b82356001600160401b03811115614c6a57600080fd5b614b3b85828601614bfd565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614ccb57603f19888603018452614cb9858351614622565b94509285019290850190600101614c9d565b5092979650505050505050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b0381118282101715614d1057614d10614cd8565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614d3e57614d3e614cd8565b604052919050565b60006001600160401b03821115614d5f57614d5f614cd8565b50601f01601f191660200190565b600082601f830112614d7e57600080fd5b8135614d91614d8c82614d46565b614d16565b818152846020838601011115614da657600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215614dd957600080fd5b614de2856146c6565b9350614df0602086016146c6565b92506040850135915060608501356001600160401b03811115614e1257600080fd5b614e1e87828801614d6d565b91505092959194509250565b600060a0828403121561468c57600080fd5b600060208284031215614e4e57600080fd5b81356001600160401b03811115614e6457600080fd5b61322884828501614e2a565b60208152815160208201526020820151604082015260006040830151610100806060850152614ea3610120850183614622565b9150606085015160018060a01b0380821660808701528060808801511660a0870152505060a0850151614ee160c08601826001600160a01b03169052565b5060c085015180151560e08601525060e0850151801515858301525090949350505050565b60008060008060008060808789031215614f1f57600080fd5b863595506020870135945060408701356001600160401b0380821115614f4457600080fd5b614f508a838b01614bfd565b90965094506060890135915080821115614f6957600080fd5b50614f7689828a01614bfd565b979a9699509497509295939492505050565b60008060008060008060008060c0898b031215614fa457600080fd5b88356001600160401b0380821115614fbb57600080fd5b614fc78c838d016148bc565b909a50985060208b0135915080821115614fe057600080fd5b50614fed8b828c016148bc565b9097509550615000905060408a016146c6565b935061500e60608a016146c6565b925061501c60808a016146c6565b915061502a60a08a016146c6565b90509295985092959890939650565b6000806040838503121561504c57600080fd5b615055836146c6565b91506117a2602084016146c6565b60008060006040848603121561507857600080fd5b83356001600160401b038082111561508f57600080fd5b61509b87838801614804565b945060208601359150808211156150b157600080fd5b50614942868287016148bc565b600181811c908216806150d257607f821691505b60208210810361468c57634e487b7160e01b600052602260045260246000fd5b6000808335601e1984360301811261510957600080fd5b8301803591506001600160401b0382111561512357600080fd5b6020019150368190038213156148fd57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b0386811682528516602082015260806040820181905260009061518e9083018587615138565b90508260608301529695505050505050565b6000602082840312156151b257600080fd5b5051919050565b8581526001600160a01b038516602082015260806040820181905260009061518e9083018587615138565b948552602085019390935260408401919091526001600160a01b03166060830152608082015260a00190565b88815287602082015286604082015260e06060820152600061523660e083018789615138565b6001600160a01b0395861660808401529390941660a082015260c001529695505050505050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000808335601e198436030181126152c557600080fd5b83016020810192503590506001600160401b038111156152e457600080fd5b8036038213156148fd57600080fd5b80358252600061530660208301836152ae565b60e0602086015261531b60e086018284615138565b91505061532a604084016146c6565b6001600160a01b03818116604087015261534760608601866152ae565b9250868403606088015261535c848483615138565b9350508061536c608087016146c6565b166080870152505061538160a08401846152ae565b85830360a0870152615394838284615138565b925050506153a460c08401614bc3565b151560c08501528091505092915050565b60c0815260006153c860c08301886152f3565b602083810197909752604083019590955250606081019290925281830360808301526000835260a09091015201919050565b60c08152600061540d60c08301896152f3565b87602084015286604084015285606084015282810360808401526154318186614622565b9150508260a0830152979650505050505050565b83815260406020820152600061345e604083018486615138565b600080835461546d816150be565b60018281168015615485576001811461549a576154c9565b60ff19841687528215158302870194506154c9565b8760005260208060002060005b858110156154c05781548a8201529084019082016154a7565b50505082870194505b50929695505050505050565b601f821115610e2457600081815260208120601f850160051c810160208610156154fc5750805b601f850160051c820191505b81811015610f2b57828155600101615508565b6001600160401b0383111561553257615532614cd8565b6155468361554083546150be565b836154d5565b6000601f84116001811461557a57600085156155625750838201355b600019600387901b1c1916600186901b178355610d0d565b600083815260209020601f19861690835b828110156155ab578685013582556020948501946001909201910161558b565b50868210156155c85760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152600061112b602083018486615138565b634e487b7160e01b600052603260045260246000fd5b86815260a06020820152600061561e60a083018789615138565b6040830195909552506001600160a01b039290921660608301526080909101529392505050565b85815284602082015260806040820152600061518e608083018587615138565b8183823760009101908152919050565b85815260806020820152600061568f608083018688615138565b604083019490945250606001529392505050565b878152866020820152600060018060a01b03808816604084015260c060608401526156d260c084018789615138565b941660808301525060a0015295945050505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161570f5761570f6156e7565b5060010190565b60006101008b83528a6020840152896040840152886060840152806080840152615743818401888a615138565b6001600160a01b0396871660a08501529490951660c08301525060e00152979650505050505050565b600060a0823603121561577e57600080fd5b615786614cee565b61578f836146c6565b815260208301356001600160401b03808211156157ab57600080fd5b6157b736838701614d6d565b602084015260408501359150808211156157d057600080fd5b6157dc36838701614d6d565b60408401526157ed606086016146c6565b6060840152608085013591508082111561580657600080fd5b5061581336828601614d6d565b60808301525092915050565b86815285602082015260018060a01b038516604082015260a06060820152600061584d60a083018587615138565b9050826080830152979650505050505050565b8183526000602080850194508260005b85811015614a0a576001600160a01b03615889836146c6565b1687529582019590820190600101615870565b87815286602082015260a0604082015260006158bc60a083018789615860565b82810360608401526158cf818688615860565b91505082608083015298975050505050505050565b6000602082840312156158f657600080fd5b81516001600160401b0381111561590c57600080fd5b8201601f8101841361591d57600080fd5b805161592b614d8c82614d46565b81815285602083850101111561594057600080fd5b61345e8260208301602086016145fe565b81810381811115610b0b57610b0b6156e7565b80820180821115610b0b57610b0b6156e7565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038981168252610100602083018190526000916159ef8483018c614622565b91508382036040850152615a03828b614622565b908916606085015283810360808501529050615a1f8188614622565b60a0840196909652505060c081019290925260e09091015295945050505050565b606081526000615a54606083018789615138565b8281036020840152615a67818688615138565b9150508260408301529695505050505050565b60008251615a8c8184602087016145fe565b9190910192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613e3190830184614622565b600060208284031215615adb57600080fd5b815161112e816145cb565b634e487b7160e01b600052603160045260246000fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212205f0d5e9e498f3a347142a818f072dd61486ac0c193c33456fd6fdad78707584564736f6c63430008100033