File size: 117,581 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
  "language": "Solidity",
  "sources": {
    "contracts/facets/OnDemandMint/OnDemandMintFacet.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {OnDemandMintLib} from \"./OnDemandMintLib.sol\";\nimport {AccessControlModifiers} from \"../AccessControl/AccessControlModifiers.sol\";\nimport {PausableModifiers} from \"../Pausable/PausableModifiers.sol\";\nimport {SaleStateModifiers} from \"../BaseNFTModifiers.sol\";\n\ncontract OnDemandMintFacet is\n    AccessControlModifiers,\n    PausableModifiers,\n    SaleStateModifiers\n{\n    function setMintSigner(address _signer) external onlyOwner whenNotPaused {\n        OnDemandMintLib.setMintSigner(_signer);\n    }\n\n    function getMintSigner() public view returns (address) {\n        return OnDemandMintLib.getMintSigner();\n    }\n\n    function onDemandMint(\n        string memory _tokenURI,\n        bytes memory approvalSignature\n    ) public payable whenNotPaused onlyAtSaleState(6) {\n        OnDemandMintLib.onDemandMint(_tokenURI, approvalSignature);\n    }\n\n    function mintNonceForAddress(address minter) public view returns (uint256) {\n        return OnDemandMintLib.onDemandMintStorage()._userNonces[minter];\n    }\n}\n"
    },
    "contracts/facets/OnDemandMint/OnDemandMintLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"../LazyMint/LazyMintLib.sol\";\nimport \"../URIStorage/URIStorageLib.sol\";\n\nerror CannotMintWithoutSigner();\n\nlibrary OnDemandMintLib {\n    bytes32 constant ON_DEMAND_MINT_STORAGE =\n        keccak256(\"on.demand.mint.storage\");\n\n    struct OnDemandMintStorage {\n        address _mintSigner;\n        mapping(address => uint256) _userNonces;\n    }\n\n    function onDemandMintStorage()\n        internal\n        pure\n        returns (OnDemandMintStorage storage s)\n    {\n        bytes32 position = ON_DEMAND_MINT_STORAGE;\n        assembly {\n            s.slot := position\n        }\n    }\n\n    function getMintSigner() internal view returns (address) {\n        return onDemandMintStorage()._mintSigner;\n    }\n\n    function setMintSigner(address _nextMintSigner) internal {\n        onDemandMintStorage()._mintSigner = _nextMintSigner;\n    }\n\n    function _verifyApprovalSignature(\n        string memory tokenURI,\n        bytes memory approvalSignature\n    ) internal {\n        OnDemandMintStorage storage s = onDemandMintStorage();\n        if (s._mintSigner == address(0)) {\n            revert CannotMintWithoutSigner();\n        }\n\n        bytes memory signedBytes = abi.encode(\n            msg.sender,\n            address(this),\n            s._userNonces[msg.sender]++,\n            tokenURI\n        );\n        bytes32 ethHash = ECDSA.toEthSignedMessageHash(signedBytes);\n        address signer = ECDSA.recover(ethHash, approvalSignature);\n\n        require(signer == s._mintSigner, \"ON DEMAND MINT: invalid signature\");\n    }\n\n    function onDemandMint(\n        string memory _tokenURI,\n        bytes memory approvalSignature\n    ) internal {\n        _verifyApprovalSignature(_tokenURI, approvalSignature);\n        uint256 tokenId = LazyMintLib.publicMint(1);\n        URIStorageLib.setTokenURI(tokenId, _tokenURI);\n    }\n}\n"
    },
    "contracts/facets/AccessControl/AccessControlModifiers.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./AccessControlLib.sol\";\n\nabstract contract AccessControlModifiers {\n    modifier onlyOperator() {\n        AccessControlLib._checkRole(AccessControlLib.OPERATOR_ROLE, msg.sender);\n        _;\n    }\n\n    modifier onlyOwner() {\n        AccessControlLib._enforceOwner();\n        _;\n    }\n}\n"
    },
    "contracts/facets/Pausable/PausableModifiers.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./PausableLib.sol\";\n\nabstract contract PausableModifiers {\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        PausableLib.enforceUnpaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        PausableLib.enforcePaused();\n        _;\n    }\n}\n"
    },
    "contracts/facets/BaseNFTModifiers.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport {BaseNFTLib} from \"./BaseNFTLib.sol\";\n\n// sale states\n// 0 - closed\n// 1 - public sale\n// 2 - allow list sale\n\nerror IncorrectSaleState();\n\nabstract contract SaleStateModifiers {\n    modifier onlyAtSaleState(uint256 _gatedSaleState) {\n        if (_gatedSaleState != BaseNFTLib.saleState()) {\n            revert IncorrectSaleState();\n        }\n        _;\n    }\n\n    modifier onlyAtOneOfSaleStates(uint256[] calldata _gatedSaleStates) {\n        uint256 currState = BaseNFTLib.saleState();\n        for (uint256 i; i < _gatedSaleStates.length; i++) {\n            if (_gatedSaleStates[i] == currState) {\n                _;\n                return;\n            }\n        }\n\n        revert IncorrectSaleState();\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS,\n        InvalidSignatureV\n    }\n\n    function _throwError(RecoverError error) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert(\"ECDSA: invalid signature\");\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert(\"ECDSA: invalid signature length\");\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert(\"ECDSA: invalid signature 's' value\");\n        } else if (error == RecoverError.InvalidSignatureV) {\n            revert(\"ECDSA: invalid signature 'v' value\");\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature` or error string. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n        // Check the signature length\n        // - case 65: r,s,v signature (standard)\n        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            assembly {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else if (signature.length == 64) {\n            bytes32 r;\n            bytes32 vs;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            assembly {\n                r := mload(add(signature, 0x20))\n                vs := mload(add(signature, 0x40))\n            }\n            return tryRecover(hash, r, vs);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength);\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, signature);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address, RecoverError) {\n        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n        uint8 v = uint8((uint256(vs) >> 255) + 27);\n        return tryRecover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     *\n     * _Available since v4.2._\n     */\n    function recover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address, RecoverError) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS);\n        }\n        if (v != 27 && v != 28) {\n            return (address(0), RecoverError.InvalidSignatureV);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature);\n        }\n\n        return (signer, RecoverError.NoError);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from `s`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Typed Data, created from a\n     * `domainSeparator` and a `structHash`. This produces hash corresponding\n     * to the one signed with the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n     * JSON-RPC method as part of EIP-712.\n     *\n     * See {recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n    }\n}\n"
    },
    "contracts/facets/LazyMint/LazyMintLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {ERC721ALib} from \"../ERC721A/ERC721ALib.sol\";\nimport {BaseNFTLib} from \"../BaseNFTLib.sol\";\n\nerror InsufficientFunds();\nerror ExceededMaxMintsPerTxn();\nerror ExceededMaxMintsPerWallet();\nerror ReachedMaxMintableAtCurrentStage();\n\nlibrary LazyMintLib {\n    bytes32 constant LAZY_MINT_STORAGE_POSITION =\n        keccak256(\"lazy.mint.storage\");\n\n    struct LazyMintStorage {\n        uint256 publicMintPrice;\n        uint256 maxMintsPerTxn;\n        uint256 maxMintsPerWallet;\n        uint256 maxMintableAtCurrentStage;\n    }\n\n    function lazyMintStorage()\n        internal\n        pure\n        returns (LazyMintStorage storage s)\n    {\n        bytes32 position = LAZY_MINT_STORAGE_POSITION;\n        assembly {\n            s.slot := position\n        }\n    }\n\n    function setPublicMintPrice(uint256 _mintPrice) internal {\n        lazyMintStorage().publicMintPrice = _mintPrice;\n    }\n\n    function setMaxMintsPerTransaction(uint256 _numPerTransaction) internal {\n        lazyMintStorage().maxMintsPerTxn = _numPerTransaction;\n    }\n\n    function setMaxMintsPerWallet(uint256 _numPerWallet) internal {\n        lazyMintStorage().maxMintsPerWallet = _numPerWallet;\n    }\n\n    function publicMintPrice() internal view returns (uint256) {\n        return lazyMintStorage().publicMintPrice;\n    }\n\n    function setMaxMintableAtCurrentStage(uint256 _maxAtCurrentStage) internal {\n        lazyMintStorage().maxMintableAtCurrentStage = _maxAtCurrentStage;\n    }\n\n    function publicMint(uint256 quantity) internal returns (uint256) {\n        LazyMintStorage storage s = lazyMintStorage();\n        if (msg.value < quantity * publicMintPrice()) {\n            revert InsufficientFunds();\n        }\n\n        if (s.maxMintsPerTxn > 0 && quantity > s.maxMintsPerTxn) {\n            revert ExceededMaxMintsPerTxn();\n        }\n\n        if (\n            s.maxMintsPerWallet > 0 &&\n            (ERC721ALib._numberMinted(msg.sender) + quantity) >\n            s.maxMintsPerWallet\n        ) {\n            revert ExceededMaxMintsPerWallet();\n        }\n\n        if (\n            s.maxMintableAtCurrentStage > 0 &&\n            (ERC721ALib.totalMinted() + quantity) > s.maxMintableAtCurrentStage\n        ) {\n            revert ReachedMaxMintableAtCurrentStage();\n        }\n\n        return BaseNFTLib._safeMint(msg.sender, quantity);\n    }\n}\n"
    },
    "contracts/facets/URIStorage/URIStorageLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {DiamondCloneLib} from \"../DiamondClone/DiamondCloneLib.sol\";\nimport {Strings} from \"../ERC721A/ERC721ALib.sol\";\nimport {DiamondSaw} from \"../../DiamondSaw.sol\";\n\nerror MetaDataLocked();\n\nlibrary URIStorageLib {\n    using Strings for uint256;\n\n    struct URIStorage {\n        mapping(uint256 => string) _tokenURIs;\n        string folderStorageBaseURI;\n        string tokenStorageBaseURI;\n        bytes4 tokenURIOverrideSelector;\n        bool metadataLocked;\n    }\n\n    function uriStorage() internal pure returns (URIStorage storage s) {\n        bytes32 position = keccak256(\"uri.storage.facet.storage\");\n        assembly {\n            s.slot := position\n        }\n    }\n\n    function setFolderStorageBaseURI(string memory _baseURI) internal {\n        URIStorage storage s = uriStorage();\n        if (s.metadataLocked) revert MetaDataLocked();\n        s.folderStorageBaseURI = _baseURI;\n    }\n\n    function setTokenStorageBaseURI(string memory _baseURI) internal {\n        URIStorage storage s = uriStorage();\n        if (s.metadataLocked) revert MetaDataLocked();\n        s.tokenStorageBaseURI = _baseURI;\n    }\n\n    function tokenURIFromStorage(uint256 tokenId)\n        internal\n        view\n        returns (string storage)\n    {\n        return uriStorage()._tokenURIs[tokenId];\n    }\n\n    function setTokenURI(uint256 tokenId, string memory _tokenURI) internal {\n        URIStorage storage s = uriStorage();\n        if (s.metadataLocked) revert MetaDataLocked();\n        s._tokenURIs[tokenId] = _tokenURI;\n    }\n\n    function _burn(uint256 tokenId) internal {\n        URIStorage storage s = uriStorage();\n        if (bytes(s._tokenURIs[tokenId]).length != 0) {\n            delete s._tokenURIs[tokenId];\n        }\n    }\n\n    function setTokenURIOverrideSelector(bytes4 selector) internal {\n        URIStorage storage s = uriStorage();\n        if (s.metadataLocked) revert MetaDataLocked();\n\n        address sawAddress = DiamondCloneLib\n            .diamondCloneStorage()\n            .diamondSawAddress;\n        bool isApproved = DiamondSaw(sawAddress).isTokenURISelectorApproved(\n            selector\n        );\n        require(isApproved, \"selector not approved\");\n        s.tokenURIOverrideSelector = selector;\n    }\n\n    function removeTokenURIOverrideSelector() internal {\n        URIStorage storage s = uriStorage();\n        if (s.metadataLocked) revert MetaDataLocked();\n        s.tokenURIOverrideSelector = bytes4(0);\n    }\n\n    // Check for\n    // 1. tokenURIOverride (approved override function)\n    // 2. if individual token uri is set\n    // 3. folder storage\n    function tokenURI(uint256 tokenId) internal view returns (string memory) {\n        URIStorage storage s = uriStorage();\n\n        // the override is set, use that\n        if (s.tokenURIOverrideSelector != bytes4(0)) {\n            (bool success, bytes memory result) = address(this).staticcall(\n                abi.encodeWithSelector(s.tokenURIOverrideSelector, tokenId)\n            );\n            require(success, \"Token URI Override Failed\");\n\n            string memory uri = abi.decode(result, (string));\n            return uri;\n        }\n\n        // fall back on \"normal\" token storage\n        string storage individualTokenURI = tokenURIFromStorage(tokenId);\n        string storage folderStorageBaseURI = s.folderStorageBaseURI;\n        string storage tokenStorageBaseURI = s.tokenStorageBaseURI;\n\n        return\n            bytes(individualTokenURI).length != 0\n                ? string(\n                    abi.encodePacked(tokenStorageBaseURI, individualTokenURI)\n                )\n                : string(\n                    abi.encodePacked(folderStorageBaseURI, tokenId.toString())\n                );\n    }\n\n    function lockMetadata() internal {\n        uriStorage().metadataLocked = true;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Strings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n}\n"
    },
    "contracts/facets/ERC721A/ERC721ALib.sol": {
      "content": "// SPDX-License-Identifier: MIT\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport \"../../interfaces/IERC721Metadata.sol\";\nimport {TransferHooksLib} from \"../TransferHooks/TransferHooksLib.sol\";\n\npragma solidity ^0.8.4;\n\nerror ApprovalCallerNotOwnerNorApproved();\nerror ApprovalQueryForNonexistentToken();\nerror ApproveToCaller();\nerror ApprovalToCurrentOwner();\nerror BalanceQueryForZeroAddress();\nerror MintToZeroAddress();\nerror MintZeroQuantity();\nerror OwnerQueryForNonexistentToken();\nerror TransferCallerNotOwnerNorApproved();\nerror TransferFromIncorrectOwner();\nerror TransferToNonERC721ReceiverImplementer();\nerror TransferToZeroAddress();\nerror URIQueryForNonexistentToken();\n\nlibrary ERC721ALib {\n    using Address for address;\n    using Strings for uint256;\n\n    bytes32 constant ERC721A_STORAGE_POSITION =\n        keccak256(\"erc721a.facet.storage\");\n\n    event Transfer(\n        address indexed from,\n        address indexed to,\n        uint256 indexed tokenId\n    );\n\n    event Approval(\n        address indexed owner,\n        address indexed approved,\n        uint256 indexed tokenId\n    );\n\n    // Compiler will pack this into a single 256bit word.\n    struct TokenOwnership {\n        // The address of the owner.\n        address addr;\n        // Keeps track of the start time of ownership with minimal overhead for tokenomics.\n        uint64 startTimestamp;\n        // Whether the token has been burned.\n        bool burned;\n    }\n\n    // Compiler will pack this into a single 256bit word.\n    struct AddressData {\n        // Realistically, 2**64-1 is more than enough.\n        uint64 balance;\n        // Keeps track of mint count with minimal overhead for tokenomics.\n        uint64 numberMinted;\n        // Keeps track of burn count with minimal overhead for tokenomics.\n        uint64 numberBurned;\n        // For miscellaneous variable(s) pertaining to the address\n        // (e.g. number of whitelist mint slots used).\n        // If there are multiple variables, please pack them into a uint64.\n        uint64 aux; // NOTE - this is unused in Juice implementation\n    }\n\n    struct ERC721AStorage {\n        // The tokenId of the next token to be minted.\n        uint256 _currentIndex;\n        // The number of tokens burned.\n        uint256 _burnCounter;\n        // Token name\n        string _name;\n        // Token symbol\n        string _symbol;\n        // Mapping from token ID to ownership details\n        // An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details.\n        mapping(uint256 => TokenOwnership) _ownerships;\n        // Mapping owner address to address data\n        mapping(address => AddressData) _addressData;\n        // Mapping from token ID to approved address\n        mapping(uint256 => address) _tokenApprovals;\n        // Mapping from owner to operator approvals\n        mapping(address => mapping(address => bool)) _operatorApprovals;\n    }\n\n    function erc721AStorage()\n        internal\n        pure\n        returns (ERC721AStorage storage es)\n    {\n        bytes32 position = ERC721A_STORAGE_POSITION;\n        assembly {\n            es.slot := position\n        }\n    }\n\n    function _safeMint(address to, uint256 quantity) internal {\n        _safeMint(to, quantity, \"\");\n    }\n\n    /**\n     * @dev Safely mints `quantity` tokens and transfers them to `to`.\n     *\n     * Requirements:\n     *\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.\n     * - `quantity` must be greater than 0.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeMint(\n        address to,\n        uint256 quantity,\n        bytes memory _data\n    ) internal {\n        _mint(to, quantity, _data, true);\n    }\n\n    /**\n     * @dev Mints `quantity` tokens and transfers them to `to`.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - `quantity` must be greater than 0.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _mint(\n        address to,\n        uint256 quantity,\n        bytes memory _data,\n        bool safe\n    ) internal {\n        ERC721ALib.ERC721AStorage storage s = ERC721ALib.erc721AStorage();\n\n        uint256 startTokenId = s._currentIndex;\n        if (to == address(0)) revert MintToZeroAddress();\n        if (quantity == 0) revert MintZeroQuantity();\n\n        TransferHooksLib.beforeTokenTransfers(\n            address(0),\n            to,\n            startTokenId,\n            quantity\n        );\n\n        // Overflows are incredibly unrealistic.\n        // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1\n        // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1\n        unchecked {\n            s._addressData[to].balance += uint64(quantity);\n            s._addressData[to].numberMinted += uint64(quantity);\n\n            s._ownerships[startTokenId].addr = to;\n            s._ownerships[startTokenId].startTimestamp = uint64(\n                block.timestamp\n            );\n\n            uint256 updatedIndex = startTokenId;\n            uint256 end = updatedIndex + quantity;\n\n            if (safe && to.isContract()) {\n                do {\n                    emit Transfer(address(0), to, updatedIndex);\n                    if (\n                        !_checkContractOnERC721Received(\n                            address(0),\n                            to,\n                            updatedIndex++,\n                            _data\n                        )\n                    ) {\n                        revert TransferToNonERC721ReceiverImplementer();\n                    }\n                } while (updatedIndex != end);\n                // Reentrancy protection\n                if (s._currentIndex != startTokenId) revert();\n            } else {\n                do {\n                    emit Transfer(address(0), to, updatedIndex++);\n                } while (updatedIndex != end);\n            }\n            s._currentIndex = updatedIndex;\n        }\n        TransferHooksLib.afterTokenTransfers(\n            address(0),\n            to,\n            startTokenId,\n            quantity\n        );\n    }\n\n    /**\n     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target contract.\n     *\n     * @param from address representing the previous owner of the given token ID\n     * @param to target address that will receive the tokens\n     * @param tokenId uint256 ID of the token to be transferred\n     * @param _data bytes optional data to send along with the call\n     * @return bool whether the call correctly returned the expected magic value\n     */\n    function _checkContractOnERC721Received(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory _data\n    ) internal returns (bool) {\n        try\n            IERC721Receiver(to).onERC721Received(\n                msg.sender,\n                from,\n                tokenId,\n                _data\n            )\n        returns (bytes4 retval) {\n            return retval == IERC721Receiver(to).onERC721Received.selector;\n        } catch (bytes memory reason) {\n            if (reason.length == 0) {\n                revert TransferToNonERC721ReceiverImplementer();\n            } else {\n                assembly {\n                    revert(add(32, reason), mload(reason))\n                }\n            }\n        }\n    }\n\n    function _startTokenId() internal pure returns (uint256) {\n        return 1;\n    }\n\n    function currentIndex() internal view returns (uint256) {\n        return erc721AStorage()._currentIndex;\n    }\n\n    function totalMinted() internal view returns (uint256) {\n        // Counter underflow is impossible as _currentIndex does not decrement,\n        // and it is initialized to ERC721ALib._startTokenId()\n        unchecked {\n            return erc721AStorage()._currentIndex - _startTokenId();\n        }\n    }\n\n    function _exists(uint256 tokenId) internal view returns (bool) {\n        return\n            ERC721ALib._startTokenId() <= tokenId &&\n            tokenId < ERC721ALib.erc721AStorage()._currentIndex &&\n            !ERC721ALib.erc721AStorage()._ownerships[tokenId].burned;\n    }\n\n    /**\n     * Gas spent here starts off proportional to the maximum mint batch size.\n     * It gradually moves to O(1) as tokens get transferred around in the collection over time.\n     */\n    function _ownershipOf(uint256 tokenId)\n        internal\n        view\n        returns (ERC721ALib.TokenOwnership memory)\n    {\n        uint256 curr = tokenId;\n\n        ERC721ALib.ERC721AStorage storage s = ERC721ALib.erc721AStorage();\n        unchecked {\n            if (ERC721ALib._startTokenId() <= curr && curr < s._currentIndex) {\n                ERC721ALib.TokenOwnership memory ownership = s._ownerships[\n                    curr\n                ];\n                if (!ownership.burned) {\n                    if (ownership.addr != address(0)) {\n                        return ownership;\n                    }\n                    // Invariant:\n                    // There will always be an ownership that has an address and is not burned\n                    // before an ownership that does not have an address and is not burned.\n                    // Hence, curr will not underflow.\n                    while (true) {\n                        curr--;\n                        ownership = s._ownerships[curr];\n                        if (ownership.addr != address(0)) {\n                            return ownership;\n                        }\n                    }\n                }\n            }\n        }\n        revert OwnerQueryForNonexistentToken();\n    }\n\n    function balanceOf(address owner) internal view returns (uint256) {\n        if (owner == address(0)) revert BalanceQueryForZeroAddress();\n        return uint256(ERC721ALib.erc721AStorage()._addressData[owner].balance);\n    }\n\n    /**\n     * @dev Approve `to` to operate on `tokenId`\n     *\n     * Emits a {Approval} event.\n     */\n    function _approve(\n        address to,\n        uint256 tokenId,\n        address owner\n    ) internal {\n        ERC721ALib.erc721AStorage()._tokenApprovals[tokenId] = to;\n        emit Approval(owner, to, tokenId);\n    }\n\n    /**\n     * @dev Transfers `tokenId` from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _transfer(\n        address from,\n        address to,\n        uint256 tokenId\n    ) internal {\n        ERC721ALib.ERC721AStorage storage s = ERC721ALib.erc721AStorage();\n        ERC721ALib.TokenOwnership memory prevOwnership = ERC721ALib\n            ._ownershipOf(tokenId);\n\n        if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();\n\n        bool isApprovedOrOwner = (msg.sender == from ||\n            _isApprovedForAll(from, msg.sender) ||\n            _getApproved(tokenId) == msg.sender);\n\n        if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();\n        if (to == address(0)) revert TransferToZeroAddress();\n\n        TransferHooksLib.beforeTokenTransfers(from, to, tokenId, 1);\n\n        // Clear approvals from the previous owner\n        _approve(address(0), tokenId, from);\n\n        // Underflow of the sender's balance is impossible because we check for\n        // ownership above and the recipient's balance can't realistically overflow.\n        // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.\n        unchecked {\n            s._addressData[from].balance -= 1;\n            s._addressData[to].balance += 1;\n\n            ERC721ALib.TokenOwnership storage currSlot = s._ownerships[tokenId];\n            currSlot.addr = to;\n            currSlot.startTimestamp = uint64(block.timestamp);\n\n            // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.\n            // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.\n            uint256 nextTokenId = tokenId + 1;\n            ERC721ALib.TokenOwnership storage nextSlot = s._ownerships[\n                nextTokenId\n            ];\n            if (nextSlot.addr == address(0)) {\n                // This will suffice for checking _exists(nextTokenId),\n                // as a burned slot cannot contain the zero address.\n                if (nextTokenId != s._currentIndex) {\n                    nextSlot.addr = from;\n                    nextSlot.startTimestamp = prevOwnership.startTimestamp;\n                }\n            }\n        }\n\n        emit Transfer(from, to, tokenId);\n        TransferHooksLib.afterTokenTransfers(from, to, tokenId, 1);\n    }\n\n    /**\n     * @dev This is equivalent to _burn(tokenId, true)\n     */\n    function _burn(uint256 tokenId) internal {\n        _burn(tokenId, true);\n    }\n\n    /**\n     * Returns the number of tokens minted by `owner`.\n     */\n    function _numberMinted(address owner) internal view returns (uint256) {\n        return\n            uint256(\n                ERC721ALib.erc721AStorage()._addressData[owner].numberMinted\n            );\n    }\n\n    /**\n     * Returns the number of tokens burned by or on behalf of `owner`.\n     */\n    function _numberBurned(address owner) internal view returns (uint256) {\n        return\n            uint256(\n                ERC721ALib.erc721AStorage()._addressData[owner].numberBurned\n            );\n    }\n\n    /**\n     * @dev Destroys `tokenId`.\n     * The approval is cleared when the token is burned.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _burn(uint256 tokenId, bool approvalCheck) internal {\n        ERC721ALib.TokenOwnership memory prevOwnership = ERC721ALib\n            ._ownershipOf(tokenId);\n        ERC721ALib.ERC721AStorage storage s = ERC721ALib.erc721AStorage();\n\n        address from = prevOwnership.addr;\n\n        if (approvalCheck) {\n            bool isApprovedOrOwner = (msg.sender == from ||\n                _isApprovedForAll(from, msg.sender) ||\n                _getApproved(tokenId) == msg.sender);\n\n            if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();\n        }\n\n        TransferHooksLib.beforeTokenTransfers(from, address(0), tokenId, 1);\n\n        // Clear approvals from the previous owner\n        _approve(address(0), tokenId, from);\n\n        // Underflow of the sender's balance is impossible because we check for\n        // ownership above and the recipient's balance can't realistically overflow.\n        // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.\n        unchecked {\n            ERC721ALib.AddressData storage addressData = s._addressData[from];\n            addressData.balance -= 1;\n            addressData.numberBurned += 1;\n\n            // Keep track of who burned the token, and the timestamp of burning.\n            ERC721ALib.TokenOwnership storage currSlot = s._ownerships[tokenId];\n            currSlot.addr = from;\n            currSlot.startTimestamp = uint64(block.timestamp);\n            currSlot.burned = true;\n\n            // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.\n            // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.\n            uint256 nextTokenId = tokenId + 1;\n            ERC721ALib.TokenOwnership storage nextSlot = s._ownerships[\n                nextTokenId\n            ];\n            if (nextSlot.addr == address(0)) {\n                // This will suffice for checking _exists(nextTokenId),\n                // as a burned slot cannot contain the zero address.\n                if (nextTokenId != s._currentIndex) {\n                    nextSlot.addr = from;\n                    nextSlot.startTimestamp = prevOwnership.startTimestamp;\n                }\n            }\n        }\n\n        emit Transfer(from, address(0), tokenId);\n        TransferHooksLib.afterTokenTransfers(from, address(0), tokenId, 1);\n\n        // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.\n        unchecked {\n            s._burnCounter++;\n        }\n    }\n\n    function _isApprovedForAll(address owner, address operator)\n        internal\n        view\n        returns (bool)\n    {\n        return ERC721ALib.erc721AStorage()._operatorApprovals[owner][operator];\n    }\n\n    /**\n     * @dev See {IERC721-getApproved}.\n     */\n    function _getApproved(uint256 tokenId) internal view returns (address) {\n        if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();\n\n        return ERC721ALib.erc721AStorage()._tokenApprovals[tokenId];\n    }\n}\n"
    },
    "contracts/facets/BaseNFTLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport {ERC721ALib} from \"./ERC721A/ERC721ALib.sol\";\n\nerror ExceedsMaxMintable();\nerror MaxMintableTooSmall();\nerror MaxMintableLocked();\n\nlibrary BaseNFTLib {\n    struct BaseNFTStorage {\n        uint256 saleState;\n        uint256 maxMintable; // the max number of tokens able to be minted\n        bool maxMintableLocked;\n    }\n\n    function baseNFTStorage()\n        internal\n        pure\n        returns (BaseNFTStorage storage es)\n    {\n        bytes32 position = keccak256(\"base.nft.diamond.storage\");\n        assembly {\n            es.slot := position\n        }\n    }\n\n    function saleState() internal view returns (uint256) {\n        return baseNFTStorage().saleState;\n    }\n\n    function setSaleState(uint256 _saleState) internal {\n        baseNFTStorage().saleState = _saleState;\n    }\n\n    function _safeMint(address to, uint256 quantity)\n        internal\n        returns (uint256 initialTokenId)\n    {\n        // if max mintable is zero, unlimited mints are allowed\n        uint256 max = baseNFTStorage().maxMintable;\n        if (max != 0 && max < (ERC721ALib.totalMinted() + quantity)) {\n            revert ExceedsMaxMintable();\n        }\n\n        // returns the id of the first token minted!\n        initialTokenId = ERC721ALib.currentIndex();\n        ERC721ALib._safeMint(to, quantity);\n    }\n\n    // skips checks about sending to contract addresses\n    function _unsafeMint(address to, uint256 quantity)\n        internal\n        returns (uint256 initialTokenId)\n    {\n        // if max mintable is zero, unlimited mints are allowed\n        uint256 max = baseNFTStorage().maxMintable;\n        if (max != 0 && max < (ERC721ALib.totalMinted() + quantity)) {\n            revert ExceedsMaxMintable();\n        }\n\n        // returns the id of the first token minted!\n        initialTokenId = ERC721ALib.currentIndex();\n        ERC721ALib._mint(to, quantity, \"\", false);\n    }\n\n    function maxMintable() internal view returns (uint256) {\n        return baseNFTStorage().maxMintable;\n    }\n\n    function setMaxMintable(uint256 _maxMintable) internal {\n        if (_maxMintable < ERC721ALib.totalMinted()) {\n            revert MaxMintableTooSmall();\n        }\n        if (baseNFTStorage().maxMintableLocked) {\n            revert MaxMintableLocked();\n        }\n\n        baseNFTStorage().maxMintable = _maxMintable;\n    }\n\n    // NOTE: this returns an array of owner addresses for each token\n    // this may return duplicate addresses if one address owns multiple\n    // tokens. The client should de-doop as needed\n    function allOwners() internal view returns (address[] memory) {\n        uint256 currIndex = ERC721ALib.erc721AStorage()._currentIndex;\n\n        address[] memory _allOwners = new address[](currIndex - 1);\n\n        for (uint256 i = 0; i < currIndex - 1; i++) {\n            uint256 tokenId = i + 1;\n            if (ERC721ALib._exists(tokenId)) {\n                address owner = ERC721ALib._ownershipOf(tokenId).addr;\n                _allOwners[i] = owner;\n            } else {\n                _allOwners[i] = address(0x0);\n            }\n        }\n\n        return _allOwners;\n    }\n\n    function allTokensForOwner(address _owner)\n        internal\n        view\n        returns (uint256[] memory)\n    {\n        uint256 balance = ERC721ALib.balanceOf(_owner);\n        uint256 currIndex = ERC721ALib.erc721AStorage()._currentIndex;\n\n        uint256[] memory tokens = new uint256[](balance);\n        uint256 tokenCount = 0;\n\n        for (uint256 i = 1; i < currIndex; i++) {\n            if (ERC721ALib._exists(i)) {\n                address ownerOfToken = ERC721ALib._ownershipOf(i).addr;\n\n                if (ownerOfToken == _owner) {\n                    tokens[tokenCount] = i;\n                    tokenCount++;\n                }\n            }\n        }\n\n        return tokens;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
    },
    "contracts/interfaces/IERC721Metadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n    /**\n     * @dev Returns the token collection name.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the token collection symbol.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n     */\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
    },
    "contracts/facets/TransferHooks/TransferHooksLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {DiamondCloneLib} from \"../DiamondClone/DiamondCloneLib.sol\";\nimport {DiamondSaw} from \"../../DiamondSaw.sol\";\n\nlibrary TransferHooksLib {\n    struct TransferHooksStorage {\n        bytes4 beforeTransfersHook; // selector of before transfer hook\n        bytes4 afterTransfersHook; // selector of after transfer hook\n    }\n\n    function transferHooksStorage()\n        internal\n        pure\n        returns (TransferHooksStorage storage s)\n    {\n        bytes32 position = keccak256(\"transfer.hooks.facet.storage\");\n        assembly {\n            s.slot := position\n        }\n    }\n\n    function setBeforeTransfersHook(bytes4 _beforeTransfersHook) internal {\n        require(!DiamondCloneLib.isImmutable(), \"Cannot update when immutable\");\n        address sawAddress = DiamondCloneLib\n            .diamondCloneStorage()\n            .diamondSawAddress;\n\n        bool isApproved = DiamondSaw(sawAddress).isTransferHookSelectorApproved(\n            _beforeTransfersHook\n        );\n        require(isApproved, \"selector not approved\");\n        transferHooksStorage().beforeTransfersHook = _beforeTransfersHook;\n    }\n\n    function setAfterTransfersHook(bytes4 _afterTransfersHook) internal {\n        require(!DiamondCloneLib.isImmutable(), \"Cannot update when immutable\");\n        address sawAddress = DiamondCloneLib\n            .diamondCloneStorage()\n            .diamondSawAddress;\n        bool isApproved = DiamondSaw(sawAddress).isTransferHookSelectorApproved(\n            _afterTransfersHook\n        );\n        require(isApproved, \"selector not approved\");\n        transferHooksStorage().afterTransfersHook = _afterTransfersHook;\n    }\n\n    function removeBeforeTransfersHook() internal {\n        require(!DiamondCloneLib.isImmutable(), \"Cannot update when immutable\");\n        TransferHooksLib.transferHooksStorage().beforeTransfersHook = bytes4(0);\n    }\n\n    function removeAfterTransfersHook() internal {\n        require(!DiamondCloneLib.isImmutable(), \"Cannot update when immutable\");\n        TransferHooksLib.transferHooksStorage().afterTransfersHook = bytes4(0);\n    }\n\n    function maybeCallTransferHook(\n        bytes4 selector,\n        address from,\n        address to,\n        uint256 startTokenId,\n        uint256 quantity\n    ) internal {\n        if (selector == bytes4(0)) {\n            return;\n        }\n\n        (bool success, ) = address(this).call(\n            abi.encodeWithSelector(selector, from, to, startTokenId, quantity)\n        );\n\n        require(success, \"Transfer hook failed\");\n    }\n\n    function beforeTokenTransfers(\n        address from,\n        address to,\n        uint256 startTokenId,\n        uint256 quantity\n    ) internal {\n        bytes4 selector = transferHooksStorage().beforeTransfersHook;\n        maybeCallTransferHook(selector, from, to, startTokenId, quantity);\n    }\n\n    function afterTokenTransfers(\n        address from,\n        address to,\n        uint256 startTokenId,\n        uint256 quantity\n    ) internal {\n        bytes4 selector = transferHooksStorage().afterTransfersHook;\n        maybeCallTransferHook(selector, from, to, startTokenId, quantity);\n    }\n}\n"
    },
    "contracts/interfaces/IERC721.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes calldata data\n    ) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the caller.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool _approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
    },
    "contracts/facets/DiamondClone/DiamondCloneLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {DiamondSaw} from \"../../DiamondSaw.sol\";\nimport {IDiamondLoupe} from \"./IDiamondLoupe.sol\";\nimport {IDiamondCut} from \"./IDiamondCut.sol\";\n\nlibrary DiamondCloneLib {\n    bytes32 constant DIAMOND_CLONE_STORAGE_POSITION =\n        keccak256(\"diamond.standard.diamond.clone.storage\");\n\n    bytes32 constant ERC721A_STORAGE_POSITION =\n        keccak256(\"erc721a.facet.storage\");\n\n    event DiamondCut(\n        IDiamondCut.FacetCut[] _diamondCut,\n        address _init,\n        bytes _calldata\n    );\n\n    struct DiamondCloneStorage {\n        // address of the diamond saw contract\n        address diamondSawAddress;\n        // mapping to all the facets this diamond implements.\n        mapping(address => bool) facetAddresses;\n        // number of facets supported\n        uint256 numFacets;\n        // optional gas cache for highly trafficked write selectors\n        mapping(bytes4 => address) selectorGasCache;\n        // immutability window\n        uint256 immutableUntilBlock;\n    }\n\n    // minimal copy  of ERC721AStorage for initialization\n    struct ERC721AStorage {\n        // The tokenId of the next token to be minted.\n        uint256 _currentIndex;\n    }\n\n    function diamondCloneStorage()\n        internal\n        pure\n        returns (DiamondCloneStorage storage s)\n    {\n        bytes32 position = DIAMOND_CLONE_STORAGE_POSITION;\n        assembly {\n            s.slot := position\n        }\n    }\n\n    // calls externally to the saw to find the appropriate facet to delegate to\n    function _getFacetAddressForCall() internal view returns (address addr) {\n        DiamondCloneStorage storage s = diamondCloneStorage();\n\n        addr = s.selectorGasCache[msg.sig];\n        if (addr != address(0)) {\n            return addr;\n        }\n\n        (bool success, bytes memory res) = s.diamondSawAddress.staticcall(\n            abi.encodeWithSelector(0x14bc7560, msg.sig)\n        );\n        require(success, \"Failed to fetch facet address for call\");\n\n        assembly {\n            addr := mload(add(res, 32))\n        }\n\n        return s.facetAddresses[addr] ? addr : address(0);\n    }\n\n    function initNFT() internal {\n        ERC721AStorage storage es;\n        bytes32 position = ERC721A_STORAGE_POSITION;\n        assembly {\n            es.slot := position\n        }\n\n        es._currentIndex = 1;\n    }\n\n    function initializeDiamondClone(\n        address diamondSawAddress,\n        address[] calldata _facetAddresses\n    ) internal {\n        DiamondCloneLib.DiamondCloneStorage storage s = DiamondCloneLib\n            .diamondCloneStorage();\n\n        require(diamondSawAddress != address(0), \"Must set saw addy\");\n        require(s.diamondSawAddress == address(0), \"Already inited\");\n\n        initNFT();\n\n        s.diamondSawAddress = diamondSawAddress;\n        IDiamondCut.FacetCut[] memory cuts = new IDiamondCut.FacetCut[](\n            _facetAddresses.length\n        );\n\n        // emit the diamond cut event\n        for (uint256 i; i < _facetAddresses.length; i++) {\n            address facetAddress = _facetAddresses[i];\n            bytes4[] memory selectors = DiamondSaw(diamondSawAddress)\n                .functionSelectorsForFacetAddress(facetAddress);\n            require(selectors.length > 0, \"Facet is not supported by the saw\");\n            cuts[i].facetAddress = _facetAddresses[i];\n            cuts[i].functionSelectors = selectors;\n            s.facetAddresses[facetAddress] = true;\n        }\n\n        emit DiamondCut(cuts, address(0), \"\");\n\n        s.numFacets = _facetAddresses.length;\n    }\n\n    function _purgeGasCache(bytes4[] memory selectors) internal {\n        DiamondCloneStorage storage s = diamondCloneStorage();\n\n        for (uint256 i; i < selectors.length; i++) {\n            if (s.selectorGasCache[selectors[i]] != address(0)) {\n                delete s.selectorGasCache[selectors[i]];\n            }\n        }\n    }\n\n    function cutWithDiamondSaw(\n        IDiamondCut.FacetCut[] memory _diamondCut,\n        address _init,\n        bytes calldata _calldata\n    ) internal {\n        DiamondCloneStorage storage s = diamondCloneStorage();\n\n        uint256 newNumFacets = s.numFacets;\n\n        // emit the diamond cut event\n        for (uint256 i; i < _diamondCut.length; i++) {\n            IDiamondCut.FacetCut memory cut = _diamondCut[i];\n            bytes4[] memory selectors = DiamondSaw(s.diamondSawAddress)\n                .functionSelectorsForFacetAddress(cut.facetAddress);\n\n            require(selectors.length > 0, \"Facet is not supported by the saw\");\n            require(\n                selectors.length == cut.functionSelectors.length,\n                \"You can only modify all selectors at once with diamond saw\"\n            );\n\n            // NOTE we override the passed selectors after validating the length matches\n            // With diamond saw we can only add / remove all selectors for a given facet\n            cut.functionSelectors = selectors;\n\n            // if the address is already in the facet map\n            // remove it and remove all the selectors\n            // otherwise add the selectors\n            if (s.facetAddresses[cut.facetAddress]) {\n                require(\n                    cut.action == IDiamondCut.FacetCutAction.Remove,\n                    \"Can only remove existing facet selectors\"\n                );\n                delete s.facetAddresses[cut.facetAddress];\n                _purgeGasCache(selectors);\n                newNumFacets -= 1;\n            } else {\n                require(\n                    cut.action == IDiamondCut.FacetCutAction.Add,\n                    \"Can only add non-existing facet selectors\"\n                );\n                s.facetAddresses[cut.facetAddress] = true;\n                newNumFacets += 1;\n            }\n        }\n\n        emit DiamondCut(_diamondCut, _init, _calldata);\n\n        // call the init function\n        (bool success, bytes memory error) = _init.delegatecall(_calldata);\n        if (!success) {\n            if (error.length > 0) {\n                // bubble up the error\n                revert(string(error));\n            } else {\n                revert(\"DiamondCloneLib: _init function reverted\");\n            }\n        }\n\n        s.numFacets = newNumFacets;\n    }\n\n    function upgradeDiamondSaw(\n        address _upgradeSawAddress,\n        address[] calldata _oldFacetAddresses,\n        address[] calldata _newFacetAddresses,\n        address _init,\n        bytes calldata _calldata\n    ) internal {\n        require(\n            !isImmutable(),\n            \"Cannot upgrade saw during immutability window\"\n        );\n        require(\n            _upgradeSawAddress != address(0),\n            \"Cannot set saw to zero address\"\n        );\n\n        DiamondCloneStorage storage s = diamondCloneStorage();\n\n        require(\n            _oldFacetAddresses.length == s.numFacets,\n            \"Must remove all facets to upgrade saw\"\n        );\n\n        DiamondSaw oldSawInstance = DiamondSaw(s.diamondSawAddress);\n\n        require(\n            oldSawInstance.isUpgradeSawSupported(_upgradeSawAddress),\n            \"Upgrade saw is not supported\"\n        );\n        DiamondSaw newSawInstance = DiamondSaw(_upgradeSawAddress);\n\n        IDiamondCut.FacetCut[] memory cuts = new IDiamondCut.FacetCut[](\n            _oldFacetAddresses.length + _newFacetAddresses.length\n        );\n\n        for (\n            uint256 i;\n            i < _oldFacetAddresses.length + _newFacetAddresses.length;\n            i++\n        ) {\n            if (i < _oldFacetAddresses.length) {\n                address facetAddress = _oldFacetAddresses[i];\n                require(\n                    s.facetAddresses[facetAddress],\n                    \"Cannot remove facet that is not supported\"\n                );\n                bytes4[] memory selectors = oldSawInstance\n                    .functionSelectorsForFacetAddress(facetAddress);\n                require(\n                    selectors.length > 0,\n                    \"Facet is not supported by the saw\"\n                );\n\n                cuts[i].action = IDiamondCut.FacetCutAction.Remove;\n                cuts[i].facetAddress = facetAddress;\n                cuts[i].functionSelectors = selectors;\n\n                _purgeGasCache(selectors);\n                delete s.facetAddresses[facetAddress];\n            } else {\n                address facetAddress = _newFacetAddresses[\n                    i - _oldFacetAddresses.length\n                ];\n                bytes4[] memory selectors = newSawInstance\n                    .functionSelectorsForFacetAddress(facetAddress);\n                require(\n                    selectors.length > 0,\n                    \"Facet is not supported by the new saw\"\n                );\n\n                cuts[i].action = IDiamondCut.FacetCutAction.Add;\n                cuts[i].facetAddress = facetAddress;\n                cuts[i].functionSelectors = selectors;\n\n                s.facetAddresses[facetAddress] = true;\n            }\n        }\n\n        emit DiamondCut(cuts, _init, _calldata);\n\n        // actually update the diamond saw address\n        s.numFacets = _newFacetAddresses.length;\n        s.diamondSawAddress = _upgradeSawAddress;\n\n        // call the init function\n        (bool success, bytes memory error) = _init.delegatecall(_calldata);\n        if (!success) {\n            if (error.length > 0) {\n                // bubble up the error\n                revert(string(error));\n            } else {\n                revert(\"DiamondCloneLib: _init function reverted\");\n            }\n        }\n    }\n\n    function setGasCacheForSelector(bytes4 selector) internal {\n        DiamondCloneStorage storage s = diamondCloneStorage();\n\n        address facetAddress = DiamondSaw(s.diamondSawAddress)\n            .facetAddressForSelector(selector);\n        require(facetAddress != address(0), \"Facet not supported\");\n        require(s.facetAddresses[facetAddress], \"Facet not included in clone\");\n\n        s.selectorGasCache[selector] = facetAddress;\n    }\n\n    function setImmutableUntilBlock(uint256 blockNum) internal {\n        diamondCloneStorage().immutableUntilBlock = blockNum;\n    }\n\n    function isImmutable() internal view returns (bool) {\n        return block.number < diamondCloneStorage().immutableUntilBlock;\n    }\n\n    function immutableUntilBlock() internal view returns (uint256) {\n        return diamondCloneStorage().immutableUntilBlock;\n    }\n\n    /**\n     * LOUPE FUNCTIONALITY BELOW\n     */\n\n    function facets()\n        internal\n        view\n        returns (IDiamondLoupe.Facet[] memory facets_)\n    {\n        DiamondCloneLib.DiamondCloneStorage storage ds = DiamondCloneLib\n            .diamondCloneStorage();\n        IDiamondLoupe.Facet[] memory allSawFacets = DiamondSaw(\n            ds.diamondSawAddress\n        ).allFacetsWithSelectors();\n\n        uint256 copyIndex = 0;\n\n        facets_ = new IDiamondLoupe.Facet[](ds.numFacets);\n\n        for (uint256 i; i < allSawFacets.length; i++) {\n            if (ds.facetAddresses[allSawFacets[i].facetAddress]) {\n                facets_[copyIndex] = allSawFacets[i];\n                copyIndex++;\n            }\n        }\n    }\n\n    function facetAddresses()\n        internal\n        view\n        returns (address[] memory facetAddresses_)\n    {\n        DiamondCloneLib.DiamondCloneStorage storage ds = DiamondCloneLib\n            .diamondCloneStorage();\n\n        address[] memory allSawFacetAddresses = DiamondSaw(ds.diamondSawAddress)\n            .allFacetAddresses();\n        facetAddresses_ = new address[](ds.numFacets);\n\n        uint256 copyIndex = 0;\n\n        for (uint256 i; i < allSawFacetAddresses.length; i++) {\n            if (ds.facetAddresses[allSawFacetAddresses[i]]) {\n                facetAddresses_[copyIndex] = allSawFacetAddresses[i];\n                copyIndex++;\n            }\n        }\n    }\n}\n"
    },
    "contracts/DiamondSaw.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\nimport {IDiamondCut} from \"./facets/DiamondClone/IDiamondCut.sol\";\nimport {IDiamondLoupe} from \"./facets/DiamondClone/IDiamondLoupe.sol\";\nimport {DiamondSawLib} from \"./libraries/DiamondSawLib.sol\";\nimport {BasicAccessControlFacet} from \"./facets/AccessControl/BasicAccessControlFacet.sol\";\nimport {AccessControlModifiers} from \"./facets/AccessControl/AccessControlModifiers.sol\";\nimport {AccessControlLib} from \"./facets/AccessControl/AccessControlLib.sol\";\nimport {PausableFacet} from \"./facets/Pausable/PausableFacet.sol\";\nimport {PausableModifiers} from \"./facets/Pausable/PausableModifiers.sol\";\n\n/**\n * DiamondSaw is meant to be used as a\n * Singleton to \"cut\" many minimal diamond clones\n * In a gas efficient manner for deployments.\n *\n * This is accomplished by handling the storage intensive\n * selector mappings in one contract, \"the saw\" instead of in each diamond.\n *\n * Adding a new facet to the saw enables new diamond \"patterns\"\n *\n * This should be used if you\n *\n * 1. Need cheap deployments of many similar cloned diamonds that\n * utilize the same pre-deployed facets\n *\n * 2. Are okay with gas overhead on write txn to the diamonds\n * to communicate with the singleton (saw) to fetch selectors\n *\n */\ncontract DiamondSaw is\n    BasicAccessControlFacet,\n    AccessControlModifiers,\n    PausableFacet,\n    PausableModifiers\n{\n    constructor() {\n        AccessControlLib._transferOwnership(msg.sender);\n    }\n\n    function addFacetPattern(\n        IDiamondCut.FacetCut[] calldata _facetAdds,\n        address _init,\n        bytes calldata _calldata\n    ) external onlyOwner whenNotPaused {\n        DiamondSawLib.diamondCutAddOnly(_facetAdds, _init, _calldata);\n    }\n\n    // if a facet has no selectors, it is not supported\n    function checkFacetSupported(address _facetAddress) external view {\n        DiamondSawLib.checkFacetSupported(_facetAddress);\n    }\n\n    function facetAddressForSelector(bytes4 selector)\n        external\n        view\n        returns (address)\n    {\n        return\n            DiamondSawLib\n                .diamondSawStorage()\n                .selectorToFacetAndPosition[selector]\n                .facetAddress;\n    }\n\n    function functionSelectorsForFacetAddress(address facetAddress)\n        external\n        view\n        returns (bytes4[] memory)\n    {\n        return\n            DiamondSawLib\n                .diamondSawStorage()\n                .facetFunctionSelectors[facetAddress]\n                .functionSelectors;\n    }\n\n    function allFacetAddresses() external view returns (address[] memory) {\n        return DiamondSawLib.diamondSawStorage().facetAddresses;\n    }\n\n    function allFacetsWithSelectors()\n        external\n        view\n        returns (IDiamondLoupe.Facet[] memory _facetsWithSelectors)\n    {\n        DiamondSawLib.DiamondSawStorage storage ds = DiamondSawLib\n            .diamondSawStorage();\n\n        uint256 numFacets = ds.facetAddresses.length;\n        _facetsWithSelectors = new IDiamondLoupe.Facet[](numFacets);\n        for (uint256 i; i < numFacets; i++) {\n            address facetAddress_ = ds.facetAddresses[i];\n            _facetsWithSelectors[i].facetAddress = facetAddress_;\n            _facetsWithSelectors[i].functionSelectors = ds\n                .facetFunctionSelectors[facetAddress_]\n                .functionSelectors;\n        }\n    }\n\n    function facetAddressForInterface(bytes4 _interface)\n        external\n        view\n        returns (address)\n    {\n        DiamondSawLib.DiamondSawStorage storage ds = DiamondSawLib\n            .diamondSawStorage();\n        return ds.interfaceToFacet[_interface];\n    }\n\n    function setFacetForERC165Interface(bytes4 _interface, address _facet)\n        external\n        onlyOwner\n        whenNotPaused\n    {\n        DiamondSawLib.checkFacetSupported(_facet);\n        require(\n            DiamondSawLib.diamondSawStorage().interfaceToFacet[_interface] ==\n                address(0),\n            \"Only one facet can implement an interface\"\n        );\n        DiamondSawLib.diamondSawStorage().interfaceToFacet[_interface] = _facet;\n    }\n\n    function approveTransferHookSelector(bytes4 selector)\n        external\n        onlyOwner\n        whenNotPaused\n    {\n        DiamondSawLib.approveTransferHookSelector(selector);\n    }\n\n    function approveTokenURISelector(bytes4 selector)\n        external\n        onlyOwner\n        whenNotPaused\n    {\n        DiamondSawLib.approveTokenURISelector(selector);\n    }\n\n    function isTokenURISelectorApproved(bytes4 selector)\n        external\n        view\n        returns (bool)\n    {\n        return\n            DiamondSawLib.diamondSawStorage().approvedTokenURIFunctionSelectors[\n                selector\n            ];\n    }\n\n    function isTransferHookSelectorApproved(bytes4 selector)\n        external\n        view\n        returns (bool)\n    {\n        return\n            DiamondSawLib\n                .diamondSawStorage()\n                .approvedTransferHookFunctionSelectors[selector];\n    }\n\n    function setUpgradeSawAddress(address _upgradeSaw)\n        external\n        onlyOwner\n        whenNotPaused\n    {\n        DiamondSawLib.setUpgradeSawAddress(_upgradeSaw);\n    }\n\n    function isUpgradeSawSupported(address _upgradeSaw)\n        external\n        view\n        returns (bool)\n    {\n        return\n            DiamondSawLib.diamondSawStorage().supportedSawAddresses[\n                _upgradeSaw\n            ];\n    }\n}\n"
    },
    "contracts/facets/DiamondClone/IDiamondLoupe.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\n// A loupe is a small magnifying glass used to look at diamonds.\n// These functions look at diamonds\ninterface IDiamondLoupe {\n    /// These functions are expected to be called frequently\n    /// by tools.\n\n    struct Facet {\n        address facetAddress;\n        bytes4[] functionSelectors;\n    }\n\n    /// @notice Gets all facet addresses and their four byte function selectors.\n    /// @return facets_ Facet\n    function facets() external view returns (Facet[] memory facets_);\n\n    /// @notice Gets all the function selectors supported by a specific facet.\n    /// @param _facet The facet address.\n    /// @return facetFunctionSelectors_\n    function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);\n\n    /// @notice Get all the facet addresses used by a diamond.\n    /// @return facetAddresses_\n    function facetAddresses() external view returns (address[] memory facetAddresses_);\n\n    /// @notice Gets the facet that supports the given selector.\n    /// @dev If facet is not found return address(0).\n    /// @param _functionSelector The function selector.\n    /// @return facetAddress_ The facet address.\n    function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);\n}\n"
    },
    "contracts/facets/DiamondClone/IDiamondCut.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/******************************************************************************\\\n* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)\n* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535\n/******************************************************************************/\n\ninterface IDiamondCut {\n    enum FacetCutAction {Add, Replace, Remove}\n    // Add=0, Replace=1, Remove=2\n\n    struct FacetCut {\n        address facetAddress;\n        FacetCutAction action;\n        bytes4[] functionSelectors;\n    }\n\n    /// @notice Add/replace/remove any number of functions and optionally execute\n    ///         a function with delegatecall\n    /// @param _diamondCut Contains the facet addresses and function selectors\n    /// @param _init The address of the contract or facet to execute _calldata\n    /// @param _calldata A function call, including function selector and arguments\n    ///                  _calldata is executed with delegatecall on _init\n    function diamondCut(\n        FacetCut[] calldata _diamondCut,\n        address _init,\n        bytes calldata _calldata\n    ) external;\n\n    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "contracts/libraries/DiamondSawLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IDiamondCut} from \"../facets/DiamondClone/IDiamondCut.sol\";\n\nlibrary DiamondSawLib {\n    bytes32 constant DIAMOND_SAW_STORAGE_POSITION =\n        keccak256(\"diamond.standard.diamond.saw.storage\");\n\n    struct FacetAddressAndPosition {\n        address facetAddress;\n        uint96 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array\n    }\n\n    struct FacetFunctionSelectors {\n        bytes4[] functionSelectors;\n        uint256 facetAddressPosition; // position of facetAddress in facetAddresses array\n    }\n\n    struct DiamondSawStorage {\n        // maps function selector to the facet address and\n        // the position of the selector in the facetFunctionSelectors.selectors array\n        mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;\n        // maps facet addresses to function selectors\n        mapping(address => FacetFunctionSelectors) facetFunctionSelectors;\n        // facet addresses\n        address[] facetAddresses;\n        // Used to query if a facet implements a given interface\n        // Note: this works because no interface can be implemented by\n        // two different facets with diamond saw because no\n        // selector overlap is permitted!!\n        mapping(bytes4 => address) interfaceToFacet;\n        // for transfer hooks, selectors must be approved in the saw\n        mapping(bytes4 => bool) approvedTransferHookFunctionSelectors;\n        // for tokenURI overrides, selectors must be approved in the saw\n        mapping(bytes4 => bool) approvedTokenURIFunctionSelectors;\n        // Saw contracts which clients can upgrade to\n        mapping(address => bool) supportedSawAddresses;\n    }\n\n    function diamondSawStorage()\n        internal\n        pure\n        returns (DiamondSawStorage storage ds)\n    {\n        bytes32 position = DIAMOND_SAW_STORAGE_POSITION;\n        assembly {\n            ds.slot := position\n        }\n    }\n\n    event DiamondCut(\n        IDiamondCut.FacetCut[] _diamondCut,\n        address _init,\n        bytes _calldata\n    );\n\n    // Internal function version of diamondCut\n    // only supports adding new selectors\n    function diamondCutAddOnly(\n        IDiamondCut.FacetCut[] memory _diamondCut,\n        address _init,\n        bytes memory _calldata\n    ) internal {\n        for (\n            uint256 facetIndex;\n            facetIndex < _diamondCut.length;\n            facetIndex++\n        ) {\n            require(\n                _diamondCut[facetIndex].action ==\n                    IDiamondCut.FacetCutAction.Add,\n                \"Only add action supported in saw\"\n            );\n            require(\n                !isFacetSupported(_diamondCut[facetIndex].facetAddress),\n                \"Facet already exists in saw\"\n            );\n            addFunctions(\n                _diamondCut[facetIndex].facetAddress,\n                _diamondCut[facetIndex].functionSelectors\n            );\n        }\n        emit DiamondCut(_diamondCut, _init, _calldata);\n        initializeDiamondCut(_init, _calldata);\n    }\n\n    function addFunctions(\n        address _facetAddress,\n        bytes4[] memory _functionSelectors\n    ) internal {\n        require(\n            _functionSelectors.length > 0,\n            \"LibDiamondCut: No selectors in facet to cut\"\n        );\n        DiamondSawStorage storage ds = diamondSawStorage();\n        require(\n            _facetAddress != address(0),\n            \"LibDiamondCut: Add facet can't be address(0)\"\n        );\n        uint96 selectorPosition = uint96(\n            ds.facetFunctionSelectors[_facetAddress].functionSelectors.length\n        );\n        // add new facet address if it does not exist\n        if (selectorPosition == 0) {\n            addFacet(ds, _facetAddress);\n        }\n        for (\n            uint256 selectorIndex;\n            selectorIndex < _functionSelectors.length;\n            selectorIndex++\n        ) {\n            bytes4 selector = _functionSelectors[selectorIndex];\n            address oldFacetAddress = ds\n                .selectorToFacetAndPosition[selector]\n                .facetAddress;\n\n            require(\n                oldFacetAddress == address(0),\n                \"Cannot add function that already exists\"\n            );\n            addFunction(ds, selector, selectorPosition, _facetAddress);\n            selectorPosition++;\n        }\n    }\n\n    function addFacet(DiamondSawStorage storage ds, address _facetAddress)\n        internal\n    {\n        enforceHasContractCode(\n            _facetAddress,\n            \"LibDiamondCut: New facet has no code\"\n        );\n        ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = ds\n            .facetAddresses\n            .length;\n        ds.facetAddresses.push(_facetAddress);\n    }\n\n    function addFunction(\n        DiamondSawStorage storage ds,\n        bytes4 _selector,\n        uint96 _selectorPosition,\n        address _facetAddress\n    ) internal {\n        ds\n            .selectorToFacetAndPosition[_selector]\n            .functionSelectorPosition = _selectorPosition;\n        ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(\n            _selector\n        );\n        ds.selectorToFacetAndPosition[_selector].facetAddress = _facetAddress;\n    }\n\n    function initializeDiamondCut(address _init, bytes memory _calldata)\n        internal\n    {\n        if (_init == address(0)) {\n            require(\n                _calldata.length == 0,\n                \"LibDiamondCut: _init is address(0) but_calldata is not empty\"\n            );\n        } else {\n            require(\n                _calldata.length > 0,\n                \"LibDiamondCut: _calldata is empty but _init is not address(0)\"\n            );\n            if (_init != address(this)) {\n                enforceHasContractCode(\n                    _init,\n                    \"LibDiamondCut: _init address has no code\"\n                );\n            }\n            (bool success, bytes memory error) = _init.delegatecall(_calldata);\n            if (!success) {\n                if (error.length > 0) {\n                    // bubble up the error\n                    revert(string(error));\n                } else {\n                    revert(\"LibDiamondCut: _init function reverted\");\n                }\n            }\n        }\n    }\n\n    function enforceHasContractCode(\n        address _contract,\n        string memory _errorMessage\n    ) internal view {\n        uint256 contractSize;\n        assembly {\n            contractSize := extcodesize(_contract)\n        }\n        require(contractSize > 0, _errorMessage);\n    }\n\n    function setFacetSupportsInterface(bytes4 _interface, address _facetAddress)\n        internal\n    {\n        checkFacetSupported(_facetAddress);\n        DiamondSawStorage storage ds = diamondSawStorage();\n        ds.interfaceToFacet[_interface] = _facetAddress;\n    }\n\n    function isFacetSupported(address _facetAddress)\n        internal\n        view\n        returns (bool)\n    {\n        return\n            diamondSawStorage()\n                .facetFunctionSelectors[_facetAddress]\n                .functionSelectors\n                .length > 0;\n    }\n\n    function checkFacetSupported(address _facetAddress) internal view {\n        require(isFacetSupported(_facetAddress), \"Facet not supported\");\n    }\n\n    function approveTransferHookSelector(bytes4 transferHookSelector) internal {\n        DiamondSawStorage storage s = diamondSawStorage();\n        address facetImplementation = s\n            .selectorToFacetAndPosition[transferHookSelector]\n            .facetAddress;\n\n        require(\n            facetImplementation != address(0),\n            \"Cannot set transfer hook to unsupported selector\"\n        );\n\n        s.approvedTransferHookFunctionSelectors[transferHookSelector] = true;\n    }\n\n    function approveTokenURISelector(bytes4 tokenURISelector) internal {\n        DiamondSawStorage storage s = diamondSawStorage();\n        address facetImplementation = s\n            .selectorToFacetAndPosition[tokenURISelector]\n            .facetAddress;\n        require(\n            facetImplementation != address(0),\n            \"Cannot set token uri override to unsupported selector\"\n        );\n        s.approvedTokenURIFunctionSelectors[tokenURISelector] = true;\n    }\n\n    function setUpgradeSawAddress(address _upgradeSaw) internal {\n        diamondSawStorage().supportedSawAddresses[_upgradeSaw] = true;\n    }\n}\n"
    },
    "contracts/facets/AccessControl/BasicAccessControlFacet.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/IAccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\nimport \"./AccessControlLib.sol\";\nimport {PausableLib} from \"../Pausable/PausableLib.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract BasicAccessControlFacet is Context {\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return AccessControlLib.accessControlStorage()._owner;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual {\n        PausableLib.enforceUnpaused();\n        AccessControlLib._enforceOwner();\n        AccessControlLib._transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual {\n        PausableLib.enforceUnpaused();\n        AccessControlLib._enforceOwner();\n        require(\n            newOwner != address(0),\n            \"Ownable: new owner is the zero address\"\n        );\n        AccessControlLib._transferOwnership(newOwner);\n    }\n\n    function grantOperator(address _operator) public virtual {\n        PausableLib.enforceUnpaused();\n        AccessControlLib._enforceOwner();\n\n        AccessControlLib.grantRole(AccessControlLib.OPERATOR_ROLE, _operator);\n    }\n\n    function revokeOperator(address _operator) public virtual {\n        PausableLib.enforceUnpaused();\n        AccessControlLib._enforceOwner();\n        AccessControlLib.revokeRole(AccessControlLib.OPERATOR_ROLE, _operator);\n    }\n}\n"
    },
    "contracts/facets/AccessControl/AccessControlLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport {IAccessControl} from \"@openzeppelin/contracts/access/IAccessControl.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\n\npragma solidity ^0.8.0;\n\nlibrary AccessControlLib {\n    bytes32 constant DEFAULT_ADMIN_ROLE = 0x00;\n    bytes32 constant OPERATOR_ROLE = keccak256(\"operator.role\");\n\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(\n        bytes32 indexed role,\n        bytes32 indexed previousAdminRole,\n        bytes32 indexed newAdminRole\n    );\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(\n        bytes32 indexed role,\n        address indexed account,\n        address indexed sender\n    );\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(\n        bytes32 indexed role,\n        address indexed account,\n        address indexed sender\n    );\n\n    event OwnershipTransferred(\n        address indexed previousOwner,\n        address indexed newOwner\n    );\n\n    struct RoleData {\n        mapping(address => bool) members;\n        bytes32 adminRole;\n    }\n\n    struct AccessControlStorage {\n        address _owner;\n        mapping(bytes32 => RoleData) _roles;\n    }\n\n    bytes32 constant ACCESS_CONTROL_STORAGE_POSITION =\n        keccak256(\"Access.Control.library.storage\");\n\n    function accessControlStorage()\n        internal\n        pure\n        returns (AccessControlStorage storage s)\n    {\n        bytes32 position = ACCESS_CONTROL_STORAGE_POSITION;\n        assembly {\n            s.slot := position\n        }\n    }\n\n    function _isOwner() internal view returns (bool) {\n        return accessControlStorage()._owner == msg.sender;\n    }\n\n    function owner() internal view returns (address) {\n        return accessControlStorage()._owner;\n    }\n\n    function _enforceOwner() internal view {\n        require(_isOwner(), \"Caller is not the owner\");\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal {\n        address oldOwner = accessControlStorage()._owner;\n        accessControlStorage()._owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with a standardized message including the required role.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     *\n     * _Available since v4.1._\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role, msg.sender);\n        _;\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account)\n        internal\n        view\n        returns (bool)\n    {\n        return accessControlStorage()._roles[role].members[account];\n    }\n\n    /**\n     * @dev Revert with a standard message if `account` is missing `role`.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     *\n     * NOTE: Modified to always pass if the account is the owner\n     * and to always fail if ownership is revoked!\n     */\n    function _checkRole(bytes32 role, address account) internal view {\n        address ownerAddress = accessControlStorage()._owner;\n        require(ownerAddress != address(0), \"Admin functionality revoked\");\n        if (!hasRole(role, account) && account != ownerAddress) {\n            revert(\n                string(\n                    abi.encodePacked(\n                        \"AccessControl: account \",\n                        Strings.toHexString(uint160(account), 20),\n                        \" is missing role \",\n                        Strings.toHexString(uint256(role), 32)\n                    )\n                )\n            );\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) internal view returns (bytes32) {\n        return accessControlStorage()._roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account)\n        internal\n        onlyRole(getRoleAdmin(role))\n    {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account)\n        internal\n        onlyRole(getRoleAdmin(role))\n    {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) internal {\n        require(\n            account == msg.sender,\n            \"AccessControl: can only renounce roles for self\"\n        );\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal {\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        accessControlStorage()._roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * Internal function without access restriction.\n     */\n    function _grantRole(bytes32 role, address account) internal {\n        if (!hasRole(role, account)) {\n            accessControlStorage()._roles[role].members[account] = true;\n            emit RoleGranted(role, account, msg.sender);\n        }\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * Internal function without access restriction.\n     */\n    function _revokeRole(bytes32 role, address account) internal {\n        if (hasRole(role, account)) {\n            accessControlStorage()._roles[role].members[account] = false;\n            emit RoleRevoked(role, account, msg.sender);\n        }\n    }\n}\n"
    },
    "contracts/facets/Pausable/PausableFacet.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport {AccessControlModifiers} from \"../AccessControl/AccessControlModifiers.sol\";\nimport {PausableLib} from \"./PausableLib.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableFacet is AccessControlModifiers {\n    function pause() public onlyOwner {\n        PausableLib._pause();\n    }\n\n    function unpause() public onlyOwner {\n        PausableLib._unpause();\n    }\n\n    function paused() public view returns (bool) {\n        return PausableLib._paused();\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
    },
    "@openzeppelin/contracts/access/IAccessControl.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
    },
    "contracts/facets/Pausable/PausableLib.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nerror ContractPaused();\nerror ContractUnpaused();\n\nlibrary PausableLib {\n    bytes32 constant PAUSABLE_STORAGE_POSITION =\n        keccak256(\"pausable.facet.storage\");\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    struct PausableStorage {\n        bool _paused;\n    }\n\n    function pausableStorage()\n        internal\n        pure\n        returns (PausableStorage storage s)\n    {\n        bytes32 position = PAUSABLE_STORAGE_POSITION;\n        assembly {\n            s.slot := position\n        }\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function _paused() internal view returns (bool) {\n        return pausableStorage()._paused;\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal {\n        PausableStorage storage s = pausableStorage();\n        if (s._paused) revert ContractPaused();\n        s._paused = true;\n        emit Paused(msg.sender);\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal {\n        PausableStorage storage s = pausableStorage();\n        if (!s._paused) revert ContractUnpaused();\n        s._paused = false;\n        emit Unpaused(msg.sender);\n    }\n\n    function enforceUnpaused() internal view {\n        if (pausableStorage()._paused) revert ContractPaused();\n    }\n\n    function enforcePaused() internal view {\n        if (!pausableStorage()._paused) revert ContractUnpaused();\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "libraries": {}
  }
}