zellic-audit
Initial commit
f998fcd
raw
history blame
138 kB
{
"language": "Solidity",
"sources": {
"src/QuantumSpaces.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Creator: JCBDEV (Quantum Art)\npragma solidity ^0.8.4;\n\nimport \"./ERC721QUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/BitMapsUpgradeable.sol\";\nimport \"./ERC2981V3.sol\";\nimport \"./TokenId.sol\";\nimport \"./ManageableUpgradeable.sol\";\nimport \"./QuantumBlackListable.sol\";\nimport \"./QuantumSpacesStorage.sol\";\n\nerror VariantAndMintAmountMismatch();\nerror InvalidVariantForDrop();\nerror MintExceedsDropSupply();\nerror InvalidAuthorizationSignature();\nerror NotValidYet(uint256 validFrom, uint256 blockTimestamp);\nerror AuthorizationExpired(uint256 expiredAt, uint256 blockTimestamp);\nerror IncorrectFees(uint256 expectedFee, uint256 suppliedMsgValue);\nerror DropPaused(uint128 dropId);\n\ncontract QuantumSpaces is\n ERC2981,\n OwnableUpgradeable,\n ManageableUpgradeable,\n ERC721QUpgradeable,\n PausableUpgradeable,\n UUPSUpgradeable\n{\n using QuantumSpacesStorage for QuantumSpacesStorage.Layout;\n using BitMapsUpgradeable for BitMapsUpgradeable.BitMap;\n using StringsUpgradeable for uint256;\n using TokenId for uint256;\n\n /// >>>>>>>>>>>>>>>>>>>>>>> EVENTS <<<<<<<<<<<<<<<<<<<<<<<<<< ///\n\n event DropMint(\n address indexed to,\n uint256 indexed dropId,\n uint256 indexed variant,\n uint256 id\n );\n\n /// >>>>>>>>>>>>>>>>>>>>>>> STATE <<<<<<<<<<<<<<<<<<<<<<<<<< ///\n\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n\n /// >>>>>>>>>>>>>>>>>>>>> INITIALIZER <<<<<<<<<<<<<<<<<<<<<< ///\n\n function initialize(\n address admin,\n address payable quantumTreasury,\n address authorizer,\n address blAddress\n ) public virtual initializer {\n __QuantumSpaces_init(admin, quantumTreasury, authorizer, blAddress);\n }\n\n function __QuantumSpaces_init(\n address admin,\n address payable quantumTreasury,\n address authorizer,\n address blAddress\n ) internal onlyInitializing {\n __ERC721Q_init(\"QuantumSpaces\", \"QSPACE\");\n __Ownable_init();\n __Manageable_init();\n __Pausable_init();\n __UUPSUpgradeable_init();\n __QuantumSpaces_init_unchained(\n admin,\n quantumTreasury,\n authorizer,\n blAddress\n );\n }\n\n function __QuantumSpaces_init_unchained(\n address admin,\n address payable quantumTreasury,\n address authorizer,\n address blAddress\n ) internal onlyInitializing {\n QuantumSpacesStorage.Layout storage qs = QuantumSpacesStorage.layout();\n ERC721QStorage.Layout storage erc = ERC721QStorage.layout();\n erc.baseURI = \"https://core-api.quantum.art/v1/drop/metadata/space/\";\n qs.ipfsURI = \"ipfs://\";\n qs.quantumTreasury = quantumTreasury;\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _setupRole(MANAGER_ROLE, msg.sender);\n _setupRole(DEFAULT_ADMIN_ROLE, admin);\n _setupRole(MANAGER_ROLE, admin);\n qs.authorizer = authorizer;\n qs.blackListAddress = blAddress;\n }\n\n /// >>>>>>>>>>>>>>>>>>>>> BLACKLIST OPS <<<<<<<<<<<<<<<<<<<<<< ///\n modifier isNotBlackListed(address user) {\n if (\n QuantumBlackListable.isBlackListed(\n user,\n QuantumSpacesStorage.layout().blackListAddress\n )\n ) {\n revert QuantumBlackListable.BlackListedAddress(user);\n }\n _;\n }\n\n function getBlackListAddress() public view returns (address) {\n return QuantumSpacesStorage.layout().blackListAddress;\n }\n\n function setBlackListAddress(address blAddress)\n public\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n if (blAddress == address(0)) {\n revert QuantumBlackListable.InvalidBlackListAddress();\n }\n QuantumSpacesStorage.layout().blackListAddress = blAddress;\n }\n\n /// >>>>>>>>>>>>>>>>>>>>> RESTRICTED <<<<<<<<<<<<<<<<<<<<<< ///\n\n function _authorizeUpgrade(address newImplementation)\n internal\n override\n onlyOwner\n {}\n\n /// @notice set address of the minter\n /// @param owner The address of the new owner\n function setOwner(address owner) public onlyOwner {\n transferOwnership(owner);\n }\n\n /// @notice set address of the minter\n /// @param minter The address of the minter - should be wallet proxy or sales platform\n function setMinter(address minter) public onlyRole(DEFAULT_ADMIN_ROLE) {\n grantRole(MINTER_ROLE, minter);\n }\n\n /// @notice remove address of the minter\n /// @param minter The address of the minter - should be wallet proxy or sales platform\n function unsetMinter(address minter) public onlyRole(DEFAULT_ADMIN_ROLE) {\n revokeRole(MINTER_ROLE, minter);\n }\n\n /// @notice add a contract manager\n /// @param manager The address of the maanger\n function setManager(address manager) public onlyRole(DEFAULT_ADMIN_ROLE) {\n grantRole(MANAGER_ROLE, manager);\n }\n\n /// @notice add a contract manager\n /// @param manager The address of the maanger\n function unsetManager(address manager) public onlyRole(DEFAULT_ADMIN_ROLE) {\n revokeRole(MANAGER_ROLE, manager);\n }\n\n /// @notice set address of the authorizer wallet\n /// @param authorizer The address of the authorizer - should be wallet proxy or sales platform\n function setAuthorizer(address authorizer)\n public\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n QuantumSpacesStorage.layout().authorizer = authorizer;\n }\n\n /// @notice set address of the treasury wallet\n /// @param treasury The address of the treasury\n function setTreasury(address payable treasury)\n public\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n QuantumSpacesStorage.layout().quantumTreasury = treasury;\n }\n\n /// @notice set the baseURI\n /// @param baseURI new base\n function setBaseURI(string calldata baseURI)\n public\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n ERC721QStorage.layout().baseURI = baseURI;\n }\n\n /// @notice set the base ipfs URI\n /// @param ipfsURI new base\n function setIpfsURI(string calldata ipfsURI)\n public\n onlyRole(DEFAULT_ADMIN_ROLE)\n {\n QuantumSpacesStorage.layout().ipfsURI = ipfsURI;\n }\n\n /// @notice Pause contract\n function pause() public onlyRole(DEFAULT_ADMIN_ROLE) {\n _pause();\n }\n\n /// @notice Unpause contract\n function unpause() public onlyRole(DEFAULT_ADMIN_ROLE) {\n _unpause();\n }\n\n /// @notice set the IPFS CID\n /// @param dropId The drop id\n /// @param cid cid\n function setCID(uint128 dropId, string calldata cid)\n public\n onlyRole(MANAGER_ROLE)\n {\n QuantumSpacesStorage.layout().dropCID[dropId] = cid;\n }\n\n /// @notice Pauses a drop\n /// @dev Relay Only\n /// @param dropId drop to pause\n function pauseDrop(uint128 dropId) public onlyRole(MANAGER_ROLE) {\n QuantumSpacesStorage.Layout storage qs = QuantumSpacesStorage.layout();\n qs.isDropPaused.set(dropId);\n }\n\n /// @notice Unpauses a drop\n /// @dev Relay Only\n /// @param dropId drop to pause\n function unpauseDrop(uint128 dropId) public onlyRole(MANAGER_ROLE) {\n QuantumSpacesStorage.layout().isDropPaused.unset(dropId);\n }\n\n /// @notice configure a drop\n /// @param dropId The drop id\n /// @param maxSupply maximum items in the drop\n /// @param numOfVariants number of expected variants in drop (zero if normal drop)\n function setDrop(\n uint128 dropId,\n uint128 maxSupply,\n uint256 numOfVariants\n ) public onlyRole(MANAGER_ROLE) {\n QuantumSpacesStorage.layout().dropMaxSupply[dropId] = maxSupply;\n QuantumSpacesStorage.layout().dropNumOfVariants[dropId] = numOfVariants;\n }\n\n /// @notice sets the recipient of the royalties\n /// @param recipient address of the recipient\n function setRoyaltyRecipient(address recipient)\n public\n onlyRole(MANAGER_ROLE)\n {\n _royaltyRecipient = recipient;\n }\n\n /// @notice sets the fee of royalties\n /// @dev The fee denominator is 10000 in BPS.\n /// @param fee fee\n /*\n Example\n\n This would set the fee at 5%\n ```\n KeyUnlocks.setRoyaltyFee(500)\n ```\n */\n function setRoyaltyFee(uint256 fee) public onlyRole(MANAGER_ROLE) {\n _royaltyFee = fee;\n }\n\n /// @notice Set specific drop royalties and override the contract default\n /// @dev there is no check regarding limiting supply\n /// @param dropId Drop id to set the royalties for\n /// @param recipient recipient of royalties\n /// @param fee fee percentage - 5% = 500\n function setDropRoyalties(\n uint128 dropId,\n address recipient,\n uint256 fee\n ) public onlyRole(MANAGER_ROLE) {\n _dropRoyaltyRecipient[dropId] = recipient;\n _dropRoyaltyFee[dropId] = fee;\n }\n\n /// @notice Mints new tokens via a presigned authorization voucher\n /// @dev there is no check regarding limiting supply\n /// @param mintAuth preauthorization voucher\n function authorizedMint(MintAuthorization calldata mintAuth)\n public\n payable\n isNotBlackListed(mintAuth.to)\n {\n QuantumSpacesStorage.Layout storage qs = QuantumSpacesStorage.layout();\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19Ethereum Signed Message:\\n32\",\n keccak256(\n abi.encodePacked(\n mintAuth.id,\n mintAuth.to,\n mintAuth.dropId,\n mintAuth.amount,\n mintAuth.fee,\n mintAuth.validFrom,\n mintAuth.validPeriod,\n mintAuth.freezePeriod,\n mintAuth.variants\n )\n )\n )\n );\n address signer = ecrecover(digest, mintAuth.v, mintAuth.r, mintAuth.s);\n if (signer != qs.authorizer) revert InvalidAuthorizationSignature();\n if (msg.value != mintAuth.fee)\n revert IncorrectFees(mintAuth.fee, msg.value);\n if (block.timestamp <= mintAuth.validFrom)\n revert NotValidYet(mintAuth.validFrom, block.timestamp);\n if (\n mintAuth.validPeriod > 0 &&\n block.timestamp > mintAuth.validFrom + mintAuth.validPeriod\n )\n revert AuthorizationExpired(\n mintAuth.validFrom + mintAuth.validPeriod,\n block.timestamp\n );\n\n _mint(\n mintAuth.to,\n mintAuth.dropId,\n mintAuth.amount,\n mintAuth.variants,\n mintAuth.freezePeriod\n );\n AddressUpgradeable.sendValue(qs.quantumTreasury, mintAuth.fee);\n }\n\n /// @notice Mints new tokens\n /// @dev there is no check regarding limiting supply\n /// @param to recipient of newly minted tokens\n /// @param dropId id of the key\n /// @param amount amount of tokens to mint\n /// @param variants use variants/episodes for token - zero for unique drops\n function mint(\n address to,\n uint128 dropId,\n uint128 amount,\n uint256[] calldata variants,\n uint8 freezePeriod\n ) public onlyRole(MINTER_ROLE) isNotBlackListed(to) {\n _mint(to, dropId, amount, variants, freezePeriod);\n }\n\n function _mint(\n address to,\n uint128 dropId,\n uint128 amount,\n uint256[] calldata variants,\n uint8 freezePeriod\n ) internal {\n ERC721QStorage.Layout storage erc = ERC721QStorage.layout();\n QuantumSpacesStorage.Layout storage qs = QuantumSpacesStorage.layout();\n if (erc.minted[dropId] == 0) erc.minted[dropId] = 1; //If drop is not preallocated\n uint256 numOfVariants = variants.length;\n if (\n qs.dropMaxSupply[dropId] == 0 ||\n (erc.minted[dropId] - 1) + amount > qs.dropMaxSupply[dropId]\n ) revert MintExceedsDropSupply();\n if (numOfVariants != 0 && amount != numOfVariants)\n revert VariantAndMintAmountMismatch();\n\n if (qs.dropNumOfVariants[dropId] > 0 && numOfVariants == 0)\n revert InvalidVariantForDrop();\n uint256 currentVariant;\n if (numOfVariants > 0) {\n //Check each variant isn't outside range\n do {\n if (\n variants[currentVariant] < 1 ||\n variants[currentVariant++] > qs.dropNumOfVariants[dropId]\n ) revert InvalidVariantForDrop();\n } while (currentVariant < numOfVariants);\n }\n currentVariant = 0;\n\n uint256 startTokenId = TokenId.from(\n dropId,\n uint128(erc.minted[dropId] - 1)\n );\n _safeMint(to, dropId, amount, freezePeriod, \"\");\n if (numOfVariants > 0) {\n do {\n emit DropMint(\n to,\n dropId,\n variants[currentVariant],\n startTokenId + currentVariant\n );\n qs.tokenVariant[startTokenId + currentVariant++] = variants[\n currentVariant\n ];\n } while (currentVariant < numOfVariants);\n } else {\n uint256 endTokenId = startTokenId + amount;\n do {\n emit DropMint(to, dropId, 0, startTokenId++);\n } while (startTokenId < endTokenId);\n }\n }\n\n /// @notice Pre-allocate storage slots upfront for a drop\n /// @dev Relay Only\n /// @param dropId dropId to preload with gas\n /// @param quantity amount of tokens to preallocate storage space for\n function preAllocateTokens(uint128 dropId, uint128 quantity)\n public\n onlyRole(MINTER_ROLE)\n {\n _preAllocateTokens(dropId, quantity);\n }\n\n /// @notice Pre-allocate storage slots for known customers\n /// @dev Relay Only\n /// @param addresses list of addresses to register\n function preAllocateAddress(address[] calldata addresses)\n public\n onlyRole(MINTER_ROLE)\n {\n _preAllocateAddresses(addresses);\n }\n\n /// @notice Burns token that has been redeemed for something else\n /// @dev Relay Only\n /// @param tokenId id of the tokens\n function redeemBurn(uint256 tokenId) public onlyRole(MINTER_ROLE) {\n _burn(tokenId, false);\n }\n\n /// >>>>>>>>>>>>>>>>>>>>> VIEW <<<<<<<<<<<<<<<<<<<<<< ///\n\n /// @notice Returns the URI of the token\n /// @param tokenId id of the token\n /// @return URI for the token ; expected to be ipfs://<cid>\n function tokenURI(uint256 tokenId)\n public\n view\n override\n returns (string memory)\n {\n ERC721QStorage.Layout storage erc = ERC721QStorage.layout();\n QuantumSpacesStorage.Layout storage qs = QuantumSpacesStorage.layout();\n (uint128 dropId, uint128 sequenceNumber) = tokenId.split();\n uint256 actualSequence = qs.tokenVariant[tokenId] > 0\n ? qs.tokenVariant[tokenId]\n : sequenceNumber;\n if (bytes(qs.dropCID[dropId]).length > 0)\n return\n string(\n abi.encodePacked(\n qs.ipfsURI,\n qs.dropCID[dropId],\n \"/\",\n actualSequence.toString()\n )\n );\n else\n return\n string(\n abi.encodePacked(\n erc.baseURI,\n uint256(dropId).toString(),\n \"/\",\n actualSequence.toString()\n )\n );\n }\n\n /// @notice Returns the URI of the token\n /// @param dropId id of the drop to check supply on\n /// @return circulating number of minted tokens from drop\n /// @return max The maximum supply of tokens in the drop\n /// @return exists Whether the drop exists\n /// @return paused Whether the drop is paused\n function drops(uint128 dropId)\n public\n view\n returns (\n uint128 circulating,\n uint128 max,\n bool exists,\n bool paused\n )\n {\n QuantumSpacesStorage.Layout storage qs = QuantumSpacesStorage.layout();\n circulating = _mintedInDrop(dropId);\n max = qs.dropMaxSupply[dropId];\n exists = max != 0;\n paused = qs.isDropPaused.get(dropId);\n }\n\n /// >>>>>>>>>>>>>>>>>>>>> EXTERNAL <<<<<<<<<<<<<<<<<<<<<< ///\n\n /// @notice Burns token\n /// @dev Can be called by the owner or approved operator\n /// @param tokenId id of the tokens\n function burn(uint256 tokenId) public {\n _burn(tokenId, true);\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(\n ERC721QUpgradeable,\n ERC2981,\n AccessControlEnumerableUpgradeable\n )\n returns (bool)\n {\n return\n ERC721QUpgradeable.supportsInterface(interfaceId) ||\n ERC2981.supportsInterface(interfaceId) ||\n AccessControlEnumerableUpgradeable.supportsInterface(interfaceId);\n }\n\n /// >>>>>>>>>>>>>>>>>>>>> HOOKS <<<<<<<<<<<<<<<<<<<<<< ///\n\n /**\n * @dev See {ERC721-_beforeTokenTransfer}.\n *\n * Requirements:\n *\n * - the contract must not be paused.\n */\n function _beforeTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal override {\n super._beforeTokenTransfers(from, to, startTokenId, quantity);\n QuantumSpacesStorage.Layout storage qs = QuantumSpacesStorage.layout();\n if (qs.isDropPaused.get(startTokenId.dropId()))\n revert DropPaused(startTokenId.dropId());\n require(!paused(), \"Token transfer while paused\");\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
},
"src/ERC721QUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Creator: JCBDEV\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"./TokenId.sol\";\nimport \"./ERC721QStorage.sol\";\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();\nerror TokenFrozenForFraudPeriod();\nerror AddressZeroNotValid();\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension. Built to optimize for lower gas during batch mints.\n *\n * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).\n *\n * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.\n *\n * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).\n */\ncontract ERC721QUpgradeable is\n Initializable,\n ContextUpgradeable,\n ERC165Upgradeable,\n IERC721Upgradeable,\n IERC721MetadataUpgradeable\n{\n using ERC721QStorage for ERC721QStorage.Layout;\n using AddressUpgradeable for address;\n using StringsUpgradeable for uint256;\n using TokenId for uint256;\n\n function __ERC721Q_init(string memory name_, string memory symbol_)\n internal\n onlyInitializing\n {\n __ERC721Q_init_unchained(name_, symbol_);\n }\n\n function __ERC721Q_init_unchained(\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n ERC721QStorage.Layout storage s = ERC721QStorage.layout();\n s.name = name_;\n s.symbol = symbol_;\n s.supplyCounter = 1; //Everything offset by one to save on minting costs\n }\n\n /**\n * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.\n */\n function totalSupply() public view returns (uint256) {\n return ERC721QStorage.layout().supplyCounter - 1;\n }\n\n /**\n * @dev Get the number mintied in a particular drop\n */\n function _mintedInDrop(uint128 dropId) internal view returns (uint128) {\n return\n ERC721QStorage.layout().minted[dropId] == 0\n ? 0\n : ERC721QStorage.layout().minted[dropId] - 1;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC165Upgradeable, IERC165Upgradeable)\n returns (bool)\n {\n return\n interfaceId == type(IERC721Upgradeable).interfaceId ||\n interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view override returns (uint256) {\n // revert(\"test\");\n if (owner == address(0)) revert BalanceQueryForZeroAddress();\n return uint256(ERC721QStorage.layout().addressData[owner].balance);\n }\n\n /**\n * Returns the number of tokens minted by `owner`.\n */\n function _numberMinted(address owner) internal view returns (uint256) {\n return uint256(ERC721QStorage.layout().addressData[owner].numberMinted);\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 uint256(ERC721QStorage.layout().addressData[owner].numberBurned);\n }\n\n /**\n * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).\n */\n function _getAux(address owner) internal view returns (uint64) {\n return ERC721QStorage.layout().addressData[owner].aux;\n }\n\n /**\n * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used).\n * If there are multiple variables, please pack them into a uint64.\n */\n function _setAux(address owner, uint64 aux) internal {\n ERC721QStorage.layout().addressData[owner].aux = aux;\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 (TokenOwnership memory)\n {\n ERC721QStorage.Layout storage s = ERC721QStorage.layout();\n uint256 curr = tokenId;\n\n uint256 minted = _mintedInDrop(tokenId.dropId());\n\n unchecked {\n if (tokenId.firstTokenInDrop() <= curr && curr.mintId() < minted) {\n TokenOwnership memory ownership = s.ownerships[curr];\n if (!ownership.burned) {\n if (ownership.addr != address(0)) {\n return ownership;\n }\n\n if (curr != 0 && ownership.addr != address(0)) {\n return ownership;\n }\n while (curr > 0 && curr >= tokenId.firstTokenInDrop()) {\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 /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view override returns (address) {\n return _ownershipOf(tokenId).addr;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return ERC721QStorage.layout().name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return ERC721QStorage.layout().symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n ERC721QStorage.Layout storage s = ERC721QStorage.layout();\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n // string memory baseURI = _baseURI();\n // return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';\n return\n bytes(s.baseURI).length != 0\n ? string(abi.encodePacked(s.baseURI, tokenId.toString()))\n : \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public override {\n address owner = ERC721QUpgradeable.ownerOf(tokenId);\n if (to == owner) revert ApprovalToCurrentOwner();\n\n if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {\n revert ApprovalCallerNotOwnerNorApproved();\n }\n\n _approve(to, tokenId, owner);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId)\n public\n view\n override\n returns (address)\n {\n if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();\n\n return ERC721QStorage.layout().tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved)\n public\n virtual\n override\n {\n if (operator == _msgSender()) revert ApproveToCaller();\n\n ERC721QStorage.layout().operatorApprovals[_msgSender()][\n operator\n ] = approved;\n emit ApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n override\n returns (bool)\n {\n return ERC721QStorage.layout().operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public virtual override {\n _transfer(from, to, tokenId);\n if (\n to.isContract() &&\n !_checkContractOnERC721Received(from, to, tokenId, _data)\n ) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n */\n function _exists(uint256 tokenId) internal view returns (bool) {\n return\n tokenId.firstTokenInDrop() <= tokenId &&\n tokenId.mintId() < _mintedInDrop(tokenId.dropId()) &&\n !ERC721QStorage.layout().ownerships[tokenId].burned;\n }\n\n function _safeMint(\n address to,\n uint128 dropId,\n uint128 quantity,\n uint8 freezePeriod\n ) internal {\n _safeMint(to, dropId, quantity, freezePeriod, \"\");\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 uint128 dropId,\n uint128 quantity,\n uint8 freezePeriod,\n bytes memory _data\n ) internal {\n _mint(to, dropId, quantity, freezePeriod, _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 uint128 dropId,\n uint128 quantity,\n uint8 freezePeriod,\n bytes memory _data,\n bool safe\n ) internal {\n ERC721QStorage.Layout storage s = ERC721QStorage.layout();\n if (s.minted[dropId] == 0) s.minted[dropId] = 1; //If drop is not preallocated\n uint128 minted = _mintedInDrop(dropId);\n uint256 startTokenId = TokenId.from(dropId, minted);\n if (to == address(0)) revert MintToZeroAddress();\n if (quantity == 0) revert MintZeroQuantity();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\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 // New customer so delete a storage item to \"refund\" 15k gas\n\n s.addressData[to].balance += uint64(quantity);\n s.addressData[to].numberMinted += uint64(quantity);\n s.addressData[to].aux = 0;\n s.supplyCounter += quantity;\n s.ownerships[startTokenId].addr = to;\n s.ownerships[startTokenId].startTimestamp = uint64(block.timestamp);\n s.ownerships[startTokenId].freezePeriod = freezePeriod;\n s.ownerships[startTokenId]._unused = 0;\n uint128 updatedIndex = minted;\n uint128 end = updatedIndex + quantity;\n if (safe && to.isContract()) {\n do {\n uint256 tokenId = TokenId.from(dropId, updatedIndex++);\n emit Transfer(address(0), to, tokenId);\n if (\n !_checkContractOnERC721Received(\n address(0),\n to,\n tokenId,\n _data\n )\n ) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n } while (updatedIndex != end);\n // Reentrancy protection\n if (minted != startTokenId.mintId()) revert();\n } else {\n do {\n uint256 tokenId = TokenId.from(dropId, updatedIndex++);\n emit Transfer(address(0), to, tokenId);\n } while (updatedIndex != end);\n }\n s.minted[dropId] = updatedIndex + 1;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Create storage slot entries for tokens upfront to reduce minting costs at purchase\n *\n * Requirements:\n *\n * - `quantity` must be greater than 0.\n *\n */\n function _preAllocateTokens(uint128 dropId, uint128 quantity) internal {\n if (quantity == 0) revert MintZeroQuantity();\n ERC721QStorage.Layout storage s = ERC721QStorage.layout();\n\n unchecked {\n // _supplyCounter = _supplyCounter;\n s.minted[dropId] = s.minted[dropId] >= 1 ? s.minted[dropId] : 1;\n // reserveGasSlots(quantity);\n uint128 minted = _mintedInDrop(dropId);\n uint256 startTokenId = TokenId.from(dropId, minted);\n uint256 endTokenId = TokenId.from(dropId, minted + quantity - 1);\n uint256 currentTokenId = startTokenId;\n do {\n // console.log(currentTokenId);\n s.ownerships[currentTokenId++]._unused = 1;\n } while (currentTokenId <= endTokenId);\n }\n }\n\n /**\n * @dev Create storage slots upfront for new addresses\n */\n function _preAllocateAddresses(address[] calldata addresses) internal {\n uint256 currentAddress = 0;\n unchecked {\n do {\n if (addresses[currentAddress] == address(0))\n revert AddressZeroNotValid();\n ERC721QStorage\n .layout()\n .addressData[addresses[currentAddress++]]\n .aux = 1;\n } while (currentAddress < addresses.length);\n }\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 ) private {\n ERC721QStorage.Layout storage s = ERC721QStorage.layout();\n TokenOwnership memory prevOwnership = _ownershipOf(tokenId);\n if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();\n if (\n block.timestamp <=\n (uint256(prevOwnership.startTimestamp) +\n (uint256(prevOwnership.freezePeriod) * 60))\n ) revert TokenFrozenForFraudPeriod();\n\n bool isApprovedOrOwner = (_msgSender() == from ||\n isApprovedForAll(from, _msgSender()) ||\n getApproved(tokenId) == _msgSender());\n\n if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();\n if (to == address(0)) revert TransferToZeroAddress();\n\n _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 TokenOwnership storage currSlot = s.ownerships[tokenId];\n currSlot.addr = to;\n currSlot.startTimestamp = uint64(block.timestamp);\n currSlot.freezePeriod = 0;\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 TokenOwnership storage nextSlot = s.ownerships[nextTokenId];\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.mintId() != _mintedInDrop(tokenId.dropId())) {\n nextSlot.addr = from;\n nextSlot.startTimestamp = prevOwnership.startTimestamp;\n }\n }\n }\n\n emit Transfer(from, to, tokenId);\n _afterTokenTransfers(from, to, tokenId, 1);\n }\n\n /**\n * @dev This is equivalent to _burn(tokenId, false)\n */\n function _burn(uint256 tokenId) internal virtual {\n _burn(tokenId, false);\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 virtual {\n ERC721QStorage.Layout storage s = ERC721QStorage.layout();\n TokenOwnership memory prevOwnership = _ownershipOf(tokenId);\n\n address from = prevOwnership.addr;\n\n if (approvalCheck) {\n bool isApprovedOrOwner = (_msgSender() == from ||\n isApprovedForAll(from, _msgSender()) ||\n getApproved(tokenId) == _msgSender());\n\n if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();\n //TODO: Check if we need this on burn\n if (\n block.timestamp <=\n (prevOwnership.startTimestamp +\n (prevOwnership.freezePeriod * 60))\n ) revert TokenFrozenForFraudPeriod();\n }\n\n _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 uint128 dropId = tokenId.dropId();\n unchecked {\n 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 TokenOwnership storage currSlot = s.ownerships[tokenId];\n currSlot.addr = from;\n currSlot.startTimestamp = uint64(block.timestamp);\n currSlot.freezePeriod = 0;\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 TokenOwnership storage nextSlot = s.ownerships[nextTokenId];\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.mintId() < _mintedInDrop(dropId)) {\n nextSlot.addr = from;\n nextSlot.startTimestamp = prevOwnership.startTimestamp;\n }\n }\n }\n\n emit Transfer(from, address(0), tokenId);\n _afterTokenTransfers(from, address(0), tokenId, 1);\n\n // Underflow should be impossible as supplyCounter is increased for every mint\n unchecked {\n s.supplyCounter--;\n }\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 ) private {\n ERC721QStorage.layout().tokenApprovals[tokenId] = to;\n emit Approval(owner, to, tokenId);\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 ) private returns (bool) {\n try\n IERC721ReceiverUpgradeable(to).onERC721Received(\n _msgSender(),\n from,\n tokenId,\n _data\n )\n returns (bytes4 retval) {\n return\n retval ==\n IERC721ReceiverUpgradeable(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 /**\n * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.\n * And also called before burning one token.\n *\n * startTokenId - the first token id to be transferred\n * quantity - the amount to be transferred\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _beforeTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes\n * minting.\n * And also called after one token has been burned.\n *\n * startTokenId - the first token id to be transferred\n * quantity - the amount to be transferred\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been\n * transferred to `to`.\n * - When `from` is zero, `tokenId` has been minted for `to`.\n * - When `to` is zero, `tokenId` has been burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _afterTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[42] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {\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 function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerableUpgradeable.sol\";\nimport \"./AccessControlUpgradeable.sol\";\nimport \"../utils/structs/EnumerableSetUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {\n function __AccessControlEnumerable_init() internal onlyInitializing {\n }\n\n function __AccessControlEnumerable_init_unchained() internal onlyInitializing {\n }\n using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;\n\n mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.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 StringsUpgradeable {\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"
},
"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {\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 bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\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 require(!paused(), \"Pausable: paused\");\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 require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.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 AddressUpgradeable {\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 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-upgradeable/proxy/utils/UUPSUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport \"./Initializable.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {\n function __UUPSUpgradeable_init() internal onlyInitializing {\n }\n\n function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\n }\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable __self = address(this);\n\n /**\n * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n * fail.\n */\n modifier onlyProxy() {\n require(address(this) != __self, \"Function must be called through delegatecall\");\n require(_getImplementation() == __self, \"Function must be called through active proxy\");\n _;\n }\n\n /**\n * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n * callable on the implementing contract but not through proxies.\n */\n modifier notDelegated() {\n require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n _;\n }\n\n /**\n * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n * implementation. It is used to validate that the this implementation remains valid after an upgrade.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n */\n function proxiableUUID() external view virtual override notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeTo(address newImplementation) external virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n * encoded in `data`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data, true);\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeTo} and {upgradeToAndCall}.\n *\n * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n *\n * ```solidity\n * function _authorizeUpgrade(address) internal override onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) internal virtual;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/structs/BitMapsUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/BitMaps.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential.\n * Largelly inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor].\n */\nlibrary BitMapsUpgradeable {\n struct BitMap {\n mapping(uint256 => uint256) _data;\n }\n\n /**\n * @dev Returns whether the bit at `index` is set.\n */\n function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {\n uint256 bucket = index >> 8;\n uint256 mask = 1 << (index & 0xff);\n return bitmap._data[bucket] & mask != 0;\n }\n\n /**\n * @dev Sets the bit at `index` to the boolean `value`.\n */\n function setTo(\n BitMap storage bitmap,\n uint256 index,\n bool value\n ) internal {\n if (value) {\n set(bitmap, index);\n } else {\n unset(bitmap, index);\n }\n }\n\n /**\n * @dev Sets the bit at `index`.\n */\n function set(BitMap storage bitmap, uint256 index) internal {\n uint256 bucket = index >> 8;\n uint256 mask = 1 << (index & 0xff);\n bitmap._data[bucket] |= mask;\n }\n\n /**\n * @dev Unsets the bit at `index`.\n */\n function unset(BitMap storage bitmap, uint256 index) internal {\n uint256 bucket = index >> 8;\n uint256 mask = 1 << (index & 0xff);\n bitmap._data[bucket] &= ~mask;\n }\n}\n"
},
"src/ERC2981V3.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Creator: JCBDEV (Quantum Art)\npragma solidity >=0.8.0;\n\n/// @title Minimalist ERC2981 implementation.\n/// @notice To be used within Quantum, as it was written for its needs.\n/// @author JCBDEV (Quantum Art)\nabstract contract ERC2981 {\n //TODO: Library for token functions\n function __dropIdOf(uint256 tokenId) private pure returns (uint128) {\n return uint128(tokenId >> 128);\n }\n\n /// @dev default global fee for all royalties.\n uint256 internal _royaltyFee;\n /// @dev default global recipient for all royalties.\n address internal _royaltyRecipient;\n\n mapping(uint128 => uint256) internal _dropRoyaltyFee;\n mapping(uint128 => address) internal _dropRoyaltyRecipient;\n\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n public\n view\n virtual\n returns (address receiver, uint256 royaltyAmount)\n {\n uint128 dropId = __dropIdOf(tokenId);\n uint256 dropFee = _dropRoyaltyRecipient[dropId] != address(0)\n ? _dropRoyaltyFee[dropId]\n : _royaltyFee;\n receiver = _dropRoyaltyRecipient[dropId] != address(0)\n ? _dropRoyaltyRecipient[dropId]\n : _royaltyRecipient;\n royaltyAmount = (salePrice * dropFee) / 10000;\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n returns (bool)\n {\n return\n interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165\n interfaceId == 0x2a55205a; // ERC165 Interface ID for ERC2981\n }\n}\n"
},
"src/TokenId.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Creator: JCBDEV (Quantum Art)\n\npragma solidity ^0.8.4;\n\nlibrary TokenId {\n uint256 private constant _baseIdMask = ~uint256(type(uint128).max);\n\n /// @notice Generate a token id\n /// @param drop The drop id the token belongs to\n /// @param mint The sequence number of the token minted\n /// @return tokenId the token id\n function from(uint128 drop, uint128 mint)\n internal\n pure\n returns (uint256 tokenId)\n {\n tokenId |= uint256(drop) << 128;\n tokenId |= uint256(mint);\n\n return tokenId;\n }\n\n /// @notice Get the first token Id in the range for the same stop as the token id\n /// @param tokenId The token id to check the drop range\n /// @return uint128 the first token in this drop range\n function firstTokenInDrop(uint256 tokenId) internal pure returns (uint256) {\n return tokenId & _baseIdMask;\n }\n\n /// @notice extract the drop id from the token id\n /// @param tokenId The token id to extract the values from\n /// @return uint128 the drop id\n function dropId(uint256 tokenId) internal pure returns (uint128) {\n return uint128(tokenId >> 128);\n }\n\n /// @notice extract the sequence number from the token id\n /// @param tokenId The token id to extract the values from\n /// @return uint128 the sequence number\n function mintId(uint256 tokenId) internal pure returns (uint128) {\n return uint128(tokenId);\n }\n\n /// @notice extract the drop id and the sequence number from the token id\n /// @param tokenId The token id to extract the values from\n /// @return uint128 the drop id\n /// @return uint128 the sequence number\n function split(uint256 tokenId) internal pure returns (uint128, uint128) {\n return (uint128(tokenId >> 128), uint128(tokenId));\n }\n}\n"
},
"src/ManageableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol\";\n\nabstract contract ManageableUpgradeable is AccessControlEnumerableUpgradeable {\n bytes32 public constant MANAGER_ROLE = keccak256(\"MANAGER_ROLE\");\n\n function __Manageable_init() internal onlyInitializing {\n __AccessControl_init_unchained();\n __Manageable_init_unchained();\n }\n\n function __Manageable_init_unchained() internal onlyInitializing {\n }\n}"
},
"src/QuantumBlackListable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.11;\n\nimport \"./QuantumBlackList.sol\";\n\n// contracts that want to implement blackListing on specific methods (e.g. minting) can and use the functions in this library\n// due to issues with upgrading storage on already deployed contracts, the blackListContractAddress must be stored in the contract itself\n\nlibrary QuantumBlackListable {\n error BlackListedAddress(address _address);\n error InvalidBlackListAddress();\n error BlackListedAddressNotSet();\n\n function isBlackListed(address user, address blContractAddress)\n internal\n view\n returns (bool)\n {\n QuantumBlackList qbl = QuantumBlackList(blContractAddress);\n\n if (blContractAddress == address(0)) {\n revert BlackListedAddressNotSet();\n }\n\n if (qbl.isBlackListed(user)) {\n return true;\n }\n return false;\n }\n}\n"
},
"src/QuantumSpacesStorage.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/structs/BitMapsUpgradeable.sol\";\n\nstruct MintAuthorization {\n uint256 id;\n address to;\n uint128 dropId;\n uint128 amount;\n uint256 fee;\n bytes32 r;\n bytes32 s;\n uint256 validFrom;\n uint256 validPeriod;\n uint8 v;\n uint8 freezePeriod;\n uint256[] variants;\n}\n\nlibrary QuantumSpacesStorage {\n using BitMapsUpgradeable for BitMapsUpgradeable.BitMap;\n\n struct Layout {\n mapping(uint128 => string) dropCID;\n mapping(uint128 => uint128) dropMaxSupply;\n mapping(uint256 => uint256) tokenVariant;\n mapping(uint128 => uint256) dropNumOfVariants;\n BitMapsUpgradeable.BitMap isDropPaused;\n string ipfsURI;\n address authorizer;\n address payable quantumTreasury;\n address blackListAddress;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256(\"quantum.contracts.storage.quantumspaces.v1\");\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n//QuantumSpacesStorage.Layout storage qs = QuantumSpacesStorage.layout();\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\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`, 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 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 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 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 /**\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"
},
"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.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 IERC721ReceiverUpgradeable {\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"
},
"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.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 \"../IERC721Upgradeable.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 IERC721MetadataUpgradeable is IERC721Upgradeable {\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"
},
"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n // contract may have been reentered.\n require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} modifier, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n function _isConstructor() private view returns (bool) {\n return !AddressUpgradeable.isContract(address(this));\n }\n}\n"
},
"src/ERC721QStorage.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n// // Compiler will pack this into a single 256bit word.\nstruct 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 // Prevent forward transfer for up to max 256 hours (fraud)\n uint8 freezePeriod;\n // Unused\n uint16 _unused;\n // Whether the token has been burned.\n bool burned;\n bool isPre;\n}\n\n// Compiler will pack this into a single 256bit word.\nstruct 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;\n}\n\nlibrary ERC721QStorage {\n struct Layout {\n // The tokenId of the next token to be minted.\n // Contract should always be offset by 1 everytime a mint starts (for preallocation gas savings)\n mapping(uint128 => uint128) minted;\n // The number of tokens.\n uint256 supplyCounter; //offset by 1 to save gas on mint 0\n // Token name\n string name;\n // Token symbol\n string symbol;\n string baseURI;\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 bytes32 internal constant STORAGE_SLOT =\n keccak256(\"quantum.contracts.storage.erc721q.v1\");\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n//ERC721QStorage.Layout storage erc = ERC721QStorage.layout();\n"
},
"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.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 IERC165Upgradeable {\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"
},
"@openzeppelin/contracts-upgradeable/access/IAccessControlEnumerableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n"
},
"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlUpgradeable.sol\";\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../utils/StringsUpgradeable.sol\";\nimport \"../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\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, _msgSender());\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _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 function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n StringsUpgradeable.toHexString(uint160(account), 20),\n \" is missing role \",\n StringsUpgradeable.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) public view virtual override returns (bytes32) {\n return _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) public virtual override onlyRole(getRoleAdmin(role)) {\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) public virtual override onlyRole(getRoleAdmin(role)) {\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) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(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 virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _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 virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\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 virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSetUpgradeable {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n"
},
"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.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 IAccessControlUpgradeable {\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-upgradeable/interfaces/draft-IERC1822Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822ProxiableUpgradeable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n"
},
"@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeaconUpgradeable.sol\";\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport \"../utils/Initializable.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967UpgradeUpgradeable is Initializable {\n function __ERC1967Upgrade_init() internal onlyInitializing {\n }\n\n function __ERC1967Upgrade_init_unchained() internal onlyInitializing {\n }\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n _functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(\n address newImplementation,\n bytes memory data,\n bool forceCall\n ) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {AdminChanged} event.\n */\n function _changeAdmin(address newAdmin) internal {\n emit AdminChanged(_getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Emitted when the beacon is upgraded.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Returns the current beacon.\n */\n function _getBeacon() internal view returns (address) {\n return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n require(AddressUpgradeable.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(\n address newBeacon,\n bytes memory data,\n bool forceCall\n ) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n }\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(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return AddressUpgradeable.verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"
},
"@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeaconUpgradeable {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlotUpgradeable {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n assembly {\n r.slot := slot\n }\n }\n}\n"
},
"src/QuantumBlackList.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.11;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport \"./interfaces/IQuantumBlackList.sol\";\nimport \"./QuantumBlackListStorage.sol\";\nimport \"./ManageableUpgradeable.sol\";\n\nerror AlreadyBlackListed();\nerror NotBlackListed(address _address);\n\ncontract QuantumBlackList is\n IQuantumBlackList,\n OwnableUpgradeable,\n ManageableUpgradeable,\n UUPSUpgradeable\n{\n using QuantumBlackListStorage for QuantumBlackListStorage.Layout;\n\n event BlackListAddress(address indexed user, bool isBlackListed);\n\n /// >>>>>>>>>>>>>>>>>>>>> INITIALIZER <<<<<<<<<<<<<<<<<<<<<< ///\n\n function initialize(address admin) public initializer {\n __QuantumBlackList_init(admin);\n }\n\n function __QuantumBlackList_init(address admin) internal onlyInitializing {\n __Ownable_init();\n __UUPSUpgradeable_init();\n __QuantumBlackList_init_unchained(admin);\n }\n\n function __QuantumBlackList_init_unchained(address admin)\n internal\n onlyInitializing\n {\n _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _setupRole(MANAGER_ROLE, msg.sender);\n _setupRole(DEFAULT_ADMIN_ROLE, admin);\n _setupRole(MANAGER_ROLE, admin);\n }\n\n /// >>>>>>>>>>>>>>>>>>>>> PERMISSIONS <<<<<<<<<<<<<<<<<<<<<< ///\n\n function _authorizeUpgrade(address newImplementation)\n internal\n override\n onlyOwner\n {}\n\n /// @notice set address of the minter\n /// @param owner The address of the new owner\n function setOwner(address owner) public onlyOwner {\n transferOwnership(owner);\n }\n\n /// @notice add a contract manager\n /// @param manager The address of the maanger\n function setManager(address manager) public onlyRole(DEFAULT_ADMIN_ROLE) {\n grantRole(MANAGER_ROLE, manager);\n }\n\n /// @notice add a contract manager\n /// @param manager The address of the maanger\n function unsetManager(address manager) public onlyRole(DEFAULT_ADMIN_ROLE) {\n revokeRole(MANAGER_ROLE, manager);\n }\n\n /// >>>>>>>>>>>>>>>>>>>>> CORE FUNCTIONALITY <<<<<<<<<<<<<<<<<<<<<< ///\n\n /// @notice bulk add addresses to blackList\n /// @param users The list of address to add to the blackList\n function addToBlackList(address[] calldata users)\n public\n onlyRole(MANAGER_ROLE)\n {\n QuantumBlackListStorage.Layout storage qbl = QuantumBlackListStorage\n .layout();\n\n for (uint256 i = 0; i < users.length; i++) {\n address user = users[i];\n\n if (user != address(0) && !qbl.blackList[user]) {\n qbl.blackList[user] = true;\n emit BlackListAddress(user, true);\n }\n }\n }\n\n /// @notice remove single address from blackList\n /// @param user The address to remove from the blackList\n function removeFromBlackList(address user) public onlyRole(MANAGER_ROLE) {\n QuantumBlackListStorage.Layout storage qbl = QuantumBlackListStorage\n .layout();\n\n if (qbl.blackList[user]) {\n qbl.blackList[user] = false;\n emit BlackListAddress(user, false);\n } else {\n revert NotBlackListed(user);\n }\n }\n\n function isBlackListed(address user) public view returns (bool) {\n return QuantumBlackListStorage.layout().blackList[user];\n }\n}\n"
},
"src/interfaces/IQuantumBlackList.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.11;\n\ninterface IQuantumBlackList {\n function initialize(address admin) external;\n\n function addToBlackList(address[] calldata users) external;\n\n function removeFromBlackList(address user) external;\n\n function isBlackListed(address user) external view returns (bool);\n}\n"
},
"src/QuantumBlackListStorage.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.11;\n\nlibrary QuantumBlackListStorage {\n struct Layout {\n mapping(address => bool) blackList;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n keccak256(\"quantum.contracts.storage.quantumblacklist.v1\");\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}