zellic-audit
Initial commit
f998fcd
raw
history blame
103 kB
{
"language": "Solidity",
"sources": {
"src/token/metadata/MetadataRenderer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { Base64 } from \"@openzeppelin/contracts/utils/Base64.sol\";\nimport { Strings } from \"@openzeppelin/contracts/utils/Strings.sol\";\nimport { UriEncode } from \"sol-uriencode/src/UriEncode.sol\";\nimport { MetadataBuilder } from \"micro-onchain-metadata-utils/MetadataBuilder.sol\";\nimport { MetadataJSONKeys } from \"micro-onchain-metadata-utils/MetadataJSONKeys.sol\";\n\nimport { UUPS } from \"../../lib/proxy/UUPS.sol\";\nimport { Initializable } from \"../../lib/utils/Initializable.sol\";\nimport { IOwnable } from \"../../lib/interfaces/IOwnable.sol\";\nimport { ERC721 } from \"../../lib/token/ERC721.sol\";\n\nimport { MetadataRendererStorageV1 } from \"./storage/MetadataRendererStorageV1.sol\";\nimport { MetadataRendererStorageV2 } from \"./storage/MetadataRendererStorageV2.sol\";\nimport { IToken } from \"../../token/IToken.sol\";\nimport { IPropertyIPFSMetadataRenderer } from \"./interfaces/IPropertyIPFSMetadataRenderer.sol\";\nimport { IManager } from \"../../manager/IManager.sol\";\n\n/// @title Metadata Renderer\n/// @author Iain Nash & Rohan Kulkarni\n/// @notice A DAO's artwork generator and renderer\ncontract MetadataRenderer is IPropertyIPFSMetadataRenderer, Initializable, UUPS, MetadataRendererStorageV1, MetadataRendererStorageV2 {\n /// ///\n /// IMMUTABLES ///\n /// ///\n\n /// @notice The contract upgrade manager\n IManager private immutable manager;\n\n /// ///\n /// MODIFIERS ///\n /// ///\n\n /// @notice Checks the token owner if the current action is allowed\n modifier onlyOwner() {\n if (owner() != msg.sender) {\n revert IOwnable.ONLY_OWNER();\n }\n\n _;\n }\n\n /// ///\n /// CONSTRUCTOR ///\n /// ///\n\n /// @param _manager The contract upgrade manager address\n constructor(address _manager) payable initializer {\n manager = IManager(_manager);\n }\n\n /// ///\n /// INITIALIZER ///\n /// ///\n\n /// @notice Initializes a DAO's token metadata renderer\n /// @param _initStrings The encoded token and metadata initialization strings\n /// @param _token The ERC-721 token address\n function initialize(bytes calldata _initStrings, address _token) external initializer {\n // Ensure the caller is the contract manager\n if (msg.sender != address(manager)) {\n revert ONLY_MANAGER();\n }\n\n // Decode the token initialization strings\n (, , string memory _description, string memory _contractImage, string memory _projectURI, string memory _rendererBase) = abi.decode(\n _initStrings,\n (string, string, string, string, string, string)\n );\n\n // Store the renderer settings\n settings.projectURI = _projectURI;\n settings.description = _description;\n settings.contractImage = _contractImage;\n settings.rendererBase = _rendererBase;\n settings.projectURI = _projectURI;\n settings.token = _token;\n }\n\n /// ///\n /// PROPERTIES & ITEMS ///\n /// ///\n\n /// @notice The number of properties\n function propertiesCount() external view returns (uint256) {\n return properties.length;\n }\n\n /// @notice The number of items in a property\n /// @param _propertyId The property id\n function itemsCount(uint256 _propertyId) external view returns (uint256) {\n return properties[_propertyId].items.length;\n }\n\n /// @notice Updates the additional token properties associated with the metadata.\n /// @dev Be careful to not conflict with already used keys such as \"name\", \"description\", \"properties\",\n function setAdditionalTokenProperties(AdditionalTokenProperty[] memory _additionalTokenProperties) external onlyOwner {\n delete additionalTokenProperties;\n for (uint256 i = 0; i < _additionalTokenProperties.length; i++) {\n additionalTokenProperties.push(_additionalTokenProperties[i]);\n }\n\n emit AdditionalTokenPropertiesSet(_additionalTokenProperties);\n }\n\n /// @notice Adds properties and/or items to be pseudo-randomly chosen from during token minting\n /// @param _names The names of the properties to add\n /// @param _items The items to add to each property\n /// @param _ipfsGroup The IPFS base URI and extension\n function addProperties(\n string[] calldata _names,\n ItemParam[] calldata _items,\n IPFSGroup calldata _ipfsGroup\n ) external onlyOwner {\n _addProperties(_names, _items, _ipfsGroup);\n }\n\n /// @notice Deletes existing properties and/or items to be pseudo-randomly chosen from during token minting, replacing them with provided properties. WARNING: This function can alter or break existing token metadata if the number of properties for this renderer change before/after the upsert. If the properties selected in any tokens do not exist in the new version those token will not render\n /// @dev We do not require the number of properties for an reset to match the existing property length, to allow multi-stage property additions (for e.g. when there are more properties than can fit in a single transaction)\n /// @param _names The names of the properties to add\n /// @param _items The items to add to each property\n /// @param _ipfsGroup The IPFS base URI and extension\n function deleteAndRecreateProperties(\n string[] calldata _names,\n ItemParam[] calldata _items,\n IPFSGroup calldata _ipfsGroup\n ) external onlyOwner {\n delete ipfsData;\n delete properties;\n _addProperties(_names, _items, _ipfsGroup);\n }\n\n function _addProperties(\n string[] calldata _names,\n ItemParam[] calldata _items,\n IPFSGroup calldata _ipfsGroup\n ) internal {\n // Cache the existing amount of IPFS data stored\n uint256 dataLength = ipfsData.length;\n\n // Add the IPFS group information\n ipfsData.push(_ipfsGroup);\n\n // Cache the number of existing properties\n uint256 numStoredProperties = properties.length;\n\n // Cache the number of new properties\n uint256 numNewProperties = _names.length;\n\n // Cache the number of new items\n uint256 numNewItems = _items.length;\n\n // If this is the first time adding metadata:\n if (numStoredProperties == 0) {\n // Ensure at least one property and one item are included\n if (numNewProperties == 0 || numNewItems == 0) {\n revert ONE_PROPERTY_AND_ITEM_REQUIRED();\n }\n }\n\n unchecked {\n // Check if not too many items are stored\n if (numStoredProperties + numNewProperties > 15) {\n revert TOO_MANY_PROPERTIES();\n }\n\n // For each new property:\n for (uint256 i = 0; i < numNewProperties; ++i) {\n // Append storage space\n properties.push();\n\n // Get the new property id\n uint256 propertyId = numStoredProperties + i;\n\n // Store the property name\n properties[propertyId].name = _names[i];\n\n emit PropertyAdded(propertyId, _names[i]);\n }\n\n // For each new item:\n for (uint256 i = 0; i < numNewItems; ++i) {\n // Cache the id of the associated property\n uint256 _propertyId = _items[i].propertyId;\n\n // Offset the id if the item is for a new property\n // Note: Property ids under the hood are offset by 1\n if (_items[i].isNewProperty) {\n _propertyId += numStoredProperties;\n }\n\n // Ensure the item is for a valid property\n if (_propertyId >= properties.length) {\n revert INVALID_PROPERTY_SELECTED(_propertyId);\n }\n\n // Get the pointer to the other items for the property\n Item[] storage items = properties[_propertyId].items;\n\n // Append storage space\n items.push();\n\n // Get the index of the new item\n // Cannot underflow as the items array length is ensured to be at least 1\n uint256 newItemIndex = items.length - 1;\n\n // Store the new item\n Item storage newItem = items[newItemIndex];\n\n // Store the new item's name and reference slot\n newItem.name = _items[i].name;\n newItem.referenceSlot = uint16(dataLength);\n }\n }\n }\n\n /// ///\n /// ATTRIBUTE GENERATION ///\n /// ///\n\n /// @notice Generates attributes for a token upon mint\n /// @param _tokenId The ERC-721 token id\n function onMinted(uint256 _tokenId) external override returns (bool) {\n // Ensure the caller is the token contract\n if (msg.sender != settings.token) revert ONLY_TOKEN();\n\n // Compute some randomness for the token id\n uint256 seed = _generateSeed(_tokenId);\n\n // Get the pointer to store generated attributes\n uint16[16] storage tokenAttributes = attributes[_tokenId];\n\n // Cache the total number of properties available\n uint256 numProperties = properties.length;\n\n if (numProperties == 0) {\n return false;\n }\n\n // Store the total as reference in the first slot of the token's array of attributes\n tokenAttributes[0] = uint16(numProperties);\n\n unchecked {\n // For each property:\n for (uint256 i = 0; i < numProperties; ++i) {\n // Get the number of items to choose from\n uint256 numItems = properties[i].items.length;\n\n // Use the token's seed to select an item\n tokenAttributes[i + 1] = uint16(seed % numItems);\n\n // Adjust the randomness\n seed >>= 16;\n }\n }\n\n return true;\n }\n\n /// @notice The properties and query string for a generated token\n /// @param _tokenId The ERC-721 token id\n function getAttributes(uint256 _tokenId) public view returns (string memory resultAttributes, string memory queryString) {\n // Get the token's query string\n queryString = string.concat(\n \"?contractAddress=\",\n Strings.toHexString(uint256(uint160(address(this))), 20),\n \"&tokenId=\",\n Strings.toString(_tokenId)\n );\n\n // Get the token's generated attributes\n uint16[16] memory tokenAttributes = attributes[_tokenId];\n\n // Cache the number of properties when the token was minted\n uint256 numProperties = tokenAttributes[0];\n\n // Ensure the given token was minted\n if (numProperties == 0) revert TOKEN_NOT_MINTED(_tokenId);\n\n // Get an array to store the token's generated attribtues\n MetadataBuilder.JSONItem[] memory arrayAttributesItems = new MetadataBuilder.JSONItem[](numProperties);\n\n unchecked {\n // For each of the token's properties:\n for (uint256 i = 0; i < numProperties; ++i) {\n // Get its name and list of associated items\n Property memory property = properties[i];\n\n // Get the randomly generated index of the item to select for this token\n uint256 attribute = tokenAttributes[i + 1];\n\n // Get the associated item data\n Item memory item = property.items[attribute];\n\n // Store the encoded attributes and query string\n MetadataBuilder.JSONItem memory itemJSON = arrayAttributesItems[i];\n\n itemJSON.key = property.name;\n itemJSON.value = item.name;\n itemJSON.quote = true;\n\n queryString = string.concat(queryString, \"&images=\", _getItemImage(item, property.name));\n }\n\n resultAttributes = MetadataBuilder.generateJSON(arrayAttributesItems);\n }\n }\n\n /// @dev Generates a psuedo-random seed for a token id\n function _generateSeed(uint256 _tokenId) private view returns (uint256) {\n return uint256(keccak256(abi.encode(_tokenId, blockhash(block.number), block.coinbase, block.timestamp)));\n }\n\n /// @dev Encodes the reference URI of an item\n function _getItemImage(Item memory _item, string memory _propertyName) private view returns (string memory) {\n return\n UriEncode.uriEncode(\n string(\n abi.encodePacked(ipfsData[_item.referenceSlot].baseUri, _propertyName, \"/\", _item.name, ipfsData[_item.referenceSlot].extension)\n )\n );\n }\n\n /// ///\n /// URIs ///\n /// ///\n\n /// @notice Internal getter function for token name\n function _name() internal view returns (string memory) {\n return ERC721(settings.token).name();\n }\n\n /// @notice The contract URI\n function contractURI() external view override returns (string memory) {\n MetadataBuilder.JSONItem[] memory items = new MetadataBuilder.JSONItem[](4);\n\n items[0] = MetadataBuilder.JSONItem({ key: MetadataJSONKeys.keyName, value: _name(), quote: true });\n items[1] = MetadataBuilder.JSONItem({ key: MetadataJSONKeys.keyDescription, value: settings.description, quote: true });\n items[2] = MetadataBuilder.JSONItem({ key: MetadataJSONKeys.keyImage, value: settings.contractImage, quote: true });\n items[3] = MetadataBuilder.JSONItem({ key: \"external_url\", value: settings.projectURI, quote: true });\n\n return MetadataBuilder.generateEncodedJSON(items);\n }\n\n /// @notice The token URI\n /// @param _tokenId The ERC-721 token id\n function tokenURI(uint256 _tokenId) external view returns (string memory) {\n (string memory _attributes, string memory queryString) = getAttributes(_tokenId);\n\n MetadataBuilder.JSONItem[] memory items = new MetadataBuilder.JSONItem[](4 + additionalTokenProperties.length);\n\n items[0] = MetadataBuilder.JSONItem({\n key: MetadataJSONKeys.keyName,\n value: string.concat(_name(), \" #\", Strings.toString(_tokenId)),\n quote: true\n });\n items[1] = MetadataBuilder.JSONItem({ key: MetadataJSONKeys.keyDescription, value: settings.description, quote: true });\n items[2] = MetadataBuilder.JSONItem({\n key: MetadataJSONKeys.keyImage,\n value: string.concat(settings.rendererBase, queryString),\n quote: true\n });\n items[3] = MetadataBuilder.JSONItem({ key: MetadataJSONKeys.keyProperties, value: _attributes, quote: false });\n\n for (uint256 i = 0; i < additionalTokenProperties.length; i++) {\n AdditionalTokenProperty memory tokenProperties = additionalTokenProperties[i];\n items[4 + i] = MetadataBuilder.JSONItem({ key: tokenProperties.key, value: tokenProperties.value, quote: tokenProperties.quote });\n }\n\n return MetadataBuilder.generateEncodedJSON(items);\n }\n\n /// ///\n /// METADATA SETTINGS ///\n /// ///\n\n /// @notice The associated ERC-721 token\n function token() external view returns (address) {\n return settings.token;\n }\n\n /// @notice The contract image\n function contractImage() external view returns (string memory) {\n return settings.contractImage;\n }\n\n /// @notice The renderer base\n function rendererBase() external view returns (string memory) {\n return settings.rendererBase;\n }\n\n /// @notice The collection description\n function description() external view returns (string memory) {\n return settings.description;\n }\n\n /// @notice The collection description\n function projectURI() external view returns (string memory) {\n return settings.projectURI;\n }\n\n /// @notice Get the owner of the metadata (here delegated to the token owner)\n function owner() public view returns (address) {\n return IOwnable(settings.token).owner();\n }\n\n /// ///\n /// UPDATE SETTINGS ///\n /// ///\n\n /// @notice Updates the contract image\n /// @param _newContractImage The new contract image\n function updateContractImage(string memory _newContractImage) external onlyOwner {\n emit ContractImageUpdated(settings.contractImage, _newContractImage);\n\n settings.contractImage = _newContractImage;\n }\n\n /// @notice Updates the renderer base\n /// @param _newRendererBase The new renderer base\n function updateRendererBase(string memory _newRendererBase) external onlyOwner {\n emit RendererBaseUpdated(settings.rendererBase, _newRendererBase);\n\n settings.rendererBase = _newRendererBase;\n }\n\n /// @notice Updates the collection description\n /// @param _newDescription The new description\n function updateDescription(string memory _newDescription) external onlyOwner {\n emit DescriptionUpdated(settings.description, _newDescription);\n\n settings.description = _newDescription;\n }\n\n function updateProjectURI(string memory _newProjectURI) external onlyOwner {\n emit WebsiteURIUpdated(settings.projectURI, _newProjectURI);\n\n settings.projectURI = _newProjectURI;\n }\n\n /// ///\n /// METADATA UPGRADE ///\n /// ///\n\n /// @notice Ensures the caller is authorized to upgrade the contract to a valid implementation\n /// @dev This function is called in UUPS `upgradeTo` & `upgradeToAndCall`\n /// @param _impl The address of the new implementation\n function _authorizeUpgrade(address _impl) internal view override onlyOwner {\n if (!manager.isRegisteredUpgrade(_getImplementation(), _impl)) revert INVALID_UPGRADE(_impl);\n }\n}\n"
},
"node_modules/@openzeppelin/contracts/utils/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"node_modules/@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (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 uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // 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 /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"node_modules/sol-uriencode/src/UriEncode.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nlibrary UriEncode {\n string internal constant _TABLE = \"0123456789abcdef\";\n\n function uriEncode(string memory uri)\n internal\n pure\n returns (string memory)\n {\n bytes memory bytesUri = bytes(uri);\n\n string memory table = _TABLE;\n\n // Max size is worse case all chars need to be encoded\n bytes memory result = new bytes(3 * bytesUri.length);\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get the lookup table\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Keep track of the final result size string length\n let resultSize := 0\n\n for {\n let dataPtr := bytesUri\n let endPtr := add(bytesUri, mload(bytesUri))\n } lt(dataPtr, endPtr) {\n\n } {\n // advance 1 byte\n dataPtr := add(dataPtr, 1)\n // bytemask out a char\n let input := and(mload(dataPtr), 255)\n\n // Check if is valid URI character\n let isValidUriChar := or(\n and(gt(input, 96), lt(input, 134)), // a 97 / z 133\n or(\n and(gt(input, 64), lt(input, 91)), // A 65 / Z 90\n or(\n and(gt(input, 47), lt(input, 58)), // 0 48 / 9 57\n or(\n or(\n eq(input, 46), // . 46\n eq(input, 95) // _ 95\n ),\n or(\n eq(input, 45), // - 45\n eq(input, 126) // ~ 126\n )\n )\n )\n )\n )\n\n switch isValidUriChar\n // If is valid uri character copy character over and increment the result\n case 1 {\n mstore8(resultPtr, input)\n resultPtr := add(resultPtr, 1)\n resultSize := add(resultSize, 1)\n }\n // If the char is not a valid uri character, uriencode the character\n case 0 {\n mstore8(resultPtr, 37)\n resultPtr := add(resultPtr, 1)\n // table[character >> 4] (take the last 4 bits)\n mstore8(resultPtr, mload(add(tablePtr, shr(4, input))))\n resultPtr := add(resultPtr, 1)\n // table & 15 (take the first 4 bits)\n mstore8(resultPtr, mload(add(tablePtr, and(input, 15))))\n resultPtr := add(resultPtr, 1)\n resultSize := add(resultSize, 3)\n }\n }\n\n // Set size of result string in memory\n mstore(result, resultSize)\n }\n\n return string(result);\n }\n}\n"
},
"node_modules/micro-onchain-metadata-utils/src/MetadataBuilder.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nimport {Base64} from \"./lib/Base64.sol\";\nimport {Strings} from \"./lib/Strings.sol\";\nimport {MetadataMIMETypes} from \"./MetadataMIMETypes.sol\";\n\nlibrary MetadataBuilder {\n struct JSONItem {\n string key;\n string value;\n bool quote;\n }\n\n function generateSVG(\n string memory contents,\n string memory viewBox,\n string memory width,\n string memory height\n ) internal pure returns (string memory) {\n return\n string.concat(\n '<svg viewBox=\"',\n viewBox,\n '\" xmlns=\"http://www.w3.org/2000/svg\" width=\"',\n width,\n '\" height=\"',\n height,\n '\">',\n contents,\n \"</svg>\"\n );\n }\n\n /// @notice prefer to use properties with key-value object instead of list\n function generateAttributes(string memory displayType, string memory traitType, string memory value) internal pure returns (string memory) {\n\n }\n\n function generateEncodedSVG(\n string memory contents,\n string memory viewBox,\n string memory width,\n string memory height\n ) internal pure returns (string memory) {\n return\n encodeURI(\n MetadataMIMETypes.mimeSVG,\n generateSVG(contents, viewBox, width, height)\n );\n }\n\n function encodeURI(string memory uriType, string memory result)\n internal\n pure\n returns (string memory)\n {\n return\n string.concat(\n \"data:\",\n uriType,\n \";base64,\",\n string(Base64.encode(bytes(result)))\n );\n }\n\n function generateJSONArray(JSONItem[] memory items)\n internal\n pure\n returns (string memory result)\n {\n result = \"[\";\n uint256 added = 0;\n for (uint256 i = 0; i < items.length; i++) {\n if (bytes(items[i].value).length == 0) {\n continue;\n }\n if (items[i].quote) {\n result = string.concat(\n result,\n added == 0 ? \"\" : \",\",\n '\"',\n items[i].value,\n '\"'\n );\n } else {\n result = string.concat(\n result,\n added == 0 ? \"\" : \",\",\n items[i].value\n );\n }\n added += 1;\n }\n result = string.concat(result, \"]\");\n }\n\n function generateJSON(JSONItem[] memory items)\n internal\n pure\n returns (string memory result)\n {\n result = \"{\";\n uint256 added = 0;\n for (uint256 i = 0; i < items.length; i++) {\n if (bytes(items[i].value).length == 0) {\n continue;\n }\n if (items[i].quote) {\n result = string.concat(\n result,\n added == 0 ? \"\" : \",\",\n '\"',\n items[i].key,\n '\": \"',\n items[i].value,\n '\"'\n );\n } else {\n result = string.concat(\n result,\n added == 0 ? \"\" : \",\",\n '\"',\n items[i].key,\n '\": ',\n items[i].value\n );\n }\n added += 1;\n }\n result = string.concat(result, \"}\");\n }\n\n function generateEncodedJSON(JSONItem[] memory items)\n internal\n pure\n returns (string memory)\n {\n return encodeURI(MetadataMIMETypes.mimeJSON, generateJSON(items));\n }\n}\n"
},
"node_modules/micro-onchain-metadata-utils/src/MetadataJSONKeys.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nlibrary MetadataJSONKeys {\n string constant keyName = \"name\";\n string constant keyDescription = \"description\";\n string constant keyImage = \"image\";\n string constant keyAnimationURL = \"animation_url\";\n string constant keyAttributes = \"attributes\";\n string constant keyProperties = \"properties\";\n}"
},
"src/lib/proxy/UUPS.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../interfaces/IUUPS.sol\";\nimport { ERC1967Upgrade } from \"./ERC1967Upgrade.sol\";\n\n/// @title UUPS\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (proxy/utils/UUPSUpgradeable.sol)\n/// - Uses custom errors declared in IUUPS\n/// - Inherits a modern, minimal ERC1967Upgrade\nabstract contract UUPS is IUUPS, ERC1967Upgrade {\n /// ///\n /// IMMUTABLES ///\n /// ///\n\n /// @dev The address of the implementation\n address private immutable __self = address(this);\n\n /// ///\n /// MODIFIERS ///\n /// ///\n\n /// @dev Ensures that execution is via proxy delegatecall with the correct implementation\n modifier onlyProxy() {\n if (address(this) == __self) revert ONLY_DELEGATECALL();\n if (_getImplementation() != __self) revert ONLY_PROXY();\n _;\n }\n\n /// @dev Ensures that execution is via direct call\n modifier notDelegated() {\n if (address(this) != __self) revert ONLY_CALL();\n _;\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Hook to authorize an implementation upgrade\n /// @param _newImpl The new implementation address\n function _authorizeUpgrade(address _newImpl) internal virtual;\n\n /// @notice Upgrades to an implementation\n /// @param _newImpl The new implementation address\n function upgradeTo(address _newImpl) external onlyProxy {\n _authorizeUpgrade(_newImpl);\n _upgradeToAndCallUUPS(_newImpl, \"\", false);\n }\n\n /// @notice Upgrades to an implementation with an additional function call\n /// @param _newImpl The new implementation address\n /// @param _data The encoded function call\n function upgradeToAndCall(address _newImpl, bytes memory _data) external payable onlyProxy {\n _authorizeUpgrade(_newImpl);\n _upgradeToAndCallUUPS(_newImpl, _data, true);\n }\n\n /// @notice The storage slot of the implementation address\n function proxiableUUID() external view notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n}\n"
},
"src/lib/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IInitializable } from \"../interfaces/IInitializable.sol\";\nimport { Address } from \"../utils/Address.sol\";\n\n/// @title Initializable\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (proxy/utils/Initializable.sol)\n/// - Uses custom errors declared in IInitializable\nabstract contract Initializable is IInitializable {\n /// ///\n /// STORAGE ///\n /// ///\n\n /// @dev Indicates the contract has been initialized\n uint8 internal _initialized;\n\n /// @dev Indicates the contract is being initialized\n bool internal _initializing;\n\n /// ///\n /// MODIFIERS ///\n /// ///\n\n /// @dev Ensures an initialization function is only called within an `initializer` or `reinitializer` function\n modifier onlyInitializing() {\n if (!_initializing) revert NOT_INITIALIZING();\n _;\n }\n\n /// @dev Enables initializing upgradeable contracts\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n\n if ((!isTopLevelCall || _initialized != 0) && (Address.isContract(address(this)) || _initialized != 1)) revert ALREADY_INITIALIZED();\n\n _initialized = 1;\n\n if (isTopLevelCall) {\n _initializing = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n\n emit Initialized(1);\n }\n }\n\n /// @dev Enables initializer versioning\n /// @param _version The version to set\n modifier reinitializer(uint8 _version) {\n if (_initializing || _initialized >= _version) revert ALREADY_INITIALIZED();\n\n _initialized = _version;\n\n _initializing = true;\n\n _;\n\n _initializing = false;\n\n emit Initialized(_version);\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Prevents future initialization\n function _disableInitializers() internal virtual {\n if (_initializing) revert INITIALIZING();\n\n if (_initialized < type(uint8).max) {\n _initialized = type(uint8).max;\n\n emit Initialized(type(uint8).max);\n }\n }\n}\n"
},
"src/lib/interfaces/IOwnable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IOwnable\n/// @author Rohan Kulkarni\n/// @notice The external Ownable events, errors, and functions\ninterface IOwnable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when ownership has been updated\n /// @param prevOwner The previous owner address\n /// @param newOwner The new owner address\n event OwnerUpdated(address indexed prevOwner, address indexed newOwner);\n\n /// @notice Emitted when an ownership transfer is pending\n /// @param owner The current owner address\n /// @param pendingOwner The pending new owner address\n event OwnerPending(address indexed owner, address indexed pendingOwner);\n\n /// @notice Emitted when a pending ownership transfer has been canceled\n /// @param owner The current owner address\n /// @param canceledOwner The canceled owner address\n event OwnerCanceled(address indexed owner, address indexed canceledOwner);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if an unauthorized user calls an owner function\n error ONLY_OWNER();\n\n /// @dev Reverts if an unauthorized user calls a pending owner function\n error ONLY_PENDING_OWNER();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The address of the owner\n function owner() external view returns (address);\n\n /// @notice The address of the pending owner\n function pendingOwner() external view returns (address);\n\n /// @notice Forces an ownership transfer\n /// @param newOwner The new owner address\n function transferOwnership(address newOwner) external;\n\n /// @notice Initiates a two-step ownership transfer\n /// @param newOwner The new owner address\n function safeTransferOwnership(address newOwner) external;\n\n /// @notice Accepts an ownership transfer\n function acceptOwnership() external;\n\n /// @notice Cancels a pending ownership transfer\n function cancelOwnershipTransfer() external;\n}\n"
},
"src/lib/token/ERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IERC721 } from \"../interfaces/IERC721.sol\";\nimport { Initializable } from \"../utils/Initializable.sol\";\nimport { ERC721TokenReceiver } from \"../utils/TokenReceiver.sol\";\nimport { Address } from \"../utils/Address.sol\";\n\n/// @title ERC721\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (token/ERC721/ERC721Upgradeable.sol)\n/// - Uses custom errors declared in IERC721\nabstract contract ERC721 is IERC721, Initializable {\n /// ///\n /// STORAGE ///\n /// ///\n\n /// @notice The token name\n string public name;\n\n /// @notice The token symbol\n string public symbol;\n\n /// @notice The token owners\n /// @dev ERC-721 token id => Owner\n mapping(uint256 => address) internal owners;\n\n /// @notice The owner balances\n /// @dev Owner => Balance\n mapping(address => uint256) internal balances;\n\n /// @notice The token approvals\n /// @dev ERC-721 token id => Manager\n mapping(uint256 => address) internal tokenApprovals;\n\n /// @notice The balance approvals\n /// @dev Owner => Operator => Approved\n mapping(address => mapping(address => bool)) internal operatorApprovals;\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Initializes an ERC-721 token\n /// @param _name The ERC-721 token name\n /// @param _symbol The ERC-721 token symbol\n function __ERC721_init(string memory _name, string memory _symbol) internal onlyInitializing {\n name = _name;\n symbol = _symbol;\n }\n\n /// @notice The token URI\n /// @param _tokenId The ERC-721 token id\n function tokenURI(uint256 _tokenId) public view virtual returns (string memory) {}\n\n /// @notice The contract URI\n function contractURI() public view virtual returns (string memory) {}\n\n /// @notice If the contract implements an interface\n /// @param _interfaceId The interface id\n function supportsInterface(bytes4 _interfaceId) external pure returns (bool) {\n return\n _interfaceId == 0x01ffc9a7 || // ERC165 Interface ID\n _interfaceId == 0x80ac58cd || // ERC721 Interface ID\n _interfaceId == 0x5b5e139f; // ERC721Metadata Interface ID\n }\n\n /// @notice The account approved to manage a token\n /// @param _tokenId The ERC-721 token id\n function getApproved(uint256 _tokenId) external view returns (address) {\n return tokenApprovals[_tokenId];\n }\n\n /// @notice If an operator is authorized to manage all of an owner's tokens\n /// @param _owner The owner address\n /// @param _operator The operator address\n function isApprovedForAll(address _owner, address _operator) external view returns (bool) {\n return operatorApprovals[_owner][_operator];\n }\n\n /// @notice The number of tokens owned\n /// @param _owner The owner address\n function balanceOf(address _owner) public view returns (uint256) {\n if (_owner == address(0)) revert ADDRESS_ZERO();\n\n return balances[_owner];\n }\n\n /// @notice The owner of a token\n /// @param _tokenId The ERC-721 token id\n function ownerOf(uint256 _tokenId) public view returns (address) {\n address owner = owners[_tokenId];\n\n if (owner == address(0)) revert INVALID_OWNER();\n\n return owner;\n }\n\n /// @notice Authorizes an account to manage a token\n /// @param _to The account address\n /// @param _tokenId The ERC-721 token id\n function approve(address _to, uint256 _tokenId) external {\n address owner = owners[_tokenId];\n\n if (msg.sender != owner && !operatorApprovals[owner][msg.sender]) revert INVALID_APPROVAL();\n\n tokenApprovals[_tokenId] = _to;\n\n emit Approval(owner, _to, _tokenId);\n }\n\n /// @notice Authorizes an account to manage all tokens\n /// @param _operator The account address\n /// @param _approved If permission is being given or removed\n function setApprovalForAll(address _operator, bool _approved) external {\n operatorApprovals[msg.sender][_operator] = _approved;\n\n emit ApprovalForAll(msg.sender, _operator, _approved);\n }\n\n /// @notice Transfers a token from sender to recipient\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function transferFrom(\n address _from,\n address _to,\n uint256 _tokenId\n ) public {\n if (_from != owners[_tokenId]) revert INVALID_OWNER();\n\n if (_to == address(0)) revert ADDRESS_ZERO();\n\n if (msg.sender != _from && !operatorApprovals[_from][msg.sender] && msg.sender != tokenApprovals[_tokenId]) revert INVALID_APPROVAL();\n\n _beforeTokenTransfer(_from, _to, _tokenId);\n\n unchecked {\n --balances[_from];\n\n ++balances[_to];\n }\n\n owners[_tokenId] = _to;\n\n delete tokenApprovals[_tokenId];\n\n emit Transfer(_from, _to, _tokenId);\n\n _afterTokenTransfer(_from, _to, _tokenId);\n }\n\n /// @notice Safe transfers a token from sender to recipient\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function safeTransferFrom(\n address _from,\n address _to,\n uint256 _tokenId\n ) external {\n transferFrom(_from, _to, _tokenId);\n\n if (\n Address.isContract(_to) &&\n ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, \"\") != ERC721TokenReceiver.onERC721Received.selector\n ) revert INVALID_RECIPIENT();\n }\n\n /// @notice Safe transfers a token from sender to recipient with additional data\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function safeTransferFrom(\n address _from,\n address _to,\n uint256 _tokenId,\n bytes calldata _data\n ) external {\n transferFrom(_from, _to, _tokenId);\n\n if (\n Address.isContract(_to) &&\n ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data) != ERC721TokenReceiver.onERC721Received.selector\n ) revert INVALID_RECIPIENT();\n }\n\n /// @dev Mints a token to a recipient\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function _mint(address _to, uint256 _tokenId) internal virtual {\n if (_to == address(0)) revert ADDRESS_ZERO();\n\n if (owners[_tokenId] != address(0)) revert ALREADY_MINTED();\n\n _beforeTokenTransfer(address(0), _to, _tokenId);\n\n unchecked {\n ++balances[_to];\n }\n\n owners[_tokenId] = _to;\n\n emit Transfer(address(0), _to, _tokenId);\n\n _afterTokenTransfer(address(0), _to, _tokenId);\n }\n\n /// @dev Burns a token to a recipient\n /// @param _tokenId The ERC-721 token id\n function _burn(uint256 _tokenId) internal virtual {\n address owner = owners[_tokenId];\n\n if (owner == address(0)) revert NOT_MINTED();\n\n _beforeTokenTransfer(owner, address(0), _tokenId);\n\n unchecked {\n --balances[owner];\n }\n\n delete owners[_tokenId];\n\n delete tokenApprovals[_tokenId];\n\n emit Transfer(owner, address(0), _tokenId);\n\n _afterTokenTransfer(owner, address(0), _tokenId);\n }\n\n /// @dev Hook called before a token transfer\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function _beforeTokenTransfer(\n address _from,\n address _to,\n uint256 _tokenId\n ) internal virtual {}\n\n /// @dev Hook called after a token transfer\n /// @param _from The sender address\n /// @param _to The recipient address\n /// @param _tokenId The ERC-721 token id\n function _afterTokenTransfer(\n address _from,\n address _to,\n uint256 _tokenId\n ) internal virtual {}\n}\n"
},
"src/token/metadata/storage/MetadataRendererStorageV1.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { MetadataRendererTypesV1 } from \"../types/MetadataRendererTypesV1.sol\";\n\n/// @title MetadataRendererTypesV1\n/// @author Iain Nash & Rohan Kulkarni\n/// @notice The Metadata Renderer storage contract\ncontract MetadataRendererStorageV1 is MetadataRendererTypesV1 {\n /// @notice The metadata renderer settings\n Settings internal settings;\n\n /// @notice The properties chosen from upon generation\n Property[] internal properties;\n\n /// @notice The IPFS data of all property items\n IPFSGroup[] internal ipfsData;\n\n /// @notice The attributes generated for a token\n mapping(uint256 => uint16[16]) internal attributes;\n}\n"
},
"src/token/metadata/storage/MetadataRendererStorageV2.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { MetadataRendererTypesV2 } from \"../types/MetadataRendererTypesV2.sol\";\n\n/// @title MetadataRendererTypesV1\n/// @author Iain Nash & Rohan Kulkarni\n/// @notice The Metadata Renderer storage contract\ncontract MetadataRendererStorageV2 is MetadataRendererTypesV2 {\n /// @notice Additional JSON key/value properties for each token.\n /// @dev While strings are quoted, JSON needs to be escaped.\n AdditionalTokenProperty[] internal additionalTokenProperties;\n}\n"
},
"src/token/IToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../lib/interfaces/IUUPS.sol\";\nimport { IERC721Votes } from \"../lib/interfaces/IERC721Votes.sol\";\nimport { IManager } from \"../manager/IManager.sol\";\nimport { TokenTypesV1 } from \"./types/TokenTypesV1.sol\";\n\n/// @title IToken\n/// @author Rohan Kulkarni\n/// @notice The external Token events, errors and functions\ninterface IToken is IUUPS, IERC721Votes, TokenTypesV1 {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a token is scheduled to be allocated\n /// @param baseTokenId The\n /// @param founderId The founder's id\n /// @param founder The founder's vesting details\n event MintScheduled(uint256 baseTokenId, uint256 founderId, Founder founder);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the founder ownership exceeds 100 percent\n error INVALID_FOUNDER_OWNERSHIP();\n\n /// @dev Reverts if the caller was not the auction contract\n error ONLY_AUCTION();\n\n /// @dev Reverts if no metadata was generated upon mint\n error NO_METADATA_GENERATED();\n\n /// @dev Reverts if the caller was not the contract manager\n error ONLY_MANAGER();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Initializes a DAO's ERC-721 token\n /// @param founders The founding members to receive vesting allocations\n /// @param initStrings The encoded token and metadata initialization strings\n /// @param metadataRenderer The token's metadata renderer\n /// @param auction The token's auction house\n function initialize(\n IManager.FounderParams[] calldata founders,\n bytes calldata initStrings,\n address metadataRenderer,\n address auction,\n address initialOwner\n ) external;\n\n /// @notice Mints tokens to the auction house for bidding and handles founder vesting\n function mint() external returns (uint256 tokenId);\n\n /// @notice Burns a token that did not see any bids\n /// @param tokenId The ERC-721 token id\n function burn(uint256 tokenId) external;\n\n /// @notice The URI for a token\n /// @param tokenId The ERC-721 token id\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n /// @notice The URI for the contract\n function contractURI() external view returns (string memory);\n\n /// @notice The number of founders\n function totalFounders() external view returns (uint256);\n\n /// @notice The founders total percent ownership\n function totalFounderOwnership() external view returns (uint256);\n\n /// @notice The vesting details of a founder\n /// @param founderId The founder id\n function getFounder(uint256 founderId) external view returns (Founder memory);\n\n /// @notice The vesting details of all founders\n function getFounders() external view returns (Founder[] memory);\n\n /// @notice The founder scheduled to receive the given token id\n /// NOTE: If a founder is returned, there's no guarantee they'll receive the token as vesting expiration is not considered\n /// @param tokenId The ERC-721 token id\n function getScheduledRecipient(uint256 tokenId) external view returns (Founder memory);\n\n /// @notice The total supply of tokens\n function totalSupply() external view returns (uint256);\n\n /// @notice The token's auction house\n function auction() external view returns (address);\n\n /// @notice The token's metadata renderer\n function metadataRenderer() external view returns (address);\n\n /// @notice The owner of the token and metadata renderer\n function owner() external view returns (address);\n\n /// @notice Callback called by auction on first auction started to transfer ownership to treasury from founder\n function onFirstAuctionStarted() external;\n}\n"
},
"src/token/metadata/interfaces/IPropertyIPFSMetadataRenderer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { MetadataRendererTypesV1 } from \"../types/MetadataRendererTypesV1.sol\";\nimport { MetadataRendererTypesV2 } from \"../types/MetadataRendererTypesV2.sol\";\nimport { IBaseMetadata } from \"./IBaseMetadata.sol\";\n\n/// @title IPropertyIPFSMetadataRenderer\n/// @author Iain Nash & Rohan Kulkarni\n/// @notice The external Metadata Renderer events, errors, and functions\ninterface IPropertyIPFSMetadataRenderer is IBaseMetadata, MetadataRendererTypesV1, MetadataRendererTypesV2 {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a property is added\n event PropertyAdded(uint256 id, string name);\n\n /// @notice Additional token properties have been set\n event AdditionalTokenPropertiesSet(AdditionalTokenProperty[] _additionalJsonProperties);\n\n /// @notice Emitted when the contract image is updated\n event ContractImageUpdated(string prevImage, string newImage);\n\n /// @notice Emitted when the renderer base is updated\n event RendererBaseUpdated(string prevRendererBase, string newRendererBase);\n\n /// @notice Emitted when the collection description is updated\n event DescriptionUpdated(string prevDescription, string newDescription);\n\n /// @notice Emitted when the collection uri is updated\n event WebsiteURIUpdated(string lastURI, string newURI);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the caller isn't the token contract\n error ONLY_TOKEN();\n\n /// @dev Reverts if querying attributes for a token not minted\n error TOKEN_NOT_MINTED(uint256 tokenId);\n\n /// @dev Reverts if the founder does not include both a property and item during the initial artwork upload\n error ONE_PROPERTY_AND_ITEM_REQUIRED();\n\n /// @dev Reverts if an item is added for a non-existent property\n error INVALID_PROPERTY_SELECTED(uint256 selectedPropertyId);\n\n ///\n error TOO_MANY_PROPERTIES();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Adds properties and/or items to be pseudo-randomly chosen from during token minting\n /// @param names The names of the properties to add\n /// @param items The items to add to each property\n /// @param ipfsGroup The IPFS base URI and extension\n function addProperties(\n string[] calldata names,\n ItemParam[] calldata items,\n IPFSGroup calldata ipfsGroup\n ) external;\n\n /// @notice The number of properties\n function propertiesCount() external view returns (uint256);\n\n /// @notice The number of items in a property\n /// @param propertyId The property id\n function itemsCount(uint256 propertyId) external view returns (uint256);\n\n /// @notice The properties and query string for a generated token\n /// @param tokenId The ERC-721 token id\n function getAttributes(uint256 tokenId) external view returns (string memory resultAttributes, string memory queryString);\n\n /// @notice The contract image\n function contractImage() external view returns (string memory);\n\n /// @notice The renderer base\n function rendererBase() external view returns (string memory);\n\n /// @notice The collection description\n function description() external view returns (string memory);\n\n /// @notice Updates the contract image\n /// @param newContractImage The new contract image\n function updateContractImage(string memory newContractImage) external;\n\n /// @notice Updates the renderer base\n /// @param newRendererBase The new renderer base\n function updateRendererBase(string memory newRendererBase) external;\n\n /// @notice Updates the collection description\n /// @param newDescription The new description\n function updateDescription(string memory newDescription) external;\n}\n"
},
"src/manager/IManager.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../lib/interfaces/IUUPS.sol\";\nimport { IOwnable } from \"../lib/interfaces/IOwnable.sol\";\n\n/// @title IManager\n/// @author Rohan Kulkarni\n/// @notice The external Manager events, errors, structs and functions\ninterface IManager is IUUPS, IOwnable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a DAO is deployed\n /// @param token The ERC-721 token address\n /// @param metadata The metadata renderer address\n /// @param auction The auction address\n /// @param treasury The treasury address\n /// @param governor The governor address\n event DAODeployed(address token, address metadata, address auction, address treasury, address governor);\n\n /// @notice Emitted when an upgrade is registered by the Builder DAO\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n event UpgradeRegistered(address baseImpl, address upgradeImpl);\n\n /// @notice Emitted when an upgrade is unregistered by the Builder DAO\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n event UpgradeRemoved(address baseImpl, address upgradeImpl);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if at least one founder is not provided upon deploy\n error FOUNDER_REQUIRED();\n\n /// ///\n /// STRUCTS ///\n /// ///\n\n /// @notice The founder parameters\n /// @param wallet The wallet address\n /// @param ownershipPct The percent ownership of the token\n /// @param vestExpiry The timestamp that vesting expires\n struct FounderParams {\n address wallet;\n uint256 ownershipPct;\n uint256 vestExpiry;\n }\n\n /// @notice The ERC-721 token parameters\n /// @param initStrings The encoded token name, symbol, collection description, collection image uri, renderer base uri\n struct TokenParams {\n bytes initStrings;\n }\n\n /// @notice The auction parameters\n /// @param reservePrice The reserve price of each auction\n /// @param duration The duration of each auction\n struct AuctionParams {\n uint256 reservePrice;\n uint256 duration;\n }\n\n /// @notice The governance parameters\n /// @param timelockDelay The time delay to execute a queued transaction\n /// @param votingDelay The time delay to vote on a created proposal\n /// @param votingPeriod The time period to vote on a proposal\n /// @param proposalThresholdBps The basis points of the token supply required to create a proposal\n /// @param quorumThresholdBps The basis points of the token supply required to reach quorum\n /// @param vetoer The address authorized to veto proposals (address(0) if none desired)\n struct GovParams {\n uint256 timelockDelay;\n uint256 votingDelay;\n uint256 votingPeriod;\n uint256 proposalThresholdBps;\n uint256 quorumThresholdBps;\n address vetoer;\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The token implementation address\n function tokenImpl() external view returns (address);\n\n /// @notice The metadata renderer implementation address\n function metadataImpl() external view returns (address);\n\n /// @notice The auction house implementation address\n function auctionImpl() external view returns (address);\n\n /// @notice The treasury implementation address\n function treasuryImpl() external view returns (address);\n\n /// @notice The governor implementation address\n function governorImpl() external view returns (address);\n\n /// @notice Deploys a DAO with custom token, auction, and governance settings\n /// @param founderParams The DAO founder(s)\n /// @param tokenParams The ERC-721 token settings\n /// @param auctionParams The auction settings\n /// @param govParams The governance settings\n function deploy(\n FounderParams[] calldata founderParams,\n TokenParams calldata tokenParams,\n AuctionParams calldata auctionParams,\n GovParams calldata govParams\n )\n external\n returns (\n address token,\n address metadataRenderer,\n address auction,\n address treasury,\n address governor\n );\n\n /// @notice A DAO's remaining contract addresses from its token address\n /// @param token The ERC-721 token address\n function getAddresses(address token)\n external\n returns (\n address metadataRenderer,\n address auction,\n address treasury,\n address governor\n );\n\n /// @notice If an implementation is registered by the Builder DAO as an optional upgrade\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n function isRegisteredUpgrade(address baseImpl, address upgradeImpl) external view returns (bool);\n\n /// @notice Called by the Builder DAO to offer opt-in implementation upgrades for all other DAOs\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n function registerUpgrade(address baseImpl, address upgradeImpl) external;\n\n /// @notice Called by the Builder DAO to remove an upgrade\n /// @param baseImpl The base implementation address\n /// @param upgradeImpl The upgrade implementation address\n function removeUpgrade(address baseImpl, address upgradeImpl) external;\n}\n"
},
"node_modules/micro-onchain-metadata-utils/src/lib/Base64.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"
},
"node_modules/micro-onchain-metadata-utils/src/lib/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (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 uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // 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 /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"node_modules/micro-onchain-metadata-utils/src/MetadataMIMETypes.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nlibrary MetadataMIMETypes {\n string constant mimeJSON = \"application/json\";\n string constant mimeSVG = \"image/svg+xml\";\n string constant mimeTextPlain = \"text/plain\";\n}\n"
},
"src/lib/interfaces/IUUPS.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.16;\n\nimport { IERC1822Proxiable } from \"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\";\nimport { IERC1967Upgrade } from \"./IERC1967Upgrade.sol\";\n\n/// @title IUUPS\n/// @author Rohan Kulkarni\n/// @notice The external UUPS errors and functions\ninterface IUUPS is IERC1967Upgrade, IERC1822Proxiable {\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if not called directly\n error ONLY_CALL();\n\n /// @dev Reverts if not called via delegatecall\n error ONLY_DELEGATECALL();\n\n /// @dev Reverts if not called via proxy\n error ONLY_PROXY();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Upgrades to an implementation\n /// @param newImpl The new implementation address\n function upgradeTo(address newImpl) external;\n\n /// @notice Upgrades to an implementation with an additional function call\n /// @param newImpl The new implementation address\n /// @param data The encoded function call\n function upgradeToAndCall(address newImpl, bytes memory data) external payable;\n}\n"
},
"src/lib/proxy/ERC1967Upgrade.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IERC1822Proxiable } from \"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\";\nimport { StorageSlot } from \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\nimport { IERC1967Upgrade } from \"../interfaces/IERC1967Upgrade.sol\";\nimport { Address } from \"../utils/Address.sol\";\n\n/// @title ERC1967Upgrade\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (proxy/ERC1967/ERC1967Upgrade.sol)\n/// - Uses custom errors declared in IERC1967Upgrade\n/// - Removes ERC1967 admin and beacon support\nabstract contract ERC1967Upgrade is IERC1967Upgrade {\n /// ///\n /// CONSTANTS ///\n /// ///\n\n /// @dev bytes32(uint256(keccak256('eip1967.proxy.rollback')) - 1)\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n /// @dev bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Upgrades to an implementation with security checks for UUPS proxies and an additional function call\n /// @param _newImpl The new implementation address\n /// @param _data The encoded function call\n function _upgradeToAndCallUUPS(\n address _newImpl,\n bytes memory _data,\n bool _forceCall\n ) internal {\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(_newImpl);\n } else {\n try IERC1822Proxiable(_newImpl).proxiableUUID() returns (bytes32 slot) {\n if (slot != _IMPLEMENTATION_SLOT) revert UNSUPPORTED_UUID();\n } catch {\n revert ONLY_UUPS();\n }\n\n _upgradeToAndCall(_newImpl, _data, _forceCall);\n }\n }\n\n /// @dev Upgrades to an implementation with an additional function call\n /// @param _newImpl The new implementation address\n /// @param _data The encoded function call\n function _upgradeToAndCall(\n address _newImpl,\n bytes memory _data,\n bool _forceCall\n ) internal {\n _upgradeTo(_newImpl);\n\n if (_data.length > 0 || _forceCall) {\n Address.functionDelegateCall(_newImpl, _data);\n }\n }\n\n /// @dev Performs an implementation upgrade\n /// @param _newImpl The new implementation address\n function _upgradeTo(address _newImpl) internal {\n _setImplementation(_newImpl);\n\n emit Upgraded(_newImpl);\n }\n\n /// @dev Stores the address of an implementation\n /// @param _impl The implementation address\n function _setImplementation(address _impl) private {\n if (!Address.isContract(_impl)) revert INVALID_UPGRADE(_impl);\n\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = _impl;\n }\n\n /// @dev The address of the current implementation\n function _getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n }\n}\n"
},
"src/lib/interfaces/IInitializable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IInitializable\n/// @author Rohan Kulkarni\n/// @notice The external Initializable events and errors\ninterface IInitializable {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when the contract has been initialized or reinitialized\n event Initialized(uint256 version);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if incorrectly initialized with address(0)\n error ADDRESS_ZERO();\n\n /// @dev Reverts if disabling initializers during initialization\n error INITIALIZING();\n\n /// @dev Reverts if calling an initialization function outside of initialization\n error NOT_INITIALIZING();\n\n /// @dev Reverts if reinitializing incorrectly\n error ALREADY_INITIALIZED();\n}\n"
},
"src/lib/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title EIP712\n/// @author Rohan Kulkarni\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (utils/Address.sol)\n/// - Uses custom errors `INVALID_TARGET()` & `DELEGATE_CALL_FAILED()`\n/// - Adds util converting address to bytes32\nlibrary Address {\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the target of a delegatecall is not a contract\n error INVALID_TARGET();\n\n /// @dev Reverts if a delegatecall has failed\n error DELEGATE_CALL_FAILED();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @dev Utility to convert an address to bytes32\n function toBytes32(address _account) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(_account)) << 96);\n }\n\n /// @dev If an address is a contract\n function isContract(address _account) internal view returns (bool rv) {\n assembly {\n rv := gt(extcodesize(_account), 0)\n }\n }\n\n /// @dev Performs a delegatecall on an address\n function functionDelegateCall(address _target, bytes memory _data) internal returns (bytes memory) {\n if (!isContract(_target)) revert INVALID_TARGET();\n\n (bool success, bytes memory returndata) = _target.delegatecall(_data);\n\n return verifyCallResult(success, returndata);\n }\n\n /// @dev Verifies a delegatecall was successful\n function verifyCallResult(bool _success, bytes memory _returndata) internal pure returns (bytes memory) {\n if (_success) {\n return _returndata;\n } else {\n if (_returndata.length > 0) {\n assembly {\n let returndata_size := mload(_returndata)\n\n revert(add(32, _returndata), returndata_size)\n }\n } else {\n revert DELEGATE_CALL_FAILED();\n }\n }\n }\n}\n"
},
"src/lib/interfaces/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IERC721\n/// @author Rohan Kulkarni\n/// @notice The external ERC721 events, errors, and functions\ninterface IERC721 {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when a token is transferred from sender to recipient\n /// @param from The sender address\n /// @param to The recipient address\n /// @param tokenId The ERC-721 token id\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /// @notice Emitted when an owner approves an account to manage a token\n /// @param owner The owner address\n /// @param approved The account address\n /// @param tokenId The ERC-721 token id\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /// @notice Emitted when an owner sets an approval for a spender to manage all tokens\n /// @param owner The owner address\n /// @param operator The spender address\n /// @param approved If the approval is being set or removed\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if a caller is not authorized to approve or transfer a token\n error INVALID_APPROVAL();\n\n /// @dev Reverts if a transfer is called with the incorrect token owner\n error INVALID_OWNER();\n\n /// @dev Reverts if a transfer is attempted to address(0)\n error INVALID_RECIPIENT();\n\n /// @dev Reverts if an existing token is called to be minted\n error ALREADY_MINTED();\n\n /// @dev Reverts if a non-existent token is called to be burned\n error NOT_MINTED();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The number of tokens owned\n /// @param owner The owner address\n function balanceOf(address owner) external view returns (uint256);\n\n /// @notice The owner of a token\n /// @param tokenId The ERC-721 token id\n function ownerOf(uint256 tokenId) external view returns (address);\n\n /// @notice The account approved to manage a token\n /// @param tokenId The ERC-721 token id\n function getApproved(uint256 tokenId) external view returns (address);\n\n /// @notice If an operator is authorized to manage all of an owner's tokens\n /// @param owner The owner address\n /// @param operator The operator address\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /// @notice Authorizes an account to manage a token\n /// @param to The account address\n /// @param tokenId The ERC-721 token id\n function approve(address to, uint256 tokenId) external;\n\n /// @notice Authorizes an account to manage all tokens\n /// @param operator The account address\n /// @param approved If permission is being given or removed\n function setApprovalForAll(address operator, bool approved) external;\n\n /// @notice Safe transfers a token from sender to recipient with additional data\n /// @param from The sender address\n /// @param to The recipient address\n /// @param tokenId The ERC-721 token id\n /// @param data The additional data sent in the call to the recipient\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /// @notice Safe transfers a token from sender to recipient\n /// @param from The sender address\n /// @param to The recipient address\n /// @param tokenId The ERC-721 token id\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /// @notice Transfers a token from sender to recipient\n /// @param from The sender address\n /// @param to The recipient address\n /// @param tokenId The ERC-721 token id\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n}\n"
},
"src/lib/utils/TokenReceiver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (token/ERC721/utils/ERC721Holder.sol)\nabstract contract ERC721TokenReceiver {\n function onERC721Received(\n address,\n address,\n uint256,\n bytes calldata\n ) external virtual returns (bytes4) {\n return this.onERC721Received.selector;\n }\n}\n\n/// @notice Modified from OpenZeppelin Contracts v4.7.3 (token/ERC1155/utils/ERC1155Holder.sol)\nabstract contract ERC1155TokenReceiver {\n function onERC1155Received(\n address,\n address,\n uint256,\n uint256,\n bytes calldata\n ) external virtual returns (bytes4) {\n return this.onERC1155Received.selector;\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata,\n uint256[] calldata,\n bytes calldata\n ) external virtual returns (bytes4) {\n return this.onERC1155BatchReceived.selector;\n }\n}\n"
},
"src/token/metadata/types/MetadataRendererTypesV1.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title MetadataRendererTypesV1\n/// @author Iain Nash & Rohan Kulkarni\n/// @notice The Metadata Renderer custom data types\ninterface MetadataRendererTypesV1 {\n struct ItemParam {\n uint256 propertyId;\n string name;\n bool isNewProperty;\n }\n\n struct IPFSGroup {\n string baseUri;\n string extension;\n }\n\n struct Item {\n uint16 referenceSlot;\n string name;\n }\n\n struct Property {\n string name;\n Item[] items;\n }\n\n struct Settings {\n address token;\n string projectURI;\n string description;\n string contractImage;\n string rendererBase;\n }\n}\n"
},
"src/token/metadata/types/MetadataRendererTypesV2.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title MetadataRendererTypesV2\n/// @author Iain Nash & Rohan Kulkarni\n/// @notice The Metadata Renderer custom data types\ninterface MetadataRendererTypesV2 {\n struct AdditionalTokenProperty {\n string key;\n string value;\n bool quote;\n }\n}\n"
},
"src/lib/interfaces/IERC721Votes.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IERC721 } from \"./IERC721.sol\";\nimport { IEIP712 } from \"./IEIP712.sol\";\n\n/// @title IERC721Votes\n/// @author Rohan Kulkarni\n/// @notice The external ERC721Votes events, errors, and functions\ninterface IERC721Votes is IERC721, IEIP712 {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when an account changes their delegate\n event DelegateChanged(address indexed delegator, address indexed from, address indexed to);\n\n /// @notice Emitted when a delegate's number of votes is updated\n event DelegateVotesChanged(address indexed delegate, uint256 prevTotalVotes, uint256 newTotalVotes);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the timestamp provided isn't in the past\n error INVALID_TIMESTAMP();\n\n /// ///\n /// STRUCTS ///\n /// ///\n\n /// @notice The checkpoint data type\n /// @param timestamp The recorded timestamp\n /// @param votes The voting weight\n struct Checkpoint {\n uint64 timestamp;\n uint192 votes;\n }\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The current number of votes for an account\n /// @param account The account address\n function getVotes(address account) external view returns (uint256);\n\n /// @notice The number of votes for an account at a past timestamp\n /// @param account The account address\n /// @param timestamp The past timestamp\n function getPastVotes(address account, uint256 timestamp) external view returns (uint256);\n\n /// @notice The delegate for an account\n /// @param account The account address\n function delegates(address account) external view returns (address);\n\n /// @notice Delegates votes to an account\n /// @param to The address delegating votes to\n function delegate(address to) external;\n\n /// @notice Delegates votes from a signer to an account\n /// @param from The address delegating votes from\n /// @param to The address delegating votes to\n /// @param deadline The signature deadline\n /// @param v The 129th byte and chain id of the signature\n /// @param r The first 64 bytes of the signature\n /// @param s Bytes 64-128 of the signature\n function delegateBySig(\n address from,\n address to,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n"
},
"src/token/types/TokenTypesV1.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IBaseMetadata } from \"../metadata/interfaces/IBaseMetadata.sol\";\n\n/// @title TokenTypesV1\n/// @author Rohan Kulkarni\n/// @notice The Token custom data types\ninterface TokenTypesV1 {\n /// @notice The settings type\n /// @param auction The DAO auction house\n /// @param totalSupply The number of active tokens\n /// @param numFounders The number of vesting recipients\n /// @param metadatarenderer The token metadata renderer\n /// @param mintCount The number of minted tokens\n /// @param totalPercentage The total percentage owned by founders\n struct Settings {\n address auction;\n uint88 totalSupply;\n uint8 numFounders;\n IBaseMetadata metadataRenderer;\n uint88 mintCount;\n uint8 totalOwnership;\n }\n\n /// @notice The founder type\n /// @param wallet The address where tokens are sent\n /// @param ownershipPct The percentage of token ownership\n /// @param vestExpiry The timestamp when vesting ends\n struct Founder {\n address wallet;\n uint8 ownershipPct;\n uint32 vestExpiry;\n }\n}\n"
},
"src/token/metadata/interfaces/IBaseMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\nimport { IUUPS } from \"../../../lib/interfaces/IUUPS.sol\";\n\n\n/// @title IBaseMetadata\n/// @author Rohan Kulkarni\n/// @notice The external Base Metadata errors and functions\ninterface IBaseMetadata is IUUPS {\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the caller was not the contract manager\n error ONLY_MANAGER();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice Initializes a DAO's token metadata renderer\n /// @param initStrings The encoded token and metadata initialization strings\n /// @param token The associated ERC-721 token address\n function initialize(\n bytes calldata initStrings,\n address token\n ) external;\n\n /// @notice Generates attributes for a token upon mint\n /// @param tokenId The ERC-721 token id\n function onMinted(uint256 tokenId) external returns (bool);\n\n /// @notice The token URI\n /// @param tokenId The ERC-721 token id\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n /// @notice The contract URI\n function contractURI() external view returns (string memory);\n\n /// @notice The associated ERC-721 token\n function token() external view returns (address);\n\n /// @notice Get metadata owner address\n function owner() external view returns (address);\n}\n"
},
"node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n"
},
"src/lib/interfaces/IERC1967Upgrade.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IERC1967Upgrade\n/// @author Rohan Kulkarni\n/// @notice The external ERC1967Upgrade events and errors\ninterface IERC1967Upgrade {\n /// ///\n /// EVENTS ///\n /// ///\n\n /// @notice Emitted when the implementation is upgraded\n /// @param impl The address of the implementation\n event Upgraded(address impl);\n\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if an implementation is an invalid upgrade\n /// @param impl The address of the invalid implementation\n error INVALID_UPGRADE(address impl);\n\n /// @dev Reverts if an implementation upgrade is not stored at the storage slot of the original\n error UNSUPPORTED_UUID();\n\n /// @dev Reverts if an implementation does not support ERC1822 proxiableUUID()\n error ONLY_UUPS();\n}\n"
},
"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
},
"src/lib/interfaces/IEIP712.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.16;\n\n/// @title IEIP712\n/// @author Rohan Kulkarni\n/// @notice The external EIP712 errors and functions\ninterface IEIP712 {\n /// ///\n /// ERRORS ///\n /// ///\n\n /// @dev Reverts if the deadline has passed to submit a signature\n error EXPIRED_SIGNATURE();\n\n /// @dev Reverts if the recovered signature is invalid\n error INVALID_SIGNATURE();\n\n /// ///\n /// FUNCTIONS ///\n /// ///\n\n /// @notice The sig nonce for an account\n /// @param account The account address\n function nonce(address account) external view returns (uint256);\n\n /// @notice The EIP-712 domain separator\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
}
},
"settings": {
"remappings": [
"@openzeppelin/=node_modules/@openzeppelin/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"micro-onchain-metadata-utils/=node_modules/micro-onchain-metadata-utils/src/",
"sol-uriencode/=node_modules/sol-uriencode/",
"sol2string/=node_modules/sol2string/"
],
"optimizer": {
"enabled": true,
"runs": 500000
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
}