Skip to content

Commit c54d028

Browse files
committed
refactor: base dispute kit
1 parent 9303c62 commit c54d028

10 files changed

+663
-1736
lines changed

contracts/src/arbitration/KlerosCore.sol

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ pragma solidity 0.8.24;
1010

1111
import "./KlerosCoreBase.sol";
1212
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol";
13-
import {Initializable} from "../proxy/Initializable.sol";
1413

1514
/// @title KlerosCore
1615
/// Core arbitrator contract for Kleros v2.
1716
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
18-
contract KlerosCore is KlerosCoreBase, UUPSProxiable, Initializable {
17+
contract KlerosCore is KlerosCoreBase, UUPSProxiable {
1918
// ************************************* //
2019
// * Constructor * //
2120
// ************************************* //
@@ -48,7 +47,7 @@ contract KlerosCore is KlerosCoreBase, UUPSProxiable, Initializable {
4847
bytes memory _sortitionExtraData,
4948
ISortitionModule _sortitionModuleAddress
5049
) external reinitializer(1) {
51-
_initialize(
50+
__KlerosCoreBase_initialize(
5251
_governor,
5352
_guardian,
5453
_pinakion,

contracts/src/arbitration/KlerosCoreBase.sol

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ pragma solidity 0.8.24;
1111
import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitratorV2.sol";
1212
import {IDisputeKit} from "./interfaces/IDisputeKit.sol";
1313
import {ISortitionModule} from "./interfaces/ISortitionModule.sol";
14+
import {Initializable} from "../proxy/Initializable.sol";
1415
import {SafeERC20, IERC20} from "../libraries/SafeERC20.sol";
1516
import "../libraries/Constants.sol";
1617

1718
/// @title KlerosCoreBase
1819
/// Core arbitrator contract for Kleros v2.
1920
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
20-
abstract contract KlerosCoreBase is IArbitratorV2 {
21+
abstract contract KlerosCoreBase is IArbitratorV2, Initializable {
2122
using SafeERC20 for IERC20;
2223

2324
// ************************************* //
@@ -193,7 +194,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
193194
// * Constructor * //
194195
// ************************************* //
195196

196-
function _initialize(
197+
function __KlerosCoreBase_initialize(
197198
address _governor,
198199
address _guardian,
199200
IERC20 _pinakion,
@@ -204,7 +205,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
204205
uint256[4] memory _timesPerPeriod,
205206
bytes memory _sortitionExtraData,
206207
ISortitionModule _sortitionModuleAddress
207-
) internal {
208+
) internal onlyInitializing {
208209
governor = _governor;
209210
guardian = _guardian;
210211
pinakion = _pinakion;

contracts/src/arbitration/KlerosCoreNeo.sol

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ pragma solidity 0.8.24;
1010

1111
import "./KlerosCoreBase.sol";
1212
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol";
13-
import {Initializable} from "../proxy/Initializable.sol";
1413
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
1514

1615
/// @title KlerosCoreNeo
1716
/// Core arbitrator contract for Kleros v2.
1817
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
19-
contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable, Initializable {
18+
contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable {
2019
// ************************************* //
2120
// * Storage * //
2221
// ************************************* //
@@ -58,7 +57,7 @@ contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable, Initializable {
5857
ISortitionModule _sortitionModuleAddress,
5958
IERC721 _jurorNft
6059
) external reinitializer(2) {
61-
super._initialize(
60+
__KlerosCoreBase_initialize(
6261
_governor,
6362
_guardian,
6463
_pinakion,

contracts/src/arbitration/SortitionModule.sol

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ pragma solidity 0.8.24;
1212

1313
import "./SortitionModuleBase.sol";
1414
import "../proxy/UUPSProxiable.sol";
15-
import "../proxy/Initializable.sol";
1615

1716
/// @title SortitionModule
1817
/// @dev A factory of trees that keeps track of staked values for sortition.
19-
contract SortitionModule is SortitionModuleBase, UUPSProxiable, Initializable {
18+
contract SortitionModule is SortitionModuleBase, UUPSProxiable {
2019
// ************************************* //
2120
// * Constructor * //
2221
// ************************************* //
@@ -41,7 +40,7 @@ contract SortitionModule is SortitionModuleBase, UUPSProxiable, Initializable {
4140
RNG _rng,
4241
uint256 _rngLookahead
4342
) external reinitializer(1) {
44-
super._initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
43+
__SortitionModuleBase_initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
4544
}
4645

4746
// ************************************* //

contracts/src/arbitration/SortitionModuleBase.sol

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ pragma solidity 0.8.24;
1313
import "./KlerosCore.sol";
1414
import "./interfaces/ISortitionModule.sol";
1515
import "./interfaces/IDisputeKit.sol";
16+
import "../proxy/Initializable.sol";
1617
import "../rng/RNG.sol";
1718
import "../libraries/Constants.sol";
1819

1920
/// @title SortitionModuleBase
2021
/// @dev A factory of trees that keeps track of staked values for sortition.
21-
abstract contract SortitionModuleBase is ISortitionModule {
22+
abstract contract SortitionModuleBase is ISortitionModule, Initializable {
2223
// ************************************* //
2324
// * Enums / Structs * //
2425
// ************************************* //
@@ -89,14 +90,14 @@ abstract contract SortitionModuleBase is ISortitionModule {
8990
// * Constructor * //
9091
// ************************************* //
9192

92-
function _initialize(
93+
function __SortitionModuleBase_initialize(
9394
address _governor,
9495
KlerosCore _core,
9596
uint256 _minStakingTime,
9697
uint256 _maxDrawingTime,
9798
RNG _rng,
9899
uint256 _rngLookahead
99-
) internal {
100+
) internal onlyInitializing {
100101
governor = _governor;
101102
core = _core;
102103
minStakingTime = _minStakingTime;

contracts/src/arbitration/SortitionModuleNeo.sol

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ pragma solidity 0.8.24;
1212

1313
import "./SortitionModuleBase.sol";
1414
import "../proxy/UUPSProxiable.sol";
15-
import "../proxy/Initializable.sol";
1615

1716
/// @title SortitionModuleNeo
1817
/// @dev A factory of trees that keeps track of staked values for sortition.
19-
contract SortitionModuleNeo is SortitionModuleBase, UUPSProxiable, Initializable {
18+
contract SortitionModuleNeo is SortitionModuleBase, UUPSProxiable {
2019
// ************************************* //
2120
// * Storage * //
2221
// ************************************* //
@@ -53,7 +52,7 @@ contract SortitionModuleNeo is SortitionModuleBase, UUPSProxiable, Initializable
5352
uint256 _maxStakePerJuror,
5453
uint256 _maxTotalStaked
5554
) external reinitializer(2) {
56-
super._initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
55+
__SortitionModuleBase_initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
5756
maxStakePerJuror = _maxStakePerJuror;
5857
maxTotalStaked = _maxTotalStaked;
5958
}

0 commit comments

Comments
 (0)