Skip to content

Commit

Permalink
#46: permission hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill authored and Kirill committed Aug 31, 2018
1 parent 3453e12 commit 67fe680
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 55 deletions.
14 changes: 7 additions & 7 deletions contracts/3-DevZenDao/DevZenDao.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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();
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down
13 changes: 8 additions & 5 deletions contracts/3-DevZenDao/DevZenDaoCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand Down
84 changes: 41 additions & 43 deletions contracts/3-DevZenDao/DevZenDaoFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -94,53 +94,51 @@ 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 {
// TODO: add all custom actions to the DaoBaseAuto derived contract

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);
}
Expand Down

0 comments on commit 67fe680

Please sign in to comment.