Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
c8c2309
Role tests (#1228)
nventuro Aug 22, 2018
ed04195
Removed RBAC tokens (#1229)
nventuro Aug 22, 2018
5b7ec56
Roles can now be transfered. (#1235)
nventuro Aug 28, 2018
0530e1e
True Ownership (#1247)
nventuro Aug 30, 2018
128c4c0
Improve encapsulation on ERC165
Sep 3, 2018
0d8a5e4
Improve encapsulation on ERC20
Sep 3, 2018
1c365fe
Improve encapsulation on ERC721
Sep 3, 2018
9ebdae6
Add tests, use standard getters
Sep 3, 2018
963a00b
fix tests
Sep 3, 2018
4d8db8d
Fix lint
Sep 3, 2018
dc7b21e
Merge branch 'master' into refactor/1174/private-state-vars-erc
Sep 4, 2018
d8e7c25
MintableToken using Roles (#1236)
nventuro Sep 4, 2018
0b0d6c6
move interface ids to implementation contracts
frangio Sep 4, 2018
68094d1
Do not prefix getters
Sep 5, 2018
2ea79e9
Merge branch 'master' into refactor/1174/private-state-vars-erc
Sep 5, 2018
5fc3742
Improve encapsulation on Pausable
Sep 3, 2018
172b720
add the underscore
Sep 3, 2018
86bbab3
Improve encapsulation on ownership
Sep 3, 2018
faed52d
fix rebase
Sep 3, 2018
21ae177
fix ownership
Sep 3, 2018
917a019
Improve encapsulation on payments
Sep 3, 2018
478d974
Add missing tests
Sep 4, 2018
0fecbac
add missing test
Sep 4, 2018
9449572
Do not prefix getters
Sep 5, 2018
1856f07
Fix tests.
Sep 5, 2018
f61acdc
Improve encapsulation on Crowdsales
Sep 3, 2018
44d113a
add missing tests
Sep 3, 2018
0257670
remove only
Sep 3, 2018
5a476d1
Do not prefix getters
Sep 5, 2018
85a0fc3
Update modifiers to call public view functions.
Sep 5, 2018
c420563
Improve encapsulation on Pausable
Sep 3, 2018
fcd369a
add the underscore
Sep 3, 2018
1eb1340
Improve encapsulation on ownership
Sep 3, 2018
211e2aa
fix rebase
Sep 3, 2018
411058f
fix ownership
Sep 3, 2018
0be5129
Improve encapsulation on payments
Sep 3, 2018
1c1399c
Add missing tests
Sep 4, 2018
cbe4f36
add missing test
Sep 4, 2018
869b364
Do not prefix getters
Sep 5, 2018
526ff31
Fix tests.
Sep 5, 2018
b4d64d4
Improve encapsulation on Crowdsales
Sep 3, 2018
2e2d634
add missing tests
Sep 3, 2018
4be20f7
remove only
Sep 3, 2018
8559477
Do not prefix getters
Sep 5, 2018
edf8ea5
Improve encapsulation on BreakInvariantBounty
Sep 3, 2018
b64cdef
Make researchers private
Sep 3, 2018
148ef64
Do not prefix getters
Sep 5, 2018
4080385
tmp
Sep 5, 2018
24761a5
remove isMinter
Sep 5, 2018
c14d597
fix is owner call
Sep 5, 2018
ba7fa16
fix isOpen
Sep 5, 2018
776d47a
Merge branch 'master' into feature/1179/modifiers-call-functions
Sep 6, 2018
7a37725
Fix merge
Sep 6, 2018
cab8bdb
Merge branch 'master' into refactor/underscores-final-final
Sep 6, 2018
093a9d5
tmp
Sep 6, 2018
52352ce
Improve encapsulation on TimedCrowdsale
Sep 6, 2018
7d10c0e
tmp
Sep 6, 2018
63b93cc
Add missing parentheses
Sep 6, 2018
4403e49
Merge branch 'refactor/1174/private-state-vars-timed-crowdsale' into …
Sep 6, 2018
093bcd3
Use prefix underscore for state variables and no underscore for param…
Sep 6, 2018
a14963b
Improved Roles API. (#1280)
nventuro Sep 6, 2018
4d4a004
Added PauserRole. (#1283)
nventuro Sep 6, 2018
b6bddb2
Merge branch 'master' into refactor/1174/private-state-vars-timed-cro…
frangio Sep 6, 2018
369b8d6
remove duplicate function definition
frangio Sep 6, 2018
b2f350d
Remove Claimable, DelayedClaimable, Heritable (#1274)
frangio Sep 5, 2018
c529524
Merge remote-tracking branch 'upstream/master' into rbac-migration
frangio Sep 6, 2018
145962d
Merge branch 'refactor/1174/private-state-vars-timed-crowdsale' into …
Sep 6, 2018
cb836c3
Merge branch 'master' into refactor/underscores-final-final
Sep 6, 2018
bf4a211
Role behavior tests (#1285)
nventuro Sep 6, 2018
199e156
Migrate Ownable to Roles (#1287)
nventuro Sep 6, 2018
d4dea3c
Remove RBAC, SignatureBouncer refactor (#1289)
nventuro Sep 6, 2018
e9cc437
feat: implement ERC721Mintable and ERC721Burnable (#1276)
shrugs Sep 6, 2018
075334a
Merge branch 'master' into refactor/underscores-final-final
Sep 7, 2018
abd946d
Merge branch 'master' into refactor/underscores-final-final
Sep 7, 2018
436c89f
Merge branch 'master' into rbac-migration
Sep 7, 2018
c81e75d
Fix the merge with the privatization branch
Sep 7, 2018
a49efc0
Merge branch 'master' into refactor/underscores-final-final
Sep 7, 2018
be372f2
Merge branch 'rbac-migration' into refactor/underscores-final-final
Sep 7, 2018
1002c20
fix lint
Sep 7, 2018
58524e3
Remove underscore
Sep 7, 2018
d4a1178
Merge branch 'master' of github.com:OpenZeppelin/openzeppelin-solidit…
frangio Sep 7, 2018
2458d72
Delete CapperRole.test.js
nventuro Sep 7, 2018
58e1050
fix increaseApproval
frangio Sep 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve encapsulation on payments
  • Loading branch information
Leo Arias committed Sep 5, 2018
commit 917a0197586e9bb6d3c0b628b22659a1a261ca20
2 changes: 1 addition & 1 deletion contracts/ownership/Heritable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ contract Heritable is Ownable {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= timeOfDeath_ + heartbeatTimeout_);
emit HeirOwnershipClaimed(getOwner(), heir_);
transferOwnership(heir_);
_transferOwnership(heir_);
timeOfDeath_ = 0;
}

Expand Down
38 changes: 26 additions & 12 deletions contracts/payment/RefundEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,39 @@ contract RefundEscrow is Ownable, ConditionalEscrow {
event Closed();
event RefundsEnabled();

State public state;
address public beneficiary;
State private state_;
address private beneficiary_;

/**
* @dev Constructor.
* @param _beneficiary The beneficiary of the deposits.
*/
constructor(address _beneficiary) public {
require(_beneficiary != address(0));
beneficiary = _beneficiary;
state = State.Active;
beneficiary_ = _beneficiary;
state_ = State.Active;
}

/**
* @return the current state of the escrow.
*/
function getState() public view returns(State) {
return state_;
}

/**
* @return the beneficiary of the escrow.
*/
function getBeneficiary() public view returns(address) {
return beneficiary_;
}

/**
* @dev Stores funds that may later be refunded.
* @param _refundee The address funds will be sent to if a refund occurs.
*/
function deposit(address _refundee) public payable {
require(state == State.Active);
require(state_ == State.Active);
super.deposit(_refundee);
}

Expand All @@ -43,32 +57,32 @@ contract RefundEscrow is Ownable, ConditionalEscrow {
* further deposits.
*/
function close() public onlyOwner {
require(state == State.Active);
state = State.Closed;
require(state_ == State.Active);
state_ = State.Closed;
emit Closed();
}

/**
* @dev Allows for refunds to take place, rejecting further deposits.
*/
function enableRefunds() public onlyOwner {
require(state == State.Active);
state = State.Refunding;
require(state_ == State.Active);
state_ = State.Refunding;
emit RefundsEnabled();
}

/**
* @dev Withdraws the beneficiary's funds.
*/
function beneficiaryWithdraw() public {
require(state == State.Closed);
beneficiary.transfer(address(this).balance);
require(state_ == State.Closed);
beneficiary_.transfer(address(this).balance);
}

/**
* @dev Returns whether refundees can withdraw their deposits (be refunded).
*/
function withdrawalAllowed(address _payee) public view returns (bool) {
return state == State.Refunding;
return state_ == State.Refunding;
}
}
67 changes: 51 additions & 16 deletions contracts/payment/SplitPayment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import "../math/SafeMath.sol";
contract SplitPayment {
using SafeMath for uint256;

uint256 public totalShares = 0;
uint256 public totalReleased = 0;
uint256 private totalShares_ = 0;
uint256 private totalReleased_ = 0;

mapping(address => uint256) public shares;
mapping(address => uint256) public released;
address[] public payees;
mapping(address => uint256) private shares_;
mapping(address => uint256) private released_;
address[] private payees_;

/**
* @dev Constructor
Expand All @@ -35,26 +35,61 @@ contract SplitPayment {
*/
function () external payable {}

/**
* @return the total shares of the contract.
*/
function getTotalShares() public view returns(uint256) {
return totalShares_;
}

/**
* @return the total amount already released.
*/
function getTotalReleased() public view returns(uint256) {
return totalReleased_;
}

/**
* @return the shares of an account.
*/
function getShares(address _account) public view returns(uint256) {
return shares_[_account];
}

/**
* @return the amount already released to an account.
*/
function getReleased(address _account) public view returns(uint256) {
return released_[_account];
}

/**
* @return the address of a payee.
*/
function getPayee(uint256 index) public view returns(address) {
return payees_[index];
}

/**
* @dev Claim your share of the balance.
*/
function claim() public {
address payee = msg.sender;

require(shares[payee] > 0);
require(shares_[payee] > 0);

uint256 totalReceived = address(this).balance.add(totalReleased);
uint256 totalReceived = address(this).balance.add(totalReleased_);
uint256 payment = totalReceived.mul(
shares[payee]).div(
totalShares).sub(
released[payee]
shares_[payee]).div(
totalShares_).sub(
released_[payee]
);

require(payment != 0);
assert(address(this).balance >= payment);

released[payee] = released[payee].add(payment);
totalReleased = totalReleased.add(payment);
released_[payee] = released_[payee].add(payment);
totalReleased_ = totalReleased_.add(payment);

payee.transfer(payment);
}
Expand All @@ -67,10 +102,10 @@ contract SplitPayment {
function _addPayee(address _payee, uint256 _shares) internal {
require(_payee != address(0));
require(_shares > 0);
require(shares[_payee] == 0);
require(shares_[_payee] == 0);

payees.push(_payee);
shares[_payee] = _shares;
totalShares = totalShares.add(_shares);
payees_.push(_payee);
shares_[_payee] = _shares;
totalShares_ = totalShares_.add(_shares);
}
}
4 changes: 4 additions & 0 deletions test/payment/RefundEscrow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ contract('RefundEscrow', function ([_, owner, beneficiary, refundee1, refundee2]
});

context('active state', function () {
it('has beneficiary', async function () {
(await this.escrow.getBeneficiary()).should.be.equal(beneficiary);
});

it('accepts deposits', async function () {
await this.escrow.deposit(refundee1, { from: owner, value: amount });

Expand Down
6 changes: 3 additions & 3 deletions test/payment/SplitPayment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
});

it('should store shares if address is payee', async function () {
(await this.contract.shares.call(payee1)).should.be.bignumber.not.equal(0);
(await this.contract.getShares(payee1)).should.be.bignumber.not.equal(0);
});

it('should not store shares if address is not payee', async function () {
(await this.contract.shares.call(nonpayee1)).should.be.bignumber.equal(0);
(await this.contract.getShares(nonpayee1)).should.be.bignumber.equal(0);
});

it('should throw if no funds to claim', async function () {
Expand Down Expand Up @@ -96,7 +96,7 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1,
(await ethGetBalance(this.contract.address)).should.be.bignumber.equal(0);

// check correct funds released accounting
(await this.contract.totalReleased.call()).should.be.bignumber.equal(initBalance);
(await this.contract.getTotalReleased()).should.be.bignumber.equal(initBalance);
});
});
});