Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdossa committed Jul 3, 2019
1 parent 490a95d commit f80a50a
Show file tree
Hide file tree
Showing 9 changed files with 3,994 additions and 1,917 deletions.
23 changes: 13 additions & 10 deletions contracts/Arbitration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,16 @@ contract Arbitration {
/**
* @dev Calculates the current end time of the voting period
*/
function calcDisputeEnds() public hasState(State.Dispute) returns(uint256) {
function calcDisputeEnds() public view hasState(State.Dispute) returns(uint256, uint256) {
//Extend dispute period if:
// - vote is tied
// - more than 5% of votes places in last 30 minutes of dispute period
if (getNow() < disputeEnds) {
return disputeEnds;
return (disputeEnds, disputeWindowVotes);
}
if (disputeWindowVotes > totalVotes.mul(DISPUTE_WINDOW_MAX).div(10**18)) {
disputeWindowVotes = 0;
return disputeEnds.add(DISPUTE_EXTENSION);
//disputeWindowVotes = 0;
return (disputeEnds.add(DISPUTE_EXTENSION), 0);
}
uint256 winningVotes = partyVotes[address(0)];
for (uint8 i = 0; i < allParties.length; i++) {
Expand All @@ -440,11 +440,11 @@ contract Arbitration {
}
}
if (countWinners > 1) {
disputeWindowVotes = 0;
//disputeWindowVotes = 0;
//New end time is calculated from now
return getNow().add(DISPUTE_EXTENSION);
return (getNow().add(DISPUTE_EXTENSION), 0);
}
return disputeEnds;
return (disputeEnds, disputeWindowVotes);
}

//Functions to allow voting on disputed agreements
Expand All @@ -469,10 +469,11 @@ contract Arbitration {
}

function _vote(address _sender, address _voteAddress, uint256 _voteAmount) internal hasState(State.Dispute) {
uint256 newDisputeEnds = calcDisputeEnds();
(uint256 newDisputeEnds, uint256 newDisputeWindowVotes) = calcDisputeEnds();
if (newDisputeEnds != disputeEnds) {
emit DisputeEndsAdjusted(newDisputeEnds, disputeEnds);
disputeEnds = newDisputeEnds;
disputeWindowVotes = newDisputeWindowVotes;
}
require(getNow() < disputeEnds);
//Parties are allowed to vote straightaway
Expand Down Expand Up @@ -519,10 +520,11 @@ contract Arbitration {
*/
function payoutVoter(uint256 _start, uint256 _end) public hasState(State.Dispute) {
//Generally setting _start to 0 and _end to a large number should be fine, but having the option avoids a possible block gas limit issue
uint256 newDisputeEnds = calcDisputeEnds();
(uint256 newDisputeEnds, uint256 newDisputeWindowVotes) = calcDisputeEnds();
if (newDisputeEnds != disputeEnds) {
emit DisputeEndsAdjusted(newDisputeEnds, disputeEnds);
disputeEnds = newDisputeEnds;
disputeWindowVotes = newDisputeWindowVotes;
}
require(getNow() >= disputeEnds.add(VOTE_LOCKUP));
//There should be a clear winner now, otherwise the dispute would have been extended.
Expand Down Expand Up @@ -589,10 +591,11 @@ contract Arbitration {
* @dev Allows sender (party) to claim their dispersal tokens
*/
function payoutParty() public hasState(State.Dispute) onlyParties {
uint256 newDisputeEnds = calcDisputeEnds();
(uint256 newDisputeEnds, uint256 newDisputeWindowVotes) = calcDisputeEnds();
if (newDisputeEnds != disputeEnds) {
emit DisputeEndsAdjusted(newDisputeEnds, disputeEnds);
disputeEnds = newDisputeEnds;
disputeWindowVotes = newDisputeWindowVotes;
}
require(getNow() >= disputeEnds);
require(!hasWithdrawn[msg.sender]);
Expand Down
24 changes: 24 additions & 0 deletions contracts/JURToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import "openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
contract JURToken is MintableToken {

mapping (bytes4 => bool) allowedFunctions;
string public name = "JUR Token";
string public symbol = "JUR";
uint8 public decimals = 18;


/**
Expand All @@ -18,6 +21,27 @@ contract JURToken is MintableToken {
}
}

/**
* @dev Override: function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address _to,
uint256 _amount
)
canMint
public
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}

/**
* @dev Adds / removes functions from list of functions which are allowed with approve and call
* @param _sig Signature of function to add / remove
Expand Down
4 changes: 3 additions & 1 deletion migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ let voteJURFunction = {
};
let voteJUR = web3.eth.abi.encodeFunctionSignature(voteJURFunction);

module.exports = function (deployer, network, accounts) {
console.log([signJUR, proposeAmendmentJUR, agreeAmendmentJUR, disputeJUR, voteJUR]);

module.exports = function (deployer, network, accounts) {
console.log([signJUR, proposeAmendmentJUR, agreeAmendmentJUR, disputeJUR, voteJUR]);
return deployer.deploy(JURToken, [signJUR, proposeAmendmentJUR, agreeAmendmentJUR, disputeJUR, voteJUR]).then(() => {
return JURToken.deployed().then((jurToken) => {
return deployer.deploy(ArbitrationFactory, JURToken.address);
Expand Down
Loading

0 comments on commit f80a50a

Please sign in to comment.