Commit cd24e96b authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #6028 from ethereum-optimism/refcell/initializedgf

fix(ctb): Initialize DisputeGameFactory in Constructor
parents ae8a3a74 3ea3937e
This diff is collapsed.
...@@ -43,18 +43,17 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, IVersion ...@@ -43,18 +43,17 @@ contract DisputeGameFactory is OwnableUpgradeable, IDisputeGameFactory, IVersion
IDisputeGame[] public disputeGameList; IDisputeGame[] public disputeGameList;
/** /**
* @notice Constructs a new DisputeGameFactory contract. Set the owner * @notice Constructs a new DisputeGameFactory contract.
* to `address(0)` to prevent accidental usage of the implementation.
*/ */
constructor() OwnableUpgradeable() { constructor() OwnableUpgradeable() {
_transferOwnership(address(0)); initialize(address(0));
} }
/** /**
* @notice Initializes the contract. * @notice Initializes the contract.
* @param _owner The owner of the contract. * @param _owner The owner of the contract.
*/ */
function initialize(address _owner) external initializer { function initialize(address _owner) public initializer {
__Ownable_init(); __Ownable_init();
_transferOwnership(_owner); _transferOwnership(_owner);
} }
......
...@@ -29,6 +29,7 @@ contract DisputeGameFactory_Initializer is Test { ...@@ -29,6 +29,7 @@ contract DisputeGameFactory_Initializer is Test {
_data: abi.encodeCall(impl.initialize, (address(this))) _data: abi.encodeCall(impl.initialize, (address(this)))
}); });
factory = DisputeGameFactory(address(proxy)); factory = DisputeGameFactory(address(proxy));
vm.label(address(factory), "DisputeGameFactoryProxy");
} }
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
pragma solidity ^0.8.15; pragma solidity ^0.8.15;
import { Test } from "forge-std/Test.sol"; import { Test } from "forge-std/Test.sol";
import { DisputeGameFactory_Initializer } from "./DisputeGameFactory.t.sol";
import { DisputeGameFactory } from "../dispute/DisputeGameFactory.sol"; import { DisputeGameFactory } from "../dispute/DisputeGameFactory.sol";
import { FaultDisputeGame } from "../dispute/FaultDisputeGame.sol"; import { FaultDisputeGame } from "../dispute/FaultDisputeGame.sol";
...@@ -10,7 +11,7 @@ import "../libraries/DisputeErrors.sol"; ...@@ -10,7 +11,7 @@ import "../libraries/DisputeErrors.sol";
import { LibClock } from "../dispute/lib/LibClock.sol"; import { LibClock } from "../dispute/lib/LibClock.sol";
import { LibPosition } from "../dispute/lib/LibPosition.sol"; import { LibPosition } from "../dispute/lib/LibPosition.sol";
contract FaultDisputeGame_Test is Test { contract FaultDisputeGame_Test is DisputeGameFactory_Initializer {
/** /**
* @dev The root claim of the game. * @dev The root claim of the game.
*/ */
...@@ -28,10 +29,6 @@ contract FaultDisputeGame_Test is Test { ...@@ -28,10 +29,6 @@ contract FaultDisputeGame_Test is Test {
*/ */
string internal constant VERSION = "0.0.1"; string internal constant VERSION = "0.0.1";
/**
* @dev The factory that will be used to create the game.
*/
DisputeGameFactory internal factory;
/** /**
* @dev The implementation of the game. * @dev The implementation of the game.
*/ */
...@@ -43,10 +40,8 @@ contract FaultDisputeGame_Test is Test { ...@@ -43,10 +40,8 @@ contract FaultDisputeGame_Test is Test {
event Move(uint256 indexed parentIndex, Claim indexed pivot, address indexed claimant); event Move(uint256 indexed parentIndex, Claim indexed pivot, address indexed claimant);
function setUp() public { function setUp() public override {
// Deploy a new dispute game factory. super.setUp();
factory = new DisputeGameFactory();
factory.initialize(address(this));
// Deploy an implementation of the fault game // Deploy an implementation of the fault game
gameImpl = new FaultDisputeGame(); gameImpl = new FaultDisputeGame();
// Register the game implementation with the factory. // Register the game implementation with the factory.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment