From 67fe680faef2a539daf8cfbf4115ab0d6ba37cf3 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 31 Aug 2018 11:41:04 +0700 Subject: [PATCH] #46: permission hashes --- contracts/3-DevZenDao/DevZenDao.sol | 14 ++-- contracts/3-DevZenDao/DevZenDaoCore.sol | 13 ++-- contracts/3-DevZenDao/DevZenDaoFactory.sol | 84 +++++++++++----------- 3 files changed, 56 insertions(+), 55 deletions(-) diff --git a/contracts/3-DevZenDao/DevZenDao.sol b/contracts/3-DevZenDao/DevZenDao.sol index c41df15..8f6fe8c 100644 --- a/contracts/3-DevZenDao/DevZenDao.sol +++ b/contracts/3-DevZenDao/DevZenDao.sol @@ -26,7 +26,7 @@ contract DevZenDao is DevZenDaoCore { * This method should require voting! * Notice: DevZen_updateDaoParams is a custom action! */ - function updateDaoParams(Params _params) isCanDo("DevZen_updateDaoParams") public { + function updateDaoParams(Params _params) isCanDo(DEV_ZEN_UPDATE_DAO_PARAMS) public { super._updateDaoParams(_params); } @@ -35,7 +35,7 @@ contract DevZenDao is DevZenDaoCore { * This method should require voting! * Notice: DevZen_withdrawEther is a custom action! */ - function withdrawEther(address _output) isCanDo("DevZen_withdrawEther") public { + function withdrawEther(address _output) isCanDo(DEV_ZEN_WITHDRAW_ETHER) public { super._withdrawEther(_output); } @@ -44,7 +44,7 @@ contract DevZenDao is DevZenDaoCore { * This method should require voting! * Notice: DevZen_selectNextHost is a custom action! */ - function selectNextHost(address _nextHost) isCanDo("DevZen_selectNextHost") public { + function selectNextHost(address _nextHost) isCanDo(DEV_ZEN_SELECT_NEXT_HOST) public { super._selectNextHost(_nextHost); } @@ -53,7 +53,7 @@ contract DevZenDao is DevZenDaoCore { * This method should require voting! * Notice: DevZen_selectNextHost is a custom action! */ - function burnGuestStake() public isCanDo("DevZen_burnGuestStake") { + function burnGuestStake() public isCanDo(DEV_ZEN_BURN_GUEST_STAKE) { super._burnGuestStake(); } @@ -62,7 +62,7 @@ contract DevZenDao is DevZenDaoCore { * @param _guest New guest address * When guest is changed via this function we ensure that stake is returned to previous guest. */ - function changeTheGuest(address _guest) isCanDo("DevZen_changeGuest") public { + function changeTheGuest(address _guest) isCanDo(DEV_ZEN_CHANGE_GUEST) public { super._changeTheGuest(_guest); } @@ -72,7 +72,7 @@ contract DevZenDao is DevZenDaoCore { * However, sometimes DevZen team should be able to fix the next guest! * Notice: DevZen_emergencyChangeGuest is a custom action! */ - function emergency_ChangeTheGuest(address _guest) isCanDo("DevZen_emergencyChangeGuest") public { + function emergency_ChangeTheGuest(address _guest) isCanDo(DEV_ZEN_EMERGENCY_CHANGE_GUEST) public { super._emergency_ChangeTheGuest(_guest); } @@ -82,7 +82,7 @@ contract DevZenDao is DevZenDaoCore { * Should be called right AFTER the recording of the current episode * Notice: DevZen_moveToNextExpisode is a custom action! */ - function moveToNextEpisode(bool _guestHasCome) isCanDo("DevZen_moveToNextExpisode") public { + function moveToNextEpisode(bool _guestHasCome) isCanDo(DEV_ZEN_MOVE_TO_NEXT_EXPISODE) public { super._moveToNextEpisode(_guestHasCome); } diff --git a/contracts/3-DevZenDao/DevZenDaoCore.sol b/contracts/3-DevZenDao/DevZenDaoCore.sol index 80b635b..a378ec3 100644 --- a/contracts/3-DevZenDao/DevZenDaoCore.sol +++ b/contracts/3-DevZenDao/DevZenDaoCore.sol @@ -40,6 +40,14 @@ contract DevZenDaoCore is DaoClient { NextEpisode public nextEpisode; IDaoBase daoBase; + bytes32 public constant DEV_ZEN_UPDATE_DAO_PARAMS = keccak256("DevZen_updateDaoParams"); + bytes32 public constant DEV_ZEN_WITHDRAW_ETHER = keccak256("DevZen_withdrawEther"); + bytes32 public constant DEV_ZEN_SELECT_NEXT_HOST = keccak256("DevZen_selectNextHost"); + bytes32 public constant DEV_ZEN_BURN_GUEST_STAKE = keccak256("DevZen_burnGuestStake"); + bytes32 public constant DEV_ZEN_CHANGE_GUEST = keccak256("DevZen_changeGuest"); + bytes32 public constant DEV_ZEN_EMERGENCY_CHANGE_GUEST = keccak256("DevZen_emergencyChangeGuest"); + bytes32 public constant DEV_ZEN_MOVE_TO_NEXT_EXPISODE = keccak256("DevZen_moveToNextExpisode"); + event DevZenDaoCore_WithdrawEther(address _output); event DevZenDaoCore_SelectNextHost(address _nextHost); event DevZenDaoCore_ChangeTheGuest(address _guest); @@ -75,11 +83,6 @@ contract DevZenDaoCore is DaoClient { bool isEmergencyGuest; } - modifier isCanDo(bytes32 _what){ - require(daoBase.isCanDoAction(msg.sender, _what)); - _; - } - constructor(IDaoBase _daoBase, address[] _tokens, Params _params) public DaoClient(_daoBase){ daoBase = _daoBase; devZenToken = StdDaoToken(_tokens[0]); diff --git a/contracts/3-DevZenDao/DevZenDaoFactory.sol b/contracts/3-DevZenDao/DevZenDaoFactory.sol index 0ed74c3..7800d49 100644 --- a/contracts/3-DevZenDao/DevZenDaoFactory.sol +++ b/contracts/3-DevZenDao/DevZenDaoFactory.sol @@ -64,13 +64,13 @@ contract DevZenDaoFactory { devZenToken.transferOwnership(daoBase); repToken.transferOwnership(daoBase); - daoBase.allowActionByAddress(keccak256("DevZen_updateDaoParams"), address(devZenDao)); - daoBase.allowActionByAddress(keccak256("DevZen_withdrawEther"), address(devZenDao)); - daoBase.allowActionByAddress(keccak256("DevZen_selectNextHost"), address(devZenDao)); - daoBase.allowActionByAddress(keccak256("DevZen_burnGuestStake"), address(devZenDao)); - daoBase.allowActionByAddress(keccak256("DevZen_changeGuest"), address(devZenDao)); - daoBase.allowActionByAddress(keccak256("DevZen_emergencyChangeGuest"), address(devZenDao)); - daoBase.allowActionByAddress(keccak256("DevZen_moveToNextExpisode"), address(devZenDao)); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), address(devZenDao)); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_WITHDRAW_ETHER(), address(devZenDao)); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_SELECT_NEXT_HOST(), address(devZenDao)); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_BURN_GUEST_STAKE(), address(devZenDao)); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_CHANGE_GUEST(), address(devZenDao)); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_EMERGENCY_CHANGE_GUEST(), address(devZenDao)); + // daoBase.allowActionByAddress(devZenDao.DEV_ZEN_MOVE_TO_NEXT_EXPISODE(), address(devZenDao)); // 2 - setup setPermissions(_boss, _devZenTeam); @@ -94,22 +94,21 @@ contract DevZenDaoFactory { } // 1 - set DevZenTeam group permissions - daoBase.allowActionByAnyMemberOfGroup(keccak256("addNewProposal"),"DevZenTeam"); - daoBase.allowActionByVoting(keccak256("manageGroups"), devZenDao.repToken()); - daoBase.allowActionByVoting(keccak256("modifyMoneyscheme"), devZenDao.repToken()); - daoBase.allowActionByVoting(keccak256("upgradeDaoContract"), devZenDao.repToken()); + daoBase.allowActionByAnyMemberOfGroup(daoBase.ADD_NEW_PROPOSAL(),"DevZenTeam"); + daoBase.allowActionByVoting(daoBase.MANAGE_GROUPS(), devZenDao.repToken()); + daoBase.allowActionByVoting(daoBase.UPGRADE_DAO_CONTRACT(), devZenDao.repToken()); // 2 - set custom DevZenTeam permissions - daoBase.allowActionByVoting(keccak256("DevZen_updateDaoParams"), devZenDao.repToken()); - daoBase.allowActionByVoting(keccak256("DevZen_withdrawEther"), devZenDao.repToken()); - daoBase.allowActionByVoting(keccak256("DevZen_selectNextHost"), devZenDao.repToken()); - daoBase.allowActionByVoting(keccak256("DevZen_burnGuestStake"), devZenDao.repToken()); - daoBase.allowActionByVoting(keccak256("DevZen_changeGuest"), devZenDao.repToken()); - daoBase.allowActionByVoting(keccak256("DevZen_emergencyChangeGuest"), devZenDao.repToken()); - daoBase.allowActionByVoting(keccak256("DevZen_moveToNextEpisode"), devZenDao.repToken()); + daoBase.allowActionByVoting(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), devZenDao.repToken()); + daoBase.allowActionByVoting(devZenDao.DEV_ZEN_WITHDRAW_ETHER(), devZenDao.repToken()); + daoBase.allowActionByVoting(devZenDao.DEV_ZEN_SELECT_NEXT_HOST(), devZenDao.repToken()); + daoBase.allowActionByVoting(devZenDao.DEV_ZEN_BURN_GUEST_STAKE(), devZenDao.repToken()); + daoBase.allowActionByVoting(devZenDao.DEV_ZEN_CHANGE_GUEST(), devZenDao.repToken()); + daoBase.allowActionByVoting(devZenDao.DEV_ZEN_EMERGENCY_CHANGE_GUEST(), devZenDao.repToken()); + // daoBase.allowActionByVoting(devZenDao.DEV_ZEN_MOVE_TO_NEXT_EPISODE(), devZenDao.repToken()); // DO NOT ALLOW to issueTokens even to DevZenTeam members!!! - // devZenDao.allowActionByVoting(keccak256("issueTokens"), devZenDao.repToken()); + // devZenDao.allowActionByVoting(devZenDao.ISSUE_TOKENS(), devZenDao.repToken()); } function setupAac() internal { @@ -117,30 +116,29 @@ contract DevZenDaoFactory { aac = new DevZenDaoAuto(IDaoBase(daoBase), devZenDao); - // daoBase.allowActionByAddress(keccak256("addNewProposal"), aac); - - // daoBase.allowActionByAddress(keccak256("manageGroups"), aac); - // daoBase.allowActionByAddress(keccak256("modifyMoneyscheme"), aac); - // daoBase.allowActionByAddress(keccak256("upgradeDaoContract"), aac); - // daoBase.allowActionByAddress(keccak256("DevZen_updateDaoParams"), aac); - // daoBase.allowActionByAddress(keccak256("DevZen_withdrawEther"), aac); - // daoBase.allowActionByAddress(keccak256("DevZen_selectNextHost"), aac); - // daoBase.allowActionByAddress(keccak256("DevZen_burnGuestStake"), aac); - // daoBase.allowActionByAddress(keccak256("DevZen_changeGuest"), aac); - // daoBase.allowActionByAddress(keccak256("DevZen_emergencyChangeGuest"), aac); - // daoBase.allowActionByAddress(keccak256("DevZen_moveToNextEpisode"), aac); - - // uint VOTING_TYPE_1P1V = 1; - // aac.setVotingParams("manageGroups", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("modifyMoneyscheme", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("upgradeDaoContract", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("DevZen_updateDaoParams", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("DevZen_withdrawEther", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("DevZen_selectNextHost", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("DevZen_burnGuestStake", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("DevZen_changeGuest", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("DevZen_emergencyChangeGuest", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); - // aac.setVotingParams("DevZen_moveToNextEpisode", VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + daoBase.allowActionByAddress(daoBase.ADD_NEW_PROPOSAL(), aac); + daoBase.allowActionByAddress(daoBase.MANAGE_GROUPS(), aac); + daoBase.allowActionByAddress(daoBase.UPGRADE_DAO_CONTRACT(), aac); + + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), aac); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_WITHDRAW_ETHER(), aac); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_SELECT_NEXT_HOST(), aac); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_BURN_GUEST_STAKE(), aac); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_CHANGE_GUEST(), aac); + daoBase.allowActionByAddress(devZenDao.DEV_ZEN_EMERGENCY_CHANGE_GUEST(), aac); + // daoBase.allowActionByAddress(devZenDao.DEV_ZEN_MOVE_TO_NEXT_EPISODE(), aac); + + uint VOTING_TYPE_1P1V = 1; + aac.setVotingParams(daoBase.MANAGE_GROUPS(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + aac.setVotingParams(daoBase.UPGRADE_DAO_CONTRACT(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + + aac.setVotingParams(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + aac.setVotingParams(devZenDao.DEV_ZEN_WITHDRAW_ETHER(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + aac.setVotingParams(devZenDao.DEV_ZEN_SELECT_NEXT_HOST(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + aac.setVotingParams(devZenDao.DEV_ZEN_BURN_GUEST_STAKE(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + aac.setVotingParams(devZenDao.DEV_ZEN_CHANGE_GUEST(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + aac.setVotingParams(devZenDao.DEV_ZEN_EMERGENCY_CHANGE_GUEST(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); + // aac.setVotingParams(devZenDao.DEV_ZEN_MOVE_TO_NEXT_EPISODE(), VOTING_TYPE_1P1V, bytes32(0), "DevZenTeam", bytes32(50), bytes32(50), 0); // aac.transferOwnership(msg.sender); }