From 5434e82946bbdefc281b5f34ac4e5567ddb6312f Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sat, 25 Aug 2018 17:51:55 +0530 Subject: [PATCH] Fixed linting, added solhint --- contracts/EventCaller.sol | 7 +- contracts/GBTStandardToken.sol | 8 +- contracts/GovBlocksMaster.sol | 53 +- contracts/GovernCheckerContract.sol | 120 +-- contracts/Governance.sol | 175 +++-- contracts/GovernanceData.sol | 65 +- contracts/Governed.sol | 9 +- contracts/Master.sol | 25 +- contracts/MemberRoles.sol | 45 +- contracts/Pool.sol | 24 +- contracts/ProposalCategory.sol | 84 +-- contracts/ProposalCategoryAdder.sol | 3 +- contracts/SimpleVoting.sol | 185 ++--- contracts/TokenProxy.sol | 26 +- contracts/Upgradeable.sol | 7 +- contracts/VotingType.sol | 12 +- contracts/imports/lockable-token/ERC1132.sol | 2 +- package-lock.json | 738 +++++++++++++++++++ package.json | 3 +- test/06_GovernChecker.js | 2 +- test/07_Governance.js | 4 +- test/10_SimpleVoting.js | 3 + test/11_ProposalCategory.js | 2 - 23 files changed, 1174 insertions(+), 428 deletions(-) diff --git a/contracts/EventCaller.sol b/contracts/EventCaller.sol index 934f77d..92f1827 100644 --- a/contracts/EventCaller.sol +++ b/contracts/EventCaller.sol @@ -15,6 +15,7 @@ pragma solidity 0.4.24; + contract EventCaller { /// @dev VoteCast event is called whenever a vote is cast that can potentially close the proposal. @@ -34,7 +35,7 @@ contract EventCaller { /// @dev CloseProposalOnTime event is called whenever a proposal is created or updated to close it on time. /// closeProposalAddress is used to call closeProposal(proposalId) if proposal is ready to be closed. event CloseProposalOnTime ( - uint256 proposalId, + uint256 proposalId, address closeProposalAddress, uint256 time ); @@ -42,7 +43,7 @@ contract EventCaller { /// @dev ActionSuccess event is called whenever an onchain action is executed. /// closeProposalAddress is used to know which action. event ActionSuccess ( - uint256 proposalId, + uint256 proposalId, address closeProposalAddress ); @@ -76,6 +77,6 @@ contract EventCaller { /// @dev calls ActionSuccess event /// @param _proposalId Proposal ID for which the action is executed function callActionSuccess (uint256 _proposalId) external { - emit ActionSuccess(_proposalId, msg.sender); + emit ActionSuccess(_proposalId, msg.sender); } } \ No newline at end of file diff --git a/contracts/GBTStandardToken.sol b/contracts/GBTStandardToken.sol index 74b5755..e76b81a 100644 --- a/contracts/GBTStandardToken.sol +++ b/contracts/GBTStandardToken.sol @@ -19,11 +19,12 @@ import "./imports/lockable-token/ERC1132.sol"; import "./imports/openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol"; import "./imports/openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol"; + contract GBTStandardToken is ERC1132, MintableToken, DetailedERC20 { uint public tokenPrice; /// @dev constructor - constructor() DetailedERC20("GovBlocks Standard Token", "GBT", 18) public { + constructor() public DetailedERC20("GovBlocks Standard Token", "GBT", 18) { owner = msg.sender; totalSupply_ = 10 ** 20; balances[address(msg.sender)] = totalSupply_; @@ -38,9 +39,4 @@ contract GBTStandardToken is ERC1132, MintableToken, DetailedERC20 { emit Mint(msg.sender, actualAmount); emit Transfer(address(0), msg.sender, actualAmount); } - - /*/// @dev function to change Token price - function changeTokenPrice(uint _price) public onlyOwner { - tokenPrice = _price; - }*/ } \ No newline at end of file diff --git a/contracts/GovBlocksMaster.sol b/contracts/GovBlocksMaster.sol index 3205c2f..b1599c1 100644 --- a/contracts/GovBlocksMaster.sol +++ b/contracts/GovBlocksMaster.sol @@ -39,23 +39,6 @@ contract GovBlocksMaster is Ownable { string internal byteCodeHash; string internal contractsAbiHash; - /// @dev Initializes GovBlocks master - /// @param _gbtAddress GBT standard token address - function govBlocksMasterInit(address _gbtAddress, address _eventCaller) public { - require(!initialized); - - require (owner != address(0)); - - gbtAddress = _gbtAddress; - eventCaller = _eventCaller; - Governed govern = new Governed(); - governChecker = GovernChecker(govern.governChecker()); - masterByteCode = "0x496e6974616c697a65"; - if(address(governChecker) != address(0)) - governChecker.updateGBMAdress(address(this)); - initialized = true; - } - /// @dev Updates GBt standard token address /// @param _gbtContractAddress New GBT standard token contract address function updateGBTAddress(address _gbtContractAddress) external onlyOwner { @@ -63,12 +46,14 @@ contract GovBlocksMaster is Ownable { for (uint i = 0; i < allGovBlocksUsers.length; i++) { address masterAddress = govBlocksDapps[allGovBlocksUsers[i]].masterAddress; Master master = Master(masterAddress); + /* solhint-disable */ if (master.getCurrentVersion() > 0) { //Master can re enter but we don't expect to use this function ever on the public network if (address(master).call(bytes4(keccak256("changeGBTSAddress(address)")), _gbtContractAddress)) { //just to silence the compiler warning } - } + } + /* solhint-enable */ } } @@ -78,14 +63,16 @@ contract GovBlocksMaster is Ownable { for (uint i = 0; i < allGovBlocksUsers.length; i++) { address masterAddress = govBlocksDapps[allGovBlocksUsers[i]].masterAddress; Master master = Master(masterAddress); + /* solhint-disable */ if (master.getCurrentVersion() > 0) { //Master can re enter but we don't expect to use this function ever on the public network - if(address(master).call(bytes4(keccak256("changeGBMAddress(address)")), _newGBMAddress)) { + if (address(master).call(bytes4(keccak256("changeGBMAddress(address)")), _newGBMAddress)) { //just to silence the compiler warning } - } + } + /* solhint-enable */ } - if(address(governChecker) != address(0)) + if (address(governChecker) != address(0)) governChecker.updateGBMAdress(_newGBMAddress); } @@ -108,7 +95,7 @@ contract GovBlocksMaster is Ownable { /// @param _gbUserName dApp name /// @param _newMasterAddress dApp new master address function changeDappMasterAddress(bytes32 _gbUserName, address _newMasterAddress) external { - if(address(governChecker) != address(0)) // Owner for debugging only, will be removed before launch + if (address(governChecker) != address(0)) // Owner for debugging only, will be removed before launch require(governChecker.authorizedAddressNumber(_gbUserName, msg.sender) > 0 || owner == msg.sender); else require(owner == msg.sender); @@ -120,7 +107,7 @@ contract GovBlocksMaster is Ownable { /// @param _gbUserName dApp name /// @param _descHash dApp new desc hash function changeDappDescHash(bytes32 _gbUserName, string _descHash) external { - if(address(governChecker) != address(0)) // Owner for debugging only, will be removed before launch + if (address(governChecker) != address(0)) // Owner for debugging only, will be removed before launch require(governChecker.authorizedAddressNumber(_gbUserName, msg.sender) > 0 || owner == msg.sender); else require(owner == msg.sender); @@ -131,7 +118,7 @@ contract GovBlocksMaster is Ownable { /// @param _gbUserName dApp name /// @param _dappTokenAddress dApp new token address function changeDappTokenAddress(bytes32 _gbUserName, address _dappTokenAddress) external { - if(address(governChecker) != address(0)) // Owner for debugging only, will be removed before launch + if (address(governChecker) != address(0)) // Owner for debugging only, will be removed before launch require(governChecker.authorizedAddressNumber(_gbUserName, msg.sender) > 0 || owner == msg.sender); else require(owner == msg.sender); @@ -162,6 +149,22 @@ contract GovBlocksMaster is Ownable { eventCaller = _eventCaller; } + /// @dev Initializes GovBlocks master + /// @param _gbtAddress GBT standard token address + function govBlocksMasterInit(address _gbtAddress, address _eventCaller) public { + require(!initialized); + require(owner != address(0)); + + gbtAddress = _gbtAddress; + eventCaller = _eventCaller; + Governed govern = new Governed(); + governChecker = GovernChecker(govern.governChecker()); + masterByteCode = "0x496e6974616c697a65"; + if (address(governChecker) != address(0)) + governChecker.updateGBMAdress(address(this)); + initialized = true; + } + /// @dev Gets byte code and abi hash function getByteCodeAndAbi() public view returns(string, string) { return (byteCodeHash, contractsAbiHash); @@ -295,9 +298,11 @@ contract GovBlocksMaster is Ownable { /// @dev Deploys a new Master function deployMaster(bytes32 _gbUserName, bytes _masterByteCode) internal returns(address deployedAddress) { + /* solhint-disable */ assembly { deployedAddress := create(0, add(_masterByteCode, 0x20), mload(_masterByteCode)) // deploys contract } + /* solhint-enable */ Master master = Master(deployedAddress); master.initMaster(msg.sender, _gbUserName); } diff --git a/contracts/GovernCheckerContract.sol b/contracts/GovernCheckerContract.sol index d7ddd16..7c4b626 100644 --- a/contracts/GovernCheckerContract.sol +++ b/contracts/GovernCheckerContract.sol @@ -17,69 +17,69 @@ pragma solidity 0.4.24; contract GBM { - function getDappMasterAddress(bytes32 _gbUserName) public view returns(address masterAddress); + function getDappMasterAddress(bytes32 _gbUserName) public view returns(address masterAddress); } contract GovernCheckerContract { - mapping (bytes32 => address[]) public authorized; //Mapping to store authorized address of every dApp - - GBM internal govBlockMaster; //GovBlockMaster instance to prevent registeration of non existant dApps. - - /// @dev Updates GBM address, can only be called by current GBM - /// @param _govBlockMaster new govBlockMaster address - function updateGBMAdress(address _govBlockMaster) public { - require(address(govBlockMaster) == msg.sender || address(govBlockMaster) == address(0)); - govBlockMaster = GBM(_govBlockMaster); - } - - /// @dev Allows dApp's master to add authorized address for initalization - /// @param _dAppName new dApp's name - /// @param _authorizedAddress authorized address of the new dapp - function initializeAuthorized(bytes32 _dAppName, address _authorizedAddress) public { - require(authorized[_dAppName].length == 0); - if(address(govBlockMaster) != address(0)) - require(govBlockMaster.getDappMasterAddress(_dAppName) == msg.sender); - authorized[_dAppName].push(_authorizedAddress); - } - - /// @dev Allows the authorized address to pass on the authorized to someone else - /// @param _dAppName dApp's name whose _authorizedAddress has to be changed - /// @param _authorizedAddress new authorized address of the dapp - function updateAuthorized(bytes32 _dAppName, address _authorizedAddress) public { - uint authNumber = authorizedAddressNumber(_dAppName, msg.sender); - require(authNumber > 0); - authorized[_dAppName][authNumber - 1] = _authorizedAddress; - } - - /// @dev add authorized address (a new voting type) - /// @param _dAppName dApp's name whose _authorizedAddress has to be changed - /// @param _authorizedAddress new authorized address of the dapp - function addAuthorized(bytes32 _dAppName, address _authorizedAddress) public { - uint authNumber = authorizedAddressNumber(_dAppName, msg.sender); - require(authNumber > 0); - authNumber = authorizedAddressNumber(_dAppName, _authorizedAddress); - if(authNumber == 0) - authorized[_dAppName].push(_authorizedAddress); - } - - /// @dev checks if an address is authprized and returns its authorized number. - /// returns 0 if not authorized. - function authorizedAddressNumber(bytes32 _dAppName, address _authorizedAddress) - public - view - returns(uint authorizationNumber) - { - for(uint i = 0; i < authorized[_dAppName].length; i++) { - if(authorized[_dAppName][i] == _authorizedAddress) { - return(i + 1); - } - } - } - - /// @dev Returns govBlockMaster Address - function GetGovBlockMasterAddress() public view returns(address) { - return address(govBlockMaster); - } + mapping (bytes32 => address[]) public authorized; //Mapping to store authorized address of every dApp + + GBM internal govBlockMaster; //GovBlockMaster instance to prevent registeration of non existant dApps. + + /// @dev Updates GBM address, can only be called by current GBM + /// @param _govBlockMaster new govBlockMaster address + function updateGBMAdress(address _govBlockMaster) public { + require(address(govBlockMaster) == msg.sender || address(govBlockMaster) == address(0)); + govBlockMaster = GBM(_govBlockMaster); + } + + /// @dev Allows dApp's master to add authorized address for initalization + /// @param _dAppName new dApp's name + /// @param _authorizedAddress authorized address of the new dapp + function initializeAuthorized(bytes32 _dAppName, address _authorizedAddress) public { + require(authorized[_dAppName].length == 0); + if (address(govBlockMaster) != address(0)) + require(govBlockMaster.getDappMasterAddress(_dAppName) == msg.sender); + authorized[_dAppName].push(_authorizedAddress); + } + + /// @dev Allows the authorized address to pass on the authorized to someone else + /// @param _dAppName dApp's name whose _authorizedAddress has to be changed + /// @param _authorizedAddress new authorized address of the dapp + function updateAuthorized(bytes32 _dAppName, address _authorizedAddress) public { + uint authNumber = authorizedAddressNumber(_dAppName, msg.sender); + require(authNumber > 0); + authorized[_dAppName][authNumber - 1] = _authorizedAddress; + } + + /// @dev add authorized address (a new voting type) + /// @param _dAppName dApp's name whose _authorizedAddress has to be changed + /// @param _authorizedAddress new authorized address of the dapp + function addAuthorized(bytes32 _dAppName, address _authorizedAddress) public { + uint authNumber = authorizedAddressNumber(_dAppName, msg.sender); + require(authNumber > 0); + authNumber = authorizedAddressNumber(_dAppName, _authorizedAddress); + if (authNumber == 0) + authorized[_dAppName].push(_authorizedAddress); + } + + /// @dev checks if an address is authprized and returns its authorized number. + /// returns 0 if not authorized. + function authorizedAddressNumber(bytes32 _dAppName, address _authorizedAddress) + public + view + returns(uint authorizationNumber) + { + for (uint i = 0; i < authorized[_dAppName].length; i++) { + if (authorized[_dAppName][i] == _authorizedAddress) { + return(i + 1); + } + } + } + + /// @dev Returns govBlockMaster Address + function getGovBlockMasterAddress() public view returns(address) { + return address(govBlockMaster); + } } \ No newline at end of file diff --git a/contracts/Governance.sol b/contracts/Governance.sol index f7ed753..b83d3e7 100644 --- a/contracts/Governance.sol +++ b/contracts/Governance.sol @@ -49,6 +49,31 @@ contract Governance is Upgradeable { _; } + /// @dev Creates a new proposal + /// @param _proposalDescHash Proposal description hash through IPFS having Short and long description of proposal + /// @param _votingTypeId Voting type id that depicts which voting procedure to follow for this proposal + /// @param _subCategoryId This id tells under which the proposal is categorized i.e. Proposal's Objective + /// @param _solutionHash Solution hash contains parameters, values and description needed according to proposal + function createProposalwithSolution( + string _proposalTitle, + string _proposalSD, + string _proposalDescHash, + uint _votingTypeId, + uint _subCategoryId, + string _solutionHash, + bytes _action + ) + external + { + uint _proposalId = governanceDat.getProposalLength(); + createProposal(_proposalTitle, _proposalSD, _proposalDescHash, _votingTypeId, _subCategoryId); + proposalSubmission( + _proposalId, + _solutionHash, + _action + ); + } + /// @dev updates all dependency addresses to latest ones from Master function updateDependencyAddresses() public { dAppToken = master.dAppToken(); @@ -66,10 +91,10 @@ contract Governance is Upgradeable { function allowedToCreateProposal(uint category) public view returns(bool check) { uint[] memory mrAllowed = proposalCategory.getMRAllowed(category); if (mrAllowed[0] == 0) { - check = true; + check = true; return check; } else { - for(uint i = 0; i 0) { + if (_subCategoryId > 0) { + /* solhint-disable */ if (proposalCategory.isCategoryExternal(category)) token = address(govBlocksToken); else if (!governanceDat.dAppTokenSupportsLocking()) token = dAppTokenProxy; else token = dAppToken; - require (validateStake(_categoryId, token)); - governanceDat.addNewProposal(msg.sender, _categoryId, votingAddress, token); - uint incentive = proposalCategory.getCatIncentive(_categoryId); + /* solhint-enable */ + require(validateStake(_subCategoryId, token)); + governanceDat.addNewProposal(msg.sender, _subCategoryId, votingAddress, token); + uint incentive = proposalCategory.getSubCatIncentive(_subCategoryId); governanceDat.setProposalIncentive(_proposalId, incentive); } else governanceDat.createProposal1(msg.sender, votingAddress); } - /// @dev Creates a new proposal - /// @param _proposalDescHash Proposal description hash through IPFS having Short and long description of proposal - /// @param _votingTypeId Voting type id that depicts which voting procedure to follow for this proposal - /// @param _categoryId This id tells under which the proposal is categorized i.e. Proposal's Objective - /// @param _solutionHash Solution hash contains parameters, values and description needed according to proposal - function createProposalwithSolution( - string _proposalTitle, - string _proposalSD, - string _proposalDescHash, - uint _votingTypeId, - uint _categoryId, - string _solutionHash, - bytes _action - ) - external - { - uint _proposalId = governanceDat.getProposalLength(); - createProposal(_proposalTitle, _proposalSD, _proposalDescHash, _votingTypeId, _categoryId); - proposalSubmission( - _proposalId, - _solutionHash, - _action - ); - } - /// @dev Submit proposal with solution /// @param _proposalId Proposal id /// @param _solutionHash Solution hash contains parameters, values and description needed according to proposal @@ -168,40 +172,44 @@ contract Governance is Upgradeable { uint minStake; uint tokenholdingTime; (minStake, tokenholdingTime) = proposalCategory.getRequiredStake(_subCat); - if(minStake == 0) + if (minStake == 0) return true; GBTStandardToken tokenInstance = GBTStandardToken(_token); - tokenholdingTime += now; + tokenholdingTime += now; // solhint-disable-line uint lockedTokens = tokenInstance.tokensLockedAtTime(msg.sender, "GOV", tokenholdingTime); - if(lockedTokens > minStake) + if (lockedTokens > minStake) return true; } /// @dev Categorizes proposal to proceed further. Categories shows the proposal objective. function categorizeProposal( uint _proposalId, - uint _categoryId + uint _subCategoryId ) public checkProposalValidity(_proposalId) { - uint dappIncentive = proposalCategory.getCatIncentive(_categoryId); - require(memberRole.checkRoleIdByAddress(msg.sender, 1) || msg.sender == governanceDat.getProposalOwner(_proposalId)); + uint dappIncentive = proposalCategory.getSubCatIncentive(_subCategoryId); + require(memberRole.checkRoleIdByAddress(msg.sender, 1) + || msg.sender == governanceDat.getProposalOwner(_proposalId) + ); require(dappIncentive <= govBlocksToken.balanceOf(poolAddress)); - uint category = proposalCategory.getCategoryIdBySubId(_categoryId); + uint category = proposalCategory.getCategoryIdBySubId(_subCategoryId); require(allowedToCreateProposal(category)); governanceDat.setProposalIncentive(_proposalId, dappIncentive); address tokenAddress; + /* solhint-disable */ if (proposalCategory.isCategoryExternal(category)) tokenAddress = address(govBlocksToken); else if (!governanceDat.dAppTokenSupportsLocking()) tokenAddress = dAppTokenProxy; else tokenAddress = dAppToken; - require (validateStake(_categoryId, tokenAddress)); - governanceDat.setProposalCategory(_proposalId, _categoryId, tokenAddress); + /* solhint-enable */ + require(validateStake(_subCategoryId, tokenAddress)); + governanceDat.setProposalSubCategory(_proposalId, _subCategoryId, tokenAddress); } /// @dev Opens proposal for voting @@ -212,7 +220,7 @@ contract Governance is Upgradeable { onlyProposalOwner(_proposalId) checkProposalValidity(_proposalId) { - uint category = proposalCategory.getCategoryIdBySubId(governanceDat.getProposalCategory(_proposalId)); + uint category = proposalCategory.getCategoryIdBySubId(governanceDat.getProposalSubCategory(_proposalId)); require(category != 0); governanceDat.changeProposalStatus(_proposalId, 2); callCloseEvent(_proposalId); @@ -242,7 +250,11 @@ contract Governance is Upgradeable { /// @dev Calculates member reward to be claimed /// @param _memberAddress Member address /// @return rewardToClaim Rewards to be claimed - function calculateMemberReward(address _memberAddress) public onlyInternal returns(uint pendingGBTReward, uint pendingDAppReward) { + function calculateMemberReward(address _memberAddress) + public + onlyInternal + returns(uint pendingGBTReward, uint pendingDAppReward) + { uint lastRewardProposalId; uint lastRewardSolutionProposalId; (lastRewardProposalId, lastRewardSolutionProposalId) = @@ -255,7 +267,7 @@ contract Governance is Upgradeable { pendingGBTReward += tempGBTReward; pendingDAppReward += tempDAppRward; uint votingTypes = governanceDat.getVotingTypeLength(); - for(uint i = 0; i < votingTypes; i++) { + for (uint i = 0; i < votingTypes; i++) { VotingType votingType = VotingType(governanceDat.getVotingTypeAddress(i)); (tempGBTReward, tempDAppRward) = votingType.claimVoteReward(_memberAddress); pendingGBTReward += tempGBTReward; @@ -274,7 +286,7 @@ contract Governance is Upgradeable { returns(uint totalTime) { uint pClosingTime; - uint subc = governanceDat.getProposalCategory(_proposalId); + uint subc = governanceDat.getProposalSubCategory(_proposalId); uint categoryId = proposalCategory.getCategoryIdBySubId(subc); uint ctLength = proposalCategory.getCloseTimeLength(categoryId); for (uint i = _index; i < ctLength; i++) { @@ -284,7 +296,7 @@ contract Governance is Upgradeable { totalTime = pClosingTime + proposalCategory.getTokenHoldingTime(subc) + governanceDat.getProposalDateUpd(_proposalId) - - now; + - now; // solhint-disable-line } /// @dev Gets Total vote closing time against sub category i.e. @@ -343,12 +355,12 @@ contract Governance is Upgradeable { proposalId = _proposalId; for (uint i = 1; i < length; i++) { if (_memberAddress == governanceDat.getSolutionAddedByProposalId(_proposalId, i)) { - proposalId = _proposalId; + proposalId = _proposalId; solutionId = i; proposalStatus = governanceDat.getProposalStatus(_proposalId); finalVerdict = governanceDat.getProposalFinalVerdict(_proposalId); totalReward = governanceDat.getProposalIncentive(_proposalId); - subCategory = governanceDat.getProposalCategory(_proposalId); + subCategory = governanceDat.getProposalSubCategory(_proposalId); break; } } @@ -369,37 +381,13 @@ contract Governance is Upgradeable { /// @dev Call event for closing proposal /// @param _proposalId Proposal id which voting needs to be closed function callCloseEvent(uint _proposalId) internal { - uint subCategory = governanceDat.getProposalCategory(_proposalId); - uint _categoryId = proposalCategory.getCategoryIdBySubId(subCategory); - uint closingTime = proposalCategory.getClosingTimeAtIndex(_categoryId, 0) + now; + uint subCategory = governanceDat.getProposalSubCategory(_proposalId); + uint categoryId = proposalCategory.getCategoryIdBySubId(subCategory); + uint closingTime = proposalCategory.getClosingTimeAtIndex(categoryId, 0) + now; // solhint-disable-line address votingType = governanceDat.getProposalVotingAddress(_proposalId); eventCaller.callCloseProposalOnTimeAtAddress(_proposalId, votingType, closingTime); } - // /// @dev Edits the details of an existing proposal and creates new version - // /// @param _proposalId Proposal id that details needs to be updated - // /// @param _proposalDescHash Proposal description hash having long and short description of proposal. - // function updateProposalDetails1( - // uint _proposalId, - // string _proposalTitle, - // string _proposalSD, - // string _proposalDescHash - // ) - // internal - // { - // governanceDat.storeProposalVersion(_proposalId, _proposalDescHash); - // governanceDat.setProposalDateUpd(_proposalId); - // governanceDat.changeProposalStatus(_proposalId, 1); - // governanceDat.callProposalEvent( - // governanceDat.getProposalOwner(_proposalId), - // _proposalId, - // now, - // _proposalTitle, - // _proposalSD, - // _proposalDescHash - // ); - // } - /// @dev Calculate reward for proposal creation against member /// @param _memberAddress Address of member who claimed the reward /// @param _lastRewardProposalId Last id proposal till which the reward being distributed @@ -421,11 +409,15 @@ contract Governance is Upgradeable { for (i = _lastRewardProposalId; i < allProposalLength; i++) { if (_memberAddress == governanceDat.getProposalOwner(i)) { - (rewardClaimed, subCategory, proposalStatus, finalVredict) = governanceDat.getProposalDetailsById3(i, _memberAddress); + (rewardClaimed, subCategory, proposalStatus, finalVredict) = + governanceDat.getProposalDetailsById3(i, _memberAddress); if (proposalStatus <= 2 && lastIndex == 0) lastIndex = i; if (proposalStatus > 2 && finalVredict > 0 && !rewardClaimed) { - calcReward = (proposalCategory.getRewardPercProposal(subCategory).mul(governanceDat.getProposalIncentive(i))).div(100); + calcReward = proposalCategory.getRewardPercProposal(subCategory).mul( + governanceDat.getProposalIncentive(i) + ); + calcReward = calcReward.div(100); if (proposalCategory.isSubCategoryExternal(subCategory)) pendingGBTReward += calcReward; else @@ -477,7 +469,7 @@ contract Governance is Upgradeable { address _memberAddress, uint _lastRewardSolutionProposalId ) - public + internal returns(uint pendingGBTReward, uint pendingDAppReward) { uint allProposalLength = governanceDat.getProposalLength(); @@ -495,14 +487,16 @@ contract Governance is Upgradeable { getSolutionIdAgainstAddressProposal(_memberAddress, i); if (proposalStatus <= 2 && lastIndex == 0) lastIndex = i; - if (finalVerdict > 0 && finalVerdict == solutionId && !governanceDat.getRewardClaimed(i,_memberAddress)) { - governanceDat.setRewardClaimed(i,_memberAddress); - calcReward = (proposalCategory.getRewardPercSolution(subCategory) * totalReward) / 100; - if (proposalCategory.isSubCategoryExternal(subCategory)) - pendingGBTReward += calcReward; - else - pendingDAppReward += calcReward; - calculateSolutionReward1(_memberAddress, i, calcReward); + if (finalVerdict > 0 && finalVerdict == solutionId) { + if (!governanceDat.getRewardClaimed(i, _memberAddress)) { + governanceDat.setRewardClaimed(i, _memberAddress); + calcReward = (proposalCategory.getRewardPercSolution(subCategory) * totalReward) / 100; + if (proposalCategory.isSubCategoryExternal(subCategory)) + pendingGBTReward += calcReward; + else + pendingDAppReward += calcReward; + calculateSolutionReward1(_memberAddress, i, calcReward); + } } } @@ -572,7 +566,7 @@ contract Governance is Upgradeable { _solutionHash, _action ); - + /* solhint-disable */ governanceDat.callProposalWithSolutionEvent( msg.sender, _proposalId, @@ -580,6 +574,7 @@ contract Governance is Upgradeable { _solutionHash, now ); + /* solhint-enable */ } } \ No newline at end of file diff --git a/contracts/GovernanceData.sol b/contracts/GovernanceData.sol index 510db9a..3ea8d59 100644 --- a/contracts/GovernanceData.sol +++ b/contracts/GovernanceData.sol @@ -22,7 +22,7 @@ import "./Governance.sol"; import "./VotingType.sol"; -contract GovernanceData is Upgradeable { +contract GovernanceData is Upgradeable { //solhint-disable-line event Proposal( address indexed proposalOwner, @@ -210,7 +210,7 @@ contract GovernanceData is Upgradeable { uint64 finalVerdict; uint64 currentVerdict; uint currVotingStatus; - uint category; + uint subCategory; uint versionNumber; uint totalVoteValue; uint commonIncentive; @@ -238,7 +238,7 @@ contract GovernanceData is Upgradeable { mapping(address => LastReward) internal lastRewardDetails; mapping(uint => bool) public proposalPaused; mapping(address => mapping(uint => bool)) internal rewardClaimed; - + uint public quorumPercentage; bool public constructorCheck; bool public punishVoters; @@ -271,7 +271,7 @@ contract GovernanceData is Upgradeable { setGlobalParameters(); addMemberReputationPoints(); setVotingTypeDetails("Simple Voting", address(0)); - allProposal.push(ProposalStruct(address(0), now, master.getLatestAddress("SV"))); + allProposal.push(ProposalStruct(address(0), now, master.getLatestAddress("SV"))); //solhint-disable-line constructorCheck = true; } @@ -308,11 +308,11 @@ contract GovernanceData is Upgradeable { } function toggleProposalPause(uint _proposalId) public onlyInternal { - if(!proposalPaused[_proposalId]) + if (!proposalPaused[_proposalId]) proposalPaused[_proposalId] = true; else { proposalPaused[_proposalId] = false; - allProposal[_proposalId].dateUpd = now; + allProposal[_proposalId].dateUpd = now; //solhint-disable-line } } @@ -415,8 +415,8 @@ contract GovernanceData is Upgradeable { } /// @dev Sets proposal category - function setProposalCategory(uint _proposalId, uint _categoryId, address _stakeToken) public onlyInternal { - allProposalData[_proposalId].category = _categoryId; + function setProposalSubCategory(uint _proposalId, uint _subCategoryId, address _stakeToken) public onlyInternal { + allProposalData[_proposalId].subCategory = _subCategoryId; allProposalData[_proposalId].stakeToken = _stakeToken; } @@ -427,8 +427,8 @@ contract GovernanceData is Upgradeable { /// @dev Changes the status of a given proposal. function changeProposalStatus(uint _id, uint8 _status) public onlyInternal { - require(allProposalData[_id].category != 0); - emit ProposalStatus(_id, _status, now); + require(allProposalData[_id].subCategory != 0); + emit ProposalStatus(_id, _status, now); //solhint-disable-line updateProposalStatus(_id, _status); } @@ -475,13 +475,13 @@ contract GovernanceData is Upgradeable { /// Maintains the record of all the versions of a proposal. function storeProposalVersion(uint _proposalId, string _proposalDescHash) public onlyInternal { uint versionNo = allProposalData[_proposalId].versionNumber + 1; - emit ProposalVersion(_proposalId, versionNo, _proposalDescHash, now); + emit ProposalVersion(_proposalId, versionNo, _proposalDescHash, now); //solhint-disable-line setProposalVersion(_proposalId, versionNo); } /// @dev Sets proposal's date when the proposal last modified function setProposalDateUpd(uint _proposalId) public onlyInternal { - allProposal[_proposalId].dateUpd = now; + allProposal[_proposalId].dateUpd = now; //solhint-disable-line } /// @dev Fetch details of proposal when giving proposal id @@ -505,7 +505,7 @@ contract GovernanceData is Upgradeable { view returns( uint id, - uint category, + uint subCategory, uint currentVotingId, uint64 intermediateVerdict, uint64 finalVerdict, @@ -515,7 +515,7 @@ contract GovernanceData is Upgradeable { { return ( _proposalId, - allProposalData[_proposalId].category, + allProposalData[_proposalId].subCategory, allProposalData[_proposalId].currVotingStatus, allProposalData[_proposalId].currentVerdict, allProposalData[_proposalId].finalVerdict, @@ -532,7 +532,7 @@ contract GovernanceData is Upgradeable { { return ( rewardClaimed[_memberAddress][_proposalId], - allProposalData[_proposalId].category, + allProposalData[_proposalId].subCategory, allProposalData[_proposalId].propStatus, allProposalData[_proposalId].finalVerdict ); @@ -601,7 +601,7 @@ contract GovernanceData is Upgradeable { } /// @dev Gets proposal current voting status i.e. Who is next in voting sequence - function getProposalCurrentVotingId(uint _proposalId) public view returns(uint _currVotingStatus) { + function getProposalCurrentVotingId(uint _proposalId) public view returns(uint) { return (allProposalData[_proposalId].currVotingStatus); } @@ -611,13 +611,13 @@ contract GovernanceData is Upgradeable { } /// @dev Get Current Status of proposal when given proposal Id - function getProposalStatus(uint _proposalId) public view returns(uint propStatus) { + function getProposalStatus(uint _proposalId) public view returns(uint) { return allProposalData[_proposalId].propStatus; } /// @dev Gets proposal sub category when given proposal id - function getProposalCategory(uint _proposalId) public view returns(uint) { - return allProposalData[_proposalId].category; + function getProposalSubCategory(uint _proposalId) public view returns(uint) { + return allProposalData[_proposalId].subCategory; } function setRewardClaimed(uint _proposalId, address _memberAddress) public onlyInternal { @@ -640,7 +640,8 @@ contract GovernanceData is Upgradeable { function getMemberReputationSV(address _memberAddress, uint32 _proposalId) public view - returns (uint, uint, uint, uint, uint, address, uint) { + returns (uint, uint, uint, uint, uint, address, uint) + { return( stakeWeight, bonusStake, @@ -648,19 +649,19 @@ contract GovernanceData is Upgradeable { bonusReputation, allMemberReputationByAddress[_memberAddress], allProposalData[_proposalId].stakeToken, - allProposalData[_proposalId].category + allProposalData[_proposalId].subCategory ); } /// @dev fetches details for simplevoting and also verifies that the voter has not casted a vote already function getProposalDetailsForSV(uint _proposalId) - external + public view returns(uint, uint, uint64) { require(allProposalData[_proposalId].propStatus == 2); return( - allProposalData[_proposalId].category, + allProposalData[_proposalId].subCategory, allProposalData[_proposalId].currVotingStatus, allProposalData[_proposalId].currentVerdict ); @@ -668,7 +669,7 @@ contract GovernanceData is Upgradeable { /// @dev gets total number of votes by a voter function getTotalNumberOfVotesByAddress(address _voter) public view returns(uint totalVotes) { - for(uint i=0; i 0); _; } @@ -42,12 +44,13 @@ contract Governed { /// @dev checks if an address is authorized to govern function isAuthorizedToGovern(address _toCheck) public view returns(bool) { - if(address(governChecker) == address(0) || governChecker.authorizedAddressNumber(dappName, _toCheck) > 0) + if (address(governChecker) == address(0) || governChecker.authorizedAddressNumber(dappName, _toCheck) > 0) return true; } /// @dev sets the address of governChecker based on the network being used. function setGovernChecker() public { + /* solhint-disable */ if (getCodeSize(0xF0AF942909632711694B02357B03fe967e18e32c) > 0) //kovan testnet governChecker = GovernChecker(0xF0AF942909632711694B02357B03fe967e18e32c); else if (getCodeSize(0xdF6c6a73BCf71E8CAa6A2c131bCf98f10eBb5162) > 0) //RSK testnet @@ -58,10 +61,12 @@ contract Governed { governChecker = GovernChecker(0xb5fE0857770D85302585564b04C81a5Be96022C8); else if (getCodeSize(0x962d110554E0b20E18E5c3680018b49A58EF0bBB) > 0) //Private testnet governChecker = GovernChecker(0x962d110554E0b20E18E5c3680018b49A58EF0bBB); + /* solhint-enable */ } /// @dev returns the code size at an address, used to confirm that a contract exisits at an address. function getCodeSize(address _addr) internal view returns(uint _size) { + //solhint-disable-next-line assembly { _size := extcodesize(_addr) } diff --git a/contracts/Master.sol b/contracts/Master.sol index 11fd033..5896730 100644 --- a/contracts/Master.sol +++ b/contracts/Master.sol @@ -38,23 +38,23 @@ contract Master is Ownable { address public dAppToken; function initMaster(address _ownerAddress, bytes32 _gbUserName) public { - require (address(gbm) == address(0)); + require(address(gbm) == address(0)); contractsActive[address(this)] = true; gbm = GovBlocksMaster(msg.sender); dAppName = _gbUserName; owner = _ownerAddress; - versionDates.push(now); + versionDates.push(now); //solhint-disable-line addContractNames(); } /// @dev Checks if the address is authorized to make changes. /// owner allowed for debugging only, will be removed before launch. function isAuth() public view returns(bool check) { - if(versionDates.length < 2) { - if(owner == msg.sender) + if (versionDates.length < 2) { + if (owner == msg.sender) check = true; } else { - if(getLatestAddress("SV") == msg.sender || owner == msg.sender) + if (getLatestAddress("SV") == msg.sender || owner == msg.sender) check = true; } } @@ -77,11 +77,11 @@ contract Master is Ownable { function addNewVersion(address[] _contractAddresses) public { require(isAuth()); address gbt = gbm.gbtAddress(); - if(versionDates.length < 2) { + if (versionDates.length < 2) { govern = new Governed(); GovernChecker governChecker = GovernChecker(govern.governChecker()); - if(getCodeSize(address(governChecker)) > 0 ){ - if(governChecker.authorizedAddressNumber(dAppName, _contractAddresses[3]) == 0) + if (getCodeSize(address(governChecker)) > 0) { + if (governChecker.authorizedAddressNumber(dAppName, _contractAddresses[3]) == 0) governChecker.initializeAuthorized(dAppName, _contractAddresses[3]); } dAppToken = gbm.getDappTokenAddress(dAppName); @@ -94,7 +94,7 @@ contract Master is Ownable { allContractVersions[versionDates.length]["GS"] = gbt; - versionDates.push(now); + versionDates.push(now); //solhint-disable-line changeMasterAddress(address(this)); changeAllAddress(); @@ -117,7 +117,7 @@ contract Master is Ownable { /// @dev Changes Master contract address function changeMasterAddress(address _masterAddress) public { - if(_masterAddress != address(this)){ + if (_masterAddress != address(this)) { require(isAuth()); } allContractVersions[versionDates.length - 1]["MS"] = _masterAddress; @@ -172,6 +172,7 @@ contract Master is Ownable { /// @dev Configures global parameters i.e. Voting or Reputation parameters /// @param _typeOf Passing intials of the parameter name which value needs to be updated /// @param _value New value that needs to be updated + // solhint-disable-next-line function configureGlobalParameters(bytes4 _typeOf, uint32 _value) public { require(isAuth()); GovernanceData governanceDat = GovernanceData(getLatestAddress("GD")); @@ -223,7 +224,7 @@ contract Master is Ownable { } function getCodeSize(address _addr) internal view returns(uint _size) { - assembly { + assembly { //solhint-disable-line _size := extcodesize(_addr) } } @@ -231,7 +232,7 @@ contract Master is Ownable { /// @dev Sets the older versions of contract addresses as inactive and the latest one as active. function changeAllAddress() internal { uint i; - if(versionDates.length < 3) { + if (versionDates.length < 3) { for (i = 1; i < allContractNames.length - 1; i++) { contractsActive[allContractVersions[versionDates.length - 1][allContractNames[i]]] = true; up = Upgradeable(allContractVersions[versionDates.length - 1][allContractNames[i]]); diff --git a/contracts/MemberRoles.sol b/contracts/MemberRoles.sol index 014edb9..f9dbf24 100644 --- a/contracts/MemberRoles.sol +++ b/contracts/MemberRoles.sol @@ -18,6 +18,7 @@ import "./imports/openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./imports/openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol"; import "./Governed.sol"; + contract MemberRoles is Governed { event MemberRole(uint256 indexed roleId, bytes32 roleName, string roleDescription, bool limitedValidity); using SafeMath for uint; @@ -25,7 +26,7 @@ contract MemberRoles is Governed { bytes32[] internal memberRole; StandardToken public dAppToken; bool internal constructorCheck; - uint constant UINT_MAX = uint256(0) - uint256(1); + uint constant internal UINT_MAX = uint256(0) - uint256(1); struct MemberRoleDetails { uint memberCounter; @@ -39,10 +40,10 @@ contract MemberRoles is Governed { mapping(uint => MemberRoleDetails) internal memberRoleData; modifier checkRoleAuthority(uint _memberRoleId) { - if(authorizedAddressAgainstRole[_memberRoleId] != address(0)) + if (authorizedAddressAgainstRole[_memberRoleId] != address(0)) require(msg.sender == authorizedAddressAgainstRole[_memberRoleId]); else - require (isAuthorizedToGovern(msg.sender)); + require(isAuthorizedToGovern(msg.sender)); _; } @@ -56,14 +57,14 @@ contract MemberRoles is Governed { emit MemberRole( 1, "Advisory Board", - "Selected few members that are deeply entrusted by the dApp. An ideal advisory board should be a mix of skills of domain, governance,research, technology, consulting etc to improve the performance of the dApp.", + "Selected few members that are deeply entrusted by the dApp. An ideal advisory board should be a mix of skills of domain, governance,research, technology, consulting etc to improve the performance of the dApp.", //solhint-disable-line false ); memberRole.push("Token Holder"); emit MemberRole( 2, "Token Holder", - "Represents all users who hold dApp tokens. This is the most general category and anyone holding token balance is a part of this category by default.", + "Represents all users who hold dApp tokens. This is the most general category and anyone holding token balance is a part of this category by default.", //solhint-disable-line false ); memberRoleData[1].memberCounter = 1; @@ -74,11 +75,11 @@ contract MemberRoles is Governed { } /// @dev To Initiate default settings whenever the contract is regenerated! - function updateDependencyAddresses() public pure { + function updateDependencyAddresses() public pure { //solhint-disable-line } /// @dev just to adhere to GovBlockss' Upgradeable interface - function changeMasterAddress() public pure { + function changeMasterAddress() public pure { //solhint-disable-line } /// @dev Get All role ids array that has been assigned to a member so far. @@ -88,13 +89,13 @@ contract MemberRoles is Governed { assignedRoles = new uint[](length); for (uint i = 0; i < getTotalMemberRoles(); i++) { if (memberRoleData[i].memberActive[_memberAddress] - && (!memberRoleData[i].limitedValidity || memberRoleData[i].validity[_memberAddress] > now) + && (!memberRoleData[i].limitedValidity || memberRoleData[i].validity[_memberAddress] > now) //solhint-disable-line ) { assignedRoles[j] = i; j++; } } - if(dAppToken.balanceOf(_memberAddress) > 0) { + if (dAppToken.balanceOf(_memberAddress) > 0) { assignedRoles[j] = 2; } @@ -109,17 +110,17 @@ contract MemberRoles is Governed { /// @param _memberAddress Address of member /// @param _roleId Checks member's authenticity with the roleId. /// i.e. Returns true if this roleId is assigned to member - function checkRoleIdByAddress(address _memberAddress, uint _roleId) external view returns(bool) { + function checkRoleIdByAddress(address _memberAddress, uint _roleId) public view returns(bool) { if (_roleId == 0) return true; if (_roleId == 2) { - if(dAppToken.balanceOf(_memberAddress) > 0) + if (dAppToken.balanceOf(_memberAddress) > 0) return true; else return false; } if (memberRoleData[_roleId].memberActive[_memberAddress] - && (!memberRoleData[_roleId].limitedValidity || memberRoleData[_roleId].validity[_memberAddress] > now)) + && (!memberRoleData[_roleId].limitedValidity || memberRoleData[_roleId].validity[_memberAddress] > now)) //solhint-disable-line return true; else return false; @@ -139,8 +140,8 @@ contract MemberRoles is Governed { checkRoleAuthority(_roleId) { if (_typeOf) { - if(memberRoleData[_roleId].validity[_memberAddress] <= _validity) { - if(!memberRoleData[_roleId].memberActive[_memberAddress]) { + if (memberRoleData[_roleId].validity[_memberAddress] <= _validity) { + if (!memberRoleData[_roleId].memberActive[_memberAddress]) { memberRoleData[_roleId].memberCounter = SafeMath.add(memberRoleData[_roleId].memberCounter, 1); memberRoleData[_roleId].memberActive[_memberAddress] = true; memberRoleData[_roleId].memberAddress.push(_memberAddress); @@ -180,7 +181,12 @@ contract MemberRoles is Governed { /// @param _newRoleName New role name /// @param _roleDescription New description hash /// @param _canAddMembers Authorized member against every role id - function addNewMemberRole(bytes32 _newRoleName, string _roleDescription, address _canAddMembers, bool _limitedValidity) + function addNewMemberRole( + bytes32 _newRoleName, + string _roleDescription, + address _canAddMembers, + bool _limitedValidity + ) public onlyAuthorizedToGovern { @@ -203,14 +209,15 @@ contract MemberRoles is Governed { for (i = 0; i < length; i++) { address member = memberRoleData[_memberRoleId].memberAddress[i]; if (memberRoleData[_memberRoleId].memberActive[member] - && (!memberRoleData[_memberRoleId].limitedValidity || memberRoleData[_memberRoleId].validity[member] > now) + && (!memberRoleData[_memberRoleId].limitedValidity + || memberRoleData[_memberRoleId].validity[member] > now) //solhint-disable-line ) { tempAllMemberAddress[j] = member; j++; } } allMemberAddress = new address[](j); - for(i = 0; i < j; i++) { + for (i = 0; i < j; i++) { allMemberAddress[i] = tempAllMemberAddress[i]; } return (_memberRoleId, allMemberAddress); @@ -270,10 +277,10 @@ contract MemberRoles is Governed { uint length = getTotalMemberRoles(); for (uint i = 0; i < length; i++) { if (memberRoleData[i].memberActive[_memberAddress] - && (!memberRoleData[i].limitedValidity || memberRoleData[i].validity[_memberAddress] > now)) + && (!memberRoleData[i].limitedValidity || memberRoleData[i].validity[_memberAddress] > now)) //solhint-disable-line count++; } - if(dAppToken.balanceOf(_memberAddress) > 0) + if (dAppToken.balanceOf(_memberAddress) > 0) count++; return count; } diff --git a/contracts/Pool.sol b/contracts/Pool.sol index fd4c375..1db84c7 100644 --- a/contracts/Pool.sol +++ b/contracts/Pool.sol @@ -23,6 +23,7 @@ import "./GovernanceData.sol"; import "./ProposalCategory.sol"; import "./VotingType.sol"; + contract Pool is Upgradeable { using SafeMath for uint; @@ -32,7 +33,7 @@ contract Pool is Upgradeable { GovernanceData internal governanceDat; ProposalCategory internal proposalCategory; - function () public payable {} + function () public payable {} //solhint-disable-line modifier onlySV { require( @@ -54,7 +55,7 @@ contract Pool is Upgradeable { /// @dev transfers its assets to latest addresses function transferAssets() public { address newPool = master.getLatestAddress("PL"); - if(address(this) != newPool) { + if (address(this) != newPool) { uint gbtBal = gbt.balanceOf(address(this)); uint ethBal = address(this).balance; if (gbtBal > 0) @@ -85,8 +86,9 @@ contract Pool is Upgradeable { } } - event Debu(uint a); - function getPendingReward(address _memberAddress) public view returns (uint pendingGBTReward, uint pendingDAppReward) { + function getPendingReward(address _memberAddress) + public view returns (uint pendingGBTReward, uint pendingDAppReward) + { uint lastRewardProposalId; uint lastRewardSolutionProposalId; uint tempGBTReward; @@ -98,7 +100,7 @@ contract Pool is Upgradeable { pendingDAppReward += tempDAppRward; uint votingTypes = governanceDat.getVotingTypeLength(); - for(uint i = 0; i < votingTypes; i++) { + for (uint i = 0; i < votingTypes; i++) { VotingType votingType = VotingType(governanceDat.getVotingTypeAddress(i)); (tempGBTReward, tempDAppRward) = votingType.getPendingReward(_memberAddress); pendingGBTReward += tempGBTReward; @@ -119,15 +121,15 @@ contract Pool is Upgradeable { bool rewardClaimed; for (uint i = _lastRewardProposalId; i < allProposalLength; i++) { if (_memberAddress == governanceDat.getProposalOwner(i)) { - (rewardClaimed, subCat, proposalStatus, finalVredict) = governanceDat.getProposalDetailsById3(i, _memberAddress); + (rewardClaimed, subCat, proposalStatus, finalVredict) = + governanceDat.getProposalDetailsById3(i, _memberAddress); if ( proposalStatus > 2 && finalVredict > 0 && governanceDat.getProposalIncentive(i) != 0 && !rewardClaimed - ) - { - calcReward = (proposalCategory.getRewardPercProposal(subCat).mul(governanceDat.getProposalIncentive(i))).div(100); + ) { + calcReward = (proposalCategory.getRewardPercProposal(subCat).mul(governanceDat.getProposalIncentive(i))).div(100); //solhint-disable-line if (proposalCategory.isSubCategoryExternal(subCat)) pendingGBTReward += calcReward; else @@ -154,7 +156,9 @@ contract Pool is Upgradeable { for (i = _lastRewardSolutionProposalId; i < allProposalLength; i++) { (proposalId, solutionId, , finalVerdict, totalReward, subCategory) = gov.getSolutionIdAgainstAddressProposal(_memberAddress, i); - if (finalVerdict > 0 && finalVerdict == solutionId && proposalId == i && !governanceDat.getRewardClaimed(i,_memberAddress)) { + if (finalVerdict > 0 && finalVerdict == solutionId && proposalId == i + && !governanceDat.getRewardClaimed(i, _memberAddress) + ) { calcReward = (proposalCategory.getRewardPercSolution(subCategory) * totalReward) / 100; if (proposalCategory.isSubCategoryExternal(subCategory)) pendingGBTReward += calcReward; diff --git a/contracts/ProposalCategory.sol b/contracts/ProposalCategory.sol index a44d042..9c12e03 100644 --- a/contracts/ProposalCategory.sol +++ b/contracts/ProposalCategory.sol @@ -16,8 +16,10 @@ pragma solidity 0.4.24; import "./Governed.sol"; import "./ProposalCategoryAdder.sol"; + contract ProposalCategory is Governed { bool public constructorCheck; + struct Category { string name; uint[] memberRoleSequence; @@ -27,7 +29,7 @@ contract ProposalCategory is Governed { } struct SubCategory { - string categoryName; + string subCategoryName; string actionHash; uint categoryId; address contractAddress; @@ -44,14 +46,6 @@ contract ProposalCategory is Governed { Category[] internal allCategory; mapping(uint => uint[]) internal allSubIdByCategory; - ///@dev just to follow the interface - function updateDependencyAddresses() public pure { - } - - /// @dev just to adhere to GovBlockss' Upgradeable interface - function changeMasterAddress() public pure { - } - constructor() public { uint[] memory rs = new uint[](1); uint[] memory al = new uint[](1); @@ -75,16 +69,6 @@ contract ProposalCategory is Governed { allCategory.push(Category("Others", rs, mv, al, ct)); } - /// @dev Initiates Default settings for Proposal Category contract (Adding default categories) - function proposalCategoryInitiate(bytes32 _dAppName) public { - require(!constructorCheck); - dappName = _dAppName; - - addInitialSubCategories(); - - constructorCheck = true; - } - /// @dev Adds new category /// @param _name Category name /// @param _memberRoleSequence Voting Layer sequence in which the voting has to be performed. @@ -198,7 +182,7 @@ contract ProposalCategory is Governed { external onlyAuthorizedToGovern { - allSubCategory[_subCategoryId].categoryName = _subCategoryName; + allSubCategory[_subCategoryId].subCategoryName = _subCategoryName; allSubCategory[_subCategoryId].actionHash = _actionHash; allSubCategory[_subCategoryId].contractAddress = _address; allSubCategory[_subCategoryId].contractName = _contractName; @@ -224,7 +208,7 @@ contract ProposalCategory is Governed { /// @dev Get Sub category name function getSubCategoryName(uint _subCategoryId) public view returns(uint, string) { - return (_subCategoryId, allSubCategory[_subCategoryId].categoryName); + return (_subCategoryId, allSubCategory[_subCategoryId].subCategoryName); } /// @dev Get contractName @@ -265,12 +249,12 @@ contract ProposalCategory is Governed { } function isCategoryExternal(uint _category) public view returns(bool ext) { - if(allCategory[_category].allowedToCreateProposal[0] == 0) + if (allCategory[_category].allowedToCreateProposal[0] == 0) ext = true; } - function isSubCategoryExternal(uint _category) public view returns(bool ext) { - if(allCategory[allSubCategory[_category].categoryId].allowedToCreateProposal[0] == 0) + function isSubCategoryExternal(uint _subCategory) public view returns(bool ext) { + if (allCategory[allSubCategory[_subCategory].categoryId].allowedToCreateProposal[0] == 0) ext = true; } @@ -343,14 +327,8 @@ contract ProposalCategory is Governed { } /// @dev Gets Default incentive to be distributed against sub category. - function getCatIncentive(uint _subCategoryId) public view returns(uint incentive) { - incentive = allSubCategory[_subCategoryId].defaultIncentive; - } - - /// @dev Gets Default incentive to be distributed against sub category. - function getCategoryIncentive(uint _subCategoryId) public view returns(uint category, uint incentive) { - category = _subCategoryId; - incentive = allSubCategory[_subCategoryId].defaultIncentive; + function getSubCatIncentive(uint _subCategoryId) public view returns(uint) { + return allSubCategory[_subCategoryId].defaultIncentive; } /// @dev Gets Total number of categories added till now @@ -384,26 +362,11 @@ contract ProposalCategory is Governed { ); } - function getMRSequenceBySubCat(uint _subCategoryId, uint _currVotingIndex) external view returns (uint) { + function getMRSequenceBySubCat(uint _subCategoryId, uint _currVotingIndex) public view returns (uint) { uint category = allSubCategory[_subCategoryId].categoryId; return allCategory[category].memberRoleSequence[_currVotingIndex]; } - // /// @dev Gets Category and SubCategory name from Proposal ID. - // function getCatAndSubNameByPropId(uint _proposalId) - // public - // view - // returns(string categoryName, string subCategoryName) - // { - // categoryName = allCategory[getCategoryIdBySubId(governanceDat.getProposalCategory(_proposalId))].name; - // subCategoryName = allSubCategory[governanceDat.getProposalCategory(_proposalId)].categoryName; - // } - - // /// @dev Gets Category ID from Proposal ID. - // function getCatIdByPropId(uint _proposalId) public view returns(uint catId) { - // catId = allSubCategory[governanceDat.getProposalCategory(_proposalId)].categoryId; - // } - function addInitialSubC( string _subCategoryName, string _actionHash, @@ -434,14 +397,32 @@ contract ProposalCategory is Governed { } } + /// @dev Initiates Default settings for Proposal Category contract (Adding default categories) + function proposalCategoryInitiate(bytes32 _dAppName) public { + require(!constructorCheck); + dappName = _dAppName; + + addInitialSubCategories(); + + constructorCheck = true; + } + + ///@dev just to follow the interface + function updateDependencyAddresses() public pure { //solhint-disable-line + } + + /// @dev just to adhere to GovBlockss' Upgradeable interface + function changeMasterAddress() public pure { //solhint-disable-line + } + function getCodeSize(address _addr) internal view returns(uint _size) { - assembly { + assembly { //solhint-disable-line _size := extcodesize(_addr) } } /// @dev adds second half of the inital categories - function addInitialSubCategories() internal { + function addInitialSubCategories() internal { //solhint-disable-line uint[] memory stakeInecntive = new uint[](3); uint8[] memory rewardPerc = new uint8[](3); stakeInecntive[0] = 0; @@ -520,7 +501,8 @@ contract ProposalCategory is Governed { rewardPerc ); if (getCodeSize(0x4267dF0e1239f7b86C21C3830A2D15729B0Bd84a) > 0) //kovan testnet - ProposalCategoryAdder proposalCategoryAdder = ProposalCategoryAdder(0x4267dF0e1239f7b86C21C3830A2D15729B0Bd84a); + ProposalCategoryAdder proposalCategoryAdder = + ProposalCategoryAdder(0x4267dF0e1239f7b86C21C3830A2D15729B0Bd84a); if (address(proposalCategoryAdder) != 0) proposalCategoryAdder.addSubC(address(this)); } diff --git a/contracts/ProposalCategoryAdder.sol b/contracts/ProposalCategoryAdder.sol index 61ead19..6458a01 100644 --- a/contracts/ProposalCategoryAdder.sol +++ b/contracts/ProposalCategoryAdder.sol @@ -17,10 +17,11 @@ pragma solidity 0.4.24; import "./ProposalCategory.sol"; + contract ProposalCategoryAdder { /// @dev ads the default govBlocks sub categories to dApps - function addSubC(address _to) public { + function addSubC(address _to) public { //solhint-disable-line ProposalCategory proposalCategory = ProposalCategory(_to); uint[] memory stakeInecntive = new uint[](3); uint8[] memory rewardPerc = new uint8[](3); diff --git a/contracts/SimpleVoting.sol b/contracts/SimpleVoting.sol index d18d1d2..70bc13f 100644 --- a/contracts/SimpleVoting.sol +++ b/contracts/SimpleVoting.sol @@ -26,6 +26,7 @@ import "./imports/openzeppelin-solidity/contracts/math/SafeMath.sol"; import "./EventCaller.sol"; import "./Governed.sol"; + contract SimpleVoting is Upgradeable { using SafeMath for uint; GovernanceData internal governanceDat; @@ -59,69 +60,6 @@ contract SimpleVoting is Upgradeable { _; } - /// @dev Initiates simple voting contract - function simpleVotingInitiate() public { - require(!constructorCheck); - votingTypeName = "Simple Voting"; - allVotes.push(ProposalVote(address(0), 0, 0, 1)); - constructorCheck = true; - } - - /// @dev updates dependancies - function updateDependencyAddresses() public { - if (!constructorCheck) - simpleVotingInitiate(); - governanceDat = GovernanceData(master.getLatestAddress("GD")); - memberRole = MemberRoles(master.getLatestAddress("MR")); - proposalCategory = ProposalCategory(master.getLatestAddress("PC")); - governance = Governance(master.getLatestAddress("GV")); - pool = Pool(master.getLatestAddress("PL")); - eventCaller = EventCaller(master.getEventCallerAddress()); - governChecker = GovernChecker(master.getGovernCheckerAddress()); - } - - /// @dev validates that the voter has enough tokens locked for voting - function validateStake(uint32 _proposalId) public view returns(bool) { - address token; - uint subCatThenMinStake; - uint tokenHoldingTimeThenBalance; - (token, subCatThenMinStake) = governanceDat.getTokenAndSubCat(_proposalId); - (subCatThenMinStake, tokenHoldingTimeThenBalance) = proposalCategory.getRequiredStake(subCatThenMinStake); - if(subCatThenMinStake == 0) - return true; - GBTStandardToken tokenInstance = GBTStandardToken(token); - tokenHoldingTimeThenBalance += now; - tokenHoldingTimeThenBalance = tokenInstance.tokensLockedAtTime(msg.sender, "GOV", tokenHoldingTimeThenBalance); - if(tokenHoldingTimeThenBalance > subCatThenMinStake) - return true; - } - - /// @dev validates that the voter has enough tokens locked for voting and returns vote value - /// Seperate function from validateStake to save gas. - function validateStakeAndReturnVoteValue(uint32 _proposalId) public view returns(uint voteValue) { - address token; - uint subCatThenMinStake; - uint tokenHoldingTimeThenBalance; - uint stakeWeight; - uint bonusStake; - uint reputationWeight; - uint bonusReputation; - uint memberReputation; - (stakeWeight, bonusStake, reputationWeight, bonusReputation, memberReputation, token, subCatThenMinStake) - = governanceDat.getMemberReputationSV(msg.sender, _proposalId); - (subCatThenMinStake, tokenHoldingTimeThenBalance) = proposalCategory.getRequiredStake(subCatThenMinStake); - GBTStandardToken tokenInstance = GBTStandardToken(token); - tokenHoldingTimeThenBalance += now; - tokenHoldingTimeThenBalance = tokenInstance.tokensLockedAtTime(msg.sender, "GOV", tokenHoldingTimeThenBalance); - - require(tokenHoldingTimeThenBalance > subCatThenMinStake); - - tokenHoldingTimeThenBalance = SafeMath.div(tokenHoldingTimeThenBalance, tokenInstance.decimals()); - stakeWeight = SafeMath.mul(SafeMath.add(log(tokenHoldingTimeThenBalance), bonusStake), stakeWeight); - reputationWeight = SafeMath.mul(SafeMath.add(log(memberReputation), bonusReputation), reputationWeight); - voteValue = SafeMath.add(stakeWeight, reputationWeight); - } - /// @dev Initiates add solution /// @param _memberAddress Address of member who is adding the solution /// @param _solutionHash Solution hash having required data against adding solution @@ -133,15 +71,14 @@ contract SimpleVoting is Upgradeable { ) external { - if(msg.sender == _memberAddress) { + if (msg.sender == _memberAddress) { require(validateStake(_proposalId)); - } - else + } else require(master.isInternal(msg.sender)); require(!alreadyAdded(_proposalId, _memberAddress)); governanceDat.setSolutionAdded(_proposalId, _memberAddress, _action); uint solutionId = governanceDat.getTotalSolutions(_proposalId); - governanceDat.callSolutionEvent(_proposalId, msg.sender, solutionId - 1, _solutionHash, now); + governanceDat.callSolutionEvent(_proposalId, msg.sender, solutionId - 1, _solutionHash, now); //solhint-disable-line } @@ -154,7 +91,7 @@ contract SimpleVoting is Upgradeable { ) external { - //Variables are reused to save gas. We know that this reduces code readability but proposalVoting is one function + //Variables are reused to save gas. We know that this reduces code readability but proposalVoting is //where gas usage should be optimized as much as possible. voters should not feel burdened while voting. require(addressProposalVote[msg.sender][_proposalId] == 0); @@ -165,7 +102,8 @@ contract SimpleVoting is Upgradeable { (categoryThenMRSequence, currentVotingIdThenVoteValue, intermediateVerdict) = governanceDat.getProposalDetailsForSV(_proposalId); - categoryThenMRSequence = proposalCategory.getMRSequenceBySubCat(categoryThenMRSequence, currentVotingIdThenVoteValue); + categoryThenMRSequence = + proposalCategory.getMRSequenceBySubCat(categoryThenMRSequence, currentVotingIdThenVoteValue); //categoryThenMRSequence is now MemberRoleSequence require(memberRole.checkRoleIdByAddress(msg.sender, categoryThenMRSequence)); @@ -181,10 +119,10 @@ contract SimpleVoting is Upgradeable { proposalRoleVote[_proposalId][categoryThenMRSequence].push(allVotes.length); allVotesByMember[msg.sender].push(allVotes.length); addressProposalVote[msg.sender][_proposalId] = allVotes.length; - governanceDat.callVoteEvent(msg.sender, _proposalId, now, allVotes.length); + governanceDat.callVoteEvent(msg.sender, _proposalId, now, allVotes.length); //solhint-disable-line allVotes.push(ProposalVote(msg.sender, _solutionChosen[0], _proposalId, currentVotingIdThenVoteValue)); - if(proposalRoleVote[_proposalId][categoryThenMRSequence].length + if (proposalRoleVote[_proposalId][categoryThenMRSequence].length == memberRole.getAllMemberLength(categoryThenMRSequence) && categoryThenMRSequence != 2 && categoryThenMRSequence != 0 @@ -193,7 +131,72 @@ contract SimpleVoting is Upgradeable { } } - function claimVoteReward(address _memberAddress) public onlyInternal returns(uint pendingGBTReward, uint pendingDAppReward) { + /// @dev Initiates simple voting contract + function simpleVotingInitiate() public { + require(!constructorCheck); + votingTypeName = "Simple Voting"; + allVotes.push(ProposalVote(address(0), 0, 0, 1)); + constructorCheck = true; + } + + /// @dev updates dependancies + function updateDependencyAddresses() public { + if (!constructorCheck) + simpleVotingInitiate(); + governanceDat = GovernanceData(master.getLatestAddress("GD")); + memberRole = MemberRoles(master.getLatestAddress("MR")); + proposalCategory = ProposalCategory(master.getLatestAddress("PC")); + governance = Governance(master.getLatestAddress("GV")); + pool = Pool(master.getLatestAddress("PL")); + eventCaller = EventCaller(master.getEventCallerAddress()); + governChecker = GovernChecker(master.getGovernCheckerAddress()); + } + + /// @dev validates that the voter has enough tokens locked for voting + function validateStake(uint32 _proposalId) public view returns(bool) { + address token; + uint subCatThenMinStake; + uint tokenHoldingTimeThenBalance; + (token, subCatThenMinStake) = governanceDat.getTokenAndSubCat(_proposalId); + (subCatThenMinStake, tokenHoldingTimeThenBalance) = proposalCategory.getRequiredStake(subCatThenMinStake); + if (subCatThenMinStake == 0) + return true; + GBTStandardToken tokenInstance = GBTStandardToken(token); + tokenHoldingTimeThenBalance += now; //solhint-disable-line + tokenHoldingTimeThenBalance = tokenInstance.tokensLockedAtTime(msg.sender, "GOV", tokenHoldingTimeThenBalance); + if (tokenHoldingTimeThenBalance > subCatThenMinStake) + return true; + } + + /// @dev validates that the voter has enough tokens locked for voting and returns vote value + /// Seperate function from validateStake to save gas. + function validateStakeAndReturnVoteValue(uint32 _proposalId) public view returns(uint voteValue) { + address token; + uint subCatThenMinStake; + uint tokenHoldingTimeThenBalance; + uint stakeWeight; + uint bonusStake; + uint reputationWeight; + uint bonusReputation; + uint memberReputation; + (stakeWeight, bonusStake, reputationWeight, bonusReputation, memberReputation, token, subCatThenMinStake) + = governanceDat.getMemberReputationSV(msg.sender, _proposalId); + (subCatThenMinStake, tokenHoldingTimeThenBalance) = proposalCategory.getRequiredStake(subCatThenMinStake); + GBTStandardToken tokenInstance = GBTStandardToken(token); + tokenHoldingTimeThenBalance += now; //solhint-disable-line + tokenHoldingTimeThenBalance = tokenInstance.tokensLockedAtTime(msg.sender, "GOV", tokenHoldingTimeThenBalance); + + require(tokenHoldingTimeThenBalance > subCatThenMinStake); + + tokenHoldingTimeThenBalance = SafeMath.div(tokenHoldingTimeThenBalance, tokenInstance.decimals()); + stakeWeight = SafeMath.mul(SafeMath.add(log(tokenHoldingTimeThenBalance), bonusStake), stakeWeight); + reputationWeight = SafeMath.mul(SafeMath.add(log(memberReputation), bonusReputation), reputationWeight); + voteValue = SafeMath.add(stakeWeight, reputationWeight); + } + + function claimVoteReward(address _memberAddress) + public onlyInternal returns(uint pendingGBTReward, uint pendingDAppReward) + { uint lastIndex = 0; uint i; uint totalVotes = allVotesByMember[_memberAddress].length; @@ -206,7 +209,8 @@ contract SimpleVoting is Upgradeable { voteId = allVotesByMember[_memberAddress][i]; if (!rewardClaimed[voteId]) { proposalId = allVotes[voteId].proposalId; - (tempGBTReward, tempDAppReward, lastIndex) = calculateVoteReward(_memberAddress, i, proposalId, lastIndex); + (tempGBTReward, tempDAppReward, lastIndex) = + calculateVoteReward(_memberAddress, i, proposalId, lastIndex); pendingGBTReward += tempGBTReward; pendingDAppReward += tempDAppReward; rewardClaimed[voteId] = true; @@ -217,7 +221,9 @@ contract SimpleVoting is Upgradeable { lastRewardVoteId[_memberAddress] = lastIndex; } - function getPendingReward(address _memberAddress) public view returns(uint pendingGBTReward, uint pendingDAppReward) { + function getPendingReward(address _memberAddress) + public view returns(uint pendingGBTReward, uint pendingDAppReward) + { uint i; uint totalVotes = allVotesByMember[_memberAddress].length; uint voteId; @@ -299,7 +305,7 @@ contract SimpleVoting is Upgradeable { view returns(uint) { - require (_solutionChosenId == 0); + require(_solutionChosenId == 0); return (allVotes[_voteId].solutionChosen); } @@ -342,7 +348,7 @@ contract SimpleVoting is Upgradeable { /// @dev Closes Proposal Voting after All voting layers done with voting or Time out happens. function closeProposalVote(uint _proposalId) public { - uint category = proposalCategory.getCategoryIdBySubId(governanceDat.getProposalCategory(_proposalId)); + uint category = proposalCategory.getCategoryIdBySubId(governanceDat.getProposalSubCategory(_proposalId)); uint currentVotingId = governanceDat.getProposalCurrentVotingId(_proposalId); uint _mrSequenceId = proposalCategory.getRoleSequencAtIndex(category, currentVotingId); uint64 max; @@ -359,7 +365,8 @@ contract SimpleVoting is Upgradeable { voteId = proposalRoleVote[_proposalId][_mrSequenceId][i]; voteValue = allVotes[voteId].voteValue; totalVoteValue = totalVoteValue + voteValue; - finalVoteValue[allVotes[voteId].solutionChosen] = finalVoteValue[allVotes[voteId].solutionChosen] + voteValue; + finalVoteValue[allVotes[voteId].solutionChosen] = + finalVoteValue[allVotes[voteId].solutionChosen].add(voteValue); } totalVoteValue = totalVoteValue + governanceDat.getProposalTotalVoteValue(_proposalId); @@ -411,7 +418,7 @@ contract SimpleVoting is Upgradeable { uint _closingTime; uint _majorityVote; - require (!governanceDat.proposalPaused(_proposalId)); + require(!governanceDat.proposalPaused(_proposalId)); (, , dateUpdate, , pStatus) = governanceDat.getProposalDetailsById1(_proposalId); (, _majorityVote, _closingTime) = proposalCategory.getCategoryData3( @@ -419,12 +426,12 @@ contract SimpleVoting is Upgradeable { _currentVotingId ); if (pStatus == 2 && _roleId != 2 && _roleId != 0) { - if (SafeMath.add(dateUpdate, _closingTime) <= now || + if (SafeMath.add(dateUpdate, _closingTime) <= now || //solhint-disable-line proposalRoleVote[_proposalId][_roleId].length == memberRole.getAllMemberLength(_roleId) ) closeValue = 1; } else if (pStatus == 2) { - if (SafeMath.add(dateUpdate, _closingTime) <= now) + if (SafeMath.add(dateUpdate, _closingTime) <= now) //solhint-disable-line closeValue = 1; } else if (pStatus > 2) { closeValue = 2; @@ -435,7 +442,7 @@ contract SimpleVoting is Upgradeable { /// @dev Does category specific tasks function finalActions(uint _proposalId) internal { - uint subCategory = governanceDat.getProposalCategory(_proposalId); + uint subCategory = governanceDat.getProposalSubCategory(_proposalId); if (subCategory == 10) { upgrade(); } else if (subCategory == 11) { @@ -461,18 +468,18 @@ contract SimpleVoting is Upgradeable { max, 0 ); - eventCaller.callCloseProposalOnTime(_proposalId, _closingTime + now); + eventCaller.callCloseProposalOnTime(_proposalId, _closingTime + now); //solhint-disable-line } else { governance.updateProposalDetails(_proposalId, currentVotingId - 1, max, max); governanceDat.changeProposalStatus(_proposalId, 3); - uint subCategory = governanceDat.getProposalCategory(_proposalId); + uint subCategory = governanceDat.getProposalSubCategory(_proposalId); bytes2 contractName = proposalCategory.getContractName(subCategory); address actionAddress; - if(contractName == "EX") + if (contractName == "EX") actionAddress = proposalCategory.getContractAddress(subCategory); else actionAddress = master.getLatestAddress(contractName); - if (actionAddress.call(governanceDat.getSolutionActionByProposalId(_proposalId, max))) { + if (actionAddress.call(governanceDat.getSolutionActionByProposalId(_proposalId, max))) { //solhint-disable-line eventCaller.callActionSuccess(_proposalId); } eventCaller.callProposalAccepted(_proposalId); @@ -611,7 +618,7 @@ contract SimpleVoting is Upgradeable { address _memberAddress, uint _voteNo ) - public + internal view returns( uint solutionChosen, @@ -629,11 +636,12 @@ contract SimpleVoting is Upgradeable { proposalStatus = governanceDat.getProposalStatus(proposalId); finalVerdict = governanceDat.getProposalFinalVerdict(proposalId); totalReward = governanceDat.getProposalIncentive(proposalId); - subCategory = governanceDat.getProposalCategory(proposalId); + subCategory = governanceDat.getProposalSubCategory(proposalId); } + /* solhint-disable */ ///@dev calculates log2. Taken from stackoverflow. - function log(uint x) public pure returns (uint y) { + function log(uint x) internal pure returns (uint y) { assembly { let arg := x x := sub(x,1) @@ -663,4 +671,5 @@ contract SimpleVoting is Upgradeable { y := add(y, mul(256, gt(arg, 0x8000000000000000000000000000000000000000000000000000000000000000))) } } + /* solhint-enable */ } diff --git a/contracts/TokenProxy.sol b/contracts/TokenProxy.sol index 77a5f87..894481d 100644 --- a/contracts/TokenProxy.sol +++ b/contracts/TokenProxy.sol @@ -5,42 +5,40 @@ import "./imports/openzeppelin-solidity/contracts/math/SafeMath.sol"; contract TokenProxy { - using SafeMath for uint256; + using SafeMath for uint256; - GBTStandardToken public originalToken; + GBTStandardToken public originalToken; - constructor(address _originalToken) public { + constructor(address _originalToken) public { originalToken = GBTStandardToken(_originalToken); } - function totalSupply() public view returns(uint) { - return originalToken.totalSupply(); + return originalToken.totalSupply(); } function balanceOf(address _of) public view returns(uint) { - return originalToken.balanceOf(_of); + return originalToken.balanceOf(_of); } function name() public view returns(string) { - return originalToken.name(); + return originalToken.name(); } function symbol() public view returns(string) { - return originalToken.symbol(); + return originalToken.symbol(); } function decimals() public view returns(uint8) { - return originalToken.decimals(); + return originalToken.decimals(); } - /** * @dev Reasons why a user's tokens have been locked */ mapping(address => bytes32[]) public lockReason; - struct lockToken { + struct LockedToken { uint256 amount; uint256 validity; bool claimed; @@ -50,7 +48,7 @@ contract TokenProxy { * @dev Holds number & validity of tokens locked for a given reason for * a given member address */ - mapping(address => mapping(bytes32 => lockToken)) public locked; + mapping(address => mapping(bytes32 => LockedToken)) public locked; event Lock( address indexed _of, @@ -88,7 +86,7 @@ contract TokenProxy { originalToken.transferFrom(msg.sender, address(this), _amount); if (locked[msg.sender][_reason].amount == 0) lockReason[msg.sender].push(_reason); - locked[msg.sender][_reason] = lockToken(_amount, validUntil, false); + locked[msg.sender][_reason] = LockedToken(_amount, validUntil, false); emit Lock(msg.sender, _reason, _amount, validUntil); return true; } @@ -205,7 +203,7 @@ contract TokenProxy { emit Unlock(_of, lockReason[_of][i], lockedTokens); } } - if(unlockableTokens > 0) { + if (unlockableTokens > 0) { originalToken.transfer(_of, unlockableTokens); } } diff --git a/contracts/Upgradeable.sol b/contracts/Upgradeable.sol index 10ffbd8..e1b3e06 100644 --- a/contracts/Upgradeable.sol +++ b/contracts/Upgradeable.sol @@ -17,7 +17,8 @@ pragma solidity 0.4.24; import "./Master.sol"; -contract Upgradeable{ + +contract Upgradeable { Master public master; @@ -26,9 +27,9 @@ contract Upgradeable{ _; } - function updateDependencyAddresses() public; //To be implemented by every contract depending on its needs + function updateDependencyAddresses() public; //To be implemented by every contract depending on its needs - function changeMasterAddress() public { + function changeMasterAddress() public { if (address(master) == address(0)) master = Master(msg.sender); else diff --git a/contracts/VotingType.sol b/contracts/VotingType.sol index b144206..18f3a97 100644 --- a/contracts/VotingType.sol +++ b/contracts/VotingType.sol @@ -19,14 +19,12 @@ pragma solidity 0.4.24; + contract VotingType { string public votingTypeName; - - function addSolution(uint32 _proposalId, address _memberAddress, string _solutionHash, bytes _action) public; - function proposalVoting(uint32 _proposalId, uint64[] _solutionChosen) external; - function closeProposalVote(uint _proposalId) public; + function getAllVoteIdsLengthByProposalRole(uint _proposalId, uint _roleId) public view returns(uint length); function getTotalNumberOfVotesByAddress(address _memberAddress) public view returns(uint); @@ -34,7 +32,9 @@ contract VotingType { function getPendingReward(address _memberAddress) public view returns(uint, uint); - function giveRewardAfterFinalDecision(uint _proposalId) internal; + function closeProposalVote(uint _proposalId) public; - function getAllVoteIdsLengthByProposalRole(uint _proposalId, uint _roleId) public view returns(uint length); + function addSolution(uint32 _proposalId, address _memberAddress, string _solutionHash, bytes _action) public; + + function giveRewardAfterFinalDecision(uint _proposalId) internal; } \ No newline at end of file diff --git a/contracts/imports/lockable-token/ERC1132.sol b/contracts/imports/lockable-token/ERC1132.sol index 4fdbf70..6f4440e 100644 --- a/contracts/imports/lockable-token/ERC1132.sol +++ b/contracts/imports/lockable-token/ERC1132.sol @@ -174,7 +174,7 @@ contract ERC1132 is StandardToken { emit Unlock(_of, lockReason[_of][i], lockedTokens); } } - if(unlockableTokens > 0) { + if (unlockableTokens > 0) { balances[address(this)] = balances[address(this)].sub(unlockableTokens); balances[_of] = balances[_of].add(unlockableTokens); } diff --git a/package-lock.json b/package-lock.json index 568bb78..9453c4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -112,6 +112,23 @@ "acorn": "^5.0.0" } }, + "acorn-jsx": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", + "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "dev": true, + "requires": { + "acorn": "^3.0.4" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, "aes-js": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz", @@ -130,6 +147,12 @@ "json-schema-traverse": "^0.3.0" } }, + "ajv-keywords": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", + "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", + "dev": true + }, "align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", @@ -165,6 +188,12 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, + "antlr4": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/antlr4/-/antlr4-4.7.0.tgz", + "integrity": "sha1-KX+VbdwG+DOX/AmQ7PLgzyC/u+4=", + "dev": true + }, "any-observable": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/any-observable/-/any-observable-0.3.0.tgz", @@ -261,6 +290,21 @@ "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", "dev": true }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "^1.0.1" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -1396,6 +1440,23 @@ "unset-value": "^1.0.0" } }, + "caller-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", + "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", + "dev": true, + "requires": { + "callsites": "^0.2.0" + }, + "dependencies": { + "callsites": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", + "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "dev": true + } + } + }, "callsites": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", @@ -1482,6 +1543,12 @@ } } }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "dev": true + }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -1513,6 +1580,12 @@ "safe-buffer": "^5.0.1" } }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "dev": true + }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -1561,6 +1634,12 @@ "string-width": "^1.0.1" } }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, "cliui": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", @@ -1985,6 +2064,21 @@ "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "dev": true, + "requires": { + "globby": "^5.0.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "rimraf": "^2.2.8" + } + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -2012,6 +2106,15 @@ "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", "dev": true }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, "dom-walk": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", @@ -2167,12 +2270,198 @@ } } }, + "eslint": { + "version": "4.19.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", + "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", + "dev": true, + "requires": { + "ajv": "^5.3.0", + "babel-code-frame": "^6.22.0", + "chalk": "^2.1.0", + "concat-stream": "^1.6.0", + "cross-spawn": "^5.1.0", + "debug": "^3.1.0", + "doctrine": "^2.1.0", + "eslint-scope": "^3.7.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^3.5.4", + "esquery": "^1.0.0", + "esutils": "^2.0.2", + "file-entry-cache": "^2.0.0", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.0.1", + "ignore": "^3.3.3", + "imurmurhash": "^0.1.4", + "inquirer": "^3.0.6", + "is-resolvable": "^1.0.0", + "js-yaml": "^3.9.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.4", + "minimatch": "^3.0.2", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "pluralize": "^7.0.0", + "progress": "^2.0.0", + "regexpp": "^1.0.1", + "require-uncached": "^1.0.3", + "semver": "^5.3.0", + "strip-ansi": "^4.0.0", + "strip-json-comments": "~2.0.1", + "table": "4.0.2", + "text-table": "~0.2.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globals": { + "version": "11.7.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.7.0.tgz", + "integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "eslint-scope": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", + "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + }, + "dependencies": { + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + } + } + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "dev": true + }, + "espree": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "dev": true, + "requires": { + "acorn": "^5.5.0", + "acorn-jsx": "^3.0.0" + } + }, "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", "dev": true }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + }, + "dependencies": { + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + } + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + }, + "dependencies": { + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + } + } + }, "estraverse": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", @@ -2876,6 +3165,17 @@ } } }, + "external-editor": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", + "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", + "dev": true, + "requires": { + "chardet": "^0.4.0", + "iconv-lite": "^0.4.17", + "tmp": "^0.0.33" + } + }, "extglob": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", @@ -3020,6 +3320,16 @@ "object-assign": "^4.1.0" } }, + "file-entry-cache": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", + "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "dev": true, + "requires": { + "flat-cache": "^1.2.1", + "object-assign": "^4.0.1" + } + }, "filename-regex": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", @@ -3091,6 +3401,18 @@ "pinkie-promise": "^2.0.0" } }, + "flat-cache": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", + "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "dev": true, + "requires": { + "circular-json": "^0.3.1", + "del": "^2.0.2", + "graceful-fs": "^4.1.2", + "write": "^0.2.1" + } + }, "for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -3797,6 +4119,36 @@ "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", "dev": true }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "dev": true, + "requires": { + "array-union": "^1.0.1", + "arrify": "^1.0.0", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", @@ -4014,6 +4366,12 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "dev": true + }, "immediate": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.2.3.tgz", @@ -4061,6 +4419,133 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "dev": true, + "requires": { + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.0", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^2.0.4", + "figures": "^2.0.0", + "lodash": "^4.3.0", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rx-lite": "^4.0.8", + "rx-lite-aggregates": "^4.0.8", + "string-width": "^2.1.0", + "strip-ansi": "^4.0.0", + "through": "^2.3.6" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "interpret": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", @@ -4269,6 +4754,30 @@ "symbol-observable": "^1.1.0" } }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "dev": true + }, + "is-path-in-cwd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", + "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", + "dev": true, + "requires": { + "is-path-inside": "^1.0.0" + } + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "dev": true, + "requires": { + "path-is-inside": "^1.0.1" + } + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -4311,6 +4820,12 @@ "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", "dev": true }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", + "dev": true + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -5749,6 +6264,12 @@ "jsonify": "~0.0.0" } }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -6719,6 +7240,12 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, "nan": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", @@ -7224,6 +7751,12 @@ "semver-compare": "^1.0.0" } }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", + "dev": true + }, "pn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", @@ -7305,6 +7838,12 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, + "progress": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", + "dev": true + }, "promise-to-callback": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/promise-to-callback/-/promise-to-callback-1.0.0.tgz", @@ -7485,6 +8024,12 @@ "safe-regex": "^1.1.0" } }, + "regexpp": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", + "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==", + "dev": true + }, "regexpu-core": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", @@ -7622,6 +8167,24 @@ "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", "dev": true }, + "require-uncached": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", + "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "dev": true, + "requires": { + "caller-path": "^0.1.0", + "resolve-from": "^1.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", + "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "dev": true + } + } + }, "resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", @@ -7742,12 +8305,36 @@ "integrity": "sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw==", "dev": true }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, "rustbn.js": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/rustbn.js/-/rustbn.js-0.1.2.tgz", "integrity": "sha512-bAkNqSHYdJdFsBC7Z11JgzYktL31HIpB2o70jZcGiL1U1TVtPyvaVhDrGWwS8uZtaqwW2k6NOPGZCqW/Dgh5Lg==", "dev": true }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", + "dev": true + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "dev": true, + "requires": { + "rx-lite": "*" + } + }, "rxjs": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.2.2.tgz", @@ -8201,6 +8788,36 @@ } } }, + "solhint": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/solhint/-/solhint-1.2.1.tgz", + "integrity": "sha512-3B0ydhkOlicyyTmKnwJC6kiwdJUXvbbDYXcy8m7rznoQPgzzkmSOsJgb9BAe+KBQP5BD3PLgcoOQ84t3FSxqsQ==", + "dev": true, + "requires": { + "antlr4": "4.7.0", + "commander": "2.11.0", + "eslint": "^4.19.1", + "glob": "7.1.2", + "ignore": "^3.3.7", + "lodash": "^4.17.10" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, "solidity-coverage": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.5.7.tgz", @@ -8523,6 +9140,12 @@ "integrity": "sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g=", "dev": true }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, "supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", @@ -8544,6 +9167,97 @@ "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=", "dev": true }, + "table": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", + "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "dev": true, + "requires": { + "ajv": "^5.2.3", + "ajv-keywords": "^2.1.0", + "chalk": "^2.1.0", + "lodash": "^4.17.4", + "slice-ansi": "1.0.0", + "string-width": "^2.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "slice-ansi": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", + "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0" + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "tape": { "version": "4.9.1", "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.1.tgz", @@ -8638,6 +9352,12 @@ } } }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, "throat": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/throat/-/throat-4.1.0.tgz", @@ -8660,6 +9380,15 @@ "xtend": "~4.0.1" } }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, "tmpl": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", @@ -9176,6 +9905,15 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, "write-file-atomic": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", diff --git a/package.json b/package.json index 71e4134..e14f8ed 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "coverage": "./node_modules/.bin/solidity-coverage", "pretty": "prettier --write --single-quote --tab-width 2 \"**/*.js\"", - "precommit": "lint-staged" + "precommit": "lint-staged && solhint \"contracts/*.sol\"" }, "lint-staged": { "**/*.{js,json}": [ @@ -23,6 +23,7 @@ "jest": "^23.5.0", "lint-staged": "^7.2.2", "prettier": "^1.14.2", + "solhint": "^1.2.1", "solidity-coverage": "^0.5.5", "truffle": "^4.1.13", "truffle-hdwallet-provider": "^0.0.5" diff --git a/test/06_GovernChecker.js b/test/06_GovernChecker.js index 7f07a50..5813a8c 100644 --- a/test/06_GovernChecker.js +++ b/test/06_GovernChecker.js @@ -53,7 +53,7 @@ contract('GovernCheckerContract', function([first, second, third, foruth]) { await gc.updateGBMAdress(first); await catchRevert(gc.initializeAuthorized('0x42', first)); assert.equal( - await gc.GetGovBlockMasterAddress(), + await gc.getGovBlockMasterAddress(), first, 'gbm not added properly' ); diff --git a/test/07_Governance.js b/test/07_Governance.js index 446bc9a..ef4dcd9 100644 --- a/test/07_Governance.js +++ b/test/07_Governance.js @@ -81,7 +81,7 @@ contract('Governance', ([owner, notOwner]) => { await catchRevert(gv.categorizeProposal(p, 9, { from: notOwner })); await mr.updateMemberRole(notOwner, 1, false, 356800000054); await gv.categorizeProposal(p, 9); - const category = await gd.getProposalCategory(p); + const category = await gd.getProposalSubCategory(p); assert.equal(category.toNumber(), 9, 'Category not set properly'); }); @@ -227,7 +227,7 @@ contract('Governance', ([owner, notOwner]) => { p1 = await gd.getAllProposalIdsLengthByAddress(owner); await gv.categorizeProposal(p1.toNumber(), 9, { from: notOwner }); await gv.categorizeProposal(p1.toNumber(), 4); - const category = await gd.getProposalCategory(p1.toNumber()); + const category = await gd.getProposalSubCategory(p1.toNumber()); assert.equal(category.toNumber(), 4, 'Category not set properly'); }); diff --git a/test/10_SimpleVoting.js b/test/10_SimpleVoting.js index 2e08e9f..f3ba362 100644 --- a/test/10_SimpleVoting.js +++ b/test/10_SimpleVoting.js @@ -2,6 +2,7 @@ const SimpleVoting = artifacts.require('SimpleVoting'); const GovernanceData = artifacts.require('GovernanceData'); const catchRevert = require('../helpers/exceptions.js').catchRevert; let sv; +const nullAddress = 0x0000000000000000000000000000000000000000; // proposalVoting, adddSolution, claimReward, closeProposal tested already contract('Simple Voting', function([owner]) { @@ -28,6 +29,8 @@ contract('Simple Voting', function([owner]) { let g8 = await sv.getAllVoteIdsByProposalRole(0, 1); let g9 = await sv.getVoteValue(0); let g10 = await sv.allVotesTotal(); + let g11 = await sv.getSolutionByVoteIdAndIndex(0, 0); + let g12 = await sv.getVoteDetailById(0); assert.equal(g2, true, 'Not initialized'); // TODO verify the data returned }); diff --git a/test/11_ProposalCategory.js b/test/11_ProposalCategory.js index 848939f..ea0eeca 100644 --- a/test/11_ProposalCategory.js +++ b/test/11_ProposalCategory.js @@ -41,8 +41,6 @@ contract('Proposal Category', function([owner, taker]) { assert.equal(g10.toNumber(), 1); const g11 = await pc.getRoleMajorityVotelength(0); assert.equal(g11[1].toNumber(), 1); - const g12 = await pc.getCategoryIncentive(0); - assert.equal(g12[1].toNumber(), 0); const g14 = await pc.getMinStake(9); assert.isAbove(g14.toNumber(), 1); const g15 = await pc.getRoleMajorityVoteAtIndex(4, 0);