zellic-audit
Initial commit
f998fcd
raw
history blame
80.7 kB
{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/AccessControl.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n * Overriding this function changes the behavior of the {onlyRole} modifier.\n *\n * Format of the revert message is described in {_checkRole}.\n *\n * _Available since v4.6._\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(account),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * May emit a {RoleGranted} event.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n"
},
"@openzeppelin/contracts/access/AccessControlEnumerable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n"
},
"@openzeppelin/contracts/access/IAccessControl.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n"
},
"@openzeppelin/contracts/access/IAccessControlEnumerable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n"
},
"@openzeppelin/contracts/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"
},
"@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/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/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/math/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10**64) {\n value /= 10**64;\n result += 64;\n }\n if (value >= 10**32) {\n value /= 10**32;\n result += 32;\n }\n if (value >= 10**16) {\n value /= 10**16;\n result += 16;\n }\n if (value >= 10**8) {\n value /= 10**8;\n result += 8;\n }\n if (value >= 10**4) {\n value /= 10**4;\n result += 4;\n }\n if (value >= 10**2) {\n value /= 10**2;\n result += 2;\n }\n if (value >= 10**1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
},
"@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastValue;\n // Update the index for the moved value\n set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n"
},
"contracts/DiamondDawnMine.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/utils/Base64.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"./interface/IDiamondDawnMine.sol\";\nimport \"./interface/IDiamondDawnMineAdmin.sol\";\nimport \"./objects/Diamond.sol\";\nimport \"./objects/Mine.sol\";\nimport \"./utils/MathUtils.sol\";\nimport \"./utils/Serializer.sol\";\n\n/**\n * ________ .__ .___\n * \\______ \\ |__| _____ _____ ____ ____ __| _/\n * | | \\ | | \\__ \\ / \\ / _ \\ / \\ / __ |\n * | ` \\ | | / __ \\_ | Y Y \\ ( <_> ) | | \\ / /_/ |\n * /_______ / |__| (____ / |__|_| / \\____/ |___| / \\____ |\n * \\/ \\/ \\/ \\/ \\/\n * ________\n * \\______ \\ _____ __ _ __ ____\n * | | \\ \\__ \\ \\ \\/ \\/ / / \\\n * | ` \\ / __ \\_ \\ / | | \\\n * /_______ / (____ / \\/\\_/ |___| /\n * \\/ \\/ \\/\n * _____ .__\n * / \\ |__| ____ ____\n * / \\ / \\ | | / \\ _/ __ \\\n * / Y \\ | | | | \\ \\ ___/\n * \\____|__ / |__| |___| / \\___ >\n * \\/ \\/ \\/\n *\n * @title DiamondDawnMine\n * @author Mike Moldawsky (Tweezers)\n */\ncontract DiamondDawnMine is AccessControlEnumerable, IDiamondDawnMine, IDiamondDawnMineAdmin {\n bool public isLocked; // mine is locked forever.\n bool public isInitialized;\n uint16 public maxDiamonds;\n uint16 public diamondCount;\n address public diamondDawn;\n mapping(uint => string) public manifests;\n\n // Carat loss of ~35% to ~65% from rough stone to the polished diamond.\n uint8 private constant MIN_EXTRA_ROUGH_POINTS = 37;\n uint8 private constant MAX_EXTRA_ROUGH_POINTS = 74;\n // Carat loss of ~2% to ~8% in the polish process.\n uint8 private constant MIN_EXTRA_POLISH_POINTS = 1;\n uint8 private constant MAX_EXTRA_POLISH_POINTS = 4;\n\n uint16 private _mineCounter;\n uint16 private _cutCounter;\n uint16 private _polishedCounter;\n uint16 private _rebornCounter;\n uint16 private _randNonce = 0;\n Certificate[] private _mine;\n mapping(uint => Metadata) private _metadata;\n string private _baseTokenURI = \"ar://\";\n\n constructor() {\n _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n /********************** Modifiers ************************/\n modifier onlyDiamondDawn() {\n require(_msgSender() == diamondDawn, \"Only DD\");\n _;\n }\n\n modifier notInitialized() {\n require(!isInitialized, \"Initialized\");\n _;\n }\n\n modifier exists(uint tokenId) {\n require(_metadata[tokenId].state_ != Stage.NO_STAGE, \"Don't exist\");\n _;\n }\n\n modifier canProcess(uint tokenId, Stage state_) {\n require(!isLocked, \"Locked\");\n require(state_ == _metadata[tokenId].state_, \"Can't process\");\n _;\n }\n\n modifier mineOverflow(uint cnt) {\n require((diamondCount + cnt) <= maxDiamonds, \"Mine overflow\");\n _;\n }\n\n modifier mineNotDry() {\n require(_mine.length > 0, \"Dry mine\");\n _;\n }\n\n /********************** External Functions ************************/\n function initialize(uint16 maxDiamonds_) external notInitialized {\n diamondDawn = _msgSender();\n maxDiamonds = maxDiamonds_;\n isInitialized = true;\n }\n\n function forge(uint tokenId) external onlyDiamondDawn canProcess(tokenId, Stage.NO_STAGE) {\n _metadata[tokenId].state_ = Stage.KEY;\n emit Forge(tokenId);\n }\n\n function mine(uint tokenId) external onlyDiamondDawn mineNotDry canProcess(tokenId, Stage.KEY) {\n uint extraPoints = _getRandomBetween(MIN_EXTRA_ROUGH_POINTS, MAX_EXTRA_ROUGH_POINTS);\n Metadata storage metadata = _metadata[tokenId];\n metadata.state_ = Stage.MINE;\n metadata.rough.id = ++_mineCounter;\n metadata.rough.extraPoints = uint8(extraPoints);\n metadata.rough.shape = extraPoints % 2 == 0 ? RoughShape.MAKEABLE_1 : RoughShape.MAKEABLE_2;\n metadata.certificate = _mineDiamond();\n emit Mine(tokenId);\n }\n\n function cut(uint tokenId) external onlyDiamondDawn canProcess(tokenId, Stage.MINE) {\n uint extraPoints = _getRandomBetween(MIN_EXTRA_POLISH_POINTS, MAX_EXTRA_POLISH_POINTS);\n Metadata storage metadata = _metadata[tokenId];\n metadata.state_ = Stage.CUT;\n metadata.cut.id = ++_cutCounter;\n metadata.cut.extraPoints = uint8(extraPoints);\n emit Cut(tokenId);\n }\n\n function polish(uint tokenId) external onlyDiamondDawn canProcess(tokenId, Stage.CUT) {\n Metadata storage metadata = _metadata[tokenId];\n metadata.state_ = Stage.POLISH;\n metadata.polished.id = ++_polishedCounter;\n emit Polish(tokenId);\n }\n\n function ship(uint tokenId) external onlyDiamondDawn canProcess(tokenId, Stage.POLISH) {\n Metadata storage metadata = _metadata[tokenId];\n require(metadata.reborn.id == 0, \"Shipped\");\n metadata.reborn.id = ++_rebornCounter;\n emit Ship(tokenId, metadata.reborn.id, metadata.certificate.number);\n }\n\n function dawn(uint tokenId) external onlyDiamondDawn {\n require(_metadata[tokenId].reborn.id > 0, \"Not shipped\");\n require(_metadata[tokenId].state_ == Stage.POLISH, \"Wrong state\");\n _metadata[tokenId].state_ = Stage.DAWN;\n emit Dawn(tokenId);\n }\n\n function lockMine() external onlyDiamondDawn {\n while (0 < getRoleMemberCount(DEFAULT_ADMIN_ROLE)) {\n _revokeRole(DEFAULT_ADMIN_ROLE, getRoleMember(DEFAULT_ADMIN_ROLE, 0));\n }\n isLocked = true;\n }\n\n function eruption(Certificate[] calldata diamonds)\n external\n onlyRole(DEFAULT_ADMIN_ROLE)\n mineOverflow(diamonds.length)\n {\n for (uint i = 0; i < diamonds.length; i++) {\n _mine.push(diamonds[i]);\n }\n diamondCount += uint16(diamonds.length);\n }\n\n function lostShipment(uint tokenId, Certificate calldata diamond) external onlyRole(DEFAULT_ADMIN_ROLE) {\n Metadata storage metadata = _metadata[tokenId];\n require(metadata.state_ == Stage.POLISH || metadata.state_ == Stage.DAWN, \"Wrong shipment state\");\n metadata.certificate = diamond;\n }\n\n function setManifest(Stage stage_, string calldata manifest) external onlyRole(DEFAULT_ADMIN_ROLE) {\n require(stage_ != Stage.NO_STAGE);\n manifests[uint(stage_)] = manifest;\n }\n\n function setBaseTokenURI(string calldata baseTokenURI) external onlyRole(DEFAULT_ADMIN_ROLE) {\n _baseTokenURI = baseTokenURI;\n }\n\n function getMetadata(uint tokenId) external view onlyDiamondDawn exists(tokenId) returns (string memory) {\n Metadata memory metadata = _metadata[tokenId];\n string memory noExtensionURI = _getNoExtensionURI(metadata);\n string memory base64Json = Base64.encode(bytes(_getMetadataJson(tokenId, metadata, noExtensionURI)));\n return string(abi.encodePacked(\"data:application/json;base64,\", base64Json));\n }\n\n function isReady(Stage stage_) external view returns (bool) {\n if (stage_ == Stage.NO_STAGE) return true;\n if (stage_ == Stage.COMPLETED) return true;\n if (stage_ == Stage.MINE && diamondCount != maxDiamonds) return false;\n return bytes(manifests[uint(stage_)]).length > 0;\n }\n\n /********************** Private Functions ************************/\n\n function _mineDiamond() private returns (Certificate memory) {\n assert(_mine.length > 0);\n uint index = _getRandomBetween(0, _mine.length - 1);\n Certificate memory diamond = _mine[index];\n _mine[index] = _mine[_mine.length - 1]; // swap last diamond with mined diamond\n _mine.pop();\n return diamond;\n }\n\n function _getRandomBetween(uint min, uint max) private returns (uint) {\n _randNonce++;\n return getRandomInRange(min, max, _randNonce);\n }\n\n function _getNoExtensionURI(Metadata memory metadata) private view returns (string memory) {\n string memory manifest = manifests[uint(metadata.state_)];\n string memory name = _getResourceName(metadata);\n return string.concat(_baseTokenURI, manifest, \"/\", name);\n }\n\n function _getMetadataJson(\n uint tokenId,\n Metadata memory metadata,\n string memory noExtensionURI\n ) private view returns (string memory) {\n Serializer.NFTMetadata memory nftMetadata = Serializer.NFTMetadata({\n name: Serializer.getName(metadata, tokenId),\n image: string.concat(noExtensionURI, \".jpeg\"), // TODO: change to jpg\n animationUrl: string.concat(noExtensionURI, \".mp4\"),\n attributes: _getJsonAttributes(metadata)\n });\n return Serializer.serialize(nftMetadata);\n }\n\n function _getJsonAttributes(Metadata memory metadata) private view returns (Serializer.Attribute[] memory) {\n uint8 i = 0;\n bool isRound = metadata.certificate.shape == Shape.ROUND;\n Stage state_ = metadata.state_;\n Serializer.Attribute[] memory attributes = new Serializer.Attribute[](_getStateAttrsNum(state_, isRound));\n attributes[i] = Serializer.toStrAttribute(\"Origin\", \"Metaverse\");\n attributes[++i] = Serializer.toStrAttribute(\"Type\", Serializer.toTypeStr(state_));\n if (Stage.KEY == state_) {\n attributes[++i] = Serializer.toStrAttribute(\"Metal\", \"Gold\");\n return attributes;\n }\n if (uint(Stage.MINE) <= uint(state_)) {\n attributes[++i] = Serializer.toStrAttribute(\"Stage\", Serializer.toStageStr(state_));\n attributes[++i] = Serializer.toStrAttribute(\"Identification\", \"Natural\");\n attributes[++i] = Serializer.toAttribute(\n \"Carat\",\n Serializer.toDecimalStr(_getPoints(metadata, metadata.state_)),\n \"\"\n );\n attributes[++i] = Serializer.toMaxValueAttribute(\n \"Mined\",\n Strings.toString(metadata.rough.id),\n Strings.toString(_mineCounter),\n \"number\"\n );\n bool wasProcessed = uint(state_) > uint(Stage.MINE);\n attributes[++i] = Serializer.toStrAttribute(wasProcessed ? \"Color Rough Stone\" : \"Color\", \"Cape\");\n attributes[++i] = Serializer.toStrAttribute(\n wasProcessed ? \"Shape Rough Stone\" : \"Shape\",\n Serializer.toRoughShapeStr(metadata.rough.shape)\n );\n }\n Certificate memory certificate = metadata.certificate;\n if (uint(Stage.CUT) <= uint(state_)) {\n attributes[++i] = Serializer.toAttribute(\n \"Carat Rough Stone\",\n Serializer.toDecimalStr(_getPoints(metadata, Stage.MINE)),\n \"\"\n );\n attributes[++i] = Serializer.toStrAttribute(\n \"Color\",\n Serializer.toColorStr(certificate.color, certificate.toColor)\n );\n if (isRound) {\n attributes[++i] = Serializer.toStrAttribute(\"Cut\", Serializer.toGradeStr(certificate.cut));\n }\n attributes[++i] = Serializer.toStrAttribute(\n \"Fluorescence\",\n Serializer.toFluorescenceStr(certificate.fluorescence)\n );\n attributes[++i] = Serializer.toStrAttribute(\n \"Measurements\",\n Serializer.toMeasurementsStr(isRound, certificate.length, certificate.width, certificate.depth)\n );\n attributes[++i] = Serializer.toStrAttribute(\"Shape\", Serializer.toShapeStr(certificate.shape));\n attributes[++i] = Serializer.toMaxValueAttribute(\n \"Cut\",\n Strings.toString(metadata.cut.id),\n Strings.toString(_cutCounter),\n \"number\"\n );\n }\n if (uint(Stage.POLISH) <= uint(state_)) {\n attributes[++i] = Serializer.toAttribute(\n \"Carat Pre Polish\",\n Serializer.toDecimalStr(_getPoints(metadata, Stage.CUT)),\n \"\"\n );\n attributes[++i] = Serializer.toStrAttribute(\"Clarity\", Serializer.toClarityStr(certificate.clarity));\n attributes[++i] = Serializer.toStrAttribute(\"Polish\", Serializer.toGradeStr(certificate.polish));\n attributes[++i] = Serializer.toStrAttribute(\"Symmetry\", Serializer.toGradeStr(certificate.symmetry));\n attributes[++i] = Serializer.toMaxValueAttribute(\n \"Polished\",\n Strings.toString(metadata.polished.id),\n Strings.toString(_polishedCounter),\n \"number\"\n );\n }\n if (uint(Stage.DAWN) <= uint(state_)) {\n attributes[++i] = Serializer.toStrAttribute(\"Laboratory\", \"GIA\");\n attributes[++i] = Serializer.toAttribute(\"Report Date\", Strings.toString(certificate.date), \"date\");\n attributes[++i] = Serializer.toStrAttribute(\"Report Number\", Strings.toString(certificate.number));\n attributes[++i] = Serializer.toMaxValueAttribute(\n \"Physical\",\n Strings.toString(metadata.reborn.id),\n Strings.toString(_rebornCounter),\n \"number\"\n );\n }\n return attributes;\n }\n\n function _getStateAttrsNum(Stage state_, bool isRound) private pure returns (uint) {\n if (state_ == Stage.KEY) return 3;\n if (state_ == Stage.MINE) return 8;\n if (state_ == Stage.CUT) return isRound ? 15 : 14;\n if (state_ == Stage.POLISH) return isRound ? 20 : 19;\n if (state_ == Stage.DAWN) return isRound ? 24 : 23;\n revert(\"Attributes number\");\n }\n\n function _getPoints(Metadata memory metadata, Stage state_) private pure returns (uint) {\n assert(metadata.certificate.points > 0);\n if (state_ == Stage.MINE) {\n assert(metadata.rough.extraPoints > 0);\n return metadata.certificate.points + metadata.rough.extraPoints;\n } else if (state_ == Stage.CUT) {\n assert(metadata.cut.extraPoints > 0);\n return metadata.certificate.points + metadata.cut.extraPoints;\n } else if (state_ == Stage.POLISH || state_ == Stage.DAWN) return metadata.certificate.points;\n revert(\"Points\");\n }\n\n function _getResourceName(Metadata memory metadata) private pure returns (string memory) {\n if (metadata.state_ == Stage.KEY || metadata.state_ == Stage.DAWN) return \"resource\";\n else if (metadata.state_ == Stage.MINE) {\n if (metadata.rough.shape == RoughShape.MAKEABLE_1) return \"makeable1\";\n if (metadata.rough.shape == RoughShape.MAKEABLE_2) return \"makeable2\";\n } else if (metadata.certificate.shape == Shape.PEAR) return \"pear\";\n else if (metadata.certificate.shape == Shape.ROUND) return \"round\";\n else if (metadata.certificate.shape == Shape.OVAL) return \"oval\";\n else if (metadata.certificate.shape == Shape.CUSHION) return \"cushion\";\n revert();\n }\n}\n"
},
"contracts/interface/IDiamondDawnMine.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"../objects/Mine.sol\";\nimport \"../objects/System.sol\";\n\ninterface IDiamondDawnMine {\n event Forge(uint tokenId);\n event Mine(uint tokenId);\n event Cut(uint tokenId);\n event Polish(uint tokenId);\n event Ship(uint tokenId, uint16 physicalId, uint64 number);\n event Dawn(uint tokenId);\n\n function initialize(uint16 maxDiamond) external;\n\n function forge(uint tokenId) external;\n\n function mine(uint tokenId) external;\n\n function cut(uint tokenId) external;\n\n function polish(uint tokenId) external;\n\n function ship(uint tokenId) external;\n\n function dawn(uint tokenId) external;\n\n function lockMine() external;\n\n function getMetadata(uint tokenId) external view returns (string memory);\n\n function isReady(Stage stage) external view returns (bool);\n}\n"
},
"contracts/interface/IDiamondDawnMineAdmin.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"../objects/Diamond.sol\";\nimport \"../objects/System.sol\";\n\ninterface IDiamondDawnMineAdmin {\n function eruption(Certificate[] calldata diamonds) external;\n\n function lostShipment(uint tokenId, Certificate calldata diamond) external;\n\n function setManifest(Stage stage_, string calldata manifest) external;\n\n function setBaseTokenURI(string calldata baseTokenURI) external;\n}\n"
},
"contracts/objects/Diamond.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nenum Shape {\n NO_SHAPE,\n PEAR,\n ROUND,\n OVAL,\n CUSHION\n}\n\nenum Grade {\n NO_GRADE,\n GOOD,\n VERY_GOOD,\n EXCELLENT\n}\n\nenum Clarity {\n NO_CLARITY,\n VS2,\n VS1,\n VVS2,\n VVS1,\n IF,\n FL\n}\n\nenum Fluorescence {\n NO_FLUORESCENCE,\n FAINT,\n NONE\n}\n\nenum Color {\n NO_COLOR,\n K,\n L,\n M,\n N,\n O,\n P,\n Q,\n R,\n S,\n T,\n U,\n V,\n W,\n X,\n Y,\n Z\n}\n\nstruct Certificate {\n uint64 number;\n uint32 date;\n uint16 length;\n uint16 width;\n uint16 depth;\n uint8 points;\n Clarity clarity;\n Color color;\n Color toColor;\n Grade cut;\n Grade symmetry;\n Grade polish;\n Fluorescence fluorescence;\n Shape shape;\n}\n"
},
"contracts/objects/Mine.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"./Diamond.sol\";\nimport \"./System.sol\";\n\nenum RoughShape {\n NO_SHAPE,\n MAKEABLE_1,\n MAKEABLE_2\n}\n\nstruct RoughMetadata {\n uint16 id;\n uint8 extraPoints;\n RoughShape shape;\n}\n\nstruct CutMetadata {\n uint16 id;\n uint8 extraPoints;\n}\n\nstruct PolishedMetadata {\n uint16 id;\n}\n\nstruct RebornMetadata {\n uint16 id;\n}\n\nstruct Metadata {\n Stage state_;\n RoughMetadata rough;\n CutMetadata cut;\n PolishedMetadata polished;\n RebornMetadata reborn;\n Certificate certificate;\n}\n"
},
"contracts/objects/System.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nenum Stage {\n NO_STAGE,\n KEY,\n MINE,\n CUT,\n POLISH,\n DAWN,\n COMPLETED\n}\n"
},
"contracts/utils/MathUtils.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nfunction getRandomInRange(\n uint min,\n uint max,\n uint nonce\n) view returns (uint) {\n uint rand = _rand(nonce);\n uint range = max - min + 1;\n return (rand % range) + min;\n}\n\nfunction _rand(uint nonce) view returns (uint) {\n return uint(keccak256(abi.encodePacked(block.timestamp, block.difficulty, tx.origin, nonce)));\n}\n"
},
"contracts/utils/Serializer.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"../objects/Diamond.sol\";\nimport \"../objects/Mine.sol\";\n\nlibrary Serializer {\n struct NFTMetadata {\n string name;\n string image;\n string animationUrl;\n Attribute[] attributes;\n }\n\n struct Attribute {\n string traitType;\n string value;\n string maxValue;\n string displayType;\n bool isString;\n }\n\n function toStrAttribute(string memory traitType, string memory value) public pure returns (Attribute memory) {\n return Attribute({traitType: traitType, value: value, maxValue: \"\", displayType: \"\", isString: true});\n }\n\n function toAttribute(\n string memory traitType,\n string memory value,\n string memory displayType\n ) public pure returns (Attribute memory) {\n return Attribute({traitType: traitType, value: value, maxValue: \"\", displayType: displayType, isString: false});\n }\n\n function toMaxValueAttribute(\n string memory traitType,\n string memory value,\n string memory maxValue,\n string memory displayType\n ) public pure returns (Attribute memory) {\n return\n Attribute({\n traitType: traitType,\n value: value,\n maxValue: maxValue,\n displayType: displayType,\n isString: false\n });\n }\n\n function serialize(NFTMetadata memory metadata) public pure returns (string memory) {\n bytes memory bytes_;\n bytes_ = abi.encodePacked(bytes_, _openObject());\n bytes_ = abi.encodePacked(bytes_, _pushAttr(\"name\", metadata.name, true, false));\n bytes_ = abi.encodePacked(bytes_, _pushAttr(\"image\", metadata.image, true, false));\n bytes_ = abi.encodePacked(bytes_, _pushAttr(\"animation_url\", metadata.animationUrl, true, false));\n bytes_ = abi.encodePacked(bytes_, _pushAttr(\"attributes\", _serializeAttrs(metadata.attributes), false, true));\n bytes_ = abi.encodePacked(bytes_, _closeObject());\n return string(bytes_);\n }\n\n function _serializeAttrs(Attribute[] memory attributes) public pure returns (string memory) {\n bytes memory bytes_;\n bytes_ = abi.encodePacked(bytes_, _openArray());\n for (uint i = 0; i < attributes.length; i++) {\n Attribute memory attribute = attributes[i];\n bytes_ = abi.encodePacked(bytes_, _pushArray(_serializeAttr(attribute), i == attributes.length - 1));\n }\n bytes_ = abi.encodePacked(bytes_, _closeArray());\n return string(bytes_);\n }\n\n function _serializeAttr(Attribute memory attribute) public pure returns (string memory) {\n bytes memory bytes_;\n bytes_ = abi.encodePacked(bytes_, _openObject());\n if (bytes(attribute.displayType).length > 0) {\n bytes_ = abi.encodePacked(bytes_, _pushAttr(\"display_type\", attribute.displayType, true, false));\n }\n if (bytes(attribute.maxValue).length > 0) {\n bytes_ = abi.encodePacked(bytes_, _pushAttr(\"max_value\", attribute.maxValue, attribute.isString, false));\n }\n bytes_ = abi.encodePacked(bytes_, _pushAttr(\"trait_type\", attribute.traitType, true, false));\n bytes_ = abi.encodePacked(bytes_, _pushAttr(\"value\", attribute.value, attribute.isString, true));\n bytes_ = abi.encodePacked(bytes_, _closeObject());\n return string(bytes_);\n }\n\n // Objects\n function _openObject() public pure returns (bytes memory) {\n return abi.encodePacked(\"{\");\n }\n\n function _closeObject() public pure returns (bytes memory) {\n return abi.encodePacked(\"}\");\n }\n\n function _pushAttr(\n string memory key,\n string memory value,\n bool isStr,\n bool isLast\n ) public pure returns (bytes memory) {\n if (isStr) value = string.concat('\"', value, '\"');\n return abi.encodePacked('\"', key, '\": ', value, isLast ? \"\" : \",\");\n }\n\n // Arrays\n function _openArray() public pure returns (bytes memory) {\n return abi.encodePacked(\"[\");\n }\n\n function _closeArray() public pure returns (bytes memory) {\n return abi.encodePacked(\"]\");\n }\n\n function _pushArray(string memory value, bool isLast) public pure returns (bytes memory) {\n return abi.encodePacked(value, isLast ? \"\" : \",\");\n }\n\n function toColorStr(Color color, Color toColor) public pure returns (string memory) {\n return\n toColor == Color.NO_COLOR\n ? _toColorStr(color)\n : string.concat(_toColorStr(color), \"-\", _toColorStr(toColor));\n }\n\n function toGradeStr(Grade grade) public pure returns (string memory) {\n if (grade == Grade.GOOD) return \"Good\";\n if (grade == Grade.VERY_GOOD) return \"Very Good\";\n if (grade == Grade.EXCELLENT) return \"Excellent\";\n revert();\n }\n\n function toClarityStr(Clarity clarity) public pure returns (string memory) {\n if (clarity == Clarity.VS2) return \"VS2\";\n if (clarity == Clarity.VS1) return \"VS1\";\n if (clarity == Clarity.VVS2) return \"VVS2\";\n if (clarity == Clarity.VVS1) return \"VVS1\";\n if (clarity == Clarity.IF) return \"IF\";\n if (clarity == Clarity.FL) return \"FL\";\n revert();\n }\n\n function toFluorescenceStr(Fluorescence fluorescence) public pure returns (string memory) {\n if (fluorescence == Fluorescence.FAINT) return \"Faint\";\n if (fluorescence == Fluorescence.NONE) return \"None\";\n revert();\n }\n\n function toMeasurementsStr(\n bool isRound,\n uint16 length,\n uint16 width,\n uint16 depth\n ) public pure returns (string memory) {\n string memory separator = isRound ? \" - \" : \" x \";\n return string.concat(toDecimalStr(length), separator, toDecimalStr(width), \" x \", toDecimalStr(depth));\n }\n\n function toShapeStr(Shape shape) public pure returns (string memory) {\n if (shape == Shape.PEAR) return \"Pear\";\n if (shape == Shape.ROUND) return \"Round\";\n if (shape == Shape.OVAL) return \"Oval\";\n if (shape == Shape.CUSHION) return \"Cushion\";\n revert();\n }\n\n function toRoughShapeStr(RoughShape shape) public pure returns (string memory) {\n if (shape == RoughShape.MAKEABLE_1) return \"Makeable 1\";\n if (shape == RoughShape.MAKEABLE_2) return \"Makeable 2\";\n revert();\n }\n\n function getName(Metadata memory metadata, uint tokenId) public pure returns (string memory) {\n if (metadata.state_ == Stage.KEY) return string.concat(\"Mine Key #\", Strings.toString(tokenId));\n if (metadata.state_ == Stage.MINE) return string.concat(\"Rough Stone #\", Strings.toString(metadata.rough.id));\n if (metadata.state_ == Stage.CUT) return string.concat(\"Formation #\", Strings.toString(metadata.cut.id));\n if (metadata.state_ == Stage.POLISH) return string.concat(\"Diamond #\", Strings.toString(metadata.polished.id));\n if (metadata.state_ == Stage.DAWN) return string.concat(\"Dawn #\", Strings.toString(metadata.reborn.id));\n revert();\n }\n\n function toDecimalStr(uint percentage) public pure returns (string memory) {\n uint remainder = percentage % 100;\n string memory quotient = Strings.toString(percentage / 100);\n if (remainder < 10) return string.concat(quotient, \".0\", Strings.toString(remainder));\n return string.concat(quotient, \".\", Strings.toString(remainder));\n }\n\n function toTypeStr(Stage state_) public pure returns (string memory) {\n if (state_ == Stage.KEY) return \"Key\";\n if (state_ == Stage.MINE || state_ == Stage.CUT || state_ == Stage.POLISH) return \"Diamond\";\n if (state_ == Stage.DAWN) return \"Certificate\";\n revert();\n }\n\n function toStageStr(Stage state_) public pure returns (string memory) {\n if (state_ == Stage.MINE) return \"Rough\";\n if (state_ == Stage.CUT) return \"Cut\";\n if (state_ == Stage.POLISH) return \"Polished\";\n if (state_ == Stage.DAWN) return \"Reborn\";\n revert();\n }\n\n function _toColorStr(Color color) public pure returns (string memory) {\n if (color == Color.K) return \"K\";\n if (color == Color.L) return \"L\";\n if (color == Color.M) return \"M\";\n if (color == Color.N) return \"N\";\n if (color == Color.O) return \"O\";\n if (color == Color.P) return \"P\";\n if (color == Color.Q) return \"Q\";\n if (color == Color.R) return \"R\";\n if (color == Color.S) return \"S\";\n if (color == Color.T) return \"T\";\n if (color == Color.U) return \"U\";\n if (color == Color.V) return \"V\";\n if (color == Color.W) return \"W\";\n if (color == Color.X) return \"X\";\n if (color == Color.Y) return \"Y\";\n if (color == Color.Z) return \"Z\";\n revert();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {
"contracts/utils/Serializer.sol": {
"Serializer": "0xc694ba737b78e9564142f608fa4aad890b4bacba"
}
}
}
}