Contract Address Details

0xBc0F2491e5A7d87123006CeF7a8f0c8BF21525db

Contract Name
Web3Entry
Creator
0xe01c8d–e085f7 at 0x446b7f–3d038b
Balance
0 CSB
Tokens
Fetching tokens...
Transactions
1 Transactions
Transfers
0 Transfers
Gas Used
160,829
Last Balance Update
61257822
Contract name:
Web3Entry




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




Optimization runs
200
Verified at
2023-05-18T10:56:53.059099Z

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 {

}
        

@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/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/utils/cryptography/ECDSA.sol

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

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}
          

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

    mapping(address => uint256) internal _sigNonces; // for replay protection // slot 28
}
// slither-disable-end naming-convention
          

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 or exceed the approval amount
error ErrNotApprovedOrExceedApproval();

/// @dev Exceed max supply
error ErrExceedMaxSupply();

/// @dev Exceed the approval amount
error ErrExceedApproval();

/// @dev Signature is expired
error ErrSignatureExpired();

/// @dev Signature is invalid
error ErrSignatureInvalid();
          

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 {
    /**
     * @notice Initializes the Web3Entry.
     * @param name_ The name to set for the web3Entry character NFT.
     * @param symbol_ The symbol to set for the web3Entry character NFT.
     * @param linklist_ The address of linklist contract to set.
     * @param mintNFTImpl_ The address of mintNFTImpl contract to set.
     * @param periphery_ The address of periphery contract to set.
     * @param newbieVilla_ The address of newbieVilla contract to set.
     */
    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 an address as an operator and authorize it with custom permissions via signature.
     * @dev Only character owner can call.
     * @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.
     * @param sig The EIP712Signature struct containing the character owner's signature.
     * @dev Every bit in permissionBitMap stands for a corresponding method in Web3Entry. more details in OP.sol.
     */
    function grantOperatorPermissionsWithSig(
        uint256 characterId,
        address operator,
        uint256 permissionBitMap,
        DataTypes.EIP712Signature calldata sig
    ) 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;

    /**
     * @notice Links an address with the given parameters.
     * @param vars The linkAddressData struct containing the linking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a link action.<br>
     * `ethAddress`: The address to be linked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     * `data`: The data passed to the link module to use, if any.<br>
     */
    function linkAddress(DataTypes.linkAddressData calldata vars) external;

    /**
     * @notice Unlinks an address with the given parameters.
     * @param vars The unlinkAddressData struct containing the unlinking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a unlink action.<br>
     * `ethAddress`: The address to be unlinked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     */
    function unlinkAddress(DataTypes.unlinkAddressData calldata vars) external;

    /**
     * @notice Links a character with the given parameters.
     * @param vars The linkCharacterData struct containing the linking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a link action.<br>
     * `toCharacterId`: The character ID to be linked.<br>
     * `linkType`: The link type, like "follow", which is a bytes32 format.<br>
     * `data`: The data passed to the link module to use, if any.<br>
     */
    function linkCharacter(DataTypes.linkCharacterData calldata vars) external;

    /**
     * @notice Unlinks a character with the given parameters.
     * @param vars The unlinkCharacterData struct containing the unlinking parameters:
     * `fromCharacterId`: The character ID to sponsor a unlink action.<br>
     * `toCharacterId`: The character ID to be unlinked.<br>
     * `linkType`: The link type, like "follow", which is a bytes32 format.<br>
     */
    function unlinkCharacter(DataTypes.unlinkCharacterData calldata vars) external;

    /**
     * @notice Create a character and then link it.
     * @param vars The createThenLinkCharacterData struct containing the parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a link action.<br>
     * `to`: The address to receive the new character nft.<br>
     * `linkType`: The link type, like "follow", which is a bytes32 format.<br>
     */
    function createThenLinkCharacter(
        DataTypes.createThenLinkCharacterData calldata vars
    ) external returns (uint256 characterId);

    /**
     * @notice Links a note with the given parameters.
     * @param vars The linkNoteData struct containing the linking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a link action.<br>
     * `toCharacterId`: The character ID of note to be linked.<br>
     * `toNoteId`: The note ID of note to be linked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     * `data`: The data passed to the link module to use, if any.<br>
     */
    function linkNote(DataTypes.linkNoteData calldata vars) external;

    /**
     * @notice UnLinks a note with the given parameters.
     * @param vars The unlinkNoteData struct containing the unlinking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a unlink action.<br>
     * `toCharacterId`: The character ID of note to be unlinked.<br>
     * `toNoteId`: The note ID of note to be unlinked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     */
    function unlinkNote(DataTypes.unlinkNoteData calldata vars) external;

    /**
     * @notice Links an ERC721 with the given parameters.
     * @param vars The linkERC721Data struct containing the linking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a link action.<br>
     * `tokenAddress`: The token address of ERC721 to be linked.<br>
     * `tokenId`: The token ID of ERC721 to be linked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     * `data`: The data passed to the link module to use, if any.<br>
     */
    function linkERC721(DataTypes.linkERC721Data calldata vars) external;

    /**
     * @notice Unlinks an ERC721 with the given parameters.
     * @param vars The unlinkERC721Data struct containing the unlinking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a unlink action.<br>
     * `tokenAddress`: The token address of ERC721 to be unlinked.<br>
     * `tokenId`: The token ID of ERC721 to be unlinked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     */
    function unlinkERC721(DataTypes.unlinkERC721Data calldata vars) external;

    /**
     * @notice Links any uri with the given parameters.
     * @param vars The linkAnyUriData struct containing the linking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a link action.<br>
     * `toUri`: The uri to be linked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     * `data`: The data passed to the link module to use, if any.<br>
     */
    function linkAnyUri(DataTypes.linkAnyUriData calldata vars) external;

    /**
     * @notice Unlinks any uri with the given parameters.
     * @param vars The unlinkAnyUriData struct containing the unlinking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a unlink action.<br>
     * `toUri`: The uri to be unlinked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     */
    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;
    */

    /**
     * @notice Links a linklist with the given parameters.
     * @param vars The linkLinklistData struct containing the linking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a link action.<br>
     * `toLinkListId`: The linklist ID to be linked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     * `data`: The data passed to the link module to use, if any.<br>
     */
    function linkLinklist(DataTypes.linkLinklistData calldata vars) external;

    /**
     * @notice Unlinks a linklist with the given parameters.
     * @param vars The unlinkLinklistData struct containing the unlinking parameters:<br>
     * `fromCharacterId`: The character ID to sponsor a unlink action.<br>
     * `toLinkListId`: The linklist ID to be unlinked.<br>
     * `linkType`: The link type, like "like", which is a bytes32 format.<br>
     */
    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 Sets 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;

    /**
     * @notice Mints an nft with the given note.
     * @param vars The MintNoteData struct containing the minting parameters:<br>
     * `characterId`: The character ID of the note.<br>
     * `noteId`: The note ID of the note.<br>
     * `to`: The address to receive the minted nft.<br>
     * `data`: The data passed to the mint module to use, if any.<br>
     */
    function mintNote(DataTypes.MintNoteData calldata vars) external returns (uint256 tokenId);

    /**
     * @notice Sets a mint module for the given note.
     * @param vars The setMintModule4NoteData struct containing the setting parameters:<br>
     * `characterId`: The character ID of the note.<br>
     * `noteId`: The note ID of the note.<br>
     * `mintModule`: The address of mint module to set.<br>
     * `mintModuleInitData`: The data passed to the mint module to init, if any.<br>
     */
    function setMintModule4Note(DataTypes.setMintModule4NoteData calldata vars) external;

    /**
     * @notice Posts a note with the given parameters.
     * @param vars The postNoteData struct containing the posting parameters:<br>
     * `characterId`: The character ID to post to.<br>
     * `contentUri`: The uri to set for the new post.<br>
     * `linkModule`: The address of link module to set for the new post.<br>
     * `linkModuleInitData`: The data passed to the link module to init, if any.<br>
     * `mintModule`: The address of mint module to set for the new post.<br>
     * `mintModuleInitData`: The data passed to the mint module to init, if any.<br>
     */
    function postNote(DataTypes.PostNoteData calldata vars) 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;

    /**
     * @notice Posts a note for a given character.
     * @param vars The postNoteData struct containing the posting parameters:<br>
     * `characterId`: The character ID to post to.<br>
     * `contentUri`: The uri to set for the new post.<br>
     * `linkModule`: The address of link module to set for the new post.<br>
     * `linkModuleInitData`: The data passed to the link module to init, if any.<br>
     * `mintModule`: The address of mint module to set for the new post.<br>
     * `mintModuleInitData`: The data passed to the mint module to init, if any.<br>
     * @param toCharacterId The target character ID.
     */
    function postNote4Character(
        DataTypes.PostNoteData calldata vars,
        uint256 toCharacterId
    ) external returns (uint256);

    /**
     * @notice Posts a note for a given address.
     * @param vars The postNoteData struct containing the posting parameters:<br>
     * `characterId`: The character ID to post to.<br>
     * `contentUri`: The uri to set for the new post.<br>
     * `linkModule`: The address of link module to set for the new post.<br>
     * `linkModuleInitData`: The data passed to the link module to init, if any.<br>
     * `mintModule`: The address of mint module to set for the new post.<br>
     * `mintModuleInitData`: The data passed to the mint module to init, if any.<br>
     * @param ethAddress The target address.
     */
    function postNote4Address(
        DataTypes.PostNoteData calldata vars,
        address ethAddress
    ) external returns (uint256);

    /**
     * @notice Posts a note for a given linklist.
     * @param vars The postNoteData struct containing the posting parameters:<br>
     * `characterId`: The character ID to post to.<br>
     * `contentUri`: The uri to set for the new post.<br>
     * `linkModule`: The address of link module to set for the new post.<br>
     * `linkModuleInitData`: The data passed to the link module to init, if any.<br>
     * `mintModule`: The address of mint module to set for the new post.<br>
     * `mintModuleInitData`: The data passed to the mint module to init, if any.<br>
     * @param toLinklistId The target linklist.
     */
    function postNote4Linklist(
        DataTypes.PostNoteData calldata vars,
        uint256 toLinklistId
    ) external returns (uint256);

    /**
     * @notice Posts a note for a given note.
     * @param vars The postNoteData struct containing the posting parameters:<br>
     * `characterId`: The character ID to post to.<br>
     * `contentUri`: The uri to set for the new post.<br>
     * `linkModule`: The address of link module to set for the new post.<br>
     * `linkModuleInitData`: The data passed to the link module to init, if any.<br>
     * `mintModule`: The address of mint module to set for the new post.<br>
     * `mintModuleInitData`: The data passed to the mint module to init, if any.<br>
     * @param note The target note struct containing the parameters:<br>
     * `characterId`: The character ID of target note.<br>
     * `noteId`: The note ID of target note.
     */
    function postNote4Note(
        DataTypes.PostNoteData calldata vars,
        DataTypes.NoteStruct calldata note
    ) external returns (uint256);

    /**
     * @notice Posts a note for a given ERC721.
     * @param vars The postNoteData struct containing the posting parameters:<br>
     * `characterId`: The character ID to post to.<br>
     * `contentUri`: The uri to set for the new post.<br>
     * `linkModule`: The address of link module to set for the new post.<br>
     * `linkModuleInitData`: The data passed to the link module to init, if any.<br>
     * `mintModule`: The address of mint module to set for the new post.<br>
     * `mintModuleInitData`: The data passed to the mint module to init, if any.<br>
     * @param erc721 The target ERC721 struct containing the parameters:<br>
     * `tokenAddress`: The token address of target ERC721.<br>
     * `erc721TokenId`: The token ID of target ERC721.
     */
    function postNote4ERC721(
        DataTypes.PostNoteData calldata vars,
        DataTypes.ERC721Struct calldata erc721
    ) external returns (uint256);

    /**
     * @notice Posts a note for a given uri.
     * @param vars The postNoteData struct containing the posting parameters:<br>
     * `characterId`: The character ID to post to.<br>
     * `contentUri`: The uri to set for the new post.<br>
     * `linkModule`: The address of link module to set for the new post.<br>
     * `linkModuleInitData`: The data passed to the link module to init, if any.<br>
     * `mintModule`: The address of mint module to set for the new post.<br>
     * `mintModuleInitData`: The data passed to the mint module to init, if any.<br>
     * @param uri The target uri(could be an url link).
     */
    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);

    /**
     * @notice Returns primary character for a given account.
     * @param account The address to query.
     * @return uint256 The primary character ID, which will be 0 if not mapped.
     */
    function getPrimaryCharacterId(address account) external view returns (uint256);

    /**
     * @notice Returns whether or not a character is primary character.
     * @param characterId The character ID to query.
     * @return bool True if the character is primary, false otherwise.
     */
    function isPrimaryCharacter(uint256 characterId) external view returns (bool);

    /**
     * @notice Returns the full character struct associated with a given character token ID.
     * @param characterId The token ID of the character to query.
     * @return The full character struct of given character.
     */
    function getCharacter(uint256 characterId) external view returns (DataTypes.Character memory);

    /**
     * @notice Returns the full character struct associated with a given character handle.
     * @param handle The handle of the character to query.
     * @return The full character struct of given character.
     */
    function getCharacterByHandle(
        string calldata handle
    ) external view returns (DataTypes.Character memory);

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

    /**
     * @notice Returns the uri of character with a given character.
     * @param characterId The token ID of the character to query.
     * @return The uri of given character.
     */
    function getCharacterUri(uint256 characterId) external view returns (string memory);

    /**
     * @notice Returns the full note struct associated with a given note.
     * @param characterId The token ID of the character to query.
     * @param noteId The token ID of the note to query.
     * @return The full note struct of given note.
     */
    function getNote(
        uint256 characterId,
        uint256 noteId
    ) external view returns (DataTypes.Note memory);

    /**
     * @notice Returns the linkModule address of a given address.
     * @param account The address to query.
     * @return The address of linkModule.
     */
    function getLinkModule4Address(address account) external view returns (address);

    /**
     * @notice Returns the linkModule address of a given linklist.
     * @param tokenId The token ID of linklist to query.
     * @return The address of linkModule.
     */
    function getLinkModule4Linklist(uint256 tokenId) external view returns (address);

    /**
     * @notice Returns the linkModule address of a given ERC721.
     * @param tokenAddress The token address of ERC721 to query.
     * @param tokenId The token ID of ERC721 to query.
     * @return The address of linkModule.
     */
    function getLinkModule4ERC721(
        address tokenAddress,
        uint256 tokenId
    ) external view returns (address);

    /**
     * @notice Returns the uri of linklist with a given linklist.
     * @param tokenId The token ID of the linklist to query.
     * @return string The uri of given linklist.
     */
    function getLinklistUri(uint256 tokenId) external view returns (string memory);

    /**
     * @notice Returns the token ID of linklist with a given character and linkType.
     * @param characterId The token ID of the character to query.
     * @param linkType The linkType.
     * @return The token ID of linklist.
     */
    function getLinklistId(uint256 characterId, bytes32 linkType) external view returns (uint256);

    /**
     * @notice Returns the linkType of linklist with a given linklist.
     * @param linkListId The token ID of the linklist to query.
     * @return bytes32 The linkType of given linklist.
     */
    function getLinklistType(uint256 linkListId) external view returns (bytes32);

    /**
     * @notice Returns the address of linklist contract.
     * @return The address of linklist contract.
     */
    function getLinklistContract() external view returns (address);

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

    /**
     * @notice Returns the current nonce for `owner`. This value must be included
     * whenever a signature is generated by `grantOperatorPermissionsWithSig`.
     * Every successful call to `grantOperatorPermissionsWithSig` increases `owner`'s nonce by one. This
     * prevents a signature from being used multiple times.
     * @param owner The owner address to query.
     * @return uint256 The current nonce for `owner`.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @notice Returns the revision number of web3Entry contract.
     * @return The the revision number of web3Entry contract.
     */
    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;
}
          

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
    );
}
          

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

