{ "language": "Solidity", "sources": { "/contracts/Merge.sol": { "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.4;\r\n\r\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\r\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\r\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol\";\r\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol\";\r\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\r\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\r\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\r\nimport \"./Sentence.sol\";\r\n\r\ncontract Merge is ERC721, ERC721Enumerable, Ownable, ReentrancyGuard, IERC721Receiver {\r\n // lib\r\n using Strings for uint256;\r\n using SafeERC20 for IERC20;\r\n\r\n // struct\r\n struct MergeInfo{\r\n uint256 sentenceTokenID;\r\n\r\n address erc721Address;\r\n uint256 erc721TokenID;\r\n\r\n address mergeAddress;\r\n\r\n uint256 reward;\r\n }\r\n \r\n // constant\r\n\r\n // storage\r\n IERC20 public rewardToken;\r\n uint256 private _counter;\r\n string private _basePath;\r\n\r\n mapping(uint256=>MergeInfo) public mergeInfos;\r\n mapping(address=>uint256) public erc721Rewards;\r\n uint256 public minRewards = 1 ether;\r\n\r\n IERC721 public senteceAddress;\r\n\r\n // event\r\n event Bind(address indexed to, address indexed erc721Address, uint256 erc721TokenID, uint256 sentenceTokenID);\r\n event Unbind(address indexed from, address indexed erc721Address, uint256 erc721TokenID, uint256 sentenceTokenID);\r\n\r\n constructor(address _rewardToken, address _sentenceAddress) ERC721(\"Merge\", \"MG\") {\r\n rewardToken = IERC20(_rewardToken);\r\n senteceAddress = IERC721(_sentenceAddress);\r\n }\r\n\r\n function bind(address erc721Address, uint256 erc721TokenID, uint256 sentenceTokenID) public nonReentrant{\r\n senteceAddress.safeTransferFrom(msg.sender, address(this), sentenceTokenID);\r\n (IERC721(erc721Address)).safeTransferFrom(msg.sender, address(this), erc721TokenID);\r\n\r\n _counter++;\r\n _mint(msg.sender, _counter);\r\n mergeInfos[_counter].sentenceTokenID = sentenceTokenID;\r\n mergeInfos[_counter].erc721Address = erc721Address;\r\n mergeInfos[_counter].erc721TokenID = erc721TokenID;\r\n mergeInfos[_counter].mergeAddress = msg.sender;\r\n uint256 reward = erc721Rewards[erc721Address];\r\n if (reward <= 0){\r\n reward = minRewards;\r\n }\r\n mergeInfos[_counter].reward = reward;\r\n \r\n if (reward > 0){\r\n uint256 balance = rewardToken.balanceOf(address(this));\r\n if (reward > balance){\r\n reward = balance;\r\n }\r\n\r\n if (reward > 0){\r\n rewardToken.safeTransfer(msg.sender, reward);\r\n }\r\n }\r\n\r\n emit Bind(msg.sender, erc721Address, erc721TokenID, sentenceTokenID);\r\n }\r\n\r\n function unbind(uint256 tokenID) public nonReentrant{\r\n require(ownerOf(tokenID) == msg.sender, \"unbind caller is not owner\");\r\n\r\n _burn(tokenID);\r\n senteceAddress.safeTransferFrom(address(this), msg.sender, mergeInfos[tokenID].sentenceTokenID);\r\n (IERC721(mergeInfos[tokenID].erc721Address)).safeTransferFrom(address(this), msg.sender, mergeInfos[tokenID].erc721TokenID);\r\n\r\n uint256 reward = mergeInfos[tokenID].reward;\r\n if (reward > 0){\r\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\r\n }\r\n\r\n emit Unbind(msg.sender, mergeInfos[tokenID].erc721Address, mergeInfos[tokenID].erc721TokenID, mergeInfos[tokenID].sentenceTokenID);\r\n }\r\n\r\n function bindReward(address erc721Address) public view returns(uint256){\r\n return erc721Rewards[erc721Address];\r\n }\r\n\r\n function setBindReward(address[] memory erc721Address, uint256[] memory amounts) public onlyOwner{\r\n for (uint256 i = 0; i < erc721Address.length; ++i){\r\n erc721Rewards[erc721Address[i]] = amounts[i];\r\n }\r\n }\r\n\r\n function setBindMinReward(uint256 _minReward) public onlyOwner{\r\n minRewards = _minReward;\r\n }\r\n\r\n // url\r\n function setBaseURI(string calldata path) public onlyOwner {\r\n _basePath = path;\r\n }\r\n\r\n function tokenURI(uint256 tokenId)\r\n public\r\n view\r\n override\r\n returns (string memory)\r\n {\r\n require(\r\n _exists(tokenId),\r\n \"ERC721Metadata: URI query for nonexistent token\"\r\n );\r\n\r\n return string(abi.encodePacked(_basePath, tokenId.toString()));\r\n }\r\n\r\n // The following functions are overrides required by Solidity.\r\n function _beforeTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) internal override(ERC721, ERC721Enumerable) {\r\n super._beforeTokenTransfer(from, to, tokenId);\r\n }\r\n\r\n function supportsInterface(bytes4 interfaceId)\r\n public\r\n view\r\n override(ERC721, ERC721Enumerable)\r\n returns (bool)\r\n {\r\n return interfaceId == type(IERC721Receiver).interfaceId || super.supportsInterface(interfaceId);\r\n }\r\n\r\n function onERC721Received(\r\n address ,\r\n address ,\r\n uint256 ,\r\n bytes calldata \r\n ) external virtual override returns (bytes4){\r\n return this.onERC721Received.selector;\r\n }\r\n}\r\n" }, "/contracts/common/EnumerableMap.sol": { "content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableMap.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\r\n\r\n/**\r\n * @dev Library for managing an enumerable variant of Solidity's\r\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\r\n * type.\r\n *\r\n * Maps have the following properties:\r\n *\r\n * - Entries are added, removed, and checked for existence in constant time\r\n * (O(1)).\r\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\r\n *\r\n * ```\r\n * contract Example {\r\n * // Add the library methods\r\n * using EnumerableMap for EnumerableMap.UintToAddressMap;\r\n *\r\n * // Declare a set state variable\r\n * EnumerableMap.UintToAddressMap private myMap;\r\n * }\r\n * ```\r\n *\r\n * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are\r\n * supported.\r\n */\r\nlibrary EnumerableMap {\r\n using EnumerableSet for EnumerableSet.Bytes32Set;\r\n\r\n // To implement this library for multiple types with as little code\r\n // repetition as possible, we write it in terms of a generic Map type with\r\n // bytes32 keys and values.\r\n // The Map implementation uses private functions, and user-facing\r\n // implementations (such as Uint256ToAddressMap) are just wrappers around\r\n // the underlying Map.\r\n // This means that we can only create new EnumerableMaps for types that fit\r\n // in bytes32.\r\n\r\n struct Map {\r\n // Storage of keys\r\n EnumerableSet.Bytes32Set _keys;\r\n mapping(bytes32 => bytes32) _values;\r\n }\r\n\r\n /**\r\n * @dev Adds a key-value pair to a map, or updates the value for an existing\r\n * key. O(1).\r\n *\r\n * Returns true if the key was added to the map, that is if it was not\r\n * already present.\r\n */\r\n function _set(\r\n Map storage map,\r\n bytes32 key,\r\n bytes32 value\r\n ) private returns (bool) {\r\n map._values[key] = value;\r\n return map._keys.add(key);\r\n }\r\n\r\n /**\r\n * @dev Removes a key-value pair from a map. O(1).\r\n *\r\n * Returns true if the key was removed from the map, that is if it was present.\r\n */\r\n function _remove(Map storage map, bytes32 key) private returns (bool) {\r\n delete map._values[key];\r\n return map._keys.remove(key);\r\n }\r\n\r\n /**\r\n * @dev Returns true if the key is in the map. O(1).\r\n */\r\n function _contains(Map storage map, bytes32 key) private view returns (bool) {\r\n return map._keys.contains(key);\r\n }\r\n\r\n /**\r\n * @dev Returns the number of key-value pairs in the map. O(1).\r\n */\r\n function _length(Map storage map) private view returns (uint256) {\r\n return map._keys.length();\r\n }\r\n\r\n /**\r\n * @dev Returns the key-value pair stored at position `index` in the map. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of entries inside the\r\n * array, and it may change when more entries are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {\r\n bytes32 key = map._keys.at(index);\r\n return (key, map._values[key]);\r\n }\r\n\r\n /**\r\n * @dev Tries to returns the value associated with `key`. O(1).\r\n * Does not revert if `key` is not in the map.\r\n */\r\n function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {\r\n bytes32 value = map._values[key];\r\n if (value == bytes32(0)) {\r\n return (_contains(map, key), bytes32(0));\r\n } else {\r\n return (true, value);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the value associated with `key`. O(1).\r\n *\r\n * Requirements:\r\n *\r\n * - `key` must be in the map.\r\n */\r\n function _get(Map storage map, bytes32 key) private view returns (bytes32) {\r\n bytes32 value = map._values[key];\r\n require(value != 0 || _contains(map, key), \"EnumerableMap: nonexistent key\");\r\n return value;\r\n }\r\n\r\n /**\r\n * @dev Same as {_get}, with a custom error message when `key` is not in the map.\r\n *\r\n * CAUTION: This function is deprecated because it requires allocating memory for the error\r\n * message unnecessarily. For custom revert reasons use {_tryGet}.\r\n */\r\n function _get(\r\n Map storage map,\r\n bytes32 key,\r\n string memory errorMessage\r\n ) private view returns (bytes32) {\r\n bytes32 value = map._values[key];\r\n require(value != 0 || _contains(map, key), errorMessage);\r\n return value;\r\n }\r\n\r\n // Bytes32ToUintMap\r\n struct Bytes32ToUintMap {\r\n Map _inner;\r\n }\r\n\r\n /**\r\n * @dev Adds a key-value pair to a map, or updates the value for an existing\r\n * key. O(1).\r\n *\r\n * Returns true if the key was added to the map, that is if it was not\r\n * already present.\r\n */\r\n function set(\r\n Bytes32ToUintMap storage map,\r\n bytes32 key,\r\n uint256 value\r\n ) internal returns (bool) {\r\n return _set(map._inner, key, bytes32(value));\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the key was removed from the map, that is if it was present.\r\n */\r\n function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) {\r\n return _remove(map._inner, key);\r\n }\r\n\r\n /**\r\n * @dev Returns true if the key is in the map. O(1).\r\n */\r\n function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) {\r\n return _contains(map._inner, key);\r\n }\r\n\r\n /**\r\n * @dev Returns the number of elements in the map. O(1).\r\n */\r\n function length(Bytes32ToUintMap storage map) internal view returns (uint256) {\r\n return _length(map._inner);\r\n }\r\n\r\n /**\r\n * @dev Returns the element stored at position `index` in the set. O(1).\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) {\r\n (bytes32 key, bytes32 value) = _at(map._inner, index);\r\n return (key, uint256(value));\r\n }\r\n\r\n /**\r\n * @dev Tries to returns the value associated with `key`. O(1).\r\n * Does not revert if `key` is not in the map.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {\r\n (bool success, bytes32 value) = _tryGet(map._inner, key);\r\n return (success, uint256(value));\r\n }\r\n\r\n /**\r\n * @dev Returns the value associated with `key`. O(1).\r\n *\r\n * Requirements:\r\n *\r\n * - `key` must be in the map.\r\n */\r\n function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {\r\n return uint256(_get(map._inner, key));\r\n }\r\n}\r\n" }, "/contracts/common/Descriptor.sol": { "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.4;\r\n\r\nlibrary Descriptor {\r\n bytes internal constant TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\r\n bytes internal constant FONT_DATA = \"d09GRgABAAAAACa0ABAAAAAAY/wACQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAmmAAAABwAAAAcgdpSK0dERUYAACZ4AAAAHgAAAB4AKQBoT1MvMgAAAeAAAABeAAAAYCRZSspjbWFwAAACeAAAAKAAAAFCzJGg2WN2dCAAAAVwAAAAJAAAACwJKAooZnBnbQAAA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TP9FB3sIAAAEAAf//AA8AAQAAAAwAAAAWAAAAAgABAAMAYQABAAQAAAACAAAAAAAAAAEAAAAA1+jybAAAAADUghaqAAAAANVvSRQ=\";\r\n /// @notice Encodes some bytes to the base64 representation\r\n function encode(bytes memory data) internal pure returns (string memory) {\r\n uint256 len = data.length;\r\n if (len == 0) return \"\";\r\n\r\n // multiply by 4/3 rounded up\r\n uint256 encodedLen = 4 * ((len + 2) / 3);\r\n\r\n // Add some extra buffer at the end\r\n bytes memory result = new bytes(encodedLen + 32);\r\n\r\n bytes memory table = TABLE;\r\n\r\n assembly {\r\n let tablePtr := add(table, 1)\r\n let resultPtr := add(result, 32)\r\n\r\n for {\r\n let i := 0\r\n } lt(i, len) {\r\n\r\n } {\r\n i := add(i, 3)\r\n let input := and(mload(add(data, i)), 0xffffff)\r\n\r\n let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))\r\n out := shl(8, out)\r\n out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF))\r\n out := shl(8, out)\r\n out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF))\r\n out := shl(8, out)\r\n out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))\r\n out := shl(224, out)\r\n\r\n mstore(resultPtr, out)\r\n\r\n resultPtr := add(resultPtr, 4)\r\n }\r\n\r\n switch mod(len, 3)\r\n case 1 {\r\n mstore(sub(resultPtr, 2), shl(240, 0x3d3d))\r\n }\r\n case 2 {\r\n mstore(sub(resultPtr, 1), shl(248, 0x3d))\r\n }\r\n\r\n mstore(result, encodedLen)\r\n }\r\n\r\n return string(result);\r\n }\r\n\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n if (value == 0) {\r\n return \"0\";\r\n }\r\n uint256 temp = value;\r\n uint256 digits;\r\n while (temp != 0) {\r\n digits++;\r\n temp /= 10;\r\n }\r\n bytes memory buffer = new bytes(digits);\r\n while (value != 0) {\r\n digits -= 1;\r\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\r\n value /= 10;\r\n }\r\n return string(buffer);\r\n }\r\n\r\n function GetSentenceDesc(uint256 tokenId, string memory sentence, uint24 color) public pure returns (string memory){\r\n string memory output = string(\r\n abi.encodePacked(\r\n ''\r\n )\r\n );\r\n bytes memory b = bytes(sentence);\r\n uint256 len = b.length / 29;\r\n uint256 startPosY = 35;\r\n uint256 i = 0;\r\n for (; i < len; ++i){\r\n bytes memory temp = new bytes(29);\r\n for (uint256 j = 0; j < 29; ++j){\r\n temp[j] = b[i*29+j];\r\n }\r\n bytes memory line = abi.encodePacked(\r\n '',\r\n temp,\r\n ''\r\n );\r\n output = string(abi.encodePacked(output, line));\r\n }\r\n\r\n uint256 remain = b.length % 29;\r\n if (remain > 0){\r\n bytes memory temp = new bytes(remain);\r\n for (uint256 j = 0; j < remain; ++j){\r\n temp[j] = b[i*29+j];\r\n }\r\n bytes memory line = abi.encodePacked(\r\n '',\r\n temp,\r\n ''\r\n );\r\n output = string(abi.encodePacked(output, line));\r\n }\r\n output = string(abi.encodePacked(output, \"\"));\r\n\r\n string memory json = encode(\r\n bytes(\r\n string(\r\n abi.encodePacked(\r\n '{\"name\": \"Sentence#',\r\n toString(tokenId),\r\n '\", \"description\": \"\", \"image\": \"data:image/svg+xml;base64,',\r\n encode(bytes(output)),\r\n '\"}'\r\n )\r\n )\r\n )\r\n );\r\n output = string(\r\n abi.encodePacked(\"data:application/json;base64,\", json)\r\n );\r\n\r\n return output;\r\n }\r\n\r\n\r\n function GetWordDesc(uint256 tokenId, string memory word) public pure returns (string memory) {\r\n string memory output = string(\r\n abi.encodePacked(\r\n '',\r\n word,\r\n \"\"\r\n )\r\n );\r\n string memory json = encode(\r\n bytes(\r\n string(\r\n abi.encodePacked(\r\n '{\"name\": \"Word#',\r\n toString(tokenId),\r\n '\", \"description\": \"\", \"image\": \"data:image/svg+xml;base64,',\r\n encode(bytes(output)),\r\n '\"}'\r\n )\r\n )\r\n )\r\n );\r\n output = string(\r\n abi.encodePacked(\"data:application/json;base64,\", json)\r\n );\r\n return output;\r\n }\r\n}\r\n" }, "/contracts/Word.sol": { "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.4;\r\n\r\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\r\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol\";\r\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol\";\r\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\r\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\r\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\r\nimport \"./common/EnumerableMap.sol\";\r\nimport \"./common/Descriptor.sol\";\r\n\r\ncontract Word is ERC721, ERC721Enumerable, Ownable, ReentrancyGuard {\r\n // lib\r\n using EnumerableMap for EnumerableMap.Bytes32ToUintMap;\r\n using Strings for uint256;\r\n using ECDSA for bytes32;\r\n\r\n // struct\r\n\r\n // constant\r\n uint256 public constant mintPrice = 0.1 ether;\r\n uint256 public constant sentenceWordPrice = 0.01 ether;\r\n uint256 public constant publicMintDate = 1662408000;\r\n\r\n uint256 public constant whitelistMintMaxNum = 10;\r\n uint256[] public whitelistMintPrize = [0.08 ether, 0.04 ether, 0.01 ether];\r\n uint256[] public whitelistMintDate = [1662321600, 1662235200, 1662148800];\r\n\r\n // storage\r\n uint256 private _counter;\r\n\r\n uint256 public maxSupply;\r\n\r\n mapping(bytes32 => uint256) public wordHash2TokenID;\r\n mapping(uint256 => bytes32) public wordTokenID2Hash;\r\n mapping(bytes32 => string) public wordHash2String;\r\n\r\n EnumerableMap.Bytes32ToUintMap private _lockWord;\r\n\r\n string private _basePath;\r\n\r\n uint256 public mintRevenue;\r\n\r\n address public senteceAddress;\r\n mapping(bytes32 => uint256[]) public sentenceMintTokenIDs;\r\n mapping(uint256 => uint256) public sentenceMintRevenue;\r\n\r\n address public mineAddress;\r\n\r\n uint256 public feePer = 0;\r\n\r\n mapping(address => uint256) public whitelistMintNum;\r\n address public signAddress;\r\n\r\n // event\r\n event ClaimSentenceRevenue(uint256 tokenID);\r\n event FeePerChange(uint256 newFee);\r\n\r\n constructor(address _mineAddress, address _signAddress) ERC721(\"Word\", \"WD\") {\r\n mineAddress = _mineAddress;\r\n signAddress = _signAddress;\r\n }\r\n\r\n function setSignAddress(address _signAddress) public onlyOwner{\r\n signAddress = _signAddress;\r\n }\r\n\r\n function setSentenceAddress(address addr) public onlyOwner {\r\n senteceAddress = addr;\r\n }\r\n\r\n function setMineAddress(address addr) public onlyOwner{\r\n mineAddress = addr;\r\n }\r\n\r\n function setMaxSupply(uint256 num) public onlyOwner {\r\n maxSupply = num;\r\n }\r\n\r\n function setFeePer(uint256 per) public onlyOwner{\r\n require(per <= 1000, \"per overflow\");\r\n feePer = per;\r\n emit FeePerChange(per);\r\n }\r\n\r\n function updateLockWord(string[] memory words, uint256[] memory wordDates)\r\n public\r\n onlyOwner\r\n {\r\n for (uint256 i = 0; i < words.length; ++i) {\r\n string memory tempStr = toLowerCase(words[i]);\r\n bytes32 tempHash = keccak256(bytes(tempStr));\r\n _lockWord.set(tempHash, wordDates[i]);\r\n wordHash2String[tempHash] = tempStr;\r\n }\r\n }\r\n\r\n function getAllLockWord()\r\n public\r\n view\r\n returns (string[] memory, uint256[] memory)\r\n {\r\n uint256 len = _lockWord.length();\r\n string[] memory words = new string[](len);\r\n uint256[] memory dates = new uint256[](len);\r\n bytes32 tempHash;\r\n for (uint256 i = 0; i < len; ++i) {\r\n (tempHash, dates[i]) = _lockWord.at(i);\r\n words[i] = wordHash2String[tempHash];\r\n }\r\n\r\n return (words, dates);\r\n }\r\n\r\n function toLowerCase(string memory word)\r\n public\r\n pure\r\n returns (string memory)\r\n {\r\n unchecked {\r\n bytes memory s = bytes(word);\r\n for (uint256 i = 0; i < s.length; ++i) {\r\n uint8 temp = uint8(s[i]);\r\n require(\r\n (temp >= 0x30 && temp <= 0x39) ||\r\n (temp >= 0x41 && temp <= 0x5a) ||\r\n (temp >= 0x61 && temp <= 0x7a),\r\n \"word contains illegal characters!\"\r\n );\r\n if (temp >= 0x41 && temp <= 0x5a) {\r\n s[i] = bytes1(temp + 32);\r\n }\r\n }\r\n }\r\n\r\n return word;\r\n }\r\n\r\n function whitelistMint(string memory word, uint256 level, bytes calldata sig) public payable{\r\n require(level < whitelistMintDate.length, \"level error\");\r\n require(block.timestamp >= whitelistMintDate[level], \"mint date is not enabled\");\r\n require(whitelistMintNum[msg.sender] < whitelistMintMaxNum, \"mint num limit\");\r\n require(block.timestamp < publicMintDate, \"public mint enabled\");\r\n\r\n bytes32 hash = keccak256(abi.encode(msg.sender, level, address(this)));\r\n require(hash.recover(sig) == signAddress, \"sign error\");\r\n whitelistMintNum[msg.sender]++;\r\n _mint(word, whitelistMintPrize[level]);\r\n }\r\n\r\n function mint(string memory word) public payable {\r\n require(block.timestamp >= publicMintDate, \"mint date is not enabled\");\r\n _mint(word, mintPrice);\r\n }\r\n\r\n function _mint(string memory word, uint256 price) private {\r\n require(\r\n maxSupply <= 0 || totalSupply() < maxSupply,\r\n \"max supply limit\"\r\n );\r\n word = toLowerCase(word);\r\n bytes memory s = bytes(word);\r\n bytes32 wordHash = keccak256(s);\r\n\r\n require(s.length > 0 && s.length <= 18, \"word length illegal!\");\r\n require(msg.value == price, \"eth illegal!\");\r\n require(_exists(wordHash2TokenID[wordHash]) == false, \"word exist!\");\r\n (bool suc, uint256 date) = _lockWord.tryGet(wordHash);\r\n if (suc) {\r\n require(date > 0 && block.timestamp >= date, \"word locked!\");\r\n }\r\n unchecked {\r\n mintRevenue += msg.value;\r\n _counter++;\r\n }\r\n _mint(msg.sender, _counter);\r\n wordHash2TokenID[wordHash] = _counter;\r\n wordHash2String[wordHash] = word;\r\n wordTokenID2Hash[_counter] = wordHash;\r\n }\r\n\r\n function sentenceMint(uint256 tokenID, string[] memory words)\r\n public\r\n payable\r\n {\r\n require(msg.sender == senteceAddress, \"sentence address error!\");\r\n unchecked {\r\n uint256 price = 0;\r\n uint256 mineAmount = 0;\r\n uint256 feeRevenueUnit = (sentenceWordPrice / 10000) * feePer;\r\n uint256 priceUnit = sentenceWordPrice - feeRevenueUnit;\r\n uint256 feeRevenue = 0;\r\n string memory word;\r\n bytes32 wordHash;\r\n uint256 wordTokenID;\r\n bytes32[] memory wordHashs = new bytes32[](words.length);\r\n for (uint256 i = 0; i < words.length; ++i) {\r\n word = toLowerCase(words[i]);\r\n wordHash = keccak256(bytes(word));\r\n\r\n bool find = false;\r\n for (uint256 j = 0; j < i; ++j) {\r\n if (wordHash == wordHashs[j]) {\r\n find = true;\r\n continue;\r\n }\r\n }\r\n if (find) {\r\n continue;\r\n }\r\n wordHashs[i] = wordHash;\r\n\r\n if (!isWordLock(wordHash)) {\r\n wordTokenID = wordHash2TokenID[wordHash];\r\n price += sentenceWordPrice;\r\n feeRevenue += feeRevenueUnit;\r\n if (wordTokenID != 0){\r\n sentenceMintRevenue[wordTokenID] += priceUnit;\r\n }\r\n else{\r\n mineAmount += priceUnit;\r\n }\r\n }\r\n\r\n sentenceMintTokenIDs[wordHash].push(tokenID);\r\n }\r\n\r\n mintRevenue += feeRevenue;\r\n\r\n require(msg.value == price, \"eth not enough\");\r\n if (mineAmount > 0){\r\n _sendEth(mineAddress, mineAmount);\r\n }\r\n }\r\n }\r\n\r\n function sentenceMintNum(bytes32 wordHash) public view returns (uint256){\r\n return sentenceMintTokenIDs[wordHash].length;\r\n }\r\n\r\n function queryTokenID(string memory word) public view returns (uint256) {\r\n return wordHash2TokenID[keccak256(bytes(toLowerCase(word)))];\r\n }\r\n\r\n function queryWord(uint256 tokenID) public view returns (string memory) {\r\n return wordHash2String[wordTokenID2Hash[tokenID]];\r\n }\r\n\r\n function isWordLock(bytes32 wordHash) public view returns (bool) {\r\n if (_exists(wordHash2TokenID[wordHash])) {\r\n return false;\r\n }\r\n (bool suc, uint256 date) = _lockWord.tryGet(wordHash);\r\n if (suc && (date == 0 || block.timestamp < date)) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n function getWordHash(string memory word) public pure returns (bytes32) {\r\n return keccak256(bytes(toLowerCase(word)));\r\n }\r\n\r\n function ownerClaimMintRevenue() public onlyOwner nonReentrant {\r\n _sendEth(msg.sender, mintRevenue);\r\n mintRevenue = 0;\r\n }\r\n\r\n function claimSentenceRevenue(uint256[] memory tokenIDs)\r\n public\r\n nonReentrant\r\n {\r\n unchecked {\r\n uint256 amount = 0;\r\n uint256 tokenID;\r\n for (uint256 i = 0; i < tokenIDs.length; ++i) {\r\n tokenID = tokenIDs[i];\r\n require(ownerOf(tokenID) == msg.sender, \"not owned!\");\r\n amount += sentenceMintRevenue[tokenID];\r\n sentenceMintRevenue[tokenID] = 0;\r\n\r\n emit ClaimSentenceRevenue(tokenID);\r\n }\r\n _sendEth(msg.sender, amount);\r\n }\r\n }\r\n\r\n function _sendEth(address to, uint256 value) private{\r\n (bool suc,) = to.call{value:value}(\"\");\r\n require(suc, \"sendEth fail\");\r\n }\r\n\r\n // url\r\n function setBaseURI(string calldata path) public onlyOwner {\r\n _basePath = path;\r\n }\r\n\r\n function tokenURI(uint256 tokenId)\r\n public\r\n view\r\n override\r\n returns (string memory)\r\n {\r\n require(\r\n _exists(tokenId),\r\n \"ERC721Metadata: URI query for nonexistent token\"\r\n );\r\n if (bytes(_basePath).length > 0) {\r\n return string(abi.encodePacked(_basePath, tokenId.toString()));\r\n }\r\n\r\n return Descriptor.GetWordDesc(tokenId, queryWord(tokenId));\r\n }\r\n\r\n // The following functions are overrides required by Solidity.\r\n function _beforeTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) internal override(ERC721, ERC721Enumerable) {\r\n super._beforeTokenTransfer(from, to, tokenId);\r\n }\r\n\r\n function supportsInterface(bytes4 interfaceId)\r\n public\r\n view\r\n override(ERC721, ERC721Enumerable)\r\n returns (bool)\r\n {\r\n return super.supportsInterface(interfaceId);\r\n }\r\n}\r\n" }, "/contracts/Sentence.sol": { "content": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.4;\r\n\r\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\r\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol\";\r\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol\";\r\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\r\nimport \"./common/EnumerableMap.sol\";\r\nimport \"./common/Descriptor.sol\";\r\nimport \"./Word.sol\";\r\n\r\ncontract Sentence is ERC721, ERC721Enumerable, Ownable {\r\n // lib\r\n using EnumerableMap for EnumerableMap.Bytes32ToUintMap;\r\n using Strings for uint256;\r\n\r\n // struct\r\n\r\n // constant\r\n\r\n // storage\r\n uint256 private _counter;\r\n Word public wordAddress;\r\n string private _basePath;\r\n\r\n mapping(bytes32 => uint256) public sentenceHash2TokenID;\r\n mapping(uint256 => bytes32) public sentenceTokenID2Hash;\r\n mapping(bytes32 => string) public sentenceHash2String;\r\n mapping(uint256 => uint256) public sentenceTokenID2Color;\r\n\r\n // event\r\n\r\n constructor(address _word) ERC721(\"Sentence\", \"STC\") {\r\n wordAddress = Word(_word);\r\n }\r\n\r\n function splitSentence(string memory sentence)\r\n public\r\n pure\r\n returns (string[] memory words)\r\n {\r\n bytes memory b = bytes(sentence);\r\n uint16 len = uint16(b.length);\r\n require(len >= 1 && len <= 319, \"sentence length illegal!\");\r\n\r\n uint16 count = 0;\r\n uint16 code = uint8(b[0]);\r\n require(\r\n code >= 32 && code <= 126,\r\n \"sentence contains illegal characters!\"\r\n );\r\n bool isPrevWord = (code >= 48 && code <= 57) ||\r\n (code >= 65 && code <= 90) ||\r\n (code >= 97 && code <= 122);\r\n bool isWord = false;\r\n uint16[] memory arrIndex = new uint16[](320);\r\n uint16 arrIndexIndex = 0;\r\n if (isPrevWord) {\r\n arrIndex[arrIndexIndex++] = 0;\r\n }\r\n\r\n for (uint16 i = 1; i < len - 1; ++i) {\r\n code = uint8(b[i]);\r\n require(\r\n code >= 32 && code <= 126,\r\n \"sentence contains illegal characters!\"\r\n );\r\n isWord =\r\n (code >= 48 && code <= 57) ||\r\n (code >= 65 && code <= 90) ||\r\n (code >= 97 && code <= 122);\r\n if (isWord && !isPrevWord) {\r\n arrIndex[arrIndexIndex++] = i;\r\n } else if (!isWord && isPrevWord) {\r\n arrIndex[arrIndexIndex++] = i;\r\n count++;\r\n }\r\n isPrevWord = isWord;\r\n }\r\n\r\n code = uint8(b[len - 1]);\r\n require(\r\n code >= 32 && code <= 126,\r\n \"sentence contains illegal characters!\"\r\n );\r\n isWord =\r\n (code >= 48 && code <= 57) ||\r\n (code >= 65 && code <= 90) ||\r\n (code >= 97 && code <= 122);\r\n if (isWord) {\r\n if (isPrevWord) {\r\n arrIndex[arrIndexIndex++] = len;\r\n } else {\r\n arrIndex[arrIndexIndex++] = len - 1;\r\n arrIndex[arrIndexIndex++] = len;\r\n }\r\n count++;\r\n } else {\r\n if (isPrevWord) {\r\n arrIndex[arrIndexIndex++] = len - 1;\r\n count++;\r\n }\r\n }\r\n\r\n words = new string[](count);\r\n for (uint16 i = 0; i < count; ++i) {\r\n uint16 start = arrIndex[i * 2];\r\n uint16 end = arrIndex[i * 2 + 1];\r\n bytes memory word = new bytes(end - start);\r\n for (uint16 j = start; j < end; ++j) {\r\n word[j - start] = b[j];\r\n }\r\n words[i] = string(word);\r\n }\r\n }\r\n\r\n function queryPrice(string memory sentence)\r\n public\r\n view\r\n returns (uint256 ret)\r\n {\r\n string[] memory words = splitSentence(sentence);\r\n bytes32[] memory wordHashs = new bytes32[](words.length);\r\n uint256 price = wordAddress.sentenceWordPrice();\r\n for (uint256 i = 0; i < words.length; ++i) {\r\n bytes32 wordHash = wordAddress.getWordHash(words[i]);\r\n if (wordAddress.isWordLock(wordHash)) {\r\n continue;\r\n }\r\n bool find = false;\r\n for (uint256 j = 0; j < i; ++j){\r\n if (wordHash == wordHashs[j]){\r\n find = true;\r\n continue;\r\n }\r\n }\r\n if (find){\r\n continue;\r\n }\r\n\r\n wordHashs[i] = wordHash;\r\n ret += price;\r\n }\r\n }\r\n\r\n function mint(string memory sentence, uint24 color) public payable {\r\n string[] memory words = splitSentence(sentence);\r\n\r\n bytes memory byteSentence = bytes(sentence);\r\n bytes memory byteLowerCaseSentence = new bytes(byteSentence.length);\r\n require((uint8)(byteSentence[byteSentence.length - 1]) != 32, \"space at end\");\r\n\r\n // tolowercase\r\n for (uint256 i = 0; i < byteLowerCaseSentence.length; ++i) {\r\n if (byteSentence[i] >= 0x41 && byteSentence[i] <= 0x5a) {\r\n byteLowerCaseSentence[i] = bytes1(uint8(byteSentence[i]) + 32);\r\n }\r\n else{\r\n byteLowerCaseSentence[i] = byteSentence[i];\r\n }\r\n }\r\n\r\n bytes32 hashSentence = keccak256(byteLowerCaseSentence);\r\n require(sentenceHash2TokenID[hashSentence] == 0, \"sentence exsit!\");\r\n\r\n // mint token\r\n _counter++;\r\n _mint(msg.sender, _counter);\r\n sentenceHash2TokenID[hashSentence] = _counter;\r\n sentenceHash2String[hashSentence] = sentence;\r\n sentenceTokenID2Hash[_counter] = hashSentence;\r\n sentenceTokenID2Color[_counter] = color;\r\n\r\n // word proc\r\n wordAddress.sentenceMint{value:msg.value}(_counter, words);\r\n }\r\n\r\n function queryTokenID(string memory sentence) public view returns (uint256) {\r\n bytes memory byteSentence = bytes(sentence);\r\n\r\n // tolowercase\r\n for (uint256 i = 0; i < byteSentence.length; ++i) {\r\n if (byteSentence[i] >= 0x41 && byteSentence[i] <= 0x5a) {\r\n byteSentence[i] = bytes1(uint8(byteSentence[i]) + 32);\r\n }\r\n }\r\n\r\n return sentenceHash2TokenID[keccak256(byteSentence)];\r\n }\r\n\r\n function querySentence(uint256 tokenID) public view returns (string memory) {\r\n return sentenceHash2String[sentenceTokenID2Hash[tokenID]];\r\n }\r\n\r\n // url\r\n function setBaseURI(string calldata path) public onlyOwner {\r\n _basePath = path;\r\n }\r\n\r\n function tokenURI(uint256 tokenId)\r\n public\r\n view\r\n override\r\n returns (string memory)\r\n {\r\n require(\r\n _exists(tokenId),\r\n \"ERC721Metadata: URI query for nonexistent token\"\r\n );\r\n if (bytes(_basePath).length > 0) {\r\n return string(abi.encodePacked(_basePath, tokenId.toString()));\r\n }\r\n\r\n return Descriptor.GetSentenceDesc(tokenId, sentenceHash2String[sentenceTokenID2Hash[tokenId]], uint24(sentenceTokenID2Color[tokenId]));\r\n }\r\n\r\n // The following functions are overrides required by Solidity.\r\n function _beforeTokenTransfer(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) internal override(ERC721, ERC721Enumerable) {\r\n super._beforeTokenTransfer(from, to, tokenId);\r\n }\r\n\r\n function supportsInterface(bytes4 interfaceId)\r\n public\r\n view\r\n override(ERC721, ERC721Enumerable)\r\n returns (bool)\r\n {\r\n return super.supportsInterface(interfaceId);\r\n }\r\n}\r\n" }, "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary 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 return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" }, "@openzeppelin/contracts/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/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/utils/cryptography/ECDSA.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" }, "@openzeppelin/contracts/utils/Strings.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" }, "@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/Address.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" }, "@openzeppelin/contracts/token/ERC721/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/extensions/IERC721Enumerable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" }, "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"./IERC721Enumerable.sol\";\n\n/**\n * @dev This implements an optional extension of {ERC721} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n // Mapping from owner to list of owned token IDs\n mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n // Mapping from token ID to index of the owner tokens list\n mapping(uint256 => uint256) private _ownedTokensIndex;\n\n // Array with all token ids, used for enumeration\n uint256[] private _allTokens;\n\n // Mapping from token id to position in the allTokens array\n mapping(uint256 => uint256) private _allTokensIndex;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\n require(index < ERC721.balanceOf(owner), \"ERC721Enumerable: owner index out of bounds\");\n return _ownedTokens[owner][index];\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _allTokens.length;\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\n require(index < ERC721Enumerable.totalSupply(), \"ERC721Enumerable: global index out of bounds\");\n return _allTokens[index];\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, tokenId);\n\n if (from == address(0)) {\n _addTokenToAllTokensEnumeration(tokenId);\n } else if (from != to) {\n _removeTokenFromOwnerEnumeration(from, tokenId);\n }\n if (to == address(0)) {\n _removeTokenFromAllTokensEnumeration(tokenId);\n } else if (to != from) {\n _addTokenToOwnerEnumeration(to, tokenId);\n }\n }\n\n /**\n * @dev Private function to add a token to this extension's ownership-tracking data structures.\n * @param to address representing the new owner of the given token ID\n * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n */\n function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n uint256 length = ERC721.balanceOf(to);\n _ownedTokens[to][length] = tokenId;\n _ownedTokensIndex[tokenId] = length;\n }\n\n /**\n * @dev Private function to add a token to this extension's token tracking data structures.\n * @param tokenId uint256 ID of the token to be added to the tokens list\n */\n function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n _allTokensIndex[tokenId] = _allTokens.length;\n _allTokens.push(tokenId);\n }\n\n /**\n * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n * @param from address representing the previous owner of the given token ID\n * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n */\n function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {\n // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;\n uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary\n if (tokenIndex != lastTokenIndex) {\n uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n }\n\n // This also deletes the contents at the last position of the array\n delete _ownedTokensIndex[tokenId];\n delete _ownedTokens[from][lastTokenIndex];\n }\n\n /**\n * @dev Private function to remove a token from this extension's token tracking data structures.\n * This has O(1) time complexity, but alters the order of the _allTokens array.\n * @param tokenId uint256 ID of the token to be removed from the tokens list\n */\n function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n // then delete the last slot (swap and pop).\n\n uint256 lastTokenIndex = _allTokens.length - 1;\n uint256 tokenIndex = _allTokensIndex[tokenId];\n\n // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n // This also deletes the contents at the last position of the array\n delete _allTokensIndex[tokenId];\n _allTokens.pop();\n }\n}\n" }, "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @title ERC721 Burnable Token\n * @dev ERC721 Token that can be irreversibly burned (destroyed).\n */\nabstract contract ERC721Burnable is Context, ERC721 {\n /**\n * @dev Burns `tokenId`. See {ERC721-_burn}.\n *\n * Requirements:\n *\n * - The caller must own `tokenId` or be an approved operator.\n */\n function burn(uint256 tokenId) public virtual {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721Burnable: caller is not owner nor approved\");\n _burn(tokenId);\n }\n}\n" }, "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" }, "@openzeppelin/contracts/token/ERC721/IERC721.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/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`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" }, "@openzeppelin/contracts/token/ERC721/ERC721.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\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 }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\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) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: balance query for the zero address\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: owner query for nonexistent token\");\n return owner;\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), \"ERC721Metadata: 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 * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: 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) public view virtual override returns (address) {\n require(_exists(tokenId), \"ERC721: approved query for nonexistent token\");\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\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(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\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(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\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(_checkOnERC721Received(from, to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\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 virtual returns (bool) {\n return _owners[tokenId] != address(0);\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) internal view virtual returns (bool) {\n require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\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 _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory _data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, _data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\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 require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\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(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits a {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\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 tokenId uint256 ID of the token to be transferred\n * @param _data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" }, "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" }, "@openzeppelin/contracts/token/ERC20/IERC20.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" }, "@openzeppelin/contracts/security/ReentrancyGuard.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" }, "@openzeppelin/contracts/access/Ownable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" } }, "settings": { "remappings": [], "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "london", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } } }