File size: 48,874 Bytes
f998fcd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
{
"language": "Solidity",
"sources": {
"src/dttd_poap_contract.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\n/// @title DTTD POAPs Contract\n/// @author irreverent.eth @ DTTD\n/// @notice https://dttd.io/\n\n// ___ _____ _____ ___ \n// | \\ |_ _| |_ _| | \\ \n// | |) | | | | | | |) | \n// |___/ _|_|_ _|_|_ |___/ \n// _|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"| \n// \"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-' \n\nimport \"openzeppelin-contracts/token/ERC1155/ERC1155.sol\";\nimport \"openzeppelin-contracts/access/Ownable.sol\";\n\ncontract DTTDPOAPContract is ERC1155, Ownable {\n struct Token {\n string name;\n string symbol;\n uint256 maxSupply;\n uint256 totalSupply;\n string uri;\n }\n\n uint256 public numberOfTokens;\n mapping(uint256 => Token) public tokens;\n mapping(bytes32 => bool) public tidUsed;\n mapping(bytes32 => bool) public claimed;\n\n constructor() payable ERC1155(\"\") {\n }\n\n modifier tidCheck(bytes32 tid) {\n require (tidUsed[tid] == false, \"Already minted: tid\");\n _;\n }\n\n // Setup new POAP\n\n function setupPOAP(string memory tokenName, string memory tokenSymbol, uint256 tokenMaxSupply, string memory tokenURI) external onlyOwner {\n require(bytes(tokenName).length > 0, \"Missing name\");\n require(bytes(tokenSymbol).length > 0, \"Missing symbol\");\n require(tokenMaxSupply > 0, \"Missing max supply\");\n require(bytes(tokenURI).length > 0, \"Missing URI\");\n\n Token memory token = Token({\n name: tokenName,\n symbol: tokenSymbol,\n maxSupply: tokenMaxSupply,\n totalSupply: 0,\n uri: tokenURI\n });\n\n tokens[numberOfTokens] = token;\n ++numberOfTokens;\n }\n\n function setURI(uint256 tokenID, string memory tokenURI) external onlyOwner {\n require(tokenID < numberOfTokens, \"Invalid ID\");\n require(bytes(tokenURI).length > 0, \"Missing URI\");\n\n Token storage token = tokens[tokenID];\n token.uri = tokenURI;\n emit URI(tokenURI, tokenID);\n }\n\n // Airdrop\n\n function airdropPOAP(bytes32 tid, bytes32 pid, address to, uint256 tokenID) external onlyOwner tidCheck(tid) {\n require(tokenID < numberOfTokens, \"Invalid ID\");\n\n bytes32 claimHash = keccak256(abi.encode(pid, tokenID));\n require(claimed[claimHash] == false, \"Already claimed: pid-tokenId\");\n\n Token memory token = tokens[tokenID];\n uint256 tokenMaxSupply = token.maxSupply;\n uint256 tokenTotalSupply = token.totalSupply;\n require (tokenTotalSupply + 1 <= tokenMaxSupply, \"Insufficient remaining supply\");\n\n claimed[claimHash] = true;\n tidUsed[tid] = true;\n _mint(to, tokenID, 1, \"\");\n }\n\n function batchMint(address to, uint256 tokenID, uint256 quantity) external onlyOwner {\n require(tokenID < numberOfTokens, \"Invalid ID\");\n require(quantity > 0, \"Zero quantity\");\n\n Token memory token = tokens[tokenID];\n uint256 tokenMaxSupply = token.maxSupply;\n uint256 tokenTotalSupply = token.totalSupply;\n require (tokenTotalSupply + quantity <= tokenMaxSupply, \"Insufficient remaining supply\");\n\n _mint(to, tokenID, quantity, \"\");\n }\n\n // Token data\n\n function uri(uint256 tokenID) public view override returns (string memory) {\n Token memory token = tokens[tokenID];\n return token.uri;\n }\n\n function name(uint256 tokenID) public view returns (string memory) {\n Token memory token = tokens[tokenID];\n return token.name;\n }\n\n function symbol(uint256 tokenID) public view returns (string memory) {\n Token memory token = tokens[tokenID];\n return token.symbol;\n }\n\n function maxSupply(uint256 tokenID) public view returns (uint256) {\n Token memory token = tokens[tokenID];\n return token.maxSupply;\n }\n\n function totalSupply(uint256 tokenID) public view returns (uint256) {\n Token memory token = tokens[tokenID];\n return token.totalSupply;\n }\n\n // Override for token total supply\n\n function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) internal virtual override {\n super._beforeTokenTransfer(operator, from, to, ids, amounts, data);\n if (from == address(0)) {\n for (uint256 i = 0; i < ids.length; ++i) {\n Token storage token = tokens[ids[i]];\n token.totalSupply += amounts[i];\n }\n }\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/token/ERC1155/ERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./IERC1155.sol\";\r\nimport \"./IERC1155Receiver.sol\";\r\nimport \"./extensions/IERC1155MetadataURI.sol\";\r\nimport \"../../utils/Address.sol\";\r\nimport \"../../utils/Context.sol\";\r\nimport \"../../utils/introspection/ERC165.sol\";\r\n\r\n/**\r\n * @dev Implementation of the basic standard multi-token.\r\n * See https://eips.ethereum.org/EIPS/eip-1155\r\n * Originally based on code by Enjin: https://github.com/enjin/erc-1155\r\n *\r\n * _Available since v3.1._\r\n */\r\ncontract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {\r\n using Address for address;\r\n\r\n // Mapping from token ID to account balances\r\n mapping(uint256 => mapping(address => uint256)) private _balances;\r\n\r\n // Mapping from account to operator approvals\r\n mapping(address => mapping(address => bool)) private _operatorApprovals;\r\n\r\n // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json\r\n string private _uri;\r\n\r\n /**\r\n * @dev See {_setURI}.\r\n */\r\n constructor(string memory uri_) {\r\n _setURI(uri_);\r\n }\r\n\r\n /**\r\n * @dev See {IERC165-supportsInterface}.\r\n */\r\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\r\n return\r\n interfaceId == type(IERC1155).interfaceId ||\r\n interfaceId == type(IERC1155MetadataURI).interfaceId ||\r\n super.supportsInterface(interfaceId);\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155MetadataURI-uri}.\r\n *\r\n * This implementation returns the same URI for *all* token types. It relies\r\n * on the token type ID substitution mechanism\r\n * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].\r\n *\r\n * Clients calling this function must replace the `\\{id\\}` substring with the\r\n * actual token type ID.\r\n */\r\n function uri(uint256) public view virtual override returns (string memory) {\r\n return _uri;\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-balanceOf}.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n */\r\n function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {\r\n require(account != address(0), \"ERC1155: address zero is not a valid owner\");\r\n return _balances[id][account];\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-balanceOfBatch}.\r\n *\r\n * Requirements:\r\n *\r\n * - `accounts` and `ids` must have the same length.\r\n */\r\n function balanceOfBatch(address[] memory accounts, uint256[] memory ids)\r\n public\r\n view\r\n virtual\r\n override\r\n returns (uint256[] memory)\r\n {\r\n require(accounts.length == ids.length, \"ERC1155: accounts and ids length mismatch\");\r\n\r\n uint256[] memory batchBalances = new uint256[](accounts.length);\r\n\r\n for (uint256 i = 0; i < accounts.length; ++i) {\r\n batchBalances[i] = balanceOf(accounts[i], ids[i]);\r\n }\r\n\r\n return batchBalances;\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-setApprovalForAll}.\r\n */\r\n function setApprovalForAll(address operator, bool approved) public virtual override {\r\n _setApprovalForAll(_msgSender(), operator, approved);\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-isApprovedForAll}.\r\n */\r\n function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {\r\n return _operatorApprovals[account][operator];\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-safeTransferFrom}.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes memory data\r\n ) public virtual override {\r\n require(\r\n from == _msgSender() || isApprovedForAll(from, _msgSender()),\r\n \"ERC1155: caller is not token owner or approved\"\r\n );\r\n _safeTransferFrom(from, to, id, amount, data);\r\n }\r\n\r\n /**\r\n * @dev See {IERC1155-safeBatchTransferFrom}.\r\n */\r\n function safeBatchTransferFrom(\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) public virtual override {\r\n require(\r\n from == _msgSender() || isApprovedForAll(from, _msgSender()),\r\n \"ERC1155: caller is not token owner or approved\"\r\n );\r\n _safeBatchTransferFrom(from, to, ids, amounts, data);\r\n }\r\n\r\n /**\r\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\r\n *\r\n * Emits a {TransferSingle} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\r\n * acceptance magic value.\r\n */\r\n function _safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes memory data\r\n ) internal virtual {\r\n require(to != address(0), \"ERC1155: transfer to the zero address\");\r\n\r\n address operator = _msgSender();\r\n uint256[] memory ids = _asSingletonArray(id);\r\n uint256[] memory amounts = _asSingletonArray(amount);\r\n\r\n _beforeTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n uint256 fromBalance = _balances[id][from];\r\n require(fromBalance >= amount, \"ERC1155: insufficient balance for transfer\");\r\n unchecked {\r\n _balances[id][from] = fromBalance - amount;\r\n }\r\n _balances[id][to] += amount;\r\n\r\n emit TransferSingle(operator, from, to, id, amount);\r\n\r\n _afterTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);\r\n }\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.\r\n *\r\n * Emits a {TransferBatch} event.\r\n *\r\n * Requirements:\r\n *\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\r\n * acceptance magic value.\r\n */\r\n function _safeBatchTransferFrom(\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual {\r\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\r\n require(to != address(0), \"ERC1155: transfer to the zero address\");\r\n\r\n address operator = _msgSender();\r\n\r\n _beforeTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n for (uint256 i = 0; i < ids.length; ++i) {\r\n uint256 id = ids[i];\r\n uint256 amount = amounts[i];\r\n\r\n uint256 fromBalance = _balances[id][from];\r\n require(fromBalance >= amount, \"ERC1155: insufficient balance for transfer\");\r\n unchecked {\r\n _balances[id][from] = fromBalance - amount;\r\n }\r\n _balances[id][to] += amount;\r\n }\r\n\r\n emit TransferBatch(operator, from, to, ids, amounts);\r\n\r\n _afterTokenTransfer(operator, from, to, ids, amounts, data);\r\n\r\n _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);\r\n }\r\n\r\n /**\r\n * @dev Sets a new URI for all token types, by relying on the token type ID\r\n * substitution mechanism\r\n * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].\r\n *\r\n * By this mechanism, any occurrence of the `\\{id\\}` substring in either the\r\n * URI or any of the amounts in the JSON file at said URI will be replaced by\r\n * clients with the token type ID.\r\n *\r\n * For example, the `https://token-cdn-domain/\\{id\\}.json` URI would be\r\n * interpreted by clients as\r\n * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`\r\n * for token type ID 0x4cce0.\r\n *\r\n * See {uri}.\r\n *\r\n * Because these URIs cannot be meaningfully represented by the {URI} event,\r\n * this function emits no events.\r\n */\r\n function _setURI(string memory newuri) internal virtual {\r\n _uri = newuri;\r\n }\r\n\r\n /**\r\n * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.\r\n *\r\n * Emits a {TransferSingle} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\r\n * acceptance magic value.\r\n */\r\n function _mint(\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes memory data\r\n ) internal virtual {\r\n require(to != address(0), \"ERC1155: mint to the zero address\");\r\n\r\n address operator = _msgSender();\r\n uint256[] memory ids = _asSingletonArray(id);\r\n uint256[] memory amounts = _asSingletonArray(amount);\r\n\r\n _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);\r\n\r\n _balances[id][to] += amount;\r\n emit TransferSingle(operator, address(0), to, id, amount);\r\n\r\n _afterTokenTransfer(operator, address(0), to, ids, amounts, data);\r\n\r\n _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);\r\n }\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.\r\n *\r\n * Emits a {TransferBatch} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `ids` and `amounts` must have the same length.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\r\n * acceptance magic value.\r\n */\r\n function _mintBatch(\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual {\r\n require(to != address(0), \"ERC1155: mint to the zero address\");\r\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\r\n\r\n address operator = _msgSender();\r\n\r\n _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);\r\n\r\n for (uint256 i = 0; i < ids.length; i++) {\r\n _balances[ids[i]][to] += amounts[i];\r\n }\r\n\r\n emit TransferBatch(operator, address(0), to, ids, amounts);\r\n\r\n _afterTokenTransfer(operator, address(0), to, ids, amounts, data);\r\n\r\n _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);\r\n }\r\n\r\n /**\r\n * @dev Destroys `amount` tokens of token type `id` from `from`\r\n *\r\n * Emits a {TransferSingle} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `from` must have at least `amount` tokens of token type `id`.\r\n */\r\n function _burn(\r\n address from,\r\n uint256 id,\r\n uint256 amount\r\n ) internal virtual {\r\n require(from != address(0), \"ERC1155: burn from the zero address\");\r\n\r\n address operator = _msgSender();\r\n uint256[] memory ids = _asSingletonArray(id);\r\n uint256[] memory amounts = _asSingletonArray(amount);\r\n\r\n _beforeTokenTransfer(operator, from, address(0), ids, amounts, \"\");\r\n\r\n uint256 fromBalance = _balances[id][from];\r\n require(fromBalance >= amount, \"ERC1155: burn amount exceeds balance\");\r\n unchecked {\r\n _balances[id][from] = fromBalance - amount;\r\n }\r\n\r\n emit TransferSingle(operator, from, address(0), id, amount);\r\n\r\n _afterTokenTransfer(operator, from, address(0), ids, amounts, \"\");\r\n }\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.\r\n *\r\n * Emits a {TransferBatch} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `ids` and `amounts` must have the same length.\r\n */\r\n function _burnBatch(\r\n address from,\r\n uint256[] memory ids,\r\n uint256[] memory amounts\r\n ) internal virtual {\r\n require(from != address(0), \"ERC1155: burn from the zero address\");\r\n require(ids.length == amounts.length, \"ERC1155: ids and amounts length mismatch\");\r\n\r\n address operator = _msgSender();\r\n\r\n _beforeTokenTransfer(operator, from, address(0), ids, amounts, \"\");\r\n\r\n for (uint256 i = 0; i < ids.length; i++) {\r\n uint256 id = ids[i];\r\n uint256 amount = amounts[i];\r\n\r\n uint256 fromBalance = _balances[id][from];\r\n require(fromBalance >= amount, \"ERC1155: burn amount exceeds balance\");\r\n unchecked {\r\n _balances[id][from] = fromBalance - amount;\r\n }\r\n }\r\n\r\n emit TransferBatch(operator, from, address(0), ids, amounts);\r\n\r\n _afterTokenTransfer(operator, from, address(0), ids, amounts, \"\");\r\n }\r\n\r\n /**\r\n * @dev Approve `operator` to operate on all of `owner` tokens\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function _setApprovalForAll(\r\n address owner,\r\n address operator,\r\n bool approved\r\n ) internal virtual {\r\n require(owner != operator, \"ERC1155: setting approval status for self\");\r\n _operatorApprovals[owner][operator] = approved;\r\n emit ApprovalForAll(owner, operator, approved);\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before any token transfer. This includes minting\r\n * and burning, as well as batched variants.\r\n *\r\n * The same hook is called on both single and batched variants. For single\r\n * transfers, the length of the `ids` and `amounts` arrays will be 1.\r\n *\r\n * Calling conditions (for each `id` and `amount` pair):\r\n *\r\n * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * of token type `id` will be transferred to `to`.\r\n * - When `from` is zero, `amount` tokens of token type `id` will be minted\r\n * for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`\r\n * will be burned.\r\n * - `from` and `to` are never both zero.\r\n * - `ids` and `amounts` have the same, non-zero length.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _beforeTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual {}\r\n\r\n /**\r\n * @dev Hook that is called after any token transfer. This includes minting\r\n * and burning, as well as batched variants.\r\n *\r\n * The same hook is called on both single and batched variants. For single\r\n * transfers, the length of the `id` and `amount` arrays will be 1.\r\n *\r\n * Calling conditions (for each `id` and `amount` pair):\r\n *\r\n * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r\n * of token type `id` will be transferred to `to`.\r\n * - When `from` is zero, `amount` tokens of token type `id` will be minted\r\n * for `to`.\r\n * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`\r\n * will be burned.\r\n * - `from` and `to` are never both zero.\r\n * - `ids` and `amounts` have the same, non-zero length.\r\n *\r\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r\n */\r\n function _afterTokenTransfer(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) internal virtual {}\r\n\r\n function _doSafeTransferAcceptanceCheck(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes memory data\r\n ) private {\r\n if (to.isContract()) {\r\n try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {\r\n if (response != IERC1155Receiver.onERC1155Received.selector) {\r\n revert(\"ERC1155: ERC1155Receiver rejected tokens\");\r\n }\r\n } catch Error(string memory reason) {\r\n revert(reason);\r\n } catch {\r\n revert(\"ERC1155: transfer to non-ERC1155Receiver implementer\");\r\n }\r\n }\r\n }\r\n\r\n function _doSafeBatchTransferAcceptanceCheck(\r\n address operator,\r\n address from,\r\n address to,\r\n uint256[] memory ids,\r\n uint256[] memory amounts,\r\n bytes memory data\r\n ) private {\r\n if (to.isContract()) {\r\n try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (\r\n bytes4 response\r\n ) {\r\n if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {\r\n revert(\"ERC1155: ERC1155Receiver rejected tokens\");\r\n }\r\n } catch Error(string memory reason) {\r\n revert(reason);\r\n } catch {\r\n revert(\"ERC1155: transfer to non-ERC1155Receiver implementer\");\r\n }\r\n }\r\n }\r\n\r\n function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {\r\n uint256[] memory array = new uint256[](1);\r\n array[0] = element;\r\n\r\n return array;\r\n }\r\n}\r\n"
},
"lib/openzeppelin-contracts/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"../utils/Context.sol\";\r\n\r\n/**\r\n * @dev Contract module which provides a basic access control mechanism, where\r\n * there is an account (an owner) that can be granted exclusive access to\r\n * specific functions.\r\n *\r\n * By default, the owner account will be the one that deploys the contract. This\r\n * can later be changed with {transferOwnership}.\r\n *\r\n * This module is used through inheritance. It will make available the modifier\r\n * `onlyOwner`, which can be applied to your functions to restrict their use to\r\n * the owner.\r\n */\r\nabstract contract Ownable is Context {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n constructor() {\r\n _transferOwnership(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n _checkOwner();\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view virtual returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if the sender is not the owner.\r\n */\r\n function _checkOwner() internal view virtual {\r\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n *\r\n * NOTE: Renouncing ownership will leave the contract without an owner,\r\n * thereby removing any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public virtual onlyOwner {\r\n _transferOwnership(address(0));\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual onlyOwner {\r\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\r\n _transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Internal function without access restriction.\r\n */\r\n function _transferOwnership(address newOwner) internal virtual {\r\n address oldOwner = _owner;\r\n _owner = newOwner;\r\n emit OwnershipTransferred(oldOwner, newOwner);\r\n }\r\n}\r\n"
},
"lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"../../utils/introspection/IERC165.sol\";\r\n\r\n/**\r\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\r\n *\r\n * _Available since v3.1._\r\n */\r\ninterface IERC1155 is IERC165 {\r\n /**\r\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\r\n */\r\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\r\n\r\n /**\r\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\r\n * transfers.\r\n */\r\n event TransferBatch(\r\n address indexed operator,\r\n address indexed from,\r\n address indexed to,\r\n uint256[] ids,\r\n uint256[] values\r\n );\r\n\r\n /**\r\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\r\n * `approved`.\r\n */\r\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\r\n\r\n /**\r\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\r\n *\r\n * If an {URI} event was emitted for `id`, the standard\r\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\r\n * returned by {IERC1155MetadataURI-uri}.\r\n */\r\n event URI(string value, uint256 indexed id);\r\n\r\n /**\r\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\r\n *\r\n * Requirements:\r\n *\r\n * - `account` cannot be the zero address.\r\n */\r\n function balanceOf(address account, uint256 id) external view returns (uint256);\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\r\n *\r\n * Requirements:\r\n *\r\n * - `accounts` and `ids` must have the same length.\r\n */\r\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\r\n external\r\n view\r\n returns (uint256[] memory);\r\n\r\n /**\r\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `operator` cannot be the caller.\r\n */\r\n function setApprovalForAll(address operator, bool approved) external;\r\n\r\n /**\r\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\r\n *\r\n * See {setApprovalForAll}.\r\n */\r\n function isApprovedForAll(address account, address operator) external view returns (bool);\r\n\r\n /**\r\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\r\n *\r\n * Emits a {TransferSingle} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.\r\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\r\n * acceptance magic value.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 id,\r\n uint256 amount,\r\n bytes calldata data\r\n ) external;\r\n\r\n /**\r\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\r\n *\r\n * Emits a {TransferBatch} event.\r\n *\r\n * Requirements:\r\n *\r\n * - `ids` and `amounts` must have the same length.\r\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\r\n * acceptance magic value.\r\n */\r\n function safeBatchTransferFrom(\r\n address from,\r\n address to,\r\n uint256[] calldata ids,\r\n uint256[] calldata amounts,\r\n bytes calldata data\r\n ) external;\r\n}\r\n"
},
"lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"../../utils/introspection/IERC165.sol\";\r\n\r\n/**\r\n * @dev _Available since v3.1._\r\n */\r\ninterface IERC1155Receiver is IERC165 {\r\n /**\r\n * @dev Handles the receipt of a single ERC1155 token type. This function is\r\n * called at the end of a `safeTransferFrom` after the balance has been updated.\r\n *\r\n * NOTE: To accept the transfer, this must return\r\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\r\n * (i.e. 0xf23a6e61, or its own function selector).\r\n *\r\n * @param operator The address which initiated the transfer (i.e. msg.sender)\r\n * @param from The address which previously owned the token\r\n * @param id The ID of the token being transferred\r\n * @param value The amount of tokens being transferred\r\n * @param data Additional data with no specified format\r\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\r\n */\r\n function onERC1155Received(\r\n address operator,\r\n address from,\r\n uint256 id,\r\n uint256 value,\r\n bytes calldata data\r\n ) external returns (bytes4);\r\n\r\n /**\r\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\r\n * is called at the end of a `safeBatchTransferFrom` after the balances have\r\n * been updated.\r\n *\r\n * NOTE: To accept the transfer(s), this must return\r\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\r\n * (i.e. 0xbc197c81, or its own function selector).\r\n *\r\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\r\n * @param from The address which previously owned the token\r\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\r\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\r\n * @param data Additional data with no specified format\r\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\r\n */\r\n function onERC1155BatchReceived(\r\n address operator,\r\n address from,\r\n uint256[] calldata ids,\r\n uint256[] calldata values,\r\n bytes calldata data\r\n ) external returns (bytes4);\r\n}\r\n"
},
"lib/openzeppelin-contracts/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"../IERC1155.sol\";\r\n\r\n/**\r\n * @dev Interface of the optional ERC1155MetadataExtension interface, as defined\r\n * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].\r\n *\r\n * _Available since v3.1._\r\n */\r\ninterface IERC1155MetadataURI is IERC1155 {\r\n /**\r\n * @dev Returns the URI for token type `id`.\r\n *\r\n * If the `\\{id\\}` substring is present in the URI, it must be replaced by\r\n * clients with the actual token type ID.\r\n */\r\n function uri(uint256 id) external view returns (string memory);\r\n}\r\n"
},
"lib/openzeppelin-contracts/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\r\n\r\npragma solidity ^0.8.1;\r\n\r\n/**\r\n * @dev Collection of functions related to the address type\r\n */\r\nlibrary Address {\r\n /**\r\n * @dev Returns true if `account` is a contract.\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * It is unsafe to assume that an address for which this function returns\r\n * false is an externally-owned account (EOA) and not a contract.\r\n *\r\n * Among others, `isContract` will return false for the following\r\n * types of addresses:\r\n *\r\n * - an externally-owned account\r\n * - a contract in construction\r\n * - an address where a contract will be created\r\n * - an address where a contract lived, but was destroyed\r\n * ====\r\n *\r\n * [IMPORTANT]\r\n * ====\r\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\r\n *\r\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\r\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\r\n * constructor.\r\n * ====\r\n */\r\n function isContract(address account) internal view returns (bool) {\r\n // This method relies on extcodesize/address.code.length, which returns 0\r\n // for contracts in construction, since the code is only stored at the end\r\n // of the constructor execution.\r\n\r\n return account.code.length > 0;\r\n }\r\n\r\n /**\r\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\r\n * `recipient`, forwarding all available gas and reverting on errors.\r\n *\r\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\r\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\r\n * imposed by `transfer`, making them unable to receive funds via\r\n * `transfer`. {sendValue} removes this limitation.\r\n *\r\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\r\n *\r\n * IMPORTANT: because control is transferred to `recipient`, care must be\r\n * taken to not create reentrancy vulnerabilities. Consider using\r\n * {ReentrancyGuard} or the\r\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\r\n */\r\n function sendValue(address payable recipient, uint256 amount) internal {\r\n require(address(this).balance >= amount, \"Address: insufficient balance\");\r\n\r\n (bool success, ) = recipient.call{value: amount}(\"\");\r\n require(success, \"Address: unable to send value, recipient may have reverted\");\r\n }\r\n\r\n /**\r\n * @dev Performs a Solidity function call using a low level `call`. A\r\n * plain `call` is an unsafe replacement for a function call: use this\r\n * function instead.\r\n *\r\n * If `target` reverts with a revert reason, it is bubbled up by this\r\n * function (like regular Solidity function calls).\r\n *\r\n * Returns the raw returned data. To convert to the expected return value,\r\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\r\n *\r\n * Requirements:\r\n *\r\n * - `target` must be a contract.\r\n * - calling `target` with `data` must not revert.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\r\n * `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, 0, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but also transferring `value` wei to `target`.\r\n *\r\n * Requirements:\r\n *\r\n * - the calling contract must have an ETH balance of at least `value`.\r\n * - the called Solidity function must be `payable`.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value\r\n ) internal returns (bytes memory) {\r\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\r\n * with `errorMessage` as a fallback revert reason when `target` reverts.\r\n *\r\n * _Available since v3.1._\r\n */\r\n function functionCallWithValue(\r\n address target,\r\n bytes memory data,\r\n uint256 value,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\r\n (bool success, bytes memory returndata) = target.call{value: value}(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\r\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a static call.\r\n *\r\n * _Available since v3.3._\r\n */\r\n function functionStaticCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n (bool success, bytes memory returndata) = target.staticcall(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\r\n * but performing a delegate call.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\r\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\r\n }\r\n\r\n /**\r\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\r\n * but performing a delegate call.\r\n *\r\n * _Available since v3.4._\r\n */\r\n function functionDelegateCall(\r\n address target,\r\n bytes memory data,\r\n string memory errorMessage\r\n ) internal returns (bytes memory) {\r\n (bool success, bytes memory returndata) = target.delegatecall(data);\r\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\r\n }\r\n\r\n /**\r\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\r\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\r\n *\r\n * _Available since v4.8._\r\n */\r\n function verifyCallResultFromTarget(\r\n address target,\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal view returns (bytes memory) {\r\n if (success) {\r\n if (returndata.length == 0) {\r\n // only check isContract if the call was successful and the return data is empty\r\n // otherwise we already know that it was a contract\r\n require(isContract(target), \"Address: call to non-contract\");\r\n }\r\n return returndata;\r\n } else {\r\n _revert(returndata, errorMessage);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\r\n * revert reason or using the provided one.\r\n *\r\n * _Available since v4.3._\r\n */\r\n function verifyCallResult(\r\n bool success,\r\n bytes memory returndata,\r\n string memory errorMessage\r\n ) internal pure returns (bytes memory) {\r\n if (success) {\r\n return returndata;\r\n } else {\r\n _revert(returndata, errorMessage);\r\n }\r\n }\r\n\r\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\r\n // Look for revert reason and bubble it up if present\r\n if (returndata.length > 0) {\r\n // The easiest way to bubble the revert reason is using memory via assembly\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n let returndata_size := mload(returndata)\r\n revert(add(32, returndata), returndata_size)\r\n }\r\n } else {\r\n revert(errorMessage);\r\n }\r\n }\r\n}\r\n"
},
"lib/openzeppelin-contracts/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available\r\n * via msg.sender and msg.data, they should not be accessed in such a direct\r\n * manner, since when dealing with meta-transactions the account sending and\r\n * paying for execution may not be the actual sender (as far as an application\r\n * is concerned).\r\n *\r\n * This contract is only required for intermediate, library-like contracts.\r\n */\r\nabstract contract Context {\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n}\r\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./IERC165.sol\";\r\n\r\n/**\r\n * @dev Implementation of the {IERC165} interface.\r\n *\r\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\r\n * for the additional interface id that will be supported. For example:\r\n *\r\n * ```solidity\r\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\r\n * }\r\n * ```\r\n *\r\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\r\n */\r\nabstract contract ERC165 is IERC165 {\r\n /**\r\n * @dev See {IERC165-supportsInterface}.\r\n */\r\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n return interfaceId == type(IERC165).interfaceId;\r\n }\r\n}\r\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Interface of the ERC165 standard, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\r\n *\r\n * Implementers can declare support of contract interfaces, which can then be\r\n * queried by others ({ERC165Checker}).\r\n *\r\n * For an implementation, see {ERC165}.\r\n */\r\ninterface IERC165 {\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30 000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n"
}
},
"settings": {
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
} |