Commit 175e2c72 by Francisco Giordano

convert Crowdsale to initializers

parent a0a3187b
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../token/ERC20/IERC20.sol";
import "../math/SafeMath.sol";
import "../token/ERC20/SafeERC20.sol";
......@@ -17,7 +18,7 @@ import "../token/ERC20/SafeERC20.sol";
* the methods to add functionality. Consider using 'super' where appropriate to concatenate
* behavior.
*/
contract Crowdsale {
contract Crowdsale is Initializable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
......@@ -50,6 +51,9 @@ contract Crowdsale {
uint256 amount
);
constructor(uint256 rate, address wallet, IERC20 token) public {
}
/**
* @param rate Number of token units a buyer gets per wei
* @dev The rate is the conversion between wei and the smallest and indivisible
......@@ -58,7 +62,7 @@ contract Crowdsale {
* @param wallet Address where collected funds will be forwarded to
* @param token Address of the token being sold
*/
constructor(uint256 rate, address wallet, IERC20 token) public {
function initialize(uint256 rate, address wallet, IERC20 token) public initializer {
require(rate > 0);
require(wallet != address(0));
require(token != address(0));
......
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../crowdsale/Crowdsale.sol";
contract CrowdsaleMock is Initializable, Crowdsale {
constructor(uint256 rate, address wallet, IERC20 token) public Crowdsale(rate, wallet, token) {
Crowdsale.initialize(rate, wallet, token);
}
}
......@@ -8,8 +8,8 @@ const should = require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
const Crowdsale = artifacts.require('Crowdsale');
const SimpleToken = artifacts.require('SimpleToken');
const Crowdsale = artifacts.require('CrowdsaleMock');
const SimpleToken = artifacts.require('SimpleTokenMock');
contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
const rate = new BigNumber(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