You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** @dev To be emitted when a translation is submitted.
77
83
* @param _taskID The ID of the respective task.
78
84
* @param _translator The address that performed the translation.
@@ -199,6 +205,7 @@ contract Linguo is Arbitrable {
199
205
task.requesterDeposit =msg.value;
200
206
201
207
emitMetaEvidence(taskID, _metaEvidence);
208
+
emitTaskCreated(taskID, msg.sender);
202
209
}
203
210
204
211
/** @dev Assigns a specific task to the sender. Requires a translator's deposit.
@@ -380,7 +387,7 @@ contract Linguo is Arbitrable {
380
387
* @param _taskID The ID of the associated task.
381
388
* @param _round The round from which to withdraw.
382
389
*/
383
-
function withdrawFeesAndRewards(address_beneficiary, uint_taskID, uint_round) external {
390
+
function withdrawFeesAndRewards(address_beneficiary, uint_taskID, uint_round) public {
384
391
Task storage task = tasks[_taskID];
385
392
Round storage round = task.rounds[_round];
386
393
require(task.status == Status.Resolved, "The task should be resolved.");
@@ -413,6 +420,18 @@ contract Linguo is Arbitrable {
413
420
_beneficiary.send(reward); // It is the user responsibility to accept ETH.
414
421
}
415
422
423
+
/** @dev Withdraws contributions of multiple appeal rounds at once. This function is O(n) where n is the number of rounds. This could exceed the gas limit, therefore this function should be used only as a utility and not be relied upon by other contracts.
424
+
* @param _beneficiary The address that made contributions.
425
+
* @param _taskID The ID of the associated task.
426
+
* @param _cursor The round from where to start withdrawing.
427
+
* @param _count The number of rounds to iterate. If set to 0 or a value larger than the number of rounds, iterates until the last round.
428
+
*/
429
+
function batchRoundWithdraw(address_beneficiary, uint_taskID, uint_cursor, uint_count) public {
430
+
Task storage task = tasks[_taskID];
431
+
for (uint i = _cursor; i<task.rounds.length&& (_count==0|| i<_cursor+_count); i++)
432
+
withdrawFeesAndRewards(_beneficiary, _taskID, i);
433
+
}
434
+
416
435
/** @dev Gives a ruling for a dispute. Must be called by the arbitrator.
417
436
* The purpose of this function is to ensure that the address calling it has the right to rule on the contract.
418
437
* @param _disputeID ID of the dispute in the Arbitrator contract.
@@ -479,6 +498,38 @@ contract Linguo is Arbitrable {
479
498
// * Getters * //
480
499
// ******************** //
481
500
501
+
/** @dev Returns the sum of withdrawable wei from appeal rounds. This function is O(n), where n is the number of rounds of the task. This could exceed the gas limit, therefore this function should only be used for interface display and not by other contracts.
502
+
* @param _taskID The ID of the associated task.
503
+
* @param _beneficiary The contributor for which to query.
504
+
* @return The total amount of wei available to withdraw.
505
+
*/
506
+
function amountWithdrawable(uint_taskID, address_beneficiary) externalviewreturns (uinttotal){
507
+
Task storage task = tasks[_taskID];
508
+
if (task.status != Status.Resolved) return total;
509
+
510
+
for (uint i =0; i < task.rounds.length; i++) {
511
+
Round storage round = task.rounds[i];
512
+
if (!round.hasPaid[uint(Party.Translator)] ||!round.hasPaid[uint(Party.Challenger)]) {
513
+
total += round.contributions[_beneficiary][uint(Party.Translator)] + round.contributions[_beneficiary][uint(Party.Challenger)];
newBalanceTranslator1.plus(roundInfo[2]).toString(),// First 2 rounds have the same feeRewards value so we don't need to get info directly from each round.
1151
+
'Incorrect translator balance after withdrawing from the first round'
1152
+
)
1153
+
1154
+
// Check that 'amountWithdrawable' function returns the correct amount.
0 commit comments