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 {
* @param goal Funding goal
*/
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);
// conditional added to make initializer idempotent in case of diamond inheritance
......
......@@ -22,6 +22,11 @@ contract AllowanceCrowdsale is Initializable, Crowdsale {
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/
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));
_tokenWallet = tokenWallet;
}
......
......@@ -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
*/
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(initialRate >= finalRate);
_initialRate = initialRate;
......
......@@ -19,6 +19,11 @@ contract CappedCrowdsale is Initializable, Crowdsale {
* @param cap Max amount of wei to be contributed
*/
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);
_cap = cap;
}
......
......@@ -17,6 +17,11 @@ contract IndividuallyCappedCrowdsale is Initializable, Crowdsale, CapperRole {
mapping(address => uint256) private _caps;
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);
}
......
......@@ -29,6 +29,11 @@ contract TimedCrowdsale is Initializable, Crowdsale {
* @param closingTime Crowdsale closing time
*/
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
require(openingTime >= block.timestamp);
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