Skip to content

Commit

Permalink
feat(DisputeKit): add flushing feature
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownunknown1 committed Jul 17, 2024
1 parent a1dff3b commit 9fb2cf1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/src/arbitration/KlerosCoreBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
Court[] public courts; // The courts.
IDisputeKit[] public disputeKits; // Array of dispute kits.
Dispute[] public disputes; // The disputes.
mapping(IDisputeKit => uint256) public disputeKitIDs; // Maps dispute kit's address to its index.
mapping(IERC20 => CurrencyRate) public currencyRates; // The price of each token in ETH.
bool public paused; // Whether asset withdrawals are paused.

Expand Down Expand Up @@ -216,6 +217,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {

// DISPUTE_KIT_CLASSIC
disputeKits.push(_disputeKit);
disputeKitIDs[_disputeKit] = DISPUTE_KIT_CLASSIC;

emit DisputeKitCreated(DISPUTE_KIT_CLASSIC, _disputeKit);

Expand Down Expand Up @@ -316,6 +318,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
function addNewDisputeKit(IDisputeKit _disputeKitAddress) external onlyByGovernor {
uint256 disputeKitID = disputeKits.length;
disputeKits.push(_disputeKitAddress);
disputeKitIDs[_disputeKitAddress] = disputeKitID;
emit DisputeKitCreated(disputeKitID, _disputeKitAddress);
}

Expand Down Expand Up @@ -479,6 +482,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
uint256 _newStake,
bool _alreadyTransferred
) external {
// TODO: generalize this function so it can be used by DK too. Rename to setStakeWhitelist or something. So it can be done for someone not just for sender.
if (msg.sender != address(sortitionModule)) revert SortitionModuleOnly();
_setStake(_account, _courtID, _newStake, _alreadyTransferred, OnError.Return);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,21 @@ contract DisputeKitSybilResistant is IDisputeKit, Initializable, UUPSProxiable {
}
}

/// @dev Unstakes the jurors who are not eligible for drawing, so they don't interfere with the drawing process.
/// Can be called by anyone. The juror will be unstaked if he doesn't pass the check specific to this DK.
/// @param _juror The juror to unstake.
/// @param _courts The courts to unstake from. Note that each court must support this DK.
function flush(address _juror, uint96[] memory _courts) external {
require(!_proofOfHumanity(_juror), "The juror is eligible");
uint256 disputeKitID = core.disputeKitIDs(this);
for (uint256 i = 0; i < _courts.length; i++) {
uint96 courtID = _courts[i];
require(core.isSupported(courtID, disputeKitID), "DK not supported by court");
// TODO: generalize the function name and its permission.
core.setStakeBySortitionModule(_juror, courtID, 0, false);
}
}

// ************************************* //
// * Public Views * //
// ************************************* //
Expand Down

0 comments on commit 9fb2cf1

Please sign in to comment.