Skip to content

Commit

Permalink
fix: Conflict on TwoPartyArbitrable.sol with master
Browse files Browse the repository at this point in the history
  • Loading branch information
eccentricexit committed Jul 28, 2018
2 parents 118ee09 + e5a1ce1 commit bf471d1
Show file tree
Hide file tree
Showing 7 changed files with 780 additions and 752 deletions.
9 changes: 1 addition & 8 deletions contracts/standard/arbitration/Arbitrable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ contract Arbitrable{

modifier onlyArbitrator {require(msg.sender==address(arbitrator)); _;}

/** @dev To be raised when a dispute is created. The main purpose of this event is to let the arbitrator know the meaning ruling IDs.
* @param _arbitrator The arbitrator of the contract.
* @param _disputeID ID of the dispute in the Arbitrator contract.
* @param _rulingOptions Map ruling IDs to short description of the ruling in a CSV format using ";" as a delimiter. Note that ruling IDs start a 1. For example "Send funds to buyer;Send funds to seller", means that ruling 1 will make the contract send funds to the buyer and 2 to the seller.
*/
event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, string _rulingOptions);

/** @dev To be raised when a ruling is given.
* @param _arbitrator The arbitrator giving the ruling.
* @param _disputeID ID of the dispute in the Arbitrator contract.
Expand All @@ -47,7 +40,7 @@ contract Arbitrable{
* @param _disputeID ID of the dispute in the Arbitrator contract.
* @param _metaEvidenceID Unique identifier of meta-evidence.
*/
event LinkMetaEvidence(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID);
event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID);

/** @dev To be raised when evidence are submitted. Should point to the ressource (evidences are not to be stored on chain due to gas considerations).
* @param _arbitrator The arbitrator of the contract.
Expand Down
6 changes: 4 additions & 2 deletions contracts/standard/arbitration/ArbitrableDeposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ contract ArbitrableDeposit is Arbitrable {
* @param _arbitrator The arbitrator of the contract.
* @param _timeout Time after which a party automatically loose a dispute.
* @param _arbitratorExtraData Extra data for the arbitrator.
* @param _metaEvidence Link to the meta evidence.
*/
constructor(Arbitrator _arbitrator, uint _timeout, bytes _arbitratorExtraData, uint _claimRate) Arbitrable(_arbitrator, _arbitratorExtraData) public payable {
constructor(Arbitrator _arbitrator, uint _timeout, bytes _arbitratorExtraData, uint _claimRate, string _metaEvidence) Arbitrable(_arbitrator, _arbitratorExtraData) public payable {
timeout = _timeout;
claimRate = _claimRate;
status = Status.NoDispute;
amount += msg.value;
owner = msg.sender;
address(this).transfer(amount);
emit MetaEvidence(0, _metaEvidence);
}

/** @dev Owner deposit to contract. To be called when the owner makes a deposit.
Expand Down Expand Up @@ -142,7 +144,7 @@ contract ArbitrableDeposit is Arbitrable {
function raiseDispute(uint _arbitrationCost) internal {
status = Status.DisputeCreated;
disputeID = arbitrator.createDispute.value(_arbitrationCost)(AMOUNT_OF_CHOICES,arbitratorExtraData);
emit Dispute(arbitrator, disputeID, RULING_OPTIONS);
emit Dispute(arbitrator, disputeID, 0);
}

/** @dev Reimburse owner if claimant fails to pay the fee.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import "./Arbitrator.sol";
* @param _disputeID ID of the dispute in the Arbitrator contract.
* @param _transactionId The index of the transaction.
*/
event LinkMetaEvidence(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _transactionId);
event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _transactionId);

/** @dev To be raised when evidence are submitted. Should point to the ressource (evidences are not to be stored on chain due to gas considerations).
* @param _arbitrator The arbitrator of the contract.
Expand Down Expand Up @@ -158,8 +158,7 @@ import "./Arbitrator.sol";
transaction.status = Status.DisputeCreated;
transaction.disputeId = transaction.arbitrator.createDispute.value(_arbitrationCost)(AMOUNT_OF_CHOICES,transaction.arbitratorExtraData);
disputeTxMap[keccak256(transaction.arbitrator, transaction.disputeId)] = _transactionId;
emit Dispute(_transactionId, transaction.arbitrator, transaction.disputeId,RULING_OPTIONS);
emit LinkMetaEvidence(transaction.arbitrator,transaction.disputeId,_transactionId);
emit Dispute(transaction.arbitrator,transaction.disputeId,_transactionId);
}

/** @dev Reimburse partyA if partyB fails to pay the fee.
Expand Down Expand Up @@ -215,7 +214,7 @@ import "./Arbitrator.sol";
transaction.arbitrator.appeal.value(msg.value)(transaction.disputeId,_extraData);
}

/** @dev
/** @dev Create a transaction.
* @param _arbitrator The arbitrator of the contract.
* @param _timeout Time after which a party automatically loose a dispute.
* @param _seller The recipient of the transaction.
Expand Down
3 changes: 1 addition & 2 deletions contracts/standard/arbitration/TwoPartyArbitrable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ contract TwoPartyArbitrable is Arbitrable {
function raiseDispute(uint _arbitrationCost) internal {
status = Status.DisputeCreated;
disputeID = arbitrator.createDispute.value(_arbitrationCost)(amountOfChoices,arbitratorExtraData);
emit Dispute(arbitrator,disputeID,RULING_OPTIONS);
emit LinkMetaEvidence(arbitrator,disputeID,0);
emit Dispute(arbitrator,disputeID,0);
}

/** @dev Reimburse partyA if partyB fails to pay the fee.
Expand Down
56 changes: 43 additions & 13 deletions contracts/standard/permission/ArbitrablePermissionList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ contract ArbitrablePermissionList is PermissionInterface, Arbitrable {
// Settings
bool public blacklist; // True if the list should function as a blacklist, false if it should function as a whitelist.
bool public appendOnly; // True if the list should be append only.
bool public rechallengePossible; // True if items winning their disputes can be challenged again.
uint public stake; // The stake to put to submit/clear/challenge and item in addition of arbitration fees.
uint public timeToChallenge; // The time before which an action is executable if not challenged.

Expand All @@ -85,6 +86,7 @@ contract ArbitrablePermissionList is PermissionInterface, Arbitrable {
* @param _metaEvidence The URL of the meta evidence object.
* @param _blacklist True if the list should function as a blacklist, false if it should function as a whitelist.
* @param _appendOnly True if the list should be append only.
* @param _rechallengePossible True if it is possible to challenge again a submission which has won a dispute.
* @param _stake The amount in Weis of deposit required for a submission or a challenge in addition of the arbitration fees.
* @param _timeToChallenge The time in seconds, other parties have to challenge.
*/
Expand All @@ -94,11 +96,13 @@ contract ArbitrablePermissionList is PermissionInterface, Arbitrable {
string _metaEvidence,
bool _blacklist,
bool _appendOnly,
bool _rechallengePossible,
uint _stake,
uint _timeToChallenge) Arbitrable(_arbitrator, _arbitratorExtraData) public {
emit MetaEvidence(0, _metaEvidence);
blacklist = _blacklist;
appendOnly = _appendOnly;
rechallengePossible = _rechallengePossible;
stake = _stake;
timeToChallenge = _timeToChallenge;
}
Expand Down Expand Up @@ -177,7 +181,7 @@ contract ArbitrablePermissionList is PermissionInterface, Arbitrable {
item.disputed = true;
item.disputeID = arbitrator.createDispute.value(arbitratorCost)(2,arbitratorExtraData);
disputeIDToItem[item.disputeID] = _value;
emit LinkMetaEvidence(arbitrator, item.disputeID, 0);
emit Dispute(arbitrator, item.disputeID, 0);
} else { // In the case the arbitration fees increased so much that the deposit of the requester is not high enough. Cancel the request.
if (item.status == ItemStatus.Resubmitted)
item.status = ItemStatus.Cleared;
Expand Down Expand Up @@ -211,7 +215,7 @@ contract ArbitrablePermissionList is PermissionInterface, Arbitrable {
item.disputed = true;
item.disputeID = arbitrator.createDispute.value(arbitratorCost)(2,arbitratorExtraData);
disputeIDToItem[item.disputeID] = _value;
emit LinkMetaEvidence(arbitrator, item.disputeID, 0);
emit Dispute(arbitrator, item.disputeID, 0);
} else { // In the case the arbitration fees increased so much that the deposit of the requester is not high enough. Cancel the request.
if (item.status == ItemStatus.ClearingRequested)
item.status = ItemStatus.Registered;
Expand Down Expand Up @@ -285,12 +289,21 @@ contract ArbitrablePermissionList is PermissionInterface, Arbitrable {
require(item.disputed);

if (_ruling == REGISTER) {
if (item.status == ItemStatus.Resubmitted || item.status == ItemStatus.Submitted)
item.submitter.send(item.balance); // Deliberate use of send in order to not block the contract in case of reverting fallback.
else
item.challenger.send(item.balance);

item.status = ItemStatus.Registered;
if (rechallengePossible && item.status==ItemStatus.Submitted) {
uint arbitratorCost = arbitrator.arbitrationCost(arbitratorExtraData);
if (arbitratorCost + stake < item.balance) { // Check that the balance is enough.
uint toSend = item.balance - (arbitratorCost + stake);
item.submitter.send(toSend); // Keep the arbitration cost and the stake and send the remaining to the submitter.
item.balance -= toSend;
}
} else {
if (item.status==ItemStatus.Resubmitted || item.status==ItemStatus.Submitted)
item.submitter.send(item.balance); // Deliberate use of send in order to not block the contract in case of reverting fallback.
else
item.challenger.send(item.balance);

item.status = ItemStatus.Registered;
}
} else if (_ruling == CLEAR) {
if (item.status == ItemStatus.PreventiveClearingRequested || item.status == ItemStatus.ClearingRequested)
item.submitter.send(item.balance);
Expand All @@ -300,17 +313,20 @@ contract ArbitrablePermissionList is PermissionInterface, Arbitrable {
item.status = ItemStatus.Cleared;
} else { // Split the balance 50-50 and give the item the initial status.
if (item.status==ItemStatus.Resubmitted)
item.status==ItemStatus.Cleared;
item.status = ItemStatus.Cleared;
else if (item.status==ItemStatus.ClearingRequested)
item.status==ItemStatus.Submitted;
item.status = ItemStatus.Registered;
else
item.status==ItemStatus.Absent;
item.status = ItemStatus.Absent;
item.submitter.send(item.balance / 2);
item.challenger.send(item.balance / 2);
}

item.disputed = false;
item.balance = 0;
if (rechallengePossible && item.status==ItemStatus.Submitted && _ruling==REGISTER)
item.lastAction=now; // If the item can be rechallenged, update the time and keep the remaining balance.
else
item.balance = 0;

emit ItemStatusChange(item.submitter, item.challenger, disputeIDToItem[_disputeID], item.status, item.disputed);
}
Expand All @@ -325,6 +341,20 @@ contract ArbitrablePermissionList is PermissionInterface, Arbitrable {
count = itemsList.length;
}

/**
* @dev Return the numbers of items in the list per status.
* @return The numbers of items in the list per status.
*/
function itemsCounts() public view returns (uint pending, uint challenged, uint accepted, uint rejected) {
for (uint i = 0; i < itemsList.length; i++) {
Item storage item = items[itemsList[i]];
if (item.disputed) challenged++;
else if (item.status == ItemStatus.Resubmitted || item.status == ItemStatus.Submitted) pending++;
else if (item.status == ItemStatus.Registered) accepted++;
else if (item.status == ItemStatus.Cleared) rejected++;
}
}

/**
* @dev Return the values of the items the query finds.
* This function is O(n) at worst, where n is the number of items. This could exceed the gas limit, therefore this function should only be used for interface display and not by other contracts.
Expand Down
Loading

0 comments on commit bf471d1

Please sign in to comment.