Commit e2e05294 by Francisco Giordano

convert RefundEscrow to initializers

parent 3130a3f3
......@@ -26,7 +26,13 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
*/
constructor(uint256 goal) public {
require(goal > 0);
_escrow = new RefundEscrow(wallet());
// conditional added to make initializer idempotent in case of diamond inheritance
if (address(_escrow) == address(0)) {
_escrow = new RefundEscrow();
_escrow.initialize(wallet());
}
_goal = goal;
}
......
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "../payment/RefundEscrow.sol";
contract RefundEscrowMock is Initializable, RefundEscrow {
constructor(address beneficiary) public {
RefundEscrow.initialize(beneficiary);
}
}
pragma solidity ^0.4.24;
import "../Initializable.sol";
import "./ConditionalEscrow.sol";
import "../ownership/Secondary.sol";
......@@ -10,7 +11,7 @@ import "../ownership/Secondary.sol";
* The primary account may close the deposit period, and allow for either withdrawal
* by the beneficiary, or refunds to the depositors.
*/
contract RefundEscrow is Secondary, ConditionalEscrow {
contract RefundEscrow is Initializable, Secondary, ConditionalEscrow {
enum State { Active, Refunding, Closed }
event Closed();
......@@ -23,7 +24,10 @@ contract RefundEscrow is Secondary, ConditionalEscrow {
* @dev Constructor.
* @param beneficiary The beneficiary of the deposits.
*/
constructor(address beneficiary) public {
function initialize(address beneficiary) public initializer {
Secondary.initialize();
ConditionalEscrow.initialize();
require(beneficiary != address(0));
_beneficiary = beneficiary;
_state = State.Active;
......
......@@ -9,7 +9,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
const RefundEscrow = artifacts.require('RefundEscrow');
const RefundEscrow = artifacts.require('RefundEscrowMock');
contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) {
const amount = web3.toWei(54.0, 'ether');
......
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