Commit 418b6f7c by Francisco Giordano

convert IncreasingPriceCrowdsale to initializers

parent ed200a02
pragma solidity ^0.4.24; pragma solidity ^0.4.24;
import "../../Initializable.sol";
import "../validation/TimedCrowdsale.sol"; import "../validation/TimedCrowdsale.sol";
import "../../math/SafeMath.sol"; import "../../math/SafeMath.sol";
...@@ -10,18 +11,21 @@ import "../../math/SafeMath.sol"; ...@@ -10,18 +11,21 @@ import "../../math/SafeMath.sol";
* Note that what should be provided to the constructor is the initial and final _rates_, that is, * Note that what should be provided to the constructor is the initial and final _rates_, that is,
* the amount of tokens per wei contributed. Thus, the initial rate must be greater than the final rate. * the amount of tokens per wei contributed. Thus, the initial rate must be greater than the final rate.
*/ */
contract IncreasingPriceCrowdsale is TimedCrowdsale { contract IncreasingPriceCrowdsale is Initializable, TimedCrowdsale {
using SafeMath for uint256; using SafeMath for uint256;
uint256 private _initialRate; uint256 private _initialRate;
uint256 private _finalRate; uint256 private _finalRate;
constructor(uint256 initialRate, uint256 finalRate) public {
}
/** /**
* @dev Constructor, takes initial and final rates of tokens received per wei contributed. * @dev Constructor, takes initial and final rates of tokens received per wei contributed.
* @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 { function initialize(uint256 initialRate, uint256 finalRate) public initializer {
require(finalRate > 0); require(finalRate > 0);
require(initialRate >= finalRate); require(initialRate >= finalRate);
_initialRate = initialRate; _initialRate = initialRate;
......
pragma solidity ^0.4.24; pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../crowdsale/price/IncreasingPriceCrowdsale.sol"; import "../crowdsale/price/IncreasingPriceCrowdsale.sol";
import "../math/SafeMath.sol"; import "../math/SafeMath.sol";
contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale { contract IncreasingPriceCrowdsaleImpl is Initializable, IncreasingPriceCrowdsale {
constructor ( constructor (
uint256 openingTime, uint256 openingTime,
...@@ -19,6 +20,9 @@ contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale { ...@@ -19,6 +20,9 @@ contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
TimedCrowdsale(openingTime, closingTime) TimedCrowdsale(openingTime, closingTime)
IncreasingPriceCrowdsale(initialRate, finalRate) IncreasingPriceCrowdsale(initialRate, finalRate)
{ {
Crowdsale.initialize(initialRate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime);
IncreasingPriceCrowdsale.initialize(initialRate, finalRate);
} }
} }
...@@ -11,7 +11,7 @@ require('chai') ...@@ -11,7 +11,7 @@ require('chai')
.should(); .should();
const IncreasingPriceCrowdsale = artifacts.require('IncreasingPriceCrowdsaleImpl'); const IncreasingPriceCrowdsale = artifacts.require('IncreasingPriceCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken'); const SimpleToken = artifacts.require('SimpleTokenMock');
contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) { contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) {
const value = ether(1); const value = ether(1);
......
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