More consistent contract parameter naming
This commit is contained in:
parent
e9c6f1e4a7
commit
7f30006703
@ -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 ProposalCreated(uint256 id, address creator, uint recipientId, uint256 amount);
|
||||
event ProposalVoted(uint256 id, address voter, uint256 totalVotes);
|
||||
event ProposalExecuted(uint256 id, uint recipient, uint256 amount);
|
||||
event ProposalExecuted(uint256 id, uint recipientId, uint256 amount);
|
||||
|
||||
modifier coreOnly() {
|
||||
require(contributorsContract().addressIsCore(msg.sender));
|
||||
@ -55,45 +55,29 @@ 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 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));
|
||||
function addProposal(uint recipientId, uint256 amount, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize) public returns {
|
||||
require(contributorsContract().exists(recipientId));
|
||||
|
||||
proposalId = proposalsCount + 1;
|
||||
uint _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.recipientId = recipientId;
|
||||
p.amount = amount;
|
||||
p.ipfsHash = ipfsHash;
|
||||
p.hashFunction = hashFunction;
|
||||
p.hashSize = hashSize;
|
||||
p.votesCount = 0;
|
||||
p.votesNeeded = _votesNeeded;
|
||||
p.votesNeeded = votesNeeded;
|
||||
p.exists = true;
|
||||
|
||||
proposalsCount++;
|
||||
ProposalCreated(proposalId, msg.sender, p.recipientId, 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 id) 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[id];
|
||||
return (
|
||||
p.creator,
|
||||
p.recipientId,
|
||||
@ -109,25 +93,22 @@ 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, msg.sender, 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);
|
||||
@ -135,7 +116,6 @@ contract Operator is Upgradeable {
|
||||
tokenContract().mintFor(recipientAddress, p.amount, proposalId);
|
||||
p.executed = true;
|
||||
ProposalExecuted(proposalId, p.recipientId, p.amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 recipientAddress, uint256 amount, uint proposalId) onlyRegistryContractFor('Operator') public {
|
||||
totalSupply_ = totalSupply_.add(amount);
|
||||
balances[recipientAddress] = balances[recipientAddress].add(amount);
|
||||
|
||||
LogMint(_recipient, _amount, _proposalId);
|
||||
return true;
|
||||
LogMint(recipientAddress, amount, proposalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user