{ "language": "Solidity", "sources": { "PostNFT_flatten.sol": { "content": "// Sources flattened with hardhat v2.10.1 https://hardhat.org\r\n\r\npragma solidity 0.8.17;\r\n\r\n// File @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.8.0-rc.1) (utils/Address.sol)\r\n\r\n\r\n/**\r\n * @dev Collection of functions related to the address type\r\n */\r\nlibrary AddressUpgradeable {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n * ====\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\r\n *\r\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\r\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\r\n * constructor.\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies on extcodesize/address.code.length, which returns 0\r\n // for contracts in construction, since the code is only stored at the end\r\n // of the constructor execution.\r\n\r\n return account.code.length > 0;\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(address(this).balance >= amount, \"Address: insufficient balance\");\r\n\r\n (bool success, ) = recipient.call{value: amount}(\"\");\r\n require(success, \"Address: unable to send value, recipient may have reverted\");\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain `call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\r\n (bool success, bytes memory returndata) = target.call{value: value}(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\r\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n (bool success, bytes memory returndata) = target.staticcall(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\r\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\r\n *\r\n * _Available since v4.8._\r\n */\r\n function verifyCallResultFromTarget(\r\n address target,\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n if (success) {\r\n if (returndata.length == 0) {\r\n // only check isContract if the call was successful and the return data is empty\r\n // otherwise we already know that it was a contract\r\n require(isContract(target), \"Address: call to non-contract\");\r\n }\r\n return returndata;\r\n } else {\r\n _revert(returndata, errorMessage);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\r\n * revert reason or using the provided one.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function verifyCallResult(\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal pure returns (bytes memory) {\r\n if (success) {\r\n return returndata;\r\n } else {\r\n _revert(returndata, errorMessage);\r\n }\r\n }\r\n\r\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length > 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.8.0-rc.1) (proxy/utils/Initializable.sol)\r\n\r\n\r\n/**\r\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\r\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\r\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\r\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\r\n *\r\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\r\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\r\n * case an upgrade adds a module that needs to be initialized.\r\n *\r\n * For example:\r\n *\r\n * [.hljs-theme-light.nopadding]\r\n * ```\r\n * contract MyToken is ERC20Upgradeable {\r\n * function initialize() initializer public {\r\n * __ERC20_init(\"MyToken\", \"MTK\");\r\n * }\r\n * }\r\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\r\n * function initializeV2() reinitializer(2) public {\r\n * __ERC20Permit_init(\"MyToken\");\r\n * }\r\n * }\r\n * ```\r\n *\r\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\r\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\r\n *\r\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\r\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\r\n *\r\n * [CAUTION]\r\n * ====\r\n * Avoid leaving a contract uninitialized.\r\n *\r\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\r\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\r\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\r\n *\r\n * [.hljs-theme-light.nopadding]\r\n * ```\r\n * /// @custom:oz-upgrades-unsafe-allow constructor\r\n * constructor() {\r\n * _disableInitializers();\r\n * }\r\n * ```\r\n * ====\r\n */\r\nabstract contract Initializable {\r\n /**\r\n * @dev Indicates that the contract has been initialized.\r\n * @custom:oz-retyped-from bool\r\n */\r\n uint8 private _initialized;\r\n\r\n /**\r\n * @dev Indicates that the contract is in the process of being initialized.\r\n */\r\n bool private _initializing;\r\n\r\n /**\r\n * @dev Triggered when the contract has been initialized or reinitialized.\r\n */\r\n event Initialized(uint8 version);\r\n\r\n /**\r\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\r\n * `onlyInitializing` functions can be used to initialize parent contracts.\r\n *\r\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\r\n * constructor.\r\n *\r\n * Emits an {Initialized} event.\r\n */\r\n modifier initializer() {\r\n bool isTopLevelCall = !_initializing;\r\n require(\r\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\r\n \"Initializable: contract is already initialized\"\r\n );\r\n _initialized = 1;\r\n if (isTopLevelCall) {\r\n _initializing = true;\r\n }\r\n _;\r\n if (isTopLevelCall) {\r\n _initializing = false;\r\n emit Initialized(1);\r\n }\r\n }\r\n\r\n /**\r\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\r\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\r\n * used to initialize parent contracts.\r\n *\r\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\r\n * are added through upgrades and that require initialization.\r\n *\r\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\r\n * cannot be nested. If one is invoked in the context of another, execution will revert.\r\n *\r\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\r\n * a contract, executing them in the right order is up to the developer or operator.\r\n *\r\n * WARNING: setting the version to 255 will prevent any future reinitialization.\r\n *\r\n * Emits an {Initialized} event.\r\n */\r\n modifier reinitializer(uint8 version) {\r\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\r\n _initialized = version;\r\n _initializing = true;\r\n _;\r\n _initializing = false;\r\n emit Initialized(version);\r\n }\r\n\r\n /**\r\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\r\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\r\n */\r\n modifier onlyInitializing() {\r\n require(_initializing, \"Initializable: contract is not initializing\");\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\r\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\r\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\r\n * through proxies.\r\n *\r\n * Emits an {Initialized} event the first time it is successfully executed.\r\n */\r\n function _disableInitializers() internal virtual {\r\n require(!_initializing, \"Initializable: contract is initializing\");\r\n if (_initialized < type(uint8).max) {\r\n _initialized = type(uint8).max;\r\n emit Initialized(type(uint8).max);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Internal function that returns the initialized version. Returns `_initialized`\r\n */\r\n function _getInitializedVersion() internal view returns (uint8) {\r\n return _initialized;\r\n }\r\n\r\n /**\r\n * @dev Internal function that returns the initialized version. Returns `_initializing`\r\n */\r\n function _isInitializing() internal view returns (bool) {\r\n return _initializing;\r\n }\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\r\n\r\n/**\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available\r\n * via msg.sender and msg.data, they should not be accessed in such a direct\r\n * manner, since when dealing with meta-transactions the account sending and\r\n * paying for execution may not be the actual sender (as far as an application\r\n * is concerned).\r\n *\r\n * This contract is only required for intermediate, library-like contracts.\r\n */\r\nabstract contract ContextUpgradeable is Initializable {\r\n function __Context_init() internal onlyInitializing {\r\n }\r\n\r\n function __Context_init_unchained() internal onlyInitializing {\r\n }\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n\r\n /**\r\n * @dev This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[50] private __gap;\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\r\n\r\n\r\n\r\n/**\r\n * @dev Contract module which provides a basic access control mechanism, where\r\n * there is an account (an owner) that can be granted exclusive access to\r\n * specific functions.\r\n *\r\n * By default, the owner account will be the one that deploys the contract. This\r\n * can later be changed with {transferOwnership}.\r\n *\r\n * This module is used through inheritance. It will make available the modifier\r\n * `onlyOwner`, which can be applied to your functions to restrict their use to\r\n * the owner.\r\n */\r\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n function __Ownable_init() internal onlyInitializing {\r\n __Ownable_init_unchained();\r\n }\r\n\r\n function __Ownable_init_unchained() internal onlyInitializing {\r\n _transferOwnership(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n _checkOwner();\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view virtual returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if the sender is not the owner.\r\n */\r\n function _checkOwner() internal view virtual {\r\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n *\r\n * NOTE: Renouncing ownership will leave the contract without an owner,\r\n * thereby removing any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public virtual onlyOwner {\r\n _transferOwnership(address(0));\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual onlyOwner {\r\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\r\n _transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Internal function without access restriction.\r\n */\r\n function _transferOwnership(address newOwner) internal virtual {\r\n address oldOwner = _owner;\r\n _owner = newOwner;\r\n emit OwnershipTransferred(oldOwner, newOwner);\r\n }\r\n\r\n /**\r\n * @dev This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[49] private __gap;\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.8.0-rc.1) (utils/math/Math.sol)\r\n\r\n\r\n/**\r\n * @dev Standard math utilities missing in the Solidity language.\r\n */\r\nlibrary MathUpgradeable {\r\n enum Rounding {\r\n Down, // Toward negative infinity\r\n Up, // Toward infinity\r\n Zero // Toward zero\r\n }\r\n\r\n /**\r\n * @dev Returns the largest of two numbers.\r\n */\r\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a > b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the smallest of two numbers.\r\n */\r\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a < b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the average of two numbers. The result is rounded towards\r\n * zero.\r\n */\r\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // (a + b) / 2 can overflow.\r\n return (a & b) + (a ^ b) / 2;\r\n }\r\n\r\n /**\r\n * @dev Returns the ceiling of the division of two numbers.\r\n *\r\n * This differs from standard division with `/` in that it rounds up instead\r\n * of rounding down.\r\n */\r\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // (a + b - 1) / b can overflow on addition, so we distribute.\r\n return a == 0 ? 0 : (a - 1) / b + 1;\r\n }\r\n\r\n /**\r\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\r\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\r\n * with further edits by Uniswap Labs also under MIT license.\r\n */\r\n function mulDiv(\r\n uint256 x,\r\n uint256 y,\r\n uint256 denominator\r\n ) internal pure returns (uint256 result) {\r\n unchecked {\r\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\r\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\r\n // variables such that product = prod1 * 2^256 + prod0.\r\n uint256 prod0; // Least significant 256 bits of the product\r\n uint256 prod1; // Most significant 256 bits of the product\r\n assembly {\r\n let mm := mulmod(x, y, not(0))\r\n prod0 := mul(x, y)\r\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\r\n }\r\n\r\n // Handle non-overflow cases, 256 by 256 division.\r\n if (prod1 == 0) {\r\n return prod0 / denominator;\r\n }\r\n\r\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\r\n require(denominator > prod1);\r\n\r\n ///////////////////////////////////////////////\r\n // 512 by 256 division.\r\n ///////////////////////////////////////////////\r\n\r\n // Make division exact by subtracting the remainder from [prod1 prod0].\r\n uint256 remainder;\r\n assembly {\r\n // Compute remainder using mulmod.\r\n remainder := mulmod(x, y, denominator)\r\n\r\n // Subtract 256 bit number from 512 bit number.\r\n prod1 := sub(prod1, gt(remainder, prod0))\r\n prod0 := sub(prod0, remainder)\r\n }\r\n\r\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\r\n // See https://cs.stackexchange.com/q/138556/92363.\r\n\r\n // Does not overflow because the denominator cannot be zero at this stage in the function.\r\n uint256 twos = denominator & (~denominator + 1);\r\n assembly {\r\n // Divide denominator by twos.\r\n denominator := div(denominator, twos)\r\n\r\n // Divide [prod1 prod0] by twos.\r\n prod0 := div(prod0, twos)\r\n\r\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\r\n twos := add(div(sub(0, twos), twos), 1)\r\n }\r\n\r\n // Shift in bits from prod1 into prod0.\r\n prod0 |= prod1 * twos;\r\n\r\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\r\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\r\n // four bits. That is, denominator * inv = 1 mod 2^4.\r\n uint256 inverse = (3 * denominator) ^ 2;\r\n\r\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\r\n // in modular arithmetic, doubling the correct bits in each step.\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\r\n\r\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\r\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\r\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\r\n // is no longer required.\r\n result = prod0 * inverse;\r\n return result;\r\n }\r\n }\r\n\r\n /**\r\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\r\n */\r\n function mulDiv(\r\n uint256 x,\r\n uint256 y,\r\n uint256 denominator,\r\n Rounding rounding\r\n ) internal pure returns (uint256) {\r\n uint256 result = mulDiv(x, y, denominator);\r\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\r\n result += 1;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\r\n *\r\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\r\n */\r\n function sqrt(uint256 a) internal pure returns (uint256) {\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\r\n //\r\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\r\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\r\n //\r\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\r\n // โ†’ `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\r\n // โ†’ `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\r\n //\r\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\r\n uint256 result = 1 << (log2(a) >> 1);\r\n\r\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\r\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\r\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\r\n // into the expected uint128 result.\r\n unchecked {\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n result = (result + a / result) >> 1;\r\n return min(result, a / result);\r\n }\r\n }\r\n\r\n /**\r\n * @notice Calculates sqrt(a), following the selected rounding direction.\r\n */\r\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = sqrt(a);\r\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 2, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log2(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value >> 128 > 0) {\r\n value >>= 128;\r\n result += 128;\r\n }\r\n if (value >> 64 > 0) {\r\n value >>= 64;\r\n result += 64;\r\n }\r\n if (value >> 32 > 0) {\r\n value >>= 32;\r\n result += 32;\r\n }\r\n if (value >> 16 > 0) {\r\n value >>= 16;\r\n result += 16;\r\n }\r\n if (value >> 8 > 0) {\r\n value >>= 8;\r\n result += 8;\r\n }\r\n if (value >> 4 > 0) {\r\n value >>= 4;\r\n result += 4;\r\n }\r\n if (value >> 2 > 0) {\r\n value >>= 2;\r\n result += 2;\r\n }\r\n if (value >> 1 > 0) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log2(value);\r\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 10, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log10(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value >= 10**64) {\r\n value /= 10**64;\r\n result += 64;\r\n }\r\n if (value >= 10**32) {\r\n value /= 10**32;\r\n result += 32;\r\n }\r\n if (value >= 10**16) {\r\n value /= 10**16;\r\n result += 16;\r\n }\r\n if (value >= 10**8) {\r\n value /= 10**8;\r\n result += 8;\r\n }\r\n if (value >= 10**4) {\r\n value /= 10**4;\r\n result += 4;\r\n }\r\n if (value >= 10**2) {\r\n value /= 10**2;\r\n result += 2;\r\n }\r\n if (value >= 10**1) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log10(value);\r\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 256, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n *\r\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\r\n */\r\n function log256(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value >> 128 > 0) {\r\n value >>= 128;\r\n result += 16;\r\n }\r\n if (value >> 64 > 0) {\r\n value >>= 64;\r\n result += 8;\r\n }\r\n if (value >> 32 > 0) {\r\n value >>= 32;\r\n result += 4;\r\n }\r\n if (value >> 16 > 0) {\r\n value >>= 16;\r\n result += 2;\r\n }\r\n if (value >> 8 > 0) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log256(value);\r\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\r\n }\r\n }\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.8.0-rc.1) (utils/Strings.sol)\r\n\r\n\r\n/**\r\n * @dev String operations.\r\n */\r\nlibrary StringsUpgradeable {\r\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\r\n uint8 private constant _ADDRESS_LENGTH = 20;\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\r\n */\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n unchecked {\r\n uint256 length = MathUpgradeable.log10(value) + 1;\r\n string memory buffer = new string(length);\r\n uint256 ptr;\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n ptr := add(buffer, add(32, length))\r\n }\r\n while (true) {\r\n ptr--;\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\r\n }\r\n value /= 10;\r\n if (value == 0) break;\r\n }\r\n return buffer;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(uint256 value) internal pure returns (string memory) {\r\n unchecked {\r\n return toHexString(value, MathUpgradeable.log256(value) + 1);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\r\n */\r\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\r\n bytes memory buffer = new bytes(2 * length + 2);\r\n buffer[0] = \"0\";\r\n buffer[1] = \"x\";\r\n for (uint256 i = 2 * length + 1; i > 1; --i) {\r\n buffer[i] = _SYMBOLS[value & 0xf];\r\n value >>= 4;\r\n }\r\n require(value == 0, \"Strings: hex length insufficient\");\r\n return string(buffer);\r\n }\r\n\r\n /**\r\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(address addr) internal pure returns (string memory) {\r\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\r\n }\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.8.0-rc.1) (utils/cryptography/ECDSA.sol)\r\n\r\n\r\n/**\r\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\r\n *\r\n * These functions can be used to verify that a message was signed by the holder\r\n * of the private keys of a given address.\r\n */\r\nlibrary ECDSAUpgradeable {\r\n enum RecoverError {\r\n NoError,\r\n InvalidSignature,\r\n InvalidSignatureLength,\r\n InvalidSignatureS,\r\n InvalidSignatureV // Deprecated in v4.8\r\n }\r\n\r\n function _throwError(RecoverError error) private pure {\r\n if (error == RecoverError.NoError) {\r\n return; // no error: do nothing\r\n } else if (error == RecoverError.InvalidSignature) {\r\n revert(\"ECDSA: invalid signature\");\r\n } else if (error == RecoverError.InvalidSignatureLength) {\r\n revert(\"ECDSA: invalid signature length\");\r\n } else if (error == RecoverError.InvalidSignatureS) {\r\n revert(\"ECDSA: invalid signature 's' value\");\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the address that signed a hashed message (`hash`) with\r\n * `signature` or error string. This address can then be used for verification purposes.\r\n *\r\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\r\n * this function rejects them by requiring the `s` value to be in the lower\r\n * half order, and the `v` value to be either 27 or 28.\r\n *\r\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\r\n * verification to be secure: it is possible to craft signatures that\r\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\r\n * this is by receiving a hash of the original message (which may otherwise\r\n * be too long), and then calling {toEthSignedMessageHash} on it.\r\n *\r\n * Documentation for signature generation:\r\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\r\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\r\n *\r\n * _Available since v4.3._\r\n */\r\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\r\n if (signature.length == 65) {\r\n bytes32 r;\r\n bytes32 s;\r\n uint8 v;\r\n // ecrecover takes the signature parameters, and the only way to get them\r\n // currently is to use assembly.\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n r := mload(add(signature, 0x20))\r\n s := mload(add(signature, 0x40))\r\n v := byte(0, mload(add(signature, 0x60)))\r\n }\r\n return tryRecover(hash, v, r, s);\r\n } else {\r\n return (address(0), RecoverError.InvalidSignatureLength);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the address that signed a hashed message (`hash`) with\r\n * `signature`. This address can then be used for verification purposes.\r\n *\r\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\r\n * this function rejects them by requiring the `s` value to be in the lower\r\n * half order, and the `v` value to be either 27 or 28.\r\n *\r\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\r\n * verification to be secure: it is possible to craft signatures that\r\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\r\n * this is by receiving a hash of the original message (which may otherwise\r\n * be too long), and then calling {toEthSignedMessageHash} on it.\r\n */\r\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\r\n (address recovered, RecoverError error) = tryRecover(hash, signature);\r\n _throwError(error);\r\n return recovered;\r\n }\r\n\r\n /**\r\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\r\n *\r\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\r\n *\r\n * _Available since v4.3._\r\n */\r\n function tryRecover(\r\n bytes32 hash,\r\n bytes32 r,\r\n bytes32 vs\r\n ) internal pure returns (address, RecoverError) {\r\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\r\n uint8 v = uint8((uint256(vs) >> 255) + 27);\r\n return tryRecover(hash, v, r, s);\r\n }\r\n\r\n /**\r\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\r\n *\r\n * _Available since v4.2._\r\n */\r\n function recover(\r\n bytes32 hash,\r\n bytes32 r,\r\n bytes32 vs\r\n ) internal pure returns (address) {\r\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\r\n _throwError(error);\r\n return recovered;\r\n }\r\n\r\n /**\r\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\r\n * `r` and `s` signature fields separately.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function tryRecover(\r\n bytes32 hash,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) internal pure returns (address, RecoverError) {\r\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\r\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\r\n // the valid range for s in (301): 0 < s < secp256k1n รท 2 + 1, and for v in (302): v โˆˆ {27, 28}. Most\r\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\r\n //\r\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\r\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\r\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\r\n // these malleable signatures as well.\r\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\r\n return (address(0), RecoverError.InvalidSignatureS);\r\n }\r\n\r\n // If the signature is valid (and not malleable), return the signer address\r\n address signer = ecrecover(hash, v, r, s);\r\n if (signer == address(0)) {\r\n return (address(0), RecoverError.InvalidSignature);\r\n }\r\n\r\n return (signer, RecoverError.NoError);\r\n }\r\n\r\n /**\r\n * @dev Overload of {ECDSA-recover} that receives the `v`,\r\n * `r` and `s` signature fields separately.\r\n */\r\n function recover(\r\n bytes32 hash,\r\n uint8 v,\r\n bytes32 r,\r\n bytes32 s\r\n ) internal pure returns (address) {\r\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\r\n _throwError(error);\r\n return recovered;\r\n }\r\n\r\n /**\r\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\r\n * produces hash corresponding to the one signed with the\r\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\r\n * JSON-RPC method as part of EIP-191.\r\n *\r\n * See {recover}.\r\n */\r\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\r\n // 32 is the length in bytes of hash,\r\n // enforced by the type signature above\r\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\r\n }\r\n\r\n /**\r\n * @dev Returns an Ethereum Signed Message, created from `s`. This\r\n * produces hash corresponding to the one signed with the\r\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\r\n * JSON-RPC method as part of EIP-191.\r\n *\r\n * See {recover}.\r\n */\r\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\r\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\r\n }\r\n\r\n /**\r\n * @dev Returns an Ethereum Signed Typed Data, created from a\r\n * `domainSeparator` and a `structHash`. This produces hash corresponding\r\n * to the one signed with the\r\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\r\n * JSON-RPC method as part of EIP-712.\r\n *\r\n * See {recover}.\r\n */\r\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\r\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\r\n }\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.8.0-rc.1) (security/ReentrancyGuard.sol)\r\n\r\n\r\n/**\r\n * @dev Contract module that helps prevent reentrant calls to a function.\r\n *\r\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\r\n * available, which can be applied to functions to make sure there are no nested\r\n * (reentrant) calls to them.\r\n *\r\n * Note that because there is a single `nonReentrant` guard, functions marked as\r\n * `nonReentrant` may not call one another. This can be worked around by making\r\n * those functions `private`, and then adding `external` `nonReentrant` entry\r\n * points to them.\r\n *\r\n * TIP: If you would like to learn more about reentrancy and alternative ways\r\n * to protect against it, check out our blog post\r\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\r\n */\r\nabstract contract ReentrancyGuardUpgradeable is Initializable {\r\n // Booleans are more expensive than uint256 or any type that takes up a full\r\n // word because each write operation emits an extra SLOAD to first read the\r\n // slot's contents, replace the bits taken up by the boolean, and then write\r\n // back. This is the compiler's defense against contract upgrades and\r\n // pointer aliasing, and it cannot be disabled.\r\n\r\n // The values being non-zero value makes deployment a bit more expensive,\r\n // but in exchange the refund on every call to nonReentrant will be lower in\r\n // amount. Since refunds are capped to a percentage of the total\r\n // transaction's gas, it is best to keep them low in cases like this one, to\r\n // increase the likelihood of the full refund coming into effect.\r\n uint256 private constant _NOT_ENTERED = 1;\r\n uint256 private constant _ENTERED = 2;\r\n\r\n uint256 private _status;\r\n\r\n function __ReentrancyGuard_init() internal onlyInitializing {\r\n __ReentrancyGuard_init_unchained();\r\n }\r\n\r\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\r\n _status = _NOT_ENTERED;\r\n }\r\n\r\n /**\r\n * @dev Prevents a contract from calling itself, directly or indirectly.\r\n * Calling a `nonReentrant` function from another `nonReentrant`\r\n * function is not supported. It is possible to prevent this from happening\r\n * by making the `nonReentrant` function external, and making it call a\r\n * `private` function that does the actual work.\r\n */\r\n modifier nonReentrant() {\r\n _nonReentrantBefore();\r\n _;\r\n _nonReentrantAfter();\r\n }\r\n\r\n function _nonReentrantBefore() private {\r\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\r\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\r\n\r\n // Any calls to nonReentrant after this point will fail\r\n _status = _ENTERED;\r\n }\r\n\r\n function _nonReentrantAfter() private {\r\n // By storing the original value once again, a refund is triggered (see\r\n // https://eips.ethereum.org/EIPS/eip-2200)\r\n _status = _NOT_ENTERED;\r\n }\r\n\r\n /**\r\n * @dev This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[49] private __gap;\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\r\n\r\n\r\n/**\r\n * @dev Interface of the ERC165 standard, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\r\n *\r\n * Implementers can declare support of contract interfaces, which can then be\r\n * queried by others ({ERC165Checker}).\r\n *\r\n * For an implementation, see {ERC165}.\r\n */\r\ninterface IERC165Upgradeable {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\r\n\r\n\r\n/**\r\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\r\n *\r\n * _Available since v3.1._\r\n */\r\ninterface IERC1155Upgradeable is IERC165Upgradeable {\r\n /**\r\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\r\n */\r\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\r\n\r\n /**\r\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\r\n * transfers.\r\n */\r\n event TransferBatch(\r\n address indexed operator,\r\n address indexed from,\r\n address indexed to,\r\n uint256[] ids,\r\n uint256[] values\r\n );\r\n\r\n /**\r\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\r\n * `approved`.\r\n */\r\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\r\n\r\n /**\r\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\r\n *\r\n * If an {URI} event was emitted for `id`, the standard\r\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\r\n * returned by {IERC1155MetadataURI-uri}.\r\n */\r\n event URI(string value, uint256 indexed id);\r\n\r\n /**\r\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n */\r\n function balanceOf(address account, uint256 id) external view returns (uint256);\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\r\n *\r\n * Requirements:\r\n *\r\n * - `accounts` and `ids` must have the same length.\r\n */\r\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\r\n external\r\n view\r\n returns (uint256[] memory);\r\n\r\n /**\r\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `operator` cannot be the caller.\r\n */\r\n function setApprovalForAll(address operator, bool approved) external;\r\n\r\n /**\r\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\r\n *\r\n * See {setApprovalForAll}.\r\n */\r\n function isApprovedForAll(address account, address operator) external view returns (bool);\r\n\r\n /**\r\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\r\n *\r\n * Emits a {TransferSingle} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\r\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\r\n * acceptance magic value.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes calldata data\r\n ) external;\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\r\n *\r\n * Emits a {TransferBatch} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `ids` and `amounts` must have the same length.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\r\n * acceptance magic value.\r\n */\r\n function safeBatchTransferFrom(\r\n address from,\r\n address to,\r\n uint256[] calldata ids,\r\n uint256[] calldata amounts,\r\n bytes calldata data\r\n ) external;\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155ReceiverUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\r\n\r\n\r\n/**\r\n * @dev _Available since v3.1._\r\n */\r\ninterface IERC1155ReceiverUpgradeable is IERC165Upgradeable {\r\n /**\r\n * @dev Handles the receipt of a single ERC1155 token type. This function is\r\n * called at the end of a `safeTransferFrom` after the balance has been updated.\r\n *\r\n * NOTE: To accept the transfer, this must return\r\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\r\n * (i.e. 0xf23a6e61, or its own function selector).\r\n *\r\n * @param operator The address which initiated the transfer (i.e. msg.sender)\r\n * @param from The address which previously owned the token\r\n * @param id The ID of the token being transferred\r\n * @param value The amount of tokens being transferred\r\n * @param data Additional data with no specified format\r\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\r\n */\r\n function onERC1155Received(\r\n address operator,\r\n address from,\r\n uint256 id,\r\n uint256 value,\r\n bytes calldata data\r\n ) external returns (bytes4);\r\n\r\n /**\r\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\r\n * is called at the end of a `safeBatchTransferFrom` after the balances have\r\n * been updated.\r\n *\r\n * NOTE: To accept the transfer(s), this must return\r\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\r\n * (i.e. 0xbc197c81, or its own function selector).\r\n *\r\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\r\n * @param from The address which previously owned the token\r\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\r\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\r\n * @param data Additional data with no specified format\r\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\r\n */\r\n function onERC1155BatchReceived(\r\n address operator,\r\n address from,\r\n uint256[] calldata ids,\r\n uint256[] calldata values,\r\n bytes calldata data\r\n ) external returns (bytes4);\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/token/ERC1155/extensions/IERC1155MetadataURIUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)\r\n\r\n\r\n/**\r\n * @dev Interface of the optional ERC1155MetadataExtension interface, as defined\r\n * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].\r\n *\r\n * _Available since v3.1._\r\n */\r\ninterface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable {\r\n /**\r\n * @dev Returns the URI for token type `id`.\r\n *\r\n * If the `\\{id\\}` substring is present in the URI, it must be replaced by\r\n * clients with the actual token type ID.\r\n */\r\n function uri(uint256 id) external view returns (string memory);\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\r\n\r\n\r\n\r\n/**\r\n * @dev Implementation of the {IERC165} interface.\r\n *\r\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\r\n * for the additional interface id that will be supported. For example:\r\n *\r\n * ```solidity\r\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\r\n * }\r\n * ```\r\n *\r\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\r\n */\r\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\r\n function __ERC165_init() internal onlyInitializing {\r\n }\r\n\r\n function __ERC165_init_unchained() internal onlyInitializing {\r\n }\r\n /**\r\n * @dev See {IERC165-supportsInterface}.\r\n */\r\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n return interfaceId == type(IERC165Upgradeable).interfaceId;\r\n }\r\n\r\n /**\r\n * @dev This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[50] private __gap;\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.8.0-rc.1) (token/ERC1155/ERC1155.sol)\r\n\r\n\r\n/**\r\n * @dev Implementation of the basic standard multi-token.\r\n * See https://eips.ethereum.org/EIPS/eip-1155\r\n * Originally based on code by Enjin: https://github.com/enjin/erc-1155\r\n *\r\n * _Available since v3.1._\r\n */\r\ncontract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable {\r\n using AddressUpgradeable for address;\r\n\r\n // Mapping from token ID to account balances\r\n mapping(uint256 => mapping(address => uint256)) private _balances;\r\n\r\n // Mapping from account to operator approvals\r\n mapping(address => mapping(address => bool)) private _operatorApprovals;\r\n\r\n // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json\r\n string private _uri;\r\n\r\n /**\r\n * @dev See {_setURI}.\r\n */\r\n function __ERC1155_init(string memory uri_) internal onlyInitializing {\r\n __ERC1155_init_unchained(uri_);\r\n }\r\n\r\n function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing {\r\n _setURI(uri_);\r\n }\r\n\r\n /**\r\n * @dev See {IERC165-supportsInterface}.\r\n */\r\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\r\n return\r\n interfaceId == type(IERC1155Upgradeable).interfaceId ||\r\n interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId ||\r\n super.supportsInterface(interfaceId);\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155MetadataURI-uri}.\r\n *\r\n * This implementation returns the same URI for *all* token types. It relies\r\n * on the token type ID substitution mechanism\r\n * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].\r\n *\r\n * Clients calling this function must replace the `\\{id\\}` substring with the\r\n * actual token type ID.\r\n */\r\n function uri(uint256) public view virtual override returns (string memory) {\r\n return _uri;\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-balanceOf}.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n */\r\n function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {\r\n require(account != address(0), \"ERC1155: address zero is not a valid owner\");\r\n return _balances[id][account];\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-balanceOfBatch}.\r\n *\r\n * Requirements:\r\n *\r\n * - `accounts` and `ids` must have the same length.\r\n */\r\n function balanceOfBatch(address[] memory accounts, uint256[] memory ids)\r\n public\r\n view\r\n virtual\r\n override\r\n returns (uint256[] memory)\r\n {\r\n require(accounts.length == ids.length, \"ERC1155: accounts and ids length mismatch\");\r\n\r\n uint256[] memory batchBalances = new uint256[](accounts.length);\r\n\r\n for (uint256 i = 0; i < accounts.length; ++i) {\r\n batchBalances[i] = balanceOf(accounts[i], ids[i]);\r\n }\r\n\r\n return batchBalances;\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-setApprovalForAll}.\r\n */\r\n function setApprovalForAll(address operator, bool approved) public virtual override {\r\n _setApprovalForAll(_msgSender(), operator, approved);\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-isApprovedForAll}.\r\n */\r\n function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {\r\n return _operatorApprovals[account][operator];\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-safeTransferFrom}.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes memory data\r\n ) public virtual override {\r\n require(\r\n from == _msgSender() || isApprovedForAll(from, _msgSender()),\r\n \"ERC1155: caller is not token owner or approved\"\r\n );\r\n _safeTransferFrom(from, to, id, amount, data);\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-safeBatchTransferFrom}.\r\n */\r\n function safeBatchTransferFrom(\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) public virtual override {\r\n require(\r\n from == _msgSender() || isApprovedForAll(from, _msgSender()),\r\n \"ERC1155: caller is not token owner or approved\"\r\n );\r\n _safeBatchTransferFrom(from, to, ids, amounts, data);\r\n }\r\n\r\n /**\r\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\r\n *\r\n * Emits a {TransferSingle} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\r\n * acceptance magic value.\r\n */\r\n function _safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes memory data\r\n ) internal virtual {\r\n require(to != address(0), \"ERC1155: transfer to the zero address\");\r\n\r\n address operator = _msgSender();\r\n uint256[] memory ids = _asSingletonArray(id);\r\n uint256[] memory amounts = _asSingletonArray(amount);\r\n\r\n _beforeTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n uint256 fromBalance = _balances[id][from];\r\n require(fromBalance >= amount, \"ERC1155: insufficient balance for transfer\");\r\n unchecked {\r\n _balances[id][from] = fromBalance - amount;\r\n }\r\n _balances[id][to] += amount;\r\n\r\n emit TransferSingle(operator, from, to, id, amount);\r\n\r\n _afterTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);\r\n }\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.\r\n *\r\n * Emits a {TransferBatch} event.\r\n *\r\n * Requirements:\r\n *\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\r\n * acceptance magic value.\r\n */\r\n function _safeBatchTransferFrom(\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual {\r\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\r\n require(to != address(0), \"ERC1155: transfer to the zero address\");\r\n\r\n address operator = _msgSender();\r\n\r\n _beforeTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n for (uint256 i = 0; i < ids.length; ++i) {\r\n uint256 id = ids[i];\r\n uint256 amount = amounts[i];\r\n\r\n uint256 fromBalance = _balances[id][from];\r\n require(fromBalance >= amount, \"ERC1155: insufficient balance for transfer\");\r\n unchecked {\r\n _balances[id][from] = fromBalance - amount;\r\n }\r\n _balances[id][to] += amount;\r\n }\r\n\r\n emit TransferBatch(operator, from, to, ids, amounts);\r\n\r\n _afterTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);\r\n }\r\n\r\n /**\r\n * @dev Sets a new URI for all token types, by relying on the token type ID\r\n * substitution mechanism\r\n * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].\r\n *\r\n * By this mechanism, any occurrence of the `\\{id\\}` substring in either the\r\n * URI or any of the amounts in the JSON file at said URI will be replaced by\r\n * clients with the token type ID.\r\n *\r\n * For example, the `https://token-cdn-domain/\\{id\\}.json` URI would be\r\n * interpreted by clients as\r\n * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`\r\n * for token type ID 0x4cce0.\r\n *\r\n * See {uri}.\r\n *\r\n * Because these URIs cannot be meaningfully represented by the {URI} event,\r\n * this function emits no events.\r\n */\r\n function _setURI(string memory newuri) internal virtual {\r\n _uri = newuri;\r\n }\r\n\r\n /**\r\n * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.\r\n *\r\n * Emits a {TransferSingle} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\r\n * acceptance magic value.\r\n */\r\n function _mint(\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes memory data\r\n ) internal virtual {\r\n require(to != address(0), \"ERC1155: mint to the zero address\");\r\n\r\n address operator = _msgSender();\r\n uint256[] memory ids = _asSingletonArray(id);\r\n uint256[] memory amounts = _asSingletonArray(amount);\r\n\r\n _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);\r\n\r\n _balances[id][to] += amount;\r\n emit TransferSingle(operator, address(0), to, id, amount);\r\n\r\n _afterTokenTransfer(operator, address(0), to, ids, amounts, data);\r\n\r\n _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);\r\n }\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.\r\n *\r\n * Emits a {TransferBatch} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `ids` and `amounts` must have the same length.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\r\n * acceptance magic value.\r\n */\r\n function _mintBatch(\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual {\r\n require(to != address(0), \"ERC1155: mint to the zero address\");\r\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\r\n\r\n address operator = _msgSender();\r\n\r\n _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);\r\n\r\n for (uint256 i = 0; i < ids.length; i++) {\r\n _balances[ids[i]][to] += amounts[i];\r\n }\r\n\r\n emit TransferBatch(operator, address(0), to, ids, amounts);\r\n\r\n _afterTokenTransfer(operator, address(0), to, ids, amounts, data);\r\n\r\n _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);\r\n }\r\n\r\n /**\r\n * @dev Destroys `amount` tokens of token type `id` from `from`\r\n *\r\n * Emits a {TransferSingle} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `from` must have at least `amount` tokens of token type `id`.\r\n */\r\n function _burn(\r\n address from,\r\n uint256 id,\r\n uint256 amount\r\n ) internal virtual {\r\n require(from != address(0), \"ERC1155: burn from the zero address\");\r\n\r\n address operator = _msgSender();\r\n uint256[] memory ids = _asSingletonArray(id);\r\n uint256[] memory amounts = _asSingletonArray(amount);\r\n\r\n _beforeTokenTransfer(operator, from, address(0), ids, amounts, \"\");\r\n\r\n uint256 fromBalance = _balances[id][from];\r\n require(fromBalance >= amount, \"ERC1155: burn amount exceeds balance\");\r\n unchecked {\r\n _balances[id][from] = fromBalance - amount;\r\n }\r\n\r\n emit TransferSingle(operator, from, address(0), id, amount);\r\n\r\n _afterTokenTransfer(operator, from, address(0), ids, amounts, \"\");\r\n }\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.\r\n *\r\n * Emits a {TransferBatch} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `ids` and `amounts` must have the same length.\r\n */\r\n function _burnBatch(\r\n address from,\r\n uint256[] memory ids,\r\n uint256[] memory amounts\r\n ) internal virtual {\r\n require(from != address(0), \"ERC1155: burn from the zero address\");\r\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\r\n\r\n address operator = _msgSender();\r\n\r\n _beforeTokenTransfer(operator, from, address(0), ids, amounts, \"\");\r\n\r\n for (uint256 i = 0; i < ids.length; i++) {\r\n uint256 id = ids[i];\r\n uint256 amount = amounts[i];\r\n\r\n uint256 fromBalance = _balances[id][from];\r\n require(fromBalance >= amount, \"ERC1155: burn amount exceeds balance\");\r\n unchecked {\r\n _balances[id][from] = fromBalance - amount;\r\n }\r\n }\r\n\r\n emit TransferBatch(operator, from, address(0), ids, amounts);\r\n\r\n _afterTokenTransfer(operator, from, address(0), ids, amounts, \"\");\r\n }\r\n\r\n /**\r\n * @dev Approve `operator` to operate on all of `owner` tokens\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function _setApprovalForAll(\r\n address owner,\r\n address operator,\r\n bool approved\r\n ) internal virtual {\r\n require(owner != operator, \"ERC1155: setting approval status for self\");\r\n _operatorApprovals[owner][operator] = approved;\r\n emit ApprovalForAll(owner, operator, approved);\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before any token transfer. This includes minting\r\n * and burning, as well as batched variants.\r\n *\r\n * The same hook is called on both single and batched variants. For single\r\n * transfers, the length of the `ids` and `amounts` arrays will be 1.\r\n *\r\n * Calling conditions (for each `id` and `amount` pair):\r\n *\r\n * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * of token type `id` will be transferred to `to`.\r\n * - When `from` is zero, `amount` tokens of token type `id` will be minted\r\n * for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`\r\n * will be burned.\r\n * - `from` and `to` are never both zero.\r\n * - `ids` and `amounts` have the same, non-zero length.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _beforeTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual {}\r\n\r\n /**\r\n * @dev Hook that is called after any token transfer. This includes minting\r\n * and burning, as well as batched variants.\r\n *\r\n * The same hook is called on both single and batched variants. For single\r\n * transfers, the length of the `id` and `amount` arrays will be 1.\r\n *\r\n * Calling conditions (for each `id` and `amount` pair):\r\n *\r\n * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * of token type `id` will be transferred to `to`.\r\n * - When `from` is zero, `amount` tokens of token type `id` will be minted\r\n * for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`\r\n * will be burned.\r\n * - `from` and `to` are never both zero.\r\n * - `ids` and `amounts` have the same, non-zero length.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _afterTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual {}\r\n\r\n function _doSafeTransferAcceptanceCheck(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes memory data\r\n ) private {\r\n if (to.isContract()) {\r\n try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {\r\n if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) {\r\n revert(\"ERC1155: ERC1155Receiver rejected tokens\");\r\n }\r\n } catch Error(string memory reason) {\r\n revert(reason);\r\n } catch {\r\n revert(\"ERC1155: transfer to non-ERC1155Receiver implementer\");\r\n }\r\n }\r\n }\r\n\r\n function _doSafeBatchTransferAcceptanceCheck(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) private {\r\n if (to.isContract()) {\r\n try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (\r\n bytes4 response\r\n ) {\r\n if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) {\r\n revert(\"ERC1155: ERC1155Receiver rejected tokens\");\r\n }\r\n } catch Error(string memory reason) {\r\n revert(reason);\r\n } catch {\r\n revert(\"ERC1155: transfer to non-ERC1155Receiver implementer\");\r\n }\r\n }\r\n }\r\n\r\n function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {\r\n uint256[] memory array = new uint256[](1);\r\n array[0] = element;\r\n\r\n return array;\r\n }\r\n\r\n /**\r\n * @dev This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[47] private __gap;\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\r\n\r\n\r\n\r\n/**\r\n * @dev Contract module which allows children to implement an emergency stop\r\n * mechanism that can be triggered by an authorized account.\r\n *\r\n * This module is used through inheritance. It will make available the\r\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\r\n * the functions of your contract. Note that they will not be pausable by\r\n * simply including this module, only once the modifiers are put in place.\r\n */\r\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\r\n /**\r\n * @dev Emitted when the pause is triggered by `account`.\r\n */\r\n event Paused(address account);\r\n\r\n /**\r\n * @dev Emitted when the pause is lifted by `account`.\r\n */\r\n event Unpaused(address account);\r\n\r\n bool private _paused;\r\n\r\n /**\r\n * @dev Initializes the contract in unpaused state.\r\n */\r\n function __Pausable_init() internal onlyInitializing {\r\n __Pausable_init_unchained();\r\n }\r\n\r\n function __Pausable_init_unchained() internal onlyInitializing {\r\n _paused = false;\r\n }\r\n\r\n /**\r\n * @dev Modifier to make a function callable only when the contract is not paused.\r\n *\r\n * Requirements:\r\n *\r\n * - The contract must not be paused.\r\n */\r\n modifier whenNotPaused() {\r\n _requireNotPaused();\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Modifier to make a function callable only when the contract is paused.\r\n *\r\n * Requirements:\r\n *\r\n * - The contract must be paused.\r\n */\r\n modifier whenPaused() {\r\n _requirePaused();\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Returns true if the contract is paused, and false otherwise.\r\n */\r\n function paused() public view virtual returns (bool) {\r\n return _paused;\r\n }\r\n\r\n /**\r\n * @dev Throws if the contract is paused.\r\n */\r\n function _requireNotPaused() internal view virtual {\r\n require(!paused(), \"Pausable: paused\");\r\n }\r\n\r\n /**\r\n * @dev Throws if the contract is not paused.\r\n */\r\n function _requirePaused() internal view virtual {\r\n require(paused(), \"Pausable: not paused\");\r\n }\r\n\r\n /**\r\n * @dev Triggers stopped state.\r\n *\r\n * Requirements:\r\n *\r\n * - The contract must not be paused.\r\n */\r\n function _pause() internal virtual whenNotPaused {\r\n _paused = true;\r\n emit Paused(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev Returns to normal state.\r\n *\r\n * Requirements:\r\n *\r\n * - The contract must be paused.\r\n */\r\n function _unpause() internal virtual whenPaused {\r\n _paused = false;\r\n emit Unpaused(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[49] private __gap;\r\n}\r\n\r\n\r\n// File @openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol@v4.8.0-rc.1\r\n\r\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Pausable.sol)\r\n\r\n\r\n\r\n/**\r\n * @dev ERC1155 token with pausable token transfers, minting and burning.\r\n *\r\n * Useful for scenarios such as preventing trades until the end of an evaluation\r\n * period, or having an emergency switch for freezing all token transfers in the\r\n * event of a large bug.\r\n *\r\n * _Available since v3.1._\r\n */\r\nabstract contract ERC1155PausableUpgradeable is Initializable, ERC1155Upgradeable, PausableUpgradeable {\r\n function __ERC1155Pausable_init() internal onlyInitializing {\r\n __Pausable_init_unchained();\r\n }\r\n\r\n function __ERC1155Pausable_init_unchained() internal onlyInitializing {\r\n }\r\n /**\r\n * @dev See {ERC1155-_beforeTokenTransfer}.\r\n *\r\n * Requirements:\r\n *\r\n * - the contract must not be paused.\r\n */\r\n function _beforeTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual override {\r\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n require(!paused(), \"ERC1155Pausable: token transfer while paused\");\r\n }\r\n\r\n /**\r\n * @dev This empty reserved space is put in place to allow future versions to add new\r\n * variables without shifting down storage in the inheritance chain.\r\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\r\n */\r\n uint256[50] private __gap;\r\n}\r\n\r\n\r\n// File contracts/TokenIdentifiers.sol\r\n\r\n\r\n/*\r\n DESIGN NOTES:\r\n Token ids are a concatenation of:\r\n * creator: hex address of the creator of the token. 160 bits\r\n * index: Index for this token (the regular ID), up to 2^56 - 1. 56 bits\r\n * supply: Supply cap for this token, up to 2^40 - 1 (1 trillion). 40 bits\r\n\r\n*/\r\n/**\r\n * @title TokenIdentifiers\r\n * support for authentication and metadata for token ids\r\n */\r\nlibrary TokenIdentifiers {\r\n uint8 constant ADDRESS_BITS = 160;\r\n uint8 constant INDEX_BITS = 56;\r\n uint8 constant SUPPLY_BITS = 40;\r\n\r\n uint256 constant SUPPLY_MASK = (uint256(1) << SUPPLY_BITS) - 1;\r\n uint256 constant INDEX_MASK =\r\n ((uint256(1) << (INDEX_BITS + SUPPLY_BITS)) - 1) ^ SUPPLY_MASK;\r\n\r\n function tokenMaxSupply(uint256 _id) internal pure returns (uint256) {\r\n return _id & SUPPLY_MASK;\r\n }\r\n\r\n function tokenIndex(uint256 _id) internal pure returns (uint256) {\r\n return (_id & INDEX_MASK) >> SUPPLY_BITS;\r\n }\r\n\r\n function tokenCreator(uint256 _id) internal pure returns (address) {\r\n return address(uint160(_id >> (INDEX_BITS + SUPPLY_BITS)));\r\n }\r\n}\r\n\r\n\r\n// File contracts/ReviewNFTUpgradable.sol\r\n\r\n\r\n\r\ncontract AtemReviewV2 is ERC1155PausableUpgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable {\r\n using TokenIdentifiers for uint256;\r\n using ECDSAUpgradeable for bytes32;\r\n\r\n // Contract name\r\n string public name;\r\n // Contract symbol\r\n string public symbol;\r\n // Current minted supply of each token\r\n mapping(uint256 => uint256) private _supply;\r\n // Price of each token\r\n mapping(uint256 => uint256) private _price;\r\n // Total creations of a specific creator\r\n mapping(address => uint256) private _totalCreations;\r\n // Token URIs on AR\r\n mapping(uint256 => string) private _contentURIs;\r\n \r\n // Allow to override the token creator;\r\n mapping(uint256 => address) private _creatorOverride;\r\n\r\n // Allow to set payment address different from the creator address\r\n mapping(address => address) private _creatorPayment;\r\n\r\n // Authentication account for the post creation\r\n address private _platformAuthorizeAccount;\r\n\r\n // Platform fee ratio (Unit: 1/10000)\r\n uint256 private _platformFeeRatio;\r\n // Platform fee account\r\n address private _platformFeeAccount;\r\n\r\n // Royalty fee balance of each creator (not used for current version)\r\n mapping(address => uint256) private _royaltyFeeBalance;\r\n\r\n // Chain ID\r\n uint256 private _chainId;\r\n\r\n /** Events */\r\n event CreatorChanged(uint256 indexed id, address indexed oldCreator, address indexed newCreator);\r\n event CreatorPaymentChanged(address creatorAddress, address indexed oldAddress, address indexed newAddress);\r\n event PriceChanged(uint256 indexed id, uint256 indexed price);\r\n event PostCreated(address indexed creator, uint256 indexed id, address indexed to, uint256 price);\r\n event PostPurchased(address indexed creator, uint256 indexed id, address indexed buyer, address to, uint256 price, uint256 amount);\r\n\r\n \r\n function initialize(\r\n string memory _name,\r\n string memory _symbol, \r\n string memory _uri,\r\n uint256 chainId_,\r\n address initialPlatformAuthorizeAccount,\r\n uint256 initialPlatformFeeRatio,\r\n address initialPlatformFeeAccount) public virtual initializer {\r\n __ERC1155_init_unchained(_uri);\r\n __Pausable_init_unchained();\r\n __Ownable_init_unchained();\r\n __ReentrancyGuard_init_unchained();\r\n\r\n name = _name;\r\n symbol = _symbol;\r\n \r\n _platformAuthorizeAccount = initialPlatformAuthorizeAccount;\r\n _platformFeeRatio = initialPlatformFeeRatio;\r\n _platformFeeAccount = initialPlatformFeeAccount;\r\n\r\n _chainId = chainId_;\r\n } \r\n\r\n\r\n /** --------------------------------------------\r\n * Receive and withdraw\r\n * --------------------------------------------- */\r\n\r\n receive() external payable { }\r\n\r\n function _withdraw(address _address, uint256 _amount) private {\r\n if ((_address != address(0)) && (_address != address(this)) && (_amount > 0)) {\r\n (bool success, ) = _address.call{value: _amount}(\"\");\r\n require(success, \"Transfer failed.\");\r\n }\r\n }\r\n\r\n function withdrawAll() external onlyOwner {\r\n _withdraw(_msgSender(), address(this).balance);\r\n }\r\n function withdraw(uint256 amount) external onlyOwner {\r\n require(address(this).balance >= amount);\r\n _withdraw(_msgSender(), amount);\r\n }\r\n\r\n /** --------------------------------------------\r\n * Signature verification\r\n * --------------------------------------------- */\r\n function _verify(bytes32 data, bytes memory signature, address account) internal pure returns (bool) \r\n {\r\n return signatureRecover(data, signature) == account;\r\n }\r\n\r\n function signatureRecover(bytes32 data, bytes memory signature) public pure returns (address) {\r\n return data\r\n .toEthSignedMessageHash()\r\n .recover(signature);\r\n }\r\n\r\n /** --------------------------------------------\r\n * Creator related access control\r\n * --------------------------------------------- */\r\n\r\n /**\r\n * @dev Require msg.sender to be the creator of the token id\r\n */\r\n modifier onlyCreator(uint256 _id) \r\n {\r\n require(\r\n _isCreator(_id, _msgSender()),\r\n \" AtemReview#onlyCreator: only the token creator can do this\"\r\n );\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Get the creator for a token\r\n * @param id The token id to look up\r\n */\r\n function creator(uint256 id) \r\n internal view returns (address) \r\n {\r\n if (_creatorOverride[id] != address(0)) {\r\n return _creatorOverride[id];\r\n } else {\r\n return id.tokenCreator();\r\n }\r\n }\r\n\r\n /**\r\n * @dev Check if the given address is the creator of the given token ID\r\n * @param id Token ID to check\r\n * @param addr Address to check\r\n */\r\n function _isCreator(uint256 id, address addr)\r\n internal view returns (bool)\r\n {\r\n address creator_ = creator(id);\r\n return creator_ == addr;\r\n }\r\n\r\n /**\r\n * @dev Change the creator address for given token\r\n * @param _to Address of the new creator\r\n * @param _id Token IDs to change creator of\r\n */\r\n function setCreator(uint256 _id, address _to) \r\n public onlyCreator(_id) {\r\n require(\r\n _to != address(0),\r\n \" AtemReview#setCreator: invalid address\"\r\n );\r\n _creatorOverride[_id] = _to;\r\n emit CreatorChanged(_id, _msgSender(), _to);\r\n }\r\n\r\n function setCreatorPayment(address _to) external {\r\n require(\r\n _to != address(0),\r\n \" AtemReview#setCreatorPayment: invalid address\"\r\n );\r\n\r\n emit CreatorPaymentChanged(_msgSender(), _creatorPayment[_msgSender()], _to);\r\n _creatorPayment[_msgSender()] = _to;\r\n }\r\n\r\n function creatorPayment(address addr) \r\n public view returns (address) {\r\n if (_creatorPayment[addr] != address(0)) {\r\n return _creatorPayment[addr];\r\n } else {\r\n return addr;\r\n }\r\n }\r\n\r\n /** --------------------------------------------\r\n * Sales related functions\r\n * --------------------------------------------- */\r\n\r\n function _setPrice(uint256 id, uint256 price)\r\n private\r\n {\r\n _price[id] = price;\r\n }\r\n\r\n function setPrice(uint256 id, uint256 price)\r\n external onlyCreator(id)\r\n {\r\n _setPrice(id, price);\r\n emit PriceChanged(id, price);\r\n }\r\n\r\n /**\r\n * @dev A simpler api for non-first-time purchases\r\n */\r\n function mint(\r\n address to,\r\n uint256 id,\r\n uint256 amount\r\n ) public payable\r\n {\r\n mint(to, id, amount, 0, \"\", \"\");\r\n }\r\n\r\n\r\n /**\r\n * @dev Mint a single token id and set its price. Everyone can do this, but need an authorized signature for id, price and contentURI.\r\n * The signature, contentURI, and price are only used for first-time minting.\r\n */\r\n function mint(\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n uint256 price,\r\n string memory contentURI_,\r\n bytes memory signature_\r\n ) public payable nonReentrant()\r\n { \r\n require(\r\n _supply[id] + amount <= id.tokenMaxSupply(),\r\n \" AtemReview#mint: minting would exceed total supply\"\r\n );\r\n\r\n address creator_ = creator(id);\r\n address creatorPayment_ = creatorPayment(creator_);\r\n\r\n // Initial setup if the token has not ever been minted \r\n // The token index encoded in token ID should be controlled by the authorizer\r\n if (_supply[id] == 0) {\r\n require(\r\n _verify(\r\n keccak256(abi.encodePacked(id, price, contentURI_, _chainId)), \r\n signature_,\r\n _platformAuthorizeAccount),\r\n ' AtemReview#mint: invalid signature of platform authorizer'\r\n );\r\n _totalCreations[creator_]++;\r\n _setContentURI(id, contentURI_);\r\n\r\n if (price != _price[id]){\r\n _setPrice(id, price);\r\n }\r\n emit PostCreated(creator_, id, to, price);\r\n } \r\n else {\r\n emit PostPurchased(creator_, id, _msgSender(), to, _price[id], amount);\r\n }\r\n\r\n uint256 totalPrice = _price[id] * amount;\r\n require(\r\n totalPrice == msg.value,\r\n \" AtemReview#mint: incorrect payment value\"\r\n );\r\n\r\n // Compute the platform fee\r\n uint256 platformFee = computePlatformFee(totalPrice);\r\n uint256 totalPriceDeductPlatformFee = totalPrice - platformFee;\r\n\r\n _supply[id] += amount;\r\n\r\n require(\r\n address(this).balance >= totalPriceDeductPlatformFee, \r\n \" AtemReview#mint: not enough balance\"\r\n );\r\n\r\n _withdraw(creatorPayment_, totalPriceDeductPlatformFee);\r\n _withdraw(_platformFeeAccount, platformFee);\r\n\r\n _mint(to, id, amount, \"\");\r\n }\r\n\r\n /**\r\n * @dev Mint a batch of token ids and set their prices. Everyone can do this, but need an authorized signature for id, price and contentURI.\r\n * The signatures, contentURIs and prices are only used for first-time minting.\r\n */\r\n function mintBatch(\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n uint256[] memory prices,\r\n string[] memory contentURIs,\r\n bytes[] memory signatures\r\n ) public payable nonReentrant()\r\n {\r\n require(\r\n (ids.length == amounts.length) && (ids.length == prices.length) && (ids.length == contentURIs.length) && (ids.length == signatures.length),\r\n \" AtemReview#mintBatch: parameters must have the same length\"\r\n );\r\n\r\n uint256 totalPrice = 0;\r\n uint256 totalPriceSingle = 0;\r\n uint256 platformFee = 0;\r\n uint256 platformFeeSingle = 0;\r\n address creator_ = address(0);\r\n uint256 currentPrice_ = 0;\r\n\r\n for (uint256 i = 0; i < ids.length; i++) {\r\n require(\r\n _supply[ids[i]] + amounts[i] <= ids[i].tokenMaxSupply(),\r\n \" AtemReview#mintBatch: some id(s) in this batch would exceed their total supply\"\r\n );\r\n\r\n creator_ = creator(ids[i]);\r\n currentPrice_ = _price[ids[i]];\r\n\r\n // Initial setup if the token has not ever been minted \r\n // The token indices encoded in token IDs should be controlled by the authorizer\r\n if (_supply[ids[i]] == 0) {\r\n require(\r\n _verify(\r\n keccak256(abi.encodePacked(ids[i], prices[i], contentURIs[i], _chainId)), \r\n signatures[i],\r\n _platformAuthorizeAccount),\r\n ' AtemReview#mintBatch: invalid signature of platform authorizer'\r\n );\r\n\r\n _totalCreations[creator_]++;\r\n _setContentURI(ids[i], contentURIs[i]);\r\n\r\n if (prices[i] != currentPrice_) {\r\n _setPrice(ids[i], prices[i]);\r\n currentPrice_ = prices[i];\r\n }\r\n emit PostCreated(_msgSender(), ids[i], to, currentPrice_);\r\n }\r\n else {\r\n emit PostPurchased(creator_, ids[i], _msgSender(), to, currentPrice_, amounts[i]);\r\n }\r\n\r\n // Compute the actual value\r\n totalPriceSingle = currentPrice_ * amounts[i];\r\n\r\n // Compute the platform fee\r\n platformFeeSingle = computePlatformFee(totalPriceSingle);\r\n\r\n _supply[ids[i]] += amounts[i];\r\n\r\n totalPrice += totalPriceSingle;\r\n platformFee += platformFeeSingle;\r\n\r\n _withdraw(creatorPayment(creator(ids[i])), totalPriceSingle - platformFeeSingle);\r\n\r\n }\r\n\r\n require(\r\n totalPrice == msg.value,\r\n \" AtemReview#purchaseBatch: incorrect payment value\"\r\n );\r\n\r\n _withdraw(_platformFeeAccount, platformFee);\r\n\r\n _mintBatch(to, ids, amounts, \"\");\r\n }\r\n\r\n\r\n /** --------------------------------------------\r\n * Token information related read-only functions\r\n * --------------------------------------------- */\r\n\r\n function tokenMaxSupply(\r\n uint256 id\r\n ) external pure returns (uint256)\r\n {\r\n return id.tokenMaxSupply();\r\n }\r\n\r\n function tokenIndex(\r\n uint256 id\r\n ) external pure returns (uint256)\r\n {\r\n return id.tokenIndex();\r\n }\r\n\r\n function tokenCreator(\r\n uint256 id\r\n ) external view returns (address)\r\n {\r\n return creator(id);\r\n }\r\n\r\n function tokenSupply(\r\n uint256 id\r\n ) external view returns (uint256)\r\n {\r\n return _supply[id];\r\n }\r\n\r\n function tokenPrice(\r\n uint256 id\r\n ) external view returns (uint256)\r\n {\r\n return _price[id];\r\n }\r\n\r\n function totalCreations(\r\n address addr\r\n ) external view returns (uint256)\r\n {\r\n return _totalCreations[addr];\r\n }\r\n\r\n /** --------------------------------------------\r\n * Fee related utility functions\r\n * --------------------------------------------- */\r\n\r\n function computePlatformFee(uint256 value)\r\n private view returns (uint256)\r\n {\r\n return (value * _platformFeeRatio) / 10000;\r\n }\r\n\r\n function platformFeeRatio() external view returns (uint256)\r\n {\r\n return _platformFeeRatio;\r\n }\r\n\r\n function platformFeeAccount() external view returns (address)\r\n {\r\n return _platformFeeAccount;\r\n }\r\n\r\n function platformAuthorizeAccount() external view returns (address)\r\n {\r\n return _platformAuthorizeAccount;\r\n }\r\n\r\n function chainId() external view returns (uint256)\r\n {\r\n return _chainId;\r\n }\r\n\r\n function setPlatformFeeRatio(uint256 value) external onlyOwner\r\n {\r\n _platformFeeRatio = value;\r\n }\r\n\r\n function setPlatformFeeAccount(address addr) external onlyOwner\r\n {\r\n _platformFeeAccount = addr;\r\n }\r\n\r\n function setPlatformAuthorizeAccount(address addr) external onlyOwner\r\n {\r\n _platformAuthorizeAccount = addr;\r\n }\r\n\r\n function setChainId(uint256 id) external onlyOwner\r\n {\r\n _chainId = id;\r\n }\r\n\r\n\r\n\r\n /** --------------------------------------------\r\n * Token URI related functions\r\n * --------------------------------------------- */\r\n function _setContentURI(uint256 id_, string memory contentURI_)\r\n private\r\n {\r\n _contentURIs[id_] = contentURI_;\r\n }\r\n\r\n function setbaseURI(string memory baseURI_) external onlyOwner {\r\n _setURI(baseURI_);\r\n }\r\n\r\n function setContentURI(uint256 id_, string memory contentURI_) external onlyOwner {\r\n _setContentURI(id_, contentURI_);\r\n }\r\n \r\n\r\n function contentURI(uint256 id) public view returns (string memory) {\r\n return _contentURIs[id];\r\n }\r\n\r\n function uri(uint256 id_) public view virtual override returns (string memory) {\r\n return string.concat(super.uri(id_), contentURI(id_));\r\n }\r\n\r\n\r\n \r\n\r\n /** --------------------------------------------\r\n * State setting functions\r\n * --------------------------------------------- */\r\n\r\n function pause() external onlyOwner {\r\n _pause();\r\n }\r\n\r\n function unpause() external onlyOwner {\r\n _unpause();\r\n }\r\n\r\n /** --------------------------------------------\r\n * Info setting functions\r\n * --------------------------------------------- */\r\n \r\n function setName(string memory name_) external onlyOwner {\r\n name = name_;\r\n }\r\n\r\n function setSymbol(string memory symbol_) external onlyOwner {\r\n symbol = symbol_;\r\n }\r\n\r\n}\r\n" } }, "settings": { "viaIR": true, "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } } }