Skip to content

Commit 43071bb

Browse files
ben-kaufmanOren Sokolowsky
andauthored
Buidler WIP (#100)
* Buidler WIP * fix tests * Bumpp travis node version * bump infra and OZ versions * Update .travis.yml Co-authored-by: Oren Sokolowsky <oren@daostack.io>
1 parent 4034ef5 commit 43071bb

19 files changed

+10026
-1973
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"no-undef": "off",
1414
"eol-last": 2,
1515
"eqeqeq": "error"
16-
}
16+
},
17+
"ignorePatterns": ["cache/", "node_modules/","coverage/"]
1718
}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ node_modules/
88
.vscode/
99
site/
1010
yarn*
11+
cache/
12+
artifacts/
13+
.DS_Store
14+
report*
15+
coverage/
16+
coverage.json
17+
.covera*

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@ dist: trusty
33
language: node_js
44

55
node_js:
6-
- "10.16.3"
6+
- "14.5.0"
77

88
before_install:
99

1010
install:
11-
- npm i
11+
- npm ci
1212
- rm -rf build/ # remove any remaining artifacts from a previous build
13-
- truffle version
13+
- npx buidler --version
14+
- npx buidler clean
1415

1516
jobs:
1617
include:
1718
- stage: tests
1819
name: "Unit tests"
19-
script: npm run test
20+
script: npx buidler test
2021

2122
- stage: tests
2223
name: "Solidity Lint"
23-
script: npm run solhint
24+
script: npx buidler check
2425

2526
- stage: tests
2627
name: "JS Lint"
27-
script: npm run lint
28+
script: npx eslint .

buidler.config.js

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
usePlugin("@nomiclabs/buidler-truffle5");
2+
usePlugin("@nomiclabs/buidler-solhint");
3+
usePlugin("solidity-coverage");
4+
5+
// This is a sample Buidler task. To learn how to create your own go to
6+
// https://buidler.dev/guides/create-task.html
7+
task("accounts", "Prints the list of accounts", async () => {
8+
const accounts = await web3.eth.getAccounts();
9+
10+
for (const account of accounts) {
11+
console.log(account);
12+
}
13+
});
14+
15+
module.exports = {
16+
paths: {
17+
artifacts: './build/contracts'
18+
},
19+
networks: {
20+
buidlerevm: {
21+
accounts: [
22+
{
23+
privateKey:
24+
"0xc5e8f61d1ab959b397eecc0a37a6517b8e67a0e7cf1f4bce5591f3ed80199122",
25+
balance: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
26+
},
27+
{
28+
privateKey:
29+
"0xd49743deccbccc5dc7baa8e69e5be03298da8688a15dd202e20f15d5e0e9a9fb",
30+
balance: "10000000000000000000000"
31+
},
32+
{
33+
privateKey:
34+
"0x23c601ae397441f3ef6f1075dcb0031ff17fb079837beadaf3c84d96c6f3e569",
35+
balance: "10000000000000000000000"
36+
},
37+
{
38+
privateKey:
39+
"0xee9d129c1997549ee09c0757af5939b2483d80ad649a0eda68e8b0357ad11131",
40+
balance: "10000000000000000000000"
41+
},
42+
{
43+
privateKey:
44+
"0x87630b2d1de0fbd5044eb6891b3d9d98c34c8d310c852f98550ba774480e47cc",
45+
balance: "10000000000000000000000"
46+
},
47+
{
48+
privateKey:
49+
"0x275cc4a2bfd4f612625204a20a2280ab53a6da2d14860c47a9f5affe58ad86d4",
50+
balance: "10000000000000000000000"
51+
},
52+
{
53+
privateKey:
54+
"0x7f307c41137d1ed409f0a7b028f6c7596f12734b1d289b58099b99d60a96efff",
55+
balance: "10000000000000000000000"
56+
},
57+
{
58+
privateKey:
59+
"0x2a8aede924268f84156a00761de73998dac7bf703408754b776ff3f873bcec60",
60+
balance: "10000000000000000000000"
61+
},
62+
{
63+
privateKey:
64+
"0x8b24fd94f1ce869d81a34b95351e7f97b2cd88a891d5c00abc33d0ec9501902e",
65+
balance: "10000000000000000000000"
66+
},
67+
{
68+
privateKey:
69+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29085",
70+
balance: "10000000000000000000000"
71+
},
72+
{
73+
privateKey:
74+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29086",
75+
balance: "10000000000000000000000"
76+
},
77+
{
78+
privateKey:
79+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29087",
80+
balance: "10000000000000000000000"
81+
},
82+
{
83+
privateKey:
84+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29088",
85+
balance: "10000000000000000000000"
86+
},
87+
{
88+
privateKey:
89+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29089",
90+
balance: "10000000000000000000000"
91+
},
92+
{
93+
privateKey:
94+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908a",
95+
balance: "10000000000000000000000"
96+
},
97+
{
98+
privateKey:
99+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908b",
100+
balance: "10000000000000000000000"
101+
},
102+
{
103+
privateKey:
104+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908c",
105+
balance: "10000000000000000000000"
106+
},
107+
{
108+
privateKey:
109+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908d",
110+
balance: "10000000000000000000000"
111+
},
112+
{
113+
privateKey:
114+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908e",
115+
balance: "10000000000000000000000"
116+
},
117+
{
118+
privateKey:
119+
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908f",
120+
balance: "10000000000000000000000"
121+
}
122+
]
123+
}
124+
},
125+
solc: {
126+
version: "0.5.17", // Fetch exact version from solc-bin (default: truffle's version)
127+
optimizer: {
128+
enabled: true,
129+
runs: 200
130+
}
131+
}
132+
};