@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/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/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 {
    // solhint-disable-next-line private-vars-leading-underscore, var-name-mixedcase
    bytes32 internal constant EIP712_DOMAIN_TYPEHASH =
        keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
    // solhint-disable-next-line private-vars-leading-underscore, var-name-mixedcase
    bytes32 internal constant GRANT_OPERATOR_PERMISSIONS_WITH_SIG_TYPEHASH =
        keccak256( // solhint-disable-next-line max-line-length
            "grantOperatorPermissions(uint256 characterId,address operator,uint256 permissionBitMap,uint256 nonce,uint256 deadline)"
        );

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

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

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

@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,
    ErrSignatureExpired,
    ErrSignatureInvalid
} 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";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.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);
        _grantOperatorPermissions(characterId, operator, permissionBitMap);
    }

    /// @inheritdoc IWeb3Entry
    function grantOperatorPermissionsWithSig(
        uint256 characterId,
        address operator,
        uint256 permissionBitMap,
        DataTypes.EIP712Signature calldata sig
    ) external override {
        address owner = ownerOf(characterId);

        unchecked {
            bytes32 hashedMessage = keccak256(
                abi.encode(
                    GRANT_OPERATOR_PERMISSIONS_WITH_SIG_TYPEHASH,
                    characterId,
                    operator,
                    permissionBitMap,
                    _sigNonces[owner]++,
                    sig.deadline
                )
            );
            _validateRecoveredAddress(
                ECDSA.toTypedDataHash(_calculateDomainSeparator(), hashedMessage),
                owner,
                sig
            );
        }

        _grantOperatorPermissions(characterId, operator, permissionBitMap);
    }

    /// @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.
     * 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 getDomainSeparator() external view override returns (bytes32) {
        return _calculateDomainSeparator();
    }

    /// @inheritdoc IWeb3Entry
    function nonces(address owner) external view override returns (uint256) {
        return _sigNonces[owner];
    }

    /// @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 _grantOperatorPermissions(
        uint256 characterId,
        address operator,
        uint256 permissionBitMap
    ) internal {
        OperatorLogic.grantOperatorPermissions(
            characterId,
            operator,
            permissionBitMap,
            _operatorsByCharacter,
            _operatorsPermissionBitMap
        );
    }

    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();
    }

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

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

    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
}
          

@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":"0x79eedea3f2deea92bd9774a13e5b16b0c2589d46"},"contracts/libraries/OperatorLogic.sol":{"OperatorLogic":"0x8f479bc8d4a325cf75631b123f760b7ba07415e7"},"contracts/libraries/LinkModuleLogic.sol":{"LinkModuleLogic":"0xdeb3767f23898e22aa6ab6c220c383537fc93563"},"contracts/libraries/LinkLogic.sol":{"LinkLogic":"0xb9d16c633044a1ae5d0914e13c8475705b3dffb1"},"contracts/libraries/CharacterLogic.sol":{"CharacterLogic":"0x11989a675d77f711188533113e5346ea70205b9d"}}}
              

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":"ErrSignatureExpired","inputs":[]},{"type":"error","name":"ErrSignatureInvalid","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":"bytes32","name":"","internalType":"bytes32"}],"name":"getDomainSeparator","inputs":[]},{"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":"grantOperatorPermissionsWithSig","inputs":[{"type":"uint256","name":"characterId","internalType":"uint256"},{"type":"address","name":"operator","internalType":"address"},{"type":"uint256","name":"permissionBitMap","internalType":"uint256"},{"type":"tuple","name":"sig","internalType":"struct DataTypes.EIP712Signature","components":[{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"},{"type":"uint256","name":"deadline","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":"uint256","name":"","internalType":"uint256"}],"name":"nonces","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"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

