Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"no-undef": "off",
"eol-last": 2,
"eqeqeq": "error"
}
},
"ignorePatterns": ["cache/", "node_modules/","coverage/"]
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ node_modules/
.vscode/
site/
yarn*
cache/
artifacts/
.DS_Store
report*
coverage/
coverage.json
.covera*
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ dist: trusty
language: node_js

node_js:
- "10.16.3"
- "14.5.0"

before_install:

install:
- npm i
- npm ci
- rm -rf build/ # remove any remaining artifacts from a previous build
- truffle version
- npx buidler --version
- npx buidler clean

jobs:
include:
- stage: tests
name: "Unit tests"
script: npm run test
script: npx buidler test

- stage: tests
name: "Solidity Lint"
script: npm run solhint
script: npx buidler check

- stage: tests
name: "JS Lint"
script: npm run lint
script: npx eslint .
132 changes: 132 additions & 0 deletions buidler.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
usePlugin("@nomiclabs/buidler-truffle5");
usePlugin("@nomiclabs/buidler-solhint");
usePlugin("solidity-coverage");

// This is a sample Buidler task. To learn how to create your own go to
// https://buidler.dev/guides/create-task.html
task("accounts", "Prints the list of accounts", async () => {
const accounts = await web3.eth.getAccounts();

for (const account of accounts) {
console.log(account);
}
});

