{ "language": "Solidity", "sources": { "contracts/eip/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 \"./interface/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" }, "contracts/eip/interface/IERC1155.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n/**\n @title ERC-1155 Multi Token Standard\n @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md\n Note: The ERC-165 identifier for this interface is 0xd9b67a26.\n */\ninterface IERC1155 {\n /**\n @dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see \"Safe Transfer Rules\" section of the standard).\n The `_operator` argument MUST be msg.sender.\n The `_from` argument MUST be the address of the holder whose balance is decreased.\n The `_to` argument MUST be the address of the recipient whose balance is increased.\n The `_id` argument MUST be the token type being transferred.\n The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by.\n When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).\n When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).\n */\n event TransferSingle(\n address indexed _operator,\n address indexed _from,\n address indexed _to,\n uint256 _id,\n uint256 _value\n );\n\n /**\n @dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see \"Safe Transfer Rules\" section of the standard).\n The `_operator` argument MUST be msg.sender.\n The `_from` argument MUST be the address of the holder whose balance is decreased.\n The `_to` argument MUST be the address of the recipient whose balance is increased.\n The `_ids` argument MUST be the list of tokens being transferred.\n The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by.\n When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).\n When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).\n */\n event TransferBatch(\n address indexed _operator,\n address indexed _from,\n address indexed _to,\n uint256[] _ids,\n uint256[] _values\n );\n\n /**\n @dev MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absense of an event assumes disabled).\n */\n event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);\n\n /**\n @dev MUST emit when the URI is updated for a token ID.\n URIs are defined in RFC 3986.\n The URI MUST point a JSON file that conforms to the \"ERC-1155 Metadata URI JSON Schema\".\n */\n event URI(string _value, uint256 indexed _id);\n\n /**\n @notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call).\n @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see \"Approval\" section of the standard).\n MUST revert if `_to` is the zero address.\n MUST revert if balance of holder for token `_id` is lower than the `_value` sent.\n MUST revert on any other error.\n MUST emit the `TransferSingle` event to reflect the balance change (see \"Safe Transfer Rules\" section of the standard).\n After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see \"Safe Transfer Rules\" section of the standard).\n @param _from Source address\n @param _to Target address\n @param _id ID of the token type\n @param _value Transfer amount\n @param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to`\n */\n function safeTransferFrom(\n address _from,\n address _to,\n uint256 _id,\n uint256 _value,\n bytes calldata _data\n ) external;\n\n /**\n @notice Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call).\n @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see \"Approval\" section of the standard).\n MUST revert if `_to` is the zero address.\n MUST revert if length of `_ids` is not the same as length of `_values`.\n MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient.\n MUST revert on any other error.\n MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see \"Safe Transfer Rules\" section of the standard).\n Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).\n After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see \"Safe Transfer Rules\" section of the standard).\n @param _from Source address\n @param _to Target address\n @param _ids IDs of each token type (order and length must match _values array)\n @param _values Transfer amounts per token type (order and length must match _ids array)\n @param _data Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to`\n */\n function safeBatchTransferFrom(\n address _from,\n address _to,\n uint256[] calldata _ids,\n uint256[] calldata _values,\n bytes calldata _data\n ) external;\n\n /**\n @notice Get the balance of an account's Tokens.\n @param _owner The address of the token holder\n @param _id ID of the Token\n @return The _owner's balance of the Token type requested\n */\n function balanceOf(address _owner, uint256 _id) external view returns (uint256);\n\n /**\n @notice Get the balance of multiple account/token pairs\n @param _owners The addresses of the token holders\n @param _ids ID of the Tokens\n @return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair)\n */\n function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n @notice Enable or disable approval for a third party (\"operator\") to manage all of the caller's tokens.\n @dev MUST emit the ApprovalForAll event on success.\n @param _operator Address to add to the set of authorized operators\n @param _approved True if the operator is approved, false to revoke approval\n */\n function setApprovalForAll(address _operator, bool _approved) external;\n\n /**\n @notice Queries the approval status of an operator for a given owner.\n @param _owner The owner of the Tokens\n @param _operator Address of authorized operator\n @return True if the operator is approved, false if not\n */\n function isApprovedForAll(address _owner, address _operator) external view returns (bool);\n}\n" }, "contracts/eip/interface/IERC1155Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @dev Handles the receipt of a single ERC1155 token type. This function is\n * called at the end of a `safeTransferFrom` after the balance has been updated.\n *\n * NOTE: To accept the transfer, this must return\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n * (i.e. 0xf23a6e61, or its own function selector).\n *\n * @param operator The address which initiated the transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param id The ID of the token being transferred\n * @param value The amount of tokens being transferred\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\n * is called at the end of a `safeBatchTransferFrom` after the balances have\n * been updated.\n *\n * NOTE: To accept the transfer(s), this must return\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n * (i.e. 0xbc197c81, or its own function selector).\n *\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" }, "contracts/eip/interface/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 * [EIP](https://eips.ethereum.org/EIPS/eip-165).\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 * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\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" }, "contracts/eip/interface/IERC20.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n/**\n * @title ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/20\n */\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(\n address from,\n address to,\n uint256 value\n ) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" }, "contracts/eip/interface/IERC2981.sol": { "content": "// SPDX-License-Identifier: Apache 2.0\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be payed in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n" }, "contracts/eip/interface/IERC721.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" }, "contracts/eip/interface/IERC721Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" }, "contracts/extension/ContractMetadata.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./interface/IContractMetadata.sol\";\n\n/**\n * @title Contract Metadata\n * @notice Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI\n * for you contract.\n * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea.\n */\n\nabstract contract ContractMetadata is IContractMetadata {\n /// @notice Returns the contract metadata URI.\n string public override contractURI;\n\n /**\n * @notice Lets a contract admin set the URI for contract-level metadata.\n * @dev Caller should be authorized to setup contractURI, e.g. contract admin.\n * See {_canSetContractURI}.\n * Emits {ContractURIUpdated Event}.\n *\n * @param _uri keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n */\n function setContractURI(string memory _uri) external override {\n if (!_canSetContractURI()) {\n revert(\"Not authorized\");\n }\n\n _setupContractURI(_uri);\n }\n\n /// @dev Lets a contract admin set the URI for contract-level metadata.\n function _setupContractURI(string memory _uri) internal {\n string memory prevURI = contractURI;\n contractURI = _uri;\n\n emit ContractURIUpdated(prevURI, _uri);\n }\n\n /// @dev Returns whether contract metadata can be set in the given execution context.\n function _canSetContractURI() internal view virtual returns (bool);\n}\n" }, "contracts/extension/Ownable.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./interface/IOwnable.sol\";\n\n/**\n * @title Ownable\n * @notice Thirdweb's `Ownable` is a contract extension to be used with any base contract. It exposes functions for setting and reading\n * who the 'owner' of the inheriting smart contract is, and lets the inheriting contract perform conditional logic that uses\n * information about who the contract's owner is.\n */\n\nabstract contract Ownable is IOwnable {\n /// @dev Owner of the contract (purpose: OpenSea compatibility)\n address private _owner;\n\n /// @dev Reverts if caller is not the owner.\n modifier onlyOwner() {\n if (msg.sender != _owner) {\n revert(\"Not authorized\");\n }\n _;\n }\n\n /**\n * @notice Returns the owner of the contract.\n */\n function owner() public view override returns (address) {\n return _owner;\n }\n\n /**\n * @notice Lets an authorized wallet set a new owner for the contract.\n * @param _newOwner The address to set as the new owner of the contract.\n */\n function setOwner(address _newOwner) external override {\n if (!_canSetOwner()) {\n revert(\"Not authorized\");\n }\n _setupOwner(_newOwner);\n }\n\n /// @dev Lets a contract admin set a new owner for the contract. The new owner must be a contract admin.\n function _setupOwner(address _newOwner) internal {\n address _prevOwner = _owner;\n _owner = _newOwner;\n\n emit OwnerUpdated(_prevOwner, _newOwner);\n }\n\n /// @dev Returns whether owner can be set in the given execution context.\n function _canSetOwner() internal view virtual returns (bool);\n}\n" }, "contracts/extension/Permissions.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./interface/IPermissions.sol\";\nimport \"../lib/TWStrings.sol\";\n\n/**\n * @title Permissions\n * @dev This contracts provides extending-contracts with role-based access control mechanisms\n */\ncontract Permissions is IPermissions {\n /// @dev Map from keccak256 hash of a role => a map from address => whether address has role.\n mapping(bytes32 => mapping(address => bool)) private _hasRole;\n\n /// @dev Map from keccak256 hash of a role to role admin. See {getRoleAdmin}.\n mapping(bytes32 => bytes32) private _getRoleAdmin;\n\n /// @dev Default admin role for all roles. Only accounts with this role can grant/revoke other roles.\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @dev Modifier that checks if an account has the specified role; reverts otherwise.\n modifier onlyRole(bytes32 role) {\n _checkRole(role, msg.sender);\n _;\n }\n\n /**\n * @notice Checks whether an account has a particular role.\n * @dev Returns `true` if `account` has been granted `role`.\n *\n * @param role keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n * @param account Address of the account for which the role is being checked.\n */\n function hasRole(bytes32 role, address account) public view override returns (bool) {\n return _hasRole[role][account];\n }\n\n /**\n * @notice Checks whether an account has a particular role;\n * role restrictions can be swtiched on and off.\n *\n * @dev Returns `true` if `account` has been granted `role`.\n * Role restrictions can be swtiched on and off:\n * - If address(0) has ROLE, then the ROLE restrictions\n * don't apply.\n * - If address(0) does not have ROLE, then the ROLE\n * restrictions will apply.\n *\n * @param role keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n * @param account Address of the account for which the role is being checked.\n */\n function hasRoleWithSwitch(bytes32 role, address account) public view returns (bool) {\n if (!_hasRole[role][address(0)]) {\n return _hasRole[role][account];\n }\n\n return true;\n }\n\n /**\n * @notice Returns the admin role that controls the specified role.\n * @dev See {grantRole} and {revokeRole}.\n * To change a role's admin, use {_setRoleAdmin}.\n *\n * @param role keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n */\n function getRoleAdmin(bytes32 role) external view override returns (bytes32) {\n return _getRoleAdmin[role];\n }\n\n /**\n * @notice Grants a role to an account, if not previously granted.\n * @dev Caller must have admin role for the `role`.\n * Emits {RoleGranted Event}.\n *\n * @param role keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n * @param account Address of the account to which the role is being granted.\n */\n function grantRole(bytes32 role, address account) public virtual override {\n _checkRole(_getRoleAdmin[role], msg.sender);\n if (_hasRole[role][account]) {\n revert(\"Can only grant to non holders\");\n }\n _setupRole(role, account);\n }\n\n /**\n * @notice Revokes role from an account.\n * @dev Caller must have admin role for the `role`.\n * Emits {RoleRevoked Event}.\n *\n * @param role keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n * @param account Address of the account from which the role is being revoked.\n */\n function revokeRole(bytes32 role, address account) public virtual override {\n _checkRole(_getRoleAdmin[role], msg.sender);\n _revokeRole(role, account);\n }\n\n /**\n * @notice Revokes role from the account.\n * @dev Caller must have the `role`, with caller being the same as `account`.\n * Emits {RoleRevoked Event}.\n *\n * @param role keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n * @param account Address of the account from which the role is being revoked.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n if (msg.sender != account) {\n revert(\"Can only renounce for self\");\n }\n _revokeRole(role, account);\n }\n\n /// @dev Sets `adminRole` as `role`'s admin role.\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = _getRoleAdmin[role];\n _getRoleAdmin[role] = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /// @dev Sets up `role` for `account`\n function _setupRole(bytes32 role, address account) internal virtual {\n _hasRole[role][account] = true;\n emit RoleGranted(role, account, msg.sender);\n }\n\n /// @dev Revokes `role` from `account`\n function _revokeRole(bytes32 role, address account) internal virtual {\n _checkRole(role, account);\n delete _hasRole[role][account];\n emit RoleRevoked(role, account, msg.sender);\n }\n\n /// @dev Checks `role` for `account`. Reverts with a message including the required role.\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!_hasRole[role][account]) {\n revert(\n string(\n abi.encodePacked(\n \"Permissions: account \",\n TWStrings.toHexString(uint160(account), 20),\n \" is missing role \",\n TWStrings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /// @dev Checks `role` for `account`. Reverts with a message including the required role.\n function _checkRoleWithSwitch(bytes32 role, address account) internal view virtual {\n if (!hasRoleWithSwitch(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"Permissions: account \",\n TWStrings.toHexString(uint160(account), 20),\n \" is missing role \",\n TWStrings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n}\n" }, "contracts/extension/PermissionsEnumerable.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./interface/IPermissionsEnumerable.sol\";\nimport \"./Permissions.sol\";\n\n/**\n * @title PermissionsEnumerable\n * @dev This contracts provides extending-contracts with role-based access control mechanisms.\n * Also provides interfaces to view all members with a given role, and total count of members.\n */\ncontract PermissionsEnumerable is IPermissionsEnumerable, Permissions {\n /**\n * @notice A data structure to store data of members for a given role.\n *\n * @param index Current index in the list of accounts that have a role.\n * @param members map from index => address of account that has a role\n * @param indexOf map from address => index which the account has.\n */\n struct RoleMembers {\n uint256 index;\n mapping(uint256 => address) members;\n mapping(address => uint256) indexOf;\n }\n\n /// @dev map from keccak256 hash of a role to its members' data. See {RoleMembers}.\n mapping(bytes32 => RoleMembers) private roleMembers;\n\n /**\n * @notice Returns the role-member from a list of members for a role,\n * at a given index.\n * @dev Returns `member` who has `role`, at `index` of role-members list.\n * See struct {RoleMembers}, and mapping {roleMembers}\n *\n * @param role keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n * @param index Index in list of current members for the role.\n *\n * @return member Address of account that has `role`\n */\n function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) {\n uint256 currentIndex = roleMembers[role].index;\n uint256 check;\n\n for (uint256 i = 0; i < currentIndex; i += 1) {\n if (roleMembers[role].members[i] != address(0)) {\n if (check == index) {\n member = roleMembers[role].members[i];\n return member;\n }\n check += 1;\n } else if (hasRole(role, address(0)) && i == roleMembers[role].indexOf[address(0)]) {\n check += 1;\n }\n }\n }\n\n /**\n * @notice Returns total number of accounts that have a role.\n * @dev Returns `count` of accounts that have `role`.\n * See struct {RoleMembers}, and mapping {roleMembers}\n *\n * @param role keccak256 hash of the role. e.g. keccak256(\"TRANSFER_ROLE\")\n *\n * @return count Total number of accounts that have `role`\n */\n function getRoleMemberCount(bytes32 role) external view override returns (uint256 count) {\n uint256 currentIndex = roleMembers[role].index;\n\n for (uint256 i = 0; i < currentIndex; i += 1) {\n if (roleMembers[role].members[i] != address(0)) {\n count += 1;\n }\n }\n if (hasRole(role, address(0))) {\n count += 1;\n }\n }\n\n /// @dev Revokes `role` from `account`, and removes `account` from {roleMembers}\n /// See {_removeMember}\n function _revokeRole(bytes32 role, address account) internal override {\n super._revokeRole(role, account);\n _removeMember(role, account);\n }\n\n /// @dev Grants `role` to `account`, and adds `account` to {roleMembers}\n /// See {_addMember}\n function _setupRole(bytes32 role, address account) internal override {\n super._setupRole(role, account);\n _addMember(role, account);\n }\n\n /// @dev adds `account` to {roleMembers}, for `role`\n function _addMember(bytes32 role, address account) internal {\n uint256 idx = roleMembers[role].index;\n roleMembers[role].index += 1;\n\n roleMembers[role].members[idx] = account;\n roleMembers[role].indexOf[account] = idx;\n }\n\n /// @dev removes `account` from {roleMembers}, for `role`\n function _removeMember(bytes32 role, address account) internal {\n uint256 idx = roleMembers[role].indexOf[account];\n\n delete roleMembers[role].members[idx];\n delete roleMembers[role].indexOf[account];\n }\n}\n" }, "contracts/extension/Royalty.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./interface/IRoyalty.sol\";\n\n/**\n * @title Royalty\n * @notice Thirdweb's `Royalty` is a contract extension to be used with any base contract. It exposes functions for setting and reading\n * the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic\n * that uses information about royalty fees, if desired.\n *\n * @dev The `Royalty` contract is ERC2981 compliant.\n */\n\nabstract contract Royalty is IRoyalty {\n /// @dev The (default) address that receives all royalty value.\n address private royaltyRecipient;\n\n /// @dev The (default) % of a sale to take as royalty (in basis points).\n uint16 private royaltyBps;\n\n /// @dev Token ID => royalty recipient and bps for token\n mapping(uint256 => RoyaltyInfo) private royaltyInfoForToken;\n\n /**\n * @notice View royalty info for a given token and sale price.\n * @dev Returns royalty amount and recipient for `tokenId` and `salePrice`.\n * @param tokenId The tokenID of the NFT for which to query royalty info.\n * @param salePrice Sale price of the token.\n *\n * @return receiver Address of royalty recipient account.\n * @return royaltyAmount Royalty amount calculated at current royaltyBps value.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n virtual\n override\n returns (address receiver, uint256 royaltyAmount)\n {\n (address recipient, uint256 bps) = getRoyaltyInfoForToken(tokenId);\n receiver = recipient;\n royaltyAmount = (salePrice * bps) / 10_000;\n }\n\n /**\n * @notice View royalty info for a given token.\n * @dev Returns royalty recipient and bps for `_tokenId`.\n * @param _tokenId The tokenID of the NFT for which to query royalty info.\n */\n function getRoyaltyInfoForToken(uint256 _tokenId) public view override returns (address, uint16) {\n RoyaltyInfo memory royaltyForToken = royaltyInfoForToken[_tokenId];\n\n return\n royaltyForToken.recipient == address(0)\n ? (royaltyRecipient, uint16(royaltyBps))\n : (royaltyForToken.recipient, uint16(royaltyForToken.bps));\n }\n\n /**\n * @notice Returns the defualt royalty recipient and BPS for this contract's NFTs.\n */\n function getDefaultRoyaltyInfo() external view override returns (address, uint16) {\n return (royaltyRecipient, uint16(royaltyBps));\n }\n\n /**\n * @notice Updates default royalty recipient and bps.\n * @dev Caller should be authorized to set royalty info.\n * See {_canSetRoyaltyInfo}.\n * Emits {DefaultRoyalty Event}; See {_setupDefaultRoyaltyInfo}.\n *\n * @param _royaltyRecipient Address to be set as default royalty recipient.\n * @param _royaltyBps Updated royalty bps.\n */\n function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external override {\n if (!_canSetRoyaltyInfo()) {\n revert(\"Not authorized\");\n }\n\n _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);\n }\n\n /// @dev Lets a contract admin update the default royalty recipient and bps.\n function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal {\n if (_royaltyBps > 10_000) {\n revert(\"Exceeds max bps\");\n }\n\n royaltyRecipient = _royaltyRecipient;\n royaltyBps = uint16(_royaltyBps);\n\n emit DefaultRoyalty(_royaltyRecipient, _royaltyBps);\n }\n\n /**\n * @notice Updates default royalty recipient and bps for a particular token.\n * @dev Sets royalty info for `_tokenId`. Caller should be authorized to set royalty info.\n * See {_canSetRoyaltyInfo}.\n * Emits {RoyaltyForToken Event}; See {_setupRoyaltyInfoForToken}.\n *\n * @param _recipient Address to be set as royalty recipient for given token Id.\n * @param _bps Updated royalty bps for the token Id.\n */\n function setRoyaltyInfoForToken(\n uint256 _tokenId,\n address _recipient,\n uint256 _bps\n ) external override {\n if (!_canSetRoyaltyInfo()) {\n revert(\"Not authorized\");\n }\n\n _setupRoyaltyInfoForToken(_tokenId, _recipient, _bps);\n }\n\n /// @dev Lets a contract admin set the royalty recipient and bps for a particular token Id.\n function _setupRoyaltyInfoForToken(\n uint256 _tokenId,\n address _recipient,\n uint256 _bps\n ) internal {\n if (_bps > 10_000) {\n revert(\"Exceeds max bps\");\n }\n\n royaltyInfoForToken[_tokenId] = RoyaltyInfo({ recipient: _recipient, bps: _bps });\n\n emit RoyaltyForToken(_tokenId, _recipient, _bps);\n }\n\n /// @dev Returns whether royalty info can be set in the given execution context.\n function _canSetRoyaltyInfo() internal view virtual returns (bool);\n}\n" }, "contracts/extension/TokenBundle.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./interface/ITokenBundle.sol\";\nimport \"../lib/CurrencyTransferLib.sol\";\n\ninterface IERC165 {\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n/**\n * @title Token Bundle\n * @notice `TokenBundle` contract extension allows bundling-up of ERC20/ERC721/ERC1155 and native-tokan assets\n * in a data structure, and provides logic for setting/getting IDs and URIs for created bundles.\n * @dev See {ITokenBundle}\n */\n\nabstract contract TokenBundle is ITokenBundle {\n /// @dev Mapping from bundle UID => bundle info.\n mapping(uint256 => BundleInfo) private bundle;\n\n /// @dev Returns the total number of assets in a particular bundle.\n function getTokenCountOfBundle(uint256 _bundleId) public view returns (uint256) {\n return bundle[_bundleId].count;\n }\n\n /// @dev Returns an asset contained in a particular bundle, at a particular index.\n function getTokenOfBundle(uint256 _bundleId, uint256 index) public view returns (Token memory) {\n return bundle[_bundleId].tokens[index];\n }\n\n /// @dev Returns the uri of a particular bundle.\n function getUriOfBundle(uint256 _bundleId) public view returns (string memory) {\n return bundle[_bundleId].uri;\n }\n\n /// @dev Lets the calling contract create a bundle, by passing in a list of tokens and a unique id.\n function _createBundle(Token[] calldata _tokensToBind, uint256 _bundleId) internal {\n uint256 targetCount = _tokensToBind.length;\n\n require(targetCount > 0, \"!Tokens\");\n require(bundle[_bundleId].count == 0, \"id exists\");\n\n for (uint256 i = 0; i < targetCount; i += 1) {\n _checkTokenType(_tokensToBind[i]);\n bundle[_bundleId].tokens[i] = _tokensToBind[i];\n }\n\n bundle[_bundleId].count = targetCount;\n }\n\n /// @dev Lets the calling contract update a bundle, by passing in a list of tokens and a unique id.\n function _updateBundle(Token[] memory _tokensToBind, uint256 _bundleId) internal {\n require(_tokensToBind.length > 0, \"!Tokens\");\n\n uint256 currentCount = bundle[_bundleId].count;\n uint256 targetCount = _tokensToBind.length;\n uint256 check = currentCount > targetCount ? currentCount : targetCount;\n\n for (uint256 i = 0; i < check; i += 1) {\n if (i < targetCount) {\n _checkTokenType(_tokensToBind[i]);\n bundle[_bundleId].tokens[i] = _tokensToBind[i];\n } else if (i < currentCount) {\n delete bundle[_bundleId].tokens[i];\n }\n }\n\n bundle[_bundleId].count = targetCount;\n }\n\n /// @dev Lets the calling contract add a token to a bundle for a unique bundle id and index.\n function _addTokenInBundle(Token memory _tokenToBind, uint256 _bundleId) internal {\n _checkTokenType(_tokenToBind);\n uint256 id = bundle[_bundleId].count;\n\n bundle[_bundleId].tokens[id] = _tokenToBind;\n bundle[_bundleId].count += 1;\n }\n\n /// @dev Lets the calling contract update a token in a bundle for a unique bundle id and index.\n function _updateTokenInBundle(\n Token memory _tokenToBind,\n uint256 _bundleId,\n uint256 _index\n ) internal {\n require(_index < bundle[_bundleId].count, \"index DNE\");\n _checkTokenType(_tokenToBind);\n bundle[_bundleId].tokens[_index] = _tokenToBind;\n }\n\n /// @dev Checks if the type of asset-contract is same as the TokenType specified.\n function _checkTokenType(Token memory _token) internal view {\n if (_token.tokenType == TokenType.ERC721) {\n try IERC165(_token.assetContract).supportsInterface(0x80ac58cd) returns (bool supported721) {\n require(supported721, \"!TokenType\");\n } catch {\n revert(\"!TokenType\");\n }\n } else if (_token.tokenType == TokenType.ERC1155) {\n try IERC165(_token.assetContract).supportsInterface(0xd9b67a26) returns (bool supported1155) {\n require(supported1155, \"!TokenType\");\n } catch {\n revert(\"!TokenType\");\n }\n } else if (_token.tokenType == TokenType.ERC20) {\n if (_token.assetContract != CurrencyTransferLib.NATIVE_TOKEN) {\n // 0x36372b07\n try IERC165(_token.assetContract).supportsInterface(0x80ac58cd) returns (bool supported721) {\n require(!supported721, \"!TokenType\");\n\n try IERC165(_token.assetContract).supportsInterface(0xd9b67a26) returns (bool supported1155) {\n require(!supported1155, \"!TokenType\");\n } catch Error(string memory) {} catch {}\n } catch Error(string memory) {} catch {}\n }\n }\n }\n\n /// @dev Lets the calling contract set/update the uri of a particular bundle.\n function _setUriOfBundle(string memory _uri, uint256 _bundleId) internal {\n bundle[_bundleId].uri = _uri;\n }\n\n /// @dev Lets the calling contract delete a particular bundle.\n function _deleteBundle(uint256 _bundleId) internal {\n for (uint256 i = 0; i < bundle[_bundleId].count; i += 1) {\n delete bundle[_bundleId].tokens[i];\n }\n bundle[_bundleId].count = 0;\n }\n}\n" }, "contracts/extension/TokenStore.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n// ========== External imports ==========\n\nimport \"../eip/interface/IERC1155.sol\";\nimport \"../eip/interface/IERC721.sol\";\n\nimport \"../openzeppelin-presets/utils/ERC1155/ERC1155Holder.sol\";\nimport \"../openzeppelin-presets/utils/ERC721/ERC721Holder.sol\";\n\n// ========== Internal imports ==========\n\nimport { TokenBundle, ITokenBundle } from \"./TokenBundle.sol\";\nimport \"../lib/CurrencyTransferLib.sol\";\n\n/**\n * @title Token Store\n * @notice `TokenStore` contract extension allows bundling-up of ERC20/ERC721/ERC1155 and native-tokan assets\n * and provides logic for storing, releasing, and transferring them from the extending contract.\n * @dev See {CurrencyTransferLib}\n */\n\ncontract TokenStore is TokenBundle, ERC721Holder, ERC1155Holder {\n /// @dev The address of the native token wrapper contract.\n address internal immutable nativeTokenWrapper;\n\n constructor(address _nativeTokenWrapper) {\n nativeTokenWrapper = _nativeTokenWrapper;\n }\n\n /// @dev Store / escrow multiple ERC1155, ERC721, ERC20 tokens.\n function _storeTokens(\n address _tokenOwner,\n Token[] calldata _tokens,\n string memory _uriForTokens,\n uint256 _idForTokens\n ) internal {\n _createBundle(_tokens, _idForTokens);\n _setUriOfBundle(_uriForTokens, _idForTokens);\n _transferTokenBatch(_tokenOwner, address(this), _tokens);\n }\n\n /// @dev Release stored / escrowed ERC1155, ERC721, ERC20 tokens.\n function _releaseTokens(address _recipient, uint256 _idForContent) internal {\n uint256 count = getTokenCountOfBundle(_idForContent);\n Token[] memory tokensToRelease = new Token[](count);\n\n for (uint256 i = 0; i < count; i += 1) {\n tokensToRelease[i] = getTokenOfBundle(_idForContent, i);\n }\n\n _deleteBundle(_idForContent);\n\n _transferTokenBatch(address(this), _recipient, tokensToRelease);\n }\n\n /// @dev Transfers an arbitrary ERC20 / ERC721 / ERC1155 token.\n function _transferToken(\n address _from,\n address _to,\n Token memory _token\n ) internal {\n if (_token.tokenType == TokenType.ERC20) {\n CurrencyTransferLib.transferCurrencyWithWrapper(\n _token.assetContract,\n _from,\n _to,\n _token.totalAmount,\n nativeTokenWrapper\n );\n } else if (_token.tokenType == TokenType.ERC721) {\n IERC721(_token.assetContract).safeTransferFrom(_from, _to, _token.tokenId);\n } else if (_token.tokenType == TokenType.ERC1155) {\n IERC1155(_token.assetContract).safeTransferFrom(_from, _to, _token.tokenId, _token.totalAmount, \"\");\n }\n }\n\n /// @dev Transfers multiple arbitrary ERC20 / ERC721 / ERC1155 tokens.\n function _transferTokenBatch(\n address _from,\n address _to,\n Token[] memory _tokens\n ) internal {\n uint256 nativeTokenValue;\n for (uint256 i = 0; i < _tokens.length; i += 1) {\n if (_tokens[i].assetContract == CurrencyTransferLib.NATIVE_TOKEN && _to == address(this)) {\n nativeTokenValue += _tokens[i].totalAmount;\n } else {\n _transferToken(_from, _to, _tokens[i]);\n }\n }\n if (nativeTokenValue != 0) {\n Token memory _nativeToken = Token({\n assetContract: CurrencyTransferLib.NATIVE_TOKEN,\n tokenType: ITokenBundle.TokenType.ERC20,\n tokenId: 0,\n totalAmount: nativeTokenValue\n });\n _transferToken(_from, _to, _nativeToken);\n }\n }\n}\n" }, "contracts/extension/interface/IContractMetadata.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n/**\n * Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI\n * for you contract.\n *\n * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea.\n */\n\ninterface IContractMetadata {\n /// @dev Returns the metadata URI of the contract.\n function contractURI() external view returns (string memory);\n\n /**\n * @dev Sets contract URI for the storefront-level metadata of the contract.\n * Only module admin can call this function.\n */\n function setContractURI(string calldata _uri) external;\n\n /// @dev Emitted when the contract URI is updated.\n event ContractURIUpdated(string prevURI, string newURI);\n}\n" }, "contracts/extension/interface/IOwnable.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n/**\n * Thirdweb's `Ownable` is a contract extension to be used with any base contract. It exposes functions for setting and reading\n * who the 'owner' of the inheriting smart contract is, and lets the inheriting contract perform conditional logic that uses\n * information about who the contract's owner is.\n */\n\ninterface IOwnable {\n /// @dev Returns the owner of the contract.\n function owner() external view returns (address);\n\n /// @dev Lets a module admin set a new owner for the contract. The new owner must be a module admin.\n function setOwner(address _newOwner) external;\n\n /// @dev Emitted when a new Owner is set.\n event OwnerUpdated(address indexed prevOwner, address indexed newOwner);\n}\n" }, "contracts/extension/interface/IPermissions.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IPermissions {\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" }, "contracts/extension/interface/IPermissionsEnumerable.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"./IPermissions.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IPermissionsEnumerable is IPermissions {\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 * [forum post](https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296)\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" }, "contracts/extension/interface/IRoyalty.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\nimport \"../../eip/interface/IERC2981.sol\";\n\n/**\n * Thirdweb's `Royalty` is a contract extension to be used with any base contract. It exposes functions for setting and reading\n * the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic\n * that uses information about royalty fees, if desired.\n *\n * The `Royalty` contract is ERC2981 compliant.\n */\n\ninterface IRoyalty is IERC2981 {\n struct RoyaltyInfo {\n address recipient;\n uint256 bps;\n }\n\n /// @dev Returns the royalty recipient and fee bps.\n function getDefaultRoyaltyInfo() external view returns (address, uint16);\n\n /// @dev Lets a module admin update the royalty bps and recipient.\n function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external;\n\n /// @dev Lets a module admin set the royalty recipient for a particular token Id.\n function setRoyaltyInfoForToken(\n uint256 tokenId,\n address recipient,\n uint256 bps\n ) external;\n\n /// @dev Returns the royalty recipient for a particular token Id.\n function getRoyaltyInfoForToken(uint256 tokenId) external view returns (address, uint16);\n\n /// @dev Emitted when royalty info is updated.\n event DefaultRoyalty(address indexed newRoyaltyRecipient, uint256 newRoyaltyBps);\n\n /// @dev Emitted when royalty recipient for tokenId is set\n event RoyaltyForToken(uint256 indexed tokenId, address indexed royaltyRecipient, uint256 royaltyBps);\n}\n" }, "contracts/extension/interface/ITokenBundle.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n/**\n * Group together arbitrary ERC20, ERC721 and ERC1155 tokens into a single bundle.\n *\n * The `Token` struct is a generic type that can describe any ERC20, ERC721 or ERC1155 token.\n * The `Bundle` struct is a data structure to track a group/bundle of multiple assets i.e. ERC20,\n * ERC721 and ERC1155 tokens, each described as a `Token`.\n *\n * Expressing tokens as the `Token` type, and grouping them as a `Bundle` allows for writing generic\n * logic to handle any ERC20, ERC721 or ERC1155 tokens.\n */\n\ninterface ITokenBundle {\n /// @notice The type of assets that can be wrapped.\n enum TokenType {\n ERC20,\n ERC721,\n ERC1155\n }\n\n /**\n * @notice A generic interface to describe any ERC20, ERC721 or ERC1155 token.\n *\n * @param assetContract The contract address of the asset.\n * @param tokenType The token type (ERC20 / ERC721 / ERC1155) of the asset.\n * @param tokenId The token Id of the asset, if the asset is an ERC721 / ERC1155 NFT.\n * @param totalAmount The amount of the asset, if the asset is an ERC20 / ERC1155 fungible token.\n */\n struct Token {\n address assetContract;\n TokenType tokenType;\n uint256 tokenId;\n uint256 totalAmount;\n }\n\n /**\n * @notice An internal data structure to track a group / bundle of multiple assets i.e. `Token`s.\n *\n * @param count The total number of assets i.e. `Token` in a bundle.\n * @param uri The (metadata) URI assigned to the bundle created\n * @param tokens Mapping from a UID -> to a unique asset i.e. `Token` in the bundle.\n */\n struct BundleInfo {\n uint256 count;\n string uri;\n mapping(uint256 => Token) tokens;\n }\n}\n" }, "contracts/interfaces/IPack.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.11;\n\nimport \"../extension/interface/ITokenBundle.sol\";\n\n/**\n * The thirdweb `Pack` contract is a lootbox mechanism. An account can bundle up arbitrary ERC20, ERC721 and ERC1155 tokens into\n * a set of packs. A pack can then be opened in return for a selection of the tokens in the pack. The selection of tokens distributed\n * on opening a pack depends on the relative supply of all tokens in the packs.\n */\n\ninterface IPack is ITokenBundle {\n /**\n * @notice All info relevant to packs.\n *\n * @param perUnitAmounts Mapping from a UID -> to the per-unit amount of that asset i.e. `Token` at that index.\n * @param openStartTimestamp The timestamp after which packs can be opened.\n * @param amountDistributedPerOpen The number of reward units distributed per open.\n */\n struct PackInfo {\n uint256[] perUnitAmounts;\n uint128 openStartTimestamp;\n uint128 amountDistributedPerOpen;\n }\n\n /// @notice Emitted when a set of packs is created.\n event PackCreated(uint256 indexed packId, address recipient, uint256 totalPacksCreated);\n\n /// @notice Emitted when more packs are minted for a packId.\n event PackUpdated(uint256 indexed packId, address recipient, uint256 totalPacksCreated);\n\n /// @notice Emitted when a pack is opened.\n event PackOpened(\n uint256 indexed packId,\n address indexed opener,\n uint256 numOfPacksOpened,\n Token[] rewardUnitsDistributed\n );\n\n /**\n * @notice Creates a pack with the stated contents.\n *\n * @param contents The reward units to pack in the packs.\n * @param numOfRewardUnits The number of reward units to create, for each asset specified in `contents`.\n * @param packUri The (metadata) URI assigned to the packs created.\n * @param openStartTimestamp The timestamp after which packs can be opened.\n * @param amountDistributedPerOpen The number of reward units distributed per open.\n * @param recipient The recipient of the packs created.\n *\n * @return packId The unique identifer of the created set of packs.\n * @return packTotalSupply The total number of packs created.\n */\n function createPack(\n Token[] calldata contents,\n uint256[] calldata numOfRewardUnits,\n string calldata packUri,\n uint128 openStartTimestamp,\n uint128 amountDistributedPerOpen,\n address recipient\n ) external payable returns (uint256 packId, uint256 packTotalSupply);\n\n /**\n * @notice Lets a pack owner open a pack and receive the pack's reward unit.\n *\n * @param packId The identifier of the pack to open.\n * @param amountToOpen The number of packs to open at once.\n */\n function openPack(uint256 packId, uint256 amountToOpen) external returns (Token[] memory);\n}\n" }, "contracts/interfaces/IWETH.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\ninterface IWETH {\n function deposit() external payable;\n\n function withdraw(uint256 amount) external;\n\n function transfer(address to, uint256 value) external returns (bool);\n}\n" }, "contracts/lib/CurrencyTransferLib.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.0;\n\n// Helper interfaces\nimport { IWETH } from \"../interfaces/IWETH.sol\";\n\nimport \"../openzeppelin-presets/token/ERC20/utils/SafeERC20.sol\";\n\nlibrary CurrencyTransferLib {\n using SafeERC20 for IERC20;\n\n /// @dev The address interpreted as native token of the chain.\n address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n /// @dev Transfers a given amount of currency.\n function transferCurrency(\n address _currency,\n address _from,\n address _to,\n uint256 _amount\n ) internal {\n if (_amount == 0) {\n return;\n }\n\n if (_currency == NATIVE_TOKEN) {\n safeTransferNativeToken(_to, _amount);\n } else {\n safeTransferERC20(_currency, _from, _to, _amount);\n }\n }\n\n /// @dev Transfers a given amount of currency. (With native token wrapping)\n function transferCurrencyWithWrapper(\n address _currency,\n address _from,\n address _to,\n uint256 _amount,\n address _nativeTokenWrapper\n ) internal {\n if (_amount == 0) {\n return;\n }\n\n if (_currency == NATIVE_TOKEN) {\n if (_from == address(this)) {\n // withdraw from weth then transfer withdrawn native token to recipient\n IWETH(_nativeTokenWrapper).withdraw(_amount);\n safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);\n } else if (_to == address(this)) {\n // store native currency in weth\n require(_amount == msg.value, \"msg.value != amount\");\n IWETH(_nativeTokenWrapper).deposit{ value: _amount }();\n } else {\n safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);\n }\n } else {\n safeTransferERC20(_currency, _from, _to, _amount);\n }\n }\n\n /// @dev Transfer `amount` of ERC20 token from `from` to `to`.\n function safeTransferERC20(\n address _currency,\n address _from,\n address _to,\n uint256 _amount\n ) internal {\n if (_from == _to) {\n return;\n }\n\n if (_from == address(this)) {\n IERC20(_currency).safeTransfer(_to, _amount);\n } else {\n IERC20(_currency).safeTransferFrom(_from, _to, _amount);\n }\n }\n\n /// @dev Transfers `amount` of native token to `to`.\n function safeTransferNativeToken(address to, uint256 value) internal {\n // solhint-disable avoid-low-level-calls\n // slither-disable-next-line low-level-calls\n (bool success, ) = to.call{ value: value }(\"\");\n require(success, \"native token transfer failed\");\n }\n\n /// @dev Transfers `amount` of native token to `to`. (With native token wrapping)\n function safeTransferNativeTokenWithWrapper(\n address to,\n uint256 value,\n address _nativeTokenWrapper\n ) internal {\n // solhint-disable avoid-low-level-calls\n // slither-disable-next-line low-level-calls\n (bool success, ) = to.call{ value: value }(\"\");\n if (!success) {\n IWETH(_nativeTokenWrapper).deposit{ value: value }();\n IERC20(_nativeTokenWrapper).safeTransfer(to, value);\n }\n }\n}\n" }, "contracts/lib/TWAddress.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary TWAddress {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * [EIP1884](https://eips.ethereum.org/EIPS/eip-1884) increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" }, "contracts/lib/TWStrings.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary TWStrings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" }, "contracts/openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.0 (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.11;\n\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771ContextUpgradeable is Initializable, ContextUpgradeable {\n mapping(address => bool) private _trustedForwarder;\n\n function __ERC2771Context_init(address[] memory trustedForwarder) internal onlyInitializing {\n __Context_init_unchained();\n __ERC2771Context_init_unchained(trustedForwarder);\n }\n\n function __ERC2771Context_init_unchained(address[] memory trustedForwarder) internal onlyInitializing {\n for (uint256 i = 0; i < trustedForwarder.length; i++) {\n _trustedForwarder[trustedForwarder[i]] = true;\n }\n }\n\n function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n return _trustedForwarder[forwarder];\n }\n\n function _msgSender() internal view virtual override returns (address sender) {\n if (isTrustedForwarder(msg.sender)) {\n // The assembly code is more direct than the Solidity version using `abi.decode`.\n assembly {\n sender := shr(96, calldataload(sub(calldatasize(), 20)))\n }\n } else {\n return super._msgSender();\n }\n }\n\n function _msgData() internal view virtual override returns (bytes calldata) {\n if (isTrustedForwarder(msg.sender)) {\n return msg.data[:msg.data.length - 20];\n } else {\n return super._msgData();\n }\n }\n\n uint256[49] private __gap;\n}\n" }, "contracts/openzeppelin-presets/token/ERC20/utils/SafeERC20.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../../../eip/interface/IERC20.sol\";\nimport \"../../../../lib/TWAddress.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using TWAddress for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" }, "contracts/openzeppelin-presets/utils/ERC1155/ERC1155Holder.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ERC1155Receiver.sol\";\n\n/**\n * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.\n *\n * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be\n * stuck.\n *\n * @dev _Available since v3.1._\n */\ncontract ERC1155Holder is ERC1155Receiver {\n function onERC1155Received(\n address,\n address,\n uint256,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC1155Received.selector;\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] memory,\n uint256[] memory,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC1155BatchReceived.selector;\n }\n}\n" }, "contracts/openzeppelin-presets/utils/ERC1155/ERC1155Receiver.sol": { "content": "// SPDX-License-Identifier: Apache 2.0\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../../eip/interface/IERC1155Receiver.sol\";\nimport \"../../../eip/ERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155Receiver is ERC165, IERC1155Receiver {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n}\n" }, "contracts/openzeppelin-presets/utils/ERC721/ERC721Holder.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../../eip/interface/IERC721Receiver.sol\";\n\n/**\n * @dev Implementation of the {IERC721Receiver} interface.\n *\n * Accepts all token transfers.\n * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.\n */\ncontract ERC721Holder is IERC721Receiver {\n /**\n * @dev See {IERC721Receiver-onERC721Received}.\n *\n * Always returns `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address,\n address,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC721Received.selector;\n }\n}\n" }, "contracts/pack/Pack.sol": { "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.11;\n\n// ========== External imports ==========\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC721Receiver.sol\";\nimport { IERC1155Receiver } from \"@openzeppelin/contracts/interfaces/IERC1155Receiver.sol\";\n\n// ========== Internal imports ==========\n\nimport \"../interfaces/IPack.sol\";\nimport \"../openzeppelin-presets/metatx/ERC2771ContextUpgradeable.sol\";\n\n// ========== Features ==========\n\nimport \"../extension/ContractMetadata.sol\";\nimport \"../extension/Royalty.sol\";\nimport \"../extension/Ownable.sol\";\nimport \"../extension/PermissionsEnumerable.sol\";\nimport { TokenStore, ERC1155Receiver } from \"../extension/TokenStore.sol\";\n\ncontract Pack is\n Initializable,\n ContractMetadata,\n Ownable,\n Royalty,\n PermissionsEnumerable,\n TokenStore,\n ReentrancyGuardUpgradeable,\n ERC2771ContextUpgradeable,\n MulticallUpgradeable,\n ERC1155Upgradeable,\n IPack\n{\n /*///////////////////////////////////////////////////////////////\n State variables\n //////////////////////////////////////////////////////////////*/\n\n bytes32 private constant MODULE_TYPE = bytes32(\"Pack\");\n uint256 private constant VERSION = 2;\n\n address private immutable forwarder;\n\n // Token name\n string public name;\n\n // Token symbol\n string public symbol;\n\n /// @dev Only transfers to or from TRANSFER_ROLE holders are valid, when transfers are restricted.\n bytes32 private transferRole;\n\n /// @dev Only MINTER_ROLE holders can create packs.\n bytes32 private minterRole;\n\n /// @dev Only assets with ASSET_ROLE can be packed, when packing is restricted to particular assets.\n bytes32 private assetRole;\n\n /// @dev The token Id of the next set of packs to be minted.\n uint256 public nextTokenIdToMint;\n\n /*///////////////////////////////////////////////////////////////\n Mappings\n //////////////////////////////////////////////////////////////*/\n\n /// @dev Mapping from token ID => total circulating supply of token with that ID.\n mapping(uint256 => uint256) public totalSupply;\n\n /// @dev Mapping from pack ID => The state of that set of packs.\n mapping(uint256 => PackInfo) private packInfo;\n\n /// @dev Checks if pack-creator allowed to add more tokens to a packId; set to false after first transfer\n mapping(uint256 => bool) public canUpdatePack;\n\n /*///////////////////////////////////////////////////////////////\n Constructor + initializer logic\n //////////////////////////////////////////////////////////////*/\n\n constructor(address _nativeTokenWrapper, address _trustedForwarder) TokenStore(_nativeTokenWrapper) initializer {\n forwarder = _trustedForwarder;\n }\n\n /// @dev Initiliazes the contract, like a constructor.\n function initialize(\n address _defaultAdmin,\n string memory _name,\n string memory _symbol,\n string memory _contractURI,\n address[] memory _trustedForwarders,\n address _royaltyRecipient,\n uint256 _royaltyBps\n ) external initializer {\n bytes32 _transferRole = keccak256(\"TRANSFER_ROLE\");\n bytes32 _minterRole = keccak256(\"MINTER_ROLE\");\n bytes32 _assetRole = keccak256(\"ASSET_ROLE\");\n // Initialize inherited contracts, most base-like -> most derived.\n __ReentrancyGuard_init();\n\n /** note: The immutable state-variable `forwarder` is an EOA-only forwarder,\n * which guards against automated attacks.\n *\n * Use other forwarders only if there's a strong reason to bypass this check.\n */\n address[] memory forwarders = new address[](_trustedForwarders.length + 1);\n uint256 i;\n for (; i < _trustedForwarders.length; i++) {\n forwarders[i] = _trustedForwarders[i];\n }\n forwarders[i] = forwarder;\n __ERC2771Context_init(forwarders);\n __ERC1155_init(_contractURI);\n\n name = _name;\n symbol = _symbol;\n\n _setupContractURI(_contractURI);\n _setupOwner(_defaultAdmin);\n _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);\n\n _setupRole(_transferRole, _defaultAdmin);\n _setupRole(_minterRole, _defaultAdmin);\n _setupRole(_transferRole, address(0));\n\n // note: see `onlyRoleWithSwitch` for ASSET_ROLE behaviour.\n _setupRole(_assetRole, address(0));\n\n _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);\n\n transferRole = _transferRole;\n minterRole = _minterRole;\n assetRole = _assetRole;\n }\n\n receive() external payable {\n require(msg.sender == nativeTokenWrapper, \"!nativeTokenWrapper.\");\n }\n\n /*///////////////////////////////////////////////////////////////\n Modifiers\n //////////////////////////////////////////////////////////////*/\n\n modifier onlyRoleWithSwitch(bytes32 role) {\n _checkRoleWithSwitch(role, _msgSender());\n _;\n }\n\n /*///////////////////////////////////////////////////////////////\n Generic contract logic\n //////////////////////////////////////////////////////////////*/\n\n /// @dev Returns the type of the contract.\n function contractType() external pure returns (bytes32) {\n return MODULE_TYPE;\n }\n\n /// @dev Returns the version of the contract.\n function contractVersion() external pure returns (uint8) {\n return uint8(VERSION);\n }\n\n /*///////////////////////////////////////////////////////////////\n ERC 165 / 1155 / 2981 logic\n //////////////////////////////////////////////////////////////*/\n\n /// @dev Returns the URI for a given tokenId.\n function uri(uint256 _tokenId) public view override returns (string memory) {\n return getUriOfBundle(_tokenId);\n }\n\n /// @dev See ERC 165\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC1155Receiver, ERC1155Upgradeable, IERC165)\n returns (bool)\n {\n return\n super.supportsInterface(interfaceId) ||\n type(IERC2981Upgradeable).interfaceId == interfaceId ||\n type(IERC721Receiver).interfaceId == interfaceId ||\n type(IERC1155Receiver).interfaceId == interfaceId;\n }\n\n /*///////////////////////////////////////////////////////////////\n Pack logic: create | open packs.\n //////////////////////////////////////////////////////////////*/\n\n /// @dev Creates a pack with the stated contents.\n function createPack(\n Token[] calldata _contents,\n uint256[] calldata _numOfRewardUnits,\n string memory _packUri,\n uint128 _openStartTimestamp,\n uint128 _amountDistributedPerOpen,\n address _recipient\n ) external payable onlyRoleWithSwitch(minterRole) nonReentrant returns (uint256 packId, uint256 packTotalSupply) {\n require(_contents.length > 0 && _contents.length == _numOfRewardUnits.length, \"!Len\");\n\n if (!hasRole(assetRole, address(0))) {\n for (uint256 i = 0; i < _contents.length; i += 1) {\n _checkRole(assetRole, _contents[i].assetContract);\n }\n }\n\n packId = nextTokenIdToMint;\n nextTokenIdToMint += 1;\n\n packTotalSupply = escrowPackContents(\n _contents,\n _numOfRewardUnits,\n _packUri,\n packId,\n _amountDistributedPerOpen,\n false\n );\n\n packInfo[packId].openStartTimestamp = _openStartTimestamp;\n packInfo[packId].amountDistributedPerOpen = _amountDistributedPerOpen;\n\n canUpdatePack[packId] = true;\n\n _mint(_recipient, packId, packTotalSupply, \"\");\n\n emit PackCreated(packId, _recipient, packTotalSupply);\n }\n\n function addPackContents(\n uint256 _packId,\n Token[] calldata _contents,\n uint256[] calldata _numOfRewardUnits,\n address _recipient\n )\n external\n payable\n onlyRoleWithSwitch(minterRole)\n nonReentrant\n returns (uint256 packTotalSupply, uint256 newSupplyAdded)\n {\n require(canUpdatePack[_packId], \"!Allowed\");\n require(_contents.length > 0 && _contents.length == _numOfRewardUnits.length, \"!Len\");\n require(balanceOf(_recipient, _packId) != 0, \"!Bal\");\n\n if (!hasRole(assetRole, address(0))) {\n for (uint256 i = 0; i < _contents.length; i += 1) {\n _checkRole(assetRole, _contents[i].assetContract);\n }\n }\n\n uint256 amountPerOpen = packInfo[_packId].amountDistributedPerOpen;\n\n newSupplyAdded = escrowPackContents(_contents, _numOfRewardUnits, \"\", _packId, amountPerOpen, true);\n packTotalSupply = totalSupply[_packId] + newSupplyAdded;\n\n _mint(_recipient, _packId, newSupplyAdded, \"\");\n\n emit PackUpdated(_packId, _recipient, newSupplyAdded);\n }\n\n /// @notice Lets a pack owner open packs and receive the packs' reward units.\n function openPack(uint256 _packId, uint256 _amountToOpen) external nonReentrant returns (Token[] memory) {\n address opener = _msgSender();\n\n require(isTrustedForwarder(msg.sender) || opener == tx.origin, \"!EOA\");\n require(balanceOf(opener, _packId) >= _amountToOpen, \"!Bal\");\n\n PackInfo memory pack = packInfo[_packId];\n require(pack.openStartTimestamp <= block.timestamp, \"cant open\");\n\n Token[] memory rewardUnits = getRewardUnits(_packId, _amountToOpen, pack.amountDistributedPerOpen, pack);\n\n _burn(opener, _packId, _amountToOpen);\n\n _transferTokenBatch(address(this), opener, rewardUnits);\n\n emit PackOpened(_packId, opener, _amountToOpen, rewardUnits);\n\n return rewardUnits;\n }\n\n /// @dev Stores assets within the contract.\n function escrowPackContents(\n Token[] calldata _contents,\n uint256[] calldata _numOfRewardUnits,\n string memory _packUri,\n uint256 packId,\n uint256 amountPerOpen,\n bool isUpdate\n ) internal returns (uint256 supplyToMint) {\n uint256 sumOfRewardUnits;\n\n for (uint256 i = 0; i < _contents.length; i += 1) {\n require(_contents[i].totalAmount != 0, \"0 amt\");\n require(_contents[i].totalAmount % _numOfRewardUnits[i] == 0, \"!R\");\n require(_contents[i].tokenType != TokenType.ERC721 || _contents[i].totalAmount == 1, \"!R\");\n\n sumOfRewardUnits += _numOfRewardUnits[i];\n\n packInfo[packId].perUnitAmounts.push(_contents[i].totalAmount / _numOfRewardUnits[i]);\n }\n\n require(sumOfRewardUnits % amountPerOpen == 0, \"!Amt\");\n supplyToMint = sumOfRewardUnits / amountPerOpen;\n\n if (isUpdate) {\n for (uint256 i = 0; i < _contents.length; i += 1) {\n _addTokenInBundle(_contents[i], packId);\n }\n _transferTokenBatch(_msgSender(), address(this), _contents);\n } else {\n _storeTokens(_msgSender(), _contents, _packUri, packId);\n }\n }\n\n /// @dev Returns the reward units to distribute.\n function getRewardUnits(\n uint256 _packId,\n uint256 _numOfPacksToOpen,\n uint256 _rewardUnitsPerOpen,\n PackInfo memory pack\n ) internal returns (Token[] memory rewardUnits) {\n uint256 numOfRewardUnitsToDistribute = _numOfPacksToOpen * _rewardUnitsPerOpen;\n rewardUnits = new Token[](numOfRewardUnitsToDistribute);\n uint256 totalRewardUnits = totalSupply[_packId] * _rewardUnitsPerOpen;\n uint256 totalRewardKinds = getTokenCountOfBundle(_packId);\n\n uint256 random = generateRandomValue();\n\n (Token[] memory _token, ) = getPackContents(_packId);\n bool[] memory _isUpdated = new bool[](totalRewardKinds);\n for (uint256 i = 0; i < numOfRewardUnitsToDistribute; i += 1) {\n uint256 randomVal = uint256(keccak256(abi.encode(random, i)));\n uint256 target = randomVal % totalRewardUnits;\n uint256 step;\n\n for (uint256 j = 0; j < totalRewardKinds; j += 1) {\n uint256 totalRewardUnitsOfKind = _token[j].totalAmount / pack.perUnitAmounts[j];\n\n if (target < step + totalRewardUnitsOfKind) {\n _token[j].totalAmount -= pack.perUnitAmounts[j];\n _isUpdated[j] = true;\n\n rewardUnits[i].assetContract = _token[j].assetContract;\n rewardUnits[i].tokenType = _token[j].tokenType;\n rewardUnits[i].tokenId = _token[j].tokenId;\n rewardUnits[i].totalAmount = pack.perUnitAmounts[j];\n\n totalRewardUnits -= 1;\n\n break;\n } else {\n step += totalRewardUnitsOfKind;\n }\n }\n }\n\n for (uint256 i = 0; i < totalRewardKinds; i += 1) {\n if (_isUpdated[i]) {\n _updateTokenInBundle(_token[i], _packId, i);\n }\n }\n }\n\n /*///////////////////////////////////////////////////////////////\n Getter functions\n //////////////////////////////////////////////////////////////*/\n\n /// @dev Returns the underlying contents of a pack.\n function getPackContents(uint256 _packId)\n public\n view\n returns (Token[] memory contents, uint256[] memory perUnitAmounts)\n {\n PackInfo memory pack = packInfo[_packId];\n uint256 total = getTokenCountOfBundle(_packId);\n contents = new Token[](total);\n perUnitAmounts = new uint256[](total);\n\n for (uint256 i = 0; i < total; i += 1) {\n contents[i] = getTokenOfBundle(_packId, i);\n }\n perUnitAmounts = pack.perUnitAmounts;\n }\n\n /*///////////////////////////////////////////////////////////////\n Internal functions\n //////////////////////////////////////////////////////////////*/\n\n /// @dev Returns whether owner can be set in the given execution context.\n function _canSetOwner() internal view override returns (bool) {\n return hasRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n /// @dev Returns whether royalty info can be set in the given execution context.\n function _canSetRoyaltyInfo() internal view override returns (bool) {\n return hasRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n /// @dev Returns whether contract metadata can be set in the given execution context.\n function _canSetContractURI() internal view override returns (bool) {\n return hasRole(DEFAULT_ADMIN_ROLE, _msgSender());\n }\n\n /*///////////////////////////////////////////////////////////////\n Miscellaneous\n //////////////////////////////////////////////////////////////*/\n\n function generateRandomValue() internal view returns (uint256 random) {\n random = uint256(keccak256(abi.encodePacked(_msgSender(), blockhash(block.number - 1), block.difficulty)));\n }\n\n /**\n * @dev See {ERC1155-_beforeTokenTransfer}.\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual override {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n\n // if transfer is restricted on the contract, we still want to allow burning and minting\n if (!hasRole(transferRole, address(0)) && from != address(0) && to != address(0)) {\n require(hasRole(transferRole, from) || hasRole(transferRole, to), \"!TRANSFER_ROLE\");\n }\n\n if (from == address(0)) {\n for (uint256 i = 0; i < ids.length; ++i) {\n totalSupply[ids[i]] += amounts[i];\n }\n } else {\n for (uint256 i = 0; i < ids.length; ++i) {\n // pack can no longer be updated after first transfer to non-zero address\n if (canUpdatePack[ids[i]] && amounts[i] != 0) {\n canUpdatePack[ids[i]] = false;\n }\n }\n }\n\n if (to == address(0)) {\n for (uint256 i = 0; i < ids.length; ++i) {\n totalSupply[ids[i]] -= amounts[i];\n }\n }\n }\n\n /// @dev See EIP-2771\n function _msgSender()\n internal\n view\n virtual\n override(ContextUpgradeable, ERC2771ContextUpgradeable)\n returns (address sender)\n {\n return ERC2771ContextUpgradeable._msgSender();\n }\n\n /// @dev See EIP-2771\n function _msgData()\n internal\n view\n virtual\n override(ContextUpgradeable, ERC2771ContextUpgradeable)\n returns (bytes calldata)\n {\n return ERC2771ContextUpgradeable._msgData();\n }\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165Upgradeable.sol\";\n" }, "node_modules/@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981Upgradeable is IERC165Upgradeable {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be payed in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n // contract may have been reentered.\n require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} modifier, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n function _isConstructor() private view returns (bool) {\n return !AddressUpgradeable.isContract(address(this));\n }\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n function __Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __Pausable_init_unchained() internal onlyInitializing {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC1155Upgradeable.sol\";\nimport \"./IERC1155ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC1155MetadataURIUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the basic standard multi-token.\n * See https://eips.ethereum.org/EIPS/eip-1155\n * Originally based on code by Enjin: https://github.com/enjin/erc-1155\n *\n * _Available since v3.1._\n */\ncontract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable {\n using AddressUpgradeable for address;\n\n // Mapping from token ID to account balances\n mapping(uint256 => mapping(address => uint256)) private _balances;\n\n // Mapping from account to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json\n string private _uri;\n\n /**\n * @dev See {_setURI}.\n */\n function __ERC1155_init(string memory uri_) internal onlyInitializing {\n __ERC1155_init_unchained(uri_);\n }\n\n function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing {\n _setURI(uri_);\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n return\n interfaceId == type(IERC1155Upgradeable).interfaceId ||\n interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC1155MetadataURI-uri}.\n *\n * This implementation returns the same URI for *all* token types. It relies\n * on the token type ID substitution mechanism\n * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].\n *\n * Clients calling this function must replace the `\\{id\\}` substring with the\n * actual token type ID.\n */\n function uri(uint256) public view virtual override returns (string memory) {\n return _uri;\n }\n\n /**\n * @dev See {IERC1155-balanceOf}.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {\n require(account != address(0), \"ERC1155: balance query for the zero address\");\n return _balances[id][account];\n }\n\n /**\n * @dev See {IERC1155-balanceOfBatch}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] memory accounts, uint256[] memory ids)\n public\n view\n virtual\n override\n returns (uint256[] memory)\n {\n require(accounts.length == ids.length, \"ERC1155: accounts and ids length mismatch\");\n\n uint256[] memory batchBalances = new uint256[](accounts.length);\n\n for (uint256 i = 0; i < accounts.length; ++i) {\n batchBalances[i] = balanceOf(accounts[i], ids[i]);\n }\n\n return batchBalances;\n }\n\n /**\n * @dev See {IERC1155-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC1155-isApprovedForAll}.\n */\n function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[account][operator];\n }\n\n /**\n * @dev See {IERC1155-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) public virtual override {\n require(\n from == _msgSender() || isApprovedForAll(from, _msgSender()),\n \"ERC1155: caller is not owner nor approved\"\n );\n _safeTransferFrom(from, to, id, amount, data);\n }\n\n /**\n * @dev See {IERC1155-safeBatchTransferFrom}.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) public virtual override {\n require(\n from == _msgSender() || isApprovedForAll(from, _msgSender()),\n \"ERC1155: transfer caller is not owner nor approved\"\n );\n _safeBatchTransferFrom(from, to, ids, amounts, data);\n }\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function _safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n require(to != address(0), \"ERC1155: transfer to the zero address\");\n\n address operator = _msgSender();\n\n _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);\n\n uint256 fromBalance = _balances[id][from];\n require(fromBalance >= amount, \"ERC1155: insufficient balance for transfer\");\n unchecked {\n _balances[id][from] = fromBalance - amount;\n }\n _balances[id][to] += amount;\n\n emit TransferSingle(operator, from, to, id, amount);\n\n _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);\n }\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function _safeBatchTransferFrom(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\n require(to != address(0), \"ERC1155: transfer to the zero address\");\n\n address operator = _msgSender();\n\n _beforeTokenTransfer(operator, from, to, ids, amounts, data);\n\n for (uint256 i = 0; i < ids.length; ++i) {\n uint256 id = ids[i];\n uint256 amount = amounts[i];\n\n uint256 fromBalance = _balances[id][from];\n require(fromBalance >= amount, \"ERC1155: insufficient balance for transfer\");\n unchecked {\n _balances[id][from] = fromBalance - amount;\n }\n _balances[id][to] += amount;\n }\n\n emit TransferBatch(operator, from, to, ids, amounts);\n\n _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);\n }\n\n /**\n * @dev Sets a new URI for all token types, by relying on the token type ID\n * substitution mechanism\n * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].\n *\n * By this mechanism, any occurrence of the `\\{id\\}` substring in either the\n * URI or any of the amounts in the JSON file at said URI will be replaced by\n * clients with the token type ID.\n *\n * For example, the `https://token-cdn-domain/\\{id\\}.json` URI would be\n * interpreted by clients as\n * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`\n * for token type ID 0x4cce0.\n *\n * See {uri}.\n *\n * Because these URIs cannot be meaningfully represented by the {URI} event,\n * this function emits no events.\n */\n function _setURI(string memory newuri) internal virtual {\n _uri = newuri;\n }\n\n /**\n * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function _mint(\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n require(to != address(0), \"ERC1155: mint to the zero address\");\n\n address operator = _msgSender();\n\n _beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);\n\n _balances[id][to] += amount;\n emit TransferSingle(operator, address(0), to, id, amount);\n\n _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);\n }\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function _mintBatch(\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n require(to != address(0), \"ERC1155: mint to the zero address\");\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\n\n address operator = _msgSender();\n\n _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);\n\n for (uint256 i = 0; i < ids.length; i++) {\n _balances[ids[i]][to] += amounts[i];\n }\n\n emit TransferBatch(operator, address(0), to, ids, amounts);\n\n _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);\n }\n\n /**\n * @dev Destroys `amount` tokens of token type `id` from `from`\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `from` must have at least `amount` tokens of token type `id`.\n */\n function _burn(\n address from,\n uint256 id,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC1155: burn from the zero address\");\n\n address operator = _msgSender();\n\n _beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), \"\");\n\n uint256 fromBalance = _balances[id][from];\n require(fromBalance >= amount, \"ERC1155: burn amount exceeds balance\");\n unchecked {\n _balances[id][from] = fromBalance - amount;\n }\n\n emit TransferSingle(operator, from, address(0), id, amount);\n }\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n */\n function _burnBatch(\n address from,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal virtual {\n require(from != address(0), \"ERC1155: burn from the zero address\");\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\n\n address operator = _msgSender();\n\n _beforeTokenTransfer(operator, from, address(0), ids, amounts, \"\");\n\n for (uint256 i = 0; i < ids.length; i++) {\n uint256 id = ids[i];\n uint256 amount = amounts[i];\n\n uint256 fromBalance = _balances[id][from];\n require(fromBalance >= amount, \"ERC1155: burn amount exceeds balance\");\n unchecked {\n _balances[id][from] = fromBalance - amount;\n }\n }\n\n emit TransferBatch(operator, from, address(0), ids, amounts);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits a {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC1155: setting approval status for self\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning, as well as batched variants.\n *\n * The same hook is called on both single and batched variants. For single\n * transfers, the length of the `id` and `amount` arrays will be 1.\n *\n * Calling conditions (for each `id` and `amount` pair):\n *\n * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * of token type `id` will be transferred to `to`.\n * - When `from` is zero, `amount` tokens of token type `id` will be minted\n * for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`\n * will be burned.\n * - `from` and `to` are never both zero.\n * - `ids` and `amounts` have the same, non-zero length.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n\n function _doSafeTransferAcceptanceCheck(\n address operator,\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) private {\n if (to.isContract()) {\n try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {\n if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) {\n revert(\"ERC1155: ERC1155Receiver rejected tokens\");\n }\n } catch Error(string memory reason) {\n revert(reason);\n } catch {\n revert(\"ERC1155: transfer to non ERC1155Receiver implementer\");\n }\n }\n }\n\n function _doSafeBatchTransferAcceptanceCheck(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) private {\n if (to.isContract()) {\n try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (\n bytes4 response\n ) {\n if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) {\n revert(\"ERC1155: ERC1155Receiver rejected tokens\");\n }\n } catch Error(string memory reason) {\n revert(reason);\n } catch {\n revert(\"ERC1155: transfer to non ERC1155Receiver implementer\");\n }\n }\n }\n\n function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {\n uint256[] memory array = new uint256[](1);\n array[0] = element;\n\n return array;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[47] private __gap;\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155ReceiverUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155ReceiverUpgradeable is IERC165Upgradeable {\n /**\n * @dev Handles the receipt of a single ERC1155 token type. This function is\n * called at the end of a `safeTransferFrom` after the balance has been updated.\n *\n * NOTE: To accept the transfer, this must return\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n * (i.e. 0xf23a6e61, or its own function selector).\n *\n * @param operator The address which initiated the transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param id The ID of the token being transferred\n * @param value The amount of tokens being transferred\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\n * is called at the end of a `safeBatchTransferFrom` after the balances have\n * been updated.\n *\n * NOTE: To accept the transfer(s), this must return\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n * (i.e. 0xbc197c81, or its own function selector).\n *\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155Upgradeable is IERC165Upgradeable {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1155Upgradeable.sol\";\nimport \"../../../security/PausableUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev ERC1155 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n *\n * _Available since v3.1._\n */\nabstract contract ERC1155PausableUpgradeable is Initializable, ERC1155Upgradeable, PausableUpgradeable {\n function __ERC1155Pausable_init() internal onlyInitializing {\n __Pausable_init_unchained();\n }\n\n function __ERC1155Pausable_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {ERC1155-_beforeTokenTransfer}.\n *\n * Requirements:\n *\n * - the contract must not be paused.\n */\n function _beforeTokenTransfer(\n address operator,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual override {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n\n require(!paused(), \"ERC1155Pausable: token transfer while paused\");\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/IERC1155MetadataURIUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC1155Upgradeable.sol\";\n\n/**\n * @dev Interface of the optional ERC1155MetadataExtension interface, as defined\n * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable {\n /**\n * @dev Returns the URI for token type `id`.\n *\n * If the `\\{id\\}` substring is present in the URI, it must be replaced by\n * clients with the actual token type ID.\n */\n function uri(uint256 id) external view returns (string memory);\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\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 /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./AddressUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides a function to batch together multiple calls in a single external call.\n *\n * _Available since v4.1._\n */\nabstract contract MulticallUpgradeable is Initializable {\n function __Multicall_init() internal onlyInitializing {\n }\n\n function __Multicall_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Receives and executes a batch of function calls on this contract.\n */\n function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {\n results = new bytes[](data.length);\n for (uint256 i = 0; i < data.length; i++) {\n results[i] = _functionDelegateCall(address(this), data[i]);\n }\n return results;\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return AddressUpgradeable.verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165Upgradeable).interfaceId;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n" }, "node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.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 IERC165Upgradeable {\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" }, "node_modules/@openzeppelin/contracts/interfaces/IERC1155Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC1155/IERC1155Receiver.sol\";\n" }, "node_modules/@openzeppelin/contracts/interfaces/IERC721Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC721/IERC721Receiver.sol\";\n" }, "node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @dev Handles the receipt of a single ERC1155 token type. This function is\n * called at the end of a `safeTransferFrom` after the balance has been updated.\n *\n * NOTE: To accept the transfer, this must return\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n * (i.e. 0xf23a6e61, or its own function selector).\n *\n * @param operator The address which initiated the transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param id The ID of the token being transferred\n * @param value The amount of tokens being transferred\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\n * is called at the end of a `safeBatchTransferFrom` after the balances have\n * been updated.\n *\n * NOTE: To accept the transfer(s), this must return\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n * (i.e. 0xbc197c81, or its own function selector).\n *\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" }, "node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" }, "node_modules/@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" } }, "settings": { "optimizer": { "enabled": true, "runs": 490 }, "evmVersion": "london", "remappings": [ ":@chainlink/contracts/src/=node_modules/@chainlink/contracts/src/", ":@ds-test/=lib/ds-test/src/", ":@openzeppelin/=node_modules/@openzeppelin/", ":@std/=lib/forge-std/src/", ":contracts/=contracts/", ":ds-test/=lib/ds-test/src/", ":erc721a-upgradeable/=node_modules/erc721a-upgradeable/", ":erc721a/=node_modules/erc721a/", ":forge-std/=lib/forge-std/src/" ], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } } }