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 ownership
  • Loading branch information
Leo Arias committed Sep 5, 2018
commit 86bbab3bb26ed30baf6dbb1bdb2c69da98290d52
2 changes: 1 addition & 1 deletion contracts/drafts/TokenVesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ contract TokenVesting is Ownable {

revoked_[_token] = true;

_token.safeTransfer(owner, refund);
_token.safeTransfer(getOwner(), refund);

emit Revoked();
}
Expand Down
19 changes: 13 additions & 6 deletions contracts/ownership/Claimable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,37 @@ import "./Ownable.sol";
* This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
address private pendingOwner_;

/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
require(msg.sender == pendingOwner_);
_;
}

/**
* @return the address of the pending owner.
*/
function getPendingOwner() public view returns(address) {
return pendingOwner_;
}

/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
pendingOwner_ = newOwner;
}

/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
emit OwnershipTransferred(getOwner(), pendingOwner_);
owner = pendingOwner_;
pendingOwner_ = address(0);
}
}
32 changes: 22 additions & 10 deletions contracts/ownership/DelayedClaimable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,22 @@ import "./Claimable.sol";
*/
contract DelayedClaimable is Claimable {

uint256 public end;
uint256 public start;
uint256 private start_;
uint256 private end_;

/**
* @return the start of the claimable period.
*/
function getStart() public view returns(uint256) {
return start_;
}

/**
* @return the end of the claimable period.
*/
function getEnd() public view returns(uint256) {
return end_;
}

/**
* @dev Used to specify the time period during which a pending
Expand All @@ -21,20 +35,18 @@ contract DelayedClaimable is Claimable {
*/
function setLimits(uint256 _start, uint256 _end) public onlyOwner {
require(_start <= _end);
end = _end;
start = _start;
end_ = _end;
start_ = _start;
}

/**
* @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within
* @dev Allows the pending owner address to finalize the transfer, as long as it is called within
* the specified start and end time.
*/
function claimOwnership() public onlyPendingOwner {
require((block.number <= end) && (block.number >= start));
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
end = 0;
require((block.number <= end_) && (block.number >= start_));
super.claimOwnership();
end_ = 0;
}

}
13 changes: 6 additions & 7 deletions contracts/ownership/Heritable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ contract Heritable is Ownable {
}

function setHeir(address _newHeir) public onlyOwner {
require(_newHeir != owner);
require(_newHeir != getOwner());
heartbeat();
emit HeirChanged(owner, _newHeir);
emit HeirChanged(getOwner(), _newHeir);
heir_ = _newHeir;
}

Expand Down Expand Up @@ -87,7 +87,7 @@ contract Heritable is Ownable {
*/
function proclaimDeath() public onlyHeir {
require(_ownerLives());
emit OwnerProclaimedDead(owner, heir_, timeOfDeath_);
emit OwnerProclaimedDead(getOwner(), heir_, timeOfDeath_);
// solium-disable-next-line security/no-block-members
timeOfDeath_ = block.timestamp;
}
Expand All @@ -96,7 +96,7 @@ contract Heritable is Ownable {
* @dev Owner can send a heartbeat if they were mistakenly pronounced dead.
*/
function heartbeat() public onlyOwner {
emit OwnerHeartbeated(owner);
emit OwnerHeartbeated(getOwner());
timeOfDeath_ = 0;
}

Expand All @@ -107,9 +107,8 @@ contract Heritable is Ownable {
require(!_ownerLives());
// solium-disable-next-line security/no-block-members
require(block.timestamp >= timeOfDeath_ + heartbeatTimeout_);
emit OwnershipTransferred(owner, heir_);
emit HeirOwnershipClaimed(owner, heir_);
owner = heir_;
emit HeirOwnershipClaimed(getOwner(), heir_);
transferOwnership(heir_);
timeOfDeath_ = 0;
}

Expand Down
19 changes: 13 additions & 6 deletions contracts/ownership/Ownable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pragma solidity ^0.4.24;
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
address private owner_;


event OwnershipRenounced(address indexed previousOwner);
Expand All @@ -22,14 +22,21 @@ contract Ownable {
* account.
*/
constructor() public {
owner = msg.sender;
owner_ = msg.sender;
}

/**
* @return the address of the owner.
*/
function getOwner() public view returns(address) {
return owner_;
}

/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
require(msg.sender == owner_);
_;
}

Expand All @@ -40,7 +47,7 @@ contract Ownable {
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
emit OwnershipRenounced(owner_);
owner = address(0);
}

Expand All @@ -58,7 +65,7 @@ contract Ownable {
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
emit OwnershipTransferred(owner_, _newOwner);
owner_ = _newOwner;
}
}
2 changes: 1 addition & 1 deletion contracts/ownership/Superuser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract Superuser is Ownable, RBAC {
}

modifier onlyOwnerOrSuperuser() {
require(msg.sender == owner || isSuperuser(msg.sender));
require(msg.sender == getOwner() || isSuperuser(msg.sender));
_;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/ERC20Mintable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract ERC20Mintable is ERC20, Ownable {
}

modifier hasMintPermission() {
require(msg.sender == owner);
require(msg.sender == getOwner());
_;
}

Expand Down
2 changes: 1 addition & 1 deletion test/access/SignatureBouncer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract('Bouncer', function ([_, owner, anyone, bouncerAddress, authorizedUser]

context('management', function () {
it('has a default owner of self', async function () {
(await this.bouncer.owner()).should.equal(owner);
(await this.bouncer.getOwner()).should.equal(owner);
});

it('allows the owner to add a bouncer', async function () {
Expand Down
2 changes: 1 addition & 1 deletion test/crowdsale/MintedCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) {
});

it('should be token owner', async function () {
(await this.token.owner()).should.equal(this.crowdsale.address);
(await this.token.getOwner()).should.equal(this.crowdsale.address);
});

shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
Expand Down
6 changes: 3 additions & 3 deletions test/ownership/Claimable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) {
});

it('should have an owner', async function () {
(await claimable.owner()).should.not.equal(0);
(await claimable.getOwner()).should.not.equal(0);
});

it('changes pendingOwner after transfer', async function () {
await claimable.transferOwnership(newOwner, { from: owner });
(await claimable.pendingOwner()).should.equal(newOwner);
(await claimable.getPendingOwner()).should.equal(newOwner);
});

it('should prevent to claimOwnership from anyone', async function () {
Expand All @@ -40,7 +40,7 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) {
it('changes allow pending owner to claim ownership', async function () {
await claimable.claimOwnership({ from: newOwner });

(await claimable.owner()).should.equal(newOwner);
(await claimable.getOwner()).should.equal(newOwner);
});
});
});
20 changes: 10 additions & 10 deletions test/ownership/DelayedClaimable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) {
await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(0, 1000, { from: owner });

(await this.delayedClaimable.end()).should.be.bignumber.equal(1000);
(await this.delayedClaimable.getEnd()).should.be.bignumber.equal(1000);

(await this.delayedClaimable.start()).should.be.bignumber.equal(0);
(await this.delayedClaimable.getStart()).should.be.bignumber.equal(0);
});