module.exports = {
paths: {
artifacts: './build/contracts'
},
networks: {
buidlerevm: {
accounts: [
{
privateKey:
"0xc5e8f61d1ab959b397eecc0a37a6517b8e67a0e7cf1f4bce5591f3ed80199122",
balance: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
privateKey:
"0xd49743deccbccc5dc7baa8e69e5be03298da8688a15dd202e20f15d5e0e9a9fb",
balance: "10000000000000000000000"
},
{
privateKey:
"0x23c601ae397441f3ef6f1075dcb0031ff17fb079837beadaf3c84d96c6f3e569",
balance: "10000000000000000000000"
},
{
privateKey:
"0xee9d129c1997549ee09c0757af5939b2483d80ad649a0eda68e8b0357ad11131",
balance: "10000000000000000000000"
},
{
privateKey:
"0x87630b2d1de0fbd5044eb6891b3d9d98c34c8d310c852f98550ba774480e47cc",
balance: "10000000000000000000000"
},
{
privateKey:
"0x275cc4a2bfd4f612625204a20a2280ab53a6da2d14860c47a9f5affe58ad86d4",
balance: "10000000000000000000000"
},
{
privateKey:
"0x7f307c41137d1ed409f0a7b028f6c7596f12734b1d289b58099b99d60a96efff",
balance: "10000000000000000000000"
},
{
privateKey:
"0x2a8aede924268f84156a00761de73998dac7bf703408754b776ff3f873bcec60",
balance: "10000000000000000000000"
},
{
privateKey:
"0x8b24fd94f1ce869d81a34b95351e7f97b2cd88a891d5c00abc33d0ec9501902e",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29085",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29086",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29087",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29088",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29089",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908a",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908b",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908c",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908d",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908e",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908f",
balance: "10000000000000000000000"
}
]
}
},
solc: {
version: "0.5.17", // Fetch exact version from solc-bin (default: truffle's version)
optimizer: {
enabled: true,
runs: 200
}
}
};
6 changes: 3 additions & 3 deletions contracts/Reputation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ contract Reputation is Ownable {
/// @return True if the reputation are generated correctly
function mint(address _user, uint256 _amount) public onlyOwner returns (bool) {
uint256 curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
require(curTotalSupply + _amount >= curTotalSupply, "total supply overflow"); // Check for overflow
uint256 previousBalanceTo = balanceOf(_user);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
require(previousBalanceTo + _amount >= previousBalanceTo, "balace overflow"); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_user], previousBalanceTo + _amount);
emit Mint(_user, _amount);
Expand Down Expand Up @@ -154,7 +154,7 @@ contract Reputation is Ownable {
/// @param checkpoints The history of data being updated
/// @param _value The new number of reputation
function updateValueAtNow(Checkpoint[] storage checkpoints, uint256 _value) internal {
require(uint128(_value) == _value); //check value is in the 128 bits bounderies
require(uint128(_value) == _value, "reputation overflow"); //check value is in the 128 bits bounderies
if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
newCheckPoint.fromBlock = uint128(block.number);
Expand Down
14 changes: 7 additions & 7 deletions contracts/votingMachines/AbsoluteVote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract AbsoluteVote is IntVoteInterface {
* @dev Check that the proposal is votable (open and not executed yet)
*/
modifier votable(bytes32 _proposalId) {
require(proposals[_proposalId].open);
require(proposals[_proposalId].open, "proposal is not votable");
_;
}

Expand All @@ -62,8 +62,8 @@ contract AbsoluteVote is IntVoteInterface {
returns(bytes32)
{
// Check valid params and number of choices:
require(parameters[_paramsHash].precReq > 0);
require(_numOfChoices > 0 && _numOfChoices <= MAX_NUM_OF_CHOICES);
require(parameters[_paramsHash].precReq > 0, "no setParameters been called");
require(_numOfChoices > 0 && _numOfChoices <= MAX_NUM_OF_CHOICES, "numOfChoices out of range");
// Generate a unique ID:
bytes32 proposalId = keccak256(abi.encodePacked(this, proposalsCnt));
proposalsCnt = proposalsCnt.add(1);
Expand Down Expand Up @@ -109,7 +109,7 @@ contract AbsoluteVote is IntVoteInterface {
Parameters memory params = parameters[proposal.paramsHash];
address voter;
if (params.voteOnBehalf != address(0)) {
require(msg.sender == params.voteOnBehalf);
require(msg.sender == params.voteOnBehalf, "msg.sender is not authorized to vote");
voter = _voter;
} else {
voter = msg.sender;
Expand Down Expand Up @@ -198,7 +198,7 @@ contract AbsoluteVote is IntVoteInterface {
* @dev hash the parameters, save them if necessary, and return the hash value
*/
function setParameters(uint256 _precReq, address _voteOnBehalf) public returns(bytes32) {
require(_precReq <= 100 && _precReq > 0);
require(_precReq <= 100 && _precReq > 0, "wrong precReq");
bytes32 hashedParameters = getParametersHash(_precReq, _voteOnBehalf);
parameters[hashedParameters] = Parameters({
precReq: _precReq,
Expand Down Expand Up @@ -266,11 +266,11 @@ contract AbsoluteVote is IntVoteInterface {
function internalVote(bytes32 _proposalId, address _voter, uint256 _vote, uint256 _rep) internal returns(bool) {
Proposal storage proposal = proposals[_proposalId];
// Check valid vote:
require(_vote <= proposal.numOfChoices);
require(_vote <= proposal.numOfChoices, "vote is out of range");
// Check voter has enough reputation:
uint256 reputation = VotingMachineCallbacksInterface(proposal.callbacks).reputationOf(_voter, _proposalId);
require(reputation > 0, "_voter must have reputation");
require(reputation >= _rep);
require(reputation >= _rep, "cannot vote with more reputation voter has");
uint256 rep = _rep;
if (rep == 0) {
rep = reputation;
Expand Down
4 changes: 2 additions & 2 deletions contracts/votingMachines/GenesisProtocol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
address staker = delegationDigest.recover(_signature);
//a garbage staker address due to wrong signature will revert due to lack of approval and funds.
require(staker != address(0), "staker address cannot be 0");
require(stakesNonce[staker] == _nonce);
require(stakesNonce[staker] == _nonce, "wrong nonce");
stakesNonce[staker] = stakesNonce[staker].add(1);
return _stake(_proposalId, _vote, _amount, staker);
}
Expand All @@ -119,7 +119,7 @@ contract GenesisProtocol is IntVoteInterface, GenesisProtocolLogic {
Parameters memory params = parameters[proposal.paramsHash];
address voter;
if (params.voteOnBehalf != address(0)) {
require(msg.sender == params.voteOnBehalf);
require(msg.sender == params.voteOnBehalf, "msg.sender is not authorized to vote");
voter = _voter;
} else {
voter = msg.sender;
Expand Down
9 changes: 5 additions & 4 deletions contracts/votingMachines/GenesisProtocolLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ contract GenesisProtocolLogic is IntVoteInterface {
* PreBoosted,Boosted,QuietEndingPeriod or Queued
*/
modifier votable(bytes32 _proposalId) {
require(_isVotable(_proposalId));
require(_isVotable(_proposalId), "proposal is not votable");
_;
}

Expand All @@ -174,7 +174,7 @@ contract GenesisProtocolLogic is IntVoteInterface {
// solhint-disable-next-line not-rely-on-time
require(now > parameters[_paramsHash].activationTime, "not active yet");
//Check parameters existence.
require(parameters[_paramsHash].queuedVoteRequiredPercentage >= 50);
require(parameters[_paramsHash].queuedVoteRequiredPercentage >= 50, "no parameters exist");
// Generate a unique ID:
bytes32 proposalId = keccak256(abi.encodePacked(this, proposalsCnt));
proposalsCnt = proposalsCnt.add(1);
Expand Down Expand Up @@ -404,7 +404,7 @@ contract GenesisProtocolLogic is IntVoteInterface {
public
returns(uint256 redeemedAmount, uint256 potentialAmount) {
Proposal storage proposal = proposals[_proposalId];
require(proposal.state == ProposalState.Executed);
require(proposal.state == ProposalState.Executed, "proposal state must be executed");
uint256 totalWinningStakes = proposal.stakes[proposal.winningVote];
Staker storage staker = proposal.stakers[_beneficiary];
if (
Expand All @@ -422,7 +422,8 @@ contract GenesisProtocolLogic is IntVoteInterface {
proposal.daoBountyRemain = proposal.daoBountyRemain.sub(potentialAmount);
require(
VotingMachineCallbacksInterface(proposal.callbacks)
.stakingTokenTransfer(stakingToken, _beneficiary, potentialAmount, _proposalId));
.stakingTokenTransfer(stakingToken, _beneficiary, potentialAmount, _proposalId),
"failed at stakingTokenTransfer");
redeemedAmount = potentialAmount;
emit RedeemDaoBounty(_proposalId, organizations[proposal.organizationId], _beneficiary, redeemedAmount);
}
Expand Down
5 changes: 0 additions & 5 deletions migrations/1_initial_migration.js

This file was deleted.

13 changes: 0 additions & 13 deletions migrations/2_deploy_organization.js

This file was deleted.

Loading