Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'master' into erc721-getApproved
  • Loading branch information
Leo Arias committed Sep 6, 2018
commit 0e6d2baee2e26ad234e98c079cfa3d8e3b9f5fa5
24 changes: 22 additions & 2 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Any exception or additions specific to our project are documented below.
}
```

The exception are the parameters of events. There is no chance of ambiguity
with these, so they should not have underscores. Not even if they are
specified on an ERC with underscores; removing them doesn't change the ABI,
so we should be consistent with the rest of the events in this repository
and remove them.

* Internal and private state variables should have an underscore suffix.

```
Expand All @@ -37,8 +43,22 @@ Any exception or additions specific to our project are documented below.

```
function test() {
uint256 functionVar;
...
uint256 functionVar;
...
}
```

* Internal and private functions should have an underscore prefix.

```
function _testInternal() internal {
...
}
```

```
function _testPrivate() private {
...
}
```

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Interested in contributing to OpenZeppelin?
- Framework proposal and roadmap: https://medium.com/zeppelin-blog/zeppelin-framework-proposal-and-development-roadmap-fdfa9a3a32ab#.iain47pak
- Issue tracker: https://github.com/OpenZeppelin/openzeppelin-solidity/issues
- Contribution guidelines: https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/CONTRIBUTING.md
- Code-style guide: https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/CODE_STYLE.md
- Wiki: https://github.com/OpenZeppelin/openzeppelin-solidity/wiki

## License
Expand Down
31 changes: 0 additions & 31 deletions contracts/LimitBalance.sol

This file was deleted.

