KlerosGovernor
Inherits: IArbitrableV2
State Variables
arbitrator
IArbitratorV2 public arbitrator;
arbitratorExtraData
bytes public arbitratorExtraData;
disputeTemplates
uint256 public disputeTemplates;
submissionBaseDeposit
uint256 public submissionBaseDeposit;
submissionTimeout
uint256 public submissionTimeout;
executionTimeout
uint256 public executionTimeout;
withdrawTimeout
uint256 public withdrawTimeout;
lastApprovalTime
uint256 public lastApprovalTime;
reservedETH
uint256 public reservedETH;
submissions
Submission[] public submissions;
sessions
Session[] public sessions;
Functions
duringSubmissionPeriod
modifier duringSubmissionPeriod();
duringApprovalPeriod
modifier duringApprovalPeriod();
onlyByGovernor
modifier onlyByGovernor();
constructor
Constructor.
constructor(
IArbitratorV2 _arbitrator,
bytes memory _arbitratorExtraData,
string memory _templateData,
uint256 _submissionBaseDeposit,
uint256 _submissionTimeout,
uint256 _executionTimeout,
uint256 _withdrawTimeout
);
Parameters
Name | Type | Description |
---|---|---|
_arbitrator | IArbitratorV2 | The arbitrator of the contract. |
_arbitratorExtraData | bytes | Extra data for the arbitrator. |
_templateData | string | The dispute template data. |
_submissionBaseDeposit | uint256 | The base deposit required for submission. |
_submissionTimeout | uint256 | Time in seconds allocated for submitting transaction list. |
_executionTimeout | uint256 | Time in seconds after approval that allows to execute transactions of the approved list. |
_withdrawTimeout | uint256 | Time in seconds after submission that allows to withdraw submitted list. |
changeSubmissionDeposit
Changes the value of the base deposit required for submitting a list.
function changeSubmissionDeposit(uint256 _submissionBaseDeposit) external onlyByGovernor;
Parameters
Name | Type | Description |
---|---|---|
_submissionBaseDeposit | uint256 | The new value of the base deposit, in wei. |
changeSubmissionTimeout
Changes the time allocated for submission. Note that it can't be changed during approval period because there can be an active dispute in the old arbitrator contract and prolonging submission timeout might switch it back to submission period.
function changeSubmissionTimeout(uint256 _submissionTimeout) external onlyByGovernor duringSubmissionPeriod;
Parameters
Name | Type | Description |
---|---|---|
_submissionTimeout | uint256 | The new duration of the submission period, in seconds. |
changeExecutionTimeout
Changes the time allocated for list's execution.
function changeExecutionTimeout(uint256 _executionTimeout) external onlyByGovernor;
Parameters
Name | Type | Description |
---|---|---|
_executionTimeout | uint256 | The new duration of the execution timeout, in seconds. |
changeWithdrawTimeout
Changes list withdrawal timeout. Note that withdrawals are only possible in the first half of the submission period.
function changeWithdrawTimeout(uint256 _withdrawTimeout) external onlyByGovernor;
Parameters
Name | Type | Description |
---|---|---|
_withdrawTimeout | uint256 | The new duration of withdraw period, in seconds. |
changeArbitrator
Changes the arbitrator of the contract. Note that it can't be changed during approval period because there can be an active dispute in the old arbitrator contract.
function changeArbitrator(IArbitratorV2 _arbitrator, bytes memory _arbitratorExtraData)
external
onlyByGovernor
duringSubmissionPeriod;
Parameters
Name | Type | Description |
---|---|---|
_arbitrator | IArbitratorV2 | The new trusted arbitrator. |
_arbitratorExtraData | bytes | The extra data used by the new arbitrator. |
changeDisputeTemplate
Update the dispute template data.
function changeDisputeTemplate(string memory _templateData) external onlyByGovernor;
Parameters
Name | Type | Description |
---|---|---|
_templateData | string | The new dispute template data. |
submitList
Creates transaction list based on input parameters and submits it for potential approval and execution. Transactions must be ordered by their hash.
function submitList(
address[] memory _target,
uint256[] memory _value,
bytes memory _data,
uint256[] memory _dataSize,
string memory _description
) external payable duringSubmissionPeriod;
Parameters
Name | Type | Description |
---|---|---|
_target | address[] | List of addresses to call. |
_value | uint256[] | List of values required for respective addresses. |
_data | bytes | Concatenated calldata of all transactions of this list. |
_dataSize | uint256[] | List of lengths in bytes required to split calldata for its respective targets. |
_description | string | String in CSV format that describes list's transactions. |
withdrawTransactionList
Withdraws submitted transaction list. Reimburses submission deposit. Withdrawal is only possible during the first half of the submission period and during withdrawTimeout after the submission is made.
function withdrawTransactionList(uint256 _submissionID, bytes32 _listHash) external;
Parameters
Name | Type | Description |
---|---|---|
_submissionID | uint256 | Submission's index in the array of submitted lists of the current sesssion. |
_listHash | bytes32 | Hash of a withdrawing list. |
executeSubmissions
Approves a transaction list or creates a dispute if more than one list was submitted. If nothing was submitted changes session.
function executeSubmissions() external duringApprovalPeriod;
rule
Gives a ruling for a dispute. Must be called by the arbitrator.
function rule(uint256 _disputeID, uint256 _ruling) external override;
Parameters
Name | Type | Description |
---|---|---|
_disputeID | uint256 | ID of the dispute in the Arbitrator contract. |
_ruling | uint256 | Ruling given by the arbitrator. Note that 0 is reserved for "Refuse to arbitrate". Note If the final ruling is "0" nothing is approved and deposits will stay locked in the contract. |
executeTransactionList
Executes selected transactions of the list.
function executeTransactionList(uint256 _listID, uint256 _cursor, uint256 _count) external;
Parameters
Name | Type | Description |
---|---|---|
_listID | uint256 | The index of the transaction list in the array of lists. |
_cursor | uint256 | Index of the transaction from which to start executing. |
_count | uint256 | Number of transactions to execute. Executes until the end if set to "0" or number higher than number of transactions in the list. |
receive
Receive function to receive funds for the execution of transactions.
receive() external payable;
getExpendableFunds
Gets the sum of contract funds that are used for the execution of transactions.
function getExpendableFunds() public view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | Contract balance without reserved ETH. |
getTransactionInfo
Gets the info of the specific transaction in the specific list.
function getTransactionInfo(uint256 _listID, uint256 _transactionIndex)
external
view
returns (address target, uint256 value, bytes memory data, bool executed);
Parameters
Name | Type | Description |
---|---|---|
_listID | uint256 | The index of the transaction list in the array of lists. |
_transactionIndex | uint256 | The index of the transaction. |
Returns
Name | Type | Description |
---|---|---|
target | address | The target of the transaction. |
value | uint256 | The value of the transaction. |
data | bytes | The data of the transaction. |
executed | bool | Whether the transaction was executed or not. |
getSubmittedLists
Gets the array of submitted lists in the session. Note that this function is O(n), where n is the number of submissions in the session. This could exceed the gas limit, therefore this function should only be used for interface display and not by other contracts.
function getSubmittedLists(uint256 _session) external view returns (uint256[] memory submittedLists);
Parameters
Name | Type | Description |
---|---|---|
_session | uint256 | The ID of the session. |
Returns
Name | Type | Description |
---|---|---|
submittedLists | uint256[] | Indexes of lists that were submitted during the session. |
getNumberOfTransactions
Gets the number of transactions in the list.
function getNumberOfTransactions(uint256 _listID) external view returns (uint256 txCount);
Parameters
Name | Type | Description |
---|---|---|
_listID | uint256 | The index of the transaction list in the array of lists. |
Returns
Name | Type | Description |
---|---|---|
txCount | uint256 | The number of transactions in the list. |
getNumberOfCreatedLists
Gets the number of lists created in contract's lifetime.
function getNumberOfCreatedLists() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The number of created lists. |
getCurrentSessionNumber
Gets the number of the ongoing session.
function getCurrentSessionNumber() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The number of the ongoing session. |
Events
ListSubmitted
Emitted when a new list is submitted.
event ListSubmitted(uint256 indexed _listID, address indexed _submitter, uint256 indexed _session, string _description);
Structs
Session
struct Session {
uint256 ruling;
uint256 disputeID;
uint256[] submittedLists;
uint256 sumDeposit;
Status status;
mapping(bytes32 => bool) alreadySubmitted;
uint256 durationOffset;
}
Transaction
struct Transaction {
address target;
uint256 value;
bytes data;
bool executed;
}
Submission
struct Submission {
address payable submitter;
uint256 deposit;
Transaction[] txs;
bytes32 listHash;
uint256 submissionTime;
bool approved;
uint256 approvalTime;
}
Enums
Status
enum Status {
NoDispute,
DisputeCreated,
Resolved
}