Skip to content

Commit

Permalink
Merge branch 'master' into fix/error-testing-in-delayed-claimable#672
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestas2k authored Jan 15, 2018
2 parents a4029e7 + ec2f7ba commit c9fff64
Show file tree
Hide file tree
Showing 67 changed files with 1,611 additions and 461 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- [ ] 📘 I've reviewed the [OpenZeppelin Contributor Guidelines](/docs/CONTRIBUTING.md)
- [ ] ✅ I've added tests where applicable to test my new functionality.
- [ ] 📖 I've made sure that my contracts are well-documented.
- [ ] 🎨 I've run the JavaScript linter (`npm run lint:fix`) and fixed all issues.
- [ ] 🎨 I've run the JS/Solidity linters (`npm run lint:all:fix`) and fixed any issues.

<!-- **Does this close any open issues?** If so, list them here. -->

Expand Down
26 changes: 8 additions & 18 deletions .soliumrc.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
{
"custom-rules-filename": null,
"extends": "solium:all",
"plugins": ["security"],
"rules": {
"imports-on-top": true,
"variable-declarations": true,
"array-declarations": true,
"operator-whitespace": true,
"lbrace": true,
"mixedcase": false,
"camelcase": true,
"uppercase": true,
"no-with": true,
"no-empty-blocks": true,
"no-unused-vars": true,
"double-quotes": true,
"blank-lines": true,
"indentation": true,
"whitespace": true,
"deprecated-suicide": true,
"pragma-on-top": true
"quotes": ["error", "double"],
"indentation": ["error", 2],
"arg-overflow": ["warning", 3],
"security/enforce-explicit-visibility": ["error"],
"security/no-block-members": ["warning"],
"security/no-inline-assembly": ["warning"]
}
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ before_script:
- truffle version
script:
- npm run lint
- npm run lint:sol
- npm run test
notifications:
slack:
Expand Down
16 changes: 8 additions & 8 deletions contracts/Bounty.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.18;


import './payment/PullPayment.sol';
import './lifecycle/Destructible.sol';
import "./payment/PullPayment.sol";
import "./lifecycle/Destructible.sol";


/**
Expand Down Expand Up @@ -34,12 +34,6 @@ contract Bounty is PullPayment, Destructible {
return target;
}

/**
* @dev Internal function to deploy the target contract.
* @return A target contract address
*/
function deployContract() internal returns(address);

/**
* @dev Sends the contract funds to the researcher that proved the contract is broken.
* @param target contract
Expand All @@ -53,6 +47,12 @@ contract Bounty is PullPayment, Destructible {
claimed = true;
}

/**
* @dev Internal function to deploy the target contract.
* @return A target contract address
*/
function deployContract() internal returns(address);

}


Expand Down
1 change: 1 addition & 0 deletions contracts/DayLimit.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.4.18;


