Skip to content

Commit 4bec363

Browse files
authored
Merge pull request #122 from kleros/feat/add-subcourt-creation-event
Feat(contracts): Add court and disputeKit events to ease subgraph indexing
2 parents 8562bff + 578a87c commit 4bec363

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

contracts/src/arbitration/KlerosCore.sol

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ contract KlerosCore is IArbitrator {
136136
event AppealPossible(uint256 indexed _disputeID, IArbitrable indexed _arbitrable);
137137
event AppealDecision(uint256 indexed _disputeID, IArbitrable indexed _arbitrable);
138138
event Draw(address indexed _address, uint256 indexed _disputeID, uint256 _roundID, uint256 _voteID);
139+
event SubcourtCreation(
140+
uint256 indexed _subcourtID,
141+
uint96 indexed _parent,
142+
bool _hiddenVotes,
143+
uint256 _minStake,
144+
uint256 _alpha,
145+
uint256 _feeForJuror,
146+
uint256 _jurorsForCourtJump,
147+
uint256[4] _timesPerPeriod,
148+
uint256 _sortitionSumTreeK,
149+
uint256[] _supportedDisputeKits
150+
);
151+
event SubcourtModification(uint96 indexed _subcourtID, string _param);
152+
event DisputeKitCreation(IDisputeKit indexed _disputeKitAddress, uint256 indexed _parent);
153+
event DisputeKitEnable(uint96 indexed _subcourtID, uint256 indexed _disputeKitID);
154+
event DisputeKitDisable(uint96 indexed _subcourtID, uint256 indexed _disputeKitID);
139155
event CourtJump(
140156
uint256 indexed _disputeID,
141157
uint256 indexed _roundID,
@@ -361,6 +377,18 @@ contract KlerosCore is IArbitrator {
361377
sortitionSumTrees.createTree(bytes32(subcourtID), _sortitionSumTreeK);
362378
// Update the parent.
363379
courts[_parent].children.push(subcourtID);
380+
emit SubcourtCreation(
381+
subcourtID,
382+
_parent,
383+
_hiddenVotes,
384+
_minStake,
385+
_alpha,
386+
_feeForJuror,
387+
_jurorsForCourtJump,
388+
_timesPerPeriod,
389+
_sortitionSumTreeK,
390+
_supportedDisputeKits
391+
);
364392
}
365393

366394
/** @dev Changes the `minStake` property value of a specified subcourt. Don't set to a value lower than its parent's `minStake` property value.
@@ -377,6 +405,7 @@ contract KlerosCore is IArbitrator {
377405
}
378406

379407
courts[_subcourtID].minStake = _minStake;
408+
emit SubcourtModification(_subcourtID, "minStake");
380409
}
381410

382411
/** @dev Changes the `alpha` property value of a specified subcourt.
@@ -385,6 +414,7 @@ contract KlerosCore is IArbitrator {
385414
*/
386415
function changeSubcourtAlpha(uint96 _subcourtID, uint256 _alpha) external onlyByGovernor {
387416
courts[_subcourtID].alpha = _alpha;
417+
emit SubcourtModification(_subcourtID, "alpha");
388418
}
389419

390420
/** @dev Changes the `feeForJuror` property value of a specified subcourt.
@@ -393,6 +423,7 @@ contract KlerosCore is IArbitrator {
393423
*/
394424
function changeSubcourtJurorFee(uint96 _subcourtID, uint256 _feeForJuror) external onlyByGovernor {
395425
courts[_subcourtID].feeForJuror = _feeForJuror;
426+
emit SubcourtModification(_subcourtID, "feeForJuror");
396427
}
397428

398429
/** @dev Changes the `jurorsForCourtJump` property value of a specified subcourt.
@@ -401,6 +432,7 @@ contract KlerosCore is IArbitrator {
401432
*/
402433
function changeSubcourtJurorsForJump(uint96 _subcourtID, uint256 _jurorsForCourtJump) external onlyByGovernor {
403434
courts[_subcourtID].jurorsForCourtJump = _jurorsForCourtJump;
435+
emit SubcourtModification(_subcourtID, "jurorsForCourtJump");
404436
}
405437

406438
/** @dev Changes the `hiddenVotes` property value of a specified subcourt.
@@ -409,6 +441,7 @@ contract KlerosCore is IArbitrator {
409441
*/
410442
function changeHiddenVotes(uint96 _subcourtID, bool _hiddenVotes) external onlyByGovernor {
411443
courts[_subcourtID].hiddenVotes = _hiddenVotes;
444+
emit SubcourtModification(_subcourtID, "hiddenVotes");
412445
}
413446

414447
/** @dev Changes the `timesPerPeriod` property value of a specified subcourt.
@@ -420,6 +453,7 @@ contract KlerosCore is IArbitrator {
420453
onlyByGovernor
421454
{
422455
courts[_subcourtID].timesPerPeriod = _timesPerPeriod;
456+
emit SubcourtModification(_subcourtID, "timesPerPeriod");
423457
}
424458

425459
/** @dev Adds/removes court's support for specified dispute kits..
@@ -437,12 +471,14 @@ contract KlerosCore is IArbitrator {
437471
if (_enable) {
438472
require(_disputeKitIDs[i] > 0 && _disputeKitIDs[i] < disputeKitNodes.length, "Wrong DK index");
439473
subcourt.supportedDisputeKits[_disputeKitIDs[i]] = true;
474+
emit DisputeKitEnable(_subcourtID, _disputeKitIDs[i]);
440475
} else {
441476
require(
442477
!(_subcourtID == GENERAL_COURT && disputeKitNodes[_disputeKitIDs[i]].parent == NULL_DISPUTE_KIT),
443478
"Can't remove root DK support from the general court"
444479
);
445480
subcourt.supportedDisputeKits[_disputeKitIDs[i]] = false;
481+
emit DisputeKitDisable(_subcourtID, _disputeKitIDs[i]);
446482
}
447483
}
448484
}

0 commit comments

Comments
 (0)