github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/src/dispute/interfaces/IDisputeGameFactory.sol (about) 1 // SPDX-License-Identifier: MIT 2 pragma solidity ^0.8.0; 3 4 import { IDisputeGame } from "./IDisputeGame.sol"; 5 6 import "src/libraries/DisputeTypes.sol"; 7 8 /// @title IDisputeGameFactory 9 /// @notice The interface for a DisputeGameFactory contract. 10 interface IDisputeGameFactory { 11 /// @notice Emitted when a new dispute game is created 12 /// @param disputeProxy The address of the dispute game proxy 13 /// @param gameType The type of the dispute game proxy's implementation 14 /// @param rootClaim The root claim of the dispute game 15 event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim); 16 17 /// @notice Emitted when a new game implementation added to the factory 18 /// @param impl The implementation contract for the given `GameType`. 19 /// @param gameType The type of the DisputeGame. 20 event ImplementationSet(address indexed impl, GameType indexed gameType); 21 22 /// @notice Emitted when a game type's initialization bond is updated 23 /// @param gameType The type of the DisputeGame. 24 /// @param newBond The new bond (in wei) for initializing the game type. 25 event InitBondUpdated(GameType indexed gameType, uint256 indexed newBond); 26 27 /// @notice Information about a dispute game found in a `findLatestGames` search. 28 struct GameSearchResult { 29 uint256 index; 30 GameId metadata; 31 Timestamp timestamp; 32 Claim rootClaim; 33 bytes extraData; 34 } 35 36 /// @notice The total number of dispute games created by this factory. 37 /// @return gameCount_ The total number of dispute games created by this factory. 38 function gameCount() external view returns (uint256 gameCount_); 39 40 /// @notice `games` queries an internal mapping that maps the hash of 41 /// `gameType ++ rootClaim ++ extraData` to the deployed `DisputeGame` clone. 42 /// @dev `++` equates to concatenation. 43 /// @param _gameType The type of the DisputeGame - used to decide the proxy implementation 44 /// @param _rootClaim The root claim of the DisputeGame. 45 /// @param _extraData Any extra data that should be provided to the created dispute game. 46 /// @return proxy_ The clone of the `DisputeGame` created with the given parameters. 47 /// Returns `address(0)` if nonexistent. 48 /// @return timestamp_ The timestamp of the creation of the dispute game. 49 function games( 50 GameType _gameType, 51 Claim _rootClaim, 52 bytes calldata _extraData 53 ) 54 external 55 view 56 returns (IDisputeGame proxy_, Timestamp timestamp_); 57 58 /// @notice `gameAtIndex` returns the dispute game contract address and its creation timestamp 59 /// at the given index. Each created dispute game increments the underlying index. 60 /// @param _index The index of the dispute game. 61 /// @return gameType_ The type of the DisputeGame - used to decide the proxy implementation. 62 /// @return timestamp_ The timestamp of the creation of the dispute game. 63 /// @return proxy_ The clone of the `DisputeGame` created with the given parameters. 64 /// Returns `address(0)` if nonexistent. 65 function gameAtIndex(uint256 _index) 66 external 67 view 68 returns (GameType gameType_, Timestamp timestamp_, IDisputeGame proxy_); 69 70 /// @notice `gameImpls` is a mapping that maps `GameType`s to their respective 71 /// `IDisputeGame` implementations. 72 /// @param _gameType The type of the dispute game. 73 /// @return impl_ The address of the implementation of the game type. 74 /// Will be cloned on creation of a new dispute game with the given `gameType`. 75 function gameImpls(GameType _gameType) external view returns (IDisputeGame impl_); 76 77 /// @notice Returns the required bonds for initializing a dispute game of the given type. 78 /// @param _gameType The type of the dispute game. 79 /// @return bond_ The required bond for initializing a dispute game of the given type. 80 function initBonds(GameType _gameType) external view returns (uint256 bond_); 81 82 /// @notice Creates a new DisputeGame proxy contract. 83 /// @param _gameType The type of the DisputeGame - used to decide the proxy implementation. 84 /// @param _rootClaim The root claim of the DisputeGame. 85 /// @param _extraData Any extra data that should be provided to the created dispute game. 86 /// @return proxy_ The address of the created DisputeGame proxy. 87 function create( 88 GameType _gameType, 89 Claim _rootClaim, 90 bytes calldata _extraData 91 ) 92 external 93 payable 94 returns (IDisputeGame proxy_); 95 96 /// @notice Sets the implementation contract for a specific `GameType`. 97 /// @dev May only be called by the `owner`. 98 /// @param _gameType The type of the DisputeGame. 99 /// @param _impl The implementation contract for the given `GameType`. 100 function setImplementation(GameType _gameType, IDisputeGame _impl) external; 101 102 /// @notice Sets the bond (in wei) for initializing a game type. 103 /// @dev May only be called by the `owner`. 104 /// @param _gameType The type of the DisputeGame. 105 /// @param _initBond The bond (in wei) for initializing a game type. 106 function setInitBond(GameType _gameType, uint256 _initBond) external; 107 108 /// @notice Returns a unique identifier for the given dispute game parameters. 109 /// @dev Hashes the concatenation of `gameType . rootClaim . extraData` 110 /// without expanding memory. 111 /// @param _gameType The type of the DisputeGame. 112 /// @param _rootClaim The root claim of the DisputeGame. 113 /// @param _extraData Any extra data that should be provided to the created dispute game. 114 /// @return uuid_ The unique identifier for the given dispute game parameters. 115 function getGameUUID( 116 GameType _gameType, 117 Claim _rootClaim, 118 bytes memory _extraData 119 ) 120 external 121 pure 122 returns (Hash uuid_); 123 124 /// @notice Finds the `_n` most recent `GameId`'s of type `_gameType` starting at `_start`. If there are less than 125 /// `_n` games of type `_gameType` starting at `_start`, then the returned array will be shorter than `_n`. 126 /// @param _gameType The type of game to find. 127 /// @param _start The index to start the reverse search from. 128 /// @param _n The number of games to find. 129 function findLatestGames( 130 GameType _gameType, 131 uint256 _start, 132 uint256 _n 133 ) 134 external 135 view 136 returns (GameSearchResult[] memory games_); 137 }