contracts/Reputation.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ contract Reputation is Ownable {
4545
/// @return True if the reputation are generated correctly
4646
function mint(address _user, uint256 _amount) public onlyOwner returns (bool) {
4747
uint256 curTotalSupply = totalSupply();
48-
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
48+
require(curTotalSupply + _amount >= curTotalSupply, "total supply overflow"); // Check for overflow
4949
uint256 previousBalanceTo = balanceOf(_user);
50-
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
50+
require(previousBalanceTo + _amount >= previousBalanceTo, "balace overflow"); // Check for overflow
5151
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
5252
updateValueAtNow(balances[_user], previousBalanceTo + _amount);
5353
emit Mint(_user, _amount);
@@ -154,7 +154,7 @@ contract Reputation is Ownable {
154154
/// @param checkpoints The history of data being updated
155155
/// @param _value The new number of reputation
156156
function updateValueAtNow(Checkpoint[] storage checkpoints, uint256 _value) internal {
157-
require(uint128(_value) == _value); //check value is in the 128 bits bounderies
157+
require(uint128(_value) == _value, "reputation overflow"); //check value is in the 128 bits bounderies
158158
if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) {
159159
Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
160160
newCheckPoint.fromBlock = uint128(block.number);

contracts/votingMachines/AbsoluteVote.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ contract AbsoluteVote is IntVoteInterface {
4545
* @dev Check that the proposal is votable (open and not executed yet)
4646
*/
4747
modifier votable(bytes32 _proposalId) {
48-
require(proposals[_proposalId].open);
48+
require(proposals[_proposalId].open, "proposal is not votable");
4949
_;
5050
}
5151

@@ -62,8 +62,8 @@ contract AbsoluteVote is IntVoteInterface {
6262
returns(bytes32)
6363
{
6464
// Check valid params and number of choices:
65-
require(parameters[_paramsHash].precReq > 0);
66-
require(_numOfChoices > 0 && _numOfChoices <= MAX_NUM_OF_CHOICES);
65+
require(parameters[_paramsHash].precReq > 0, "no setParameters been called");
66+
require(_numOfChoices > 0 && _numOfChoices <= MAX_NUM_OF_CHOICES, "numOfChoices out of range");
6767
// Generate a unique ID:
6868
bytes32 proposalId = keccak256(abi.encodePacked(this, proposalsCnt));
6969
proposalsCnt = proposalsCnt.add(1);
@@ -109,7 +109,7 @@ contract AbsoluteVote is IntVoteInterface {
109109
Parameters memory params = parameters[proposal.paramsHash];
110110
address voter;
111111
if (params.voteOnBehalf != address(0)) {
112-
require(msg.sender == params.voteOnBehalf);
112+
require(msg.sender == params.voteOnBehalf, "msg.sender is not authorized to vote");
113113
voter = _voter;
114114
} else {
115115
voter = msg.sender;
@@ -198,7 +198,7 @@ contract AbsoluteVote is IntVoteInterface {
198198
* @dev hash the parameters, save them if necessary, and return the hash value
199199
*/
200200
function setParameters(uint256 _precReq, address _voteOnBehalf) public returns(bytes32) {
201-
require(_precReq <= 100 && _precReq > 0);
201+
require(_precReq <= 100 && _precReq > 0, "wrong precReq");
202202
bytes32 hashedParameters = getParametersHash(_precReq, _voteOnBehalf);
203203
parameters[hashedParameters] = Parameters({
204204
precReq: _precReq,
@@ -266,11 +266,11 @@ contract AbsoluteVote is IntVoteInterface {
266266
function internalVote(bytes32 _proposalId, address _voter, uint256 _vote, uint256 _rep) internal returns(bool) {
267267
Proposal storage proposal = proposals[_proposalId];
268268
// Check valid vote:
269-
require(_vote <= proposal.numOfChoices);
269+
require(_vote <= proposal.numOfChoices, "vote is out of range");
270270
// Check voter has enough reputation:
271271
uint256 reputation = VotingMachineCallbacksInterface(proposal.callbacks).reputationOf(_voter, _proposalId);
272272
require(reputation > 0, "_voter must have reputation");
273-
require(reputation >= _rep);
273+
require(reputation >= _rep, "cannot vote with more reputation voter has");
274274
uint256 rep = _rep;
275275
if (rep == 0) {
276276
rep = reputation;

contracts/votingMachines/GenesisProtocol.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
9797
address staker = delegationDigest.recover(_signature);
9898
//a garbage staker address due to wrong signature will revert due to lack of approval and funds.
9999
require(staker != address(0), "staker address cannot be 0");
100-
require(stakesNonce[staker] == _nonce);
100+
require(stakesNonce[staker] == _nonce, "wrong nonce");
101101
stakesNonce[staker] = stakesNonce[staker].add(1);
102102
return _stake(_proposalId, _vote, _amount, staker);
103103
}
@@ -119,7 +119,7 @@ contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
119119
Parameters memory params = parameters[proposal.paramsHash];
120120
address voter;
121121
if (params.voteOnBehalf != address(0)) {
122-
require(msg.sender == params.voteOnBehalf);
122+
require(msg.sender == params.voteOnBehalf, "msg.sender is not authorized to vote");
123123
voter = _voter;
124124
} else {
125125
voter = msg.sender;

contracts/votingMachines/GenesisProtocolLogic.sol

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ contract GenesisProtocolLogic is IntVoteInterface {
156156
* PreBoosted,Boosted,QuietEndingPeriod or Queued
157157
*/
158158
modifier votable(bytes32 _proposalId) {
159-
require(_isVotable(_proposalId));
159+
require(_isVotable(_proposalId), "proposal is not votable");
160160
_;
161161
}
162162

@@ -174,7 +174,7 @@ contract GenesisProtocolLogic is IntVoteInterface {
174174
// solhint-disable-next-line not-rely-on-time
175175
require(now > parameters[_paramsHash].activationTime, "not active yet");
176176
//Check parameters existence.
177-
require(parameters[_paramsHash].queuedVoteRequiredPercentage >= 50);
177+
require(parameters[_paramsHash].queuedVoteRequiredPercentage >= 50, "no parameters exist");
178178
// Generate a unique ID:
179179
bytes32 proposalId = keccak256(abi.encodePacked(this, proposalsCnt));
180180
proposalsCnt = proposalsCnt.add(1);
@@ -404,7 +404,7 @@ contract GenesisProtocolLogic is IntVoteInterface {
404404
public
405405
returns(uint256 redeemedAmount, uint256 potentialAmount) {
406406
Proposal storage proposal = proposals[_proposalId];
407-
require(proposal.state == ProposalState.Executed);
407+
require(proposal.state == ProposalState.Executed, "proposal state must be executed");
408408
uint256 totalWinningStakes = proposal.stakes[proposal.winningVote];
409409
Staker storage staker = proposal.stakers[_beneficiary];
410410
if (
@@ -422,7 +422,8 @@ contract GenesisProtocolLogic is IntVoteInterface {
422422
proposal.daoBountyRemain = proposal.daoBountyRemain.sub(potentialAmount);
423423
require(
424424
VotingMachineCallbacksInterface(proposal.callbacks)
425-
.stakingTokenTransfer(stakingToken, _beneficiary, potentialAmount, _proposalId));
425+
.stakingTokenTransfer(stakingToken, _beneficiary, potentialAmount, _proposalId),
426+
"failed at stakingTokenTransfer");
426427
redeemedAmount = potentialAmount;
427428
emit RedeemDaoBounty(_proposalId, organizations[proposal.organizationId], _beneficiary, redeemedAmount);
428429
}

migrations/1_initial_migration.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

migrations/2_deploy_organization.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)