Skip to content

Commit

Permalink
refactor: base dispute kit
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybuidl committed Dec 18, 2024
1 parent 9303c62 commit 3ac630f
Show file tree
Hide file tree
Showing 11 changed files with 671 additions and 1,736 deletions.
5 changes: 2 additions & 3 deletions contracts/src/arbitration/KlerosCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ pragma solidity 0.8.24;

import "./KlerosCoreBase.sol";
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol";
import {Initializable} from "../proxy/Initializable.sol";

/// @title KlerosCore
/// Core arbitrator contract for Kleros v2.
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
contract KlerosCore is KlerosCoreBase, UUPSProxiable, Initializable {
contract KlerosCore is KlerosCoreBase, UUPSProxiable {
// ************************************* //
// * Constructor * //
// ************************************* //
Expand Down Expand Up @@ -48,7 +47,7 @@ contract KlerosCore is KlerosCoreBase, UUPSProxiable, Initializable {
bytes memory _sortitionExtraData,
ISortitionModule _sortitionModuleAddress
) external reinitializer(1) {
_initialize(
__KlerosCoreBase_initialize(
_governor,
_guardian,
_pinakion,
Expand Down
7 changes: 4 additions & 3 deletions contracts/src/arbitration/KlerosCoreBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ pragma solidity 0.8.24;
import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitratorV2.sol";
import {IDisputeKit} from "./interfaces/IDisputeKit.sol";
import {ISortitionModule} from "./interfaces/ISortitionModule.sol";
import {Initializable} from "../proxy/Initializable.sol";
import {SafeERC20, IERC20} from "../libraries/SafeERC20.sol";
import "../libraries/Constants.sol";

/// @title KlerosCoreBase
/// Core arbitrator contract for Kleros v2.
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
abstract contract KlerosCoreBase is IArbitratorV2 {
abstract contract KlerosCoreBase is IArbitratorV2, Initializable {
using SafeERC20 for IERC20;

// ************************************* //
Expand Down Expand Up @@ -193,7 +194,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
// * Constructor * //
// ************************************* //

function _initialize(
function __KlerosCoreBase_initialize(
address _governor,
address _guardian,
IERC20 _pinakion,
Expand All @@ -204,7 +205,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
uint256[4] memory _timesPerPeriod,
bytes memory _sortitionExtraData,
ISortitionModule _sortitionModuleAddress
) internal {
) internal onlyInitializing {
governor = _governor;
guardian = _guardian;
pinakion = _pinakion;
Expand Down
5 changes: 2 additions & 3 deletions contracts/src/arbitration/KlerosCoreNeo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ pragma solidity 0.8.24;

import "./KlerosCoreBase.sol";
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol";
import {Initializable} from "../proxy/Initializable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

/// @title KlerosCoreNeo
/// Core arbitrator contract for Kleros v2.
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable, Initializable {
contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable {
// ************************************* //
// * Storage * //
// ************************************* //
Expand Down Expand Up @@ -58,7 +57,7 @@ contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable, Initializable {
ISortitionModule _sortitionModuleAddress,
IERC721 _jurorNft
) external reinitializer(2) {
super._initialize(
__KlerosCoreBase_initialize(
_governor,
_guardian,
_pinakion,
Expand Down
5 changes: 2 additions & 3 deletions contracts/src/arbitration/SortitionModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ pragma solidity 0.8.24;

import "./SortitionModuleBase.sol";
import "../proxy/UUPSProxiable.sol";
import "../proxy/Initializable.sol";

/// @title SortitionModule
/// @dev A factory of trees that keeps track of staked values for sortition.
contract SortitionModule is SortitionModuleBase, UUPSProxiable, Initializable {
contract SortitionModule is SortitionModuleBase, UUPSProxiable {
// ************************************* //
// * Constructor * //
// ************************************* //
Expand All @@ -41,7 +40,7 @@ contract SortitionModule is SortitionModuleBase, UUPSProxiable, Initializable {
RNG _rng,
uint256 _rngLookahead
) external reinitializer(1) {
super._initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
__SortitionModuleBase_initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
}

// ************************************* //
Expand Down
7 changes: 4 additions & 3 deletions contracts/src/arbitration/SortitionModuleBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ pragma solidity 0.8.24;
import "./KlerosCore.sol";
import "./interfaces/ISortitionModule.sol";
import "./interfaces/IDisputeKit.sol";
import "../proxy/Initializable.sol";
import "../rng/RNG.sol";
import "../libraries/Constants.sol";

/// @title SortitionModuleBase
/// @dev A factory of trees that keeps track of staked values for sortition.
abstract contract SortitionModuleBase is ISortitionModule {
abstract contract SortitionModuleBase is ISortitionModule, Initializable {
// ************************************* //
// * Enums / Structs * //
// ************************************* //
Expand Down Expand Up @@ -89,14 +90,14 @@ abstract contract SortitionModuleBase is ISortitionModule {
// * Constructor * //
// ************************************* //

function _initialize(
function __SortitionModuleBase_initialize(
address _governor,
KlerosCore _core,
uint256 _minStakingTime,
uint256 _maxDrawingTime,
RNG _rng,
uint256 _rngLookahead
) internal {
) internal onlyInitializing {
governor = _governor;
core = _core;
minStakingTime = _minStakingTime;
Expand Down
5 changes: 2 additions & 3 deletions contracts/src/arbitration/SortitionModuleNeo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ pragma solidity 0.8.24;

import "./SortitionModuleBase.sol";
import "../proxy/UUPSProxiable.sol";
import "../proxy/Initializable.sol";

/// @title SortitionModuleNeo
/// @dev A factory of trees that keeps track of staked values for sortition.
contract SortitionModuleNeo is SortitionModuleBase, UUPSProxiable, Initializable {
contract SortitionModuleNeo is SortitionModuleBase, UUPSProxiable {
// ************************************* //
// * Storage * //
// ************************************* //
Expand Down Expand Up @@ -53,7 +52,7 @@ contract SortitionModuleNeo is SortitionModuleBase, UUPSProxiable, Initializable
uint256 _maxStakePerJuror,
uint256 _maxTotalStaked
) external reinitializer(2) {
super._initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
__SortitionModuleBase_initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
maxStakePerJuror = _maxStakePerJuror;
maxTotalStaked = _maxTotalStaked;
}
Expand Down
Loading

0 comments on commit 3ac630f

Please sign in to comment.