@@ -11,12 +11,12 @@ import "../math/SafeMath.sol";
1111contract SplitPayment {
1212 using SafeMath for uint256 ;
1313
14- uint256 public totalShares = 0 ;
15- uint256 public totalReleased = 0 ;
14+ uint256 private totalShares_ = 0 ;
15+ uint256 private totalReleased_ = 0 ;
1616
17- mapping (address => uint256 ) public shares ;
18- mapping (address => uint256 ) public released ;
19- address [] public payees ;
17+ mapping (address => uint256 ) private shares_ ;
18+ mapping (address => uint256 ) private released_ ;
19+ address [] private payees_ ;
2020
2121 /**
2222 * @dev Constructor
@@ -35,25 +35,60 @@ contract SplitPayment {
3535 */
3636 function () external payable {}
3737
38+ /**
39+ * @return the total shares of the contract.
40+ */
41+ function totalShares () public view returns (uint256 ) {
42+ return totalShares_;
43+ }
44+
45+ /**
46+ * @return the total amount already released.
47+ */
48+ function totalReleased () public view returns (uint256 ) {
49+ return totalReleased_;
50+ }
51+
52+ /**
53+ * @return the shares of an account.
54+ */
55+ function shares (address _account ) public view returns (uint256 ) {
56+ return shares_[_account];
57+ }
58+
59+ /**
60+ * @return the amount already released to an account.
61+ */
62+ function released (address _account ) public view returns (uint256 ) {
63+ return released_[_account];
64+ }
65+
66+ /**
67+ * @return the address of a payee.
68+ */
69+ function payee (uint256 index ) public view returns (address ) {
70+ return payees_[index];
71+ }
72+
3873 /**
3974 * @dev Release one of the payee's proportional payment.
4075 * @param _payee Whose payments will be released.
4176 */
4277 function release (address _payee ) public {
43- require (shares [_payee] > 0 );
78+ require (shares_ [_payee] > 0 );
4479
45- uint256 totalReceived = address (this ).balance.add (totalReleased );
80+ uint256 totalReceived = address (this ).balance.add (totalReleased_ );
4681 uint256 payment = totalReceived.mul (
47- shares [_payee]).div (
48- totalShares ).sub (
49- released [_payee]
82+ shares_ [_payee]).div (
83+ totalShares_ ).sub (
84+ released_ [_payee]
5085 );
5186
5287 require (payment != 0 );
5388 assert (address (this ).balance >= payment);
5489
55- released [_payee] = released [_payee].add (payment);
56- totalReleased = totalReleased .add (payment);
90+ released_ [_payee] = released_ [_payee].add (payment);
91+ totalReleased_ = totalReleased_ .add (payment);
5792
5893 _payee.transfer (payment);
5994 }
@@ -66,10 +101,10 @@ contract SplitPayment {
66101 function _addPayee (address _payee , uint256 _shares ) internal {
67102 require (_payee != address (0 ));
68103 require (_shares > 0 );
69- require (shares [_payee] == 0 );
104+ require (shares_ [_payee] == 0 );
70105
71- payees .push (_payee);
72- shares [_payee] = _shares;
73- totalShares = totalShares .add (_shares);
106+ payees_ .push (_payee);
107+ shares_ [_payee] = _shares;
108+ totalShares_ = totalShares_ .add (_shares);
74109 }
75110}
0 commit comments