0x608060405234801561001057600080fd5b50615e9d80620000216000396000f3fe608060405234801561001057600080fd5b506004361061045f5760003560e01c80637ecebe001161024c578063c053f6b811610146578063dca27135116100c3578063ef0828ab11610087578063ef0828ab14610ad6578063f2ad807514610ae9578063f316bacd14610afc578063f6479d7714610b0f578063fe9299fb14610b2257600080fd5b8063dca2713514610a59578063e56f2fe414610a6c578063e985e9c514610a7f578063ec81d19414610abb578063ed24911d14610ace57600080fd5b8063d23b320b1161010a578063d23b320b146109d5578063d70e10c6146109e8578063dabb053114610a13578063db491e8014610a26578063dc17b6de14610a4657600080fd5b8063c053f6b814610978578063c2a6fe3b14610989578063c87b56dd1461099c578063cb8e757e146109af578063cd69fe61146109c257600080fd5b80639864c307116101d4578063a7ccb4bf11610198578063a7ccb4bf1461090c578063ac9650d81461091f578063af90b1121461093f578063b88d4fde14610952578063b9d328451461096557600080fd5b80639864c307146108a05780639a4dec18146108b35780639a50248d146108c6578063a22cb465146108e6578063a6e6178d146108f957600080fd5b806392f7070b1161021b57806392f7070b1461082957806393f057e51461083c578063952be0ef1461084f57806395d89b411461088557806395d9fa7d1461088d57600080fd5b80637ecebe00146107c7578063867884e6146107f05780638734bbfc146108035780638b4ca06a1461081657600080fd5b806331b9d08c1161035d57806349186953116102e55780636352211e116102a95780636352211e1461075b5780636bf55d5f1461076e57806370a082311461078e57806374f345cf146107a1578063753d662d146107b457600080fd5b806349186953146106ee5780634f6ccce71461070f5780635a936d10146107225780635fb8818314610735578063628b644a1461074857600080fd5b806340ad34d81161032c57806340ad34d81461068f57806342842e0e146106a257806342966c68146106b557806344b82a24146106c857806347f94de7146106db57600080fd5b806331b9d08c1461062a578063327b2a031461065657806333f06ee614610669578063388f50831461067c57600080fd5b8063144a3e83116103eb57806323b872dd116103af57806323b872dd146105b557806328fbb805146105c857806329c301c2146105db5780632abc6bf6146105ee5780632f745c591461061757600080fd5b8063144a3e831461053e57806318160ddd14610551578063188b04b314610559578063206657f21461056c5780632209d1451461057f57600080fd5b806308cb68ff1161043257806308cb68ff146104df578063095ea7b3146104f45780630c4dd5f2146105075780630ff982441461051a5780631316529d1461052d57600080fd5b806301ffc9a71461046457806304f3bcec1461048c57806306fdde03146104b7578063081812fc146104cc575b600080fd5b6104776104723660046148bb565b610b4b565b60405190151581526020015b60405180910390f35b60175461049f906001600160a01b031681565b6040516001600160a01b039091168152602001610483565b6104bf610b76565b6040516104839190614928565b61049f6104da36600461493b565b610c08565b6104f26104ed36600461496c565b610ca2565b005b6104f26105023660046149bc565b610d79565b6104f261051536600461496c565b610e8e565b6104f26105283660046149e6565b610f98565b60045b604051908152602001610483565b6104bf61054c36600461493b565b611011565b600854610530565b6104f2610567366004614a14565b61101c565b6104f261057a366004614a48565b6110ba565b61049f61058d3660046149bc565b6001600160a01b03918216600090815260106020908152604080832093835292905220541690565b6104f26105c3366004614a7d565b6110d0565b6104776105d6366004614aa9565b611101565b6105306105e9366004614af0565b611118565b6105306105fc366004614b24565b6001600160a01b03166000908152600c602052604090205490565b6105306106253660046149bc565b6111a9565b61049f610638366004614b24565b6001600160a01b039081166000908152601160205260409020541690565b610530610664366004614b51565b61123f565b6104f2610677366004614bde565b6113ce565b6104f261068a366004614a14565b6114b5565b6104f261069d366004614c29565b61153a565b6104f26106b0366004614a7d565b6115b6565b6104f26106c336600461493b565b6115d1565b6105306106d6366004614c45565b61166e565b6104f26106e9366004614bde565b6116cf565b6107016106fc366004614c89565b611736565b604051610483929190614cef565b61053061071d36600461493b565b61178e565b6104f26107303660046149e6565b611821565b6104f2610743366004614a14565b61189a565b6104f2610756366004614d14565b611908565b61049f61076936600461493b565b611995565b61078161077c36600461493b565b611a0c565b6040516104839190614d66565b61053061079c366004614b24565b611a26565b6104f26107af366004614c89565b611aad565b6104f26107c2366004614d79565b611b27565b6105306107d5366004614b24565b6001600160a01b03166000908152601c602052604090205490565b6104f26107fe366004614c29565b611c2b565b61047761081136600461493b565b611cd5565b61053061082436600461493b565b611d03565b610530610837366004614dc0565b611d6f565b6104f261084a3660046149e6565b611dea565b61053061085d366004614e04565b60009182526019602090815260408084206001600160a01b0393909316845291905290205490565b6104bf611e8a565b6104f261089b366004614e04565b611e99565b6104f26108ae366004614a14565b611f2b565b6105306108c1366004614b51565b611f8c565b6108d96108d4366004614e27565b612077565b6040516104839190614e68565b6104f26108f4366004614ef4565b612226565b6104f2610907366004614bde565b612231565b61053061091a366004614a14565b612311565b61093261092d366004614f62565b6123b2565b6040516104839190614f97565b61053061094d366004614c45565b6124a6565b6104f26109603660046150e4565b6124cd565b6104f261097336600461515d565b612505565b6013546001600160a01b031661049f565b6104f2610997366004614c89565b6125b8565b6104bf6109aa36600461493b565b61262a565b6104f26109bd36600461515d565b6126cf565b6105306109d036600461515d565b61275e565b6104f26109e3366004614a14565b612773565b6105306109f6366004614c89565b6000918252600d6020908152604080842092845291905290205490565b6108d9610a2136600461493b565b6127fe565b610a39610a34366004614c89565b612985565b6040516104839190615191565b6104f2610a54366004615227565b612ae6565b6104bf610a6736600461493b565b612b77565b6104f2610a7a3660046152a9565b612be9565b610477610a8d36600461535a565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6104bf610ac936600461493b565b612d76565b610530612d96565b6104f2610ae436600461496c565b612da5565b6104f2610af736600461493b565b612e2f565b610530610b0a366004615384565b612e7e565b610530610b1d3660046149e6565b612fbf565b61049f610b3036600461493b565b6000908152600f60205260409020546001600160a01b031690565b60006001600160e01b0319821663780e9d6360e01b1480610b705750610b70826130da565b92915050565b606060008054610b85906153df565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb1906153df565b8015610bfe5780601f10610bd357610100808354040283529160200191610bfe565b820191906000526020600020905b815481529060010190602001808311610be157829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610c865760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b610caf6020820182614b24565b6001600160a01b0316336001600160a01b031614610ce05760405163ca67421960e01b815260040160405180910390fd5b73deb3767f23898e22aa6ab6c220c383537fc9356363dfc34f25610d076020840184614b24565b610d176040850160208601614b24565b610d246040860186615413565b60116040518663ffffffff1660e01b8152600401610d46959493929190615482565b60006040518083038186803b158015610d5e57600080fd5b505af4158015610d72573d6000803e3d6000fd5b5050505050565b6000610d8482611995565b9050806001600160a01b0316836001600160a01b031603610df15760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610c7d565b336001600160a01b0382161480610e0d5750610e0d8133610a8d565b610e7f5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610c7d565b610e89838361312a565b505050565b6013546040516367880d6160e11b8152823560048201526000916001600160a01b03169063cf101ac290602401602060405180830381865afa158015610ed8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efc91906154c1565b9050610f098160c1613198565b73deb3767f23898e22aa6ab6c220c383537fc93563636252159e8335610f356040860160208701614b24565b610f426040870187615413565b600f6040518663ffffffff1660e01b8152600401610f649594939291906154da565b60006040518083038186803b158015610f7c57600080fd5b505af4158015610f90573d6000803e3d6000fd5b505050505050565b610fa4813560b2613198565b60135481356000818152600d6020908152604080832081870135808552908352928190205490516337fb824760e11b815273b9d16c633044a1ae5d0914e13c8475705b3dffb195636ff7048e95610d469590948901359390926001600160a01b0390921691600401615505565b6060610b708261262a565b611028813560b2613198565b6110358160200135613229565b73b9d16c633044a1ae5d0914e13c8475705b3dffb1639ec52a238235602084013560408501356110686060870187615413565b6013546020808a01356000908152600a9091526040908190206005015490516001600160e01b031960e08a901b168152610d469796959493926001600160a01b03908116921690600d90600401615531565b6110c5836002613198565b610e89838383613264565b6110da33826132c0565b6110f65760405162461bcd60e51b8152600401610c7d9061557e565b610e898383836133b7565b600061110e848484613564565b90505b9392505050565b6000611126823560ec613198565b61113082356135ee565b6040516342a34a5360e01b81529091507379eedea3f2deea92bd9774a13e5b16b0c2589d46906342a34a539061117490859085906000908190600e906004016156d6565b60006040518083038186803b15801561118c57600080fd5b505af41580156111a0573d6000803e3d6000fd5b50505050919050565b60006111b483611a26565b82106112165760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610c7d565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600061124d833560ca613198565b6545524337323160d01b600061126385356135ee565b6013549091506000906001600160a01b0316632ea24efc826112886020890189614b24565b6040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152602088013560448201526064016020604051808303816000875af11580156112de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130291906154c1565b90507379eedea3f2deea92bd9774a13e5b16b0c2589d466342a34a538784868561132f60208c018c614b24565b8b6020013560405160200161136292919060609290921b6bffffffffffffffffffffffff19168252601482015260340190565b604051602081830303815290604052600e6040518763ffffffff1660e01b81526004016113949695949392919061571b565b60006040518083038186803b1580156113ac57600080fd5b505af41580156113c0573d6000803e3d6000fd5b509398975050505050505050565b6013546040516367880d6160e11b8152600481018590526000916001600160a01b03169063cf101ac290602401602060405180830381865afa158015611418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143c91906154c1565b90506114498160b1613198565b601354604051633c17845760e11b81526001600160a01b039091169063782f08ae9061147d90879087908790600401615766565b600060405180830381600087803b15801561149757600080fd5b505af11580156114ab573d6000803e3d6000fd5b5050505050505050565b6114c1813560b9613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb163a4159c6b82356114ed6040850160208601614b24565b6013546040805160e086901b6001600160e01b031916815260048101949094526001600160a01b0392831660248501528601356044840152166064820152600d608482015260a401610d46565b611546813560b6613198565b60135460408051631d4deabf60e01b81528335600482015260208401356024820152908301356044820152606083013560648201526001600160a01b039091166084820152600d60a482015273b9d16c633044a1ae5d0914e13c8475705b3dffb190631d4deabf9060c401610d46565b610e89838383604051806020016040528060008152506124cd565b6000818152600a602052604080822090516115ef9160010190615780565b60408051918290039091206000818152600b6020908152838220829055858252600a90529182208281559092509061162a600183018261480a565b61163860028301600061480a565b50600060038201556004810180546001600160a01b031990811690915560059091018054909116905561166a82613617565b5050565b600061167c833560c8613198565b67131a5b9adb1a5cdd60c21b600061169485356135ee565b905060008460001b90507379eedea3f2deea92bd9774a13e5b16b0c2589d466342a34a53878486858a60405160200161136291815260200190565b6116da8360b0613198565b6000838152600a602052604090206002016116f682848361583c565b50827f17d7c9f69270ba135480ef16837f38b9d37d3ab291cbd3ba03982290c663199783836040516117299291906158fb565b60405180910390a2505050565b6000828152601a602090815260408083208484529091529020606090819061175d90613676565b6000858152601a60209081526040808320878452909152902090925061178590600201613676565b90509250929050565b600061179960085490565b82106117fc5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610c7d565b6008828154811061180f5761180f61590f565b90600052602060002001549050919050565b61182d813560be613198565b60135481356000818152600d602090815260408083208187013580855290835292819020549051633fe4fe3960e11b815273b9d16c633044a1ae5d0914e13c8475705b3dffb195637fc9fc7295610d469590948901359390926001600160a01b0390921691600401615505565b6118a6813560bb613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb16348391dcb82356118cf6020850185615413565b601354604080516001600160e01b031960e088901b168152610d469594939291890135916001600160a01b031690600d90600401615925565b6119128484613683565b61191c84846136e8565b611926848461375f565b6040516001626802bf60e01b031981527379eedea3f2deea92bd9774a13e5b16b0c2589d469063ff97fd4190611969908790879087908790600e90600401615966565b60006040518083038186803b15801561198157600080fd5b505af41580156114ab573d6000803e3d6000fd5b6000818152600260205260408120546001600160a01b031680610b705760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610c7d565b6000818152601860205260409020606090610b7090613676565b60006001600160a01b038216611a915760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610c7d565b506001600160a01b031660009081526003602052604090205490565b611ab88260c4613198565b611ac282826136e8565b6000828152600e60209081526040808320848452825291829020600501805460ff60a81b1916600160a81b179055905182815283917f036469f3e73c83520cdefa197d7a9c854c2f8bc0164b82e9f2bd4aa7e150fd3091015b60405180910390a25050565b6000611b3285611995565b6001600160a01b038181166000908152601c6020908152604080832080546001810190915581517f53f5e122d65c239c5936ed0eb8ce8ea2c1e77831749ec178c59c5cd4a792fe04938101939093529082018a90529288166060808301919091526080820188905260a08201939093529185013560c083015291925060e001604051602081830303815290604052805190602001209050611c1f611c18611bd76137a4565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b838561381a565b50610d72858585613264565b611c37813560b8613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb163154246368235611c636040850160208601614b24565b60135485356000908152600d6020908152604080832060608a013580855292529182902054825160e088901b6001600160e01b031916815260048101969096526001600160a01b03948516602487015291880135604486015260648501529116608483015260a482015260c401610d46565b600080611ce183611995565b6001600160a01b03166000908152600c60205260409020549290921492915050565b60135460405162fba02760e01b8152600481018390526000916001600160a01b03169062fba02790602401602060405180830381865afa158015611d4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7091906154c1565b6000611d7d833560c7613198565b664164647265737360c81b6000611d9485356135ee565b6040516bffffffffffffffffffffffff19606087901b1660208201529091506001600160a01b038516907379eedea3f2deea92bd9774a13e5b16b0c2589d46906342a34a53908890859087908690603401611362565b611df6813560ba613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb16393c96a528235611e226040850160208601614b24565b60135485356000908152600d60209081526040808320818a013580855292529182902054915160e087901b6001600160e01b031916815260048101959095526001600160a01b039384166024860152604485015291166064830152608482015260a401610d46565b606060018054610b85906153df565b611ea4826001613198565b6000828152600a60205260409020600401546001600160a01b031615611edd5760405163fe6f50e560e01b815260040160405180910390fd5b6040516384b44a2f60e01b8152600481018390526001600160a01b0382166024820152600a60448201527311989a675d77f711188533113e5346ea70205b9d906384b44a2f90606401610f64565b611f37813560bd613198565b60135460408051632ca904df60e01b815273b9d16c633044a1ae5d0914e13c8475705b3dffb192632ca904df92610d4692863592602088013592880135916001600160a01b0390911690600d90600401615505565b6000611f9a833560c9613198565b634e6f746560e01b6000611fae85356135ee565b601354604051635cb46be760e01b815260006004820181905287356024830152602088013560448301529293506001600160a01b0390911690635cb46be7906064016020604051808303816000875af115801561200f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061203391906154c1565b90507379eedea3f2deea92bd9774a13e5b16b0c2589d466342a34a53878486858a600001358b60200135604051602001611362929190918252602082015260400190565b61207f614844565b60008383604051612091929190615986565b604080519182900382206000818152600b602090815283822054808352600a82529184902060c08601909452835485526001840180549396509194939290840191906120dc906153df565b80601f0160208091040260200160405190810160405280929190818152602001828054612108906153df565b80156121555780601f1061212a57610100808354040283529160200191612155565b820191906000526020600020905b81548152906001019060200180831161213857829003601f168201915b5050505050815260200160028201805461216e906153df565b80601f016020809104026020016040519081016040528092919081815260200182805461219a906153df565b80156121e75780601f106121bc576101008083540402835291602001916121e7565b820191906000526020600020905b8154815290600101906020018083116121ca57829003601f168201915b50505091835250506003820154602082015260048201546001600160a01b03908116604083015260059092015490911660609091015295945050505050565b61166a3383836138f7565b61223c836000613198565b61225c828260405161224f929190615986565b60405180910390206139c5565b61229b82828080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506139f292505050565b60405163130f361d60e01b81527311989a675d77f711188533113e5346ea70205b9d9063130f361d906122dc90869086908690600b90600a90600401615996565b60006040518083038186803b1580156122f457600080fd5b505af4158015612308573d6000803e3d6000fd5b50505050505050565b6000612322823560208401356136e8565b7379eedea3f2deea92bd9774a13e5b16b0c2589d46639d2e06f0833560208501356123536060870160408801614b24565b6123606060880188615413565b6014546040516001600160e01b031960e089901b1681526123959695949392916001600160a01b031690600e906004016159c4565b602060405180830381865af4158015611d4b573d6000803e3d6000fd5b6060816001600160401b038111156123cc576123cc614ff9565b6040519080825280602002602001820160405280156123ff57816020015b60608152602001906001900390816123ea5790505b50905060005b8281101561249f5761246f308585848181106124235761242361590f565b90506020028101906124359190615413565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613a5f92505050565b8282815181106124815761248161590f565b6020026020010181905250808061249790615a1e565b915050612405565b5092915050565b60006124b4833560c6613198565b6821b430b930b1ba32b960b91b600061169485356135ee565b6124d733836132c0565b6124f35760405162461bcd60e51b8152600401610c7d9061557e565b6124ff84848484613a84565b50505050565b612511813560b5613198565b612523816020013582604001356136e8565b73b9d16c633044a1ae5d0914e13c8475705b3dffb16371bd9b06823560208401356040850135606086013561255b6080880188615413565b6013546020808b01356000908152600e82526040808220818e013583529092528190206003015490516001600160e01b031960e08b901b168152610d46989796959493926001600160a01b03908116921690600d90600401615a37565b6125c38260c5613198565b6125cd82826136e8565b6000828152600e60209081526040808320848452825291829020600501805460ff60a01b1916600160a01b179055905182815283917f4f1db9708b537c1d26a7af4b235fd079bf2342d92a276e27eb6c8717e8bbcf939101611b1b565b6000818152600a6020526040902060020180546060919061264a906153df565b80601f0160208091040260200160405190810160405280929190818152602001828054612676906153df565b80156126c35780601f10612698576101008083540402835291602001916126c3565b820191906000526020600020905b8154815290600101906020018083116126a657829003601f168201915b50505050509050919050565b6126db813560b7613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb163f35deae182356127076040850160208601614b24565b6013546040805160e086901b6001600160e01b031916815260048101949094526001600160a01b039283166024850152860135604484015260608601356064840152166084820152600d60a482015260c401610d46565b6000610b7061276c83615a8d565b6001613ab7565b61277f813560c2613198565b61278e813560208301356136e8565b61279d8135602083013561375f565b73deb3767f23898e22aa6ab6c220c383537fc935636320828a02823560208401356127ce6060860160408701614b24565b6127db6060870187615413565b600e6040518763ffffffff1660e01b8152600401610d4696959493929190615b40565b612806614844565b600a60008381526020019081526020016000206040518060c00160405290816000820154815260200160018201805461283e906153df565b80601f016020809104026020016040519081016040528092919081815260200182805461286a906153df565b80156128b75780601f1061288c576101008083540402835291602001916128b7565b820191906000526020600020905b81548152906001019060200180831161289a57829003601f168201915b505050505081526020016002820180546128d0906153df565b80601f01602080910402602001604051908101604052809291908181526020018280546128fc906153df565b80156129495780601f1061291e57610100808354040283529160200191612949565b820191906000526020600020905b81548152906001019060200180831161292c57829003601f168201915b50505091835250506003820154602082015260048201546001600160a01b03908116604083015260059092015490911660609091015292915050565b60408051610100808201835260008083526020808401829052606084860181905284018290526080840182905260a0840182905260c0840182905260e08401829052868252600e81528482208683528152908490208451928301855280548352600181015491830191909152600281018054939492939192840191612a09906153df565b80601f0160208091040260200160405190810160405280929190818152602001828054612a35906153df565b8015612a825780601f10612a5757610100808354040283529160200191612a82565b820191906000526020600020905b815481529060010190602001808311612a6557829003601f168201915b505050918352505060038201546001600160a01b039081166020830152600483015481166040830152600590920154918216606082015260ff600160a01b8304811615156080830152600160a81b909204909116151560a090910152905092915050565b612af1866003613198565b612afb86866136e8565b604051630afb883f60e41b8152738f479bc8d4a325cf75631b123f760b7ba07415e79063afb883f090612b3f90899089908990899089908990601a90600401615bbd565b60006040518083038186803b158015612b5757600080fd5b505af4158015612b6b573d6000803e3d6000fd5b50505050505050505050565b601354604051632b05429560e21b8152600481018390526060916001600160a01b03169063ac150a5490602401600060405180830381865afa158015612bc1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b709190810190615c05565b601454600390600160a81b900460ff16158015612c14575060145460ff808316600160a01b90920416105b612c775760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c7d565b6014805460ff60a81b1960ff8416600160a01b021661ffff60a01b1990911617600160a81b179055612cab89898989613b94565b601380546001600160a01b03199081166001600160a01b0388811691909117909255601480548216878416179055601580548216868416179055601b80549091169184169190911790556040514281527f400175a56dd3710794078f7b9dbe8296ac94c5a248dfd51bb22ed4ab9eaa9fbf9060200160405180910390a16014805460ff60a81b1916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050505050565b6000818152600a6020526040902060010180546060919061264a906153df565b6000612da06137a4565b905090565b612db1813560bc613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb1631873e2188235612dda6020850185615413565b60135486356000908152600d60209081526040808320818b01358085529252918290205491516001600160e01b031960e089901b168152610d469695949391926001600160a01b039092169190600401615925565b612e3881613be5565b336000818152600c602052604080822080549085905590519092839285927fce95332e6082aebeb8058a7b56d1a109f67d6550552ed04d36aca4a6acd4d7de9190a45050565b6000612e8c843560cb613198565b65416e7955726960d01b6000612ea286356135ee565b601354604051633610bf0960e11b81529192506000916001600160a01b0390911690636c217e1290612edc9084908a908a90600401615766565b6020604051808303816000875af1158015612efb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f1f91906154c1565b90507379eedea3f2deea92bd9774a13e5b16b0c2589d466342a34a53888486858b8b604051602001612f52929190615986565b604051602081830303815290604052600e6040518763ffffffff1660e01b8152600401612f849695949392919061571b565b60006040518083038186803b158015612f9c57600080fd5b505af4158015612fb0573d6000803e3d6000fd5b50939998505050505050505050565b6000612fcd823560b4613198565b61305b6040518060a00160405280846020016020810190612fee9190614b24565b6001600160a01b031681526020016130178560200160208101906130129190614b24565b613c4b565b815260200160405180602001604052806000815250815260200160006001600160a01b03168152602001604051806020016040528060008152508152506000613ab7565b60135460408051639ec52a2360e01b8152853560048201526024810184905290850135604482015260e06064820152600060e482018190526001600160a01b03909216608482015260a4810191909152600d60c482015290915073b9d16c633044a1ae5d0914e13c8475705b3dffb190639ec52a239061010401611174565b60006001600160e01b031982166380ac58cd60e01b148061310b57506001600160e01b03198216635b5e139f60e01b145b80610b7057506301ffc9a760e01b6001600160e01b0319831614610b70565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061315f82611995565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6131a182613d54565b156131aa575050565b6015546001600160a01b031633036131e6576000828152601960209081526040808320328452909152902054600190821c8116036131e6575050565b6000828152601960209081526040808320338452909152902054600190821c811603613210575050565b604051632c4bc2b960e21b815260040160405180910390fd5b6000818152600260205260409020546001600160a01b0316613261576040516375af0fc960e11b815260048101829052602401610c7d565b50565b604051631f8c0b6760e11b8152600481018490526001600160a01b0383166024820152604481018290526018606482015260196084820152738f479bc8d4a325cf75631b123f760b7ba07415e790633f1816ce9060a4016122dc565b6000818152600260205260408120546001600160a01b03166133395760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610c7d565b600061334483611995565b9050806001600160a01b0316846001600160a01b0316148061337f5750836001600160a01b031661337484610c08565b6001600160a01b0316145b806133af57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166133ca82611995565b6001600160a01b03161461342e5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610c7d565b6001600160a01b0382166134905760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610c7d565b61349b838383613db4565b6134a660008261312a565b6001600160a01b03831660009081526003602052604081208054600192906134cf908490615c72565b90915550506001600160a01b03821660009081526003602052604081208054600192906134fd908490615c85565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4610e89838383613e86565b6000838152601a6020908152604080832085845290915281206135878184613ec3565b15613596576000915050611111565b6135a36002820184613ec3565b156135b2576001915050611111565b60008581526019602090815260408083206001600160a01b03871684529091529020546135e59060c31c60019081161490565b95945050505050565b6000818152600a602052604081206003018054829061360c90615a1e565b918290555092915050565b61362133826132c0565b61366d5760405162461bcd60e51b815260206004820152601b60248201527f4e4654426173653a204e6f744f776e65724f72417070726f76656400000000006044820152606401610c7d565b61326181613ee5565b6060600061111183613f94565b61368c82613d54565b15613695575050565b6015546001600160a01b031633036136bb576136b2828232613564565b156136bb575050565b6136c6828233613564565b156136cf575050565b604051631a1d1d4760e11b815260040160405180910390fd5b6000828152600e60209081526040808320848452909152902060050154600160a01b900460ff161561372d57604051631f0fc8f560e11b815260040160405180910390fd5b6000828152600a602052604090206003015481111561166a576040516364783acb60e01b815260040160405180910390fd5b6000828152600e60209081526040808320848452909152902060050154600160a81b900460ff161561166a57604051630bc06a0f60e21b815260040160405180910390fd5b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6137cf610b76565b8051602091820120604080519283019390935291810191909152600160608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b428160600135101561383e576040516275e96160e01b815260040160405180910390fd5b60006001846138506020850185615c98565b604080516000815260208181018084529490945260ff9092168282015291850135606082015290840135608082015260a0016020604051602081039080840390855afa1580156138a4573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806138d95750826001600160a01b0316816001600160a01b031614155b156124ff57604051636a9ca51760e01b815260040160405180910390fd5b816001600160a01b0316836001600160a01b0316036139585760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610c7d565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6000818152600b60205260409020541561326157604051631b659b9f60e21b815260040160405180910390fd5b80518190601f811180613a055750600381105b15613a2357604051636f819c2160e11b815260040160405180910390fd5b60005b818110156124ff57613a57838281518110613a4357613a4361590f565b01602001516001600160f81b031916613fef565b600101613a26565b60606111118383604051806060016040528060278152602001615e416027913961409d565b613a8f8484846133b7565b613a9b84848484614115565b6124ff5760405162461bcd60e51b8152600401610c7d90615cbb565b6000613acd8360200151805190602001206139c5565b8115613ae057613ae083602001516139f2565b601260008154613aef90615a1e565b91829055508351909150613b039082614216565b7311989a675d77f711188533113e5346ea70205b9d634daae5688460000151856020015186604001518760600151886080015187600b600a6040518963ffffffff1660e01b8152600401613b5e989796959493929190615d0d565b60006040518083038186803b158015613b7657600080fd5b505af4158015613b8a573d6000803e3d6000fd5b5050505092915050565b613ba084848484614230565b7f414cd0b34676984f09a5f76ce9718d4062e50283abe0e7e274a9a5b4e0c99c308484848442604051613bd7959493929190615d84565b60405180910390a150505050565b6000613bf082611995565b6015549091506001600160a01b031633148015613c155750326001600160a01b038216145b15613c1e575050565b6001600160a01b0381163303613c32575050565b604051631b0c476f60e11b815260040160405180910390fd5b60408051602a80825260608281019093526f181899199a1a9b1b9c1cb0b131b232b360811b916001600160a01b0385169160009190602082018180368337019050509050600360fc1b81600081518110613ca757613ca761590f565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613cd657613cd661590f565b60200101906001600160f81b031916908160001a90535060295b6001811115613d4b578383600f1660108110613d0e57613d0e61590f565b1a60f81b828281518110613d2457613d2461590f565b60200101906001600160f81b031916908160001a90535060049290921c9160001901613cf0565b50949350505050565b600080613d6083611995565b90506001600160a01b0381163303613d7b5750600192915050565b6015546001600160a01b031633148015613d9d5750326001600160a01b038216145b15613dab5750600192915050565b50600092915050565b601b546001600160a01b03848116911614613e7b576000818152601860205260408120613de09061424b565b600083815260186020526040812091925090613dfb90613676565b905060005b82811015613e3d57613e2b84838381518110613e1e57613e1e61590f565b6020026020010151614255565b80613e3581615a1e565b915050613e00565b506001600160a01b0385166000908152600c6020526040902054839003613e78576001600160a01b0385166000908152600c60205260408120555b50505b610e8983838361428e565b6001600160a01b0382166000908152600c60205260408120549003610e89576001600160a01b03919091166000908152600c602052604090205550565b6001600160a01b03811660009081526001830160205260408120541515611111565b6000613ef082611995565b9050613efe81600084613db4565b613f0960008361312a565b6001600160a01b0381166000908152600360205260408120805460019290613f32908490615c72565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a461166a81600084613e86565b6060816000018054806020026020016040519081016040528092919081815260200182805480156126c357602002820191906000526020600020905b815481526020019060010190808311613fd05750505050509050919050565b600360fc1b6001600160f81b0319821610806140185750603d60f91b6001600160f81b03198216115b806140485750603960f81b6001600160f81b031982161180156140485750606160f81b6001600160f81b03198216105b80156140625750602d60f81b6001600160f81b0319821614155b801561407c5750605f60f81b6001600160f81b0319821614155b15613261576040516001621693dd60e01b0319815260040160405180910390fd5b6060600080856001600160a01b0316856040516140ba9190615dbe565b600060405180830381855af49150503d80600081146140f5576040519150601f19603f3d011682016040523d82523d6000602084013e6140fa565b606091505b509150915061410b86838387614346565b9695505050505050565b60006001600160a01b0384163b1561420b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290614159903390899088908890600401615dda565b6020604051808303816000875af1925050508015614194575060408051601f3d908101601f1916820190925261419191810190615e0d565b60015b6141f1573d8080156141c2576040519150601f19603f3d011682016040523d82523d6000602084013e6141c7565b606091505b5080516000036141e95760405162461bcd60e51b8152600401610c7d90615cbb565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506133af565b506001949350505050565b61166a8282604051806020016040528060008152506143bf565b600061423d84868361583c565b506001610d7282848361583c565b6000610b70825490565b60008281526019602090815260408083206001600160a01b0385168452825280832083905584835260189091529020610e8990826143f2565b6001600160a01b0383166142e9576142e481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61430c565b816001600160a01b0316836001600160a01b03161461430c5761430c8382614407565b6001600160a01b03821661432357610e89816144a4565b826001600160a01b0316826001600160a01b031614610e8957610e898282614553565b606083156143b55782516000036143ae576001600160a01b0385163b6143ae5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c7d565b50816133af565b6133af8383614597565b6143c983836145c1565b6143d66000848484614115565b610e895760405162461bcd60e51b8152600401610c7d90615cbb565b6000611111836001600160a01b038416614717565b6000600161441484611a26565b61441e9190615c72565b600083815260076020526040902054909150808214614471576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906144b690600190615c72565b600083815260096020526040812054600880549394509092849081106144de576144de61590f565b9060005260206000200154905080600883815481106144ff576144ff61590f565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061453757614537615e2a565b6001900381819060005260206000200160009055905550505050565b600061455e83611a26565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b8151156145a75781518083602001fd5b8060405162461bcd60e51b8152600401610c7d9190614928565b6001600160a01b0382166146175760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c7d565b6000818152600260205260409020546001600160a01b03161561467c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c7d565b61468860008383613db4565b6001600160a01b03821660009081526003602052604081208054600192906146b1908490615c85565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a461166a60008383613e86565b6000818152600183016020526040812054801561480057600061473b600183615c72565b855490915060009061474f90600190615c72565b90508181146147b457600086600001828154811061476f5761476f61590f565b90600052602060002001549050808760000184815481106147925761479261590f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806147c5576147c5615e2a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b70565b6000915050610b70565b508054614816906153df565b6000825580601f10614826575050565b601f016020900490600052602060002090810190613261919061488c565b6040518060c001604052806000815260200160608152602001606081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b5b808211156148a1576000815560010161488d565b5090565b6001600160e01b03198116811461326157600080fd5b6000602082840312156148cd57600080fd5b8135611111816148a5565b60005b838110156148f35781810151838201526020016148db565b50506000910152565b600081518084526149148160208601602086016148d8565b601f01601f19169290920160200192915050565b60208152600061111160208301846148fc565b60006020828403121561494d57600080fd5b5035919050565b60006060828403121561496657600080fd5b50919050565b60006020828403121561497e57600080fd5b81356001600160401b0381111561499457600080fd5b6133af84828501614954565b80356001600160a01b03811681146149b757600080fd5b919050565b600080604083850312156149cf57600080fd5b6149d8836149a0565b946020939093013593505050565b6000606082840312156149f857600080fd5b6111118383614954565b60006080828403121561496657600080fd5b600060208284031215614a2657600080fd5b81356001600160401b03811115614a3c57600080fd5b6133af84828501614a02565b600080600060608486031215614a5d57600080fd5b83359250614a6d602085016149a0565b9150604084013590509250925092565b600080600060608486031215614a9257600080fd5b614a9b846149a0565b9250614a6d602085016149a0565b600080600060608486031215614abe57600080fd5b8335925060208401359150614ad5604085016149a0565b90509250925092565b600060e0828403121561496657600080fd5b600060208284031215614b0257600080fd5b81356001600160401b03811115614b1857600080fd5b6133af84828501614ade565b600060208284031215614b3657600080fd5b611111826149a0565b60006040828403121561496657600080fd5b60008060608385031215614b6457600080fd5b82356001600160401b03811115614b7a57600080fd5b614b8685828601614ade565b9250506117858460208501614b3f565b60008083601f840112614ba857600080fd5b5081356001600160401b03811115614bbf57600080fd5b602083019150836020828501011115614bd757600080fd5b9250929050565b600080600060408486031215614bf357600080fd5b8335925060208401356001600160401b03811115614c1057600080fd5b614c1c86828701614b96565b9497909650939450505050565b600060808284031215614c3b57600080fd5b6111118383614a02565b60008060408385031215614c5857600080fd5b82356001600160401b03811115614c6e57600080fd5b614c7a85828601614ade565b95602094909401359450505050565b60008060408385031215614c9c57600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b83811015614ce45781516001600160a01b031687529582019590820190600101614cbf565b509495945050505050565b604081526000614d026040830185614cab565b82810360208401526135e58185614cab565b60008060008060608587031215614d2a57600080fd5b843593506020850135925060408501356001600160401b03811115614d4e57600080fd5b614d5a87828801614b96565b95989497509550505050565b6020815260006111116020830184614cab565b60008060008060e08587031215614d8f57600080fd5b84359350614d9f602086016149a0565b925060408501359150614db58660608701614a02565b905092959194509250565b60008060408385031215614dd357600080fd5b82356001600160401b03811115614de957600080fd5b614df585828601614ade565b925050611785602084016149a0565b60008060408385031215614e1757600080fd5b82359150611785602084016149a0565b60008060208385031215614e3a57600080fd5b82356001600160401b03811115614e5057600080fd5b614e5c85828601614b96565b90969095509350505050565b60208152815160208201526000602083015160c06040840152614e8e60e08401826148fc565b90506040840151601f19848303016060850152614eab82826148fc565b91505060608401516080840152608084015160018060a01b0380821660a08601528060a08701511660c086015250508091505092915050565b803580151581146149b757600080fd5b60008060408385031215614f0757600080fd5b614f10836149a0565b915061178560208401614ee4565b60008083601f840112614f3057600080fd5b5081356001600160401b03811115614f4757600080fd5b6020830191508360208260051b8501011115614bd757600080fd5b60008060208385031215614f7557600080fd5b82356001600160401b03811115614f8b57600080fd5b614e5c85828601614f1e565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614fec57603f19888603018452614fda8583516148fc565b94509285019290850190600101614fbe565b5092979650505050505050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b038111828210171561503157615031614ff9565b60405290565b604051601f8201601f191681016001600160401b038111828210171561505f5761505f614ff9565b604052919050565b60006001600160401b0382111561508057615080614ff9565b50601f01601f191660200190565b600082601f83011261509f57600080fd5b81356150b26150ad82615067565b615037565b8181528460208386010111156150c757600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080608085870312156150fa57600080fd5b615103856149a0565b9350615111602086016149a0565b92506040850135915060608501356001600160401b0381111561513357600080fd5b61513f8782880161508e565b91505092959194509250565b600060a0828403121561496657600080fd5b60006020828403121561516f57600080fd5b81356001600160401b0381111561518557600080fd5b6133af8482850161514b565b602081528151602082015260208201516040820152600060408301516101008060608501526151c46101208501836148fc565b9150606085015160018060a01b0380821660808701528060808801511660a0870152505060a085015161520260c08601826001600160a01b03169052565b5060c085015180151560e08601525060e0850151801515858301525090949350505050565b6000806000806000806080878903121561524057600080fd5b863595506020870135945060408701356001600160401b038082111561526557600080fd5b6152718a838b01614f1e565b9096509450606089013591508082111561528a57600080fd5b5061529789828a01614f1e565b979a9699509497509295939492505050565b60008060008060008060008060c0898b0312156152c557600080fd5b88356001600160401b03808211156152dc57600080fd5b6152e88c838d01614b96565b909a50985060208b013591508082111561530157600080fd5b5061530e8b828c01614b96565b9097509550615321905060408a016149a0565b935061532f60608a016149a0565b925061533d60808a016149a0565b915061534b60a08a016149a0565b90509295985092959890939650565b6000806040838503121561536d57600080fd5b615376836149a0565b9150611785602084016149a0565b60008060006040848603121561539957600080fd5b83356001600160401b03808211156153b057600080fd5b6153bc87838801614ade565b945060208601359150808211156153d257600080fd5b50614c1c86828701614b96565b600181811c908216806153f357607f821691505b60208210810361496657634e487b7160e01b600052602260045260246000fd5b6000808335601e1984360301811261542a57600080fd5b8301803591506001600160401b0382111561544457600080fd5b602001915036819003821315614bd757600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b038681168252851660208201526080604082018190526000906154af9083018587615459565b90508260608301529695505050505050565b6000602082840312156154d357600080fd5b5051919050565b8581526001600160a01b03851660208201526080604082018190526000906154af9083018587615459565b948552602085019390935260408401919091526001600160a01b03166060830152608082015260a00190565b88815287602082015286604082015260e06060820152600061555760e083018789615459565b6001600160a01b0395861660808401529390941660a082015260c001529695505050505050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000808335601e198436030181126155e657600080fd5b83016020810192503590506001600160401b0381111561560557600080fd5b803603821315614bd757600080fd5b80358252600061562760208301836155cf565b60e0602086015261563c60e086018284615459565b91505061564b604084016149a0565b6001600160a01b03818116604087015261566860608601866155cf565b9250868403606088015261567d848483615459565b9350508061568d608087016149a0565b16608087015250506156a260a08401846155cf565b85830360a08701526156b5838284615459565b925050506156c560c08401614ee4565b151560c08501528091505092915050565b60c0815260006156e960c0830188615614565b602083810197909752604083019590955250606081019290925281830360808301526000835260a09091015201919050565b60c08152600061572e60c0830189615614565b876020840152866040840152856060840152828103608084015261575281866148fc565b9150508260a0830152979650505050505050565b8381526040602082015260006135e5604083018486615459565b600080835461578e816153df565b600182811680156157a657600181146157bb576157ea565b60ff19841687528215158302870194506157ea565b8760005260208060002060005b858110156157e15781548a8201529084019082016157c8565b50505082870194505b50929695505050505050565b601f821115610e8957600081815260208120601f850160051c8101602086101561581d5750805b601f850160051c820191505b81811015610f9057828155600101615829565b6001600160401b0383111561585357615853614ff9565b6158678361586183546153df565b836157f6565b6000601f84116001811461589b57600085156158835750838201355b600019600387901b1c1916600186901b178355610d72565b600083815260209020601f19861690835b828110156158cc57868501358255602094850194600190920191016158ac565b50868210156158e95760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152600061110e602083018486615459565b634e487b7160e01b600052603260045260246000fd5b86815260a06020820152600061593f60a083018789615459565b6040830195909552506001600160a01b039290921660608301526080909101529392505050565b8581528460208201526080604082015260006154af608083018587615459565b8183823760009101908152919050565b8581526080602082015260006159b0608083018688615459565b604083019490945250606001529392505050565b878152866020820152600060018060a01b03808816604084015260c060608401526159f360c084018789615459565b941660808301525060a0015295945050505050565b634e487b7160e01b600052601160045260246000fd5b600060018201615a3057615a30615a08565b5060010190565b60006101008b83528a6020840152896040840152886060840152806080840152615a64818401888a615459565b6001600160a01b0396871660a08501529490951660c08301525060e00152979650505050505050565b600060a08236031215615a9f57600080fd5b615aa761500f565b615ab0836149a0565b815260208301356001600160401b0380821115615acc57600080fd5b615ad83683870161508e565b60208401526040850135915080821115615af157600080fd5b615afd3683870161508e565b6040840152615b0e606086016149a0565b60608401526080850135915080821115615b2757600080fd5b50615b343682860161508e565b60808301525092915050565b86815285602082015260018060a01b038516604082015260a060608201526000615b6e60a083018587615459565b9050826080830152979650505050505050565b8183526000602080850194508260005b85811015614ce4576001600160a01b03615baa836149a0565b1687529582019590820190600101615b91565b87815286602082015260a060408201526000615bdd60a083018789615b81565b8281036060840152615bf0818688615b81565b91505082608083015298975050505050505050565b600060208284031215615c1757600080fd5b81516001600160401b03811115615c2d57600080fd5b8201601f81018413615c3e57600080fd5b8051615c4c6150ad82615067565b818152856020838501011115615c6157600080fd5b6135e58260208301602086016148d8565b81810381811115610b7057610b70615a08565b80820180821115610b7057610b70615a08565b600060208284031215615caa57600080fd5b813560ff8116811461111157600080fd5b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03898116825261010060208301819052600091615d338483018c6148fc565b91508382036040850152615d47828b6148fc565b908916606085015283810360808501529050615d6381886148fc565b60a0840196909652505060c081019290925260e09091015295945050505050565b606081526000615d98606083018789615459565b8281036020840152615dab818688615459565b9150508260408301529695505050505050565b60008251615dd08184602087016148d8565b9190910192915050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061410b908301846148fc565b600060208284031215615e1f57600080fd5b8151611111816148a5565b634e487b7160e01b600052603160045260246000fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212205df83ad3c38eba328a1cda0c48931584f7878751c67a44876718e7520924d60264736f6c63430008100033

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061045f5760003560e01c80637ecebe001161024c578063c053f6b811610146578063dca27135116100c3578063ef0828ab11610087578063ef0828ab14610ad6578063f2ad807514610ae9578063f316bacd14610afc578063f6479d7714610b0f578063fe9299fb14610b2257600080fd5b8063dca2713514610a59578063e56f2fe414610a6c578063e985e9c514610a7f578063ec81d19414610abb578063ed24911d14610ace57600080fd5b8063d23b320b1161010a578063d23b320b146109d5578063d70e10c6146109e8578063dabb053114610a13578063db491e8014610a26578063dc17b6de14610a4657600080fd5b8063c053f6b814610978578063c2a6fe3b14610989578063c87b56dd1461099c578063cb8e757e146109af578063cd69fe61146109c257600080fd5b80639864c307116101d4578063a7ccb4bf11610198578063a7ccb4bf1461090c578063ac9650d81461091f578063af90b1121461093f578063b88d4fde14610952578063b9d328451461096557600080fd5b80639864c307146108a05780639a4dec18146108b35780639a50248d146108c6578063a22cb465146108e6578063a6e6178d146108f957600080fd5b806392f7070b1161021b57806392f7070b1461082957806393f057e51461083c578063952be0ef1461084f57806395d89b411461088557806395d9fa7d1461088d57600080fd5b80637ecebe00146107c7578063867884e6146107f05780638734bbfc146108035780638b4ca06a1461081657600080fd5b806331b9d08c1161035d57806349186953116102e55780636352211e116102a95780636352211e1461075b5780636bf55d5f1461076e57806370a082311461078e57806374f345cf146107a1578063753d662d146107b457600080fd5b806349186953146106ee5780634f6ccce71461070f5780635a936d10146107225780635fb8818314610735578063628b644a1461074857600080fd5b806340ad34d81161032c57806340ad34d81461068f57806342842e0e146106a257806342966c68146106b557806344b82a24146106c857806347f94de7146106db57600080fd5b806331b9d08c1461062a578063327b2a031461065657806333f06ee614610669578063388f50831461067c57600080fd5b8063144a3e83116103eb57806323b872dd116103af57806323b872dd146105b557806328fbb805146105c857806329c301c2146105db5780632abc6bf6146105ee5780632f745c591461061757600080fd5b8063144a3e831461053e57806318160ddd14610551578063188b04b314610559578063206657f21461056c5780632209d1451461057f57600080fd5b806308cb68ff1161043257806308cb68ff146104df578063095ea7b3146104f45780630c4dd5f2146105075780630ff982441461051a5780631316529d1461052d57600080fd5b806301ffc9a71461046457806304f3bcec1461048c57806306fdde03146104b7578063081812fc146104cc575b600080fd5b6104776104723660046148bb565b610b4b565b60405190151581526020015b60405180910390f35b60175461049f906001600160a01b031681565b6040516001600160a01b039091168152602001610483565b6104bf610b76565b6040516104839190614928565b61049f6104da36600461493b565b610c08565b6104f26104ed36600461496c565b610ca2565b005b6104f26105023660046149bc565b610d79565b6104f261051536600461496c565b610e8e565b6104f26105283660046149e6565b610f98565b60045b604051908152602001610483565b6104bf61054c36600461493b565b611011565b600854610530565b6104f2610567366004614a14565b61101c565b6104f261057a366004614a48565b6110ba565b61049f61058d3660046149bc565b6001600160a01b03918216600090815260106020908152604080832093835292905220541690565b6104f26105c3366004614a7d565b6110d0565b6104776105d6366004614aa9565b611101565b6105306105e9366004614af0565b611118565b6105306105fc366004614b24565b6001600160a01b03166000908152600c602052604090205490565b6105306106253660046149bc565b6111a9565b61049f610638366004614b24565b6001600160a01b039081166000908152601160205260409020541690565b610530610664366004614b51565b61123f565b6104f2610677366004614bde565b6113ce565b6104f261068a366004614a14565b6114b5565b6104f261069d366004614c29565b61153a565b6104f26106b0366004614a7d565b6115b6565b6104f26106c336600461493b565b6115d1565b6105306106d6366004614c45565b61166e565b6104f26106e9366004614bde565b6116cf565b6107016106fc366004614c89565b611736565b604051610483929190614cef565b61053061071d36600461493b565b61178e565b6104f26107303660046149e6565b611821565b6104f2610743366004614a14565b61189a565b6104f2610756366004614d14565b611908565b61049f61076936600461493b565b611995565b61078161077c36600461493b565b611a0c565b6040516104839190614d66565b61053061079c366004614b24565b611a26565b6104f26107af366004614c89565b611aad565b6104f26107c2366004614d79565b611b27565b6105306107d5366004614b24565b6001600160a01b03166000908152601c602052604090205490565b6104f26107fe366004614c29565b611c2b565b61047761081136600461493b565b611cd5565b61053061082436600461493b565b611d03565b610530610837366004614dc0565b611d6f565b6104f261084a3660046149e6565b611dea565b61053061085d366004614e04565b60009182526019602090815260408084206001600160a01b0393909316845291905290205490565b6104bf611e8a565b6104f261089b366004614e04565b611e99565b6104f26108ae366004614a14565b611f2b565b6105306108c1366004614b51565b611f8c565b6108d96108d4366004614e27565b612077565b6040516104839190614e68565b6104f26108f4366004614ef4565b612226565b6104f2610907366004614bde565b612231565b61053061091a366004614a14565b612311565b61093261092d366004614f62565b6123b2565b6040516104839190614f97565b61053061094d366004614c45565b6124a6565b6104f26109603660046150e4565b6124cd565b6104f261097336600461515d565b612505565b6013546001600160a01b031661049f565b6104f2610997366004614c89565b6125b8565b6104bf6109aa36600461493b565b61262a565b6104f26109bd36600461515d565b6126cf565b6105306109d036600461515d565b61275e565b6104f26109e3366004614a14565b612773565b6105306109f6366004614c89565b6000918252600d6020908152604080842092845291905290205490565b6108d9610a2136600461493b565b6127fe565b610a39610a34366004614c89565b612985565b6040516104839190615191565b6104f2610a54366004615227565b612ae6565b6104bf610a6736600461493b565b612b77565b6104f2610a7a3660046152a9565b612be9565b610477610a8d36600461535a565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6104bf610ac936600461493b565b612d76565b610530612d96565b6104f2610ae436600461496c565b612da5565b6104f2610af736600461493b565b612e2f565b610530610b0a366004615384565b612e7e565b610530610b1d3660046149e6565b612fbf565b61049f610b3036600461493b565b6000908152600f60205260409020546001600160a01b031690565b60006001600160e01b0319821663780e9d6360e01b1480610b705750610b70826130da565b92915050565b606060008054610b85906153df565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb1906153df565b8015610bfe5780601f10610bd357610100808354040283529160200191610bfe565b820191906000526020600020905b815481529060010190602001808311610be157829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610c865760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b610caf6020820182614b24565b6001600160a01b0316336001600160a01b031614610ce05760405163ca67421960e01b815260040160405180910390fd5b73deb3767f23898e22aa6ab6c220c383537fc9356363dfc34f25610d076020840184614b24565b610d176040850160208601614b24565b610d246040860186615413565b60116040518663ffffffff1660e01b8152600401610d46959493929190615482565b60006040518083038186803b158015610d5e57600080fd5b505af4158015610d72573d6000803e3d6000fd5b5050505050565b6000610d8482611995565b9050806001600160a01b0316836001600160a01b031603610df15760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610c7d565b336001600160a01b0382161480610e0d5750610e0d8133610a8d565b610e7f5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610c7d565b610e89838361312a565b505050565b6013546040516367880d6160e11b8152823560048201526000916001600160a01b03169063cf101ac290602401602060405180830381865afa158015610ed8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efc91906154c1565b9050610f098160c1613198565b73deb3767f23898e22aa6ab6c220c383537fc93563636252159e8335610f356040860160208701614b24565b610f426040870187615413565b600f6040518663ffffffff1660e01b8152600401610f649594939291906154da565b60006040518083038186803b158015610f7c57600080fd5b505af4158015610f90573d6000803e3d6000fd5b505050505050565b610fa4813560b2613198565b60135481356000818152600d6020908152604080832081870135808552908352928190205490516337fb824760e11b815273b9d16c633044a1ae5d0914e13c8475705b3dffb195636ff7048e95610d469590948901359390926001600160a01b0390921691600401615505565b6060610b708261262a565b611028813560b2613198565b6110358160200135613229565b73b9d16c633044a1ae5d0914e13c8475705b3dffb1639ec52a238235602084013560408501356110686060870187615413565b6013546020808a01356000908152600a9091526040908190206005015490516001600160e01b031960e08a901b168152610d469796959493926001600160a01b03908116921690600d90600401615531565b6110c5836002613198565b610e89838383613264565b6110da33826132c0565b6110f65760405162461bcd60e51b8152600401610c7d9061557e565b610e898383836133b7565b600061110e848484613564565b90505b9392505050565b6000611126823560ec613198565b61113082356135ee565b6040516342a34a5360e01b81529091507379eedea3f2deea92bd9774a13e5b16b0c2589d46906342a34a539061117490859085906000908190600e906004016156d6565b60006040518083038186803b15801561118c57600080fd5b505af41580156111a0573d6000803e3d6000fd5b50505050919050565b60006111b483611a26565b82106112165760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610c7d565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600061124d833560ca613198565b6545524337323160d01b600061126385356135ee565b6013549091506000906001600160a01b0316632ea24efc826112886020890189614b24565b6040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152602088013560448201526064016020604051808303816000875af11580156112de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130291906154c1565b90507379eedea3f2deea92bd9774a13e5b16b0c2589d466342a34a538784868561132f60208c018c614b24565b8b6020013560405160200161136292919060609290921b6bffffffffffffffffffffffff19168252601482015260340190565b604051602081830303815290604052600e6040518763ffffffff1660e01b81526004016113949695949392919061571b565b60006040518083038186803b1580156113ac57600080fd5b505af41580156113c0573d6000803e3d6000fd5b509398975050505050505050565b6013546040516367880d6160e11b8152600481018590526000916001600160a01b03169063cf101ac290602401602060405180830381865afa158015611418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143c91906154c1565b90506114498160b1613198565b601354604051633c17845760e11b81526001600160a01b039091169063782f08ae9061147d90879087908790600401615766565b600060405180830381600087803b15801561149757600080fd5b505af11580156114ab573d6000803e3d6000fd5b5050505050505050565b6114c1813560b9613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb163a4159c6b82356114ed6040850160208601614b24565b6013546040805160e086901b6001600160e01b031916815260048101949094526001600160a01b0392831660248501528601356044840152166064820152600d608482015260a401610d46565b611546813560b6613198565b60135460408051631d4deabf60e01b81528335600482015260208401356024820152908301356044820152606083013560648201526001600160a01b039091166084820152600d60a482015273b9d16c633044a1ae5d0914e13c8475705b3dffb190631d4deabf9060c401610d46565b610e89838383604051806020016040528060008152506124cd565b6000818152600a602052604080822090516115ef9160010190615780565b60408051918290039091206000818152600b6020908152838220829055858252600a90529182208281559092509061162a600183018261480a565b61163860028301600061480a565b50600060038201556004810180546001600160a01b031990811690915560059091018054909116905561166a82613617565b5050565b600061167c833560c8613198565b67131a5b9adb1a5cdd60c21b600061169485356135ee565b905060008460001b90507379eedea3f2deea92bd9774a13e5b16b0c2589d466342a34a53878486858a60405160200161136291815260200190565b6116da8360b0613198565b6000838152600a602052604090206002016116f682848361583c565b50827f17d7c9f69270ba135480ef16837f38b9d37d3ab291cbd3ba03982290c663199783836040516117299291906158fb565b60405180910390a2505050565b6000828152601a602090815260408083208484529091529020606090819061175d90613676565b6000858152601a60209081526040808320878452909152902090925061178590600201613676565b90509250929050565b600061179960085490565b82106117fc5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610c7d565b6008828154811061180f5761180f61590f565b90600052602060002001549050919050565b61182d813560be613198565b60135481356000818152600d602090815260408083208187013580855290835292819020549051633fe4fe3960e11b815273b9d16c633044a1ae5d0914e13c8475705b3dffb195637fc9fc7295610d469590948901359390926001600160a01b0390921691600401615505565b6118a6813560bb613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb16348391dcb82356118cf6020850185615413565b601354604080516001600160e01b031960e088901b168152610d469594939291890135916001600160a01b031690600d90600401615925565b6119128484613683565b61191c84846136e8565b611926848461375f565b6040516001626802bf60e01b031981527379eedea3f2deea92bd9774a13e5b16b0c2589d469063ff97fd4190611969908790879087908790600e90600401615966565b60006040518083038186803b15801561198157600080fd5b505af41580156114ab573d6000803e3d6000fd5b6000818152600260205260408120546001600160a01b031680610b705760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610c7d565b6000818152601860205260409020606090610b7090613676565b60006001600160a01b038216611a915760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610c7d565b506001600160a01b031660009081526003602052604090205490565b611ab88260c4613198565b611ac282826136e8565b6000828152600e60209081526040808320848452825291829020600501805460ff60a81b1916600160a81b179055905182815283917f036469f3e73c83520cdefa197d7a9c854c2f8bc0164b82e9f2bd4aa7e150fd3091015b60405180910390a25050565b6000611b3285611995565b6001600160a01b038181166000908152601c6020908152604080832080546001810190915581517f53f5e122d65c239c5936ed0eb8ce8ea2c1e77831749ec178c59c5cd4a792fe04938101939093529082018a90529288166060808301919091526080820188905260a08201939093529185013560c083015291925060e001604051602081830303815290604052805190602001209050611c1f611c18611bd76137a4565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b838561381a565b50610d72858585613264565b611c37813560b8613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb163154246368235611c636040850160208601614b24565b60135485356000908152600d6020908152604080832060608a013580855292529182902054825160e088901b6001600160e01b031916815260048101969096526001600160a01b03948516602487015291880135604486015260648501529116608483015260a482015260c401610d46565b600080611ce183611995565b6001600160a01b03166000908152600c60205260409020549290921492915050565b60135460405162fba02760e01b8152600481018390526000916001600160a01b03169062fba02790602401602060405180830381865afa158015611d4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7091906154c1565b6000611d7d833560c7613198565b664164647265737360c81b6000611d9485356135ee565b6040516bffffffffffffffffffffffff19606087901b1660208201529091506001600160a01b038516907379eedea3f2deea92bd9774a13e5b16b0c2589d46906342a34a53908890859087908690603401611362565b611df6813560ba613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb16393c96a528235611e226040850160208601614b24565b60135485356000908152600d60209081526040808320818a013580855292529182902054915160e087901b6001600160e01b031916815260048101959095526001600160a01b039384166024860152604485015291166064830152608482015260a401610d46565b606060018054610b85906153df565b611ea4826001613198565b6000828152600a60205260409020600401546001600160a01b031615611edd5760405163fe6f50e560e01b815260040160405180910390fd5b6040516384b44a2f60e01b8152600481018390526001600160a01b0382166024820152600a60448201527311989a675d77f711188533113e5346ea70205b9d906384b44a2f90606401610f64565b611f37813560bd613198565b60135460408051632ca904df60e01b815273b9d16c633044a1ae5d0914e13c8475705b3dffb192632ca904df92610d4692863592602088013592880135916001600160a01b0390911690600d90600401615505565b6000611f9a833560c9613198565b634e6f746560e01b6000611fae85356135ee565b601354604051635cb46be760e01b815260006004820181905287356024830152602088013560448301529293506001600160a01b0390911690635cb46be7906064016020604051808303816000875af115801561200f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061203391906154c1565b90507379eedea3f2deea92bd9774a13e5b16b0c2589d466342a34a53878486858a600001358b60200135604051602001611362929190918252602082015260400190565b61207f614844565b60008383604051612091929190615986565b604080519182900382206000818152600b602090815283822054808352600a82529184902060c08601909452835485526001840180549396509194939290840191906120dc906153df565b80601f0160208091040260200160405190810160405280929190818152602001828054612108906153df565b80156121555780601f1061212a57610100808354040283529160200191612155565b820191906000526020600020905b81548152906001019060200180831161213857829003601f168201915b5050505050815260200160028201805461216e906153df565b80601f016020809104026020016040519081016040528092919081815260200182805461219a906153df565b80156121e75780601f106121bc576101008083540402835291602001916121e7565b820191906000526020600020905b8154815290600101906020018083116121ca57829003601f168201915b50505091835250506003820154602082015260048201546001600160a01b03908116604083015260059092015490911660609091015295945050505050565b61166a3383836138f7565b61223c836000613198565b61225c828260405161224f929190615986565b60405180910390206139c5565b61229b82828080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506139f292505050565b60405163130f361d60e01b81527311989a675d77f711188533113e5346ea70205b9d9063130f361d906122dc90869086908690600b90600a90600401615996565b60006040518083038186803b1580156122f457600080fd5b505af4158015612308573d6000803e3d6000fd5b50505050505050565b6000612322823560208401356136e8565b7379eedea3f2deea92bd9774a13e5b16b0c2589d46639d2e06f0833560208501356123536060870160408801614b24565b6123606060880188615413565b6014546040516001600160e01b031960e089901b1681526123959695949392916001600160a01b031690600e906004016159c4565b602060405180830381865af4158015611d4b573d6000803e3d6000fd5b6060816001600160401b038111156123cc576123cc614ff9565b6040519080825280602002602001820160405280156123ff57816020015b60608152602001906001900390816123ea5790505b50905060005b8281101561249f5761246f308585848181106124235761242361590f565b90506020028101906124359190615413565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613a5f92505050565b8282815181106124815761248161590f565b6020026020010181905250808061249790615a1e565b915050612405565b5092915050565b60006124b4833560c6613198565b6821b430b930b1ba32b960b91b600061169485356135ee565b6124d733836132c0565b6124f35760405162461bcd60e51b8152600401610c7d9061557e565b6124ff84848484613a84565b50505050565b612511813560b5613198565b612523816020013582604001356136e8565b73b9d16c633044a1ae5d0914e13c8475705b3dffb16371bd9b06823560208401356040850135606086013561255b6080880188615413565b6013546020808b01356000908152600e82526040808220818e013583529092528190206003015490516001600160e01b031960e08b901b168152610d46989796959493926001600160a01b03908116921690600d90600401615a37565b6125c38260c5613198565b6125cd82826136e8565b6000828152600e60209081526040808320848452825291829020600501805460ff60a01b1916600160a01b179055905182815283917f4f1db9708b537c1d26a7af4b235fd079bf2342d92a276e27eb6c8717e8bbcf939101611b1b565b6000818152600a6020526040902060020180546060919061264a906153df565b80601f0160208091040260200160405190810160405280929190818152602001828054612676906153df565b80156126c35780601f10612698576101008083540402835291602001916126c3565b820191906000526020600020905b8154815290600101906020018083116126a657829003601f168201915b50505050509050919050565b6126db813560b7613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb163f35deae182356127076040850160208601614b24565b6013546040805160e086901b6001600160e01b031916815260048101949094526001600160a01b039283166024850152860135604484015260608601356064840152166084820152600d60a482015260c401610d46565b6000610b7061276c83615a8d565b6001613ab7565b61277f813560c2613198565b61278e813560208301356136e8565b61279d8135602083013561375f565b73deb3767f23898e22aa6ab6c220c383537fc935636320828a02823560208401356127ce6060860160408701614b24565b6127db6060870187615413565b600e6040518763ffffffff1660e01b8152600401610d4696959493929190615b40565b612806614844565b600a60008381526020019081526020016000206040518060c00160405290816000820154815260200160018201805461283e906153df565b80601f016020809104026020016040519081016040528092919081815260200182805461286a906153df565b80156128b75780601f1061288c576101008083540402835291602001916128b7565b820191906000526020600020905b81548152906001019060200180831161289a57829003601f168201915b505050505081526020016002820180546128d0906153df565b80601f01602080910402602001604051908101604052809291908181526020018280546128fc906153df565b80156129495780601f1061291e57610100808354040283529160200191612949565b820191906000526020600020905b81548152906001019060200180831161292c57829003601f168201915b50505091835250506003820154602082015260048201546001600160a01b03908116604083015260059092015490911660609091015292915050565b60408051610100808201835260008083526020808401829052606084860181905284018290526080840182905260a0840182905260c0840182905260e08401829052868252600e81528482208683528152908490208451928301855280548352600181015491830191909152600281018054939492939192840191612a09906153df565b80601f0160208091040260200160405190810160405280929190818152602001828054612a35906153df565b8015612a825780601f10612a5757610100808354040283529160200191612a82565b820191906000526020600020905b815481529060010190602001808311612a6557829003601f168201915b505050918352505060038201546001600160a01b039081166020830152600483015481166040830152600590920154918216606082015260ff600160a01b8304811615156080830152600160a81b909204909116151560a090910152905092915050565b612af1866003613198565b612afb86866136e8565b604051630afb883f60e41b8152738f479bc8d4a325cf75631b123f760b7ba07415e79063afb883f090612b3f90899089908990899089908990601a90600401615bbd565b60006040518083038186803b158015612b5757600080fd5b505af4158015612b6b573d6000803e3d6000fd5b50505050505050505050565b601354604051632b05429560e21b8152600481018390526060916001600160a01b03169063ac150a5490602401600060405180830381865afa158015612bc1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b709190810190615c05565b601454600390600160a81b900460ff16158015612c14575060145460ff808316600160a01b90920416105b612c775760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c7d565b6014805460ff60a81b1960ff8416600160a01b021661ffff60a01b1990911617600160a81b179055612cab89898989613b94565b601380546001600160a01b03199081166001600160a01b0388811691909117909255601480548216878416179055601580548216868416179055601b80549091169184169190911790556040514281527f400175a56dd3710794078f7b9dbe8296ac94c5a248dfd51bb22ed4ab9eaa9fbf9060200160405180910390a16014805460ff60a81b1916905560405160ff821681527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050505050505050565b6000818152600a6020526040902060010180546060919061264a906153df565b6000612da06137a4565b905090565b612db1813560bc613198565b73b9d16c633044a1ae5d0914e13c8475705b3dffb1631873e2188235612dda6020850185615413565b60135486356000908152600d60209081526040808320818b01358085529252918290205491516001600160e01b031960e089901b168152610d469695949391926001600160a01b039092169190600401615925565b612e3881613be5565b336000818152600c602052604080822080549085905590519092839285927fce95332e6082aebeb8058a7b56d1a109f67d6550552ed04d36aca4a6acd4d7de9190a45050565b6000612e8c843560cb613198565b65416e7955726960d01b6000612ea286356135ee565b601354604051633610bf0960e11b81529192506000916001600160a01b0390911690636c217e1290612edc9084908a908a90600401615766565b6020604051808303816000875af1158015612efb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f1f91906154c1565b90507379eedea3f2deea92bd9774a13e5b16b0c2589d466342a34a53888486858b8b604051602001612f52929190615986565b604051602081830303815290604052600e6040518763ffffffff1660e01b8152600401612f849695949392919061571b565b60006040518083038186803b158015612f9c57600080fd5b505af4158015612fb0573d6000803e3d6000fd5b50939998505050505050505050565b6000612fcd823560b4613198565b61305b6040518060a00160405280846020016020810190612fee9190614b24565b6001600160a01b031681526020016130178560200160208101906130129190614b24565b613c4b565b815260200160405180602001604052806000815250815260200160006001600160a01b03168152602001604051806020016040528060008152508152506000613ab7565b60135460408051639ec52a2360e01b8152853560048201526024810184905290850135604482015260e06064820152600060e482018190526001600160a01b03909216608482015260a4810191909152600d60c482015290915073b9d16c633044a1ae5d0914e13c8475705b3dffb190639ec52a239061010401611174565b60006001600160e01b031982166380ac58cd60e01b148061310b57506001600160e01b03198216635b5e139f60e01b145b80610b7057506301ffc9a760e01b6001600160e01b0319831614610b70565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061315f82611995565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6131a182613d54565b156131aa575050565b6015546001600160a01b031633036131e6576000828152601960209081526040808320328452909152902054600190821c8116036131e6575050565b6000828152601960209081526040808320338452909152902054600190821c811603613210575050565b604051632c4bc2b960e21b815260040160405180910390fd5b6000818152600260205260409020546001600160a01b0316613261576040516375af0fc960e11b815260048101829052602401610c7d565b50565b604051631f8c0b6760e11b8152600481018490526001600160a01b0383166024820152604481018290526018606482015260196084820152738f479bc8d4a325cf75631b123f760b7ba07415e790633f1816ce9060a4016122dc565b6000818152600260205260408120546001600160a01b03166133395760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610c7d565b600061334483611995565b9050806001600160a01b0316846001600160a01b0316148061337f5750836001600160a01b031661337484610c08565b6001600160a01b0316145b806133af57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166133ca82611995565b6001600160a01b03161461342e5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610c7d565b6001600160a01b0382166134905760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610c7d565b61349b838383613db4565b6134a660008261312a565b6001600160a01b03831660009081526003602052604081208054600192906134cf908490615c72565b90915550506001600160a01b03821660009081526003602052604081208054600192906134fd908490615c85565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4610e89838383613e86565b6000838152601a6020908152604080832085845290915281206135878184613ec3565b15613596576000915050611111565b6135a36002820184613ec3565b156135b2576001915050611111565b60008581526019602090815260408083206001600160a01b03871684529091529020546135e59060c31c60019081161490565b95945050505050565b6000818152600a602052604081206003018054829061360c90615a1e565b918290555092915050565b61362133826132c0565b61366d5760405162461bcd60e51b815260206004820152601b60248201527f4e4654426173653a204e6f744f776e65724f72417070726f76656400000000006044820152606401610c7d565b61326181613ee5565b6060600061111183613f94565b61368c82613d54565b15613695575050565b6015546001600160a01b031633036136bb576136b2828232613564565b156136bb575050565b6136c6828233613564565b156136cf575050565b604051631a1d1d4760e11b815260040160405180910390fd5b6000828152600e60209081526040808320848452909152902060050154600160a01b900460ff161561372d57604051631f0fc8f560e11b815260040160405180910390fd5b6000828152600a602052604090206003015481111561166a576040516364783acb60e01b815260040160405180910390fd5b6000828152600e60209081526040808320848452909152902060050154600160a81b900460ff161561166a57604051630bc06a0f60e21b815260040160405180910390fd5b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6137cf610b76565b8051602091820120604080519283019390935291810191909152600160608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b428160600135101561383e576040516275e96160e01b815260040160405180910390fd5b60006001846138506020850185615c98565b604080516000815260208181018084529490945260ff9092168282015291850135606082015290840135608082015260a0016020604051602081039080840390855afa1580156138a4573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806138d95750826001600160a01b0316816001600160a01b031614155b156124ff57604051636a9ca51760e01b815260040160405180910390fd5b816001600160a01b0316836001600160a01b0316036139585760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610c7d565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6000818152600b60205260409020541561326157604051631b659b9f60e21b815260040160405180910390fd5b80518190601f811180613a055750600381105b15613a2357604051636f819c2160e11b815260040160405180910390fd5b60005b818110156124ff57613a57838281518110613a4357613a4361590f565b01602001516001600160f81b031916613fef565b600101613a26565b60606111118383604051806060016040528060278152602001615e416027913961409d565b613a8f8484846133b7565b613a9b84848484614115565b6124ff5760405162461bcd60e51b8152600401610c7d90615cbb565b6000613acd8360200151805190602001206139c5565b8115613ae057613ae083602001516139f2565b601260008154613aef90615a1e565b91829055508351909150613b039082614216565b7311989a675d77f711188533113e5346ea70205b9d634daae5688460000151856020015186604001518760600151886080015187600b600a6040518963ffffffff1660e01b8152600401613b5e989796959493929190615d0d565b60006040518083038186803b158015613b7657600080fd5b505af4158015613b8a573d6000803e3d6000fd5b5050505092915050565b613ba084848484614230565b7f414cd0b34676984f09a5f76ce9718d4062e50283abe0e7e274a9a5b4e0c99c308484848442604051613bd7959493929190615d84565b60405180910390a150505050565b6000613bf082611995565b6015549091506001600160a01b031633148015613c155750326001600160a01b038216145b15613c1e575050565b6001600160a01b0381163303613c32575050565b604051631b0c476f60e11b815260040160405180910390fd5b60408051602a80825260608281019093526f181899199a1a9b1b9c1cb0b131b232b360811b916001600160a01b0385169160009190602082018180368337019050509050600360fc1b81600081518110613ca757613ca761590f565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613cd657613cd661590f565b60200101906001600160f81b031916908160001a90535060295b6001811115613d4b578383600f1660108110613d0e57613d0e61590f565b1a60f81b828281518110613d2457613d2461590f565b60200101906001600160f81b031916908160001a90535060049290921c9160001901613cf0565b50949350505050565b600080613d6083611995565b90506001600160a01b0381163303613d7b5750600192915050565b6015546001600160a01b031633148015613d9d5750326001600160a01b038216145b15613dab5750600192915050565b50600092915050565b601b546001600160a01b03848116911614613e7b576000818152601860205260408120613de09061424b565b600083815260186020526040812091925090613dfb90613676565b905060005b82811015613e3d57613e2b84838381518110613e1e57613e1e61590f565b6020026020010151614255565b80613e3581615a1e565b915050613e00565b506001600160a01b0385166000908152600c6020526040902054839003613e78576001600160a01b0385166000908152600c60205260408120555b50505b610e8983838361428e565b6001600160a01b0382166000908152600c60205260408120549003610e89576001600160a01b03919091166000908152600c602052604090205550565b6001600160a01b03811660009081526001830160205260408120541515611111565b6000613ef082611995565b9050613efe81600084613db4565b613f0960008361312a565b6001600160a01b0381166000908152600360205260408120805460019290613f32908490615c72565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a461166a81600084613e86565b6060816000018054806020026020016040519081016040528092919081815260200182805480156126c357602002820191906000526020600020905b815481526020019060010190808311613fd05750505050509050919050565b600360fc1b6001600160f81b0319821610806140185750603d60f91b6001600160f81b03198216115b806140485750603960f81b6001600160f81b031982161180156140485750606160f81b6001600160f81b03198216105b80156140625750602d60f81b6001600160f81b0319821614155b801561407c5750605f60f81b6001600160f81b0319821614155b15613261576040516001621693dd60e01b0319815260040160405180910390fd5b6060600080856001600160a01b0316856040516140ba9190615dbe565b600060405180830381855af49150503d80600081146140f5576040519150601f19603f3d011682016040523d82523d6000602084013e6140fa565b606091505b509150915061410b86838387614346565b9695505050505050565b60006001600160a01b0384163b1561420b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290614159903390899088908890600401615dda565b6020604051808303816000875af1925050508015614194575060408051601f3d908101601f1916820190925261419191810190615e0d565b60015b6141f1573d8080156141c2576040519150601f19603f3d011682016040523d82523d6000602084013e6141c7565b606091505b5080516000036141e95760405162461bcd60e51b8152600401610c7d90615cbb565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506133af565b506001949350505050565b61166a8282604051806020016040528060008152506143bf565b600061423d84868361583c565b506001610d7282848361583c565b6000610b70825490565b60008281526019602090815260408083206001600160a01b0385168452825280832083905584835260189091529020610e8990826143f2565b6001600160a01b0383166142e9576142e481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61430c565b816001600160a01b0316836001600160a01b03161461430c5761430c8382614407565b6001600160a01b03821661432357610e89816144a4565b826001600160a01b0316826001600160a01b031614610e8957610e898282614553565b606083156143b55782516000036143ae576001600160a01b0385163b6143ae5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c7d565b50816133af565b6133af8383614597565b6143c983836145c1565b6143d66000848484614115565b610e895760405162461bcd60e51b8152600401610c7d90615cbb565b6000611111836001600160a01b038416614717565b6000600161441484611a26565b61441e9190615c72565b600083815260076020526040902054909150808214614471576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906144b690600190615c72565b600083815260096020526040812054600880549394509092849081106144de576144de61590f565b9060005260206000200154905080600883815481106144ff576144ff61590f565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061453757614537615e2a565b6001900381819060005260206000200160009055905550505050565b600061455e83611a26565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b8151156145a75781518083602001fd5b8060405162461bcd60e51b8152600401610c7d9190614928565b6001600160a01b0382166146175760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c7d565b6000818152600260205260409020546001600160a01b03161561467c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c7d565b61468860008383613db4565b6001600160a01b03821660009081526003602052604081208054600192906146b1908490615c85565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a461166a60008383613e86565b6000818152600183016020526040812054801561480057600061473b600183615c72565b855490915060009061474f90600190615c72565b90508181146147b457600086600001828154811061476f5761476f61590f565b90600052602060002001549050808760000184815481106147925761479261590f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806147c5576147c5615e2a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610b70565b6000915050610b70565b508054614816906153df565b6000825580601f10614826575050565b601f016020900490600052602060002090810190613261919061488c565b6040518060c001604052806000815260200160608152602001606081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b5b808211156148a1576000815560010161488d565b5090565b6001600160e01b03198116811461326157600080fd5b6000602082840312156148cd57600080fd5b8135611111816148a5565b60005b838110156148f35781810151838201526020016148db565b50506000910152565b600081518084526149148160208601602086016148d8565b601f01601f19169290920160200192915050565b60208152600061111160208301846148fc565b60006020828403121561494d57600080fd5b5035919050565b60006060828403121561496657600080fd5b50919050565b60006020828403121561497e57600080fd5b81356001600160401b0381111561499457600080fd5b6133af84828501614954565b80356001600160a01b03811681146149b757600080fd5b919050565b600080604083850312156149cf57600080fd5b6149d8836149a0565b946020939093013593505050565b6000606082840312156149f857600080fd5b6111118383614954565b60006080828403121561496657600080fd5b600060208284031215614a2657600080fd5b81356001600160401b03811115614a3c57600080fd5b6133af84828501614a02565b600080600060608486031215614a5d57600080fd5b83359250614a6d602085016149a0565b9150604084013590509250925092565b600080600060608486031215614a9257600080fd5b614a9b846149a0565b9250614a6d602085016149a0565b600080600060608486031215614abe57600080fd5b8335925060208401359150614ad5604085016149a0565b90509250925092565b600060e0828403121561496657600080fd5b600060208284031215614b0257600080fd5b81356001600160401b03811115614b1857600080fd5b6133af84828501614ade565b600060208284031215614b3657600080fd5b611111826149a0565b60006040828403121561496657600080fd5b60008060608385031215614b6457600080fd5b82356001600160401b03811115614b7a57600080fd5b614b8685828601614ade565b9250506117858460208501614b3f565b60008083601f840112614ba857600080fd5b5081356001600160401b03811115614bbf57600080fd5b602083019150836020828501011115614bd757600080fd5b9250929050565b600080600060408486031215614bf357600080fd5b8335925060208401356001600160401b03811115614c1057600080fd5b614c1c86828701614b96565b9497909650939450505050565b600060808284031215614c3b57600080fd5b6111118383614a02565b60008060408385031215614c5857600080fd5b82356001600160401b03811115614c6e57600080fd5b614c7a85828601614ade565b95602094909401359450505050565b60008060408385031215614c9c57600080fd5b50508035926020909101359150565b600081518084526020808501945080840160005b83811015614ce45781516001600160a01b031687529582019590820190600101614cbf565b509495945050505050565b604081526000614d026040830185614cab565b82810360208401526135e58185614cab565b60008060008060608587031215614d2a57600080fd5b843593506020850135925060408501356001600160401b03811115614d4e57600080fd5b614d5a87828801614b96565b95989497509550505050565b6020815260006111116020830184614cab565b60008060008060e08587031215614d8f57600080fd5b84359350614d9f602086016149a0565b925060408501359150614db58660608701614a02565b905092959194509250565b60008060408385031215614dd357600080fd5b82356001600160401b03811115614de957600080fd5b614df585828601614ade565b925050611785602084016149a0565b60008060408385031215614e1757600080fd5b82359150611785602084016149a0565b60008060208385031215614e3a57600080fd5b82356001600160401b03811115614e5057600080fd5b614e5c85828601614b96565b90969095509350505050565b60208152815160208201526000602083015160c06040840152614e8e60e08401826148fc565b90506040840151601f19848303016060850152614eab82826148fc565b91505060608401516080840152608084015160018060a01b0380821660a08601528060a08701511660c086015250508091505092915050565b803580151581146149b757600080fd5b60008060408385031215614f0757600080fd5b614f10836149a0565b915061178560208401614ee4565b60008083601f840112614f3057600080fd5b5081356001600160401b03811115614f4757600080fd5b6020830191508360208260051b8501011115614bd757600080fd5b60008060208385031215614f7557600080fd5b82356001600160401b03811115614f8b57600080fd5b614e5c85828601614f1e565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614fec57603f19888603018452614fda8583516148fc565b94509285019290850190600101614fbe565b5092979650505050505050565b634e487b7160e01b600052604160045260246000fd5b60405160a081016001600160401b038111828210171561503157615031614ff9565b60405290565b604051601f8201601f191681016001600160401b038111828210171561505f5761505f614ff9565b604052919050565b60006001600160401b0382111561508057615080614ff9565b50601f01601f191660200190565b600082601f83011261509f57600080fd5b81356150b26150ad82615067565b615037565b8181528460208386010111156150c757600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080608085870312156150fa57600080fd5b615103856149a0565b9350615111602086016149a0565b92506040850135915060608501356001600160401b0381111561513357600080fd5b61513f8782880161508e565b91505092959194509250565b600060a0828403121561496657600080fd5b60006020828403121561516f57600080fd5b81356001600160401b0381111561518557600080fd5b6133af8482850161514b565b602081528151602082015260208201516040820152600060408301516101008060608501526151c46101208501836148fc565b9150606085015160018060a01b0380821660808701528060808801511660a0870152505060a085015161520260c08601826001600160a01b03169052565b5060c085015180151560e08601525060e0850151801515858301525090949350505050565b6000806000806000806080878903121561524057600080fd5b863595506020870135945060408701356001600160401b038082111561526557600080fd5b6152718a838b01614f1e565b9096509450606089013591508082111561528a57600080fd5b5061529789828a01614f1e565b979a9699509497509295939492505050565b60008060008060008060008060c0898b0312156152c557600080fd5b88356001600160401b03808211156152dc57600080fd5b6152e88c838d01614b96565b909a50985060208b013591508082111561530157600080fd5b5061530e8b828c01614b96565b9097509550615321905060408a016149a0565b935061532f60608a016149a0565b925061533d60808a016149a0565b915061534b60a08a016149a0565b90509295985092959890939650565b6000806040838503121561536d57600080fd5b615376836149a0565b9150611785602084016149a0565b60008060006040848603121561539957600080fd5b83356001600160401b03808211156153b057600080fd5b6153bc87838801614ade565b945060208601359150808211156153d257600080fd5b50614c1c86828701614b96565b600181811c908216806153f357607f821691505b60208210810361496657634e487b7160e01b600052602260045260246000fd5b6000808335601e1984360301811261542a57600080fd5b8301803591506001600160401b0382111561544457600080fd5b602001915036819003821315614bd757600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b038681168252851660208201526080604082018190526000906154af9083018587615459565b90508260608301529695505050505050565b6000602082840312156154d357600080fd5b5051919050565b8581526001600160a01b03851660208201526080604082018190526000906154af9083018587615459565b948552602085019390935260408401919091526001600160a01b03166060830152608082015260a00190565b88815287602082015286604082015260e06060820152600061555760e083018789615459565b6001600160a01b0395861660808401529390941660a082015260c001529695505050505050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000808335601e198436030181126155e657600080fd5b83016020810192503590506001600160401b0381111561560557600080fd5b803603821315614bd757600080fd5b80358252600061562760208301836155cf565b60e0602086015261563c60e086018284615459565b91505061564b604084016149a0565b6001600160a01b03818116604087015261566860608601866155cf565b9250868403606088015261567d848483615459565b9350508061568d608087016149a0565b16608087015250506156a260a08401846155cf565b85830360a08701526156b5838284615459565b925050506156c560c08401614ee4565b151560c08501528091505092915050565b60c0815260006156e960c0830188615614565b602083810197909752604083019590955250606081019290925281830360808301526000835260a09091015201919050565b60c08152600061572e60c0830189615614565b876020840152866040840152856060840152828103608084015261575281866148fc565b9150508260a0830152979650505050505050565b8381526040602082015260006135e5604083018486615459565b600080835461578e816153df565b600182811680156157a657600181146157bb576157ea565b60ff19841687528215158302870194506157ea565b8760005260208060002060005b858110156157e15781548a8201529084019082016157c8565b50505082870194505b50929695505050505050565b601f821115610e8957600081815260208120601f850160051c8101602086101561581d5750805b601f850160051c820191505b81811015610f9057828155600101615829565b6001600160401b0383111561585357615853614ff9565b6158678361586183546153df565b836157f6565b6000601f84116001811461589b57600085156158835750838201355b600019600387901b1c1916600186901b178355610d72565b600083815260209020601f19861690835b828110156158cc57868501358255602094850194600190920191016158ac565b50868210156158e95760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152600061110e602083018486615459565b634e487b7160e01b600052603260045260246000fd5b86815260a06020820152600061593f60a083018789615459565b6040830195909552506001600160a01b039290921660608301526080909101529392505050565b8581528460208201526080604082015260006154af608083018587615459565b8183823760009101908152919050565b8581526080602082015260006159b0608083018688615459565b604083019490945250606001529392505050565b878152866020820152600060018060a01b03808816604084015260c060608401526159f360c084018789615459565b941660808301525060a0015295945050505050565b634e487b7160e01b600052601160045260246000fd5b600060018201615a3057615a30615a08565b5060010190565b60006101008b83528a6020840152896040840152886060840152806080840152615a64818401888a615459565b6001600160a01b0396871660a08501529490951660c08301525060e00152979650505050505050565b600060a08236031215615a9f57600080fd5b615aa761500f565b615ab0836149a0565b815260208301356001600160401b0380821115615acc57600080fd5b615ad83683870161508e565b60208401526040850135915080821115615af157600080fd5b615afd3683870161508e565b6040840152615b0e606086016149a0565b60608401526080850135915080821115615b2757600080fd5b50615b343682860161508e565b60808301525092915050565b86815285602082015260018060a01b038516604082015260a060608201526000615b6e60a083018587615459565b9050826080830152979650505050505050565b8183526000602080850194508260005b85811015614ce4576001600160a01b03615baa836149a0565b1687529582019590820190600101615b91565b87815286602082015260a060408201526000615bdd60a083018789615b81565b8281036060840152615bf0818688615b81565b91505082608083015298975050505050505050565b600060208284031215615c1757600080fd5b81516001600160401b03811115615c2d57600080fd5b8201601f81018413615c3e57600080fd5b8051615c4c6150ad82615067565b818152856020838501011115615c6157600080fd5b6135e58260208301602086016148d8565b81810381811115610b7057610b70615a08565b80820180821115610b7057610b70615a08565b600060208284031215615caa57600080fd5b813560ff8116811461111157600080fd5b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03898116825261010060208301819052600091615d338483018c6148fc565b91508382036040850152615d47828b6148fc565b908916606085015283810360808501529050615d6381886148fc565b60a0840196909652505060c081019290925260e09091015295945050505050565b606081526000615d98606083018789615459565b8281036020840152615dab818688615459565b9150508260408301529695505050505050565b60008251615dd08184602087016148d8565b9190910192915050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061410b908301846148fc565b600060208284031215615e1f57600080fd5b8151611111816148a5565b634e487b7160e01b600052603160045260246000fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212205df83ad3c38eba328a1cda0c48931584f7878751c67a44876718e7520924d60264736f6c63430008100033