From 884d5e01329a94572fcf6d521ee81adfc4aeae19 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 26 Sep 2018 17:51:33 -0300 Subject: [PATCH] convert SplitPayment to initializers --- contracts/mocks/SplitPaymentMock.sol | 10 ++++++++++ contracts/payment/SplitPayment.sol | 5 +++-- test/payment/SplitPayment.test.js | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 contracts/mocks/SplitPaymentMock.sol diff --git a/contracts/mocks/SplitPaymentMock.sol b/contracts/mocks/SplitPaymentMock.sol new file mode 100644 index 000000000..3b68a7eb4 --- /dev/null +++ b/contracts/mocks/SplitPaymentMock.sol @@ -0,0 +1,10 @@ +pragma solidity ^0.4.24; + +import "../Initializable.sol"; +import "../payment/SplitPayment.sol"; + +contract SplitPaymentMock is Initializable, SplitPayment { + constructor(address[] payees, uint256[] shares) public { + SplitPayment.initialize(payees, shares); + } +} diff --git a/contracts/payment/SplitPayment.sol b/contracts/payment/SplitPayment.sol index 19df9b706..64344846c 100644 --- a/contracts/payment/SplitPayment.sol +++ b/contracts/payment/SplitPayment.sol @@ -1,5 +1,6 @@ pragma solidity ^0.4.24; +import "../Initializable.sol"; import "../math/SafeMath.sol"; @@ -8,7 +9,7 @@ import "../math/SafeMath.sol"; * @dev This contract can be used when payments need to be received by a group * of people and split proportionately to some number of shares they own. */ -contract SplitPayment { +contract SplitPayment is Initializable { using SafeMath for uint256; uint256 private _totalShares = 0; @@ -21,7 +22,7 @@ contract SplitPayment { /** * @dev Constructor */ - constructor(address[] payees, uint256[] shares) public payable { + function initialize(address[] payees, uint256[] shares) public payable initializer { require(payees.length == shares.length); require(payees.length > 0); diff --git a/test/payment/SplitPayment.test.js b/test/payment/SplitPayment.test.js index 788296016..e5a5f1354 100644 --- a/test/payment/SplitPayment.test.js +++ b/test/payment/SplitPayment.test.js @@ -8,7 +8,7 @@ require('chai') const { expectThrow } = require('../helpers/expectThrow'); const { EVMRevert } = require('../helpers/EVMRevert.js'); -const SplitPayment = artifacts.require('SplitPayment'); +const SplitPayment = artifacts.require('SplitPaymentMock'); contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) { const amount = web3.toWei(1.0, 'ether');