Unverified Commit d9fdffe8 by Nicolás Venturo Committed by GitHub

Internal crowdsales (#1439)

* Made some internal crowdsale methods internal.

* Made all Crowdsale constructors internal.
parent 315f426f
......@@ -57,7 +57,7 @@ contract Crowdsale {
* @param wallet Address where collected funds will be forwarded to
* @param token Address of the token being sold
*/
constructor(uint256 rate, address wallet, IERC20 token) public {
constructor(uint256 rate, address wallet, IERC20 token) internal {
require(rate > 0);
require(wallet != address(0));
require(token != address(0));
......@@ -152,6 +152,7 @@ contract Crowdsale {
uint256 weiAmount
)
internal
view
{
require(beneficiary != address(0));
require(weiAmount != 0);
......@@ -167,6 +168,7 @@ contract Crowdsale {
uint256 weiAmount
)
internal
view
{
// optional override
}
......
......@@ -15,7 +15,7 @@ contract FinalizableCrowdsale is TimedCrowdsale {
event CrowdsaleFinalized();
constructor() public {
constructor() internal {
_finalized = false;
}
......
......@@ -13,6 +13,8 @@ contract PostDeliveryCrowdsale is TimedCrowdsale {
mapping(address => uint256) private _balances;
constructor() internal {}
/**
* @dev Withdraw tokens only after crowdsale ends.
* @param beneficiary Whose tokens will be withdrawn.
......
......@@ -22,7 +22,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
* @dev Constructor, creates RefundEscrow.
* @param goal Funding goal
*/
constructor(uint256 goal) public {
constructor(uint256 goal) internal {
require(goal > 0);
_escrow = new RefundEscrow(wallet());
_goal = goal;
......
......@@ -19,7 +19,7 @@ contract AllowanceCrowdsale is Crowdsale {
* @dev Constructor, takes token wallet address.
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/
constructor(address tokenWallet) public {
constructor(address tokenWallet) internal {
require(tokenWallet != address(0));
_tokenWallet = tokenWallet;
}
......
......@@ -9,6 +9,7 @@ import "../../token/ERC20/ERC20Mintable.sol";
* Token ownership should be transferred to MintedCrowdsale for minting.
*/
contract MintedCrowdsale is Crowdsale {
constructor() internal {}
/**
* @dev Overrides delivery by minting tokens upon purchase.
......
......@@ -20,7 +20,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
* @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
* @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
*/
constructor(uint256 initialRate, uint256 finalRate) public {
constructor(uint256 initialRate, uint256 finalRate) internal {
require(finalRate > 0);
require(initialRate >= finalRate);
_initialRate = initialRate;
......
......@@ -16,7 +16,7 @@ contract CappedCrowdsale is Crowdsale {
* @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
* @param cap Max amount of wei to be contributed
*/
constructor(uint256 cap) public {
constructor(uint256 cap) internal {
require(cap > 0);
_cap = cap;
}
......@@ -46,6 +46,7 @@ contract CappedCrowdsale is Crowdsale {
uint256 weiAmount
)
internal
view
{
super._preValidatePurchase(beneficiary, weiAmount);
require(weiRaised().add(weiAmount) <= _cap);
......
......@@ -14,6 +14,8 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
mapping(address => uint256) private _contributions;
mapping(address => uint256) private _caps;
constructor() internal {}
/**
* @dev Sets a specific beneficiary's maximum contribution.
* @param beneficiary Address to be capped
......@@ -53,6 +55,7 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
uint256 weiAmount
)
internal
view
{
super._preValidatePurchase(beneficiary, weiAmount);
require(
......
......@@ -26,7 +26,7 @@ contract TimedCrowdsale is Crowdsale {
* @param openingTime Crowdsale opening time
* @param closingTime Crowdsale closing time
*/
constructor(uint256 openingTime, uint256 closingTime) public {
constructor(uint256 openingTime, uint256 closingTime) internal {
// solium-disable-next-line security/no-block-members
require(openingTime >= block.timestamp);
require(closingTime >= openingTime);
......@@ -77,6 +77,7 @@ contract TimedCrowdsale is Crowdsale {
)
internal
onlyWhileOpen
view
{
super._preValidatePurchase(beneficiary, weiAmount);
}
......
pragma solidity ^0.4.24;
import "../crowdsale/Crowdsale.sol";
contract CrowdsaleMock is Crowdsale {
constructor(uint256 rate, address wallet, IERC20 token) public
Crowdsale(rate, wallet, token) {
}
}
......@@ -10,7 +10,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
const Crowdsale = artifacts.require('Crowdsale');
const Crowdsale = artifacts.require('CrowdsaleMock');
const SimpleToken = artifacts.require('SimpleToken');
contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment