diff --git a/contracts/3-DevZenDao/DevZenDaoFactory.sol b/contracts/3-DevZenDao/DevZenDaoFactory.sol index 14e003d..9b77a50 100644 --- a/contracts/3-DevZenDao/DevZenDaoFactory.sol +++ b/contracts/3-DevZenDao/DevZenDaoFactory.sol @@ -3,7 +3,7 @@ pragma solidity ^0.4.22; // to enable Params passing to constructor and method pragma experimental ABIEncoderV2; -import "@thetta/core/contracts/DaoBase.sol"; +import "@thetta/core/contracts/DaoBaseWithUnpackers.sol"; import "@thetta/core/contracts/IDaoBase.sol"; import "@thetta/core/contracts/DaoStorage.sol"; import "@thetta/core/contracts/DaoBaseAuto.sol"; @@ -26,7 +26,7 @@ import "./DevZenDaoWithUnpackers.sol"; contract DevZenDaoFactory { DevZenDaoWithUnpackers public devZenDao; - DaoBase public daoBase; + DaoBaseWithUnpackers public daoBase; DaoStorage store; DevZenDaoAuto public devZenDaoAuto; @@ -44,7 +44,7 @@ contract DevZenDaoFactory { tokens.push(address(devZenToken)); tokens.push(address(repToken)); store = new DaoStorage(tokens); - daoBase = new DaoBase(store); + daoBase = new DaoBaseWithUnpackers(store); createNewContract(IDaoBase(daoBase), tokens); @@ -115,6 +115,7 @@ contract DevZenDaoFactory { uint VOTING_TYPE_1P1V = 1; devZenDaoAuto.setVotingParams(daoBase.MANAGE_GROUPS(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); + devZenDaoAuto.setVotingParams(daoBase.REMOVE_GROUP_MEMBER(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); devZenDaoAuto.setVotingParams(daoBase.UPGRADE_DAO_CONTRACT(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); devZenDaoAuto.setVotingParams(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); devZenDaoAuto.setVotingParams(devZenDao.DEV_ZEN_WITHDRAW_ETHER(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); diff --git a/contracts/3-DevZenDao/DevZenDaoFactoryTestable.sol b/contracts/3-DevZenDao/DevZenDaoFactoryTestable.sol index 828a3ab..0ecbbe9 100644 --- a/contracts/3-DevZenDao/DevZenDaoFactoryTestable.sol +++ b/contracts/3-DevZenDao/DevZenDaoFactoryTestable.sol @@ -4,6 +4,7 @@ pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; import "@thetta/core/contracts/IDaoBase.sol"; +import "@thetta/core/contracts/DaoBaseWithUnpackers.sol"; import "./DevZenDaoFactory.sol"; import "./DevZenDaoTestable.sol"; @@ -13,7 +14,7 @@ import "./DevZenDaoCore.sol"; contract DevZenDaoFactoryTestable { DevZenDaoWithUnpackersTestable public devZenDao; - DaoBase public daoBase; + DaoBaseWithUnpackers public daoBase; DaoStorage store; DevZenDaoAutoTestable public devZenDaoAuto; @@ -31,7 +32,7 @@ contract DevZenDaoFactoryTestable { tokens.push(address(devZenToken)); tokens.push(address(repToken)); store = new DaoStorage(tokens); - daoBase = new DaoBase(store); + daoBase = new DaoBaseWithUnpackers(store); createNewContract(IDaoBase(daoBase), tokens); @@ -101,6 +102,7 @@ contract DevZenDaoFactoryTestable { uint VOTING_TYPE_1P1V = 1; devZenDaoAuto.setVotingParams(daoBase.MANAGE_GROUPS(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); + devZenDaoAuto.setVotingParams(daoBase.REMOVE_GROUP_MEMBER(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); devZenDaoAuto.setVotingParams(daoBase.UPGRADE_DAO_CONTRACT(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); devZenDaoAuto.setVotingParams(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); devZenDaoAuto.setVotingParams(devZenDao.DEV_ZEN_WITHDRAW_ETHER(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("DevZenTeam"), bytes32(65), bytes32(65), 0); diff --git a/migrations/3_deploy_devZenDao.js b/migrations/3_deploy_devZenDao.js index e84dc3e..17673b6 100644 --- a/migrations/3_deploy_devZenDao.js +++ b/migrations/3_deploy_devZenDao.js @@ -1,7 +1,7 @@ var DevZenDaoFactory = artifacts.require("DevZenDaoFactory"); var StdDaoToken = artifacts.require("StdDaoToken"); var DaoStorage = artifacts.require("DaoStorage"); -var DaoBase = artifacts.require("DaoBase"); +var DaoBaseWithUnpackers = artifacts.require("DaoBaseWithUnpackers"); var IDaoBase = artifacts.require("IDaoBase"); var DaoBaseAuto = artifacts.require("DaoBaseAuto"); var DevZenDao = artifacts.require("DevZenDao"); @@ -10,16 +10,16 @@ var DevZenDaoCore = artifacts.require("DevZenDaoCore"); var DevZenDaoWithUnpackers = artifacts.require("DevZenDaoWithUnpackers"); const { uintToBytes32, padToBytes, fromUtf8 } = require("../test/utils/helpers"); -let emp1 = '0xfac20ad5f3bfc1748235edf919d473272ca0fd55'; -let emp2 = '0x38ed1a11e4f2fd85995a058e1f65d41a483a662a'; -let emp3 = '0x92bc71cd9a9a6ad3a1dcacc2b8c9eab13f4d547e'; +let emp1 = '0x7EaD9f71ef8a32D351ce1966b281300114bF2eab'; +let emp2 = '0x1f27a8F4a8A50898C5735221982eefA80c070073'; +let emp3 = '0xC86d4De6dC26d73BE76a526D951d194BF13C605c'; module.exports = function(deployer, network, accounts) { return deployer.then(async () => { let devZenToken = await deployer.deploy(StdDaoToken, "DevZenToken", "DZT", 18, true, true, 100000000000000000000); let repToken = await deployer.deploy(StdDaoToken, "DevZenRepToken", "DZTREP", 18, true, true, 100000000000000000000); let store = await deployer.deploy(DaoStorage, [devZenToken.address, repToken.address]); - let daoBase = await deployer.deploy(DaoBase, store.address); + let daoBase = await deployer.deploy(DaoBaseWithUnpackers, store.address); let devZenDao = await deployer.deploy(DevZenDaoWithUnpackers, daoBase.address, [devZenToken.address, repToken.address]); await store.allowActionByAddress(await daoBase.MANAGE_GROUPS(),accounts[0]); @@ -76,6 +76,7 @@ module.exports = function(deployer, network, accounts) { let VOTING_TYPE_1P1V = 1; await devZenDaoAuto.setVotingParams(await daoBase.MANAGE_GROUPS(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("DevZenTeam"), uintToBytes32(65), uintToBytes32(65), 0); + await devZenDaoAuto.setVotingParams(await daoBase.REMOVE_GROUP_MEMBER(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("DevZenTeam"), uintToBytes32(65), uintToBytes32(65), 0); await devZenDaoAuto.setVotingParams(await daoBase.UPGRADE_DAO_CONTRACT(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("DevZenTeam"), uintToBytes32(65), uintToBytes32(65), 0); await devZenDaoAuto.setVotingParams(await devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("DevZenTeam"), uintToBytes32(65), uintToBytes32(65), 0); await devZenDaoAuto.setVotingParams(await devZenDao.DEV_ZEN_WITHDRAW_ETHER(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("DevZenTeam"), uintToBytes32(65), uintToBytes32(65), 0); diff --git a/test/DevZenDao.functional.tests.js b/test/DevZenDao.functional.tests.js index 622940d..a9712a0 100644 --- a/test/DevZenDao.functional.tests.js +++ b/test/DevZenDao.functional.tests.js @@ -53,6 +53,35 @@ contract("DevZenDaoAuto", (accounts) => { devZenDaoAuto = DevZenDaoAuto.at(await devZenDaoFactory.devZenDaoAuto()); }); + describe("addGroupMemberAuto", () => { + it("should add a new group member on successful voting", async() => { + await devZenDaoAuto.addGroupMemberAuto("DevZenTeam", guest1, {from: boss}).should.be.fulfilled; + const voting = await getVoting(daoBase, 0); + + const membersBefore = await daoBase.getGroupMembers("DevZenTeam"); + assert.equal(membersBefore.length, 3); + + await voting.vote(true, {from: teamMember1}).should.be.fulfilled; + + const membersAfter = await daoBase.getGroupMembers("DevZenTeam"); + assert.equal(membersAfter.length, 4); + assert.equal(membersAfter[3], guest1); + }); + + it("should not add a new group member on failed voting", async() => { + await devZenDaoAuto.addGroupMemberAuto("DevZenTeam", guest1, {from: boss}).should.be.fulfilled; + const voting = await getVoting(daoBase, 0); + + const membersBefore = await daoBase.getGroupMembers("DevZenTeam"); + assert.equal(membersBefore.length, 3); + + await voting.vote(false, {from: teamMember1}).should.be.fulfilled; + + const membersAfter = await daoBase.getGroupMembers("DevZenTeam"); + assert.equal(membersAfter.length, 3); + }); + }); + describe("withdrawEtherAuto", () => { it("should withdraw ether to specified address", async() => { await devZenDao.moveToNextEpisode(false, {from:boss}).should.be.fulfilled; @@ -247,6 +276,34 @@ contract("DevZenDaoAuto", (accounts) => { }); }); + describe("removeGroupMemberAuto", () => { + it("should remove group member on successful voting", async() => { + await devZenDaoAuto.removeGroupMemberAuto("DevZenTeam", teamMember2, {from: boss}).should.be.fulfilled; + const voting = await getVoting(daoBase, 0); + + const membersBefore = await daoBase.getGroupMembers("DevZenTeam"); + assert.equal(membersBefore.length, 3); + + await voting.vote(true, {from: teamMember1}).should.be.fulfilled; + + const membersAfter = await daoBase.getGroupMembers("DevZenTeam"); + assert.equal(membersAfter.length, 2); + }); + + it("should not remove group member on failed voting", async() => { + await devZenDaoAuto.removeGroupMemberAuto("DevZenTeam", teamMember2, {from: boss}).should.be.fulfilled; + const voting = await getVoting(daoBase, 0); + + const membersBefore = await daoBase.getGroupMembers("DevZenTeam"); + assert.equal(membersBefore.length, 3); + + await voting.vote(false, {from: teamMember1}).should.be.fulfilled; + + const membersAfter = await daoBase.getGroupMembers("DevZenTeam"); + assert.equal(membersAfter.length, 3); + }); + }); + describe("updateDaoParamsAuto", () => { it("should update param", async() => { let paramHash = await devZenDao.MINT_TOKENS_PER_WEEK_AMOUNT();