zellic-audit
Initial commit
f998fcd
raw
history blame
157 kB
{
"language": "Solidity",
"sources": {
"contracts/CNPBaby.sol": {
"content": "// SPDX-License-Identifier: MIT\r\npragma solidity >=0.7.0 <0.9.0;\r\n\r\nimport \"contract-allow-list/contracts/ERC721AntiScam/restrictApprove/ERC721RestrictApprove.sol\";\r\nimport \"@openzeppelin/contracts/access/AccessControl.sol\";\r\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport \"@openzeppelin/contracts/utils/cryptography/MerkleProof.sol\";\r\nimport \"@openzeppelin/contracts/token/common/ERC2981.sol\";\r\nimport \"operator-filter-registry/src/RevokableDefaultOperatorFilterer.sol\";\r\nimport \"operator-filter-registry/src/UpdatableOperatorFilterer.sol\";\r\n\r\n//tokenURI interface\r\ninterface iTokenURI {\r\n function tokenURI(uint256 _tokenId) external view returns (string memory);\r\n}\r\n\r\ncontract CNPBaby is\r\n AccessControl,\r\n Ownable,\r\n RevokableDefaultOperatorFilterer,\r\n ERC2981,\r\n ERC721RestrictApprove\r\n{\r\n // == Constants ==\r\n bytes32 public constant ADMIN = keccak256(\"ADMIN\");\r\n bytes32 public constant AIRDROP_ROLE = keccak256(\"AIRDROP_ROLE\");\r\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\r\n bytes32 public constant BURNER_ROLE = keccak256(\"BURNER_ROLE\");\r\n\r\n address public constant HITODUMADAO_ADDRESS =\r\n 0x376E2F69A4cF1E73A444055291F9b250166746a9;\r\n\r\n address public constant WITHDRAW_ADDRESS = HITODUMADAO_ADDRESS;\r\n\r\n // == For Creator fee ==\r\n address public royaltyAddress = HITODUMADAO_ADDRESS;\r\n uint96 public royaltyFee; // 0%, changable.\r\n\r\n constructor() ERC721Psi(\"CNP Baby\", \"CNPB\") {\r\n //Role initialization\r\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\r\n _grantRole(AIRDROP_ROLE, msg.sender);\r\n _grantRole(BURNER_ROLE, msg.sender);\r\n _grantRole(ADMIN, msg.sender);\r\n _grantRole(ADMIN, HITODUMADAO_ADDRESS);\r\n _grantRole(AIRDROP_ROLE, HITODUMADAO_ADDRESS);\r\n\r\n // Psiは0スタートなので、あとでバーンする\r\n _safeMint(msg.sender, 1);\r\n\r\n // ロイヤリティ0セット\r\n _setDefaultRoyalty(payable(HITODUMADAO_ADDRESS), 0);\r\n }\r\n\r\n //\r\n // withdraw section\r\n //\r\n function withdraw() external payable onlyRole(ADMIN) {\r\n (bool os, ) = payable(WITHDRAW_ADDRESS).call{\r\n value: address(this).balance\r\n }(\"\");\r\n require(os);\r\n }\r\n\r\n //\r\n // Royalty setting\r\n // ロイヤリティパーセンテージセット(10%なら1000)\r\n // \r\n function setRoyaltyFee(uint96 _feeNumerator) external onlyRole(ADMIN) {\r\n royaltyFee = _feeNumerator;\r\n _setDefaultRoyalty(royaltyAddress, royaltyFee);\r\n }\r\n\r\n // ロイヤリティ受け取りアドレスセット\r\n function setRoyaltyAddress(\r\n address _royaltyAddress\r\n ) external onlyRole(ADMIN) {\r\n royaltyAddress = _royaltyAddress;\r\n _setDefaultRoyalty(royaltyAddress, royaltyFee);\r\n }\r\n\r\n //\r\n // mint section\r\n //\r\n uint256 public cost; // freemint:0\r\n uint256 public maxSupply = 10000; // 総数1万\r\n uint256 public maxMintAmountPerTransaction = 60; //1トランザクションごとのミント最大数\r\n bool public paused = true; // コントラクトの停止フラグ\r\n bool public burnAndMintMode; //バー忍モードフラグ:false\r\n bytes32 public merkleRoot; // マークルツリールート\r\n uint256 public saleId; // ALセールからバー忍実施の時にミント済み数をリセットするため:0\r\n mapping(uint256 => mapping(address => uint256)) public userMintedAmount; // 前回ミント済み数\r\n\r\n modifier callerIsUser() {\r\n require(tx.origin == msg.sender, \"The caller is another contract.\");\r\n _;\r\n }\r\n\r\n //mint with merkle tree\r\n function mint(\r\n uint256 _mintAmount,\r\n uint256 _maxMintAmount,\r\n bytes32[] calldata _merkleProof,\r\n uint256 _burnId\r\n ) external payable callerIsUser {\r\n // コントラクトがポーズ状態ではないか\r\n require(!paused, \"the contract is paused\");\r\n // ミントサイトから入力されたミント数量が1以上か\r\n require(0 < _mintAmount, \"need to mint at least 1 NFT\");\r\n // 1トランザクションの最大ミント数以下か\r\n require(_mintAmount <= maxMintAmountPerTransaction, \"max mint amount per session exceeded\");\r\n // 現在のトークンIDとミント数量を合わせても最大供給量を超えないか\r\n require(\r\n _nextTokenId() - 1 + _mintAmount <= maxSupply,\r\n \"max NFT limit exceeded\"\r\n );\r\n // コスト×ミント数量より手持ちのETHが多いか\r\n require(cost * _mintAmount <= msg.value, \"insufficient funds\");\r\n\r\n //Merkle tree\r\n bytes32 leaf = keccak256(abi.encodePacked(msg.sender, _maxMintAmount));\r\n\r\n // ALに登録されているか\r\n require(\r\n MerkleProof.verifyCalldata(_merkleProof, merkleRoot, leaf),\r\n \"user is not allowlisted\"\r\n );\r\n\r\n // 今回ミント数量は「アドレスごとの最大ミント許可数ー前回ミント済み数」以下か\r\n require(\r\n _mintAmount <=\r\n _maxMintAmount - userMintedAmount[saleId][msg.sender],\r\n \"max NFT per address exceeded\"\r\n );\r\n\r\n // ミント済み数量に今回ミント数を加算\r\n userMintedAmount[saleId][msg.sender] += _mintAmount;\r\n\r\n // バー忍モードか\r\n if (burnAndMintMode == true) {\r\n require(_mintAmount == 1, \"The number of mints is over\");\r\n require(msg.sender == ownerOf(_burnId), \"Owner is different\");\r\n _burn(_burnId);\r\n }\r\n\r\n // ミント数量分ミント処理を行う\r\n _safeMint(msg.sender, _mintAmount);\r\n }\r\n\r\n // エアドロミント\r\n function airdropMint(\r\n address[] calldata _airdropAddresses,\r\n uint256[] memory _UserMintAmount\r\n ) external {\r\n require(\r\n hasRole(AIRDROP_ROLE, msg.sender),\r\n \"Caller is not a air dropper\"\r\n );\r\n require(\r\n _airdropAddresses.length == _UserMintAmount.length,\r\n \"Array lengths are different\"\r\n );\r\n uint256 _mintAmount = 0;\r\n for (uint256 i = 0; i < _UserMintAmount.length; i++) {\r\n require(0 < _UserMintAmount[i], \"need to mint at least 1 NFT\");\r\n _mintAmount += _UserMintAmount[i];\r\n }\r\n require(\r\n (_nextTokenId() - 1) + _mintAmount <= maxSupply,\r\n \"max NFT limit exceeded\"\r\n );\r\n for (uint256 i = 0; i < _UserMintAmount.length; i++) {\r\n _safeMint(_airdropAddresses[i], _UserMintAmount[i]);\r\n }\r\n }\r\n\r\n // バー忍モードフラグ セット関数\r\n function setBurnAndMintMode(\r\n bool _burnAndMintMode\r\n ) external onlyRole(ADMIN) {\r\n burnAndMintMode = _burnAndMintMode;\r\n }\r\n\r\n // マークルルート セット関数\r\n function setMerkleRoot(bytes32 _merkleRoot) external onlyRole(ADMIN) {\r\n merkleRoot = _merkleRoot;\r\n }\r\n\r\n // セール停止フラグ セット関数\r\n function setPause(bool _state) external onlyRole(ADMIN) {\r\n paused = _state;\r\n }\r\n\r\n // セールID セット関数\r\n function setSaleId(uint256 _saleId) external onlyRole(ADMIN) {\r\n saleId = _saleId;\r\n }\r\n\r\n // NFTの総数 セット関数\r\n function setMaxSupply(uint256 _maxSupply) external onlyRole(ADMIN) {\r\n maxSupply = _maxSupply;\r\n }\r\n\r\n // NFTの値段 セット関数\r\n function setCost(uint256 _newCost) external onlyRole(ADMIN) {\r\n cost = _newCost;\r\n }\r\n\r\n // 1回の処理で最大ミントできる枚数 セット関数\r\n function setMaxMintAmountPerTransaction(\r\n uint256 _maxMintAmountPerTransaction\r\n ) external onlyRole(ADMIN) {\r\n maxMintAmountPerTransaction = _maxMintAmountPerTransaction;\r\n }\r\n\r\n // ALに登録されている人がどれだけすでにミントしたかセールIDごとに取得する関数\r\n function getUserMintedAmountBySaleId(\r\n uint256 _saleId,\r\n address _address\r\n ) external view returns (uint256) {\r\n return userMintedAmount[_saleId][_address];\r\n }\r\n\r\n // ALに登録されている人がどれだけすでにミントしたか取得する関数\r\n function getUserMintedAmount(\r\n address _address\r\n ) external view returns (uint256) {\r\n return userMintedAmount[saleId][_address];\r\n }\r\n\r\n //\r\n //URI section\r\n //\r\n string public baseURI;\r\n string public baseExtension = \".json\";\r\n\r\n // JSONを取得するパスを保持する\r\n function _baseURI() internal view virtual override returns (string memory) {\r\n return baseURI;\r\n }\r\n\r\n // JSONを取得するパスを保持する セット関数\r\n function setBaseURI(string memory _newBaseURI) external onlyRole(ADMIN) {\r\n baseURI = _newBaseURI;\r\n }\r\n\r\n // JSONの拡張子を変更する セット関数\r\n function setBaseExtension(\r\n string memory _newBaseExtension\r\n ) external onlyRole(ADMIN) {\r\n baseExtension = _newBaseExtension;\r\n }\r\n\r\n //\r\n //interface metadata\r\n //\r\n\r\n iTokenURI public interfaceOfTokenURI;\r\n bool public useInterfaceMetadata = false;\r\n\r\n function setInterfaceOfTokenURI(address _address) external onlyRole(ADMIN) {\r\n interfaceOfTokenURI = iTokenURI(_address);\r\n }\r\n\r\n function setUseInterfaceMetadata(bool _useInterfaceMetadata) external onlyRole(ADMIN) {\r\n useInterfaceMetadata = _useInterfaceMetadata;\r\n }\r\n\r\n\r\n //\r\n //token URI\r\n //\r\n function tokenURI(uint256 tokenId) public view override returns (string memory) {\r\n if (useInterfaceMetadata == true) {\r\n return interfaceOfTokenURI.tokenURI(tokenId);\r\n }\r\n \r\n return string(abi.encodePacked(ERC721Psi.tokenURI(tokenId), baseExtension));\r\n }\r\n\r\n //\r\n //burnin' section\r\n //\r\n function externalMint(address _address, uint256 _amount) external payable {\r\n require(hasRole(MINTER_ROLE, msg.sender), \"Caller is not a minter\");\r\n require(\r\n _nextTokenId() - 1 + _amount <= maxSupply,\r\n \"max NFT limit exceeded\"\r\n );\r\n _safeMint(_address, _amount);\r\n }\r\n\r\n function externalBurn(uint256[] memory _burnTokenIds) external {\r\n require(hasRole(BURNER_ROLE, msg.sender), \"Caller is not a burner\");\r\n for (uint256 i = 0; i < _burnTokenIds.length; i++) {\r\n uint256 tokenId = _burnTokenIds[i];\r\n require(msg.sender == ownerOf(tokenId), \"Owner is different\");\r\n _burn(tokenId);\r\n }\r\n }\r\n\r\n //\r\n // override ERC721RestrictApprove\r\n //\r\n function addLocalContractAllowList(\r\n address transferer\r\n ) external onlyRole(ADMIN) {\r\n _addLocalContractAllowList(transferer);\r\n }\r\n\r\n function removeLocalContractAllowList(\r\n address transferer\r\n ) external onlyRole(ADMIN) {\r\n _removeLocalContractAllowList(transferer);\r\n }\r\n\r\n function getLocalContractAllowList()\r\n external\r\n view\r\n returns (address[] memory)\r\n {\r\n return _getLocalContractAllowList();\r\n }\r\n\r\n function setCAL(address calAddress) external onlyRole(ADMIN) {\r\n _setCAL(calAddress);\r\n }\r\n\r\n function setCALLevel(uint256 level) external onlyRole(ADMIN) {\r\n CALLevel = level;\r\n }\r\n\r\n function setEnableRestrict(bool value) external onlyRole(ADMIN) {\r\n enableRestrict = value;\r\n }\r\n\r\n //\r\n //setDefaultRoyalty\r\n //\r\n function setDefaultRoyalty(\r\n address _receiver,\r\n uint96 _feeNumerator\r\n ) external onlyOwner {\r\n _setDefaultRoyalty(_receiver, _feeNumerator);\r\n }\r\n\r\n //\r\n // override section\r\n //\r\n function grantRole(\r\n bytes32 role,\r\n address account\r\n ) public override onlyOwner {\r\n _grantRole(role, account);\r\n }\r\n\r\n function revokeRole(\r\n bytes32 role,\r\n address account\r\n ) public override onlyOwner {\r\n _revokeRole(role, account);\r\n }\r\n\r\n // OVERRIDES OperatorFilter functions\r\n function setApprovalForAll(\r\n address operator,\r\n bool approved\r\n ) public override onlyAllowedOperatorApproval(operator) {\r\n super.setApprovalForAll(operator, approved);\r\n }\r\n\r\n function approve(\r\n address operator,\r\n uint256 tokenId\r\n ) public override onlyAllowedOperatorApproval(operator) {\r\n super.approve(operator, tokenId);\r\n }\r\n\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) public override onlyAllowedOperator(from) {\r\n super.transferFrom(from, to, tokenId);\r\n }\r\n\r\n function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {\r\n super.safeTransferFrom(from, to, tokenId);\r\n }\r\n\r\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override onlyAllowedOperator(from) {\r\n super.safeTransferFrom(from, to, tokenId, data);\r\n }\r\n\r\n function owner()\r\n public\r\n view\r\n virtual\r\n override(Ownable, UpdatableOperatorFilterer)\r\n returns (address)\r\n {\r\n return Ownable.owner();\r\n }\r\n\r\n function totalSupply() public view override returns (uint256) {\r\n return super.totalSupply();\r\n }\r\n\r\n //\r\n //ERC721PsiAddressData section\r\n //\r\n\r\n // Mapping owner address to address data\r\n mapping(address => AddressData) _addressData;\r\n\r\n // Compiler will pack this into a single 256bit word.\r\n struct AddressData {\r\n // Realistically, 2**64-1 is more than enough.\r\n uint64 balance;\r\n // Keeps track of mint count with minimal overhead for tokenomics.\r\n uint64 numberMinted;\r\n // Keeps track of burn count with minimal overhead for tokenomics.\r\n uint64 numberBurned;\r\n // For miscellaneous variable(s) pertaining to the address\r\n // (e.g. number of whitelist mint slots used).\r\n // If there are multiple variables, please pack them into a uint64.\r\n uint64 aux;\r\n }\r\n\r\n /**\r\n * @dev See {IERC721-balanceOf}.\r\n */\r\n function balanceOf(\r\n address _owner\r\n ) public view virtual override returns (uint) {\r\n require(\r\n _owner != address(0),\r\n \"ERC721Psi: balance query for the zero address\"\r\n );\r\n return uint256(_addressData[_owner].balance);\r\n }\r\n\r\n /**\r\n * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes\r\n * minting.\r\n *\r\n * startTokenId - the first token id to be transferred\r\n * quantity - the amount to be transferred\r\n *\r\n * Calling conditions:\r\n *\r\n * - when `from` and `to` are both non-zero.\r\n * - `from` and `to` are never both zero.\r\n */\r\n function _afterTokenTransfers(\r\n address from,\r\n address to,\r\n uint256 startTokenId,\r\n uint256 quantity\r\n ) internal virtual override {\r\n require(quantity < 2 ** 64);\r\n uint64 _quantity = uint64(quantity);\r\n\r\n if (from != address(0)) {\r\n _addressData[from].balance -= _quantity;\r\n } else {\r\n // Mint\r\n _addressData[to].numberMinted += _quantity;\r\n }\r\n\r\n if (to != address(0)) {\r\n _addressData[to].balance += _quantity;\r\n } else {\r\n // Burn\r\n _addressData[from].numberBurned += _quantity;\r\n }\r\n super._afterTokenTransfers(from, to, startTokenId, quantity);\r\n }\r\n\r\n function supportsInterface(bytes4 interfaceId)\r\n public\r\n view\r\n override(ERC2981,ERC721RestrictApprove, AccessControl)\r\n returns (bool)\r\n {\r\n return\r\n ERC2981.supportsInterface(interfaceId) ||\r\n AccessControl.supportsInterface(interfaceId) ||\r\n ERC721RestrictApprove.supportsInterface(interfaceId);\r\n }\r\n}\r\n"
},
"operator-filter-registry/src/UpdatableOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title UpdatableOperatorFilterer\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry. This contract allows the Owner to update the\n * OperatorFilterRegistry address via updateOperatorFilterRegistryAddress, including to the zero address,\n * which will bypass registry checks.\n * Note that OpenSea will still disable creator earnings enforcement if filtered operators begin fulfilling orders\n * on-chain, eg, if the registry is revoked or bypassed.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract UpdatableOperatorFilterer {\n /// @dev Emitted when an operator is not allowed.\n error OperatorNotAllowed(address operator);\n /// @dev Emitted when someone other than the owner is trying to call an only owner function.\n error OnlyOwner();\n\n event OperatorFilterRegistryAddressUpdated(address newRegistry);\n\n IOperatorFilterRegistry public operatorFilterRegistry;\n\n /// @dev The constructor that is called when the contract is being deployed.\n constructor(address _registry, address subscriptionOrRegistrantToCopy, bool subscribe) {\n IOperatorFilterRegistry registry = IOperatorFilterRegistry(_registry);\n operatorFilterRegistry = registry;\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(registry).code.length > 0) {\n if (subscribe) {\n registry.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n registry.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n registry.register(address(this));\n }\n }\n }\n }\n\n /**\n * @dev A helper function to check if the operator is allowed.\n */\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n /**\n * @dev A helper function to check if the operator approval is allowed.\n */\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n /**\n * @notice Update the address that the contract will make OperatorFilter checks against. When set to the zero\n * address, checks will be bypassed. OnlyOwner.\n */\n function updateOperatorFilterRegistryAddress(address newRegistry) public virtual {\n if (msg.sender != owner()) {\n revert OnlyOwner();\n }\n operatorFilterRegistry = IOperatorFilterRegistry(newRegistry);\n emit OperatorFilterRegistryAddressUpdated(newRegistry);\n }\n\n /**\n * @dev Assume the contract has an owner, but leave specific Ownable implementation up to inheriting contract.\n */\n function owner() public view virtual returns (address);\n\n /**\n * @dev A helper function to check if the operator is allowed.\n */\n function _checkFilterOperator(address operator) internal view virtual {\n IOperatorFilterRegistry registry = operatorFilterRegistry;\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(registry) != address(0) && address(registry).code.length > 0) {\n // under normal circumstances, this function will revert rather than return false, but inheriting contracts\n // may specify their own OperatorFilterRegistry implementations, which may behave differently\n if (!registry.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"operator-filter-registry/src/RevokableDefaultOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {RevokableOperatorFilterer} from \"./RevokableOperatorFilterer.sol\";\nimport {CANONICAL_CORI_SUBSCRIPTION, CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS} from \"./lib/Constants.sol\";\n/**\n * @title RevokableDefaultOperatorFilterer\n * @notice Inherits from RevokableOperatorFilterer and automatically subscribes to the default OpenSea subscription.\n * Note that OpenSea will disable creator earnings enforcement if filtered operators begin fulfilling orders\n * on-chain, eg, if the registry is revoked or bypassed.\n */\n\nabstract contract RevokableDefaultOperatorFilterer is RevokableOperatorFilterer {\n /// @dev The constructor that is called when the contract is being deployed.\n constructor()\n RevokableOperatorFilterer(CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS, CANONICAL_CORI_SUBSCRIPTION, true)\n {}\n}\n"
},
"@openzeppelin/contracts/token/common/ERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/IERC2981.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.\n *\n * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for\n * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.\n *\n * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the\n * fee is specified in basis points by default.\n *\n * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See\n * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to\n * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.\n *\n * _Available since v4.5._\n */\nabstract contract ERC2981 is IERC2981, ERC165 {\n struct RoyaltyInfo {\n address receiver;\n uint96 royaltyFraction;\n }\n\n RoyaltyInfo private _defaultRoyaltyInfo;\n mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {\n return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @inheritdoc IERC2981\n */\n function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {\n RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];\n\n if (royalty.receiver == address(0)) {\n royalty = _defaultRoyaltyInfo;\n }\n\n uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();\n\n return (royalty.receiver, royaltyAmount);\n }\n\n /**\n * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a\n * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an\n * override.\n */\n function _feeDenominator() internal pure virtual returns (uint96) {\n return 10000;\n }\n\n /**\n * @dev Sets the royalty information that all ids in this contract will default to.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator.\n */\n function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {\n require(feeNumerator <= _feeDenominator(), \"ERC2981: royalty fee will exceed salePrice\");\n require(receiver != address(0), \"ERC2981: invalid receiver\");\n\n _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);\n }\n\n /**\n * @dev Removes default royalty information.\n */\n function _deleteDefaultRoyalty() internal virtual {\n delete _defaultRoyaltyInfo;\n }\n\n /**\n * @dev Sets the royalty information for a specific token id, overriding the global default.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator.\n */\n function _setTokenRoyalty(\n uint256 tokenId,\n address receiver,\n uint96 feeNumerator\n ) internal virtual {\n require(feeNumerator <= _feeDenominator(), \"ERC2981: royalty fee will exceed salePrice\");\n require(receiver != address(0), \"ERC2981: Invalid parameters\");\n\n _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);\n }\n\n /**\n * @dev Resets royalty information for the token id back to the global default.\n */\n function _resetTokenRoyalty(uint256 tokenId) internal virtual {\n delete _tokenRoyaltyInfo[tokenId];\n }\n}\n"
},
"@openzeppelin/contracts/utils/cryptography/MerkleProof.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev These functions deal with verification of Merkle Tree proofs.\n *\n * The tree and the proofs can be generated using our\n * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].\n * You will find a quickstart guide in the readme.\n *\n * WARNING: You should avoid using leaf values that are 64 bytes long prior to\n * hashing, or use a hash function other than keccak256 for hashing leaves.\n * This is because the concatenation of a sorted pair of internal nodes in\n * the merkle tree could be reinterpreted as a leaf value.\n * OpenZeppelin's JavaScript library generates merkle trees that are safe\n * against this attack out of the box.\n */\nlibrary MerkleProof {\n /**\n * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree\n * defined by `root`. For this, a `proof` must be provided, containing\n * sibling hashes on the branch from the leaf to the root of the tree. Each\n * pair of leaves and each pair of pre-images are assumed to be sorted.\n */\n function verify(\n bytes32[] memory proof,\n bytes32 root,\n bytes32 leaf\n ) internal pure returns (bool) {\n return processProof(proof, leaf) == root;\n }\n\n /**\n * @dev Calldata version of {verify}\n *\n * _Available since v4.7._\n */\n function verifyCalldata(\n bytes32[] calldata proof,\n bytes32 root,\n bytes32 leaf\n ) internal pure returns (bool) {\n return processProofCalldata(proof, leaf) == root;\n }\n\n /**\n * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up\n * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt\n * hash matches the root of the tree. When processing the proof, the pairs\n * of leafs & pre-images are assumed to be sorted.\n *\n * _Available since v4.4._\n */\n function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {\n bytes32 computedHash = leaf;\n for (uint256 i = 0; i < proof.length; i++) {\n computedHash = _hashPair(computedHash, proof[i]);\n }\n return computedHash;\n }\n\n /**\n * @dev Calldata version of {processProof}\n *\n * _Available since v4.7._\n */\n function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {\n bytes32 computedHash = leaf;\n for (uint256 i = 0; i < proof.length; i++) {\n computedHash = _hashPair(computedHash, proof[i]);\n }\n return computedHash;\n }\n\n /**\n * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by\n * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.\n *\n * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n *\n * _Available since v4.7._\n */\n function multiProofVerify(\n bytes32[] memory proof,\n bool[] memory proofFlags,\n bytes32 root,\n bytes32[] memory leaves\n ) internal pure returns (bool) {\n return processMultiProof(proof, proofFlags, leaves) == root;\n }\n\n /**\n * @dev Calldata version of {multiProofVerify}\n *\n * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n *\n * _Available since v4.7._\n */\n function multiProofVerifyCalldata(\n bytes32[] calldata proof,\n bool[] calldata proofFlags,\n bytes32 root,\n bytes32[] memory leaves\n ) internal pure returns (bool) {\n return processMultiProofCalldata(proof, proofFlags, leaves) == root;\n }\n\n /**\n * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction\n * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another\n * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false\n * respectively.\n *\n * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree\n * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the\n * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).\n *\n * _Available since v4.7._\n */\n function processMultiProof(\n bytes32[] memory proof,\n bool[] memory proofFlags,\n bytes32[] memory leaves\n ) internal pure returns (bytes32 merkleRoot) {\n // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by\n // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the\n // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of\n // the merkle tree.\n uint256 leavesLen = leaves.length;\n uint256 totalHashes = proofFlags.length;\n\n // Check proof validity.\n require(leavesLen + proof.length - 1 == totalHashes, \"MerkleProof: invalid multiproof\");\n\n // The xxxPos values are \"pointers\" to the next value to consume in each array. All accesses are done using\n // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's \"pop\".\n bytes32[] memory hashes = new bytes32[](totalHashes);\n uint256 leafPos = 0;\n uint256 hashPos = 0;\n uint256 proofPos = 0;\n // At each step, we compute the next hash using two values:\n // - a value from the \"main queue\". If not all leaves have been consumed, we get the next leaf, otherwise we\n // get the next hash.\n // - depending on the flag, either another value for the \"main queue\" (merging branches) or an element from the\n // `proof` array.\n for (uint256 i = 0; i < totalHashes; i++) {\n bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];\n bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];\n hashes[i] = _hashPair(a, b);\n }\n\n if (totalHashes > 0) {\n return hashes[totalHashes - 1];\n } else if (leavesLen > 0) {\n return leaves[0];\n } else {\n return proof[0];\n }\n }\n\n /**\n * @dev Calldata version of {processMultiProof}.\n *\n * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n *\n * _Available since v4.7._\n */\n function processMultiProofCalldata(\n bytes32[] calldata proof,\n bool[] calldata proofFlags,\n bytes32[] memory leaves\n ) internal pure returns (bytes32 merkleRoot) {\n // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by\n // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the\n // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of\n // the merkle tree.\n uint256 leavesLen = leaves.length;\n uint256 totalHashes = proofFlags.length;\n\n // Check proof validity.\n require(leavesLen + proof.length - 1 == totalHashes, \"MerkleProof: invalid multiproof\");\n\n // The xxxPos values are \"pointers\" to the next value to consume in each array. All accesses are done using\n // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's \"pop\".\n bytes32[] memory hashes = new bytes32[](totalHashes);\n uint256 leafPos = 0;\n uint256 hashPos = 0;\n uint256 proofPos = 0;\n // At each step, we compute the next hash using two values:\n // - a value from the \"main queue\". If not all leaves have been consumed, we get the next leaf, otherwise we\n // get the next hash.\n // - depending on the flag, either another value for the \"main queue\" (merging branches) or an element from the\n // `proof` array.\n for (uint256 i = 0; i < totalHashes; i++) {\n bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];\n bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];\n hashes[i] = _hashPair(a, b);\n }\n\n if (totalHashes > 0) {\n return hashes[totalHashes - 1];\n } else if (leavesLen > 0) {\n return leaves[0];\n } else {\n return proof[0];\n }\n }\n\n function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {\n return a < b ? _efficientHash(a, b) : _efficientHash(b, a);\n }\n\n function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, a)\n mstore(0x20, b)\n value := keccak256(0x00, 0x40)\n }\n }\n}\n"
},
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\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 the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual 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"
},
"@openzeppelin/contracts/access/AccessControl.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.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 AccessControl is Context, IAccessControl, ERC165 {\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);\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(IAccessControl).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 `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\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 Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) 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 * May emit a {RoleGranted} event.\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 * May emit a {RoleRevoked} event.\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 * May emit a {RoleRevoked} event.\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 * May emit a {RoleGranted} event.\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 * May emit a {RoleGranted} event.\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 * May emit a {RoleRevoked} event.\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"
},
"contract-allow-list/contracts/ERC721AntiScam/restrictApprove/ERC721RestrictApprove.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\nimport \"erc721psi/contracts/extension/ERC721PsiBurnable.sol\";\nimport \"./IERC721RestrictApprove.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport \"../../proxy/interface/IContractAllowListProxy.sol\";\n\n/// @title AntiScam機能付きERC721A\n/// @dev Readmeを見てください。\n\nabstract contract ERC721RestrictApprove is ERC721PsiBurnable, IERC721RestrictApprove {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n IContractAllowListProxy public CAL;\n EnumerableSet.AddressSet localAllowedAddresses;\n\n modifier onlyHolder(uint256 tokenId) {\n require(\n msg.sender == ownerOf(tokenId),\n \"RestrictApprove: operation is only holder.\"\n );\n _;\n }\n\n /*//////////////////////////////////////////////////////////////\n 変数\n //////////////////////////////////////////////////////////////*/\n bool public enableRestrict = true;\n\n // token lock\n mapping(uint256 => uint256) public tokenCALLevel;\n\n // wallet lock\n mapping(address => uint256) public walletCALLevel;\n\n // contract lock\n uint256 public CALLevel = 1;\n\n /*///////////////////////////////////////////////////////////////\n Approve抑制機能ロジック\n //////////////////////////////////////////////////////////////*/\n function _addLocalContractAllowList(address transferer)\n internal\n virtual\n {\n localAllowedAddresses.add(transferer);\n emit LocalCalAdded(msg.sender, transferer);\n }\n\n function _removeLocalContractAllowList(address transferer)\n internal\n virtual\n {\n localAllowedAddresses.remove(transferer);\n emit LocalCalRemoved(msg.sender, transferer);\n }\n\n function _getLocalContractAllowList()\n internal\n virtual\n view\n returns(address[] memory)\n {\n return localAllowedAddresses.values();\n }\n\n function _isLocalAllowed(address transferer)\n internal\n view\n virtual\n returns (bool)\n {\n return localAllowedAddresses.contains(transferer);\n }\n\n function _isAllowed(address transferer)\n internal\n view\n virtual\n returns (bool)\n {\n return _isAllowed(msg.sender, transferer);\n }\n\n function _isAllowed(uint256 tokenId, address transferer)\n internal\n view\n virtual\n returns (bool)\n {\n uint256 level = _getCALLevel(msg.sender, tokenId);\n return _isAllowed(transferer, level);\n }\n\n function _isAllowed(address holder, address transferer)\n internal\n view\n virtual\n returns (bool)\n {\n uint256 level = _getCALLevel(holder);\n return _isAllowed(transferer, level);\n }\n\n function _isAllowed(address transferer, uint256 level)\n internal\n view\n virtual\n returns (bool)\n {\n if (!enableRestrict) {\n return true;\n }\n\n return _isLocalAllowed(transferer) || CAL.isAllowed(transferer, level);\n }\n\n function _getCALLevel(address holder, uint256 tokenId)\n internal\n view\n virtual\n returns (uint256)\n {\n if (tokenCALLevel[tokenId] > 0) {\n return tokenCALLevel[tokenId];\n }\n\n return _getCALLevel(holder);\n }\n\n function _getCALLevel(address holder)\n internal\n view\n virtual\n returns (uint256)\n {\n if (walletCALLevel[holder] > 0) {\n return walletCALLevel[holder];\n }\n\n return CALLevel;\n }\n\n function _setCAL(address _cal) internal virtual {\n CAL = IContractAllowListProxy(_cal);\n }\n\n function _deleteTokenCALLevel(uint256 tokenId) internal virtual {\n delete tokenCALLevel[tokenId];\n }\n\n function setTokenCALLevel(uint256 tokenId, uint256 level)\n external\n virtual\n onlyHolder(tokenId)\n {\n tokenCALLevel[tokenId] = level;\n }\n\n function setWalletCALLevel(uint256 level)\n external\n virtual\n {\n walletCALLevel[msg.sender] = level;\n }\n\n /*///////////////////////////////////////////////////////////////\n OVERRIDES\n //////////////////////////////////////////////////////////////*/\n\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n override\n returns (bool)\n {\n if (_isAllowed(owner, operator) == false) {\n return false;\n }\n return super.isApprovedForAll(owner, operator);\n }\n\n function setApprovalForAll(address operator, bool approved)\n public\n virtual\n override\n {\n require(\n _isAllowed(operator) || approved == false,\n \"RestrictApprove: Can not approve locked token\"\n );\n super.setApprovalForAll(operator, approved);\n }\n\n function _beforeApprove(address to, uint256 tokenId)\n internal\n virtual\n {\n if (to != address(0)) {\n require(_isAllowed(tokenId, to), \"RestrictApprove: The contract is not allowed.\");\n }\n }\n\n function approve(address to, uint256 tokenId)\n public\n virtual\n override\n {\n _beforeApprove(to, tokenId);\n super.approve(to, tokenId);\n }\n\n function _afterTokenTransfers(\n address from,\n address, /*to*/\n uint256 startTokenId,\n uint256 /*quantity*/\n ) internal virtual override {\n // 転送やバーンにおいては、常にstartTokenIdは TokenIDそのものとなります。\n if (from != address(0)) {\n // CALレベルをデフォルトに戻す。\n _deleteTokenCALLevel(startTokenId);\n }\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override\n returns (bool)\n {\n return\n interfaceId == type(IERC721RestrictApprove).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n}\n"
},
"operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n /**\n * @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns\n * true if supplied registrant address is not registered.\n */\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n\n /**\n * @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner.\n */\n function register(address registrant) external;\n\n /**\n * @notice Registers an address with the registry and \"subscribes\" to another address's filtered operators and codeHashes.\n */\n function registerAndSubscribe(address registrant, address subscription) external;\n\n /**\n * @notice Registers an address with the registry and copies the filtered operators and codeHashes from another\n * address without subscribing.\n */\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n\n /**\n * @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner.\n * Note that this does not remove any filtered addresses or codeHashes.\n * Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes.\n */\n function unregister(address addr) external;\n\n /**\n * @notice Update an operator address for a registered address - when filtered is true, the operator is filtered.\n */\n function updateOperator(address registrant, address operator, bool filtered) external;\n\n /**\n * @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates.\n */\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n\n /**\n * @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered.\n */\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n\n /**\n * @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates.\n */\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n\n /**\n * @notice Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previous\n * subscription if present.\n * Note that accounts with subscriptions may go on to subscribe to other accounts - in this case,\n * subscriptions will not be forwarded. Instead the former subscription's existing entries will still be\n * used.\n */\n function subscribe(address registrant, address registrantToSubscribe) external;\n\n /**\n * @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes.\n */\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n\n /**\n * @notice Get the subscription address of a given registrant, if any.\n */\n function subscriptionOf(address addr) external returns (address registrant);\n\n /**\n * @notice Get the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscribers(address registrant) external returns (address[] memory);\n\n /**\n * @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscriberAt(address registrant, uint256 index) external returns (address);\n\n /**\n * @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr.\n */\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n\n /**\n * @notice Returns true if operator is filtered by a given address or its subscription.\n */\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n\n /**\n * @notice Returns true if the hash of an address's code is filtered by a given address or its subscription.\n */\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n\n /**\n * @notice Returns true if a codeHash is filtered by a given address or its subscription.\n */\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n\n /**\n * @notice Returns a list of filtered operators for a given address or its subscription.\n */\n function filteredOperators(address addr) external returns (address[] memory);\n\n /**\n * @notice Returns the set of filtered codeHashes for a given address or its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n\n /**\n * @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n\n /**\n * @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n\n /**\n * @notice Returns true if an address has registered\n */\n function isRegistered(address addr) external returns (bool);\n\n /**\n * @dev Convenience method to compute the code hash of an arbitrary contract\n */\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"operator-filter-registry/src/lib/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\naddress constant CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS = 0x000000000000AAeB6D7670E522A718067333cd4E;\naddress constant CANONICAL_CORI_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;\n"
},
"operator-filter-registry/src/RevokableOperatorFilterer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {UpdatableOperatorFilterer} from \"./UpdatableOperatorFilterer.sol\";\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\n/**\n * @title RevokableOperatorFilterer\n * @notice This contract is meant to allow contracts to permanently skip OperatorFilterRegistry checks if desired. The\n * Registry itself has an \"unregister\" function, but if the contract is ownable, the owner can re-register at\n * any point. As implemented, this abstract contract allows the contract owner to permanently skip the\n * OperatorFilterRegistry checks by calling revokeOperatorFilterRegistry. Once done, the registry\n * address cannot be further updated.\n * Note that OpenSea will still disable creator earnings enforcement if filtered operators begin fulfilling orders\n * on-chain, eg, if the registry is revoked or bypassed.\n */\nabstract contract RevokableOperatorFilterer is UpdatableOperatorFilterer {\n /// @dev Emitted when the registry has already been revoked.\n error RegistryHasBeenRevoked();\n /// @dev Emitted when the initial registry address is attempted to be set to the zero address.\n error InitialRegistryAddressCannotBeZeroAddress();\n\n event OperatorFilterRegistryRevoked();\n\n bool public isOperatorFilterRegistryRevoked;\n\n /// @dev The constructor that is called when the contract is being deployed.\n constructor(address _registry, address subscriptionOrRegistrantToCopy, bool subscribe)\n UpdatableOperatorFilterer(_registry, subscriptionOrRegistrantToCopy, subscribe)\n {\n // don't allow creating a contract with a permanently revoked registry\n if (_registry == address(0)) {\n revert InitialRegistryAddressCannotBeZeroAddress();\n }\n }\n\n /**\n * @notice Update the address that the contract will make OperatorFilter checks against. When set to the zero\n * address, checks will be permanently bypassed, and the address cannot be updated again. OnlyOwner.\n */\n function updateOperatorFilterRegistryAddress(address newRegistry) public override {\n if (msg.sender != owner()) {\n revert OnlyOwner();\n }\n // if registry has been revoked, do not allow further updates\n if (isOperatorFilterRegistryRevoked) {\n revert RegistryHasBeenRevoked();\n }\n\n operatorFilterRegistry = IOperatorFilterRegistry(newRegistry);\n emit OperatorFilterRegistryAddressUpdated(newRegistry);\n }\n\n /**\n * @notice Revoke the OperatorFilterRegistry address, permanently bypassing checks. OnlyOwner.\n */\n function revokeOperatorFilterRegistry() public {\n if (msg.sender != owner()) {\n revert OnlyOwner();\n }\n // if registry has been revoked, do not allow further updates\n if (isOperatorFilterRegistryRevoked) {\n revert RegistryHasBeenRevoked();\n }\n\n // set to zero address to bypass checks\n operatorFilterRegistry = IOperatorFilterRegistry(address(0));\n isOperatorFilterRegistryRevoked = true;\n emit OperatorFilterRegistryRevoked();\n }\n}\n"
},
"contract-allow-list/contracts/proxy/interface/IContractAllowListProxy.sol": {
"content": "// SPDX-License-Identifier: MIT\r\npragma solidity >=0.7.0 <0.9.0;\r\n\r\ninterface IContractAllowListProxy {\r\n function isAllowed(address _transferer, uint256 _level)\r\n external\r\n view\r\n returns (bool);\r\n}\r\n"
},
"@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\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 *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\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 bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\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 /// @solidity memory-safe-assembly\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 in 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 /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n"
},
"contract-allow-list/contracts/ERC721AntiScam/restrictApprove/IERC721RestrictApprove.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/// @title IERC721RestrictApprove\n/// @dev Approve抑制機能付きコントラクトのインターフェース\n/// @author Lavulite\n\ninterface IERC721RestrictApprove {\n /**\n * @dev CALレベルが変更された場合のイベント\n */\n event CalLevelChanged(address indexed operator, uint256 indexed level);\n \n /**\n * @dev LocalContractAllowListnに追加された場合のイベント\n */\n event LocalCalAdded(address indexed operator, address indexed transferer);\n\n /**\n * @dev LocalContractAllowListnに削除された場合のイベント\n */\n event LocalCalRemoved(address indexed operator, address indexed transferer);\n\n /**\n * @dev CALを利用する場合のCALのレベルを設定する。レベルが高いほど、許可されるコントラクトの範囲が狭い。\n */\n function setCALLevel(uint256 level) external;\n\n /**\n * @dev CALのアドレスをセットする。\n */\n function setCAL(address calAddress) external;\n\n /**\n * @dev CALのリストに無い独自の許可アドレスを追加する場合、こちらにアドレスを記載する。\n */\n function addLocalContractAllowList(address transferer) external;\n\n /**\n * @dev CALのリストにある独自の許可アドレスを削除する場合、こちらにアドレスを記載する。\n */\n function removeLocalContractAllowList(address transferer) external;\n\n /**\n * @dev CALのリストにある独自の許可アドレスの一覧を取得する。\n */\n function getLocalContractAllowList() external view returns(address[] memory);\n\n}\n"
},
"erc721psi/contracts/extension/ERC721PsiBurnable.sol": {
"content": "// SPDX-License-Identifier: MIT\n/**\n ______ _____ _____ ______ ___ __ _ _ _ \n | ____| __ \\ / ____|____ |__ \\/_ | || || |\n | |__ | |__) | | / / ) || | \\| |/ |\n | __| | _ /| | / / / / | |\\_ _/ \n | |____| | \\ \\| |____ / / / /_ | | | | \n |______|_| \\_\\\\_____|/_/ |____||_| |_| \n \n \n */\npragma solidity ^0.8.0;\n\nimport \"solidity-bits/contracts/BitMaps.sol\";\nimport \"../ERC721Psi.sol\";\n\n\nabstract contract ERC721PsiBurnable is ERC721Psi {\n using BitMaps for BitMaps.BitMap;\n BitMaps.BitMap private _burnedToken;\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) internal virtual {\n address from = ownerOf(tokenId);\n _beforeTokenTransfers(from, address(0), tokenId, 1);\n _burnedToken.set(tokenId);\n \n emit Transfer(from, address(0), tokenId);\n\n _afterTokenTransfers(from, address(0), tokenId, 1);\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 * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view override virtual returns (bool){\n if(_burnedToken.get(tokenId)) {\n return false;\n } \n return super._exists(tokenId);\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalMinted() - _burned();\n }\n\n /**\n * @dev Returns number of token burned.\n */\n function _burned() internal view returns (uint256 burned){\n uint256 startBucket = _startTokenId() >> 8;\n uint256 lastBucket = (_nextTokenId() >> 8) + 1;\n\n for(uint256 i=startBucket; i < lastBucket; i++) {\n uint256 bucket = _burnedToken.getBucket(i);\n burned += _popcount(bucket);\n }\n }\n\n /**\n * @dev Returns number of set bits.\n */\n function _popcount(uint256 x) private pure returns (uint256 count) {\n unchecked{\n for (count=0; x!=0; count++)\n x &= x - 1;\n }\n }\n}"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\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 unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\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 unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\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] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/access/IAccessControl.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n"
},
"erc721psi/contracts/ERC721Psi.sol": {
"content": "// SPDX-License-Identifier: MIT\n/**\n ______ _____ _____ ______ ___ __ _ _ _ \n | ____| __ \\ / ____|____ |__ \\/_ | || || |\n | |__ | |__) | | / / ) || | \\| |/ |\n | __| | _ /| | / / / / | |\\_ _/ \n | |____| | \\ \\| |____ / / / /_ | | | | \n |______|_| \\_\\\\_____|/_/ |____||_| |_| \n\n - github: https://github.com/estarriolvetch/ERC721Psi\n - npm: https://www.npmjs.com/package/erc721psi\n \n */\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\nimport \"solidity-bits/contracts/BitMaps.sol\";\n\n\ncontract ERC721Psi is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n using BitMaps for BitMaps.BitMap;\n\n BitMaps.BitMap private _batchHead;\n\n string private _name;\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) internal _owners;\n uint256 private _currentIndex;\n\n mapping(uint256 => address) private _tokenApprovals;\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n _currentIndex = _startTokenId();\n }\n\n /**\n * @dev Returns the starting token ID.\n * To change the starting token ID, please override this function.\n */\n function _startTokenId() internal pure returns (uint256) {\n // It will become modifiable in the future versions\n return 0;\n }\n\n /**\n * @dev Returns the next token ID to be minted.\n */\n function _nextTokenId() internal view virtual returns (uint256) {\n return _currentIndex;\n }\n\n /**\n * @dev Returns the total amount of tokens minted in the contract.\n */\n function _totalMinted() internal view virtual returns (uint256) {\n return _currentIndex - _startTokenId();\n }\n\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC165, IERC165)\n returns (bool)\n {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) \n public \n view \n virtual \n override \n returns (uint) \n {\n require(owner != address(0), \"ERC721Psi: balance query for the zero address\");\n\n uint count;\n for( uint i = _startTokenId(); i < _nextTokenId(); ++i ){\n if(_exists(i)){\n if( owner == ownerOf(i)){\n ++count;\n }\n }\n }\n return count;\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n (address owner, ) = _ownerAndBatchHeadOf(tokenId);\n return owner;\n }\n\n function _ownerAndBatchHeadOf(uint256 tokenId) internal view returns (address owner, uint256 tokenIdBatchHead){\n require(_exists(tokenId), \"ERC721Psi: owner query for nonexistent token\");\n tokenIdBatchHead = _getBatchHead(tokenId);\n owner = _owners[tokenIdBatchHead];\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n require(_exists(tokenId), \"ERC721Psi: URI query for nonexistent token\");\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overriden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ownerOf(tokenId);\n require(to != owner, \"ERC721Psi: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721Psi: approve caller is not owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n require(\n _exists(tokenId),\n \"ERC721Psi: approved query for nonexistent token\"\n );\n\n return _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 require(operator != _msgSender(), \"ERC721Psi: approve to caller\");\n\n _operatorApprovals[_msgSender()][operator] = 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 _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 //solhint-disable-next-line max-line-length\n require(\n _isApprovedOrOwner(_msgSender(), tokenId),\n \"ERC721Psi: transfer caller is not owner nor approved\"\n );\n\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 require(\n _isApprovedOrOwner(_msgSender(), tokenId),\n \"ERC721Psi: transfer caller is not owner nor approved\"\n );\n _safeTransfer(from, to, tokenId, _data);\n }\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 * `_data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\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 `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 _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(\n _checkOnERC721Received(from, to, tokenId, 1,_data),\n \"ERC721Psi: transfer to non ERC721Receiver implementer\"\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 virtual returns (bool) {\n return tokenId < _nextTokenId() && _startTokenId() <= tokenId;\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId)\n internal\n view\n virtual\n returns (bool)\n {\n require(\n _exists(tokenId),\n \"ERC721Psi: operator query for nonexistent token\"\n );\n address owner = ownerOf(tokenId);\n return (spender == owner ||\n getApproved(tokenId) == spender ||\n isApprovedForAll(owner, spender));\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(address to, uint256 quantity) internal virtual {\n _safeMint(to, quantity, \"\");\n }\n\n \n function _safeMint(\n address to,\n uint256 quantity,\n bytes memory _data\n ) internal virtual {\n uint256 nextTokenId = _nextTokenId();\n _mint(to, quantity);\n require(\n _checkOnERC721Received(address(0), to, nextTokenId, quantity, _data),\n \"ERC721Psi: transfer to non ERC721Receiver implementer\"\n );\n }\n\n\n function _mint(\n address to,\n uint256 quantity\n ) internal virtual {\n uint256 nextTokenId = _nextTokenId();\n \n require(quantity > 0, \"ERC721Psi: quantity must be greater 0\");\n require(to != address(0), \"ERC721Psi: mint to the zero address\");\n \n _beforeTokenTransfers(address(0), to, nextTokenId, quantity);\n _currentIndex += quantity;\n _owners[nextTokenId] = to;\n _batchHead.set(nextTokenId);\n _afterTokenTransfers(address(0), to, nextTokenId, quantity);\n \n // Emit events\n for(uint256 tokenId=nextTokenId; tokenId < nextTokenId + quantity; tokenId++){\n emit Transfer(address(0), to, tokenId);\n } \n }\n\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n (address owner, uint256 tokenIdBatchHead) = _ownerAndBatchHeadOf(tokenId);\n\n require(\n owner == from,\n \"ERC721Psi: transfer of token that is not own\"\n );\n require(to != address(0), \"ERC721Psi: transfer to the zero address\");\n\n _beforeTokenTransfers(from, to, tokenId, 1);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId); \n\n uint256 subsequentTokenId = tokenId + 1;\n\n if(!_batchHead.get(subsequentTokenId) && \n subsequentTokenId < _nextTokenId()\n ) {\n _owners[subsequentTokenId] = from;\n _batchHead.set(subsequentTokenId);\n }\n\n _owners[tokenId] = to;\n if(tokenId != tokenIdBatchHead) {\n _batchHead.set(tokenId);\n }\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfers(from, to, tokenId, 1);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits a {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a 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 startTokenId uint256 the first ID of the tokens to be transferred\n * @param quantity uint256 amount of the tokens to be transfered.\n * @param _data bytes optional data to send along with the call\n * @return r bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity,\n bytes memory _data\n ) private returns (bool r) {\n if (to.isContract()) {\n r = true;\n for(uint256 tokenId = startTokenId; tokenId < startTokenId + quantity; tokenId++){\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {\n r = r && retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721Psi: transfer to non ERC721Receiver implementer\");\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n return r;\n } else {\n return true;\n }\n }\n\n function _getBatchHead(uint256 tokenId) internal view returns (uint256 tokenIdBatchHead) {\n tokenIdBatchHead = _batchHead.scanForward(tokenId); \n }\n\n\n function totalSupply() public virtual view returns (uint256) {\n return _totalMinted();\n }\n\n /**\n * @dev Returns an array of token IDs owned by `owner`.\n *\n * This function scans the ownership mapping and is O(`totalSupply`) in complexity.\n * It is meant to be called off-chain.\n *\n * This function is compatiable with ERC721AQueryable.\n */\n function tokensOfOwner(address owner) external view virtual returns (uint256[] memory) {\n unchecked {\n uint256 tokenIdsIdx;\n uint256 tokenIdsLength = balanceOf(owner);\n uint256[] memory tokenIds = new uint256[](tokenIdsLength);\n for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {\n if (_exists(i)) {\n if (ownerOf(i) == owner) {\n tokenIds[tokenIdsIdx++] = i;\n }\n }\n }\n return tokenIds; \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 *\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 */\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 *\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.\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}"
},
"solidity-bits/contracts/BitMaps.sol": {
"content": "// SPDX-License-Identifier: MIT\n/**\n _____ ___ ___ __ ____ _ __ \n / ___/____ / (_)___/ (_) /___ __ / __ )(_) /______\n \\__ \\/ __ \\/ / / __ / / __/ / / / / __ / / __/ ___/\n ___/ / /_/ / / / /_/ / / /_/ /_/ / / /_/ / / /_(__ ) \n/____/\\____/_/_/\\__,_/_/\\__/\\__, / /_____/_/\\__/____/ \n /____/ \n\n- npm: https://www.npmjs.com/package/solidity-bits\n- github: https://github.com/estarriolvetch/solidity-bits\n\n */\npragma solidity ^0.8.0;\n\nimport \"./BitScan.sol\";\nimport \"./Popcount.sol\";\n\n/**\n * @dev This Library is a modified version of Openzeppelin's BitMaps library with extra features.\n *\n * 1. Functions of finding the index of the closest set bit from a given index are added.\n * The indexing of each bucket is modifed to count from the MSB to the LSB instead of from the LSB to the MSB.\n * The modification of indexing makes finding the closest previous set bit more efficient in gas usage.\n * 2. Setting and unsetting the bitmap consecutively.\n * 3. Accounting number of set bits within a given range. \n *\n*/\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 */\n\nlibrary BitMaps {\n using BitScan for uint256;\n uint256 private constant MASK_INDEX_ZERO = (1 << 255);\n uint256 private constant MASK_FULL = type(uint256).max;\n\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 = MASK_INDEX_ZERO >> (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 = MASK_INDEX_ZERO >> (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 = MASK_INDEX_ZERO >> (index & 0xff);\n bitmap._data[bucket] &= ~mask;\n }\n\n\n /**\n * @dev Consecutively sets `amount` of bits starting from the bit at `startIndex`.\n */ \n function setBatch(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal {\n uint256 bucket = startIndex >> 8;\n\n uint256 bucketStartIndex = (startIndex & 0xff);\n\n unchecked {\n if(bucketStartIndex + amount < 256) {\n bitmap._data[bucket] |= MASK_FULL << (256 - amount) >> bucketStartIndex;\n } else {\n bitmap._data[bucket] |= MASK_FULL >> bucketStartIndex;\n amount -= (256 - bucketStartIndex);\n bucket++;\n\n while(amount > 256) {\n bitmap._data[bucket] = MASK_FULL;\n amount -= 256;\n bucket++;\n }\n\n bitmap._data[bucket] |= MASK_FULL << (256 - amount);\n }\n }\n }\n\n\n /**\n * @dev Consecutively unsets `amount` of bits starting from the bit at `startIndex`.\n */ \n function unsetBatch(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal {\n uint256 bucket = startIndex >> 8;\n\n uint256 bucketStartIndex = (startIndex & 0xff);\n\n unchecked {\n if(bucketStartIndex + amount < 256) {\n bitmap._data[bucket] &= ~(MASK_FULL << (256 - amount) >> bucketStartIndex);\n } else {\n bitmap._data[bucket] &= ~(MASK_FULL >> bucketStartIndex);\n amount -= (256 - bucketStartIndex);\n bucket++;\n\n while(amount > 256) {\n bitmap._data[bucket] = 0;\n amount -= 256;\n bucket++;\n }\n\n bitmap._data[bucket] &= ~(MASK_FULL << (256 - amount));\n }\n }\n }\n\n /**\n * @dev Returns number of set bits within a range.\n */\n function popcountA(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal view returns(uint256 count) {\n uint256 bucket = startIndex >> 8;\n\n uint256 bucketStartIndex = (startIndex & 0xff);\n\n unchecked {\n if(bucketStartIndex + amount < 256) {\n count += Popcount.popcount256A(\n bitmap._data[bucket] & (MASK_FULL << (256 - amount) >> bucketStartIndex)\n );\n } else {\n count += Popcount.popcount256A(\n bitmap._data[bucket] & (MASK_FULL >> bucketStartIndex)\n );\n amount -= (256 - bucketStartIndex);\n bucket++;\n\n while(amount > 256) {\n count += Popcount.popcount256A(bitmap._data[bucket]);\n amount -= 256;\n bucket++;\n }\n count += Popcount.popcount256A(\n bitmap._data[bucket] & (MASK_FULL << (256 - amount))\n );\n }\n }\n }\n\n /**\n * @dev Returns number of set bits within a range.\n */\n function popcountB(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal view returns(uint256 count) {\n uint256 bucket = startIndex >> 8;\n\n uint256 bucketStartIndex = (startIndex & 0xff);\n\n unchecked {\n if(bucketStartIndex + amount < 256) {\n count += Popcount.popcount256B(\n bitmap._data[bucket] & (MASK_FULL << (256 - amount) >> bucketStartIndex)\n );\n } else {\n count += Popcount.popcount256B(\n bitmap._data[bucket] & (MASK_FULL >> bucketStartIndex)\n );\n amount -= (256 - bucketStartIndex);\n bucket++;\n\n while(amount > 256) {\n count += Popcount.popcount256B(bitmap._data[bucket]);\n amount -= 256;\n bucket++;\n }\n count += Popcount.popcount256B(\n bitmap._data[bucket] & (MASK_FULL << (256 - amount))\n );\n }\n }\n }\n\n\n /**\n * @dev Find the closest index of the set bit before `index`.\n */\n function scanForward(BitMap storage bitmap, uint256 index) internal view returns (uint256 setBitIndex) {\n uint256 bucket = index >> 8;\n\n // index within the bucket\n uint256 bucketIndex = (index & 0xff);\n\n // load a bitboard from the bitmap.\n uint256 bb = bitmap._data[bucket];\n\n // offset the bitboard to scan from `bucketIndex`.\n bb = bb >> (0xff ^ bucketIndex); // bb >> (255 - bucketIndex)\n \n if(bb > 0) {\n unchecked {\n setBitIndex = (bucket << 8) | (bucketIndex - bb.bitScanForward256()); \n }\n } else {\n while(true) {\n require(bucket > 0, \"BitMaps: The set bit before the index doesn't exist.\");\n unchecked {\n bucket--;\n }\n // No offset. Always scan from the least significiant bit now.\n bb = bitmap._data[bucket];\n \n if(bb > 0) {\n unchecked {\n setBitIndex = (bucket << 8) | (255 - bb.bitScanForward256());\n break;\n }\n } \n }\n }\n }\n\n function getBucket(BitMap storage bitmap, uint256 bucket) internal view returns (uint256) {\n return bitmap._data[bucket];\n }\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/math/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n"
},
"solidity-bits/contracts/Popcount.sol": {
"content": "// SPDX-License-Identifier: MIT\n/**\n _____ ___ ___ __ ____ _ __ \n / ___/____ / (_)___/ (_) /___ __ / __ )(_) /______\n \\__ \\/ __ \\/ / / __ / / __/ / / / / __ / / __/ ___/\n ___/ / /_/ / / / /_/ / / /_/ /_/ / / /_/ / / /_(__ ) \n/____/\\____/_/_/\\__,_/_/\\__/\\__, / /_____/_/\\__/____/ \n /____/ \n\n- npm: https://www.npmjs.com/package/solidity-bits\n- github: https://github.com/estarriolvetch/solidity-bits\n\n */\n\npragma solidity ^0.8.0;\n\nlibrary Popcount {\n uint256 private constant m1 = 0x5555555555555555555555555555555555555555555555555555555555555555;\n uint256 private constant m2 = 0x3333333333333333333333333333333333333333333333333333333333333333;\n uint256 private constant m4 = 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f;\n uint256 private constant h01 = 0x0101010101010101010101010101010101010101010101010101010101010101;\n\n function popcount256A(uint256 x) internal pure returns (uint256 count) {\n unchecked{\n for (count=0; x!=0; count++)\n x &= x - 1;\n }\n }\n\n function popcount256B(uint256 x) internal pure returns (uint256) {\n if (x == type(uint256).max) {\n return 256;\n }\n unchecked {\n x -= (x >> 1) & m1; //put count of each 2 bits into those 2 bits\n x = (x & m2) + ((x >> 2) & m2); //put count of each 4 bits into those 4 bits \n x = (x + (x >> 4)) & m4; //put count of each 8 bits into those 8 bits \n x = (x * h01) >> 248; //returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ... \n }\n return x;\n }\n}"
},
"solidity-bits/contracts/BitScan.sol": {
"content": "// SPDX-License-Identifier: MIT\n/**\n _____ ___ ___ __ ____ _ __ \n / ___/____ / (_)___/ (_) /___ __ / __ )(_) /______\n \\__ \\/ __ \\/ / / __ / / __/ / / / / __ / / __/ ___/\n ___/ / /_/ / / / /_/ / / /_/ /_/ / / /_/ / / /_(__ ) \n/____/\\____/_/_/\\__,_/_/\\__/\\__, / /_____/_/\\__/____/ \n /____/ \n\n- npm: https://www.npmjs.com/package/solidity-bits\n- github: https://github.com/estarriolvetch/solidity-bits\n\n */\n\npragma solidity ^0.8.0;\n\n\nlibrary BitScan {\n uint256 constant private DEBRUIJN_256 = 0x818283848586878898a8b8c8d8e8f929395969799a9b9d9e9faaeb6bedeeff;\n bytes constant private LOOKUP_TABLE_256 = hex\"0001020903110a19042112290b311a3905412245134d2a550c5d32651b6d3a7506264262237d468514804e8d2b95569d0d495ea533a966b11c886eb93bc176c9071727374353637324837e9b47af86c7155181ad4fd18ed32c9096db57d59ee30e2e4a6a5f92a6be3498aae067ddb2eb1d5989b56fd7baf33ca0c2ee77e5caf7ff0810182028303840444c545c646c7425617c847f8c949c48a4a8b087b8c0c816365272829aaec650acd0d28fdad4e22d6991bd97dfdcea58b4d6f29fede4f6fe0f1f2f3f4b5b6b607b8b93a3a7b7bf357199c5abcfd9e168bcdee9b3f1ecf5fd1e3e5a7a8aa2b670c4ced8bbe8f0f4fc3d79a1c3cde7effb78cce6facbf9f8\";\n\n /**\n @dev Isolate the least significant set bit.\n */ \n function isolateLS1B256(uint256 bb) pure internal returns (uint256) {\n require(bb > 0);\n unchecked {\n return bb & (0 - bb);\n }\n } \n\n /**\n @dev Isolate the most significant set bit.\n */ \n function isolateMS1B256(uint256 bb) pure internal returns (uint256) {\n require(bb > 0);\n unchecked {\n bb |= bb >> 128;\n bb |= bb >> 64;\n bb |= bb >> 32;\n bb |= bb >> 16;\n bb |= bb >> 8;\n bb |= bb >> 4;\n bb |= bb >> 2;\n bb |= bb >> 1;\n \n return (bb >> 1) + 1;\n }\n } \n\n /**\n @dev Find the index of the lest significant set bit. (trailing zero count)\n */ \n function bitScanForward256(uint256 bb) pure internal returns (uint8) {\n unchecked {\n return uint8(LOOKUP_TABLE_256[(isolateLS1B256(bb) * DEBRUIJN_256) >> 248]);\n } \n }\n\n /**\n @dev Find the index of the most significant set bit.\n */ \n function bitScanReverse256(uint256 bb) pure internal returns (uint8) {\n unchecked {\n return 255 - uint8(LOOKUP_TABLE_256[((isolateMS1B256(bb) * DEBRUIJN_256) >> 248)]);\n } \n }\n\n function log2(uint256 bb) pure internal returns (uint8) {\n unchecked {\n return uint8(LOOKUP_TABLE_256[(isolateMS1B256(bb) * DEBRUIJN_256) >> 248]);\n } \n }\n}\n"
},
"@openzeppelin/contracts/utils/StorageSlot.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (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 StorageSlot {\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 /// @solidity memory-safe-assembly\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 /// @solidity memory-safe-assembly\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 /// @solidity memory-safe-assembly\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 /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"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 (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, 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 (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or 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 _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\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 /// @solidity memory-safe-assembly\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"
},
"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.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/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}