Skip to content

Commit

Permalink
feat(proxy): finish simple arbitrator versioning proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Feb 26, 2018
1 parent 7aeaa02 commit 8578870
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 40 deletions.
2 changes: 1 addition & 1 deletion contracts/standard/proxy/ArbitratorVersioningProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.15;

import "https://github.com/kleros/kleros/contracts/KlerosPOC.sol";
import "kleros/contracts/KlerosPOC.sol";

import "./VersioningProxy.sol";

Expand Down
69 changes: 30 additions & 39 deletions contracts/standard/proxy/SimpleArbitratorVersioningProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.15;

import "https://github.com/kleros/kleros/contracts/KlerosPOC.sol";
import "kleros/contracts/KlerosPOC.sol";

import "./VersioningProxy.sol";

Expand All @@ -10,33 +10,24 @@ import "./VersioningProxy.sol";
* @notice A simpler ArbitratorVersioningProxy that only exposes methods in the Arbitrator spec.
*/
contract SimpleArbitratorVersioningProxy is VersioningProxy {
/* Enums */



/* Structs */



/* Events */



/* Storage */


mapping (uint256 => address) public disputes;

/* Modifiers */


modifier onlyIfDisputeExists {
require(disputes[_disputeID] != address(0));
_;
}

/* Constructor */

/**
* @notice Constructs the arbitrator versioning proxy with the first arbitrator contract version address and tags it v0.0.1.
* @param firstAddress The address of the first arbitrator contract version.
*/
function ArbitratorVersioningProxy(address firstAddress) VersioningProxy(false, "0.0.1", firstAddress) public {}
function SimpleArbitratorVersioningProxy(address firstAddress) VersioningProxy(false, "0.0.1", firstAddress) public {}

/* Fallback */

Expand All @@ -46,36 +37,36 @@ import "./VersioningProxy.sol";
*/
function() private {}

/* External */



/* External Views */



/* Public */

function createDispute(bytes _extraData) public payable returns(uint256 disputeID) {
uint256 disputeID = KlerosPOC(stable._address).createDispute(_extraData);
disputes[disputeID] = stable._address; // Remember arbitrator
return disputeID;
}

function appeal(uint _disputeID, bytes _extraData) public payable onlyIfDisputeExists returns(uint256 disputeID) {
if (disputes[_disputeID] != stable._address) // Arbitrator has been upgraded, create a new dispute in the new arbitrator
return createDispute(_extraData);

return KlerosPOC(stable._address).appeal(_disputeID, _extraData);
}

/* Public Views */

function arbitrationCost(bytes _extraData) public view returns(uint256 fees) {
return KlerosPOC(stable._address).arbitrationCost(_extraData);
}

function appealCost(uint256 _disputeID, bytes _extraData) public view returns(uint256 fees) {
return KlerosPOC(stable._address).appealCost(_disputeID, _extraData);
}

/* Internal */



/* Internal Views */



/* Private */



/* Private Views */


function currentRuling(uint _disputeID) public view onlyIfDisputeExists returns (uint ruling) {
return KlerosPOC(disputes[_disputeID]).currentRuling(_disputeID);
}

function disputeStatus(uint _disputeID) public view onlyIfDisputeExists returns (DisputeStatus status) {
return KlerosPOC(disputes[_disputeID]).disputeStatus(_disputeID);
}
}

0 comments on commit 8578870

Please sign in to comment.