From b919c53bfb2b6eafbda024feb59b2ad85223e460 Mon Sep 17 00:00:00 2001 From: Kirill Date: Tue, 25 Sep 2018 14:29:52 +0700 Subject: [PATCH] #58 --- .../0-FineGrainedPermissions.sol | 14 +- .../1-HierarchyDao/HierarchyDaoFactory.sol | 28 +- contracts/3-DevZenDao/DevZenDao.sol | 1 + contracts/3-DevZenDao/DevZenDaoAuto.sol | 2 +- .../3-DevZenDao/DevZenDaoAutoTestable.sol | 4 +- migrations/2_deploy_contracts_libraries.js | 16 + migrations/2_deploy_contracts_utilsLib.js | 38 --- migrations/3_deploy_contracts_votingLib.js | 37 --- ...ZenDaoFactory.js => 3_deploy_devZenDao.js} | 43 +-- migrations/4_deploy_HierarchyDao.js | 54 ++++ .../4_deploy_contracts_genericCallerLib.js | 32 -- migrations/5_deploy_BodDao.js | 57 ++++ migrations/5_deploy_contracts_daoLib.js | 27 -- package-lock.json | 278 ++++++++++-------- package.json | 2 +- test/utils/helpers.js | 40 ++- 16 files changed, 357 insertions(+), 316 deletions(-) create mode 100644 migrations/2_deploy_contracts_libraries.js delete mode 100644 migrations/2_deploy_contracts_utilsLib.js delete mode 100644 migrations/3_deploy_contracts_votingLib.js rename migrations/{6_deploy_devZenDaoFactory.js => 3_deploy_devZenDao.js} (90%) create mode 100644 migrations/4_deploy_HierarchyDao.js delete mode 100644 migrations/4_deploy_contracts_genericCallerLib.js create mode 100644 migrations/5_deploy_BodDao.js delete mode 100644 migrations/5_deploy_contracts_daoLib.js diff --git a/contracts/0-FineGrainedPermissions/0-FineGrainedPermissions.sol b/contracts/0-FineGrainedPermissions/0-FineGrainedPermissions.sol index 996980c..ad4f84e 100644 --- a/contracts/0-FineGrainedPermissions/0-FineGrainedPermissions.sol +++ b/contracts/0-FineGrainedPermissions/0-FineGrainedPermissions.sol @@ -24,31 +24,31 @@ contract ExampleOfFineGrainedPerms is DaoClient { StdDaoToken public tokenReputationDev; //// - constructor(IDaoBase _dao) public DaoClient(_dao){ + constructor(IDaoBase _daoBase) public DaoClient(_daoBase){ // 1 - create tokens tokenGovernance = new StdDaoToken("YourDaoGovToken","GOV",18, true, false, 10**25); tokenReputation = new StdDaoToken("YourDaoRepToken","REP",18, true, true, 10**25); tokenReputationDev = new StdDaoToken("YourDaoRepDevToken","REPD",18, true, false, 10**25); // 2 - transfer ownership to the Dao - tokenGovernance.transferOwnership(dao); - tokenReputation.transferOwnership(dao); - tokenReputationDev.transferOwnership(dao); + tokenGovernance.transferOwnership(daoBase); + tokenReputation.transferOwnership(daoBase); + tokenReputationDev.transferOwnership(daoBase); } // ACTIONS: function issueTokensGovr(address _to, uint _amount) external isCanDo("CUSTOM_issueTokensGovr"){ // you should grant issueTokens permission to THIS contract - dao.issueTokens(tokenGovernance, _to, _amount); + daoBase.issueTokens(tokenGovernance, _to, _amount); } function issueTokensRep(address _to, uint _amount) external isCanDo("CUSTOM_issueTokensRep"){ // you should grant issueTokens permission to THIS contract - dao.issueTokens(tokenReputation, _to, _amount); + daoBase.issueTokens(tokenReputation, _to, _amount); } function issueTokensRepDev(address _to, uint _amount) external isCanDo("CUSTOM_issueTokensRepDev"){ // you should grant issueTokens permission to THIS contract - dao.issueTokens(tokenReputationDev, _to, _amount); + daoBase.issueTokens(tokenReputationDev, _to, _amount); } } diff --git a/contracts/1-HierarchyDao/HierarchyDaoFactory.sol b/contracts/1-HierarchyDao/HierarchyDaoFactory.sol index 90fa140..a71f804 100644 --- a/contracts/1-HierarchyDao/HierarchyDaoFactory.sol +++ b/contracts/1-HierarchyDao/HierarchyDaoFactory.sol @@ -25,6 +25,7 @@ contract HierarchyDaoFactory { ) public { createDao(_boss, _managers, _employees, _outsiders); setupHierarchyDaoAuto(); + daoBase.renounceOwnership(); } function createDao( @@ -41,15 +42,11 @@ contract HierarchyDaoFactory { daoBase = new DaoBaseWithUnpackers(store); hierarcyDao = new HierarchyDao(IDaoBase(daoBase)); - store.allowActionByAddress(keccak256("manageGroups"), address(this)); + store.allowActionByAddress(daoBase.MANAGE_GROUPS(), address(this)); store.transferOwnership(daoBase); token.transferOwnership(daoBase); - // 2 - setup setPermissions(_boss, _managers, _employees); - - // 3 - return - daoBase.renounceOwnership(); } function setPermissions(address _boss, address[] _managers, address[] _employees) internal { @@ -58,22 +55,15 @@ contract HierarchyDaoFactory { daoBase.addGroupMember("Managers", _boss); daoBase.addGroupMember("Employees", _boss); - daoBase.allowActionByAddress(keccak256("issueTokens"), _boss); - daoBase.allowActionByAddress(keccak256("upgradeDaoContract"), _boss); + daoBase.allowActionByAddress(daoBase.ISSUE_TOKENS(), _boss); + daoBase.allowActionByAddress(daoBase.UPGRADE_DAO_CONTRACT(), _boss); // 2 - set managers group permission - daoBase.allowActionByAnyMemberOfGroup(keccak256("addNewProposal"), "Managers"); - daoBase.allowActionByAnyMemberOfGroup(keccak256("addNewTask"), "Managers"); - daoBase.allowActionByAnyMemberOfGroup(keccak256("startTask"), "Managers"); - daoBase.allowActionByAnyMemberOfGroup(keccak256("startBounty"), "Managers"); - - // 3 - set employees group permissions - daoBase.allowActionByAnyMemberOfGroup(keccak256("startTask"), "Employees"); - daoBase.allowActionByAnyMemberOfGroup(keccak256("startBounty"), "Employees"); + daoBase.allowActionByAnyMemberOfGroup(daoBase.ADD_NEW_PROPOSAL(), "Managers"); // 4 - the rest is by voting only (requires addNewProposal permission) // so accessable by Managers only even with voting - daoBase.allowActionByVoting(keccak256("manageGroups"), token); + daoBase.allowActionByVoting(daoBase.MANAGE_GROUPS(), token); // 5 - populate groups uint i = 0; @@ -91,10 +81,10 @@ contract HierarchyDaoFactory { // set voring params 1 person 1 vote uint8 VOTING_TYPE_1P1V = 1; - hierarchyDaoAuto.setVotingParams(keccak256("manageGroups"), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("Managers"), bytes32(50), bytes32(50), 0); + hierarchyDaoAuto.setVotingParams(daoBase.MANAGE_GROUPS(), VOTING_TYPE_1P1V, bytes32(0), UtilsLib.stringToBytes32("Managers"), bytes32(50), bytes32(50), 0); - daoBase.allowActionByAddress(keccak256("addNewProposal"), hierarchyDaoAuto); - daoBase.allowActionByAddress(keccak256("manageGroups"), hierarchyDaoAuto); + daoBase.allowActionByAddress(daoBase.ADD_NEW_PROPOSAL(), hierarchyDaoAuto); + daoBase.allowActionByAddress(daoBase.MANAGE_GROUPS(), hierarchyDaoAuto); hierarchyDaoAuto.transferOwnership(msg.sender); } diff --git a/contracts/3-DevZenDao/DevZenDao.sol b/contracts/3-DevZenDao/DevZenDao.sol index 0356b5d..0b20f02 100644 --- a/contracts/3-DevZenDao/DevZenDao.sol +++ b/contracts/3-DevZenDao/DevZenDao.sol @@ -4,6 +4,7 @@ pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; import "@thetta/core/contracts/DaoBase.sol"; +import "@thetta/core/contracts/DaoBaseImpersonated.sol"; import "@thetta/core/contracts/IDaoBase.sol"; import "@thetta/core/contracts/tokens/StdDaoToken.sol"; diff --git a/contracts/3-DevZenDao/DevZenDaoAuto.sol b/contracts/3-DevZenDao/DevZenDaoAuto.sol index 0b2e72d..d2672f2 100644 --- a/contracts/3-DevZenDao/DevZenDaoAuto.sol +++ b/contracts/3-DevZenDao/DevZenDaoAuto.sol @@ -18,7 +18,7 @@ contract DevZenDaoAuto is GenericCaller{ event BurnGuestStakeAuto(); DevZenDaoWithUnpackers devZenDao; - constructor(IDaoBase _dao, DevZenDaoWithUnpackers _devZenDao) public GenericCaller(_dao){ + constructor(IDaoBase _daoBase, DevZenDaoWithUnpackers _devZenDao) public GenericCaller(_daoBase){ devZenDao = _devZenDao; } diff --git a/contracts/3-DevZenDao/DevZenDaoAutoTestable.sol b/contracts/3-DevZenDao/DevZenDaoAutoTestable.sol index 96205c2..a35185e 100644 --- a/contracts/3-DevZenDao/DevZenDaoAutoTestable.sol +++ b/contracts/3-DevZenDao/DevZenDaoAutoTestable.sol @@ -10,7 +10,7 @@ import "./DevZenDaoWithUnpackersTestable.sol"; contract DevZenDaoAutoTestable is GenericCaller{ DevZenDaoWithUnpackersTestable devZenDao; - constructor(IDaoBase _dao, DevZenDaoWithUnpackersTestable _devZenDao) public GenericCaller(_dao){ + constructor(IDaoBase _daoBase, DevZenDaoWithUnpackersTestable _devZenDao) public GenericCaller(_daoBase){ devZenDao = _devZenDao; } @@ -18,7 +18,7 @@ contract DevZenDaoAutoTestable is GenericCaller{ bytes32[] memory params = new bytes32[](2); params[0] = _param; params[1] = bytes32(_value); - return doAction(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), dao, msg.sender, "updateDaoParamsGeneric(bytes32[])", params); + return doAction(devZenDao.DEV_ZEN_UPDATE_DAO_PARAMS(), daoBase, msg.sender, "updateDaoParamsGeneric(bytes32[])", params); } function withdrawEtherAuto(address _output) public returns(address proposalOut) { diff --git a/migrations/2_deploy_contracts_libraries.js b/migrations/2_deploy_contracts_libraries.js new file mode 100644 index 0000000..a73c2ca --- /dev/null +++ b/migrations/2_deploy_contracts_libraries.js @@ -0,0 +1,16 @@ +var migrateLibs = require('../node_modules/@thetta/core/scripts/migrateLibs'); + +module.exports = function (deployer, network, accounts) { + let additionalContracts = [ "./BodDaoFactory" + , "./DevZenDaoAuto" + , "./DevZenDaoAutoTestable" + , "./DevZenDaoFactory" + , "./DevZenDaoFactoryTestable" + , "./DevZenDaoTestable" + , "./DevZenDaoWithUnpackers" + , "./DevZenDaoWithUnpackersTestable" + , "./HierarchyDaoFactory" + ] + + return migrateLibs(artifacts, additionalContracts, deployer, network, accounts); +}; diff --git a/migrations/2_deploy_contracts_utilsLib.js b/migrations/2_deploy_contracts_utilsLib.js deleted file mode 100644 index 376e776..0000000 --- a/migrations/2_deploy_contracts_utilsLib.js +++ /dev/null @@ -1,38 +0,0 @@ -var UtilsLib = artifacts.require("./UtilsLib"); - -//var DaoBase = artifacts.require("./DaoBase"); -var DaoBaseWithUnpackers = artifacts.require("./DaoBaseWithUnpackers"); -var GenericCaller = artifacts.require("./GenericCaller"); -var GenericCallerLib = artifacts.require("./GenericCallerLib"); -// var MoneyflowAuto = artifacts.require("./MoneyflowAuto"); -var Voting = artifacts.require("./Voting"); -var VotingLib = artifacts.require("./VotingLib"); -var DaoBaseAuto = artifacts.require("./DaoBaseAuto"); -var DaoStorage = artifacts.require("./DaoStorage"); -var StdDaoToken = artifacts.require("./StdDaoToken"); -var BodDaoFactory = artifacts.require("./BodDaoFactory"); -var HierarchyDaoFactory = artifacts.require("./HierarchyDaoFactory"); -var DevZenDaoFactory = artifacts.require("./DevZenDaoFactory"); -var DevZenDaoFactoryTestable = artifacts.require("./DevZenDaoFactoryTestable"); -var DevZenDaoTestable = artifacts.require("./DevZenDaoTestable"); -var DevZenDaoWithUnpackersTestable = artifacts.require("./DevZenDaoWithUnpackersTestable"); -var DevZenDaoWithUnpackers = artifacts.require("./DevZenDaoWithUnpackers"); - -module.exports = function (deployer) { - deployer.deploy(UtilsLib).then(() => { - deployer.link(UtilsLib, GenericCaller); - deployer.link(UtilsLib, VotingLib); - deployer.link(UtilsLib, DaoBaseAuto); - deployer.link(UtilsLib, DaoStorage); - deployer.link(UtilsLib, StdDaoToken); - - deployer.link(UtilsLib, BodDaoFactory); - deployer.link(UtilsLib, HierarchyDaoFactory); - deployer.link(UtilsLib, DevZenDaoFactory); - deployer.link(UtilsLib, DevZenDaoFactoryTestable); - deployer.link(UtilsLib, DevZenDaoTestable); - deployer.link(UtilsLib, DevZenDaoWithUnpackersTestable); - deployer.link(UtilsLib, DevZenDaoWithUnpackers); - - }); -}; diff --git a/migrations/3_deploy_contracts_votingLib.js b/migrations/3_deploy_contracts_votingLib.js deleted file mode 100644 index 114e854..0000000 --- a/migrations/3_deploy_contracts_votingLib.js +++ /dev/null @@ -1,37 +0,0 @@ -var DaoBaseWithUnpackers = artifacts.require("./DaoBaseWithUnpackers"); -var GenericCaller = artifacts.require("./GenericCaller"); -var GenericCallerLib = artifacts.require("./GenericCallerLib"); -var Voting = artifacts.require("./Voting"); -var VotingLib = artifacts.require("./VotingLib"); -var DaoBaseAuto = artifacts.require("./DaoBaseAuto"); - -var BodDaoFactory = artifacts.require("./BodDaoFactory"); -var HierarchyDaoFactory = artifacts.require("./HierarchyDaoFactory"); -var DevZenDaoFactory = artifacts.require("./DevZenDaoFactory"); -var DevZenDaoFactoryTestable = artifacts.require("./DevZenDaoFactoryTestable"); -var DevZenDaoTestable = artifacts.require("./DevZenDaoTestable"); -var DevZenDaoAuto = artifacts.require("./DevZenDaoAuto"); -var DevZenDaoWithUnpackers = artifacts.require("./DevZenDaoWithUnpackers"); -var DevZenDaoWithUnpackersTestable = artifacts.require("./DevZenDaoWithUnpackersTestable"); -var DevZenDaoAutoTestable = artifacts.require("./DevZenDaoAutoTestable"); - -module.exports = function (deployer) { - deployer.deploy(VotingLib).then(() => { - deployer.link(VotingLib, Voting); - deployer.link(VotingLib, GenericCaller); - deployer.link(VotingLib, GenericCallerLib); - deployer.link(VotingLib, DaoBaseAuto); - - deployer.link(VotingLib, DevZenDaoFactory); - deployer.link(VotingLib, DevZenDaoFactoryTestable); - deployer.link(VotingLib, DevZenDaoTestable); - deployer.link(VotingLib, DevZenDaoAuto); - deployer.link(VotingLib, DevZenDaoAutoTestable); - - deployer.link(VotingLib, HierarchyDaoFactory); - deployer.link(VotingLib, BodDaoFactory); - - deployer.link(VotingLib, DevZenDaoWithUnpackers); - deployer.link(VotingLib, DevZenDaoWithUnpackersTestable); - }); -}; diff --git a/migrations/6_deploy_devZenDaoFactory.js b/migrations/3_deploy_devZenDao.js similarity index 90% rename from migrations/6_deploy_devZenDaoFactory.js rename to migrations/3_deploy_devZenDao.js index f8bef7d..8a7e5b9 100644 --- a/migrations/6_deploy_devZenDaoFactory.js +++ b/migrations/3_deploy_devZenDao.js @@ -8,43 +8,14 @@ var DevZenDao = artifacts.require("DevZenDao"); var DevZenDaoAuto = artifacts.require("DevZenDaoAuto"); var DevZenDaoCore = artifacts.require("DevZenDaoCore"); var DevZenDaoWithUnpackers = artifacts.require("DevZenDaoWithUnpackers"); -var utf8 = require('utf8'); +const { uintToBytes32, padToBytes, fromUtf8 } = require("../test/utils/helpers"); -function uintToBytes32(n) { - n = Number(n).toString(16); - while (n.length < 64) { - n = "0" + n; - } - return "0x" + n; -} - -function padToBytes32(n, dir='right', withPrefix=true) { - n = n.replace('0x', ''); - while (n.length < 64) { - if(dir == 'right') n = n + "0"; - if(dir == 'left') n = "0" + n; - } - return withPrefix ? "0x" + n : n; -} - -function fromUtf8(str) { - str = utf8.encode(str); - var hex = ""; - for (var i = 0; i < str.length; i++) { - var code = str.charCodeAt(i); - if (code === 0) { - break; - } - var n = code.toString(16); - hex += n.length < 2 ? '0' + n : n; - } - - return padToBytes32(hex); -}; +let emp1 = '0xfac20ad5f3bfc1748235edf919d473272ca0fd55'; +let emp2 = '0x38ed1a11e4f2fd85995a058e1f65d41a483a662a'; +let emp3 = '0x92bc71cd9a9a6ad3a1dcacc2b8c9eab13f4d547e'; module.exports = function(deployer, network, accounts) { - return deployer.then(async () => { - /* + return deployer.then(async () => { let devZenToken = await StdDaoToken.new("DevZenToken", "DZT", 18, true, true, 100000000000000000000); let repToken = await StdDaoToken.new("DevZenRepToken", "DZTREP", 18, true, true, 100000000000000000000); let store = await DaoStorage.new([devZenToken.address, repToken.address]); @@ -59,6 +30,9 @@ module.exports = function(deployer, network, accounts) { // await await 2 - setup await store.addGroupMember(web3.sha3("DevZenTeam"), accounts[0]); + await store.addGroupMember(web3.sha3("DevZenTeam"), emp1); + await store.addGroupMember(web3.sha3("DevZenTeam"), emp2); + await store.addGroupMember(web3.sha3("DevZenTeam"), emp3); await store.transferOwnership(daoBase.address); await devZenDao.setParam(await devZenDao.MINT_TOKENS_PER_WEEK_AMOUNT(), 10 * 1e18); @@ -116,6 +90,5 @@ module.exports = function(deployer, network, accounts) { await devZenDaoAuto.transferOwnership(daoBase.address); await daoBase.renounceOwnership(); - */ }); }; \ No newline at end of file diff --git a/migrations/4_deploy_HierarchyDao.js b/migrations/4_deploy_HierarchyDao.js new file mode 100644 index 0000000..696787e --- /dev/null +++ b/migrations/4_deploy_HierarchyDao.js @@ -0,0 +1,54 @@ +var StdDaoToken = artifacts.require("StdDaoToken"); +var DaoStorage = artifacts.require("DaoStorage"); +var DaoBase = artifacts.require("DaoBase"); +var IDaoBase = artifacts.require("IDaoBase"); +var DaoBaseAuto = artifacts.require("DaoBaseAuto"); +var HierarchyDao = artifacts.require("HierarchyDao"); +const { uintToBytes32, padToBytes, fromUtf8 } = require("../test/utils/helpers"); + +let mng1 = '0x5a2203e516d8f025eaa37d1f6d7f114ac654da05'; +let mng2 = '0x9dc108ae0579a1c856b8eff862fcab76c6e6ee15'; +let mng3 = '0x564dcf23922de39970b2b442b1a2de8d2fd25330'; +let emp1 = '0xfac20ad5f3bfc1748235edf919d473272ca0fd55'; +let emp2 = '0x38ed1a11e4f2fd85995a058e1f65d41a483a662a'; +let emp3 = '0x92bc71cd9a9a6ad3a1dcacc2b8c9eab13f4d547e'; + +module.exports = function(deployer, network, accounts) { + return deployer.then(async () => { + let token = await StdDaoToken.new("StdToken", "STD", 18, true, true, 100000000000000000000); + let store = await DaoStorage.new([token.address]); + let daoBase = await DaoBase.new(store.address); + let hierarcyDao = await HierarchyDao.new(daoBase.address); + + await store.allowActionByAddress(await daoBase.MANAGE_GROUPS(), accounts[0]); + await store.transferOwnership(daoBase.address); + await token.transferOwnership(daoBase.address); + + await daoBase.addGroupMember("Managers", accounts[0]); + await daoBase.addGroupMember("Employees", accounts[0]); + + await daoBase.allowActionByAddress(await daoBase.ISSUE_TOKENS(), accounts[0]); + await daoBase.allowActionByAddress(await daoBase.UPGRADE_DAO_CONTRACT(), accounts[0]); + await daoBase.allowActionByAnyMemberOfGroup(await daoBase.ADD_NEW_PROPOSAL(), "Managers"); + await daoBase.allowActionByVoting(await daoBase.MANAGE_GROUPS(), token.address); + + await daoBase.addGroupMember("Managers", mng1); + await daoBase.addGroupMember("Managers", mng2); + await daoBase.addGroupMember("Managers", mng3); + await daoBase.addGroupMember("Employees", emp1); + await daoBase.addGroupMember("Employees", emp2); + await daoBase.addGroupMember("Employees", emp3); + + let hierarchyDaoAuto = await DaoBaseAuto.new(daoBase.address); + + // set voring params 1 person 1 vote + let VOTING_TYPE_1P1V = 1; + await hierarchyDaoAuto.setVotingParams(await daoBase.MANAGE_GROUPS(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("Managers"), uintToBytes32(50), uintToBytes32(50), 0); + + await daoBase.allowActionByAddress(await daoBase.ADD_NEW_PROPOSAL(), hierarchyDaoAuto.address); + await daoBase.allowActionByAddress(await daoBase.MANAGE_GROUPS(), hierarchyDaoAuto.address); + + await hierarchyDaoAuto.transferOwnership(daoBase.address); + await daoBase.renounceOwnership(); + }); +}; \ No newline at end of file diff --git a/migrations/4_deploy_contracts_genericCallerLib.js b/migrations/4_deploy_contracts_genericCallerLib.js deleted file mode 100644 index 42a8129..0000000 --- a/migrations/4_deploy_contracts_genericCallerLib.js +++ /dev/null @@ -1,32 +0,0 @@ -var DaoBaseWithUnpackers = artifacts.require("./DaoBaseWithUnpackers"); -var GenericCaller = artifacts.require("./GenericCaller"); -var GenericCallerLib = artifacts.require("./GenericCallerLib"); -var DaoBaseAuto = artifacts.require("./DaoBaseAuto"); -var Voting = artifacts.require("./Voting"); -var VotingLib = artifacts.require("./VotingLib"); - -var BodDaoFactory = artifacts.require("./BodDaoFactory"); -var HierarchyDaoFactory = artifacts.require("./HierarchyDaoFactory"); -var DevZenDaoFactory = artifacts.require("./DevZenDaoFactory"); -var DevZenDaoFactoryTestable = artifacts.require("./DevZenDaoFactoryTestable"); -var DevZenDaoTestable = artifacts.require("./DevZenDaoTestable"); -var DevZenDaoAuto = artifacts.require("./DevZenDaoAuto"); -var DevZenDaoWithUnpackers = artifacts.require("./DevZenDaoWithUnpackers"); -var DevZenDaoWithUnpackersTestable = artifacts.require("./DevZenDaoWithUnpackersTestable"); -var DevZenDaoAutoTestable = artifacts.require("./DevZenDaoAutoTestable"); - -module.exports = function (deployer) { - deployer.deploy(GenericCallerLib).then(() => { - deployer.link(GenericCallerLib, GenericCaller); - deployer.link(GenericCallerLib, DaoBaseAuto); - deployer.link(GenericCallerLib, BodDaoFactory); - deployer.link(GenericCallerLib, HierarchyDaoFactory); - deployer.link(GenericCallerLib, DevZenDaoFactory); - deployer.link(GenericCallerLib, DevZenDaoFactoryTestable); - deployer.link(GenericCallerLib, DevZenDaoTestable); - deployer.link(GenericCallerLib, DevZenDaoAuto); - deployer.link(GenericCallerLib, DevZenDaoWithUnpackers); - deployer.link(GenericCallerLib, DevZenDaoWithUnpackersTestable); - deployer.link(GenericCallerLib, DevZenDaoAutoTestable); - }); -}; diff --git a/migrations/5_deploy_BodDao.js b/migrations/5_deploy_BodDao.js new file mode 100644 index 0000000..a1eb401 --- /dev/null +++ b/migrations/5_deploy_BodDao.js @@ -0,0 +1,57 @@ +var StdDaoToken = artifacts.require("StdDaoToken"); +var DaoStorage = artifacts.require("DaoStorage"); +var DaoBase = artifacts.require("DaoBase"); +var IDaoBase = artifacts.require("IDaoBase"); +var DaoBaseAuto = artifacts.require("DaoBaseAuto"); +var BodDao = artifacts.require("BodDao"); +const { uintToBytes32, padToBytes, fromUtf8 } = require("../test/utils/helpers"); + +let dir1 = '0x5a2203e516d8f025eaa37d1f6d7f114ac654da05'; +let dir2 = '0x9dc108ae0579a1c856b8eff862fcab76c6e6ee15'; +let dir3 = '0x564dcf23922de39970b2b442b1a2de8d2fd25330'; +let emp1 = '0xfac20ad5f3bfc1748235edf919d473272ca0fd55'; +let emp2 = '0x38ed1a11e4f2fd85995a058e1f65d41a483a662a'; +let emp3 = '0x92bc71cd9a9a6ad3a1dcacc2b8c9eab13f4d547e'; + +module.exports = function(deployer, network, accounts) { + return deployer.then(async () => { + let token = await StdDaoToken.new("StdToken", "STD", 18, true, true, 100000000000000000000); + let store = await DaoStorage.new([token.address]); + let daoBase = await DaoBase.new(store.address); + let bodDao = await BodDao.new(daoBase.address); + + await store.allowActionByAddress(await daoBase.MANAGE_GROUPS(), accounts[0]); + + await token.transferOwnership(daoBase.address); + await store.transferOwnership(daoBase.address); + + await daoBase.addGroupMember("BoD", accounts[0]); + await daoBase.addGroupMember("Employees", accounts[0]); + + daoBase.allowActionByAnyMemberOfGroup(await daoBase.ADD_NEW_PROPOSAL(), "BoD"); + daoBase.allowActionByVoting(await daoBase.MANAGE_GROUPS(), token.address); + daoBase.allowActionByVoting(await daoBase.ISSUE_TOKENS(), token.address); + daoBase.allowActionByVoting(await daoBase.UPGRADE_DAO_CONTRACT(), token.address); + + await daoBase.addGroupMember("BoD", dir1); + await daoBase.addGroupMember("BoD", dir2); + await daoBase.addGroupMember("BoD", dir3); + await daoBase.addGroupMember("Employees", emp1); + await daoBase.addGroupMember("Employees", emp2); + await daoBase.addGroupMember("Employees", emp3); + + let bodDaoAuto = await DaoBaseAuto.new(daoBase.address); + + let VOTING_TYPE_1P1V = 1; + await bodDaoAuto.setVotingParams(await daoBase.MANAGE_GROUPS(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("BoD"), uintToBytes32(49), uintToBytes32(49), 0); + await bodDaoAuto.setVotingParams(await daoBase.ISSUE_TOKENS(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("BoD"), uintToBytes32(49), uintToBytes32(49), 0); + await bodDaoAuto.setVotingParams(await daoBase.UPGRADE_DAO_CONTRACT(), VOTING_TYPE_1P1V, uintToBytes32(0), fromUtf8("BoD"), uintToBytes32(49), uintToBytes32(49), 0); + + await daoBase.allowActionByAddress(await daoBase.MANAGE_GROUPS(), bodDaoAuto.address); + await daoBase.allowActionByAddress(await daoBase.ISSUE_TOKENS(), bodDaoAuto.address); + await daoBase.allowActionByAddress(await daoBase.ADD_NEW_PROPOSAL(), bodDaoAuto.address); + + await bodDaoAuto.transferOwnership(daoBase.address); + await daoBase.renounceOwnership(); + }); +}; \ No newline at end of file diff --git a/migrations/5_deploy_contracts_daoLib.js b/migrations/5_deploy_contracts_daoLib.js deleted file mode 100644 index a3d51fd..0000000 --- a/migrations/5_deploy_contracts_daoLib.js +++ /dev/null @@ -1,27 +0,0 @@ -var DaoBaseLib = artifacts.require("./DaoBaseLib"); -var DaoBase = artifacts.require("./DaoBase"); -var DaoBaseWithUnpackers = artifacts.require("./DaoBaseWithUnpackers"); -var BodDaoFactory = artifacts.require("./BodDaoFactory"); -var HierarchyDaoFactory = artifacts.require("./HierarchyDaoFactory"); -var DevZenDaoFactory = artifacts.require("./DevZenDaoFactory"); -var DevZenDaoFactoryTestable = artifacts.require("./DevZenDaoFactoryTestable"); -var DevZenDaoTestable = artifacts.require("./DevZenDaoTestable"); -var DevZenDaoWithUnpackers = artifacts.require("./DevZenDaoWithUnpackers"); -var DevZenDaoWithUnpackersTestable = artifacts.require("./DevZenDaoWithUnpackersTestable"); - -module.exports = function (deployer) { - deployer.deploy(DaoBaseLib).then(() => { - deployer.link(DaoBaseLib, DaoBase); - deployer.link(DaoBaseLib, DaoBaseWithUnpackers); - deployer.link(DaoBaseLib, BodDaoFactory); - deployer.link(DaoBaseLib, HierarchyDaoFactory); - deployer.link(DaoBaseLib, DevZenDaoFactory); - - deployer.link(DaoBaseLib, DevZenDaoFactoryTestable); - deployer.link(DaoBaseLib, DevZenDaoWithUnpackers); - deployer.link(DaoBaseLib, DevZenDaoWithUnpackersTestable); - - deployer.link(DaoBaseLib, DevZenDaoTestable); - }); -}; - diff --git a/package-lock.json b/package-lock.json index 3539c46..1f75f01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -126,9 +126,8 @@ "integrity": "sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow==" }, "@thetta/core": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@thetta/core/-/core-1.3.5.tgz", - "integrity": "sha512-NHsEMwU/4GBJu5RWvo7HoSj/shXRfXLkrZES4V8gibMICt9f0QkaKo1CHkjwve6Cpxaw2UfhEk/kLSPAZc4lug==", + "version": "git+https://github.com/Thetta/Thetta-DAO-Framework.git#7a5473cec89adc70df5c05541b7540661ea555c0", + "from": "git+https://github.com/Thetta/Thetta-DAO-Framework.git#dev-enkogu-sept", "requires": { "babel-eslint": "^8.2.6", "babel-polyfill": "^6.26.0", @@ -186,9 +185,9 @@ } }, "solidity-coverage": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.5.8.tgz", - "integrity": "sha512-DPx3hZCQwOWF6KXvQz4Dhtjz3QTxXpjx1J2m5KdrxHGNb7FhMO1LX7iaAdolnTq3L1gQlPUJ5TbK3spPtuI9FA==", + "version": "0.5.11", + "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.5.11.tgz", + "integrity": "sha512-qikdsSi6+9XbfvwA0aI7HUVpF9fIFNqRWTw23M89GMDY+b6Gj0wWU9IngJS0fimoZIAdEp3bfChxvpfVcrUesg==", "requires": { "death": "^1.1.0", "ethereumjs-testrpc-sc": "6.1.6", @@ -250,9 +249,9 @@ } }, "@types/node": { - "version": "9.6.30", - "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.30.tgz", - "integrity": "sha512-mFkVM9yFexPPKm0sidVyEzM8F0O06W3vZ8QnjHYa3AB1uvtPOayGKLrXlXIKOdJ7LOE+zilhxYbGPy/34QTgrw==" + "version": "9.6.32", + "resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.32.tgz", + "integrity": "sha512-5+L3wQ+FHoQ589EaH6rYICleuj8gnunq+1CJkM9fxklirErIOv+kxm3s/vecYnpJOYnFowE5uUizcb3hgjHUug==" }, "@types/qs": { "version": "6.5.1", @@ -281,9 +280,9 @@ } }, "acorn": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.2.tgz", - "integrity": "sha512-cJrKCNcr2kv8dlDnbw+JPUGjHZzo4myaxOLmpOX8a+rgX94YeTcTMv/LFJUSByRpc+i4GgVnnhLxvMu/2Y+rqw==" + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" }, "acorn-jsx": { "version": "4.1.1", @@ -299,9 +298,9 @@ "integrity": "sha1-lLiBq3FyhtAV+iGeCPtmcJ3aWj0=" }, "ajv": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.3.tgz", - "integrity": "sha512-LqZ9wY+fx3UMiiPd741yB2pj3hhil+hQc8taf4o2QGRFpWgZ2V5C8HA165DY9sS3fJwsk7uT7ZlFEyC3Ig3lLg==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", + "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", "requires": { "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", @@ -1528,9 +1527,9 @@ "from": "bignumber.js@git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2" }, "binary-extensions": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", - "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=" + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.12.0.tgz", + "integrity": "sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg==" }, "binaryextensions": { "version": "2.1.1", @@ -1797,6 +1796,11 @@ "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=" }, + "charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=" + }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -2173,6 +2177,11 @@ "which": "^1.2.9" } }, + "crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=" + }, "crypto-js": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.8.tgz", @@ -2597,12 +2606,12 @@ } }, "eslint": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.4.0.tgz", - "integrity": "sha512-UIpL91XGex3qtL6qwyCQJar2j3osKxK9e3ano3OcGEIRM4oWIpCkDg9x95AXEC2wMs7PnxzOkPZ2gq+tsMS9yg==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.6.0.tgz", + "integrity": "sha512-/eVYs9VVVboX286mBK7bbKnO1yamUy2UCRjiY6MryhQL2PaaXCExsCQ2aO83OeYRhU2eCU/FMFP+tVMoOrzNrA==", "requires": { - "ajv": "^6.5.0", - "babel-code-frame": "^6.26.0", + "@babel/code-frame": "^7.0.0", + "ajv": "^6.5.3", "chalk": "^2.1.0", "cross-spawn": "^6.0.5", "debug": "^3.1.0", @@ -2617,11 +2626,11 @@ "functional-red-black-tree": "^1.0.1", "glob": "^7.1.2", "globals": "^11.7.0", - "ignore": "^4.0.2", + "ignore": "^4.0.6", "imurmurhash": "^0.1.4", - "inquirer": "^5.2.0", + "inquirer": "^6.1.0", "is-resolvable": "^1.1.0", - "js-yaml": "^3.11.0", + "js-yaml": "^3.12.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", "lodash": "^4.17.5", @@ -2634,18 +2643,41 @@ "progress": "^2.0.0", "regexpp": "^2.0.0", "require-uncached": "^1.0.3", - "semver": "^5.5.0", + "semver": "^5.5.1", "strip-ansi": "^4.0.0", "strip-json-comments": "^2.0.1", "table": "^4.0.3", "text-table": "^0.2.0" }, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -2667,11 +2699,67 @@ "estraverse": "^4.1.1" } }, + "external-editor": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", + "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==" }, + "inquirer": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.0.tgz", + "integrity": "sha512-QIEQG4YyQ2UYZGDC4srMZ7BjHOmNk1lR2JQj5UknBapklm6WHA+VVH7N+sUdX3A7NeCfGF8o4X1S3Ao7nAcIeg==", + "requires": { + "ansi-escapes": "^3.0.0", + "chalk": "^2.0.0", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.0", + "figures": "^2.0.0", + "lodash": "^4.17.10", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rxjs": "^6.1.0", + "string-width": "^2.1.0", + "strip-ansi": "^4.0.0", + "through": "^2.3.6" + } + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "rxjs": { + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.2.tgz", + "integrity": "sha512-hV7criqbR0pe7EeL3O66UYVg92IR0XsA97+9y+BWTePK9SKmEI5Qd3Zj6uPnGkNzXsBywBQWTvujPl+1Kn9Zjw==", + "requires": { + "tslib": "^1.9.0" + } + }, + "semver": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", + "integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==" + }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -2904,9 +2992,9 @@ } }, "eth-gas-reporter": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/eth-gas-reporter/-/eth-gas-reporter-0.1.10.tgz", - "integrity": "sha512-esVDZWlS+4ByrbHGYHA2sJSevmqBsh7tLTnp7qlc6oJrWqU+SakyTUtHWsUcxhv1SerWEvUl0aRmeytspunmww==", + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/eth-gas-reporter/-/eth-gas-reporter-0.1.12.tgz", + "integrity": "sha512-Ao5uiXSA5Ep5fi/YvGCsFJMelMKj0fMJkAvWYzPVe1h3Mg9Z7X3Rs51ovG9izFZH7wSqnqydiC6SKDhZWpxK2g==", "requires": { "abi-decoder": "^1.0.8", "cli-table3": "^0.5.0", @@ -2916,6 +3004,7 @@ "req-cwd": "^2.0.0", "request": "^2.83.0", "request-promise-native": "^1.0.5", + "sha1": "^1.1.1", "shelljs": "^0.7.8", "solidity-parser-antlr": "^0.2.10", "sync-request": "^6.0.0" @@ -3612,35 +3701,6 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, - "fbjs": { - "version": "0.8.17", - "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", - "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", - "requires": { - "core-js": "^1.0.0", - "isomorphic-fetch": "^2.1.1", - "loose-envify": "^1.0.0", - "object-assign": "^4.1.0", - "promise": "^7.1.1", - "setimmediate": "^1.0.5", - "ua-parser-js": "^0.7.18" - }, - "dependencies": { - "core-js": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", - "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" - }, - "promise": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", - "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", - "requires": { - "asap": "~2.0.3" - } - } - } - }, "fetch-ponyfill": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/fetch-ponyfill/-/fetch-ponyfill-4.1.0.tgz", @@ -5247,26 +5307,6 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "requires": { - "node-fetch": "^1.0.1", - "whatwg-fetch": ">=0.10.0" - }, - "dependencies": { - "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "^0.1.11", - "is-stream": "^1.0.1" - } - } - } - }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -7087,11 +7127,11 @@ "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=" }, "promise": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.1.tgz", - "integrity": "sha1-5F1osAoXZHttpxG/he1u1HII9FA=", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.2.tgz", + "integrity": "sha512-EIyzM39FpVOMbqgzEHhxdrEhtOSDOtjMZQ0M6iVfCE+kWNgCkAyOdnuCWqfmflylftfadU6FkiMgHZA2kUzwRw==", "requires": { - "asap": "~2.0.3" + "asap": "~2.0.6" } }, "promise-to-callback": { @@ -7173,25 +7213,25 @@ } }, "react": { - "version": "16.4.2", - "resolved": "https://registry.npmjs.org/react/-/react-16.4.2.tgz", - "integrity": "sha512-dMv7YrbxO4y2aqnvA7f/ik9ibeLSHQJTI6TrYAenPSaQ6OXfb+Oti+oJiy8WBxgRzlKatYqtCjphTgDSCEiWFg==", + "version": "16.5.2", + "resolved": "https://registry.npmjs.org/react/-/react-16.5.2.tgz", + "integrity": "sha512-FDCSVd3DjVTmbEAjUNX6FgfAmQ+ypJfHUsqUJOYNCBUp1h8lqmtC+0mXJ+JjsWx4KAVTkk1vKd1hLQPvEviSuw==", "requires": { - "fbjs": "^0.8.16", "loose-envify": "^1.1.0", "object-assign": "^4.1.1", - "prop-types": "^15.6.0" + "prop-types": "^15.6.2", + "schedule": "^0.5.0" } }, "react-dom": { - "version": "16.4.2", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.4.2.tgz", - "integrity": "sha512-Usl73nQqzvmJN+89r97zmeUpQDKDlh58eX6Hbs/ERdDHzeBzWy+ENk7fsGQ+5KxArV1iOFPT46/VneklK9zoWw==", + "version": "16.5.2", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.5.2.tgz", + "integrity": "sha512-RC8LDw8feuZOHVgzEf7f+cxBr/DnKdqp56VU0lAs1f4UfKc4cU8wU4fTq/mgnvynLQo8OtlPC19NUFh/zjZPuA==", "requires": { - "fbjs": "^0.8.16", "loose-envify": "^1.1.0", "object-assign": "^4.1.1", - "prop-types": "^15.6.0" + "prop-types": "^15.6.2", + "schedule": "^0.5.0" } }, "read-chunk": { @@ -7244,14 +7284,13 @@ } }, "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", "requires": { - "graceful-fs": "^4.1.2", - "minimatch": "^3.0.2", - "readable-stream": "^2.0.2", - "set-immediate-shim": "^1.0.1" + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" } }, "recast": { @@ -7614,6 +7653,14 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "schedule": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/schedule/-/schedule-0.5.0.tgz", + "integrity": "sha512-HUcJicG5Ou8xfR//c2rPT0lPIRR09vVvN81T9fqfVgBmhERUbDEQoYKjpBxbueJnCPpSu2ujXzOnRQt6x9o/jw==", + "requires": { + "object-assign": "^4.1.1" + } + }, "scoped-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/scoped-regex/-/scoped-regex-1.0.0.tgz", @@ -7700,11 +7747,6 @@ } } }, - "setimmediate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" - }, "sha.js": { "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", @@ -7714,6 +7756,15 @@ "safe-buffer": "^5.0.1" } }, + "sha1": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/sha1/-/sha1-1.1.1.tgz", + "integrity": "sha1-rdqnqTFo85PxnrKxUJFhjicA+Eg=", + "requires": { + "charenc": ">= 0.0.1", + "crypt": ">= 0.0.1" + } + }, "sha3": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/sha3/-/sha3-1.2.2.tgz", @@ -8065,9 +8116,9 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" }, "commander": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", - "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==" + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.18.0.tgz", + "integrity": "sha512-6CYPa+JP2ftfRU2qkDK+UTVeQYosOg/2GbcjIcKPHfinyOLPVGXu/ovN86RP49Re5ndJK1N0kuiidFFuepc4ZQ==" }, "mocha": { "version": "5.2.0", @@ -8682,9 +8733,9 @@ }, "dependencies": { "@types/node": { - "version": "8.10.28", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.28.tgz", - "integrity": "sha512-iHsAzDg3OLH7JP+wipniUULHoDSWLgEDYOvsar6/mpAkTJd9/n23Ap8ikruMlvRTqMv/LXrflH9v/AfiEqaBGg==" + "version": "8.10.30", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.30.tgz", + "integrity": "sha512-Le8HGMI5gjFSBqcCuKP/wfHC19oURzkU2D+ERIescUoJd+CmNEMYBib9LQ4zj1HHEZOJQWhw2ZTnbD8weASh/Q==" } } }, @@ -8888,11 +8939,6 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, - "ua-parser-js": { - "version": "0.7.18", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz", - "integrity": "sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA==" - }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", diff --git a/package.json b/package.json index 3df99c2..3c947b9 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "homepage": "https://web.thetta.io", "dependencies": { - "@thetta/core": "^1.3.5", + "@thetta/core": "https://github.com/Thetta/Thetta-DAO-Framework.git#dev-enkogu-sept", "babel-eslint": "^8.2.3", "babel-polyfill": "^6.26.0", "babel-register": "^6.26.0", diff --git a/test/utils/helpers.js b/test/utils/helpers.js index 682e9d7..461b37a 100644 --- a/test/utils/helpers.js +++ b/test/utils/helpers.js @@ -1,6 +1,8 @@ const should = require('chai') .use(require('chai-as-promised')) .should(); + +const utf8 = require('utf8'); /** * Increases latest block time by duration in seconds @@ -29,7 +31,43 @@ const increaseTime = function increaseTime (duration) { }); } +function uintToBytes32(n) { + n = Number(n).toString(16); + while (n.length < 64) { + n = "0" + n; + } + return "0x" + n; +} + +function padToBytes32(n, dir='right', withPrefix=true) { + n = n.replace('0x', ''); + while (n.length < 64) { + if(dir == 'right') n = n + "0"; + if(dir == 'left') n = "0" + n; + } + return withPrefix ? "0x" + n : n; +} + +function fromUtf8(str) { + str = utf8.encode(str); + var hex = ""; + for (var i = 0; i < str.length; i++) { + var code = str.charCodeAt(i); + if (code === 0) { + break; + } + var n = code.toString(16); + hex += n.length < 2 ? '0' + n : n; + } + + return padToBytes32(hex); +}; + + module.exports = { increaseTime, - should + should, + uintToBytes32, + padToBytes32, + fromUtf8 };