Skip to content

Commit

Permalink
#40: auto methods fixes + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill authored and Kirill committed Aug 31, 2018
1 parent 67fe680 commit ff4592e
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 70 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ coverage.json
node_modules/*

# env
.env
.env

.DS_Store
2 changes: 1 addition & 1 deletion contracts/3-DevZenDao/DevZenDao.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(DEV_ZEN_MOVE_TO_NEXT_EXPISODE) public {
function moveToNextEpisode(bool _guestHasCome) isCanDo(DEV_ZEN_MOVE_TO_NEXT_EPISODE) public {
super._moveToNextEpisode(_guestHasCome);
}

Expand Down
28 changes: 11 additions & 17 deletions contracts/3-DevZenDao/DevZenDaoAuto.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,42 @@ import "@thetta/core/contracts/utils/GenericCaller.sol";

import "./DevZenDao.sol";
import "./DevZenDaoCore.sol";
import "./DevZenDaoWithUnpackers.sol";

contract DevZenDaoAuto is GenericCaller{
DevZenDaoCore devZenDao;
constructor(IDaoBase _dao, DevZenDaoCore _devZenDao) public GenericCaller(_dao){
DevZenDaoWithUnpackers devZenDao;
constructor(IDaoBase _dao, DevZenDaoWithUnpackers _devZenDao) public GenericCaller(_dao){
devZenDao = _devZenDao;
}

bytes32 UPDATE_DAO_PARAMS = keccak256("updateDaoParams");
bytes32 WITHDRAW_ETHER = keccak256("withdrawEther");
bytes32 SELECT_NEXT_HOST = keccak256("selectNextHost");
bytes32 CHANGE_GUEST = keccak256("changeGuest");
bytes32 EMERGENCY_CHANGE_GUEST = keccak256("emergencyChangeGuest");
bytes32 MOVE_TO_NEXT_EXPISODE = keccak256("moveToNextExpisode");

// function updateDaoParamsAuto(DevZenDao.Params _params) public returns(address proposalOut) {
// bytes32[] memory params = new bytes32[](1);
// params[0] = bytes32(_params);
// return doAction(UPDATE_DAO_PARAMS, dao, msg.sender, "updateDaoParamsGeneric(bytes32[])", params);
// return doAction(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), dao, msg.sender, "updateDaoParamsGeneric(bytes32[])", params);
// }

function withdrawEtherAuto(address _output) public returns(address proposalOut) {
bytes32[] memory params = new bytes32[](1);
params[0] = bytes32(_output);
return doAction(WITHDRAW_ETHER, devZenDao, msg.sender, "withdrawEtherGeneric(bytes32[])", params);
return doAction(devZenDao.DEV_ZEN_WITHDRAW_ETHER(), devZenDao, msg.sender, "withdrawEtherGeneric(bytes32[])", params);
}

function selectNextHostAuto(address _nextHost) public returns(address proposalOut) {
bytes32[] memory params = new bytes32[](1);
params[0] = bytes32(_nextHost);
return doAction(SELECT_NEXT_HOST, devZenDao, msg.sender, "selectNextHostGeneric(bytes32[])", params);
return doAction(devZenDao.DEV_ZEN_SELECT_NEXT_HOST(), devZenDao, msg.sender, "selectNextHostGeneric(bytes32[])", params);
}

function changeTheGuestAuto(address _guest) public returns(address proposalOut) {
bytes32[] memory params = new bytes32[](1);
params[0] = bytes32(_guest);
return doAction(CHANGE_GUEST, devZenDao, msg.sender, "changeTheGuestGeneric(bytes32[])", params);
return doAction(devZenDao.DEV_ZEN_CHANGE_GUEST(), devZenDao, msg.sender, "changeTheGuestGeneric(bytes32[])", params);
}

function emergency_ChangeTheGuestAuto(address _guest) public returns(address proposalOut) {
bytes32[] memory params = new bytes32[](1);
params[0] = bytes32(_guest);
return doAction(EMERGENCY_CHANGE_GUEST, devZenDao, msg.sender, "emergency_ChangeTheGuestGeneric(bytes32[])", params);
return doAction(devZenDao.DEV_ZEN_EMERGENCY_CHANGE_GUEST(), devZenDao, msg.sender, "emergency_ChangeTheGuestGeneric(bytes32[])", params);
}

function moveToNextEpisodeAuto(bool _guestHasCome) public returns(address proposalOut) {
Expand All @@ -57,11 +51,11 @@ contract DevZenDaoAuto is GenericCaller{
}else{
params[0] = bytes32(0);
}
return doAction(MOVE_TO_NEXT_EXPISODE, devZenDao, msg.sender, "moveToNextExpisodeGeneric(bytes32[])", params);
return doAction(devZenDao.DEV_ZEN_MOVE_TO_NEXT_EPISODE(), devZenDao, msg.sender, "moveToNextExpisodeGeneric(bytes32[])", params);
}

function burnGuestStakeAuto() isCanDo("DevZen_burnGuestStake") public returns(address proposalOut) {
function burnGuestStakeAuto() public returns(address proposalOut) {
bytes32[] memory params = new bytes32[](0);
return doAction(MOVE_TO_NEXT_EXPISODE, devZenDao, msg.sender, "moveToNextExpisodeGeneric(bytes32[])", params);
return doAction(devZenDao.DEV_ZEN_BURN_GUEST_STAKE(), devZenDao, msg.sender, "burnGuestStakeGeneric(bytes32[])", params);
}
}
2 changes: 1 addition & 1 deletion contracts/3-DevZenDao/DevZenDaoCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract DevZenDaoCore is DaoClient {
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");
bytes32 public constant DEV_ZEN_MOVE_TO_NEXT_EPISODE = keccak256("DevZen_moveToNextExpisode");

event DevZenDaoCore_WithdrawEther(address _output);
event DevZenDaoCore_SelectNextHost(address _nextHost);
Expand Down
65 changes: 25 additions & 40 deletions contracts/3-DevZenDao/DevZenDaoFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "@thetta/core/contracts/IDaoBase.sol";
import "@thetta/core/contracts/DaoStorage.sol";
import "@thetta/core/contracts/DaoBaseAuto.sol";
import "@thetta/core/contracts/tokens/StdDaoToken.sol";
import "@thetta/core/contracts/utils/UtilsLib.sol";

import "./DevZenDao.sol";
import "./DevZenDaoAuto.sol";
Expand All @@ -24,7 +25,7 @@ import "./DevZenDaoWithUnpackers.sol";
// 1 tokens as incentive for 1 guest

contract DevZenDaoFactory {
DevZenDaoCore public devZenDao;
DevZenDaoWithUnpackers public devZenDao;
DaoBase public daoBase;
DaoStorage store;
DevZenDaoAuto public aac;
Expand Down Expand Up @@ -60,32 +61,13 @@ contract DevZenDaoFactory {
store.allowActionByAddress(daoBase.MANAGE_GROUPS(),address(this));
store.allowActionByAddress(daoBase.ISSUE_TOKENS(),address(devZenDao));
store.allowActionByAddress(daoBase.BURN_TOKENS(),address(devZenDao));
store.allowActionByAddress(devZenDao.DEV_ZEN_MOVE_TO_NEXT_EPISODE(), _boss);
store.transferOwnership(daoBase);

devZenToken.transferOwnership(daoBase);
repToken.transferOwnership(daoBase);

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);


// 3 - return
//
return devZenDao;
}

function createNewContract(IDaoBase _daoBase, address[] _tokens, DevZenDao.Params _defaultParams) internal {
devZenDao = new DevZenDaoWithUnpackers(_daoBase, _tokens, _defaultParams);
}

function setPermissions(address _boss, address[] _devZenTeam) internal {
// 1 - populate groups
daoBase.addGroupMember("DevZenTeam", _boss);

uint i = 0;
Expand All @@ -105,12 +87,17 @@ contract DevZenDaoFactory {
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(devZenDao.ISSUE_TOKENS(), devZenDao.repToken());
daoBase.allowActionByVoting(devZenDao.DEV_ZEN_MOVE_TO_NEXT_EPISODE(), devZenDao.repToken());

// 3 - return
//
return devZenDao;
}

function createNewContract(IDaoBase _daoBase, address[] _tokens, DevZenDao.Params _defaultParams) internal {
devZenDao = new DevZenDaoWithUnpackers(_daoBase, _tokens, _defaultParams);
}

function setupAac() internal {
// TODO: add all custom actions to the DaoBaseAuto derived contract

Expand All @@ -126,21 +113,19 @@ contract DevZenDaoFactory {
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);
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);
aac.setVotingParams(daoBase.MANAGE_GROUPS(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);
aac.setVotingParams(daoBase.UPGRADE_DAO_CONTRACT(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);
aac.setVotingParams(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);
aac.setVotingParams(devZenDao.DEV_ZEN_WITHDRAW_ETHER(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);
aac.setVotingParams(devZenDao.DEV_ZEN_SELECT_NEXT_HOST(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);
aac.setVotingParams(devZenDao.DEV_ZEN_BURN_GUEST_STAKE(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);
aac.setVotingParams(devZenDao.DEV_ZEN_CHANGE_GUEST(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);
aac.setVotingParams(devZenDao.DEV_ZEN_EMERGENCY_CHANGE_GUEST(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);
aac.setVotingParams(devZenDao.DEV_ZEN_MOVE_TO_NEXT_EPISODE(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0);

aac.transferOwnership(daoBase);
}

}
1 change: 1 addition & 0 deletions contracts/3-DevZenDao/DevZenDaoFactoryTestable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "./DevZenDaoTestable.sol";
import "@thetta/core/contracts/IDaoBase.sol";
import "./DevZenDaoWithUnpackersTestable.sol";
contract DevZenDaoFactoryTestable is DevZenDaoFactory {
DevZenDaoWithUnpackersTestable public devZenDao;

constructor(address _boss, address[] _devZenTeam) DevZenDaoFactory(_boss, _devZenTeam) public {}

Expand Down
1 change: 1 addition & 0 deletions migrations/2_deploy_contracts_utilsLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = function (deployer) {

deployer.link(UtilsLib, BodDaoFactory);
deployer.link(UtilsLib, HierarchyDaoFactory);
deployer.link(UtilsLib, DevZenDaoFactory);
deployer.link(UtilsLib, DevZenDaoFactoryTestable);
deployer.link(UtilsLib, DevZenDaoTestable);
deployer.link(UtilsLib, DevZenDaoWithUnpackersTestable);
Expand Down
File renamed without changes.
Loading

0 comments on commit ff4592e

Please sign in to comment.