diff --git a/contracts/Contributors.sol b/contracts/Contributors.sol index d876979..939d02b 100644 --- a/contracts/Contributors.sol +++ b/contracts/Contributors.sol @@ -49,7 +49,7 @@ contract Contributors is Upgradeable { return count; } - function updateContributorAddress(uint id, address oldAccount, address newAccount) public onlyCoreOrOperator { + function updateContributorAccount(uint id, address oldAccount, address newAccount) public onlyCoreOrOperator { contributorIds[oldAccount] = 0; contributorIds[newAccount] = id; contributors[id].account = newAccount; diff --git a/contracts/Operator.sol b/contracts/Operator.sol index 7b4fc6f..45541ba 100644 --- a/contracts/Operator.sol +++ b/contracts/Operator.sol @@ -7,8 +7,8 @@ import './Contributors.sol'; contract Operator is Upgradeable { struct Proposal { - address creator; - uint recipientId; + address creatorAccount; + uint contributorId; uint votesCount; uint votesNeeded; uint256 amount; @@ -24,9 +24,9 @@ contract Operator is Upgradeable { mapping(uint256 => Proposal) public proposals; uint256 public proposalsCount; - event ProposalCreated(uint256 id, address creator, uint recipient, uint256 amount); - event ProposalVoted(uint256 id, address voter, uint256 totalVotes); - event ProposalExecuted(uint256 id, uint recipient, uint256 amount); + event ProposalCreated(uint256 id, address creatorAccount, uint256 contributorId, uint256 amount); + event ProposalVoted(uint256 id, uint256 voterId, uint256 totalVotes); + event ProposalExecuted(uint256 id, uint256 contributorId, uint256 amount); modifier coreOnly() { require(contributorsContract().addressIsCore(msg.sender)); @@ -55,48 +55,34 @@ contract Operator is Upgradeable { return contributorsContract().coreContributorsCount(); } - function addContributor(address _address, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize, bool _isCore) public coreOnly { - contributorsContract().addContributor(_address, _ipfsHash, _hashFunction, _hashSize, _isCore); - } + function addProposal(uint contributorId, uint256 amount, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize) public { + require(contributorsContract().exists(contributorId)); - function updateContributorIpfsHash(uint _id, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize) public coreOnly { - contributorsContract().updateContributorIpfsHash(_id, _ipfsHash, _hashFunction, _hashSize); - } - - function getContributor(uint _id) view public returns (address account, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize, bool isCore) { - bool exists; - - (account, ipfsHash, hashFunction, hashSize, isCore, exists) = contributorsContract().contributors(_id); - - require(exists); - } - - function addProposal(uint _recipient, uint256 _amount, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize) public returns (uint256 proposalId) { - require(contributorsContract().exists(_recipient)); - - proposalId = proposalsCount + 1; - uint _votesNeeded = contributorsContract().coreContributorsCount() / 100 * 75; + uint256 proposalId = proposalsCount + 1; + uint256 _votesNeeded = contributorsContract().coreContributorsCount() / 100 * 75; var p = proposals[proposalId]; - p.creator = msg.sender; - p.recipientId = _recipient; - p.amount = _amount; - p.ipfsHash = _ipfsHash; - p.hashFunction = _hashFunction; - p.hashSize = _hashSize; + p.creatorAccount = msg.sender; + p.contributorId = contributorId; + p.amount = amount; + p.ipfsHash = ipfsHash; + p.hashFunction = hashFunction; + p.hashSize = hashSize; p.votesCount = 0; p.votesNeeded = _votesNeeded; p.exists = true; proposalsCount++; - ProposalCreated(proposalId, msg.sender, p.recipientId, p.amount); + ProposalCreated(proposalId, msg.sender, p.contributorId, p.amount); } - function getProposal(uint _proposalId) public view returns (address creator, uint256 recipientId, uint256 votesCount, uint256 votesNeeded, uint256 amount, bool executed, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize, uint256[] voterIds, bool exists) { - Proposal storage p = proposals[_proposalId]; + function getProposal(uint proposalId) public view returns (uint256 id, address creatorAccount, uint256 contributorId, uint256 votesCount, uint256 votesNeeded, uint256 amount, bool executed, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize, uint256[] voterIds, bool exists) { + id = proposalId; + Proposal storage p = proposals[id]; return ( - p.creator, - p.recipientId, + id, + p.creatorAccount, + p.contributorId, p.votesCount, p.votesNeeded, p.amount, @@ -109,33 +95,29 @@ contract Operator is Upgradeable { ); } - function vote(uint256 _proposalId) public coreOnly returns (uint _pId, bool _executed) { - var p = proposals[_proposalId]; + function vote(uint256 proposalId) public coreOnly { + var p = proposals[proposalId]; require(!p.executed); - uint256 contributorId = contributorsContract().getContributorIdByAddress(msg.sender); - require(p.votes[contributorId] != true); - p.voterIds.push(contributorId); - p.votes[contributorId] = true; + uint256 voterId = contributorsContract().getContributorIdByAddress(msg.sender); + require(p.votes[voterId] != true); + p.voterIds.push(voterId); + p.votes[voterId] = true; p.votesCount++; - _executed = false; - _pId = _proposalId; if (p.votesCount >= p.votesNeeded) { - executeProposal(_proposalId); - _executed = true; + executeProposal(proposalId); } - ProposalVoted(_pId, msg.sender, p.votesCount); + ProposalVoted(proposalId, voterId, p.votesCount); } - function executeProposal(uint proposalId) private returns (bool) { + function executeProposal(uint proposalId) private { var p = proposals[proposalId]; require(!p.executed); require(p.votesCount >= p.votesNeeded); - address recipientAddress = contributorsContract().getContributorAddressById(p.recipientId); + address recipientAddress = contributorsContract().getContributorAddressById(p.contributorId); tokenContract().mintFor(recipientAddress, p.amount, proposalId); p.executed = true; - ProposalExecuted(proposalId, p.recipientId, p.amount); - return true; + ProposalExecuted(proposalId, p.contributorId, p.amount); } } diff --git a/contracts/Token.sol b/contracts/Token.sol index d892165..9d81a9f 100644 --- a/contracts/Token.sol +++ b/contracts/Token.sol @@ -17,12 +17,11 @@ contract Token is Upgradeable, BasicToken { decimals = 18; } - function mintFor(address _recipient, uint256 _amount, uint _proposalId) onlyRegistryContractFor('Operator') public returns (bool success) { - totalSupply_ = totalSupply_.add(_amount); - balances[_recipient] = balances[_recipient].add(_amount); + function mintFor(address contributorAccount, uint256 amount, uint proposalId) onlyRegistryContractFor('Operator') public { + totalSupply_ = totalSupply_.add(amount); + balances[contributorAccount] = balances[contributorAccount].add(amount); - LogMint(_recipient, _amount, _proposalId); - return true; + LogMint(contributorAccount, amount, proposalId); } }