-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathERC1155ChallengeableMint-input.json
1 lines (1 loc) · 75.3 KB
/
ERC1155ChallengeableMint-input.json
1
{"language":"Solidity","sources":{"@eth-optimism/contracts-bedrock/src/dispute/interfaces/IBondManager.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\n/// @title IBondManager\n/// @notice The Bond Manager holds ether posted as a bond for a bond id.\ninterface IBondManager {\n /// @notice BondPosted is emitted when a bond is posted.\n /// @param bondId is the id of the bond.\n /// @param owner is the address that owns the bond.\n /// @param expiration is the time at which the bond expires.\n /// @param amount is the amount of the bond.\n event BondPosted(bytes32 bondId, address owner, uint256 expiration, uint256 amount);\n\n /// @notice BondSeized is emitted when a bond is seized.\n /// @param bondId is the id of the bond.\n /// @param owner is the address that owns the bond.\n /// @param seizer is the address that seized the bond.\n /// @param amount is the amount of the bond.\n event BondSeized(bytes32 bondId, address owner, address seizer, uint256 amount);\n\n /// @notice BondReclaimed is emitted when a bond is reclaimed by the owner.\n /// @param bondId is the id of the bond.\n /// @param claiment is the address that reclaimed the bond.\n /// @param amount is the amount of the bond.\n event BondReclaimed(bytes32 bondId, address claiment, uint256 amount);\n\n /// @notice Post a bond with a given id and owner.\n /// @dev This function will revert if the provided bondId is already in use.\n /// @param _bondId is the id of the bond.\n /// @param _bondOwner is the address that owns the bond.\n /// @param _minClaimHold is the minimum amount of time the owner\n /// must wait before reclaiming their bond.\n function post(\n bytes32 _bondId,\n address _bondOwner,\n uint128 _minClaimHold\n ) external payable;\n\n /// @notice Seizes the bond with the given id.\n /// @dev This function will revert if there is no bond at the given id.\n /// @param _bondId is the id of the bond.\n function seize(bytes32 _bondId) external;\n\n /// @notice Seizes the bond with the given id and distributes it to recipients.\n /// @dev This function will revert if there is no bond at the given id.\n /// @param _bondId is the id of the bond.\n /// @param _claimRecipients is a set of addresses to split the bond amongst.\n ///\n function seizeAndSplit(bytes32 _bondId, address[] calldata _claimRecipients) external;\n\n /// @notice Reclaims the bond of the bond owner.\n /// @dev This function will revert if there is no bond at the given id.\n /// @param _bondId is the id of the bond.\n function reclaim(bytes32 _bondId) external;\n}\n"},"@eth-optimism/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"../../libraries/DisputeTypes.sol\";\n\nimport { IBondManager } from \"./IBondManager.sol\";\nimport { IInitializable } from \"./IInitializable.sol\";\n\n/// @title IDisputeGame\n/// @notice The generic interface for a DisputeGame contract.\ninterface IDisputeGame is IInitializable {\n /// @notice Emitted when the game is resolved.\n /// @param status The status of the game after resolution.\n event Resolved(GameStatus indexed status);\n\n /// @notice Returns the timestamp that the DisputeGame contract was created at.\n /// @return createdAt_ The timestamp that the DisputeGame contract was created at.\n function createdAt() external view returns (Timestamp createdAt_);\n\n /// @notice Returns the current status of the game.\n /// @return status_ The current status of the game.\n function status() external view returns (GameStatus status_);\n\n /// @notice Getter for the game type.\n /// @dev The reference impl should be entirely different depending on the type (fault, validity)\n /// i.e. The game type should indicate the security model.\n /// @return gameType_ The type of proof system being used.\n function gameType() external pure returns (GameType gameType_);\n\n /// @notice Getter for the root claim.\n /// @dev `clones-with-immutable-args` argument #1\n /// @return rootClaim_ The root claim of the DisputeGame.\n function rootClaim() external pure returns (Claim rootClaim_);\n\n /// @notice Getter for the extra data.\n /// @dev `clones-with-immutable-args` argument #2\n /// @return extraData_ Any extra data supplied to the dispute game contract by the creator.\n function extraData() external pure returns (bytes memory extraData_);\n\n /// @notice Returns the address of the `BondManager` used.\n /// @return bondManager_ The address of the `BondManager` used.\n function bondManager() external view returns (IBondManager bondManager_);\n\n /// @notice If all necessary information has been gathered, this function should mark the game\n /// status as either `CHALLENGER_WINS` or `DEFENDER_WINS` and return the status of\n /// the resolved game. It is at this stage that the bonds should be awarded to the\n /// necessary parties.\n /// @dev May only be called if the `status` is `IN_PROGRESS`.\n /// @return status_ The status of the game after resolution.\n function resolve() external returns (GameStatus status_);\n\n /// @notice A compliant implementation of this interface should return the components of the\n /// game UUID's preimage provided in the cwia payload. The preimage of the UUID is\n /// constructed as `keccak256(gameType . rootClaim . extraData)` where `.` denotes\n /// concatenation.\n /// @return gameType_ The type of proof system being used.\n /// @return rootClaim_ The root claim of the DisputeGame.\n /// @return extraData_ Any extra data supplied to the dispute game contract by the creator.\n function gameData()\n external\n pure\n returns (\n GameType gameType_,\n Claim rootClaim_,\n bytes memory extraData_\n );\n}\n"},"@eth-optimism/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"../../libraries/DisputeTypes.sol\";\n\nimport { IDisputeGame } from \"./IDisputeGame.sol\";\n\n/// @title IDisputeGameFactory\n/// @notice The interface for a DisputeGameFactory contract.\ninterface IDisputeGameFactory {\n /// @notice Emitted when a new dispute game is created\n /// @param disputeProxy The address of the dispute game proxy\n /// @param gameType The type of the dispute game proxy's implementation\n /// @param rootClaim The root claim of the dispute game\n event DisputeGameCreated(\n address indexed disputeProxy,\n GameType indexed gameType,\n Claim indexed rootClaim\n );\n\n /// @notice Emitted when a new game implementation added to the factory\n /// @param impl The implementation contract for the given `GameType`.\n /// @param gameType The type of the DisputeGame.\n event ImplementationSet(address indexed impl, GameType indexed gameType);\n\n /// @notice The total number of dispute games created by this factory.\n /// @return _gameCount The total number of dispute games created by this factory.\n function gameCount() external view returns (uint256 _gameCount);\n\n /// @notice `games` queries an internal mapping that maps the hash of\n /// `gameType ++ rootClaim ++ extraData` to the deployed `DisputeGame` clone.\n /// @dev `++` equates to concatenation.\n /// @param gameType The type of the DisputeGame - used to decide the proxy implementation\n /// @param rootClaim The root claim of the DisputeGame.\n /// @param extraData Any extra data that should be provided to the created dispute game.\n /// @return _proxy The clone of the `DisputeGame` created with the given parameters.\n /// Returns `address(0)` if nonexistent.\n /// @return _timestamp The timestamp of the creation of the dispute game.\n function games(\n GameType gameType,\n Claim rootClaim,\n bytes calldata extraData\n ) external view returns (IDisputeGame _proxy, uint256 _timestamp);\n\n /// @notice `gameAtIndex` returns the dispute game contract address and its creation timestamp\n /// at the given index. Each created dispute game increments the underlying index.\n /// @param _index The index of the dispute game.\n /// @return _proxy The clone of the `DisputeGame` created with the given parameters.\n /// Returns `address(0)` if nonexistent.\n /// @return _timestamp The timestamp of the creation of the dispute game.\n function gameAtIndex(uint256 _index)\n external\n view\n returns (IDisputeGame _proxy, uint256 _timestamp);\n\n /// @notice `gameImpls` is a mapping that maps `GameType`s to their respective\n /// `IDisputeGame` implementations.\n /// @param gameType The type of the dispute game.\n /// @return _impl The address of the implementation of the game type.\n /// Will be cloned on creation of a new dispute game with the given `gameType`.\n function gameImpls(GameType gameType) external view returns (IDisputeGame _impl);\n\n /// @notice Creates a new DisputeGame proxy contract.\n /// @param gameType The type of the DisputeGame - used to decide the proxy implementation.\n /// @param rootClaim The root claim of the DisputeGame.\n /// @param extraData Any extra data that should be provided to the created dispute game.\n /// @return proxy The address of the created DisputeGame proxy.\n function create(\n GameType gameType,\n Claim rootClaim,\n bytes calldata extraData\n ) external returns (IDisputeGame proxy);\n\n /// @notice Sets the implementation contract for a specific `GameType`.\n /// @dev May only be called by the `owner`.\n /// @param gameType The type of the DisputeGame.\n /// @param impl The implementation contract for the given `GameType`.\n function setImplementation(GameType gameType, IDisputeGame impl) external;\n\n /// @notice Returns a unique identifier for the given dispute game parameters.\n /// @dev Hashes the concatenation of `gameType . rootClaim . extraData`\n /// without expanding memory.\n /// @param gameType The type of the DisputeGame.\n /// @param rootClaim The root claim of the DisputeGame.\n /// @param extraData Any extra data that should be provided to the created dispute game.\n /// @return _uuid The unique identifier for the given dispute game parameters.\n function getGameUUID(\n GameType gameType,\n Claim rootClaim,\n bytes memory extraData\n ) external pure returns (Hash _uuid);\n}\n"},"@eth-optimism/contracts-bedrock/src/dispute/interfaces/IInitializable.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\n/// @title IInitializable\n/// @notice An interface for initializable contracts.\ninterface IInitializable {\n /// @notice Initializes the contract.\n /// @dev This function may only be called once.\n function initialize() external;\n}\n"},"@eth-optimism/contracts-bedrock/src/dispute/lib/LibClock.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"../../libraries/DisputeTypes.sol\";\n\n/// @title LibClock\n/// @notice This library contains helper functions for working with the `Clock` type.\nlibrary LibClock {\n /// @notice Packs a `Duration` and `Timestamp` into a `Clock` type.\n /// @param _duration The `Duration` to pack into the `Clock` type.\n /// @param _timestamp The `Timestamp` to pack into the `Clock` type.\n /// @return clock_ The `Clock` containing the `_duration` and `_timestamp`.\n function wrap(Duration _duration, Timestamp _timestamp) internal pure returns (Clock clock_) {\n assembly {\n clock_ := or(shl(0x40, _duration), _timestamp)\n }\n }\n\n /// @notice Pull the `Duration` out of a `Clock` type.\n /// @param _clock The `Clock` type to pull the `Duration` out of.\n /// @return duration_ The `Duration` pulled out of `_clock`.\n function duration(Clock _clock) internal pure returns (Duration duration_) {\n // Shift the high-order 64 bits into the low-order 64 bits, leaving only the `duration`.\n assembly {\n duration_ := shr(0x40, _clock)\n }\n }\n\n /// @notice Pull the `Timestamp` out of a `Clock` type.\n /// @param _clock The `Clock` type to pull the `Timestamp` out of.\n /// @return timestamp_ The `Timestamp` pulled out of `_clock`.\n function timestamp(Clock _clock) internal pure returns (Timestamp timestamp_) {\n // Clean the high-order 192 bits by shifting the clock left and then right again, leaving\n // only the `timestamp`.\n assembly {\n timestamp_ := shr(0xC0, shl(0xC0, _clock))\n }\n }\n}\n"},"@eth-optimism/contracts-bedrock/src/dispute/lib/LibHashing.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"../../libraries/DisputeTypes.sol\";\n\n/// @title Hashing\n/// @notice This library contains all of the hashing utilities used in the Cannon contracts.\nlibrary LibHashing {\n\n /// @notice Hashes a claim and a position together.\n /// @param _claim A Claim type.\n /// @param _position The position of `claim`.\n /// @return claimHash_ A hash of abi.encodePacked(claim, position);\n function hashClaimPos(Claim _claim, Position _position) internal pure returns (ClaimHash claimHash_) {\n assembly {\n mstore(0x00, _claim)\n mstore(0x20, _position)\n claimHash_ := keccak256(0x00, 0x40)\n }\n }\n}\n"},"@eth-optimism/contracts-bedrock/src/dispute/lib/LibPosition.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport \"../../libraries/DisputeTypes.sol\";\n\n/// @title LibPosition\n/// @notice This library contains helper functions for working with the `Position` type.\nlibrary LibPosition {\n\n /// @notice Computes a generalized index (2^{depth} + indexAtDepth).\n /// @param _depth The depth of the position.\n /// @param _indexAtDepth The index at the depth of the position.\n /// @return position_ The computed generalized index.\n function wrap(uint64 _depth, uint64 _indexAtDepth) internal pure returns (Position position_) {\n assembly {\n // gindex = 2^{_depth} + _indexAtDepth\n position_ := add(shl(_depth, 1), _indexAtDepth)\n }\n }\n\n /// @notice Pulls the `depth` out of a `Position` type.\n /// @param _position The generalized index to get the `depth` of.\n /// @return depth_ The `depth` of the `position` gindex.\n /// @custom:attribution Solady <https://github.com/Vectorized/Solady>\n function depth(Position _position) internal pure returns (uint64 depth_) {\n // Return the most significant bit offset, which signifies the depth of the gindex.\n assembly {\n depth_ := or(depth_, shl(6, lt(0xffffffffffffffff, shr(depth_, _position))))\n depth_ := or(depth_, shl(5, lt(0xffffffff, shr(depth_, _position))))\n\n // For the remaining 32 bits, use a De Bruijn lookup.\n _position := shr(depth_, _position)\n _position := or(_position, shr(1, _position))\n _position := or(_position, shr(2, _position))\n _position := or(_position, shr(4, _position))\n _position := or(_position, shr(8, _position))\n _position := or(_position, shr(16, _position))\n\n depth_ := or(\n depth_,\n byte(\n shr(251, mul(_position, shl(224, 0x07c4acdd))),\n 0x0009010a0d15021d0b0e10121619031e080c141c0f111807131b17061a05041f\n )\n )\n }\n }\n\n /// @notice Pulls the `indexAtDepth` out of a `Position` type.\n /// The `indexAtDepth` is the left/right index of a position at a specific depth within\n /// the binary tree, starting from index 0. For example, at gindex 2, the `depth` = 1\n /// and the `indexAtDepth` = 0.\n /// @param _position The generalized index to get the `indexAtDepth` of.\n /// @return indexAtDepth_ The `indexAtDepth` of the `position` gindex.\n function indexAtDepth(Position _position) internal pure returns (uint64 indexAtDepth_) {\n // Return bits p_{msb-1}...p_{0}. This effectively pulls the 2^{depth} out of the gindex,\n // leaving only the `indexAtDepth`.\n uint256 msb = depth(_position);\n assembly {\n indexAtDepth_ := sub(_position, shl(msb, 1))\n }\n }\n\n /// @notice Get the left child of `_position`.\n /// @param _position The position to get the left position of.\n /// @return left_ The position to the left of `position`.\n function left(Position _position) internal pure returns (Position left_) {\n assembly {\n left_ := shl(1, _position)\n }\n }\n\n /// @notice Get the right child of `_position`\n /// @param _position The position to get the right position of.\n /// @return right_ The position to the right of `position`.\n function right(Position _position) internal pure returns (Position right_) {\n assembly {\n right_ := or(1, shl(1, _position))\n }\n }\n\n /// @notice Get the parent position of `_position`.\n /// @param _position The position to get the parent position of.\n /// @return parent_ The parent position of `position`.\n function parent(Position _position) internal pure returns (Position parent_) {\n assembly {\n parent_ := shr(1, _position)\n }\n }\n\n /// @notice Get the deepest, right most gindex relative to the `position`. This is equivalent to\n /// calling `right` on a position until the maximum depth is reached.\n /// @param _position The position to get the relative deepest, right most gindex of.\n /// @param _maxDepth The maximum depth of the game.\n /// @return rightIndex_ The deepest, right most gindex relative to the `position`.\n function rightIndex(\n Position _position,\n uint256 _maxDepth\n ) internal pure returns (Position rightIndex_) {\n uint256 msb = depth(_position);\n assembly {\n let remaining := sub(_maxDepth, msb)\n rightIndex_ := or(shl(remaining, _position), sub(shl(remaining, 1), 1))\n }\n }\n\n /// @notice Get the deepest, right most trace index relative to the `position`. This is\n /// equivalent to calling `right` on a position until the maximum depth is reached and\n /// then finding its index at depth.\n /// @param _position The position to get the relative trace index of.\n /// @param _maxDepth The maximum depth of the game.\n /// @return traceIndex_ The trace index relative to the `position`.\n function traceIndex(\n Position _position,\n uint256 _maxDepth\n ) internal pure returns (uint256 traceIndex_) {\n uint256 msb = depth(_position);\n assembly {\n let remaining := sub(_maxDepth, msb)\n traceIndex_ := sub(\n or(shl(remaining, _position), sub(shl(remaining, 1), 1)),\n shl(_maxDepth, 1)\n )\n }\n }\n\n /// @notice Gets the position of the highest ancestor of `_position` that commits to the same\n /// trace index.\n /// @param _position The position to get the highest ancestor of.\n /// @return ancestor_ The highest ancestor of `position` that commits to the same trace index.\n function traceAncestor(Position _position) internal pure returns (Position ancestor_) {\n // Create a field with only the lowest unset bit of `_position` set.\n Position lsb;\n assembly {\n lsb := and(not(_position), add(_position, 1))\n }\n // Find the index of the lowest unset bit within the field.\n uint256 msb = depth(lsb);\n // The highest ancestor that commits to the same trace index is the original position\n // shifted right by the index of the lowest unset bit.\n assembly {\n let a := shr(msb, _position)\n // Bound the ancestor to the minimum gindex, 1.\n ancestor_ := or(a, iszero(a))\n }\n }\n\n /// @notice Get the move position of `_position`, which is the left child of:\n /// 1. `_position + 1` if `_isAttack` is true.\n /// 1. `_position` if `_isAttack` is false.\n /// @param _position The position to get the relative attack/defense position of.\n /// @param _isAttack Whether or not the move is an attack move.\n /// @return move_ The move position relative to `position`.\n function move(Position _position, bool _isAttack) internal pure returns (Position move_) {\n assembly {\n move_ := shl(1, or(iszero(_isAttack), _position))\n }\n }\n}\n"},"@eth-optimism/contracts-bedrock/src/libraries/DisputeTypes.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport { LibHashing } from \"../dispute/lib/LibHashing.sol\";\nimport { LibPosition } from \"../dispute/lib/LibPosition.sol\";\nimport { LibClock } from \"../dispute/lib/LibClock.sol\";\n\nusing LibHashing for Claim global;\nusing LibPosition for Position global;\nusing LibClock for Clock global;\n\n/// @notice A custom type for a generic hash.\ntype Hash is bytes32;\n\n/// @notice A claim represents an MPT root representing the state of the fault proof program.\ntype Claim is bytes32;\n\n/// @notice A claim hash represents a hash of a claim and a position within the game tree.\n/// @dev Keccak hash of abi.encodePacked(Claim, Position);\ntype ClaimHash is bytes32;\n\n/// @notice A bondamount represents the amount of collateral that a user has locked up in a claim.\ntype BondAmount is uint256;\n\n/// @notice A dedicated timestamp type.\ntype Timestamp is uint64;\n\n/// @notice A dedicated duration type.\n/// @dev Unit: seconds\ntype Duration is uint64;\n\n/// @notice A `GameId` represents a packed 12 byte timestamp and a 20 byte address.\n/// @dev The packed layout of this type is as follows:\n/// ┌────────────┬────────────────┐\n/// │ Bits │ Value │\n/// ├────────────┼────────────────┤\n/// │ [0, 96) │ Timestamp │\n/// │ [96, 256) │ Address │\n/// └────────────┴────────────────┘\ntype GameId is bytes32;\n\n/// @notice A `Clock` represents a packed `Duration` and `Timestamp`\n/// @dev The packed layout of this type is as follows:\n/// ┌────────────┬────────────────┐\n/// │ Bits │ Value │\n/// ├────────────┼────────────────┤\n/// │ [0, 64) │ Duration │\n/// │ [64, 128) │ Timestamp │\n/// └────────────┴────────────────┘\ntype Clock is uint128;\n\n/// @notice A `Position` represents a position of a claim within the game tree.\n/// @dev This is represented as a \"generalized index\" where the high-order bit\n/// is the level in the tree and the remaining bits is a unique bit pattern, allowing\n/// a unique identifier for each node in the tree. Mathematically, it is calculated\n/// as 2^{depth} + indexAtDepth.\ntype Position is uint128;\n\n/// @notice A `GameType` represents the type of game being played.\ntype GameType is uint8;\n\n/// @notice The current status of the dispute game.\nenum GameStatus {\n // The game is currently in progress, and has not been resolved.\n IN_PROGRESS,\n // The game has concluded, and the `rootClaim` was challenged successfully.\n CHALLENGER_WINS,\n // The game has concluded, and the `rootClaim` could not be contested.\n DEFENDER_WINS\n}\n\n/// @title GameTypes\n/// @notice A library that defines the IDs of games that can be played.\nlibrary GameTypes {\n /// @dev The game will use a `IDisputeGame` implementation that utilizes fault proofs.\n GameType internal constant FAULT = GameType.wrap(0);\n\n /// @dev The game will use a `IDisputeGame` implementation that utilizes validity proofs.\n GameType internal constant VALIDITY = GameType.wrap(1);\n\n /// @dev The game will use a `IDisputeGame` implementation that utilizes attestation proofs.\n GameType internal constant ATTESTATION = GameType.wrap(2);\n}\n"},"@openzeppelin/contracts/token/ERC1155/ERC1155.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/ERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC1155.sol\";\nimport \"./IERC1155Receiver.sol\";\nimport \"./extensions/IERC1155MetadataURI.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/introspection/ERC165.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 ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {\n using Address 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 constructor(string memory uri_) {\n _setURI(uri_);\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC1155).interfaceId ||\n interfaceId == type(IERC1155MetadataURI).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 uint256[] memory ids = _asSingletonArray(id);\n uint256[] memory amounts = _asSingletonArray(amount);\n\n _beforeTokenTransfer(operator, from, to, ids, amounts, 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 _afterTokenTransfer(operator, from, to, ids, amounts, data);\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 _afterTokenTransfer(operator, from, to, ids, amounts, data);\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 uint256[] memory ids = _asSingletonArray(id);\n uint256[] memory amounts = _asSingletonArray(amount);\n\n _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);\n\n _balances[id][to] += amount;\n emit TransferSingle(operator, address(0), to, id, amount);\n\n _afterTokenTransfer(operator, address(0), to, ids, amounts, data);\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 _afterTokenTransfer(operator, address(0), to, ids, amounts, data);\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 uint256[] memory ids = _asSingletonArray(id);\n uint256[] memory amounts = _asSingletonArray(amount);\n\n _beforeTokenTransfer(operator, from, address(0), ids, amounts, \"\");\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 _afterTokenTransfer(operator, from, address(0), ids, amounts, \"\");\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 _afterTokenTransfer(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 /**\n * @dev Hook that is called after 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 _afterTokenTransfer(\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 IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {\n if (response != IERC1155Receiver.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 IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (\n bytes4 response\n ) {\n if (response != IERC1155Receiver.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"},"@openzeppelin/contracts/token/ERC1155/IERC1155.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/IERC165.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 IERC1155 is IERC165 {\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"},"@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"},"@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155URIStorage.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../../utils/Strings.sol\";\nimport \"../ERC1155.sol\";\n\n/**\n * @dev ERC1155 token with storage based token URI management.\n * Inspired by the ERC721URIStorage extension\n *\n * _Available since v4.6._\n */\nabstract contract ERC1155URIStorage is ERC1155 {\n using Strings for uint256;\n\n // Optional base URI\n string private _baseURI = \"\";\n\n // Optional mapping for token URIs\n mapping(uint256 => string) private _tokenURIs;\n\n /**\n * @dev See {IERC1155MetadataURI-uri}.\n *\n * This implementation returns the concatenation of the `_baseURI`\n * and the token-specific uri if the latter is set\n *\n * This enables the following behaviors:\n *\n * - if `_tokenURIs[tokenId]` is set, then the result is the concatenation\n * of `_baseURI` and `_tokenURIs[tokenId]` (keep in mind that `_baseURI`\n * is empty per default);\n *\n * - if `_tokenURIs[tokenId]` is NOT set then we fallback to `super.uri()`\n * which in most cases will contain `ERC1155._uri`;\n *\n * - if `_tokenURIs[tokenId]` is NOT set, and if the parents do not have a\n * uri value set, then the result is empty.\n */\n function uri(uint256 tokenId) public view virtual override returns (string memory) {\n string memory tokenURI = _tokenURIs[tokenId];\n\n // If token URI is set, concatenate base URI and tokenURI (via abi.encodePacked).\n return bytes(tokenURI).length > 0 ? string(abi.encodePacked(_baseURI, tokenURI)) : super.uri(tokenId);\n }\n\n /**\n * @dev Sets `tokenURI` as the tokenURI of `tokenId`.\n */\n function _setURI(uint256 tokenId, string memory tokenURI) internal virtual {\n _tokenURIs[tokenId] = tokenURI;\n emit URI(uri(tokenId), tokenId);\n }\n\n /**\n * @dev Sets `baseURI` as the `_baseURI` for all tokens\n */\n function _setBaseURI(string memory baseURI) internal virtual {\n _baseURI = baseURI;\n }\n}\n"},"@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.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 \"../IERC1155.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 IERC1155MetadataURI is IERC1155 {\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"},"@openzeppelin/contracts/utils/Address.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 Address {\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 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"},"@openzeppelin/contracts/utils/Base64.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Base64.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides a set of functions to operate with Base64 strings.\n *\n * _Available since v4.5._\n */\nlibrary Base64 {\n /**\n * @dev Base64 Encoding/Decoding Table\n */\n string internal constant _TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n /**\n * @dev Converts a `bytes` to its Bytes64 `string` representation.\n */\n function encode(bytes memory data) internal pure returns (string memory) {\n /**\n * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence\n * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol\n */\n if (data.length == 0) return \"\";\n\n // Loads the table into memory\n string memory table = _TABLE;\n\n // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter\n // and split into 4 numbers of 6 bits.\n // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up\n // - `data.length + 2` -> Round up\n // - `/ 3` -> Number of 3-bytes chunks\n // - `4 *` -> 4 characters for each chunk\n string memory result = new string(4 * ((data.length + 2) / 3));\n\n assembly {\n // Prepare the lookup table (skip the first \"length\" byte)\n let tablePtr := add(table, 1)\n\n // Prepare result pointer, jump over length\n let resultPtr := add(result, 32)\n\n // Run over the input, 3 bytes at a time\n for {\n let dataPtr := data\n let endPtr := add(data, mload(data))\n } lt(dataPtr, endPtr) {\n\n } {\n // Advance 3 bytes\n dataPtr := add(dataPtr, 3)\n let input := mload(dataPtr)\n\n // To write each character, shift the 3 bytes (18 bits) chunk\n // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)\n // and apply logical AND with 0x3F which is the number of\n // the previous character in the ASCII table prior to the Base64 Table\n // The result is then added to the table to get the character to write,\n // and finally write it in the result pointer but with a left shift\n // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n\n mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))\n resultPtr := add(resultPtr, 1) // Advance\n }\n\n // When data `bytes` is not exactly 3 bytes long\n // it is padded with `=` characters at the end\n switch mod(mload(data), 3)\n case 1 {\n mstore8(sub(resultPtr, 1), 0x3d)\n mstore8(sub(resultPtr, 2), 0x3d)\n }\n case 2 {\n mstore8(sub(resultPtr, 1), 0x3d)\n }\n }\n\n return result;\n }\n}\n"},"@openzeppelin/contracts/utils/Context.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"},"@openzeppelin/contracts/utils/Strings.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 Strings {\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"},"@openzeppelin/contracts/utils/introspection/ERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"},"@openzeppelin/contracts/utils/introspection/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},"project:/contracts/ERC1155ChallengeableMint.sol":{"content":"//SPDX-License-Identifier: MIT\npragma solidity ^0.8.15;\n\nimport { Base64 } from \"@openzeppelin/contracts/utils/Base64.sol\";\nimport { ERC1155URIStorage, ERC1155 } from \"@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol\";\nimport { IDisputeGameFactory } from \"@eth-optimism/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol\";\nimport { IDisputeGame } from \"@eth-optimism/contracts-bedrock/src/dispute/interfaces/IDisputeGame.sol\";\nimport { GameTypes, Claim, GameStatus } from \"@eth-optimism/contracts-bedrock/src/libraries/DisputeTypes.sol\";\n\n/**\n* @title ERC1155ChallengeableMint\n* @dev This contract allows for the creation of ERC1155 tokens through a two stage minting process\n*\n* The first stage is a proposal stage where a user can propose a new token to be minted\n* during a challenge period anyone who disputes the validity of the token can challenge it by\n* initiating a dispute game. If the challenger wins the dispute game\n* the token is not minted and its proposal cancelled.\n*\n* The second stage is a claim where the original proposer can receive an actual NFT\n* if it remains unchallenged for sufficiently long.\n*\n* ---\n*\n* This contract uses on-chain metadata since the metadata itself is required to check the\n* validity of the token. This may be expensive for large metadata.\n*/\ncontract ERC1155ChallengeableMint is ERC1155URIStorage {\n\n /// @dev Represents a token that has yet to be minted. It must persist\n /// for at least SETTLEMENT_PERIOD before it can be minted for real\n struct PendingMint {\n /// The address that will receive the token once minted\n address to;\n /// metadata is not stored, only the hash\n bytes32 metadataHash;\n /// hash of public input data to provable computation\n bytes32 witnessHash;\n /// block timestamp when proposal created\n uint256 timestamp;\n }\n\n /// @dev The amount of time that must pass before a pending mint can be minted\n uint256 public constant SETTLEMENT_PERIOD = 1 minutes;\n\n /// @dev The hash of the code to be run in the provable execution\n Claim public immutable ROOT_CLAIM;\n\n /// @dev The dispute game factory used to create and track open disputes\n IDisputeGameFactory public immutable disputeGameFactory;\n \n /// @dev Used to generate a fresh token ID for each token\n uint256 public nonce;\n\n /// @dev Mapping from token nonce to mintable status\n mapping(uint256 => PendingMint) public pendingMints;\n\n\n event MintProposed(uint256 indexed id, address to, uint256 timestamp);\n event MintChallenged(uint256 indexed id, address challenger);\n event Minted(uint256 indexed id, address indexed to);\n\n error MintProposalNotSettled(uint256 id);\n error ProposalHasOpenChallenge(uint256 id);\n error ProposalClaimDisproven(uint256 id);\n error MetadataHashMismatch(uint256 id);\n error CannotChallengeProposalHasSettled(uint256 id);\n\n\n /**\n * @dev Construct a new NFTCollection contract.\n */\n constructor(address disputeGameFactoryAddr, Claim rootClaim) ERC1155(\"\") {\n disputeGameFactory = IDisputeGameFactory(disputeGameFactoryAddr);\n ROOT_CLAIM = rootClaim;\n _setBaseURI(\"data:application/json;base64,\");\n }\n\n /**\n * @dev Propose a new mint.\n * @param metadataJson The string of metadata.json to associate with the token.\n * @param witness The witness given as input to the provable program \n * to produce this metadata output.\n * This must be provided in calldata so watchers can replicate the computation\n */\n function ProposeMint(address to, string calldata metadataJson, bytes calldata witness) external {\n uint256 id = nonce++;\n pendingMints[id] = PendingMint({\n to: to,\n metadataHash: keccak256(bytes(metadataJson)),\n witnessHash: keccak256(witness),\n timestamp: block.timestamp\n });\n emit MintProposed(id, to, block.timestamp);\n }\n\n /**\n * @dev Challenge a pending mint.\n * This will lead to the creation of a challenge game on this mint.\n * The winner of the game receives 1/2 the bond from the opponent.\n * The rest goes into the dev fund :)\n * @param id The ID of the pending mint to challenge\n */\n function ChallengeMint(uint256 id) external {\n PendingMint memory proposal = pendingMints[id];\n\n if (block.timestamp > proposal.timestamp + SETTLEMENT_PERIOD)\n revert CannotChallengeProposalHasSettled(id);\n\n disputeGameFactory.create(\n GameTypes.FAULT,\n ROOT_CLAIM,\n bytes(abi.encodePacked(proposal.to, proposal.metadataHash, proposal.witnessHash, proposal.timestamp))\n );\n\n emit MintChallenged(id, msg.sender);\n }\n\n /**\n * @dev Mint a new token with the given metadata.\n * @param id The ID of the pending mint (will also be the ID of the token)\n * @param metadataJson The string of metadata.json to associate with the token.\n * Must match the hash stored in pending\n */\n function ClaimMint(uint256 id, string memory metadataJson) external {\n PendingMint storage proposal = pendingMints[id];\n\n if (block.timestamp <= proposal.timestamp + SETTLEMENT_PERIOD)\n revert MintProposalNotSettled(id);\n\n if (proposal.metadataHash != keccak256(bytes(metadataJson)))\n revert MetadataHashMismatch(id);\n\n // see if there is an open challenge\n (IDisputeGame game,) = disputeGameFactory.games(\n GameTypes.FAULT,\n ROOT_CLAIM,\n bytes(abi.encodePacked(proposal.to, proposal.metadataHash, proposal.witnessHash, proposal.timestamp))\n );\n if (address(game) != address(0) && game.status() == GameStatus.IN_PROGRESS) {\n revert ProposalHasOpenChallenge(id);\n }\n if (address(game) != address(0) && game.status() == GameStatus.DEFENDER_WINS) {\n revert ProposalClaimDisproven(id);\n }\n\n _mint(proposal.to, id, 1, \"\");\n _setURI(id, Base64.encode(bytes(metadataJson)));\n delete pendingMints[id];\n\n emit Minted(id, proposal.to);\n }\n\n /**\n * @dev Get the address of the dispute game for the given pending mint\n */\n function gameAddress(uint256 id) public view returns (IDisputeGame game) {\n PendingMint memory proposal = pendingMints[id];\n (game,) = disputeGameFactory.games(\n GameTypes.FAULT,\n ROOT_CLAIM,\n bytes(abi.encodePacked(proposal.to, proposal.metadataHash, proposal.witnessHash, proposal.timestamp))\n );\n }\n}\n"}},"settings":{"remappings":[],"optimizer":{"enabled":false,"runs":200},"evmVersion":"london"}}