diff --git a/contracts/schemes/Competition.sol b/contracts/schemes/Competition.sol index 819d183f..e6b56a44 100644 --- a/contracts/schemes/Competition.sol +++ b/contracts/schemes/Competition.sol @@ -109,7 +109,7 @@ contract Competition { * _competitionParams[1] - _votingStartTime competition voting start time * _competitionParams[2] - _endTime competition end time * _competitionParams[3] - _maxNumberOfVotesPerVoter on how many suggestions a voter can vote - * _competitionParams[4] - _suggestionsEndTime suggestion submition end time + * _competitionParams[4] - _suggestionsEndTime suggestion submission end time * _proposerIsAdmin - * true - proposer is an admin. * false no admin. @@ -126,6 +126,7 @@ contract Competition { bool _proposerIsAdmin ) external + // solhint-disable-next-line function-max-lines returns(bytes32 proposalId) { uint256 numberOfWinners = _rewardSplit.length; uint256 startTime = _competitionParams[0]; @@ -142,6 +143,10 @@ contract Competition { require(_competitionParams[4] <= _competitionParams[2], "suggestionsEndTime should be earlier than proposal end time"); require(_competitionParams[4] > startTime, "suggestionsEndTime should be later than proposal start time"); + if (_rewards[2] > 0) { + require(_externalToken != ERC20(0), "extenal token cannot be zero"); + } + require(_reputationChange > 0, "only positive rep change(minting) allowed for a competition"); uint256 totalRewardSplit; for (uint256 i = 0; i < numberOfWinners; i++) { totalRewardSplit = totalRewardSplit.add(_rewardSplit[i]); @@ -160,6 +165,7 @@ contract Competition { proposals[proposalId].nativeTokenReward = _rewards[0]; proposals[proposalId].ethReward = _rewards[1]; proposals[proposalId].externalTokenReward = _rewards[2]; + proposals[proposalId].snapshotBlock = 0; if (_proposerIsAdmin) { proposals[proposalId].admin = msg.sender; } @@ -198,7 +204,7 @@ contract Competition { // solhint-disable-next-line not-rely-on-time require(proposals[_proposalId].startTime <= now, "competition not started yet"); // solhint-disable-next-line not-rely-on-time - require(proposals[_proposalId].suggestionsEndTime > now, "suggestions submition time is over"); + require(proposals[_proposalId].suggestionsEndTime > now, "suggestions submission time is over"); suggestionsCounter = suggestionsCounter.add(1); suggestions[suggestionsCounter].proposalId = _proposalId; address payable beneficiary; @@ -249,11 +255,13 @@ contract Competition { /** * @dev setSnapshotBlock set the block for the reputaion snapshot + * this function is public in order to externaly set snapshot block regardless of the first voting event. * @param _proposalId the proposal id */ function setSnapshotBlock(bytes32 _proposalId) public { // solhint-disable-next-line not-rely-on-time require(proposals[_proposalId].votingStartTime < now, "voting period not started yet"); + require(proposals[_proposalId].maxNumberOfVotesPerVoter > 0, "proposal does not exist"); if (proposals[_proposalId].snapshotBlock == 0) { proposals[_proposalId].snapshotBlock = block.number; emit SnapshotBlock(_proposalId, block.number); @@ -261,14 +269,16 @@ contract Competition { } /** - * @dev sendLeftOverFund send letf over funds back to the dao. + * @dev sendLeftOverFund send leftover funds back to the dao. * @param _proposalId the proposal id */ function sendLeftOverFunds(bytes32 _proposalId) public { // solhint-disable-next-line not-rely-on-time require(proposals[_proposalId].endTime < now, "competition is still on"); + require(proposals[_proposalId].maxNumberOfVotesPerVoter > 0, "proposal does not exist"); + require(_proposalId != bytes32(0), "proposalId is zero"); uint256[] memory topSuggestions = proposals[_proposalId].topSuggestions; - for (uint256 i; i < topSuggestions.length; i++) { + for (uint256 i = 0; i < topSuggestions.length; i++) { require(suggestions[topSuggestions[i]].beneficiary == address(0), "not all winning suggestions redeemed"); } @@ -296,9 +306,12 @@ contract Competition { */ function redeem(uint256 _suggestionId) public { bytes32 proposalId = suggestions[_suggestionId].proposalId; + require(proposalId != bytes32(0), "proposalId is zero"); Proposal storage proposal = proposals[proposalId]; + require(_suggestionId > 0, "suggestionId is zero"); // solhint-disable-next-line not-rely-on-time require(proposal.endTime < now, "competition is still on"); + require(proposal.maxNumberOfVotesPerVoter > 0, "proposal does not exist"); require(suggestions[_suggestionId].beneficiary != address(0), "suggestion was already redeemed"); address payable beneficiary = suggestions[_suggestionId].beneficiary; @@ -344,6 +357,8 @@ contract Competition { /** * @dev getOrderedIndexOfSuggestion return the index of specific suggestion in the winners list. + * for the case when the suggestion is NOT in the winners list, + * this method will return topSuggestions.length * @param _suggestionId suggestion id */ function getOrderedIndexOfSuggestion(uint256 _suggestionId) @@ -354,7 +369,7 @@ contract Competition { require(proposalId != bytes32(0), "suggestion does not exist"); uint256[] memory topSuggestions = proposals[proposalId].topSuggestions; /** get how many elements are greater than a given element*/ - for (uint256 i; i < topSuggestions.length; i++) { + for (uint256 i = 0; i < topSuggestions.length; i++) { if (suggestions[topSuggestions[i]].totalVotes > suggestions[_suggestionId].totalVotes) { index++; } diff --git a/contracts/schemes/ContributionRewardExt.sol b/contracts/schemes/ContributionRewardExt.sol index 6d3b953e..e4617a15 100644 --- a/contracts/schemes/ContributionRewardExt.sol +++ b/contracts/schemes/ContributionRewardExt.sol @@ -69,9 +69,7 @@ contract ContributionRewardExt is VotingMachineCallbacks, ProposalExecuteInterfa } modifier onlyRewarder() { - if (rewarder != address(0)) { - require(msg.sender == rewarder, "msg.sender is not authorized"); - } + require(msg.sender == rewarder, "msg.sender is not authorized"); _; } @@ -106,6 +104,7 @@ contract ContributionRewardExt is VotingMachineCallbacks, ProposalExecuteInterfa { require(avatar == Avatar(0), "can be called only one time"); require(_avatar != Avatar(0), "avatar cannot be zero"); + require(_votingMachine != IntVoteInterface(0), "votingMachine cannot be zero"); avatar = _avatar; votingMachine = _votingMachine; voteParams = _voteParams; @@ -162,6 +161,9 @@ contract ContributionRewardExt is VotingMachineCallbacks, ProposalExecuteInterfa if (beneficiary == address(0)) { beneficiary = msg.sender; } + if (beneficiary == address(this)) { + require(_reputationChange > 0, "only positive rep change(minting) allowed for this case"); + } ContributionProposal memory proposal = ContributionProposal({ nativeTokenReward: _rewards[0], @@ -211,6 +213,7 @@ contract ContributionRewardExt is VotingMachineCallbacks, ProposalExecuteInterfa if (proposal.beneficiary == address(this)) { if (proposal.reputationChangeLeft == 0) {//for now only mint(not burn) rep allowed from ext contract. proposal.reputationChangeLeft = uint256(proposal.reputationChange); + proposal.reputationChange = 0; } } else { reputation = proposal.reputationChange; diff --git a/contracts/schemes/ReputationAdmin.sol b/contracts/schemes/ReputationAdmin.sol index f27a19b0..d58f4aab 100644 --- a/contracts/schemes/ReputationAdmin.sol +++ b/contracts/schemes/ReputationAdmin.sol @@ -46,7 +46,7 @@ contract ReputationAdmin is Ownable { * @param _amounts the amounts of reputation to mint for beneficiaries */ function reputationMint(address[] calldata _beneficiaries, uint256[] calldata _amounts) external onlyOwner { - require(_beneficiaries.length == _amounts.length, "Arrays length mismuch"); + require(_beneficiaries.length == _amounts.length, "Arrays length mismatch"); for (uint256 i=0; i < _beneficiaries.length; i++) { _reputationMint(_beneficiaries[i], _amounts[i]); } @@ -58,7 +58,7 @@ contract ReputationAdmin is Ownable { * @param _amounts the amounts of reputation to burn for beneficiaries */ function reputationBurn(address[] calldata _beneficiaries, uint256[] calldata _amounts) external onlyOwner { - require(_beneficiaries.length == _amounts.length, "Arrays length mismuch"); + require(_beneficiaries.length == _amounts.length, "Arrays length mismatch"); for (uint256 i=0; i < _beneficiaries.length; i++) { _reputationBurn(_beneficiaries[i], _amounts[i]); } diff --git a/package-lock.json b/package-lock.json index 4945133e..8cd8a30f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.39", + "version": "0.0.1-rc.40", "lockfileVersion": 1, "requires": true, "dependencies": { "@babel/cli": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.8.3.tgz", - "integrity": "sha512-K2UXPZCKMv7KwWy9Bl4sa6+jTNP7JyDiHKzoOiUUygaEDbC60vaargZDnO9oFMvlq8pIKOOyUUgeMYrsaN9djA==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.8.4.tgz", + "integrity": "sha512-XXLgAm6LBbaNxaGhMAznXXaxtCWfuv6PIDJ9Alsy9JYTOh+j2jJz+L/162kkfU1j/pTSxK1xGmlwI4pdIMkoag==", "dev": true, "requires": { "chokidar": "^2.1.8", @@ -31,9 +31,9 @@ } }, "@babel/generator": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.3.tgz", - "integrity": "sha512-WjoPk8hRpDRqqzRpvaR8/gDUPkrnOOeuT2m8cNICJtZH6mwaCo3v0OKMI7Y6SM1pBtyijnLtAL0HDi41pf41ug==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.8.4.tgz", + "integrity": "sha512-PwhclGdRpNAf3IxZb0YVuITPZmmrXz9zf6fH8lT4XbrmfQKr6ryBzhv593P5C6poJRciFCL/eHGW2NuGrgEyxA==", "dev": true, "requires": { "@babel/types": "^7.8.3", @@ -83,9 +83,9 @@ } }, "@babel/parser": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.3.tgz", - "integrity": "sha512-/V72F4Yp/qmHaTALizEm9Gf2eQHV3QyTL3K0cNfijwnMnb1L+LDlAubb/ZnSdGAVzVSWakujHYs1I26x66sMeQ==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.8.4.tgz", + "integrity": "sha512-0fKu/QqildpXmPVaRBoXOlyBb3MC+J0A66x97qEfLOMkn3u6nfY5esWogQwi/K0BjASYy4DbnsEWnpNL6qT5Mw==", "dev": true }, "@babel/template": { @@ -100,16 +100,16 @@ } }, "@babel/traverse": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.8.3.tgz", - "integrity": "sha512-we+a2lti+eEImHmEXp7bM9cTxGzxPmBiVJlLVD+FuuQMeeO7RaDbutbgeheDkw+Xe3mCfJHnGOWLswT74m2IPg==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.8.4.tgz", + "integrity": "sha512-NGLJPZwnVEyBPLI+bl9y9aSnxMhsKz42so7ApAv9D+b4vAFPpY013FTS9LdKxcABoIYFU52HcYga1pPlx454mg==", "dev": true, "requires": { "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.8.3", + "@babel/generator": "^7.8.4", "@babel/helper-function-name": "^7.8.3", "@babel/helper-split-export-declaration": "^7.8.3", - "@babel/parser": "^7.8.3", + "@babel/parser": "^7.8.4", "@babel/types": "^7.8.3", "debug": "^4.1.0", "globals": "^11.1.0", @@ -216,9 +216,9 @@ } }, "@types/node": { - "version": "13.1.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.8.tgz", - "integrity": "sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A==" + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.0.tgz", + "integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==" }, "acorn": { "version": "6.4.0", @@ -1485,9 +1485,9 @@ } }, "clean-css": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz", - "integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", + "integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==", "dev": true, "requires": { "source-map": "~0.6.0" @@ -1603,9 +1603,9 @@ } }, "commander": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.0.tgz", - "integrity": "sha512-NIQrwvv9V39FHgGFm36+U9SMQzbiHvU79k+iADraJTpmrFFfx7Ds0IvDoAdZsDrknlkRk14OYoWXb57uTh7/sw==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", "dev": true }, "component-emitter": { @@ -1748,9 +1748,9 @@ } }, "cron": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/cron/-/cron-1.8.1.tgz", - "integrity": "sha512-T60noGxx/2h4FDRBf6449FrINbitSCwIZEcDIwbIPX+mkNkNH0t/4yw0RBGpOiA5yveM4koNHcAuIFopp7vbuA==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz", + "integrity": "sha512-Gk2c4y6xKEO8FSAUTklqtfSr7oTq0CiPQeLBG5Fl0qoXpZyMcj1SG59YL+hqq04bu6/IuEA7lMkYDAplQNKkyg==", "dev": true, "requires": { "moment-timezone": "^0.5.x" @@ -2162,9 +2162,9 @@ } }, "eslint-plugin-import": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.0.tgz", - "integrity": "sha512-NK42oA0mUc8Ngn4kONOPsPB1XhbUvNHqF+g307dPV28aknPoiNnKLFd9em4nkswwepdF5ouieqv5Th/63U7YJQ==", + "version": "2.20.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.1.tgz", + "integrity": "sha512-qQHgFOTjguR+LnYRoToeZWT62XM55MBVXObHM6SKFd1VzDcX/vqT1kAz8ssqigh5eMj8qXcRoXXGZpPP6RfdCw==", "dev": true, "requires": { "array-includes": "^3.0.3", @@ -2241,9 +2241,9 @@ "dev": true }, "eslint-plugin-react": { - "version": "7.18.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.18.0.tgz", - "integrity": "sha512-p+PGoGeV4SaZRDsXqdj9OWcOrOpZn8gXoGPcIQTzo2IDMbAKhNDnME9myZWqO3Ic4R3YmwAZ1lDjWl2R2hMUVQ==", + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.18.3.tgz", + "integrity": "sha512-Bt56LNHAQCoou88s8ViKRjMB2+36XRejCQ1VoLj716KI1MoE99HpTVvIThJ0rvFmG4E4Gsq+UgToEjn+j044Bg==", "dev": true, "requires": { "array-includes": "^3.1.1", @@ -2254,7 +2254,8 @@ "object.fromentries": "^2.0.2", "object.values": "^1.1.1", "prop-types": "^15.7.2", - "resolve": "^1.14.2" + "resolve": "^1.14.2", + "string.prototype.matchall": "^4.0.2" }, "dependencies": { "doctrine": { @@ -3254,9 +3255,9 @@ "dev": true }, "ganache-cli": { - "version": "6.8.2", - "resolved": "https://registry.npmjs.org/ganache-cli/-/ganache-cli-6.8.2.tgz", - "integrity": "sha512-FgsJx/hHh7A1/fmSQpNT5jxZ3dYEal4zQMqYyA8Bm7S6MgrVO48hIjnROn2JteubHY8Rob8LzxMkhEvoQce7WA==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/ganache-cli/-/ganache-cli-6.9.0.tgz", + "integrity": "sha512-ZdL6kPrApXF/O+f6uU431OJcwxMk69H3KPDSHHrMP82ZvZRNpDHbR+rVv7XX/YUeoQ5q6nZ2AFiGiFAVn9pfzA==", "dev": true, "requires": { "ethereumjs-util": "6.1.0", @@ -4218,6 +4219,17 @@ } } }, + "internal-slot": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.2.tgz", + "integrity": "sha512-2cQNfwhAfJIkU4KZPkDI+Gj5yNNnbqi40W9Gge6dfnk4TocEVm00B3bdiL+JINrbGJil2TeHvM4rETGzk/f/0g==", + "dev": true, + "requires": { + "es-abstract": "^1.17.0-next.1", + "has": "^1.0.3", + "side-channel": "^1.0.2" + } + }, "interpret": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", @@ -4964,9 +4976,9 @@ "dev": true }, "needle": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", - "integrity": "sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.2.tgz", + "integrity": "sha512-DUzITvPVDUy6vczKKYTnWc/pBZ0EnjMJnQ3y+Jo5zfKFimJs7S3HFCxCRZYB9FUZcrzUQr3WsmvZgddMEIZv6w==", "dev": true, "requires": { "debug": "^3.2.6", @@ -5799,6 +5811,16 @@ "safe-regex": "^1.1.0" } }, + "regexp.prototype.flags": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", + "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + } + }, "regexpp": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", @@ -5894,9 +5916,9 @@ } }, "resolve": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz", - "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", + "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -6103,6 +6125,16 @@ "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==", "dev": true }, + "side-channel": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.2.tgz", + "integrity": "sha512-7rL9YlPHg7Ancea1S96Pa8/QWb4BtXL/TZvS6B8XFetGBeuhAsfmUspK6DokBeZ64+Kj9TCNRD/30pVz1BvQNA==", + "dev": true, + "requires": { + "es-abstract": "^1.17.0-next.1", + "object-inspect": "^1.7.0" + } + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -6433,6 +6465,20 @@ } } }, + "string.prototype.matchall": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.2.tgz", + "integrity": "sha512-N/jp6O5fMf9os0JU3E72Qhf590RSRZU/ungsL/qJUYVTNv7hTG0P/dbPjxINVN9jpscu3nzYwKESU3P3RY5tOg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0", + "has-symbols": "^1.0.1", + "internal-slot": "^1.0.2", + "regexp.prototype.flags": "^1.3.0", + "side-channel": "^1.0.2" + } + }, "string.prototype.trimleft": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", diff --git a/package.json b/package.json index 179fbe60..393f01ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.39", + "version": "0.0.1-rc.40", "description": "A platform for building DAOs", "files": [ "contracts/", diff --git a/test/competition.js b/test/competition.js index 45e2822c..615dd14b 100644 --- a/test/competition.js +++ b/test/competition.js @@ -18,7 +18,7 @@ const setupContributionRewardParams = async function( genesisProtocol, token, avatar, - redeemer = helpers.NULL_ADDRESS + redeemer ) { var contributionRewardParams = new ContributionRewardParams(); if (genesisProtocol === true) { @@ -39,7 +39,7 @@ const setupContributionRewardParams = async function( return contributionRewardParams; }; -const setup = async function (accounts,genesisProtocol = false,tokenAddress=0,service=helpers.NULL_ADDRESS) { +const setup = async function (accounts,genesisProtocol = false,tokenAddress=0) { var testSetup = new helpers.TestSetup(); testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100000); testSetup.contributionRewardExt = await ContributionRewardExt.new(); @@ -52,20 +52,21 @@ const setup = async function (accounts,genesisProtocol = false,tokenAddress=0,se testSetup.reputationArray = [2000,5000,7000]; } testSetup.org = await helpers.setupOrganizationWithArrays(testSetup.daoCreator,[accounts[0],accounts[1],accounts[2]],[1000,0,0],testSetup.reputationArray); + testSetup.competition = await Competition.new(); + testSetup.competition.initialize(testSetup.contributionRewardExt.address); + testSetup.admin = accounts[0]; testSetup.contributionRewardExtParams= await setupContributionRewardParams( testSetup.contributionRewardExt, accounts,genesisProtocol, tokenAddress, testSetup.org.avatar, - service); + testSetup.competition.address); var permissions = "0x00000000"; await testSetup.daoCreator.setSchemes(testSetup.org.avatar.address, [testSetup.contributionRewardExt.address], [helpers.NULL_HASH],[permissions],"metaData"); - testSetup.competition = await Competition.new(); - testSetup.competition.initialize(testSetup.contributionRewardExt.address); - testSetup.admin = accounts[0]; + return testSetup; };