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