Skip to content

Commit

Permalink
fix(t2cr): simplify item status
Browse files Browse the repository at this point in the history
  • Loading branch information
eccentricexit committed Nov 19, 2018
1 parent 3fb348a commit 787102e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
67 changes: 67 additions & 0 deletions contracts/standard/arbitration/TwoPartyArbitrableEscrowPayment.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
pragma solidity ^0.4.24;

import "./Arbitrable.sol";

contract TwoPartyArbitrableEscrowPayment is Arbitrable {
address public sender;
address public receiver;
uint public value;
bytes public extraData;
Arbitrator public arbitrator;
uint public disputeID;
bool public disputed;
bool public appealed;
bool public executed;
uint public createdAt;
uint public timeOut;

modifier onlySenderOrReceiver{
require(msg.sender == sender || msg.sender == receiver, "Can only be called by the sender or the receiver.");
_;
}

constructor(address _receiver, bytes _extraData, Arbitrator _arbitrator, uint _timeOut, string _metaEvidence) public payable {
sender = msg.sender;
receiver = _receiver;
value = msg.value;
extraData = _extraData;
arbitrator = _arbitrator;
createdAt = now;
timeOut = _timeOut;
emit MetaEvidence(0, _metaEvidence);
}

function raiseDispute() public payable onlySenderOrReceiver {
disputeID = arbitrator.createDispute.value(msg.value)(2, extraData);
emit Dispute(arbitrator, disputeID, 0);
}

function submitEvidence(string _evidence) public onlySenderOrReceiver {
require(disputed, "The payment has to be disputed.");
require(!appealed, "The payment can not be appealed.");
emit Evidence(arbitrator, disputeID, msg.sender, _evidence);
}

function appeal() public payable onlySenderOrReceiver {
arbitrator.appeal.value(msg.value)(disputeID, extraData);
if (!appealed) appealed = true;
}

function executePayment() public onlySenderOrReceiver {
require(now - createdAt > timeOut, "The timeout time has not passed yet.");
require(!disputed, "The payment is disputed.");
require(!executed, "The payment was already executed.");
executed = true;
receiver.send(value);
}

function executeRuling(uint _disputeID, uint _ruling) internal {
require(disputed, "The payment is not disputed.");
require(_disputeID == disputeID, "Wrong dispute ID.");
require(!executed, "The payment was already executed.");
executed = true;
if (_ruling == 2) receiver.send(value);
else sender.send(value);
emit Ruling(arbitrator, disputeID, _ruling);
}
}
11 changes: 4 additions & 7 deletions contracts/standard/permission/ArbitrableTokenList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ contract ArbitrableTokenList is PermissionInterface, Arbitrable {
/* Enums */

enum ItemStatus {
Absent, // The item has never been submitted.
Cleared, // The item has been submitted and the dispute resolution process determined it should not be added or a clearing request has been submitted and the dispute resolution process determined it should be cleared or the clearing was never contested.
Resubmitted, // The item has been cleared but someone has resubmitted it.
Registered, // The item has been submitted and the dispute resolution process determined it should be added or the submission was never contested.
Submitted, // The item has been submitted.
ClearingRequested, // The item is registered, but someone has requested to remove it.
PreventiveClearingRequested // The item has never been registered, but someone asked to clear it preemptively to avoid it being shown as not registered during the dispute resolution process.
Absent, // The item is not on the list.
Registered, // The item is on the list.
RegistrationRequested, // The item has a request to be added to the list.
ClearingRequested // The item has a request to be removed from the list.
}

enum RulingOption {
Expand Down

0 comments on commit 787102e

Please sign in to comment.