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 ERC20
  • Loading branch information
Leo Arias committed Sep 3, 2018
commit 0d8a5e4ab76bc1e7b16e0e026caacb2a6bc43b0c
13 changes: 10 additions & 3 deletions contracts/token/ERC20/ERC20Capped.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ import "./ERC20Mintable.sol";
*/
contract ERC20Capped is ERC20Mintable {

uint256 public cap;
uint256 private cap_;

constructor(uint256 _cap) public {
require(_cap > 0);
cap = _cap;
cap_ = _cap;
}

/**
* @return the cap for the token minting.
*/
function getCap() public view returns(uint256) {
return cap_;
}

/**
Expand All @@ -29,7 +36,7 @@ contract ERC20Capped is ERC20Mintable {
public
returns (bool)
{
require(totalSupply().add(_amount) <= cap);
require(totalSupply().add(_amount) <= cap_);

return super.mint(_to, _amount);
}
Expand Down
33 changes: 27 additions & 6 deletions contracts/token/ERC20/ERC20Detailed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,34 @@ import "./IERC20.sol";
* just as on Ethereum all the operations are done in wei.
*/
contract ERC20Detailed is IERC20 {
string public name;
string public symbol;
uint8 public decimals;
string private name_;
string private symbol_;
uint8 private decimals_;

constructor(string _name, string _symbol, uint8 _decimals) public {
name = _name;
symbol = _symbol;
decimals = _decimals;
name_ = _name;
symbol_ = _symbol;
decimals_ = _decimals;
}

/**
* @return the name of the token.
*/
function getName() public view returns(string) {
return name_;
}

/**
* @return the symbol of the token.
*/
function getSymbol() public view returns(string) {
return symbol_;
}

/**
* @return the number of decimals of the token.
*/
function getDecimals() public view returns(uint8) {
return decimals_;
}
}
13 changes: 10 additions & 3 deletions contracts/token/ERC20/ERC20Mintable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ contract ERC20Mintable is ERC20, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();

bool public mintingFinished = false;
bool private mintingFinished_ = false;


modifier canMint() {
require(!mintingFinished);
require(!mintingFinished_);
_;
}

Expand All @@ -26,6 +26,13 @@ contract ERC20Mintable is ERC20, Ownable {
_;
}

/**
* @return true if the minting is finished.
*/
function isMintingFinished() public view returns(bool) {
return mintingFinished_;
}

/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
Expand All @@ -51,7 +58,7 @@ contract ERC20Mintable is ERC20, Ownable {
* @return True if the operation was successful.
*/
function finishMinting() public onlyOwner canMint returns (bool) {
mintingFinished = true;
mintingFinished_ = true;
emit MintFinished();
return true;
}
Expand Down
39 changes: 30 additions & 9 deletions contracts/token/ERC20/TokenTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ contract TokenTimelock {
using SafeERC20 for IERC20;

// ERC20 basic token contract being held
IERC20 public token;
IERC20 private token_;

// beneficiary of tokens after they are released
address public beneficiary;
address private beneficiary_;

// timestamp when token release is enabled
uint256 public releaseTime;
uint256 private releaseTime_;

constructor(
IERC20 _token,
Expand All @@ -29,21 +29,42 @@ contract TokenTimelock {
{
// solium-disable-next-line security/no-block-members
require(_releaseTime > block.timestamp);
token = _token;
beneficiary = _beneficiary;
releaseTime = _releaseTime;
token_ = _token;
beneficiary_ = _beneficiary;
releaseTime_ = _releaseTime;
}

/**
* @return the token being held.
*/
function getToken() public view returns(IERC20) {
return token_;
}

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

/**
* @return the time when the tokens are released.
*/
function getReleaseTime() public view returns(uint256) {
return releaseTime_;
}

/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() public {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= releaseTime);
require(block.timestamp >= releaseTime_);

uint256 amount = token.balanceOf(address(this));
uint256 amount = token_.balanceOf(address(this));
require(amount > 0);

token.safeTransfer(beneficiary, amount);
token_.safeTransfer(beneficiary_, amount);
}
}
93 changes: 71 additions & 22 deletions contracts/token/ERC20/TokenVesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ contract TokenVesting is Ownable {
event Revoked();

// beneficiary of tokens after they are released
address public beneficiary;
address private beneficiary_;

uint256 public cliff;
uint256 public start;
uint256 public duration;
uint256 private cliff_;
uint256 private start_;
uint256 private duration_;

bool public revocable;
bool private revocable_;

mapping (address => uint256) public released;
mapping (address => bool) public revoked;
mapping (address => uint256) private released_;
mapping (address => bool) private revoked_;

/**
* @dev Creates a vesting contract that vests its balance of any ERC20 token to the
Expand All @@ -54,11 +54,60 @@ contract TokenVesting is Ownable {
require(_beneficiary != address(0));
require(_cliff <= _duration);

beneficiary = _beneficiary;
revocable = _revocable;
duration = _duration;
cliff = _start.add(_cliff);
start = _start;
beneficiary_ = _beneficiary;
revocable_ = _revocable;
duration_ = _duration;
cliff_ = _start.add(_cliff);
start_ = _start;
}

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

/**
* @return the cliff time of the token vesting.
*/
function getCliff() public view returns(uint256) {
return cliff_;
}

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

/**
* @return the duration of the token vesting.
*/
function getDuration() public view returns(uint256) {
return duration_;
}

/**
* @return true if the vesting is revocable.
*/
function isRevocable() public view returns(bool) {
return revocable_;
}

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

/**
* @return true if the account is revoked.
*/
function isRevoked(address _account) public view returns(bool) {
return revoked_[_account];
}

/**
Expand All @@ -70,9 +119,9 @@ contract TokenVesting is Ownable {

require(unreleased > 0);

released[_token] = released[_token].add(unreleased);
released_[_token] = released_[_token].add(unreleased);

_token.safeTransfer(beneficiary, unreleased);
_token.safeTransfer(beneficiary_, unreleased);

emit Released(unreleased);
}
Expand All @@ -83,15 +132,15 @@ contract TokenVesting is Ownable {
* @param _token ERC20 token which is being vested
*/
function revoke(IERC20 _token) public onlyOwner {
require(revocable);
require(!revoked[_token]);
require(revocable_);
require(!revoked_[_token]);

uint256 balance = _token.balanceOf(address(this));

uint256 unreleased = releasableAmount(_token);
uint256 refund = balance.sub(unreleased);

revoked[_token] = true;
revoked_[_token] = true;

_token.safeTransfer(owner, refund);

Expand All @@ -103,7 +152,7 @@ contract TokenVesting is Ownable {
* @param _token ERC20 token which is being vested
*/
function releasableAmount(IERC20 _token) public view returns (uint256) {
return vestedAmount(_token).sub(released[_token]);
return vestedAmount(_token).sub(released_[_token]);
}

/**
Expand All @@ -112,14 +161,14 @@ contract TokenVesting is Ownable {
*/
function vestedAmount(IERC20 _token) public view returns (uint256) {
uint256 currentBalance = _token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[_token]);
uint256 totalBalance = currentBalance.add(released_[_token]);

if (block.timestamp < cliff) {
if (block.timestamp < cliff_) {
return 0;
} else if (block.timestamp >= start.add(duration) || revoked[_token]) {
} else if (block.timestamp >= start_.add(duration_) || revoked_[_token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(start)).div(duration);
return totalBalance.mul(block.timestamp.sub(start_)).div(duration_);
}
}
}
6 changes: 3 additions & 3 deletions test/token/ERC20/DetailedERC20.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ contract('ERC20Detailed', function () {
});

it('has a name', async function () {
(await detailedERC20.name()).should.be.equal(_name);
(await detailedERC20.getName()).should.be.equal(_name);
});

it('has a symbol', async function () {
(await detailedERC20.symbol()).should.be.equal(_symbol);
(await detailedERC20.getSymbol()).should.be.equal(_symbol);
});

it('has an amount of decimals', async function () {
(await detailedERC20.decimals()).should.be.bignumber.equal(_decimals);
(await detailedERC20.getDecimals()).should.be.bignumber.equal(_decimals);
});
});
2 changes: 1 addition & 1 deletion test/token/ERC20/ERC20Capped.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function shouldBehaveLikeERC20Capped (minter, [anyone], cap) {
const from = minter;

it('should start with the correct cap', async function () {
(await this.token.cap()).should.be.bignumber.equal(cap);
(await this.token.getCap()).should.be.bignumber.equal(cap);
});

it('should mint when amount is less than cap', async function () {
Expand Down
6 changes: 3 additions & 3 deletions test/token/ERC20/ERC20Mintable.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function shouldBehaveLikeERC20Mintable (owner, minter, [anyone]) {
describe('minting finished', function () {
describe('when the token minting is not finished', function () {
it('returns false', async function () {
(await this.token.mintingFinished()).should.equal(false);
(await this.token.isMintingFinished()).should.equal(false);
});
});

Expand All @@ -30,7 +30,7 @@ function shouldBehaveLikeERC20Mintable (owner, minter, [anyone]) {
});

it('returns true', async function () {
(await this.token.mintingFinished()).should.equal(true);
(await this.token.isMintingFinished()).should.equal(true);
});
});
});
Expand All @@ -43,7 +43,7 @@ function shouldBehaveLikeERC20Mintable (owner, minter, [anyone]) {
it('finishes token minting', async function () {
await this.token.finishMinting({ from });

(await this.token.mintingFinished()).should.equal(true);
(await this.token.isMintingFinished()).should.equal(true);
});

it('emits a mint finished event', async function () {
Expand Down