convert AllowanceCrowdsale to initializers

This commit is contained in:
Francisco Giordano
2018-09-27 18:57:59 -03:00
parent 22f8660c8e
commit 6247a7bf7c
3 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,6 @@
pragma solidity ^0.4.24;
import "../../Initializable.sol";
import "../Crowdsale.sol";
import "../../token/ERC20/IERC20.sol";
import "../../token/ERC20/SafeERC20.sol";
@ -10,17 +11,20 @@ import "../../math/SafeMath.sol";
* @title AllowanceCrowdsale
* @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale.
*/
contract AllowanceCrowdsale is Crowdsale {
contract AllowanceCrowdsale is Initializable, Crowdsale {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address private _tokenWallet;
constructor(address tokenWallet) public {
}
/**
* @dev Constructor, takes token wallet address.
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/
constructor(address tokenWallet) public {
function initialize(address tokenWallet) public initializer {
require(tokenWallet != address(0));
_tokenWallet = tokenWallet;
}

View File

@ -1,10 +1,11 @@
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../token/ERC20/IERC20.sol";
import "../crowdsale/emission/AllowanceCrowdsale.sol";
contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
contract AllowanceCrowdsaleImpl is Initializable, Crowdsale, AllowanceCrowdsale {
constructor (
uint256 rate,
@ -16,6 +17,8 @@ contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
Crowdsale(rate, wallet, token)
AllowanceCrowdsale(tokenWallet)
{
Crowdsale.initialize(rate, wallet, token);
AllowanceCrowdsale.initialize(tokenWallet);
}
}

View File

@ -9,7 +9,7 @@ const should = require('chai')
.should();
const AllowanceCrowdsale = artifacts.require('AllowanceCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');
const SimpleToken = artifacts.require('SimpleTokenMock');
contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenWallet]) {
const rate = new BigNumber(1);