New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aragon Court POC implementation #6
Changes from 18 commits
c26f6e2
7ff426f
3d91f76
500d3d1
3297fce
fee8c87
6545acc
c405771
9cf0334
3ca94bb
e167cbc
6d0b322
fe1abf9
dd687db
1f6adae
6a5737d
46ceb8f
146f788
5896c12
9d5d795
19e962c
8327a1f
323f362
61cfe77
c44ba3b
778ab8b
3824223
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
pragma solidity ^0.4.15; | ||
|
||
import "./standards/arbitration/Arbitrable.sol"; | ||
|
||
|
||
contract Agreement is Arbitrable /* AragonApp/Trigger */ { | ||
address[] parties; | ||
|
||
// TODO: Probably needs to be moved into an 'initialize()' function at some point | ||
constructor(address _court, address[] _parties) | ||
public | ||
Arbitrable(_court) { | ||
|
||
parties = _parties; | ||
} | ||
|
||
function canSubmitEvidence(uint256 _disputeId, address _submitter) public view returns (bool) { | ||
// TODO: should check court to see whether evidence can be submitted for this particular dispute at this point | ||
uint256 partiesLength = parties.length; | ||
for (uint256 i = 0; i < partiesLength; i++) { | ||
if (parties[i] == msg.sender) { | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @dev Execute a ruling of a dispute. | ||
* @param _disputeId Id of the dispute in the Court contract. | ||
* @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". | ||
*/ | ||
function _executeRuling(uint256 _disputeId, uint256 _ruling) internal; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a TODO, right? Or is it going to be abstract too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this is already in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could actually implement the management of stake locks in this contract: #13 |
||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
|
||
library ArrayUtils { | ||
function deleteItem(address[] storage self, address item) internal returns (bool) { | ||
uint256 length = self.length; | ||
for (uint256 i = 0; i < length; i++) { | ||
if (self[i] == item) { | ||
uint256 newLength = self.length - 1; | ||
if (i != newLength) { | ||
self[i] = self[newLength]; | ||
} | ||
|
||
delete self[newLength]; | ||
self.length = newLength; | ||
|
||
return true; | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
pragma solidity ^0.4.15; | ||
|
||
import "./IArbitrable.sol"; | ||
import "../erc165/ERC165.sol"; | ||
|
||
|
||
contract Arbitrable is IArbitrable, ERC165 { | ||
address public court; // TODO: replace for ICourt or Court interface | ||
|
||
bytes4 private constant ERC165_INTERFACE_ID = 0x01ffc9a7; | ||
bytes4 private constant ARBITRABLE_INTERFACE_ID = 0xabababab; // TODO: interface id | ||
|
||
string private constant ERROR_NOT_COURT = "ARBITRABLE_NOT_COURT"; | ||
string private constant ERROR_CANNOT_SUBMIT_EVIDENCE = "ARBITRABLE_CANNOT_SUBMIT_EVIDENCE"; | ||
izqui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** @dev Constructor. Choose the arbitrator. | ||
* @param _court The address of the court that arbitrates the contract. | ||
*/ | ||
constructor(address _court) public { | ||
court = _court; | ||
} | ||
|
||
/** | ||
* @dev Give a ruling for a dispute. Must be called by the arbitrator. | ||
* The purpose of this function is to ensure that the address calling it has the right to rule on the contract. | ||
* @param _disputeId Id of the dispute in the Court contract. | ||
* @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". | ||
*/ | ||
function rule(uint256 _disputeId, uint256 _ruling) external { | ||
require(msg.sender == court, ERROR_NOT_COURT); | ||
|
||
_executeRuling(_disputeId, _ruling); | ||
|
||
emit CourtRuling(msg.sender, _disputeId, _ruling); | ||
} | ||
|
||
function submitEvidence(uint256 _disputeId, bytes _evidence) external { | ||
require(canSubmitEvidence(_disputeId, msg.sender), ERROR_CANNOT_SUBMIT_EVIDENCE); | ||
|
||
emit NewEvidence(court, _disputeId, msg.sender, _evidence); | ||
} | ||
|
||
function supportsInterface(bytes4 _interfaceId) external pure returns (bool) { | ||
return _interfaceId == ARBITRABLE_INTERFACE_ID || _interfaceId == ERC165_INTERFACE_ID; | ||
} | ||
|
||
/** | ||
* @dev Execute a ruling of a dispute. | ||
* @param _disputeId Id of the dispute in the Court contract. | ||
* @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision". | ||
*/ | ||
function _executeRuling(uint256 _disputeId, uint256 _ruling) internal; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
pragma solidity ^0.4.15; | ||
|
||
|
||
interface IArbitrable { | ||
/** | ||
* @dev To be emmited when a dispute is created to link the correct meta-evidence to the disputeId | ||
* @param _court The court resolving the dispute. | ||
* @param _disputeId Id of the dispute in the Court. | ||
* @param _baseEvidence Base evidence or location of the base evidence being submitted | ||
*/ | ||
event NewDispute(address indexed _court, uint256 indexed _disputeId, bytes _baseEvidence); | ||
|
||
/** | ||
* @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 _court The court resolving the dispute. | ||
* @param _disputeId Id of the dispute in the Court. | ||
* @param _submitter The address of the entity submitting the evidence. | ||
* @param _evidence Evidence or location of the evidence being submitted | ||
*/ | ||
event NewEvidence(address indexed _court, uint256 indexed _disputeId, address indexed _submitter, bytes _evidence); | ||
|
||
/** | ||
* @dev To be raised when a ruling is given. | ||
* @param _court The court giving the ruling. | ||
* @param _disputeId Id of the dispute in the Court. | ||
* @param _ruling The ruling which was given. | ||
*/ | ||
event CourtRuling(address indexed _court, uint256 indexed _disputeId, uint256 _ruling); | ||
|
||
/** @dev Give a ruling for a dispute. Must be called by the court. | ||
* The purpose of this function is to ensure that the address calling it has the right to rule on the contract. | ||
* @param _disputeId Id of the dispute in the Court. | ||
* @param _ruling Ruling given by the court. Note that 0 is reserved for "Not able/wanting to make a decision". | ||
*/ | ||
function rule(uint256 _disputeId, uint256 _ruling) external; | ||
|
||
/** | ||
* @param _disputeId Id of the dispute in the Court | ||
* @param _submitter address of the entity that wishes to submit evidence | ||
* @return bool whether the submitter is allowed to submit evidence for the dispute | ||
*/ | ||
function canSubmitEvidence(uint256 _disputeId, address _submitter) public view returns (bool); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
|
||
interface ERC165 { | ||
function supportsInterface(bytes4 interfaceId) external pure returns (bool); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
// Interface for ERC900: https://eips.ethereum.org/EIPS/eip-900 | ||
interface ERC900 { | ||
event Staked(address indexed user, uint256 amount, uint256 total, bytes data); | ||
event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); | ||
|
||
function stake(uint256 amount, bytes data) external; | ||
function stakeFor(address user, uint256 amount, bytes data) external; | ||
function unstake(uint256 amount, bytes data) external; | ||
|
||
function totalStakedFor(address addr) external view returns (uint256); | ||
function totalStaked() external view returns (uint256); | ||
function token() external view returns (address); | ||
|
||
function supportsHistory() external pure returns (bool); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* @title Random Number Generator Standard | ||
* @author Clément Lesaege - <clement@lesaege.com> | ||
* | ||
*/ | ||
|
||
pragma solidity ^0.4.15; | ||
|
||
contract RNG{ | ||
|
||
/** @dev Contribute to the reward of a random number. | ||
* @param _block Block the random number is linked to. | ||
*/ | ||
function contribute(uint _block) public payable; | ||
|
||
/** @dev Request a random number. | ||
* @param _block Block linked to the request. | ||
*/ | ||
function requestRN(uint _block) public payable { | ||
contribute(_block); | ||
} | ||
|
||
/** @dev Get the random number. | ||
* @param _block Block the random number is linked to. | ||
* @return RN Random Number. If the number is not ready or has not been required 0 instead. | ||
*/ | ||
function getRN(uint _block) public returns (uint RN); | ||
|
||
/** @dev Get a uncorrelated random number. Act like getRN but give a different number for each sender. | ||
* This is to prevent users from getting correlated numbers. | ||
* @param _block Block the random number is linked to. | ||
* @return RN Random Number. If the number is not ready or has not been required 0 instead. | ||
*/ | ||
function getUncorrelatedRN(uint _block) public returns (uint RN) { | ||
uint baseRN = getRN(_block); | ||
if (baseRN == 0) | ||
return 0; | ||
else | ||
return uint(keccak256(msg.sender,baseRN)); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be 2, proposer and challenger, and challenger won't be known in advance. Let's discuss it.