diff --git a/contracts/Abie.sol b/contracts/Abie.sol index 8be699e..1bf72cb 100755 --- a/contracts/Abie.sol +++ b/contracts/Abie.sol @@ -1,5 +1,5 @@ //Part of this contract is from the solidity documentation -pragma solidity ^0.4.8; +pragma solidity ^0.5.7; /** Prepare for deployments: * @@ -18,11 +18,11 @@ contract Abie { uint public nbMembers; uint public nbProposalsFund; uint public nbMembershipReq; - uint public registrationTime = 1 years; + uint public registrationTime = 365; uint[2] public voteLength = [5 minutes, 5 minutes]; uint MAX_DELEGATION_DEPTH=10; - address NOT_COUNTED=0; - address COUNTED=1; + address payable NOT_COUNTED= address(0); + address payable COUNTED= address(1); event Donated(address donor, uint amount); @@ -81,7 +81,7 @@ contract Abie { } /// @param initialMembers First members of the organization. - function Abie(bytes32 _name, bytes32 _statement, address[] initialMembers) public{ + constructor(bytes32 _name, bytes32 _statement, address[] memory initialMembers) public{ name=_name; statement=_statement; for (uint i;i= 1000000000000000000000000); - Donated(msg.sender, msg.value); + emit Donated(msg.sender, msg.value); } /// Ask for membership. function askMembership () payable public costs(fee) { - Donated(msg.sender,msg.value); // Register the donation. + emit Donated(msg.sender,msg.value); // Register the donation. // Create a proposal to add the member. proposals.push(Proposal({ @@ -140,7 +140,7 @@ contract Abie { data: 0x0, proposalType: ProposalType.AddMember, endDate: now + 5 minutes, - lastMemberCounted: 0, + lastMemberCounted: address(0), executed: false })); @@ -149,7 +149,7 @@ contract Abie { /// Add Proposal. function addProposal (bytes32 _name, uint _value, bytes32 _data) payable public costs(fee) { //require(msg.value+address(this).balance >= address(this).balance); - Donated(msg.sender,msg.value); // Register the donation. + emit Donated(msg.sender,msg.value); // Register the donation. // Create a proposal to add the member. proposals.push(Proposal({ name: _name, @@ -160,7 +160,7 @@ contract Abie { data: _data, proposalType: ProposalType.FundProject, endDate: now + 5 minutes, - lastMemberCounted: 0, + lastMemberCounted: address(0), executed: false })); @@ -196,12 +196,12 @@ contract Abie { Proposal storage proposal = proposals[proposalID]; address current; require (proposal.endDate <= now); // You can't count while the vote is not over. - require (proposal.lastMemberCounted != COUNTED); // The count is already over + require (address(proposal.lastMemberCounted) != COUNTED); // The count is already over - if (proposal.lastMemberCounted == NOT_COUNTED) + if (address(proposal.lastMemberCounted) == NOT_COUNTED) current = memberList.first; else - current = proposal.lastMemberCounted; + current = address(proposal.lastMemberCounted); while (max-- != 0) { Member storage member = members[current]; @@ -215,7 +215,7 @@ contract Abie { depth+=1; delegate=members[delegate].delegate[uint(proposal.proposalType)]; // Find the delegate. if (delegate==current // The delegation chain forms a circle. - || delegate==0 // Has not set a delegate. + || delegate==address(0) // Has not set a delegate. || depth>MAX_DELEGATION_DEPTH) { // Too much depth, we must limit it in order to avoid some circle of delegation made to consume too much gaz. break; } @@ -233,8 +233,8 @@ contract Abie { } current=member.succ; // In next iteration start from the next node. - if (current==0) { // We reached the last member. - proposal.lastMemberCounted=COUNTED; + if (current==address(0)) { // We reached the last member. + proposal.lastMemberCounted=address(0); break; } } @@ -259,7 +259,7 @@ contract Abie { require(proposal.executed == false); // rejected if executed already require (beneficiary == msg.sender); // rejected if caller is not the beneficiary proposal.executed = true; // The proposal was executed. - beneficiary.transfer(check); // The beneficiary gets the requested amount. + address(uint160(beneficiary)).transfer(check); // The beneficiary gets the requested amount. } /// CONSTANTS /// @@ -268,14 +268,14 @@ contract Abie { * @param member member to get the delegate from. * @param proposalType 0 for AddMember, 1 for FundProject. */ - function getDelegate(address member, uint8 proposalType) public constant returns (address){ + function getDelegate(address member, uint8 proposalType) public view returns (address){ return members[member].delegate[proposalType]; } /** Return true if the proposal is validated, false otherwise. * @param proposalID ID of the proposal to count votes from. */ - function isExecutable(uint proposalID) public constant returns (bool) { + function isExecutable(uint proposalID) public view returns (bool) { Proposal storage proposal = proposals[proposalID]; if (proposal.lastMemberCounted != COUNTED) // Not counted yet. @@ -288,7 +288,7 @@ contract Abie { return (proposal.voteYes>proposal.voteNo); } - function isValidMember(address m) public constant returns(bool) { + function isValidMember(address m) public view returns(bool) { if (members[m].registration==0) // Not a member. return false; if (members[m].registration+registrationTime