Commit 6fe9b340 by Nicolás Venturo

Added assertions to leaf initializers of (some) pseudo-abstract contracts.

parent b25e8b91
...@@ -26,6 +26,11 @@ contract RefundableCrowdsale is Initializable, FinalizableCrowdsale { ...@@ -26,6 +26,11 @@ contract RefundableCrowdsale is Initializable, FinalizableCrowdsale {
* @param goal Funding goal * @param goal Funding goal
*/ */
function initialize(uint256 goal) public initializer { function initialize(uint256 goal) public initializer {
// Make sure TimedCrowdsale.initialize (which FinalizableCrowdsale depends on) has been
// called before this initializer is executed
require(openingTime() > 0);
require(closingTime() > 0);
require(goal > 0); require(goal > 0);
// conditional added to make initializer idempotent in case of diamond inheritance // conditional added to make initializer idempotent in case of diamond inheritance
......
...@@ -22,6 +22,11 @@ contract AllowanceCrowdsale is Initializable, Crowdsale { ...@@ -22,6 +22,11 @@ contract AllowanceCrowdsale is Initializable, Crowdsale {
* @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
*/ */
function initialize(address tokenWallet) public initializer { function initialize(address tokenWallet) public initializer {
// Make sure Crowdsale.initialize has been called before this initializer is executed
assert(rate() > 0);
assert(wallet() != address(0));
assert(token() != address(0));
require(tokenWallet != address(0)); require(tokenWallet != address(0));
_tokenWallet = tokenWallet; _tokenWallet = tokenWallet;
} }
......
...@@ -23,6 +23,10 @@ contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale { ...@@ -23,6 +23,10 @@ contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale {
* @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
*/ */
function initialize(uint256 initialRate, uint256 finalRate) public initializer { function initialize(uint256 initialRate, uint256 finalRate) public initializer {
// Make sure TimedCrowdsale.initialize has been called before this initializer is executed
require(openingTime() > 0);
require(closingTime() > 0);
require(finalRate > 0); require(finalRate > 0);
require(initialRate >= finalRate); require(initialRate >= finalRate);
_initialRate = initialRate; _initialRate = initialRate;
......
...@@ -19,6 +19,11 @@ contract CappedCrowdsale is Initializable, Crowdsale { ...@@ -19,6 +19,11 @@ contract CappedCrowdsale is Initializable, Crowdsale {
* @param cap Max amount of wei to be contributed * @param cap Max amount of wei to be contributed
*/ */
function initialize(uint256 cap) public initializer { function initialize(uint256 cap) public initializer {
// Make sure Crowdsale.initialize has been called before this initializer is executed
assert(rate() > 0);
assert(wallet() != address(0));
assert(token() != address(0));
require(cap > 0); require(cap > 0);
_cap = cap; _cap = cap;
} }
......
...@@ -17,6 +17,11 @@ contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole { ...@@ -17,6 +17,11 @@ contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole {
mapping(address => uint256) private _caps; mapping(address => uint256) private _caps;
function initialize(address sender) public initializer { function initialize(address sender) public initializer {
// Make sure Crowdsale.initialize has been called before this initializer is executed
assert(rate() > 0);
assert(wallet() != address(0));
assert(token() != address(0));
CapperRole.initialize(sender); CapperRole.initialize(sender);
} }
......
...@@ -29,6 +29,11 @@ contract TimedCrowdsale is Initializable, Crowdsale { ...@@ -29,6 +29,11 @@ contract TimedCrowdsale is Initializable, Crowdsale {
* @param closingTime Crowdsale closing time * @param closingTime Crowdsale closing time
*/ */
function initialize(uint256 openingTime, uint256 closingTime) public initializer { function initialize(uint256 openingTime, uint256 closingTime) public initializer {
// Make sure Crowdsale.initialize has been called before this initializer is executed
assert(rate() > 0);
assert(wallet() != address(0));
assert(token() != address(0));
// 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);
......
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