Skip to content

Commit

Permalink
feat(DK): add permission for flushing
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownunknown1 committed Jul 31, 2024
1 parent 87bc6c0 commit 748c9b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
10 changes: 5 additions & 5 deletions contracts/src/arbitration/KlerosCoreBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -471,19 +471,19 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
_setStake(msg.sender, _courtID, _newStake, false, OnError.Revert);
}

/// @dev Sets the stake of a specified account in a court, typically to apply a delayed stake or unstake inactive jurors.
/// @dev Sets the stake of a specified account in a court, typically to apply a delayed stake or unstake inactive/ineligible jurors.
/// @param _account The account whose stake is being set.
/// @param _courtID The ID of the court.
/// @param _newStake The new stake.
/// @param _alreadyTransferred Whether the PNKs have already been transferred to the contract.
function setStakeBySortitionModule(
function setStakeBySortitionModuleOrDK(
address _account,
uint96 _courtID,
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();
if (msg.sender != address(sortitionModule) && disputeKitIDs[IDisputeKit(msg.sender)] == 0)
revert SortitionModuleOrDKOnly();
_setStake(_account, _courtID, _newStake, _alreadyTransferred, OnError.Return);
}

Expand Down Expand Up @@ -1148,7 +1148,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
error GovernorOnly();
error GuardianOrGovernorOnly();
error DisputeKitOnly();
error SortitionModuleOnly();
error SortitionModuleOrDKOnly();
error UnsuccessfulCall();
error InvalidDisputKitParent();
error DepthLevelMax();
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/arbitration/SortitionModuleBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ abstract contract SortitionModuleBase is ISortitionModule {
DelayedStake storage delayedStake = delayedStakes[i];
// Delayed stake could've been manually removed already. In this case simply move on to the next item.
if (delayedStake.account != address(0)) {
core.setStakeBySortitionModule(
core.setStakeBySortitionModuleOrDK(
delayedStake.account,
delayedStake.courtID,
delayedStake.stake,
Expand Down Expand Up @@ -433,7 +433,7 @@ abstract contract SortitionModuleBase is ISortitionModule {
function setJurorInactive(address _account) external override onlyByCore {
uint96[] memory courtIDs = getJurorCourtIDs(_account);
for (uint256 j = courtIDs.length; j > 0; j--) {
core.setStakeBySortitionModule(_account, courtIDs[j - 1], 0, false);
core.setStakeBySortitionModuleOrDK(_account, courtIDs[j - 1], 0, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ contract DisputeKitSybilResistant is IDisputeKit, Initializable, UUPSProxiable {
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);
core.setStakeBySortitionModuleOrDK(_juror, courtID, 0, false);
}
}

Expand Down

0 comments on commit 748c9b0

Please sign in to comment.