13 changes: 8 additions & 5 deletions contracts/access/Whitelist.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import "../access/rbac/RBAC.sol";
* This simplifies the implementation of "user permissions".
*/
contract Whitelist is Ownable, RBAC {
string public constant ROLE_WHITELISTED = "whitelist";

// Name of the whitelisted role.
string private constant ROLE_WHITELISTED = "whitelist";

/**
* @dev Throws if operator is not whitelisted.
Expand All @@ -31,13 +33,14 @@ contract Whitelist is Ownable, RBAC {
public
onlyOwner
{
addRole(_operator, ROLE_WHITELISTED);
_addRole(_operator, ROLE_WHITELISTED);
}

/**
* @dev getter to determine if address is in whitelist
* @dev Determine if an account is whitelisted.
* @return true if the account is whitelisted, false otherwise.
*/
function whitelist(address _operator)
function isWhitelisted(address _operator)
public
view
returns (bool)
Expand Down Expand Up @@ -70,7 +73,7 @@ contract Whitelist is Ownable, RBAC {
public
onlyOwner
{
removeRole(_operator, ROLE_WHITELISTED);
_removeRole(_operator, ROLE_WHITELISTED);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/access/rbac/RBAC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract RBAC {
* @param _operator address
* @param _role the name of the role
*/
function addRole(address _operator, string _role)
function _addRole(address _operator, string _role)
internal
{
roles[_role].add(_operator);
Expand All @@ -64,7 +64,7 @@ contract RBAC {
* @param _operator address
* @param _role the name of the role
*/
function removeRole(address _operator, string _role)
function _removeRole(address _operator, string _role)
internal
{
roles[_role].remove(_operator);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
pragma solidity ^0.4.24;


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


/**
* @title Bounty
* @title BreakInvariantBounty
* @dev This bounty will pay out to a researcher if they break invariant logic of the contract.
*/
contract Bounty is PullPayment, Destructible {
bool public claimed;
mapping(address => address) public researchers;
contract BreakInvariantBounty is PullPayment, Ownable {
bool private claimed_;
mapping(address => address) private researchers;

event TargetCreated(address createdAddress);

/**
* @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed.
*/
function() external payable {
require(!claimed);
require(!claimed_);
}

/**
* @dev Determine if the bounty was claimed.
* @return true if the bounty was claimed, false otherwise.
*/
function claimed() public view returns(bool) {
return claimed_;
}

/**
Expand All @@ -28,7 +35,7 @@ contract Bounty is PullPayment, Destructible {
* @return A target contract
*/
function createTarget() public returns(Target) {
Target target = Target(deployContract());
Target target = Target(_deployContract());
researchers[target] = msg.sender;
emit TargetCreated(target);
return target;
Expand All @@ -43,15 +50,22 @@ contract Bounty is PullPayment, Destructible {
require(researcher != address(0));
// Check Target contract invariants
require(!_target.checkInvariant());
asyncTransfer(researcher, address(this).balance);
claimed = true;
_asyncTransfer(researcher, address(this).balance);
claimed_ = true;
}

/**
* @dev Transfers the current balance to the owner and terminates the contract.
*/
function destroy() public onlyOwner {
selfdestruct(owner());
}

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

}

Expand Down
64 changes: 46 additions & 18 deletions contracts/crowdsale/Crowdsale.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;

import "../token/ERC20/ERC20.sol";
import "../token/ERC20/IERC20.sol";
import "../math/SafeMath.sol";
import "../token/ERC20/SafeERC20.sol";

Expand All @@ -19,22 +19,19 @@ import "../token/ERC20/SafeERC20.sol";
*/
contract Crowdsale {
using SafeMath for uint256;
using SafeERC20 for ERC20;
using SafeERC20 for IERC20;

// The token being sold
ERC20 public token;
IERC20 private token_;

// Address where funds are collected
address public wallet;
address private wallet_;

// How many token units a buyer gets per wei.
// The rate is the conversion between wei and the smallest and indivisible token unit.
// So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK
// 1 wei will give you 1 unit, or 0.001 TOK.
uint256 public rate;
uint256 private rate_;

// Amount of wei raised
uint256 public weiRaised;
uint256 private weiRaised_;

/**
* Event for token purchase logging
Expand All @@ -52,17 +49,20 @@ contract Crowdsale {

/**
* @param _rate Number of token units a buyer gets per wei
* @dev The rate is the conversion between wei and the smallest and indivisible
* token unit. So, if you are using a rate of 1 with a ERC20Detailed token
* with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK.
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
constructor(uint256 _rate, address _wallet, ERC20 _token) public {
constructor(uint256 _rate, address _wallet, IERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));

rate = _rate;
wallet = _wallet;
token = _token;
rate_ = _rate;
wallet_ = _wallet;
token_ = _token;
}

// -----------------------------------------
Expand All @@ -76,6 +76,34 @@ contract Crowdsale {
buyTokens(msg.sender);
}

/**
* @return the token being sold.
*/
function token() public view returns(IERC20) {
return token_;
}

/**
* @return the address where funds are collected.
*/
function wallet() public view returns(address) {
return wallet_;
}

/**
* @return the number of token units a buyer gets per wei.
*/
function rate() public view returns(uint256) {
return rate_;
}

/**
* @return the mount of wei raised.
*/
function weiRaised() public view returns (uint256) {
return weiRaised_;
}

/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
Expand All @@ -89,7 +117,7 @@ contract Crowdsale {
uint256 tokens = _getTokenAmount(weiAmount);

// update state
weiRaised = weiRaised.add(weiAmount);
weiRaised_ = weiRaised_.add(weiAmount);

_processPurchase(_beneficiary, tokens);
emit TokensPurchased(
Expand All @@ -113,7 +141,7 @@ contract Crowdsale {
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations.
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
* super._preValidatePurchase(_beneficiary, _weiAmount);
* require(weiRaised.add(_weiAmount) <= cap);
* require(weiRaised().add(_weiAmount) <= cap);
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
Expand Down Expand Up @@ -152,7 +180,7 @@ contract Crowdsale {
)
internal
{
token.safeTransfer(_beneficiary, _tokenAmount);
token_.safeTransfer(_beneficiary, _tokenAmount);
}

/**
Expand Down Expand Up @@ -191,13 +219,13 @@ contract Crowdsale {
function _getTokenAmount(uint256 _weiAmount)
internal view returns (uint256)
{
return _weiAmount.mul(rate);
return _weiAmount.mul(rate_);
}

/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
wallet_.transfer(msg.value);
}
}
19 changes: 13 additions & 6 deletions contracts/crowdsale/distribution/FinalizableCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,37 @@ import "../validation/TimedCrowdsale.sol";
contract FinalizableCrowdsale is Ownable, TimedCrowdsale {
using SafeMath for uint256;

bool public isFinalized = false;
bool private finalized_ = false;

event CrowdsaleFinalized();

/**
* @return true if the crowdsale is finalized, false otherwise.
*/
function finalized() public view returns(bool) {
return finalized_;
}

/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public onlyOwner {
require(!isFinalized);
require(!finalized_);
require(hasClosed());

finalization();
_finalization();
emit CrowdsaleFinalized();

isFinalized = true;
finalized_ = true;
}

/**
* @dev Can be overridden to add finalization logic. The overriding function
* should call super.finalization() to ensure the chain of finalization is
* should call super._finalization() to ensure the chain of finalization is
* executed entirely.
*/
function finalization() internal {
function _finalization() internal {
}

}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.