diff --git a/contracts/universalSchemes/DaoCreator.sol b/contracts/universalSchemes/DaoCreator.sol index 76512dd0..59f23887 100644 --- a/contracts/universalSchemes/DaoCreator.sol +++ b/contracts/universalSchemes/DaoCreator.sol @@ -3,12 +3,12 @@ pragma solidity ^0.5.11; import "./UniversalScheme.sol"; import "../controller/UController.sol"; import "../controller/Controller.sol"; +import "../utils/DAOTracker.sol"; /** * @title ControllerCreator for creating a single controller. */ - contract ControllerCreator { function create(Avatar _avatar) public returns(address) { @@ -22,8 +22,6 @@ contract ControllerCreator { /** * @title Genesis Scheme that creates organizations */ - - contract DaoCreator { mapping(address=>address) public locks; @@ -32,9 +30,13 @@ contract DaoCreator { event InitialSchemesSet (address _avatar); ControllerCreator private controllerCreator; + DAOTracker private daoTracker; - constructor(ControllerCreator _controllerCreator) public { + constructor(ControllerCreator _controllerCreator, DAOTracker _daoTracker) public { + require(_controllerCreator != ControllerCreator(0)); + require(_daoTracker != DAOTracker(0)); controllerCreator = _controllerCreator; + daoTracker = _daoTracker; } /** @@ -198,16 +200,19 @@ contract DaoCreator { // Create Controller: if (UController(0) == _uController) { controller = ControllerInterface(controllerCreator.create(avatar)); - avatar.transferOwnership(address(controller)); - // Transfer ownership: - nativeToken.transferOwnership(address(controller)); - nativeReputation.transferOwnership(address(controller)); } else { controller = _uController; - avatar.transferOwnership(address(controller)); - // Transfer ownership: - nativeToken.transferOwnership(address(controller)); - nativeReputation.transferOwnership(address(controller)); + } + + // Add the DAO to the tracking registry + daoTracker.track(avatar, controller); + + // Transfer ownership: + avatar.transferOwnership(address(controller)); + nativeToken.transferOwnership(address(controller)); + nativeReputation.transferOwnership(address(controller)); + + if (controller == _uController) { _uController.newOrganization(avatar); } diff --git a/contracts/utils/DAOTracker.sol b/contracts/utils/DAOTracker.sol new file mode 100644 index 00000000..6ae6c3d8 --- /dev/null +++ b/contracts/utils/DAOTracker.sol @@ -0,0 +1,90 @@ +pragma solidity ^0.5.11; + +import "@daostack/infra/contracts/Reputation.sol"; +import "../controller/DAOToken.sol"; +import "../controller/Avatar.sol"; +import "../controller/ControllerInterface.sol"; +import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; + +/** + * @title An on-chain "source of truth" for what DAOs + * should be index into DAOstack's subgraph. + */ +contract DAOTracker is Ownable { + + // `blacklist` the DAO from the subgraph's cache. + // Only able to be set by the owner of the DAOTracker. + mapping(address=>bool) public blacklisted; + + event TrackDAO(address indexed _avatar, address _controller, address _reputation, address _daoToken); + event BlacklistDAO(address indexed _avatar, string _explanationHash); + event ResetDAO(address indexed _avatar, string _explanationHash); + + modifier onlyAvatarOwner(Avatar avatar) { + require(avatar.owner() == msg.sender, + "The caller must be the owner of the Avatar."); + _; + } + + modifier notBlacklisted(Avatar avatar) { + require(blacklisted[address(avatar)] == false, + "The avatar has been blacklisted."); + _; + } + + /** + * @dev track a new organization. This function will tell the subgraph + * to start ingesting events from the DAO's contracts. + * NOTE: This function should be called as early as possible in the DAO deployment + * process. **Smart Contract Events that are emitted from blocks prior to this function's + * event being emitted WILL NOT be ingested into the subgraph**, leading to an incorrect + * cache. If this happens to you, please contact the subgraph maintainer. Your DAO will + * need to be added to the subgraph's startup config, and the cache will need to be rebuilt. + * @param _avatar the organization avatar + * @param _controller the organization controller + */ + function track(Avatar _avatar, ControllerInterface _controller) + public + onlyAvatarOwner(_avatar) + notBlacklisted(_avatar) { + // Only allow the information to be set once. In the case of a controller upgrades, + // the subgraph will be updated via the UpgradeController event. + require(_avatar != Avatar(0)); + require(_controller != ControllerInterface(0)); + + emit TrackDAO( + address(_avatar), + address(_controller), + address(_avatar.nativeReputation()), + address(_avatar.nativeToken()) + ); + } + + /** + * @dev blacklist a DAO from the cache. This should be callable by maintainer of the cache. + * Blacklisting can be used to defend against DoS attacks, or to remove spam. In order + * for this blacklisting to take affect within the cache, it would need to be rebuilt. + * @param _avatar the organization avatar + * @param _explanationHash A hash of a document explaining why this DAO was blacklisted + */ + function blacklist(Avatar _avatar, string memory _explanationHash) + public + onlyOwner { + require(_avatar != Avatar(0)); + blacklisted[address(_avatar)] = true; + emit BlacklistDAO(address(_avatar), _explanationHash); + } + + /** + * @dev reset a DAO in the cache. This should be callable by the maintainer of the cache. + * @param _avatar the organization avatar + * @param _explanationHash A hash of a document explaining why this DAO was reset + */ + function reset(Avatar _avatar, string memory _explanationHash) + public + onlyOwner { + require(_avatar != Avatar(0)); + blacklisted[address(_avatar)] = false; + emit ResetDAO(address(_avatar), _explanationHash); + } +} diff --git a/migrations/2_deploy_organization.js b/migrations/2_deploy_organization.js index 54c91dcc..fb6353b3 100644 --- a/migrations/2_deploy_organization.js +++ b/migrations/2_deploy_organization.js @@ -9,6 +9,7 @@ var AbsoluteVote = artifacts.require('./AbsoluteVote.sol'); var ContributionReward = artifacts.require('./ContributionReward.sol'); var UpgradeScheme = artifacts.require('./UpgradeScheme.sol'); var ControllerCreator = artifacts.require('./ControllerCreator.sol'); +var DAOTracker = artifacts.require('./DAOTracker.sol'); const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; @@ -35,8 +36,10 @@ var accounts; //schemeRegistrar, upgradeScheme,globalConstraintRegistrar,simpleICO,contributionReward. module.exports = async function(deployer) { deployer.deploy(ControllerCreator, {gas: constants.ARC_GAS_LIMIT}).then(async function(){ + await deployer.deploy(DAOTracker, {gas: constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.deployed(); var controllerCreator = await ControllerCreator.deployed(); - await deployer.deploy(DaoCreator,controllerCreator.address, {gas: constants.ARC_GAS_LIMIT}); + await deployer.deploy(DaoCreator,controllerCreator.address,daoTracker.address, {gas: constants.ARC_GAS_LIMIT}); var daoCreatorInst = await DaoCreator.deployed(controllerCreator.address,{gas: constants.ARC_GAS_LIMIT}); // Create DAOstack: diff --git a/package-lock.json b/package-lock.json index 803620a5..9df4d268 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2726,12 +2726,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2746,17 +2748,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2873,7 +2878,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2885,6 +2891,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2899,6 +2906,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2906,12 +2914,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2930,6 +2940,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3010,7 +3021,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3022,6 +3034,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3143,6 +3156,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/test/auction4reputation.js b/test/auction4reputation.js index 38c79058..1dfa6a51 100644 --- a/test/auction4reputation.js +++ b/test/auction4reputation.js @@ -1,6 +1,7 @@ const helpers = require('./helpers'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const constants = require('./constants'); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); var Auction4Reputation = artifacts.require("./Auction4Reputation.sol"); @@ -17,7 +18,8 @@ const setup = async function (accounts, var testSetup = new helpers.TestSetup(); testSetup.biddingToken = await ERC20Mock.new(accounts[0], web3.utils.toWei('100', "ether")); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.auctionsEndTime = (await web3.eth.getBlock("latest")).timestamp + _auctionsEndTime; diff --git a/test/continuouslockingtoken4reputation.js b/test/continuouslockingtoken4reputation.js index 7abf3a4a..df961ecc 100644 --- a/test/continuouslockingtoken4reputation.js +++ b/test/continuouslockingtoken4reputation.js @@ -1,5 +1,6 @@ const helpers = require('./helpers'); const DaoCreator = artifacts.require("./DaoCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); const constants = require('./constants'); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); @@ -21,7 +22,8 @@ const setup = async function (accounts, var testSetup = new helpers.TestSetup(); testSetup.lockingToken = await ERC20Mock.new(accounts[0], web3.utils.toWei('100', "ether")); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.startTime = (await web3.eth.getBlock("latest")).timestamp + _startTime; diff --git a/test/contributionreward.js b/test/contributionreward.js index bba07411..09ba8ffc 100644 --- a/test/contributionreward.js +++ b/test/contributionreward.js @@ -4,6 +4,7 @@ const ContributionReward = artifacts.require("./ContributionReward.sol"); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const Avatar = artifacts.require("./Avatar.sol"); const Redeemer = artifacts.require("./Redeemer.sol"); @@ -75,7 +76,8 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=0) { testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); testSetup.contributionReward = await ContributionReward.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); if (genesisProtocol) { testSetup.reputationArray = [1000,100,0]; } else { diff --git a/test/daocreator.js b/test/daocreator.js index 61be0f94..f7defbe3 100644 --- a/test/daocreator.js +++ b/test/daocreator.js @@ -9,12 +9,14 @@ const UController = artifacts.require("./UController.sol"); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); const UniversalSchemeMock = artifacts.require('./test/UniversalSchemeMock.sol'); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const zeroBytes32 = helpers.NULL_HASH; var avatar,token,reputation,daoCreator,uController,controllerCreator; const setup = async function (accounts,founderToken,founderReputation,useUController=false,cap=0) { controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); var uControllerAddress = helpers.NULL_ADDRESS; if (useUController){ uController = await UController.new({gas:constants.ARC_GAS_LIMIT}); @@ -289,7 +291,8 @@ contract('DaoCreator', function(accounts) { it("forgeOrg with different params length should revert", async function() { var amountToMint = 10; var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); var uControllerAddress = helpers.NULL_ADDRESS; try { await daoCreator.forgeOrg("testOrg","TEST","TST",[accounts[0]],[amountToMint],[],uControllerAddress,helpers.NULL_ADDRESS,{gas:constants.ARC_GAS_LIMIT}); diff --git a/test/daotracker.js b/test/daotracker.js new file mode 100644 index 00000000..f0490538 --- /dev/null +++ b/test/daotracker.js @@ -0,0 +1,176 @@ +const helpers = require("./helpers"); +const constants = require("./constants"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); +const Reputation = artifacts.require("./Reputation.sol"); +const DAOToken = artifacts.require("./DAOToken.sol"); +const Avatar = artifacts.require("./Avatar.sol"); +const UController = artifacts.require("./UController.sol"); + +const opts = {gas: constants.ARC_GAS_LIMIT}; + +const setup = async function () { + var testSetup = new helpers.TestSetup(); + testSetup.daoTracker = await DAOTracker.new(opts); + testSetup.daoToken = await DAOToken.new("test", "test", 0, opts); + testSetup.reputation = await Reputation.new(opts); + testSetup.avatar = await Avatar.new( + "test", testSetup.daoToken.address, testSetup.reputation.address, opts, + ); + testSetup.controller = await UController.new(opts); + return testSetup; +}; + +contract("DAOTracker", accounts => { + + it("track", async () => { + const testSetup = await setup(); + const avatar = testSetup.avatar.address; + const daoToken = testSetup.daoToken.address; + const reputation = testSetup.reputation.address; + const controller = testSetup.controller.address; + + const tx = await testSetup.daoTracker.track( + avatar, controller, opts + ); + + // Verify Event + assert.equal(tx.logs.length, 1); + assert.equal(tx.logs[0].event, "TrackDAO"); + assert.equal(tx.logs[0].args._avatar, avatar); + assert.equal(tx.logs[0].args._controller, controller); + assert.equal(tx.logs[0].args._reputation, reputation); + assert.equal(tx.logs[0].args._daoToken, daoToken); + + // Verify Storage + const blacklisted = await testSetup.daoTracker.blacklisted(avatar); + assert.equal(blacklisted, false); + }); + + it("track onlyAvatarOwner", async () => { + const testSetup = await setup(); + const avatar = testSetup.avatar.address; + const controller = testSetup.controller.address; + + try { + await testSetup.daoTracker.track( + avatar, controller, {gas: opts.gas, from: accounts[1]} + ); + assert.fail("This should never happen."); + } catch (e) { + return; + } + }); + + it("track null Avatar", async () => { + const testSetup = await setup(); + const controller = testSetup.controller.address; + + try { + await testSetup.daoTracker.track( + "0x0000000000000000000000000000000000000000", controller, opts + ); + assert.fail("This should never happen."); + } catch (e) { + return; + } + }); + + it("track null Controller", async () => { + const testSetup = await setup(); + const avatar = testSetup.avatar.address; + + try { + await testSetup.daoTracker.track( + avatar, "0x0000000000000000000000000000000000000000", opts + ); + assert.fail("This should never happen."); + } catch (e) { + return; + } + }); + + it("blacklist", async () => { + const testSetup = await setup(); + const avatar = testSetup.avatar.address; + + let blacklisted = await testSetup.daoTracker.blacklisted(avatar); + assert.equal(blacklisted, false); + + const tx = await testSetup.daoTracker.blacklist(avatar, "TEST", opts); + + // Verify Event + assert.equal(tx.logs.length, 1); + assert.equal(tx.logs[0].event, "BlacklistDAO"); + assert.equal(tx.logs[0].args._avatar, avatar); + assert.equal(tx.logs[0].args._explanationHash, "TEST"); + + // Verify Storage + blacklisted = await testSetup.daoTracker.blacklisted(avatar); + assert.equal(blacklisted, true); + }); + + it("blacklist onlyOwner", async () => { + const testSetup = await setup(); + const avatar = testSetup.avatar.address; + + try { + await testSetup.daoTracker.blacklist(avatar, "TEST", {gas: opts.gas, from: accounts[1]}); + assert.fail("This should never happen."); + } catch (e) { + return; + } + }); + + it("blacklist null Avatar", async () => { + const testSetup = await setup(); + + try { + await testSetup.daoTracker.blacklist("0x0000000000000000000000000000000000000000", "TEST", opts); + assert.fail("This should never happen."); + } catch (e) { + return; + } + }); + + it("reset", async () => { + const testSetup = await setup(); + const avatar = testSetup.avatar.address; + const controller = testSetup.controller.address; + + await testSetup.daoTracker.track( + avatar, controller, opts + ); + + let blacklisted = await testSetup.daoTracker.blacklisted(avatar); + assert.equal(blacklisted, false); + + await testSetup.daoTracker.blacklist(avatar, "TEST", opts); + + blacklisted = await testSetup.daoTracker.blacklisted(avatar); + assert.equal(blacklisted, true); + + const tx = await testSetup.daoTracker.reset(avatar, "TEST", opts); + + // Verify Event + assert.equal(tx.logs.length, 1); + assert.equal(tx.logs[0].event, "ResetDAO"); + assert.equal(tx.logs[0].args._avatar, avatar); + assert.equal(tx.logs[0].args._explanationHash, "TEST"); + + // Verify Storage + blacklisted = await testSetup.daoTracker.blacklisted(avatar); + assert.equal(blacklisted, false); + }); + + it("reset onlyOwner", async () => { + const testSetup = await setup(); + const avatar = testSetup.avatar.address; + + try { + await testSetup.daoTracker.reset(avatar, "TEST", {gas: opts.gas, from: accounts[1]}); + assert.fail("This should never happen."); + } catch (e) { + return; + } + }); +}); diff --git a/test/externallocking4reputation.js b/test/externallocking4reputation.js index 0c0f28bd..4d23382c 100644 --- a/test/externallocking4reputation.js +++ b/test/externallocking4reputation.js @@ -1,14 +1,16 @@ -const helpers = require('./helpers'); +const helpers = require("./helpers"); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); -const constants = require('./constants'); +const DAOTracker = artifacts.require("./DAOTracker"); +const constants = require("./constants"); var ExternalLocking4Reputation = artifacts.require("./ExternalLocking4Reputation.sol"); var ExternalTokenLockerMock = artifacts.require("./ExternalTokenLockerMock.sol"); const setup = async function (accounts,_repAllocation = 100,_claimingStartTime = 0,_claimingEndTime = 3000,_redeemEnableTime = 3000, _agreementHash = helpers.SOME_HASH, _initialize = true) { var testSetup = new helpers.TestSetup(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); var block = await web3.eth.getBlock("latest"); testSetup.lockingEndTime = block.timestamp + _claimingEndTime; diff --git a/test/fixreputationallocation.js b/test/fixreputationallocation.js index 0468545e..cbf2c8e1 100644 --- a/test/fixreputationallocation.js +++ b/test/fixreputationallocation.js @@ -1,13 +1,15 @@ const helpers = require('./helpers'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const constants = require('./constants'); var FixedReputationAllocation = artifacts.require("./FixedReputationAllocation.sol"); const setup = async function (accounts,_repAllocation = 300,_initialize = true,_redeemEnableTime = 3000) { var testSetup = new helpers.TestSetup(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],0,0); testSetup.fixedReputationAllocation = await FixedReputationAllocation.new(); diff --git a/test/forwarder.js b/test/forwarder.js index 68356dc2..8ae36e4f 100644 --- a/test/forwarder.js +++ b/test/forwarder.js @@ -1,8 +1,9 @@ -const helpers = require('./helpers'); +const helpers = require("./helpers"); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); -const constants = require('./constants'); -const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); +const DAOTracker = artifacts.require("./DAOTracker.sol"); +const constants = require("./constants"); +const ERC20Mock = artifacts.require("./test/ERC20Mock.sol"); var Forwarder = artifacts.require("./Forwarder.sol"); var ControllerInterface = artifacts.require("./ControllerInterface.sol"); @@ -10,9 +11,10 @@ const setup = async function (accounts, _expirationTime = 300) { var testSetup = new helpers.TestSetup(); - testSetup.biddingToken = await ERC20Mock.new(accounts[0], web3.utils.toWei('100', "ether")); + testSetup.biddingToken = await ERC20Mock.new(accounts[0], web3.utils.toWei("100", "ether")); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.forwarder = await Forwarder.new(); diff --git a/test/genericscheme.js b/test/genericscheme.js index 1ddd1e1d..28576408 100644 --- a/test/genericscheme.js +++ b/test/genericscheme.js @@ -3,6 +3,7 @@ const constants = require('./constants'); const GenericScheme = artifacts.require('./GenericScheme.sol'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const ERC20Mock = artifacts.require("./ERC20Mock.sol"); const ActionMock = artifacts.require("./ActionMock.sol"); const Wallet = artifacts.require("./Wallet.sol"); @@ -45,7 +46,8 @@ const setup = async function (accounts,contractToCall = 0,reputationAccount=0,ge testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); testSetup.genericScheme = await GenericScheme.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.reputationArray = [20,10,70]; if (reputationAccount === 0) { diff --git a/test/globalconstraintregistrar.js b/test/globalconstraintregistrar.js index fe66b914..523eddce 100644 --- a/test/globalconstraintregistrar.js +++ b/test/globalconstraintregistrar.js @@ -6,6 +6,7 @@ const DaoCreator = artifacts.require("./DaoCreator.sol"); const Controller = artifacts.require("./Controller.sol"); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); @@ -43,7 +44,8 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=0) { testSetup.fee = 10; testSetup.globalConstraintRegistrar = await GlobalConstraintRegistrar.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.reputationArray = [20,10,70]; testSetup.org = await helpers.setupOrganizationWithArrays(testSetup.daoCreator,[accounts[0],accounts[1],accounts[2]],[1000,1000,1000],testSetup.reputationArray); testSetup.globalConstraintRegistrarParams= await setupGlobalConstraintRegistrarParams(testSetup.globalConstraintRegistrar,accounts,genesisProtocol,tokenAddress); diff --git a/test/lockingeth4reputation.js b/test/lockingeth4reputation.js index f84cb297..e6ee930d 100644 --- a/test/lockingeth4reputation.js +++ b/test/lockingeth4reputation.js @@ -1,6 +1,7 @@ const helpers = require('./helpers'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const constants = require('./constants'); var LockingEth4Reputation = artifacts.require("./LockingEth4Reputation.sol"); @@ -15,7 +16,8 @@ const setup = async function (accounts, _initialize = true) { var testSetup = new helpers.TestSetup(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.lockingEndTime = (await web3.eth.getBlock("latest")).timestamp + _lockingEndTime; testSetup.lockingStartTime = (await web3.eth.getBlock("latest")).timestamp + _lockingStartTime; diff --git a/test/lockingtoken4reputation.js b/test/lockingtoken4reputation.js index f939bb8c..545e457f 100644 --- a/test/lockingtoken4reputation.js +++ b/test/lockingtoken4reputation.js @@ -1,6 +1,7 @@ const helpers = require('./helpers'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const constants = require('./constants'); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); var LockingToken4Reputation = artifacts.require("./LockingToken4Reputation.sol"); @@ -18,7 +19,8 @@ const setup = async function (accounts, testSetup.lockingToken = await ERC20Mock.new(accounts[0], web3.utils.toWei('100', "ether")); testSetup.lockingToken2 = await ERC20Mock.new(accounts[0], web3.utils.toWei('100', "ether")); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.lockingEndTime = (await web3.eth.getBlock("latest")).timestamp + _lockingEndTime; testSetup.lockingStartTime = (await web3.eth.getBlock("latest")).timestamp + _lockingStartTime; diff --git a/test/organizationregister.js b/test/organizationregister.js index 34f299c8..2a1a980b 100644 --- a/test/organizationregister.js +++ b/test/organizationregister.js @@ -4,6 +4,7 @@ const OrganizationRegister = artifacts.require('./OrganizationRegister.sol'); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); export class OrganizationRegisterParams { constructor() { @@ -29,7 +30,8 @@ const setup = async function (accounts) { testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); testSetup.organizationRegister = await OrganizationRegister.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.organizationRegisterParams= await setupOrganizationRegisterParams(testSetup.organizationRegister,testSetup.standardTokenMock.address,accounts[2]); var permissions = "0x00000000"; diff --git a/test/reputationfromtoken.js b/test/reputationfromtoken.js index 66cac759..682c60a0 100644 --- a/test/reputationfromtoken.js +++ b/test/reputationfromtoken.js @@ -1,6 +1,7 @@ const helpers = require('./helpers'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const constants = require('./constants'); var ReputationFromToken = artifacts.require("./ReputationFromToken.sol"); var RepAllocation = artifacts.require("./RepAllocation.sol"); @@ -14,7 +15,8 @@ const NectarToken = artifacts.require('./Reputation.sol'); const setupNectar = async function (accounts) { var testSetup = new helpers.TestSetup(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.nectarToken = await NectarToken.new(); await testSetup.nectarToken.mint(accounts[0],100); @@ -44,7 +46,8 @@ const setupNectar = async function (accounts) { const setup = async function (accounts, _initialize = true) { var testSetup = new helpers.TestSetup(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.repAllocation = await RepAllocation.new(); await testSetup.repAllocation.addBeneficiary(accounts[0],100); diff --git a/test/schemeregistrar.js b/test/schemeregistrar.js index 7413f905..5821f269 100644 --- a/test/schemeregistrar.js +++ b/test/schemeregistrar.js @@ -6,7 +6,7 @@ const DaoCreator = artifacts.require("./DaoCreator.sol"); const UniversalScheme = artifacts.require('./UniversalScheme.sol'); const Controller = artifacts.require('./Controller.sol'); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); - +const DAOTracker = artifacts.require("./DAOTracker.sol"); export class SchemeRegistrarParams { @@ -30,7 +30,8 @@ const setup = async function (accounts) { testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); testSetup.schemeRegistrar = await SchemeRegistrar.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.reputationArray = [20,40,70]; testSetup.org = await helpers.setupOrganizationWithArrays(testSetup.daoCreator,[accounts[0],accounts[1],accounts[2]],[1000,0,0],testSetup.reputationArray); testSetup.schemeRegistrarParams= await setupSchemeRegistrarParams(testSetup.schemeRegistrar); diff --git a/test/signalscheme.js b/test/signalscheme.js index 44756821..237e6405 100644 --- a/test/signalscheme.js +++ b/test/signalscheme.js @@ -2,6 +2,7 @@ import * as helpers from './helpers'; const constants = require('./constants'); const SignalScheme = artifacts.require("./SignalScheme.sol"); const DaoCreator = artifacts.require("./DaoCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); export class SignalSchemeParams { @@ -37,7 +38,8 @@ const setup = async function (accounts,genesisProtocol = false) { var testSetup = new helpers.TestSetup(); testSetup.signalScheme = await SignalScheme.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); if (genesisProtocol) { testSetup.reputationArray = [1000,100,0]; } else { diff --git a/test/ugenericscheme.js b/test/ugenericscheme.js index 004ab620..e1509bb0 100644 --- a/test/ugenericscheme.js +++ b/test/ugenericscheme.js @@ -3,6 +3,7 @@ const constants = require('./constants'); const AbsoluteVote = artifacts.require('./AbsoluteVote.sol'); const GenericScheme = artifacts.require('./UGenericScheme.sol'); const DaoCreator = artifacts.require("./DaoCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); const ERC20Mock = artifacts.require("./ERC20Mock.sol"); const ActionMock = artifacts.require("./ActionMock.sol"); @@ -40,7 +41,8 @@ const setup = async function (accounts,contractToCall = 0,reputationAccount=0,ge testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); testSetup.genericScheme = await GenericScheme.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.reputationArray = [20,10,70]; if (reputationAccount === 0) { diff --git a/test/upgradescheme.js b/test/upgradescheme.js index 9338ba39..74cceba2 100644 --- a/test/upgradescheme.js +++ b/test/upgradescheme.js @@ -9,7 +9,7 @@ const Avatar = artifacts.require("./Avatar.sol"); const DAOToken = artifacts.require("./DAOToken.sol"); const Reputation = artifacts.require("./Reputation.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); - +const DAOTracker = artifacts.require("./DAOTracker.sol"); @@ -53,7 +53,8 @@ const setup = async function (accounts) { testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); testSetup.upgradeScheme = await UpgradeScheme.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.reputationArray = [20,40,70]; testSetup.org = await helpers.setupOrganizationWithArrays(testSetup.daoCreator,[accounts[0],accounts[1],accounts[2]],[1000,0,0],testSetup.reputationArray); testSetup.upgradeSchemeParams= await setupUpgradeSchemeParams(testSetup.upgradeScheme); diff --git a/test/voteinorganization.js b/test/voteinorganization.js index 810232fd..d98d8889 100644 --- a/test/voteinorganization.js +++ b/test/voteinorganization.js @@ -5,6 +5,7 @@ const VoteInOrganizationScheme = artifacts.require('./VoteInOrganizationScheme.s const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const AbsoluteVoteExecuteMock = artifacts.require("./AbsoluteVoteExecuteMock.sol"); const GenesisProtocolCallbacksMock = artifacts.require("./GenesisProtocolCallbacksMock.sol"); const Reputation = artifacts.require("./Reputation.sol"); @@ -51,7 +52,8 @@ const setup = async function (accounts,reputationAccount=0,genesisProtocol = fal testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); testSetup.voteInOrganization = await VoteInOrganizationScheme.new(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.reputationArray = [200,100,700]; if (reputationAccount === 0) { testSetup.org = await helpers.setupOrganizationWithArrays(testSetup.daoCreator,[accounts[0],accounts[1],accounts[2]],[1000,1000,1000],testSetup.reputationArray); diff --git a/test/votingmachinecallbacks.js b/test/votingmachinecallbacks.js index 6df8b58d..d2043402 100644 --- a/test/votingmachinecallbacks.js +++ b/test/votingmachinecallbacks.js @@ -3,13 +3,15 @@ const constants = require('./constants'); const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); const DaoCreator = artifacts.require("./DaoCreator.sol"); const ControllerCreator = artifacts.require("./ControllerCreator.sol"); +const DAOTracker = artifacts.require("./DAOTracker.sol"); const ARCVotingMachineCallbacksMock = artifacts.require("./ARCVotingMachineCallbacksMock.sol"); const proposalId = "0x1234000000000000000000000000000000000000000000000000000000000000"; const setup = async function (accounts) { var testSetup = new helpers.TestSetup(); var controllerCreator = await ControllerCreator.new({gas: constants.ARC_GAS_LIMIT}); - testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,{gas:constants.ARC_GAS_LIMIT}); + var daoTracker = await DAOTracker.new({gas: constants.ARC_GAS_LIMIT}); + testSetup.daoCreator = await DaoCreator.new(controllerCreator.address,daoTracker.address,{gas:constants.ARC_GAS_LIMIT}); testSetup.org = await helpers.setupOrganization(testSetup.daoCreator,accounts[0],1000,1000); testSetup.standardTokenMock = await ERC20Mock.new(testSetup.org.avatar.address,100);