it('changes pendingOwner after transfer successful', async function () {
await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(0, 1000, { from: owner });

(await this.delayedClaimable.end()).should.be.bignumber.equal(1000);
(await this.delayedClaimable.getEnd()).should.be.bignumber.equal(1000);

(await this.delayedClaimable.start()).should.be.bignumber.equal(0);
(await this.delayedClaimable.getStart()).should.be.bignumber.equal(0);

(await this.delayedClaimable.pendingOwner()).should.equal(newOwner);
(await this.delayedClaimable.getPendingOwner()).should.equal(newOwner);
await this.delayedClaimable.claimOwnership({ from: newOwner });
(await this.delayedClaimable.owner()).should.equal(newOwner);
(await this.delayedClaimable.getOwner()).should.equal(newOwner);
});

it('changes pendingOwner after transfer fails', async function () {
await this.delayedClaimable.transferOwnership(newOwner, { from: owner });
await this.delayedClaimable.setLimits(100, 110, { from: owner });

(await this.delayedClaimable.end()).should.be.bignumber.equal(110);
(await this.delayedClaimable.getEnd()).should.be.bignumber.equal(110);

(await this.delayedClaimable.start()).should.be.bignumber.equal(100);
(await this.delayedClaimable.getStart()).should.be.bignumber.equal(100);

(await this.delayedClaimable.pendingOwner()).should.equal(newOwner);
(await this.delayedClaimable.getPendingOwner()).should.equal(newOwner);
await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner }));
(await this.delayedClaimable.owner()).should.not.equal(newOwner);
(await this.delayedClaimable.getOwner()).should.not.equal(newOwner);
});

it('set end and start invalid values fail', async function () {
Expand Down
6 changes: 3 additions & 3 deletions test/ownership/Ownable.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ require('chai')
function shouldBehaveLikeOwnable (owner, [anyone]) {
describe('as an ownable', function () {
it('should have an owner', async function () {
(await this.ownable.owner()).should.equal(owner);
(await this.ownable.getOwner()).should.equal(owner);
});

it('changes owner after transfer', async function () {
await this.ownable.transferOwnership(anyone, { from: owner });
(await this.ownable.owner()).should.equal(anyone);
(await this.ownable.getOwner()).should.equal(anyone);
});

it('should prevent non-owners from transfering', async function () {
Expand All @@ -27,7 +27,7 @@ function shouldBehaveLikeOwnable (owner, [anyone]) {

it('loses owner after renouncement', async function () {
await this.ownable.renounceOwnership({ from: owner });
(await this.ownable.owner()).should.equal(ZERO_ADDRESS);
(await this.ownable.getOwner()).should.equal(ZERO_ADDRESS);
});

it('should prevent non-owners from renouncement', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/ownership/Superuser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone])
'OwnershipTransferred'
);

(await this.superuser.owner()).should.equal(newOwner);
(await this.superuser.getOwner()).should.equal(newOwner);
});

it('should change owner after the owner transfers the ownership', async function () {
Expand All @@ -49,7 +49,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone])
'OwnershipTransferred'
);

(await this.superuser.owner()).should.equal(newOwner);
(await this.superuser.getOwner()).should.equal(newOwner);
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/token/ERC20/ERC20Mintable.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function shouldBehaveLikeERC20Mintable (owner, minter, [anyone]) {
describe('as a basic mintable token', function () {
describe('after token creation', function () {
it('sender should be token owner', async function () {
(await this.token.owner({ from: owner })).should.equal(owner);
(await this.token.getOwner({ from: owner })).should.equal(owner);
});
});

Expand Down