From c4487ba836029ab6523544a65b5caf56b13588e2 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Thu, 27 Sep 2018 19:24:02 -0300 Subject: [PATCH] convert CappedCrowdsale --- contracts/crowdsale/validation/CappedCrowdsale.sol | 8 ++++++-- contracts/mocks/CappedCrowdsaleImpl.sol | 5 ++++- test/crowdsale/CappedCrowdsale.test.js | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 67a7d7c92..2d24077a6 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -1,5 +1,6 @@ pragma solidity ^0.4.24; +import "../../Initializable.sol"; import "../../math/SafeMath.sol"; import "../Crowdsale.sol"; @@ -8,16 +9,19 @@ import "../Crowdsale.sol"; * @title CappedCrowdsale * @dev Crowdsale with a limit for total contributions. */ -contract CappedCrowdsale is Crowdsale { +contract CappedCrowdsale is Initializable, Crowdsale { using SafeMath for uint256; uint256 private _cap; + constructor(uint256 cap) public { + } + /** * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. * @param cap Max amount of wei to be contributed */ - constructor(uint256 cap) public { + function initialize(uint256 cap) public initializer { require(cap > 0); _cap = cap; } diff --git a/contracts/mocks/CappedCrowdsaleImpl.sol b/contracts/mocks/CappedCrowdsaleImpl.sol index e92cec204..59924f538 100644 --- a/contracts/mocks/CappedCrowdsaleImpl.sol +++ b/contracts/mocks/CappedCrowdsaleImpl.sol @@ -1,10 +1,11 @@ pragma solidity ^0.4.24; +import "../Initializable.sol"; import "../token/ERC20/IERC20.sol"; import "../crowdsale/validation/CappedCrowdsale.sol"; -contract CappedCrowdsaleImpl is CappedCrowdsale { +contract CappedCrowdsaleImpl is Initializable, Crowdsale, CappedCrowdsale { constructor ( uint256 rate, @@ -16,6 +17,8 @@ contract CappedCrowdsaleImpl is CappedCrowdsale { Crowdsale(rate, wallet, token) CappedCrowdsale(cap) { + Crowdsale.initialize(rate, wallet, token); + CappedCrowdsale.initialize(cap); } } diff --git a/test/crowdsale/CappedCrowdsale.test.js b/test/crowdsale/CappedCrowdsale.test.js index 94ed0aedd..5eb8ebce8 100644 --- a/test/crowdsale/CappedCrowdsale.test.js +++ b/test/crowdsale/CappedCrowdsale.test.js @@ -9,7 +9,7 @@ require('chai') .should(); const CappedCrowdsale = artifacts.require('CappedCrowdsaleImpl'); -const SimpleToken = artifacts.require('SimpleToken'); +const SimpleToken = artifacts.require('SimpleTokenMock'); contract('CappedCrowdsale', function ([_, wallet]) { const rate = new BigNumber(1);