Skip to content

Commit 7ab6860

Browse files
committed
feat: emit event on appeal crowdfunding contribution
1 parent 1deb2be commit 7ab6860

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

contracts/GeneralizedTCR.sol

+42-10
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,24 @@ contract GeneralizedTCR is IArbitrable, IEvidence {
115115
*/
116116
event ItemSubmitted(bytes32 indexed _itemID, address indexed _submitter, bytes _data);
117117

118+
/**
119+
* @dev Emitted when a party contributes to an appeal.
120+
* @param _itemID The ID of the item with a dispute.
121+
* @param _contributor The address making the contribution.
122+
* @param _request The index disputed request.
123+
* @param _round The index of the round receiving the contribution.
124+
* @param _amount The amount of the contribution.
125+
* @param _side The party receiving the contribution.
126+
*/
127+
event AppealContribution(
128+
bytes32 indexed _itemID,
129+
address indexed _contributor,
130+
uint indexed _request,
131+
uint _round,
132+
uint _amount,
133+
Party _side
134+
);
135+
118136
/**
119137
* @dev Constructs the arbitrable curated registry.
120138
* @param _arbitrator The trusted arbitrator to resolve potential disputes.
@@ -234,12 +252,11 @@ contract GeneralizedTCR is IArbitrable, IEvidence {
234252
*/
235253
function fundAppeal(bytes32 _itemID, Party _side) external payable {
236254
require(_side == Party.Requester || _side == Party.Challenger); // solium-disable-line error-reason
237-
Item storage item = items[_itemID];
238255
require(
239-
item.status == Status.RegistrationRequested || item.status == Status.ClearingRequested,
256+
items[_itemID].status == Status.RegistrationRequested || items[_itemID].status == Status.ClearingRequested,
240257
"The item must have a pending request."
241258
);
242-
Request storage request = item.requests[item.requests.length - 1];
259+
Request storage request = items[_itemID].requests[items[_itemID].requests.length - 1];
243260
require(request.disputed, "A dispute must have been raised to fund an appeal.");
244261
(uint appealPeriodStart, uint appealPeriodEnd) = request.arbitrator.appealPeriod(request.disputeID);
245262
require(
@@ -256,17 +273,30 @@ contract GeneralizedTCR is IArbitrable, IEvidence {
256273
loser = Party.Requester;
257274
require(!(_side==loser) || (now-appealPeriodStart < (appealPeriodEnd-appealPeriodStart)/2), "The loser must contribute during the first half of the appeal period.");
258275

259-
uint multiplier;
276+
// Use array to get around stack limit.
277+
// 0: multiplier
278+
// 1: contribution
279+
uint[2] memory values = [uint(0), uint(0)];
260280
if (_side == winner)
261-
multiplier = winnerStakeMultiplier;
281+
values[0] = winnerStakeMultiplier;
262282
else if (_side == loser)
263-
multiplier = loserStakeMultiplier;
283+
values[0] = loserStakeMultiplier;
264284
else
265-
multiplier = sharedStakeMultiplier;
285+
values[0] = sharedStakeMultiplier;
266286

267287
uint appealCost = request.arbitrator.appealCost(request.disputeID, request.arbitratorExtraData);
268-
uint totalCost = appealCost.addCap((appealCost.mulCap(multiplier)) / MULTIPLIER_DIVISOR);
269-
contribute(round, _side, msg.sender, msg.value, totalCost);
288+
uint totalCost = appealCost.addCap((appealCost.mulCap(values[0])) / MULTIPLIER_DIVISOR);
289+
values[1] = contribute(round, _side, msg.sender, msg.value, totalCost);
290+
291+
emit AppealContribution(
292+
_itemID,
293+
msg.sender,
294+
items[_itemID].requests.length - 1,
295+
request.rounds.length - 1,
296+
values[1],
297+
_side
298+
);
299+
270300
if (round.paidFees[uint(_side)] >= totalCost)
271301
round.hasPaid[uint(_side)] = true;
272302

@@ -552,7 +582,7 @@ contract GeneralizedTCR is IArbitrable, IEvidence {
552582
* @param _amount The amount contributed.
553583
* @param _totalRequired The total amount required for this side.
554584
*/
555-
function contribute(Round storage _round, Party _side, address payable _contributor, uint _amount, uint _totalRequired) internal {
585+
function contribute(Round storage _round, Party _side, address payable _contributor, uint _amount, uint _totalRequired) internal returns (uint) {
556586
// Take up to the amount necessary to fund the current round at the current costs.
557587
uint contribution; // Amount contributed.
558588
uint remainingETH; // Remaining ETH to send back.
@@ -563,6 +593,8 @@ contract GeneralizedTCR is IArbitrable, IEvidence {
563593

564594
// Reimburse leftover ETH.
565595
_contributor.send(remainingETH); // Deliberate use of send in order to not block the contract in case of reverting fallback.
596+
597+
return contribution;
566598
}
567599

568600
/** @dev Execute the ruling of a dispute.

0 commit comments

Comments
 (0)