/**
* @title DayLimit
* @dev Base contract that enables methods to be protected by placing a linear limit (specifiable)
Expand Down
5 changes: 4 additions & 1 deletion contracts/MerkleProof.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.4.18;


/*
* @title MerkleProof
* @dev Merkle proof verification
Expand All @@ -15,7 +16,9 @@ library MerkleProof {
*/
function verifyProof(bytes _proof, bytes32 _root, bytes32 _leaf) public pure returns (bool) {
// Check if proof length is a multiple of 32
if (_proof.length % 32 != 0) return false;
if (_proof.length % 32 != 0) {
return false;
}

bytes32 proofElement;
bytes32 computedHash = _leaf;
Expand Down
1 change: 1 addition & 0 deletions contracts/ReentrancyGuard.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.4.18;


/**
* @title Helps contracts guard agains reentrancy attacks.
* @author Remco Bloemen <remco@2π.com>
Expand Down
19 changes: 10 additions & 9 deletions contracts/crowdsale/CappedCrowdsale.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pragma solidity ^0.4.18;

import '../math/SafeMath.sol';
import './Crowdsale.sol';
import "../math/SafeMath.sol";
import "./Crowdsale.sol";


/**
* @title CappedCrowdsale
Expand All @@ -17,18 +18,18 @@ contract CappedCrowdsale is Crowdsale {
cap = _cap;
}

// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal view returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}

// overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
bool capReached = weiRaised >= cap;
return super.hasEnded() || capReached;
}

// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal view returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}

}
38 changes: 19 additions & 19 deletions contracts/crowdsale/Crowdsale.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pragma solidity ^0.4.18;

import '../token/MintableToken.sol';
import '../math/SafeMath.sol';
import "../token/MintableToken.sol";
import "../math/SafeMath.sol";


/**
* @title Crowdsale
Expand Down Expand Up @@ -53,22 +54,11 @@ contract Crowdsale {
wallet = _wallet;
}

// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}

// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}

// Override this method to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
return weiAmount.mul(rate);
}

// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
Expand All @@ -88,6 +78,22 @@ contract Crowdsale {
forwardFunds();
}

// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}

// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}

// Override this method to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
return weiAmount.mul(rate);
}

// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
Expand All @@ -101,10 +107,4 @@ contract Crowdsale {
return withinPeriod && nonZeroPurchase;
}

// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}


}
7 changes: 4 additions & 3 deletions contracts/crowdsale/FinalizableCrowdsale.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pragma solidity ^0.4.18;

import '../math/SafeMath.sol';
import '../ownership/Ownable.sol';
import './Crowdsale.sol';
import "../math/SafeMath.sol";
import "../ownership/Ownable.sol";
import "./Crowdsale.sol";


/**
* @title FinalizableCrowdsale
Expand Down
5 changes: 3 additions & 2 deletions contracts/crowdsale/RefundVault.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pragma solidity ^0.4.18;

import '../math/SafeMath.sol';
import '../ownership/Ownable.sol';
import "../math/SafeMath.sol";
import "../ownership/Ownable.sol";


/**
* @title RefundVault
Expand Down
24 changes: 12 additions & 12 deletions contracts/crowdsale/RefundableCrowdsale.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.4.18;


import '../math/SafeMath.sol';
import './FinalizableCrowdsale.sol';
import './RefundVault.sol';
import "../math/SafeMath.sol";
import "./FinalizableCrowdsale.sol";
import "./RefundVault.sol";


/**
Expand All @@ -27,13 +27,6 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
goal = _goal;
}

// We're overriding the fund forwarding from Crowdsale.
// In addition to sending the funds, we want to call
// the RefundVault deposit function
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}

// if crowdsale is unsuccessful, investors can claim refunds here
function claimRefund() public {
require(isFinalized);
Expand All @@ -42,6 +35,10 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
vault.refund(msg.sender);
}

function goalReached() public view returns (bool) {
return weiRaised >= goal;
}

// vault finalization task, called when owner calls finalize()
function finalization() internal {
if (goalReached()) {
Expand All @@ -53,8 +50,11 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
super.finalization();
}

function goalReached() public view returns (bool) {
return weiRaised >= goal;
// We're overriding the fund forwarding from Crowdsale.
// In addition to sending the funds, we want to call
// the RefundVault deposit function
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}

}
8 changes: 5 additions & 3 deletions contracts/examples/SampleCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ import "../crowdsale/CappedCrowdsale.sol";
import "../crowdsale/RefundableCrowdsale.sol";
import "../token/MintableToken.sol";


/**
* @title SampleCrowdsaleToken
* @dev Very simple ERC20 Token that can be minted.
* It is meant to be used in a crowdsale contract.
*/
contract SampleCrowdsaleToken is MintableToken {

string public constant name = "Sample Crowdsale Token";
string public constant symbol = "SCT";
uint8 public constant decimals = 18;
string public constant name = "Sample Crowdsale Token"; // solium-disable-line uppercase
string public constant symbol = "SCT"; // solium-disable-line uppercase
uint8 public constant decimals = 18; // solium-disable-line uppercase

}


/**
* @title SampleCrowdsale
* @dev This is an example of a fully fledged crowdsale.
Expand Down
6 changes: 3 additions & 3 deletions contracts/examples/SimpleToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import "../token/StandardToken.sol";
*/
contract SimpleToken is StandardToken {

string public constant name = "SimpleToken";
string public constant symbol = "SIM";
uint8 public constant decimals = 18;
string public constant name = "SimpleToken"; // solium-disable-line uppercase
string public constant symbol = "SIM"; // solium-disable-line uppercase
uint8 public constant decimals = 18; // solium-disable-line uppercase

uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));

Expand Down
2 changes: 1 addition & 1 deletion contracts/lifecycle/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.18;

import "../ownership/Ownable.sol";

import '../ownership/Ownable.sol';

/**
* @title Migrations
Expand Down
4 changes: 2 additions & 2 deletions contracts/lifecycle/TokenDestructible.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma solidity ^0.4.18;


import "../ownership/Ownable.sol";
import "../token/ERC20Basic.sol";


/**
* @title TokenDestructible:
* @author Remco Bloemen <remco@2π.com>
Expand All @@ -24,7 +24,7 @@ contract TokenDestructible is Ownable {
function destroy(address[] tokens) onlyOwner public {

// Transfer tokens to owner
for(uint256 i = 0; i < tokens.length; i++) {
for (uint256 i = 0; i < tokens.length; i++) {
ERC20Basic token = ERC20Basic(tokens[i]);
uint256 balance = token.balanceOf(this);
token.transfer(owner, balance);
Expand Down
2 changes: 1 addition & 1 deletion contracts/math/Math.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pragma solidity ^0.4.18;


/**
* @title Math
* @dev Assorted math operations
*/

library Math {
function max64(uint64 a, uint64 b) internal pure returns (uint64) {
return a >= b ? a : b;
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/BasicTokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.18;


import '../token/BasicToken.sol';
import "../token/BasicToken.sol";


// mock class using BasicToken
Expand Down
3 changes: 2 additions & 1 deletion contracts/mocks/BurnableTokenMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pragma solidity ^0.4.18;

import '../token/BurnableToken.sol';
import "../token/BurnableToken.sol";


contract BurnableTokenMock is BurnableToken {

Expand Down
Loading

0 comments on commit c9fff64

Please sign in to comment.