convert SplitPayment to initializers

This commit is contained in:
Francisco Giordano
2018-09-26 17:51:33 -03:00
parent 8d28bd445a
commit 884d5e0132
3 changed files with 14 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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');