convert IncreasingPriceCrowdsale to initializers

This commit is contained in:
Francisco Giordano
2018-09-28 16:01:57 -03:00
parent ed200a0219
commit 418b6f7cb3
3 changed files with 12 additions and 4 deletions

View File

@ -1,5 +1,6 @@
pragma solidity ^0.4.24;
import "../../Initializable.sol";
import "../validation/TimedCrowdsale.sol";
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,
* 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;
uint256 private _initialRate;
uint256 private _finalRate;
constructor(uint256 initialRate, uint256 finalRate) public {
}
/**
* @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 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(initialRate >= finalRate);
_initialRate = initialRate;

View File

@ -1,10 +1,11 @@
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../crowdsale/price/IncreasingPriceCrowdsale.sol";
import "../math/SafeMath.sol";
contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
contract IncreasingPriceCrowdsaleImpl is Initializable, IncreasingPriceCrowdsale {
constructor (
uint256 openingTime,
@ -19,6 +20,9 @@ contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
TimedCrowdsale(openingTime, closingTime)
IncreasingPriceCrowdsale(initialRate, finalRate)
{
Crowdsale.initialize(initialRate, wallet, token);
TimedCrowdsale.initialize(openingTime, closingTime);
IncreasingPriceCrowdsale.initialize(initialRate, finalRate);
}
}

View File

@ -11,7 +11,7 @@ require('chai')
.should();
const IncreasingPriceCrowdsale = artifacts.require('IncreasingPriceCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');
const SimpleToken = artifacts.require('SimpleTokenMock');
contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) {
const value = ether(1);