From 10642d14eac32a6bb7e53abcce1117ba904568ee Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 25 Sep 2018 19:33:58 -0300 Subject: [PATCH] convert Escrow to initializers --- contracts/mocks/EscrowMock.sol | 10 ++++++++++ contracts/payment/Escrow.sol | 7 ++++++- test/payment/Escrow.test.js | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 contracts/mocks/EscrowMock.sol diff --git a/contracts/mocks/EscrowMock.sol b/contracts/mocks/EscrowMock.sol new file mode 100644 index 000000000..7eaa6295c --- /dev/null +++ b/contracts/mocks/EscrowMock.sol @@ -0,0 +1,10 @@ +pragma solidity ^0.4.24; + +import "../Initializable.sol"; +import "../payment/Escrow.sol"; + +contract EscrowMock is Initializable, Escrow { + constructor() public { + Escrow.initialize(); + } +} diff --git a/contracts/payment/Escrow.sol b/contracts/payment/Escrow.sol index 2e6c5565a..d55c31c1c 100644 --- a/contracts/payment/Escrow.sol +++ b/contracts/payment/Escrow.sol @@ -1,5 +1,6 @@ pragma solidity ^0.4.24; +import "../Initializable.sol"; import "../math/SafeMath.sol"; import "../ownership/Secondary.sol"; @@ -11,7 +12,7 @@ import "../ownership/Secondary.sol"; * should be its primary, and provide public methods redirecting to the escrow's * deposit and withdraw. */ -contract Escrow is Secondary { +contract Escrow is Initializable, Secondary { using SafeMath for uint256; event Deposited(address indexed payee, uint256 weiAmount); @@ -19,6 +20,10 @@ contract Escrow is Secondary { mapping(address => uint256) private _deposits; + function initialize() public initializer { + Secondary.initialize(); + } + function depositsOf(address payee) public view returns (uint256) { return _deposits[payee]; } diff --git a/test/payment/Escrow.test.js b/test/payment/Escrow.test.js index 6af510d65..e5c64fffd 100644 --- a/test/payment/Escrow.test.js +++ b/test/payment/Escrow.test.js @@ -1,6 +1,6 @@ const { shouldBehaveLikeEscrow } = require('./Escrow.behavior'); -const Escrow = artifacts.require('Escrow'); +const Escrow = artifacts.require('EscrowMock'); contract('Escrow', function ([_, primary, ...otherAccounts]) { beforeEach(async function () {