Commit 6c4c8989 by Leo Arias Committed by Francisco Giordano

Use prefix underscore for state variables and no underscore for parameters (#1282)

* Role tests (#1228)

* Moved RBAC tests to access.

* Added Roles.addMany and tests.

* Fixed linter error.

* Now using uint256 indexes.

* Removed RBAC tokens (#1229)

* Deleted RBACCappedTokenMock.

* Removed RBACMintableToken.

* Removed RBACMintableToken from the MintedCrowdsale tests.

* Roles can now be transfered. (#1235)

* Roles can now be transfered.

* Now explicitly checking support for the null address.

* Now rejecting transfer to a role-haver.

* Added renounce, roles can no longer be transfered to 0.

* Fixed linter errors.

* Fixed a Roles test.

* True Ownership (#1247)

* Added barebones Secondary.

* Added transferPrimary

* Escrow is now Secondary instead of Ownable.

* Now reverting on transfers to 0.

* The Secondary's primary is now private.

* Improve encapsulation on ERC165

* Improve encapsulation on ERC20

* Improve encapsulation on ERC721

* Add tests, use standard getters

* fix tests

* Fix lint

* MintableToken using Roles (#1236)

* Minor test style improvements (#1219)

* Changed .eq to .equal

* Changed equal(bool) to .to.be.bool

* Changed be.bool to equal(bool), disallowed unused expressions.

* Add ERC165Query library (#1086)

* Add ERC165Query library

* Address PR Comments

* Add tests and mocks from #1024 and refactor code slightly

* Fix javascript and solidity linting errors

* Split supportsInterface into three methods as discussed in #1086

* Change InterfaceId_ERC165 comment to match style in the rest of the repo

* Fix max-len lint issue on ERC165Checker.sol

* Conditionally ignore the asserts during solidity-coverage test

* Switch to abi.encodeWithSelector and add test for account addresses

* Switch to supportsInterfaces API as suggested by @frangio

* Adding ERC165InterfacesSupported.sol

* Fix style issues

* Add test for supportsInterfaces returning false

* Add ERC165Checker.sol newline

* feat: fix coverage implementation

* fix: solidity linting error

* fix: revert to using boolean tests instead of require statements

* fix: make supportsERC165Interface private again

* rename SupportsInterfaceWithLookupMock to avoid name clashing

* Added mint and burn tests for zero amounts. (#1230)

* Changed .eq to .equal. (#1231)

* ERC721 pausable token (#1154)

* ERC721 pausable token

* Reuse of ERC721 Basic behavior for Pausable, split view checks in paused state & style fixes

* [~] paused token behavior

* Add some detail to releasing steps (#1190)

* add note about pulling upstream changes to release branch

* add comment about upstream changes in merging section

* Increase test coverage (#1237)

* Fixed a SplitPayment test

* Deleted unnecessary function.

* Improved PostDeliveryCrowdsale tests.

* Improved RefundableCrowdsale tests.

* Improved MintedCrowdsale tests.

* Improved IncreasingPriceCrowdsale tests.

* Fixed a CappedCrowdsale test.

* Improved TimedCrowdsale tests.

* Improved descriptions of added tests.

*  ci: trigger docs update on tag  (#1186)

* MintableToken now uses Roles.

* Fixed FinalizableCrowdsale test.

* Roles can now be transfered.

* Fixed tests related to MintableToken.

* Removed Roles.check.

* Renamed transferMintPermission.

* Moved MinterRole

* Fixed RBAC.

* Adressed review comments.

* Addressed review comments

* Fixed linter errors.

* Added Events tests of Pausable contract (#1207)

* Fixed roles tests.

* Rename events to past-tense (#1181)

* fix: refactor sign.js and related tests (#1243)

* fix: refactor sign.js and related tests

* fix: remove unused dep

* fix: update package.json correctly

* Added "_" sufix to internal variables (#1171)

* Added PublicRole test.

* Fixed crowdsale tests.

* Rename ERC interfaces to I prefix (#1252)

* rename ERC20 to IERC20

* move ERC20.sol to IERC20.sol

* rename StandardToken to ERC20

* rename StandardTokenMock to ERC20Mock

* move StandardToken.sol to ERC20.sol, likewise test and mock files

* rename MintableToken to ERC20Mintable

* move MintableToken.sol to ERC20Mintable.sol, likewise test and mock files

* rename BurnableToken to ERC20Burnable

* move BurnableToken.sol to ERC20Burnable.sol, likewise for related files

* rename CappedToken to ERC20Capped

* move CappedToken.sol to ERC20Capped.sol, likewise for related files

* rename PausableToken to ERC20Pausable

* move PausableToken.sol to ERC20Pausable.sol, likewise for related files

* rename DetailedERC20 to ERC20Detailed

* move DetailedERC20.sol to ERC20Detailed.sol, likewise for related files

* rename ERC721 to IERC721, and likewise for other related interfaces

* move ERC721.sol to IERC721.sol, likewise for other 721 interfaces

* rename ERC721Token to ERC721

* move ERC721Token.sol to ERC721.sol, likewise for related files

* rename ERC721BasicToken to ERC721Basic

* move ERC721BasicToken.sol to ERC721Basic.sol, likewise for related files

* rename ERC721PausableToken to ERC721Pausable

* move ERC721PausableToken.sol to ERC721Pausable.sol

* rename ERC165 to IERC165

* move ERC165.sol to IERC165.sol

* amend comment that ERC20 is based on FirstBlood

* fix comments mentioning IERC721Receiver

* added explicit visibility (#1261)

* Remove underscores from event parameters. (#1258)

* Remove underscores from event parameters.

Fixes #1175

* Add comment about ERC

* Move contracts to subdirectories (#1253)

* Move contracts to subdirectories

Fixes #1177.

This Change also removes the LimitBalance contract.

* fix import

* move MerkleProof to cryptography

* Fix import

* Remove HasNoEther, HasNoTokens, HasNoContracts, and NoOwner (#1254)

* remove HasNoEther, HasNoTokens, HasNoContracts, and NoOwner

* remove unused ERC223TokenMock

* remove Contactable

* remove TokenDestructible

* remove DeprecatedERC721

* inline Destructible#destroy in Bounty

* remove Destructible

* Functions in interfaces changed to "external" (#1263)

* Add a leading underscore to internal and private functions. (#1257)

* Add a leading underscore to internal and private functions.

Fixes #1176

* Remove super

* update the ERC721 changes

* add missing underscore after merge

* Fix mock

* Improve encapsulation on SignatureBouncer, Whitelist and RBAC example (#1265)

* Improve encapsulation on Whitelist

* remove only

* update whitelisted crowdsale test

* Improve encapsulation on SignatureBouncer

* fix missing test

* Improve encapsulation on RBAC example

* Improve encapsulation on RBAC example

* Remove extra visibility

* Improve encapsulation on ERC20 Mintable

* Improve encapsulation on Superuser

* fix lint

* add missing constant

* Addressed review comments.

* Fixed build error.

* move interface ids to implementation contracts

* Do not prefix getters

* Improve encapsulation on Crowdsales

* add missing tests

* remove only

* Improve encapsulation on Pausable

* add the underscore

* Improve encapsulation on ownership

* fix rebase

* fix ownership

* Improve encapsulation on payments

* Add missing tests

* add missing test

* Do not prefix getters

* Do not prefix getters

* Fix tests.

* Update modifiers to call public view functions.

Fixes #1179.

* Improve encapsulation on BreakInvariantBounty

* Make researchers private

* Improve encapsulation on Crowdsales

* add missing tests

* remove only

* Improve encapsulation on Pausable

* add the underscore

* Improve encapsulation on ownership

* fix rebase

* fix ownership

* Improve encapsulation on payments

* Add missing tests

* add missing test

* Do not prefix getters

* Do not prefix getters

* Do not prefix getters

* Fix tests.

* tmp

* remove isMinter

* fix is owner call

* fix isOpen

* Fix merge

* tmp

* Improve encapsulation on TimedCrowdsale

* Add missing parentheses

* Use prefix underscore for state variables and no underscore for parameters

* Improved Roles API. (#1280)

* Improved Roles API.

* fix linter error

* Added PauserRole. (#1283)

* remove duplicate function definition

* Remove Claimable, DelayedClaimable, Heritable (#1274)

* remove Claimable, DelayedClaimable, Heritable

* remove SimpleSavingsWallet example which used Heritable

(cherry picked from commit 0dc71173)

* Role behavior tests (#1285)

* Added role tests.

* Added PauserRole tests to contracts that have that role.

* Added MinterRole tests to contracts that have that role.

* Fixed linter errors.

* Migrate Ownable to Roles (#1287)

* Added CapperRole.

* RefundEscrow is now Secondary.

* FinalizableCrowdsale is no longer Ownable.

* Removed Whitelist and WhitelistedCrowdsale, redesign needed.

* Fixed linter errors, disabled lbrace due to it being buggy.

* Remove RBAC, SignatureBouncer refactor (#1289)

* Added CapperRole.

* RefundEscrow is now Secondary.

* FinalizableCrowdsale is no longer Ownable.

* Removed Whitelist and WhitelistedCrowdsale, redesign needed.

* Fixed linter errors, disabled lbrace due to it being buggy.

* Moved SignatureBouncer tests.

* Deleted RBAC and Superuser.

* Deleted rbac directory.

* Updated readme.

* SignatureBouncer now uses SignerRole, renamed bouncer to signer.

* feat: implement ERC721Mintable and ERC721Burnable (#1276)

* feat: implement ERC721Mintable and ERC721Burnable

* fix: linting errors

* fix: remove unused mintable mock for ERC721BasicMock

* fix: add finishMinting tests

* fix: catch MintFinished typo

* inline ERC721Full behavior

* undo pretty formatting

* fix lint errors

* rename canMint to onlyBeforeMintingFinished for consistency with ERC20Mintable

* Fix the merge with the privatization branch

* fix lint

* Remove underscore

* Delete CapperRole.test.js

* fix increaseApproval
parent 254210f6
......@@ -16,34 +16,18 @@ Any exception or additions specific to our project are documented below.
* Try to avoid acronyms and abbreviations.
* Parameters must be prefixed with an underscore.
```
function test(uint256 _testParameter1, uint256 _testParameter2) {
...
}
```
The exception are the parameters of events. There is no chance of ambiguity
with these, so they should not have underscores. Not even if they are
specified on an ERC with underscores; removing them doesn't change the ABI,
so we should be consistent with the rest of the events in this repository
and remove them.
* Internal and private state variables should have an underscore suffix.
* Private state variables should have an underscore prefix.
```
contract TestContract {
uint256 internal internalVar_;
uint256 private privateVar_;
uint256 private _privateVar;
}
```
Variables declared in a function should not follow this rule.
* Parameters must not be prefixed with an underscore.
```
function test() {
uint256 functionVar;
function test(uint256 testParameter1, uint256 testParameter2) {
...
}
```
......
......@@ -20,21 +20,21 @@ contract CapperRole {
_;
}
function isCapper(address _account) public view returns (bool) {
return cappers.has(_account);
function isCapper(address account) public view returns (bool) {
return cappers.has(account);
}
function addCapper(address _account) public onlyCapper {
cappers.add(_account);
emit CapperAdded(_account);
function addCapper(address account) public onlyCapper {
cappers.add(account);
emit CapperAdded(account);
}
function renounceCapper() public {
cappers.remove(msg.sender);
}
function _removeCapper(address _account) internal {
cappers.remove(_account);
emit CapperRemoved(_account);
function _removeCapper(address account) internal {
cappers.remove(account);
emit CapperRemoved(account);
}
}
......@@ -20,21 +20,21 @@ contract MinterRole {
_;
}
function isMinter(address _account) public view returns (bool) {
return minters.has(_account);
function isMinter(address account) public view returns (bool) {
return minters.has(account);
}
function addMinter(address _account) public onlyMinter {
minters.add(_account);
emit MinterAdded(_account);
function addMinter(address account) public onlyMinter {
minters.add(account);
emit MinterAdded(account);
}
function renounceMinter() public {
minters.remove(msg.sender);
}
function _removeMinter(address _account) internal {
minters.remove(_account);
emit MinterRemoved(_account);
function _removeMinter(address account) internal {
minters.remove(account);
emit MinterRemoved(account);
}
}
......@@ -20,21 +20,21 @@ contract PauserRole {
_;
}
function isPauser(address _account) public view returns (bool) {
return pausers.has(_account);
function isPauser(address account) public view returns (bool) {
return pausers.has(account);
}
function addPauser(address _account) public onlyPauser {
pausers.add(_account);
emit PauserAdded(_account);
function addPauser(address account) public onlyPauser {
pausers.add(account);
emit PauserAdded(account);
}
function renouncePauser() public {
pausers.remove(msg.sender);
}
function _removePauser(address _account) internal {
pausers.remove(_account);
emit PauserRemoved(_account);
function _removePauser(address account) internal {
pausers.remove(account);
emit PauserRemoved(account);
}
}
......@@ -20,21 +20,21 @@ contract SignerRole {
_;
}
function isSigner(address _account) public view returns (bool) {
return signers.has(_account);
function isSigner(address account) public view returns (bool) {
return signers.has(account);
}
function addSigner(address _account) public onlySigner {
signers.add(_account);
emit SignerAdded(_account);
function addSigner(address account) public onlySigner {
signers.add(account);
emit SignerAdded(account);
}
function renounceSigner() public {
signers.remove(msg.sender);
}
function _removeSigner(address _account) internal {
signers.remove(_account);
emit SignerRemoved(_account);
function _removeSigner(address account) internal {
signers.remove(account);
emit SignerRemoved(account);
}
}
......@@ -10,8 +10,8 @@ import "../ownership/Ownable.sol";
* @dev This bounty will pay out to a researcher if they break invariant logic of the contract.
*/
contract BreakInvariantBounty is PullPayment, Ownable {
bool private claimed_;
mapping(address => address) private researchers;
bool private _claimed;
mapping(address => address) private _researchers;
event TargetCreated(address createdAddress);
......@@ -19,7 +19,7 @@ contract BreakInvariantBounty is PullPayment, Ownable {
* @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed.
*/
function() external payable {
require(!claimed_);
require(!_claimed);
}
/**
......@@ -27,7 +27,7 @@ contract BreakInvariantBounty is PullPayment, Ownable {
* @return true if the bounty was claimed, false otherwise.
*/
function claimed() public view returns(bool) {
return claimed_;
return _claimed;
}
/**
......@@ -37,22 +37,22 @@ contract BreakInvariantBounty is PullPayment, Ownable {
*/
function createTarget() public returns(Target) {
Target target = Target(_deployContract());
researchers[target] = msg.sender;
_researchers[target] = msg.sender;
emit TargetCreated(target);
return target;
}
/**
* @dev Transfers the contract funds to the researcher that proved the contract is broken.
* @param _target contract
* @param target contract
*/
function claim(Target _target) public {
address researcher = researchers[_target];
function claim(Target target) public {
address researcher = _researchers[target];
require(researcher != address(0));
// Check Target contract invariants
require(!_target.checkInvariant());
require(!target.checkInvariant());
_asyncTransfer(researcher, address(this).balance);
claimed_ = true;
_claimed = true;
}
/**
......
......@@ -22,19 +22,19 @@ contract Crowdsale {
using SafeERC20 for IERC20;
// The token being sold
IERC20 private token_;
IERC20 private _token;
// Address where funds are collected
address private wallet_;
address private _wallet;
// How many token units a buyer gets per wei.
// The rate is the conversion between wei and the smallest and indivisible token unit.
// So, if you are using a rate of 1 with a ERC20Detailed token with 3 decimals called TOK
// 1 wei will give you 1 unit, or 0.001 TOK.
uint256 private rate_;
uint256 private _rate;
// Amount of wei raised
uint256 private weiRaised_;
uint256 private _weiRaised;
/**
* Event for token purchase logging
......@@ -51,21 +51,21 @@ contract Crowdsale {
);
/**
* @param _rate Number of token units a buyer gets per wei
* @param rate Number of token units a buyer gets per wei
* @dev The rate is the conversion between wei and the smallest and indivisible
* token unit. So, if you are using a rate of 1 with a ERC20Detailed token
* with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK.
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
* @param wallet Address where collected funds will be forwarded to
* @param token Address of the token being sold
*/
constructor(uint256 _rate, address _wallet, IERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
constructor(uint256 rate, address wallet, IERC20 token) public {
require(rate > 0);
require(wallet != address(0));
require(token != address(0));
rate_ = _rate;
wallet_ = _wallet;
token_ = _token;
_rate = rate;
_wallet = wallet;
_token = token;
}
// -----------------------------------------
......@@ -83,57 +83,57 @@ contract Crowdsale {
* @return the token being sold.
*/
function token() public view returns(IERC20) {
return token_;
return _token;
}
/**
* @return the address where funds are collected.
*/
function wallet() public view returns(address) {
return wallet_;
return _wallet;
}
/**
* @return the number of token units a buyer gets per wei.
*/
function rate() public view returns(uint256) {
return rate_;
return _rate;
}
/**
* @return the mount of wei raised.
*/
function weiRaised() public view returns (uint256) {
return weiRaised_;
return _weiRaised;
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
* @param beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
function buyTokens(address beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
_preValidatePurchase(beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised_ = weiRaised_.add(weiAmount);
_weiRaised = _weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
_processPurchase(beneficiary, tokens);
emit TokensPurchased(
msg.sender,
_beneficiary,
beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_updatePurchasingState(beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
_postValidatePurchase(beneficiary, weiAmount);
}
// -----------------------------------------
......@@ -143,29 +143,29 @@ contract Crowdsale {
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations.
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
* super._preValidatePurchase(_beneficiary, _weiAmount);
* require(weiRaised().add(_weiAmount) <= cap);
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
* super._preValidatePurchase(beneficiary, weiAmount);
* require(weiRaised().add(weiAmount) <= cap);
* @param beneficiary Address performing the token purchase
* @param weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
address beneficiary,
uint256 weiAmount
)
internal
{
require(_beneficiary != address(0));
require(_weiAmount != 0);
require(beneficiary != address(0));
require(weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
* @param beneficiary Address performing the token purchase
* @param weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(
address _beneficiary,
uint256 _weiAmount
address beneficiary,
uint256 weiAmount
)
internal
{
......@@ -174,40 +174,40 @@ contract Crowdsale {
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
* @param beneficiary Address performing the token purchase
* @param tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
address beneficiary,
uint256 tokenAmount
)
internal
{
token_.safeTransfer(_beneficiary, _tokenAmount);
_token.safeTransfer(beneficiary, tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
* @param beneficiary Address receiving the tokens
* @param tokenAmount Number of tokens to be purchased
*/
function _processPurchase(
address _beneficiary,
uint256 _tokenAmount
address beneficiary,
uint256 tokenAmount
)
internal
{
_deliverTokens(_beneficiary, _tokenAmount);
_deliverTokens(beneficiary, tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
* @param beneficiary Address receiving the tokens
* @param weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(
address _beneficiary,
uint256 _weiAmount
address beneficiary,
uint256 weiAmount
)
internal
{
......@@ -216,19 +216,19 @@ contract Crowdsale {
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @param weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount)
function _getTokenAmount(uint256 weiAmount)
internal view returns (uint256)
{
return _weiAmount.mul(rate_);
return weiAmount.mul(_rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet_.transfer(msg.value);
_wallet.transfer(msg.value);
}
}
......@@ -12,7 +12,7 @@ import "../validation/TimedCrowdsale.sol";
contract FinalizableCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
bool private finalized_ = false;
bool private _finalized = false;
event CrowdsaleFinalized();
......@@ -20,7 +20,7 @@ contract FinalizableCrowdsale is TimedCrowdsale {
* @return true if the crowdsale is finalized, false otherwise.
*/
function finalized() public view returns (bool) {
return finalized_;
return _finalized;
}
/**
......@@ -28,13 +28,13 @@ contract FinalizableCrowdsale is TimedCrowdsale {
* work. Calls the contract's finalization function.
*/
function finalize() public {
require(!finalized_);
require(!_finalized);
require(hasClosed());
_finalization();
emit CrowdsaleFinalized();
finalized_ = true;
_finalized = true;
}
/**
......
......@@ -12,39 +12,39 @@ import "../../math/SafeMath.sol";
contract PostDeliveryCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
mapping(address => uint256) private balances_;
mapping(address => uint256) private _balances;
/**
* @dev Withdraw tokens only after crowdsale ends.
* @param _beneficiary Whose tokens will be withdrawn.
* @param beneficiary Whose tokens will be withdrawn.
*/
function withdrawTokens(address _beneficiary) public {
function withdrawTokens(address beneficiary) public {
require(hasClosed());
uint256 amount = balances_[_beneficiary];
uint256 amount = _balances[beneficiary];
require(amount > 0);
balances_[_beneficiary] = 0;
_deliverTokens(_beneficiary, amount);
_balances[beneficiary] = 0;
_deliverTokens(beneficiary, amount);
}
/**
* @return the balance of an account.
*/
function balanceOf(address _account) public view returns(uint256) {
return balances_[_account];
function balanceOf(address account) public view returns(uint256) {
return _balances[account];
}
/**
* @dev Overrides parent by storing balances instead of issuing tokens right away.
* @param _beneficiary Token purchaser
* @param _tokenAmount Amount of tokens purchased
* @param beneficiary Token purchaser
* @param tokenAmount Amount of tokens purchased
*/
function _processPurchase(
address _beneficiary,
uint256 _tokenAmount
address beneficiary,
uint256 tokenAmount
)
internal
{
balances_[_beneficiary] = balances_[_beneficiary].add(_tokenAmount);
_balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
}
}
......@@ -15,37 +15,37 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
using SafeMath for uint256;
// minimum amount of funds to be raised in weis
uint256 private goal_;
uint256 private _goal;
// refund escrow used to hold funds while crowdsale is running
RefundEscrow private escrow_;
RefundEscrow private _escrow;
/**
* @dev Constructor, creates RefundEscrow.
* @param _goal Funding goal
* @param goal Funding goal
*/
constructor(uint256 _goal) public {
require(_goal > 0);
escrow_ = new RefundEscrow(wallet());
goal_ = _goal;
constructor(uint256 goal) public {
require(goal > 0);
_escrow = new RefundEscrow(wallet());
_goal = goal;
}
/**
* @return minimum amount of funds to be raised in wei.
*/
function goal() public view returns(uint256) {
return goal_;
return _goal;
}
/**
* @dev Investors can claim refunds here if crowdsale is unsuccessful
* @param _beneficiary Whose refund will be claimed.
* @param beneficiary Whose refund will be claimed.
*/
function claimRefund(address _beneficiary) public {
function claimRefund(address beneficiary) public {
require(finalized());
require(!goalReached());
escrow_.withdraw(_beneficiary);
_escrow.withdraw(beneficiary);
}
/**
......@@ -53,7 +53,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
* @return Whether funding goal was reached
*/
function goalReached() public view returns (bool) {
return weiRaised() >= goal_;
return weiRaised() >= _goal;
}
/**
......@@ -61,10 +61,10 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
*/
function _finalization() internal {
if (goalReached()) {
escrow_.close();
escrow_.beneficiaryWithdraw();
_escrow.close();
_escrow.beneficiaryWithdraw();
} else {
escrow_.enableRefunds();
_escrow.enableRefunds();
}
super._finalization();
......@@ -74,7 +74,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
* @dev Overrides Crowdsale fund forwarding, sending funds to escrow.
*/
function _forwardFunds() internal {
escrow_.deposit.value(msg.value)(msg.sender);
_escrow.deposit.value(msg.value)(msg.sender);
}
}
......@@ -14,22 +14,22 @@ contract AllowanceCrowdsale is Crowdsale {
using SafeMath for uint256;
using SafeERC20 for IERC20;
address private tokenWallet_;
address private _tokenWallet;
/**
* @dev Constructor, takes token wallet address.
* @param _tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
* @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/
constructor(address _tokenWallet) public {
require(_tokenWallet != address(0));
tokenWallet_ = _tokenWallet;
constructor(address tokenWallet) public {
require(tokenWallet != address(0));
_tokenWallet = tokenWallet;
}
/**
* @return the address of the wallet that will hold the tokens.
*/
function tokenWallet() public view returns(address) {
return tokenWallet_;
return _tokenWallet;
}
/**
......@@ -37,20 +37,20 @@ contract AllowanceCrowdsale is Crowdsale {
* @return Amount of tokens left in the allowance
*/
function remainingTokens() public view returns (uint256) {
return token().allowance(tokenWallet_, this);
return token().allowance(_tokenWallet, this);
}
/**
* @dev Overrides parent behavior by transferring tokens from wallet.
* @param _beneficiary Token purchaser
* @param _tokenAmount Amount of tokens purchased
* @param beneficiary Token purchaser
* @param tokenAmount Amount of tokens purchased
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
address beneficiary,
uint256 tokenAmount
)
internal
{
token().safeTransferFrom(tokenWallet_, _beneficiary, _tokenAmount);
token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount);
}
}
......@@ -13,17 +13,17 @@ contract MintedCrowdsale is Crowdsale {
/**
* @dev Overrides delivery by minting tokens upon purchase.
* @param _beneficiary Token purchaser
* @param _tokenAmount Number of tokens to be minted
* @param beneficiary Token purchaser
* @param tokenAmount Number of tokens to be minted
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
address beneficiary,
uint256 tokenAmount
)
internal
{
// Potentially dangerous assumption about the type of the token.
require(
ERC20Mintable(address(token())).mint(_beneficiary, _tokenAmount));
ERC20Mintable(address(token())).mint(beneficiary, tokenAmount));
}
}
......@@ -13,33 +13,33 @@ import "../../math/SafeMath.sol";
contract IncreasingPriceCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
uint256 private initialRate_;
uint256 private finalRate_;
uint256 private _initialRate;
uint256 private _finalRate;
/**
* @dev Constructor, takes initial and final rates of tokens received per wei contributed.
* @param _initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
* @param _finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
* @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
* @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
*/
constructor(uint256 _initialRate, uint256 _finalRate) public {
require(_finalRate > 0);
require(_initialRate >= _finalRate);
initialRate_ = _initialRate;
finalRate_ = _finalRate;
constructor(uint256 initialRate, uint256 finalRate) public {
require(finalRate > 0);
require(initialRate >= finalRate);
_initialRate = initialRate;
_finalRate = finalRate;
}
/**
* @return the initial rate of the crowdsale.
*/
function initialRate() public view returns(uint256) {
return initialRate_;
return _initialRate;
}
/**
* @return the final rate of the crowdsale.
*/
function finalRate() public view returns (uint256) {
return finalRate_;
return _finalRate;
}
/**
......@@ -51,20 +51,20 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
// solium-disable-next-line security/no-block-members
uint256 elapsedTime = block.timestamp.sub(openingTime());
uint256 timeRange = closingTime().sub(openingTime());
uint256 rateRange = initialRate_.sub(finalRate_);
return initialRate_.sub(elapsedTime.mul(rateRange).div(timeRange));
uint256 rateRange = _initialRate.sub(_finalRate);
return _initialRate.sub(elapsedTime.mul(rateRange).div(timeRange));
}
/**
* @dev Overrides parent method taking into account variable rate.
* @param _weiAmount The value in wei to be converted into tokens
* @param weiAmount The value in wei to be converted into tokens
* @return The number of tokens _weiAmount wei will buy at present time
*/
function _getTokenAmount(uint256 _weiAmount)
function _getTokenAmount(uint256 weiAmount)
internal view returns (uint256)
{
uint256 currentRate = getCurrentRate();
return currentRate.mul(_weiAmount);
return currentRate.mul(weiAmount);
}
}
......@@ -11,22 +11,22 @@ import "../Crowdsale.sol";
contract CappedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 private cap_;
uint256 private _cap;
/**
* @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
* @param _cap Max amount of wei to be contributed
* @param cap Max amount of wei to be contributed
*/
constructor(uint256 _cap) public {
require(_cap > 0);
cap_ = _cap;
constructor(uint256 cap) public {
require(cap > 0);
_cap = cap;
}
/**
* @return the cap of the crowdsale.
*/
function cap() public view returns(uint256) {
return cap_;
return _cap;
}
/**
......@@ -34,22 +34,22 @@ contract CappedCrowdsale is Crowdsale {
* @return Whether the cap was reached
*/
function capReached() public view returns (bool) {
return weiRaised() >= cap_;
return weiRaised() >= _cap;
}
/**
* @dev Extend parent behavior requiring purchase to respect the funding cap.
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
* @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
address beneficiary,
uint256 weiAmount
)
internal
{
super._preValidatePurchase(_beneficiary, _weiAmount);
require(weiRaised().add(_weiAmount) <= cap_);
super._preValidatePurchase(beneficiary, weiAmount);
require(weiRaised().add(weiAmount) <= _cap);
}
}
......@@ -12,68 +12,68 @@ import "../../access/roles/CapperRole.sol";
contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
using SafeMath for uint256;
mapping(address => uint256) private contributions_;
mapping(address => uint256) private caps_;
mapping(address => uint256) private _contributions;
mapping(address => uint256) private _caps;
/**
* @dev Sets a specific beneficiary's maximum contribution.
* @param _beneficiary Address to be capped
* @param _cap Wei limit for individual contribution
* @param beneficiary Address to be capped
* @param cap Wei limit for individual contribution
*/
function setCap(address _beneficiary, uint256 _cap) external onlyCapper {
caps_[_beneficiary] = _cap;
function setCap(address beneficiary, uint256 cap) external onlyCapper {
_caps[beneficiary] = cap;
}
/**
* @dev Returns the cap of a specific beneficiary.
* @param _beneficiary Address whose cap is to be checked
* @param beneficiary Address whose cap is to be checked
* @return Current cap for individual beneficiary
*/
function getCap(address _beneficiary) public view returns (uint256) {
return caps_[_beneficiary];
function getCap(address beneficiary) public view returns (uint256) {
return _caps[beneficiary];
}
/**
* @dev Returns the amount contributed so far by a specific beneficiary.
* @param _beneficiary Address of contributor
* @param beneficiary Address of contributor
* @return Beneficiary contribution so far
*/
function getContribution(address _beneficiary)
function getContribution(address beneficiary)
public view returns (uint256)
{
return contributions_[_beneficiary];
return _contributions[beneficiary];
}
/**
* @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap.
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
* @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
address beneficiary,
uint256 weiAmount
)
internal
{
super._preValidatePurchase(_beneficiary, _weiAmount);
super._preValidatePurchase(beneficiary, weiAmount);
require(
contributions_[_beneficiary].add(_weiAmount) <= caps_[_beneficiary]);
_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]);
}
/**
* @dev Extend parent behavior to update beneficiary contributions
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
* @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed
*/
function _updatePurchasingState(
address _beneficiary,
uint256 _weiAmount
address beneficiary,
uint256 weiAmount
)
internal
{
super._updatePurchasingState(_beneficiary, _weiAmount);
contributions_[_beneficiary] = contributions_[_beneficiary].add(
_weiAmount);
super._updatePurchasingState(beneficiary, weiAmount);
_contributions[beneficiary] = _contributions[beneficiary].add(
weiAmount);
}
}
......@@ -11,8 +11,8 @@ import "../Crowdsale.sol";
contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 private openingTime_;
uint256 private closingTime_;
uint256 private _openingTime;
uint256 private _closingTime;
/**
* @dev Reverts if not in crowdsale time range.
......@@ -24,30 +24,30 @@ contract TimedCrowdsale is Crowdsale {
/**
* @dev Constructor, takes crowdsale opening and closing times.
* @param _openingTime Crowdsale opening time
* @param _closingTime Crowdsale closing time
* @param openingTime Crowdsale opening time
* @param closingTime Crowdsale closing time
*/
constructor(uint256 _openingTime, uint256 _closingTime) public {
constructor(uint256 openingTime, uint256 closingTime) public {
// solium-disable-next-line security/no-block-members
require(_openingTime >= block.timestamp);
require(_closingTime >= _openingTime);
require(openingTime >= block.timestamp);
require(closingTime >= openingTime);
openingTime_ = _openingTime;
closingTime_ = _closingTime;
_openingTime = openingTime;
_closingTime = closingTime;
}
/**
* @return the crowdsale opening time.
*/
function openingTime() public view returns(uint256) {
return openingTime_;
return _openingTime;
}
/**
* @return the crowdsale closing time.
*/
function closingTime() public view returns(uint256) {
return closingTime_;
return _closingTime;
}
/**
......@@ -55,7 +55,7 @@ contract TimedCrowdsale is Crowdsale {
*/
function isOpen() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp >= openingTime_ && block.timestamp <= closingTime_;
return block.timestamp >= _openingTime && block.timestamp <= _closingTime;
}
/**
......@@ -64,22 +64,22 @@ contract TimedCrowdsale is Crowdsale {
*/
function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp > closingTime_;
return block.timestamp > _closingTime;
}
/**
* @dev Extend parent behavior requiring to be within contributing period
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
* @param beneficiary Token purchaser
* @param weiAmount Amount of wei contributed
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
address beneficiary,
uint256 weiAmount
)
internal
onlyWhileOpen
{
super._preValidatePurchase(_beneficiary, _weiAmount);
super._preValidatePurchase(beneficiary, weiAmount);
}
}
......@@ -12,10 +12,10 @@ library ECDSA {
/**
* @dev Recover signer address from a message by using their signature
* @param _hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
* @param _signature bytes signature, the signature is generated using web3.eth.sign()
* @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address.
* @param signature bytes signature, the signature is generated using web3.eth.sign()
*/
function recover(bytes32 _hash, bytes _signature)
function recover(bytes32 hash, bytes signature)
internal
pure
returns (address)
......@@ -25,7 +25,7 @@ library ECDSA {
uint8 v;
// Check the signature length
if (_signature.length != 65) {
if (signature.length != 65) {
return (address(0));
}
......@@ -34,9 +34,9 @@ library ECDSA {
// currently is to use assembly.
// solium-disable-next-line security/no-inline-assembly
assembly {
r := mload(add(_signature, 32))
s := mload(add(_signature, 64))
v := byte(0, mload(add(_signature, 96)))
r := mload(add(signature, 32))
s := mload(add(signature, 64))
v := byte(0, mload(add(signature, 96)))
}
// Version of signature should be 27 or 28, but 0 and 1 are also possible versions
......@@ -49,7 +49,7 @@ library ECDSA {
return (address(0));
} else {
// solium-disable-next-line arg-overflow
return ecrecover(_hash, v, r, s);
return ecrecover(hash, v, r, s);
}
}
......@@ -58,7 +58,7 @@ library ECDSA {
* @dev prefix a bytes32 value with "\x19Ethereum Signed Message:"
* and hash the result
*/
function toEthSignedMessageHash(bytes32 _hash)
function toEthSignedMessageHash(bytes32 hash)
internal
pure
returns (bytes32)
......@@ -66,7 +66,7 @@ library ECDSA {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(
abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)
abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)
);
}
}
......@@ -10,23 +10,23 @@ library MerkleProof {
/**
* @dev Verifies a Merkle proof proving the existence of a leaf in a Merkle tree. Assumes that each pair of leaves
* and each pair of pre-images are sorted.
* @param _proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree
* @param _root Merkle root
* @param _leaf Leaf of Merkle tree
* @param proof Merkle proof containing sibling hashes on the branch from the leaf to the root of the Merkle tree
* @param root Merkle root
* @param leaf Leaf of Merkle tree
*/
function verify(
bytes32[] _proof,
bytes32 _root,
bytes32 _leaf
bytes32[] proof,
bytes32 root,
bytes32 leaf
)
internal
pure
returns (bool)
{
bytes32 computedHash = _leaf;
bytes32 computedHash = leaf;
for (uint256 i = 0; i < _proof.length; i++) {
bytes32 proofElement = _proof[i];
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash < proofElement) {
// Hash(current computed hash + current element of the proof)
......@@ -38,6 +38,6 @@ library MerkleProof {
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == _root;
return computedHash == root;
}
}
......@@ -15,15 +15,15 @@ contract ERC20TokenMetadata is IERC20 {
contract ERC20WithMetadata is ERC20TokenMetadata {
string private tokenURI_ = "";
string private _tokenURI = "";
constructor(string _tokenURI)
constructor(string tokenURI)
public
{
tokenURI_ = _tokenURI;
_tokenURI = tokenURI;
}
function tokenURI() external view returns (string) {
return tokenURI_;
return _tokenURI;
}
}
......@@ -33,34 +33,34 @@ contract SignatureBouncer is SignerRole {
// Function selectors are 4 bytes long, as documented in
// https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector
uint256 private constant METHOD_ID_SIZE = 4;
uint256 private constant _METHOD_ID_SIZE = 4;
// Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes
uint256 private constant SIGNATURE_SIZE = 96;
uint256 private constant _SIGNATURE_SIZE = 96;
/**
* @dev requires that a valid signature of a signer was provided
*/
modifier onlyValidSignature(bytes _signature)
modifier onlyValidSignature(bytes signature)
{
require(_isValidSignature(msg.sender, _signature));
require(_isValidSignature(msg.sender, signature));
_;
}
/**
* @dev requires that a valid signature with a specifed method of a signer was provided
*/
modifier onlyValidSignatureAndMethod(bytes _signature)
modifier onlyValidSignatureAndMethod(bytes signature)
{
require(_isValidSignatureAndMethod(msg.sender, _signature));
require(_isValidSignatureAndMethod(msg.sender, signature));
_;
}
/**
* @dev requires that a valid signature with a specifed method and params of a signer was provided
*/
modifier onlyValidSignatureAndData(bytes _signature)
modifier onlyValidSignatureAndData(bytes signature)
{
require(_isValidSignatureAndData(msg.sender, _signature));
require(_isValidSignatureAndData(msg.sender, signature));
_;
}
......@@ -68,14 +68,14 @@ contract SignatureBouncer is SignerRole {
* @dev is the signature of `this + sender` from a signer?
* @return bool
*/
function _isValidSignature(address _address, bytes _signature)
function _isValidSignature(address account, bytes signature)
internal
view
returns (bool)
{
return _isValidDataHash(
keccak256(abi.encodePacked(address(this), _address)),
_signature
keccak256(abi.encodePacked(address(this), account)),
signature
);
}
......@@ -83,39 +83,39 @@ contract SignatureBouncer is SignerRole {
* @dev is the signature of `this + sender + methodId` from a signer?
* @return bool
*/
function _isValidSignatureAndMethod(address _address, bytes _signature)
function _isValidSignatureAndMethod(address account, bytes signature)
internal
view
returns (bool)
{
bytes memory data = new bytes(METHOD_ID_SIZE);
bytes memory data = new bytes(_METHOD_ID_SIZE);
for (uint i = 0; i < data.length; i++) {
data[i] = msg.data[i];
}
return _isValidDataHash(
keccak256(abi.encodePacked(address(this), _address, data)),
_signature
keccak256(abi.encodePacked(address(this), account, data)),
signature
);
}
/**
* @dev is the signature of `this + sender + methodId + params(s)` from a signer?
* @notice the _signature parameter of the method being validated must be the "last" parameter
* @notice the signature parameter of the method being validated must be the "last" parameter
* @return bool
*/
function _isValidSignatureAndData(address _address, bytes _signature)
function _isValidSignatureAndData(address account, bytes signature)
internal
view
returns (bool)
{
require(msg.data.length > SIGNATURE_SIZE);
bytes memory data = new bytes(msg.data.length - SIGNATURE_SIZE);
require(msg.data.length > _SIGNATURE_SIZE);
bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE);
for (uint i = 0; i < data.length; i++) {
data[i] = msg.data[i];
}
return _isValidDataHash(
keccak256(abi.encodePacked(address(this), _address, data)),
_signature
keccak256(abi.encodePacked(address(this), account, data)),
signature
);
}
......@@ -124,14 +124,14 @@ contract SignatureBouncer is SignerRole {
* and then recover the signature and check it against the signer role
* @return bool
*/
function _isValidDataHash(bytes32 _hash, bytes _signature)
function _isValidDataHash(bytes32 hash, bytes signature)
internal
view
returns (bool)
{
address signer = _hash
address signer = hash
.toEthSignedMessageHash()
.recover(_signature);
.recover(signature);
return isSigner(signer);
}
}
......@@ -21,107 +21,107 @@ contract TokenVesting is Ownable {
event Revoked();
// beneficiary of tokens after they are released
address private beneficiary_;
address private _beneficiary;
uint256 private cliff_;
uint256 private start_;
uint256 private duration_;
uint256 private _cliff;
uint256 private _start;
uint256 private _duration;
bool private revocable_;
bool private _revocable;
mapping (address => uint256) private released_;
mapping (address => bool) private 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
* _beneficiary, gradually in a linear fashion until _start + _duration. By then all
* beneficiary, gradually in a linear fashion until start + duration. By then all
* of the balance will have vested.
* @param _beneficiary address of the beneficiary to whom vested tokens are transferred
* @param _cliffDuration duration in seconds of the cliff in which tokens will begin to vest
* @param _start the time (as Unix time) at which point vesting starts
* @param _duration duration in seconds of the period in which the tokens will vest
* @param _revocable whether the vesting is revocable or not
* @param beneficiary address of the beneficiary to whom vested tokens are transferred
* @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest
* @param start the time (as Unix time) at which point vesting starts
* @param duration duration in seconds of the period in which the tokens will vest
* @param revocable whether the vesting is revocable or not
*/
constructor(
address _beneficiary,
uint256 _start,
uint256 _cliffDuration,
uint256 _duration,
bool _revocable
address beneficiary,
uint256 start,
uint256 cliffDuration,
uint256 duration,
bool revocable
)
public
{
require(_beneficiary != address(0));
require(_cliffDuration <= _duration);
beneficiary_ = _beneficiary;
revocable_ = _revocable;
duration_ = _duration;
cliff_ = _start.add(_cliffDuration);
start_ = _start;
require(beneficiary != address(0));
require(cliffDuration <= duration);
_beneficiary = beneficiary;
_revocable = revocable;
_duration = duration;
_cliff = start.add(cliffDuration);
_start = start;
}
/**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view returns(address) {
return beneficiary_;
return _beneficiary;
}
/**
* @return the cliff time of the token vesting.
*/
function cliff() public view returns(uint256) {
return cliff_;
return _cliff;
}
/**
* @return the start time of the token vesting.
*/
function start() public view returns(uint256) {
return start_;
return _start;
}
/**
* @return the duration of the token vesting.
*/
function duration() public view returns(uint256) {
return duration_;
return _duration;
}
/**
* @return true if the vesting is revocable.
*/
function revocable() public view returns(bool) {
return revocable_;
return _revocable;
}
/**
* @return the amount of the token released.
*/
function released(address _token) public view returns(uint256) {
return released_[_token];
function released(address token) public view returns(uint256) {
return _released[token];
}
/**
* @return true if the token is revoked.
*/
function revoked(address _token) public view returns(bool) {
return revoked_[_token];
function revoked(address token) public view returns(bool) {
return _revoked[token];
}
/**
* @notice Transfers vested tokens to beneficiary.
* @param _token ERC20 token which is being vested
* @param token ERC20 token which is being vested
*/
function release(IERC20 _token) public {
uint256 unreleased = releasableAmount(_token);
function release(IERC20 token) public {
uint256 unreleased = releasableAmount(token);
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);
}
......@@ -129,46 +129,46 @@ contract TokenVesting is Ownable {
/**
* @notice Allows the owner to revoke the vesting. Tokens already vested
* remain in the contract, the rest are returned to the owner.
* @param _token ERC20 token which is being vested
* @param token ERC20 token which is being vested
*/
function revoke(IERC20 _token) public onlyOwner {
require(revocable_);
require(!revoked_[_token]);
function revoke(IERC20 token) public onlyOwner {
require(_revocable);
require(!_revoked[token]);
uint256 balance = _token.balanceOf(address(this));
uint256 balance = token.balanceOf(address(this));
uint256 unreleased = releasableAmount(_token);
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
revoked_[_token] = true;
_revoked[token] = true;
_token.safeTransfer(owner(), refund);
token.safeTransfer(owner(), refund);
emit Revoked();
}
/**
* @dev Calculates the amount that has already vested but hasn't been released yet.
* @param _token ERC20 token which is being vested
* @param token ERC20 token which is being vested
*/
function releasableAmount(IERC20 _token) public view returns (uint256) {
return vestedAmount(_token).sub(released_[_token]);
function releasableAmount(IERC20 token) public view returns (uint256) {
return vestedAmount(token).sub(_released[token]);
}
/**
* @dev Calculates the amount that has already vested.
* @param _token ERC20 token which is being vested
* @param token ERC20 token which is being vested
*/
function vestedAmount(IERC20 _token) public view returns (uint256) {
uint256 currentBalance = _token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released_[_token]);
function vestedAmount(IERC20 token) public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
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);
}
}
}
......@@ -38,22 +38,22 @@ contract SampleCrowdsaleToken is ERC20Mintable {
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
constructor(
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
address _wallet,
uint256 _cap,
ERC20Mintable _token,
uint256 _goal
uint256 openingTime,
uint256 closingTime,
uint256 rate,
address wallet,
uint256 cap,
ERC20Mintable token,
uint256 goal
)
public
Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap)
TimedCrowdsale(_openingTime, _closingTime)
RefundableCrowdsale(_goal)
Crowdsale(rate, wallet, token)
CappedCrowdsale(cap)
TimedCrowdsale(openingTime, closingTime)
RefundableCrowdsale(goal)
{
//As goal needs to be met for a successful crowdsale
//the value needs to less or equal than a cap which is limit for accepted funds
require(_goal <= _cap);
require(goal <= cap);
}
}
......@@ -10,7 +10,7 @@ import "./IERC165.sol";
*/
contract ERC165 is IERC165 {
bytes4 private constant InterfaceId_ERC165 = 0x01ffc9a7;
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
/**
* 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)'))
......@@ -19,7 +19,7 @@ contract ERC165 is IERC165 {
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) internal supportedInterfaces_;
mapping(bytes4 => bool) internal _supportedInterfaces;
/**
* @dev A contract implementing SupportsInterfaceWithLookup
......@@ -28,27 +28,27 @@ contract ERC165 is IERC165 {
constructor()
public
{
_registerInterface(InterfaceId_ERC165);
_registerInterface(_InterfaceId_ERC165);
}
/**
* @dev implement supportsInterface(bytes4) using a lookup table
*/
function supportsInterface(bytes4 _interfaceId)
function supportsInterface(bytes4 interfaceId)
external
view
returns (bool)
{
return supportedInterfaces_[_interfaceId];
return _supportedInterfaces[interfaceId];
}
/**
* @dev private method for registering an interface
*/
function _registerInterface(bytes4 _interfaceId)
function _registerInterface(bytes4 interfaceId)
internal
{
require(_interfaceId != 0xffffffff);
supportedInterfaces_[_interfaceId] = true;
require(interfaceId != 0xffffffff);
_supportedInterfaces[interfaceId] = true;
}
}
......@@ -8,9 +8,9 @@ pragma solidity ^0.4.24;
*/
library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant InterfaceId_Invalid = 0xffffffff;
bytes4 private constant _InterfaceId_Invalid = 0xffffffff;
bytes4 private constant InterfaceId_ERC165 = 0x01ffc9a7;
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
/**
* 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)'))
......@@ -19,59 +19,59 @@ library ERC165Checker {
/**
* @notice Query if a contract supports ERC165
* @param _address The address of the contract to query for support of ERC165
* @return true if the contract at _address implements ERC165
* @param account The address of the contract to query for support of ERC165
* @return true if the contract at account implements ERC165
*/
function supportsERC165(address _address)
function supportsERC165(address account)
internal
view
returns (bool)
{
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return supportsERC165Interface(_address, InterfaceId_ERC165) &&
!supportsERC165Interface(_address, InterfaceId_Invalid);
return supportsERC165Interface(account, _InterfaceId_ERC165) &&
!supportsERC165Interface(account, _InterfaceId_Invalid);
}
/**
* @notice Query if a contract implements an interface, also checks support of ERC165
* @param _address The address of the contract to query for support of an interface
* @param _interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at _address indicates support of the interface with
* identifier _interfaceId, false otherwise
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Interface identification is specified in ERC-165.
*/
function supportsInterface(address _address, bytes4 _interfaceId)
function supportsInterface(address account, bytes4 interfaceId)
internal
view
returns (bool)
{
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(_address) &&
supportsERC165Interface(_address, _interfaceId);
return supportsERC165(account) &&
supportsERC165Interface(account, interfaceId);
}
/**
* @notice Query if a contract implements interfaces, also checks support of ERC165
* @param _address The address of the contract to query for support of an interface
* @param _interfaceIds A list of interface identifiers, as specified in ERC-165
* @return true if the contract at _address indicates support all interfaces in the
* _interfaceIds list, false otherwise
* @param account The address of the contract to query for support of an interface
* @param interfaceIds A list of interface identifiers, as specified in ERC-165
* @return true if the contract at account indicates support all interfaces in the
* interfaceIds list, false otherwise
* @dev Interface identification is specified in ERC-165.
*/
function supportsInterfaces(address _address, bytes4[] _interfaceIds)
function supportsInterfaces(address account, bytes4[] interfaceIds)
internal
view
returns (bool)
{
// query support of ERC165 itself
if (!supportsERC165(_address)) {
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in _interfaceIds
for (uint256 i = 0; i < _interfaceIds.length; i++) {
if (!supportsERC165Interface(_address, _interfaceIds[i])) {
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!supportsERC165Interface(account, interfaceIds[i])) {
return false;
}
}
......@@ -82,47 +82,47 @@ library ERC165Checker {
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param _address The address of the contract to query for support of an interface
* @param _interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at _address indicates support of the interface with
* identifier _interfaceId, false otherwise
* @dev Assumes that _address contains a contract that supports ERC165, otherwise
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with the `supportsERC165` method in this library.
* Interface identification is specified in ERC-165.
*/
function supportsERC165Interface(address _address, bytes4 _interfaceId)
function supportsERC165Interface(address account, bytes4 interfaceId)
private
view
returns (bool)
{
// success determines whether the staticcall succeeded and result determines
// whether the contract at _address indicates support of _interfaceId
// whether the contract at account indicates support of _interfaceId
(bool success, bool result) = callERC165SupportsInterface(
_address, _interfaceId);
account, interfaceId);
return (success && result);
}
/**
* @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
* @param _address The address of the contract to query for support of an interface
* @param _interfaceId The interface identifier, as specified in ERC-165
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return success true if the STATICCALL succeeded, false otherwise
* @return result true if the STATICCALL succeeded and the contract at _address
* indicates support of the interface with identifier _interfaceId, false otherwise
* @return result true if the STATICCALL succeeded and the contract at account
* indicates support of the interface with identifier interfaceId, false otherwise
*/
function callERC165SupportsInterface(
address _address,
bytes4 _interfaceId
address account,
bytes4 interfaceId
)
private
view
returns (bool success, bool result)
{
bytes memory encodedParams = abi.encodeWithSelector(
InterfaceId_ERC165,
_interfaceId
_InterfaceId_ERC165,
interfaceId
);
// solium-disable-next-line security/no-inline-assembly
......@@ -135,7 +135,7 @@ library ERC165Checker {
success := staticcall(
30000, // 30k gas
_address, // To addr
account, // To addr
encodedParams_data,
encodedParams_size,
output,
......@@ -146,4 +146,3 @@ library ERC165Checker {
}
}
}
......@@ -9,11 +9,11 @@ interface IERC165 {
/**
* @notice Query if a contract implements an interface
* @param _interfaceId The interface identifier, as specified in ERC-165
* @param interfaceId The interface identifier, as specified in ERC-165
* @dev Interface identification is specified in ERC-165. This function
* uses less than 30,000 gas.
*/
function supportsInterface(bytes4 _interfaceId)
function supportsInterface(bytes4 interfaceId)
external
view
returns (bool);
......
......@@ -11,21 +11,21 @@ contract Pausable is PauserRole {
event Paused();
event Unpaused();
bool private paused_ = false;
bool private _paused = false;
/**
* @return true if the contract is paused, false otherwise.
*/
function paused() public view returns(bool) {
return paused_;
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused_);
require(!_paused);
_;
}
......@@ -33,7 +33,7 @@ contract Pausable is PauserRole {
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused_);
require(_paused);
_;
}
......@@ -41,7 +41,7 @@ contract Pausable is PauserRole {
* @dev called by the owner to pause, triggers stopped state
*/
function pause() public onlyPauser whenNotPaused {
paused_ = true;
_paused = true;
emit Paused();
}
......@@ -49,7 +49,7 @@ contract Pausable is PauserRole {
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() public onlyPauser whenPaused {
paused_ = false;
_paused = false;
emit Unpaused();
}
}
......@@ -6,16 +6,16 @@ pragma solidity ^0.4.24;
* @dev Assorted math operations
*/
library Math {
function max(uint256 _a, uint256 _b) internal pure returns (uint256) {
return _a >= _b ? _a : _b;
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function min(uint256 _a, uint256 _b) internal pure returns (uint256) {
return _a < _b ? _a : _b;
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 _a, uint256 _b) internal pure returns (uint256) {
// (_a + _b) / 2 can overflow, so we distribute
return (_a / 2) + (_b / 2) + ((_a % 2 + _b % 2) / 2);
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
......@@ -10,16 +10,16 @@ library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
if (a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
uint256 c = a * b;
require(c / a == b);
return c;
}
......@@ -27,10 +27,10 @@ library SafeMath {
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
......@@ -38,9 +38,9 @@ library SafeMath {
/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
uint256 c = _a - _b;
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
......@@ -48,9 +48,9 @@ library SafeMath {
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
......
......@@ -7,14 +7,14 @@ import "../crowdsale/emission/AllowanceCrowdsale.sol";
contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
constructor (
uint256 _rate,
address _wallet,
IERC20 _token,
address _tokenWallet
uint256 rate,
address wallet,
IERC20 token,
address tokenWallet
)
public
Crowdsale(_rate, _wallet, _token)
AllowanceCrowdsale(_tokenWallet)
Crowdsale(rate, wallet, token)
AllowanceCrowdsale(tokenWallet)
{
}
......
......@@ -9,13 +9,13 @@ contract AutoIncrementingImpl {
uint256 public theId;
// use whatever key you want to track your counters
mapping(string => AutoIncrementing.Counter) private counters;
mapping(string => AutoIncrementing.Counter) private _counters;
function doThing(string _key)
function doThing(string key)
public
returns (uint256)
{
theId = counters[_key].nextId();
theId = _counters[key].nextId();
return theId;
}
}
......@@ -7,14 +7,14 @@ import "../crowdsale/validation/CappedCrowdsale.sol";
contract CappedCrowdsaleImpl is CappedCrowdsale {
constructor (
uint256 _rate,
address _wallet,
IERC20 _token,
uint256 _cap
uint256 rate,
address wallet,
IERC20 token,
uint256 cap
)
public
Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap)
Crowdsale(rate, wallet, token)
CappedCrowdsale(cap)
{
}
......
......@@ -4,15 +4,15 @@ import "../access/roles/CapperRole.sol";
contract CapperRoleMock is CapperRole {
function removeCapper(address _account) public {
_removeCapper(_account);
function removeCapper(address account) public {
_removeCapper(account);
}
function onlyCapperMock() public view onlyCapper {
}
// Causes a compilation error if super._removeCapper is not internal
function _removeCapper(address _account) internal {
super._removeCapper(_account);
function _removeCapper(address account) internal {
super._removeCapper(account);
}
}
......@@ -6,13 +6,13 @@ import "../payment/ConditionalEscrow.sol";
// mock class using ConditionalEscrow
contract ConditionalEscrowMock is ConditionalEscrow {
mapping(address => bool) public allowed;
mapping(address => bool) private _allowed;
function setAllowed(address _payee, bool _allowed) public {
allowed[_payee] = _allowed;
function setAllowed(address payee, bool allowed) public {
_allowed[payee] = allowed;
}
function withdrawalAllowed(address _payee) public view returns (bool) {
return allowed[_payee];
function withdrawalAllowed(address payee) public view returns (bool) {
return _allowed[payee];
}
}
......@@ -6,11 +6,11 @@ import "../token/ERC20/ERC20Detailed.sol";
contract ERC20DetailedMock is ERC20, ERC20Detailed {
constructor(
string _name,
string _symbol,
uint8 _decimals
string name,
string symbol,
uint8 decimals
)
ERC20Detailed(_name, _symbol, _decimals)
ERC20Detailed(name, symbol, decimals)
public
{}
}
......@@ -7,19 +7,19 @@ import "../cryptography/ECDSA.sol";
contract ECDSAMock {
using ECDSA for bytes32;
function recover(bytes32 _hash, bytes _signature)
function recover(bytes32 hash, bytes signature)
public
pure
returns (address)
{
return _hash.recover(_signature);
return hash.recover(signature);
}
function toEthSignedMessageHash(bytes32 _hash)
function toEthSignedMessageHash(bytes32 hash)
public
pure
returns (bytes32)
{
return _hash.toEthSignedMessageHash();
return hash.toEthSignedMessageHash();
}
}
......@@ -37,33 +37,33 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
/**
* @dev implement supportsInterface(bytes4) using a lookup table
*/
function supportsInterface(bytes4 _interfaceId)
function supportsInterface(bytes4 interfaceId)
external
view
returns (bool)
{
return supportedInterfaces[_interfaceId];
return supportedInterfaces[interfaceId];
}
/**
* @dev private method for registering an interface
*/
function _registerInterface(bytes4 _interfaceId)
function _registerInterface(bytes4 interfaceId)
internal
{
require(_interfaceId != 0xffffffff);
supportedInterfaces[_interfaceId] = true;
require(interfaceId != 0xffffffff);
supportedInterfaces[interfaceId] = true;
}
}
contract ERC165InterfacesSupported is SupportsInterfaceWithLookupMock {
constructor (bytes4[] _interfaceIds)
constructor (bytes4[] interfaceIds)
public
{
for (uint256 i = 0; i < _interfaceIds.length; i++) {
_registerInterface(_interfaceIds[i]);
for (uint256 i = 0; i < interfaceIds.length; i++) {
_registerInterface(interfaceIds[i]);
}
}
}
......@@ -6,27 +6,27 @@ import "../introspection/ERC165Checker.sol";
contract ERC165CheckerMock {
using ERC165Checker for address;
function supportsERC165(address _address)
function supportsERC165(address account)
public
view
returns (bool)
{
return _address.supportsERC165();
return account.supportsERC165();
}
function supportsInterface(address _address, bytes4 _interfaceId)
function supportsInterface(address account, bytes4 interfaceId)
public
view
returns (bool)
{
return _address.supportsInterface(_interfaceId);
return account.supportsInterface(interfaceId);
}
function supportsInterfaces(address _address, bytes4[] _interfaceIds)
function supportsInterfaces(address account, bytes4[] interfaceIds)
public
view
returns (bool)
{
return _address.supportsInterfaces(_interfaceIds);
return account.supportsInterfaces(interfaceIds);
}
}
......@@ -4,9 +4,9 @@ import "../introspection/ERC165.sol";
contract ERC165Mock is ERC165 {
function registerInterface(bytes4 _interfaceId)
function registerInterface(bytes4 interfaceId)
public
{
_registerInterface(_interfaceId);
_registerInterface(interfaceId);
}
}
......@@ -5,8 +5,8 @@ import "../token/ERC20/ERC20Burnable.sol";
contract ERC20BurnableMock is ERC20Burnable {
constructor(address _initialAccount, uint256 _initialBalance) public {
_mint(_initialAccount, _initialBalance);
constructor(address initialAccount, uint256 initialBalance) public {
_mint(initialAccount, initialBalance);
}
}
......@@ -6,20 +6,20 @@ import "../token/ERC20/ERC20.sol";
// mock class using ERC20
contract ERC20Mock is ERC20 {
constructor(address _initialAccount, uint256 _initialBalance) public {
_mint(_initialAccount, _initialBalance);
constructor(address initialAccount, uint256 initialBalance) public {
_mint(initialAccount, initialBalance);
}
function mint(address _account, uint256 _amount) public {
_mint(_account, _amount);
function mint(address account, uint256 amount) public {
_mint(account, amount);
}
function burn(address _account, uint256 _amount) public {
_burn(_account, _amount);
function burn(address account, uint256 amount) public {
_burn(account, amount);
}
function burnFrom(address _account, uint256 _amount) public {
_burnFrom(_account, _amount);
function burnFrom(address account, uint256 amount) public {
_burnFrom(account, amount);
}
}
......@@ -7,8 +7,8 @@ import "./PauserRoleMock.sol";
// mock class using ERC20Pausable
contract ERC20PausableMock is ERC20Pausable, PauserRoleMock {
constructor(address _initialAccount, uint _initialBalance) public {
_mint(_initialAccount, _initialBalance);
constructor(address initialAccount, uint initialBalance) public {
_mint(initialAccount, initialBalance);
}
}
......@@ -5,8 +5,8 @@ import "../drafts/ERC1046/TokenMetadata.sol";
contract ERC20WithMetadataMock is ERC20, ERC20WithMetadata {
constructor(string _tokenURI) public
ERC20WithMetadata(_tokenURI)
constructor(string tokenURI) public
ERC20WithMetadata(tokenURI)
{
}
}
......@@ -8,11 +8,11 @@ import "../token/ERC721/ERC721Basic.sol";
* This mock just provides a public mint and burn functions for testing purposes
*/
contract ERC721BasicMock is ERC721Basic {
function mint(address _to, uint256 _tokenId) public {
_mint(_to, _tokenId);
function mint(address to, uint256 tokenId) public {
_mint(to, tokenId);
}
function burn(uint256 _tokenId) public {
_burn(ownerOf(_tokenId), _tokenId);
function burn(uint256 tokenId) public {
_burn(ownerOf(tokenId), tokenId);
}
}
......@@ -11,20 +11,20 @@ import "../token/ERC721/ERC721Burnable.sol";
* and a public setter for metadata URI
*/
contract ERC721Mock is ERC721, ERC721Mintable, ERC721Burnable {
constructor(string _name, string _symbol) public
constructor(string name, string symbol) public
ERC721Mintable()
ERC721(_name, _symbol)
ERC721(name, symbol)
{}
function exists(uint256 _tokenId) public view returns (bool) {
return _exists(_tokenId);
function exists(uint256 tokenId) public view returns (bool) {
return _exists(tokenId);
}
function setTokenURI(uint256 _tokenId, string _uri) public {
_setTokenURI(_tokenId, _uri);
function setTokenURI(uint256 tokenId, string uri) public {
_setTokenURI(tokenId, uri);
}
function removeTokenFrom(address _from, uint256 _tokenId) public {
_removeTokenFrom(_from, _tokenId);
function removeTokenFrom(address from, uint256 tokenId) public {
_removeTokenFrom(from, tokenId);
}
}
......@@ -9,15 +9,15 @@ import "./PauserRoleMock.sol";
* This mock just provides a public mint, burn and exists functions for testing purposes
*/
contract ERC721PausableMock is ERC721Pausable, PauserRoleMock {
function mint(address _to, uint256 _tokenId) public {
super._mint(_to, _tokenId);
function mint(address to, uint256 tokenId) public {
super._mint(to, tokenId);
}
function burn(uint256 _tokenId) public {
super._burn(ownerOf(_tokenId), _tokenId);
function burn(uint256 tokenId) public {
super._burn(ownerOf(tokenId), tokenId);
}
function exists(uint256 _tokenId) public view returns (bool) {
return super._exists(_tokenId);
function exists(uint256 tokenId) public view returns (bool) {
return super._exists(tokenId);
}
}
......@@ -4,8 +4,8 @@ import "../token/ERC721/IERC721Receiver.sol";
contract ERC721ReceiverMock is IERC721Receiver {
bytes4 internal retval_;
bool internal reverts_;
bytes4 private _retval;
bool private _reverts;
event Received(
address operator,
......@@ -15,28 +15,28 @@ contract ERC721ReceiverMock is IERC721Receiver {
uint256 gas
);
constructor(bytes4 _retval, bool _reverts) public {
retval_ = _retval;
reverts_ = _reverts;
constructor(bytes4 retval, bool reverts) public {
_retval = retval;
_reverts = reverts;
}
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes _data
address operator,
address from,
uint256 tokenId,
bytes data
)
public
returns(bytes4)
{
require(!reverts_);
require(!_reverts);
emit Received(
_operator,
_from,
_tokenId,
_data,
operator,
from,
tokenId,
data,
gasleft() // msg.gas was deprecated in solidityv0.4.21
);
return retval_;
return _retval;
}
}
......@@ -7,15 +7,15 @@ import "../crowdsale/distribution/FinalizableCrowdsale.sol";
contract FinalizableCrowdsaleImpl is FinalizableCrowdsale {
constructor (
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
address _wallet,
IERC20 _token
uint256 openingTime,
uint256 closingTime,
uint256 rate,
address wallet,
IERC20 token
)
public
Crowdsale(_rate, _wallet, _token)
TimedCrowdsale(_openingTime, _closingTime)
Crowdsale(rate, wallet, token)
TimedCrowdsale(openingTime, closingTime)
{
}
......
......@@ -10,7 +10,7 @@ contract ForceEther {
constructor() public payable { }
function destroyAndSend(address _recipient) public {
selfdestruct(_recipient);
function destroyAndSend(address recipient) public {
selfdestruct(recipient);
}
}
......@@ -7,17 +7,17 @@ import "../math/SafeMath.sol";
contract IncreasingPriceCrowdsaleImpl is IncreasingPriceCrowdsale {
constructor (
uint256 _openingTime,
uint256 _closingTime,
address _wallet,
IERC20 _token,
uint256 _initialRate,
uint256 _finalRate
uint256 openingTime,
uint256 closingTime,
address wallet,
IERC20 token,
uint256 initialRate,
uint256 finalRate
)
public
Crowdsale(_initialRate, _wallet, _token)
TimedCrowdsale(_openingTime, _closingTime)
IncreasingPriceCrowdsale(_initialRate, _finalRate)
Crowdsale(initialRate, wallet, token)
TimedCrowdsale(openingTime, closingTime)
IncreasingPriceCrowdsale(initialRate, finalRate)
{
}
......
......@@ -9,12 +9,12 @@ contract IndividuallyCappedCrowdsaleImpl
is IndividuallyCappedCrowdsale, CapperRoleMock {
constructor(
uint256 _rate,
address _wallet,
IERC20 _token
uint256 rate,
address wallet,
IERC20 token
)
public
Crowdsale(_rate, _wallet, _token)
Crowdsale(rate, wallet, token)
{
}
}
......@@ -5,15 +5,15 @@ import "../../contracts/math/Math.sol";
contract MathMock {
function max(uint256 _a, uint256 _b) public pure returns (uint256) {
return Math.max(_a, _b);
function max(uint256 a, uint256 b) public pure returns (uint256) {
return Math.max(a, b);
}
function min(uint256 _a, uint256 _b) public pure returns (uint256) {
return Math.min(_a, _b);
function min(uint256 a, uint256 b) public pure returns (uint256) {
return Math.min(a, b);
}
function average(uint256 _a, uint256 _b) public pure returns (uint256) {
return Math.average(_a, _b);
function average(uint256 a, uint256 b) public pure returns (uint256) {
return Math.average(a, b);
}
}
......@@ -6,14 +6,14 @@ import { MerkleProof } from "../cryptography/MerkleProof.sol";
contract MerkleProofWrapper {
function verify(
bytes32[] _proof,
bytes32 _root,
bytes32 _leaf
bytes32[] proof,
bytes32 root,
bytes32 leaf
)
public
pure
returns (bool)
{
return MerkleProof.verify(_proof, _root, _leaf);
return MerkleProof.verify(proof, root, leaf);
}
}
......@@ -7,12 +7,12 @@ import "../crowdsale/emission/MintedCrowdsale.sol";
contract MintedCrowdsaleImpl is MintedCrowdsale {
constructor (
uint256 _rate,
address _wallet,
ERC20Mintable _token
uint256 rate,
address wallet,
ERC20Mintable token
)
public
Crowdsale(_rate, _wallet, _token)
Crowdsale(rate, wallet, token)
{
}
......
......@@ -4,15 +4,15 @@ import "../access/roles/MinterRole.sol";
contract MinterRoleMock is MinterRole {
function removeMinter(address _account) public {
_removeMinter(_account);
function removeMinter(address account) public {
_removeMinter(account);
}
function onlyMinterMock() public view onlyMinter {
}
// Causes a compilation error if super._removeMinter is not internal
function _removeMinter(address _account) internal {
super._removeMinter(_account);
function _removeMinter(address account) internal {
super._removeMinter(account);
}
}
......@@ -4,15 +4,15 @@ import "../access/roles/PauserRole.sol";
contract PauserRoleMock is PauserRole {
function removePauser(address _account) public {
_removePauser(_account);
function removePauser(address account) public {
_removePauser(account);
}
function onlyPauserMock() public view onlyPauser {
}
// Causes a compilation error if super._removePauser is not internal
function _removePauser(address _account) internal {
super._removePauser(_account);
function _removePauser(address account) internal {
super._removePauser(account);
}
}
......@@ -7,15 +7,15 @@ import "../crowdsale/distribution/PostDeliveryCrowdsale.sol";
contract PostDeliveryCrowdsaleImpl is PostDeliveryCrowdsale {
constructor (
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
address _wallet,
IERC20 _token
uint256 openingTime,
uint256 closingTime,
uint256 rate,
address wallet,
IERC20 token
)
public
TimedCrowdsale(_openingTime, _closingTime)
Crowdsale(_rate, _wallet, _token)
TimedCrowdsale(openingTime, closingTime)
Crowdsale(rate, wallet, token)
{
}
......
......@@ -10,8 +10,8 @@ contract PullPaymentMock is PullPayment {
constructor() public payable { }
// test helper function to call asyncTransfer
function callTransfer(address _dest, uint256 _amount) public {
_asyncTransfer(_dest, _amount);
function callTransfer(address dest, uint256 amount) public {
_asyncTransfer(dest, amount);
}
}
......@@ -3,9 +3,9 @@ pragma solidity ^0.4.24;
contract ReentrancyAttack {
function callSender(bytes4 _data) public {
function callSender(bytes4 data) public {
// solium-disable-next-line security/no-low-level-calls
require(msg.sender.call(abi.encodeWithSelector(_data)));
require(msg.sender.call(abi.encodeWithSelector(data)));
}
}
......@@ -16,26 +16,26 @@ contract ReentrancyMock is ReentrancyGuard {
count();
}
function countLocalRecursive(uint256 _n) public nonReentrant {
if (_n > 0) {
function countLocalRecursive(uint256 n) public nonReentrant {
if (n > 0) {
count();
countLocalRecursive(_n - 1);
countLocalRecursive(n - 1);
}
}
function countThisRecursive(uint256 _n) public nonReentrant {
if (_n > 0) {
function countThisRecursive(uint256 n) public nonReentrant {
if (n > 0) {
count();
// solium-disable-next-line security/no-low-level-calls
bool result = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", _n - 1));
bool result = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1));
require(result == true);
}
}
function countAndCall(ReentrancyAttack _attacker) public nonReentrant {
function countAndCall(ReentrancyAttack attacker) public nonReentrant {
count();
bytes4 func = bytes4(keccak256("callback()"));
_attacker.callSender(func);
attacker.callSender(func);
}
function count() private {
......
......@@ -7,17 +7,17 @@ import "../crowdsale/distribution/RefundableCrowdsale.sol";
contract RefundableCrowdsaleImpl is RefundableCrowdsale {
constructor (
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
address _wallet,
ERC20Mintable _token,
uint256 _goal
uint256 openingTime,
uint256 closingTime,
uint256 rate,
address wallet,
ERC20Mintable token,
uint256 goal
)
public
Crowdsale(_rate, _wallet, _token)
TimedCrowdsale(_openingTime, _closingTime)
RefundableCrowdsale(_goal)
Crowdsale(rate, wallet, token)
TimedCrowdsale(openingTime, closingTime)
RefundableCrowdsale(goal)
{
}
......
......@@ -8,15 +8,15 @@ contract RolesMock {
Roles.Role private dummyRole;
function add(address _account) public {
dummyRole.add(_account);
function add(address account) public {
dummyRole.add(account);
}
function remove(address _account) public {
dummyRole.remove(_account);
function remove(address account) public {
dummyRole.remove(account);
}
function has(address _account) public view returns (bool) {
return dummyRole.has(_account);
function has(address account) public view returns (bool) {
return dummyRole.has(account);
}
}
......@@ -61,35 +61,35 @@ contract ERC20SucceedingMock is IERC20 {
contract SafeERC20Helper {
using SafeERC20 for IERC20;
IERC20 internal failing_;
IERC20 internal succeeding_;
IERC20 private _failing;
IERC20 private _succeeding;
constructor() public {
failing_ = new ERC20FailingMock();
succeeding_ = new ERC20SucceedingMock();
_failing = new ERC20FailingMock();
_succeeding = new ERC20SucceedingMock();
}
function doFailingTransfer() public {
failing_.safeTransfer(address(0), 0);
_failing.safeTransfer(address(0), 0);
}
function doFailingTransferFrom() public {
failing_.safeTransferFrom(address(0), address(0), 0);
_failing.safeTransferFrom(address(0), address(0), 0);
}
function doFailingApprove() public {
failing_.safeApprove(address(0), 0);
_failing.safeApprove(address(0), 0);
}
function doSucceedingTransfer() public {
succeeding_.safeTransfer(address(0), 0);
_succeeding.safeTransfer(address(0), 0);
}
function doSucceedingTransferFrom() public {
succeeding_.safeTransferFrom(address(0), address(0), 0);
_succeeding.safeTransferFrom(address(0), address(0), 0);
}
function doSucceedingApprove() public {
succeeding_.safeApprove(address(0), 0);
_succeeding.safeApprove(address(0), 0);
}
}
......@@ -6,20 +6,20 @@ import "../math/SafeMath.sol";
contract SafeMathMock {
function mul(uint256 _a, uint256 _b) public pure returns (uint256) {
return SafeMath.mul(_a, _b);
function mul(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.mul(a, b);
}
function div(uint256 _a, uint256 _b) public pure returns (uint256) {
return SafeMath.div(_a, _b);
function div(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.div(a, b);
}
function sub(uint256 _a, uint256 _b) public pure returns (uint256) {
return SafeMath.sub(_a, _b);
function sub(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.sub(a, b);
}
function add(uint256 _a, uint256 _b) public pure returns (uint256) {
return SafeMath.add(_a, _b);
function add(uint256 a, uint256 b) public pure returns (uint256) {
return SafeMath.add(a, b);
}
function mod(uint256 a, uint256 b) public pure returns (uint256) {
......
......@@ -5,54 +5,54 @@ import "./SignerRoleMock.sol";
contract SignatureBouncerMock is SignatureBouncer, SignerRoleMock {
function checkValidSignature(address _address, bytes _signature)
function checkValidSignature(address account, bytes signature)
public
view
returns (bool)
{
return _isValidSignature(_address, _signature);
return _isValidSignature(account, signature);
}
function onlyWithValidSignature(bytes _signature)
function onlyWithValidSignature(bytes signature)
public
onlyValidSignature(_signature)
onlyValidSignature(signature)
view
{
}
function checkValidSignatureAndMethod(address _address, bytes _signature)
function checkValidSignatureAndMethod(address account, bytes signature)
public
view
returns (bool)
{
return _isValidSignatureAndMethod(_address, _signature);
return _isValidSignatureAndMethod(account, signature);
}
function onlyWithValidSignatureAndMethod(bytes _signature)
function onlyWithValidSignatureAndMethod(bytes signature)
public
onlyValidSignatureAndMethod(_signature)
onlyValidSignatureAndMethod(signature)
view
{
}
function checkValidSignatureAndData(
address _address,
address account,
bytes,
uint,
bytes _signature
bytes signature
)
public
view
returns (bool)
{
return _isValidSignatureAndData(_address, _signature);
return _isValidSignatureAndData(account, signature);
}
function onlyWithValidSignatureAndData(uint, bytes _signature)
function onlyWithValidSignatureAndData(uint, bytes signature)
public
onlyValidSignatureAndData(_signature)
onlyValidSignatureAndData(signature)
view
{
......
......@@ -4,15 +4,15 @@ import "../access/roles/SignerRole.sol";
contract SignerRoleMock is SignerRole {
function removeSigner(address _account) public {
_removeSigner(_account);
function removeSigner(address account) public {
_removeSigner(account);
}
function onlySignerMock() public view onlySigner {
}
// Causes a compilation error if super._removeSigner is not internal
function _removeSigner(address _account) internal {
super._removeSigner(_account);
function _removeSigner(address account) internal {
super._removeSigner(account);
}
}
......@@ -7,15 +7,15 @@ import "../crowdsale/validation/TimedCrowdsale.sol";
contract TimedCrowdsaleImpl is TimedCrowdsale {
constructor (
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
address _wallet,
IERC20 _token
uint256 openingTime,
uint256 closingTime,
uint256 rate,
address wallet,
IERC20 token
)
public
Crowdsale(_rate, _wallet, _token)
TimedCrowdsale(_openingTime, _closingTime)
Crowdsale(rate, wallet, token)
TimedCrowdsale(openingTime, closingTime)
{
}
......
......@@ -16,11 +16,11 @@ contract CanReclaimToken is Ownable {
/**
* @dev Reclaim all ERC20 compatible tokens
* @param _token ERC20 The address of the token contract
* @param token ERC20 The address of the token contract
*/
function reclaimToken(IERC20 _token) external onlyOwner {
uint256 balance = _token.balanceOf(this);
_token.safeTransfer(owner(), balance);
function reclaimToken(IERC20 token) external onlyOwner {
uint256 balance = token.balanceOf(this);
token.safeTransfer(owner(), balance);
}
}
......@@ -7,7 +7,7 @@ pragma solidity ^0.4.24;
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address private owner_;
address private _owner;
event OwnershipRenounced(address indexed previousOwner);
......@@ -22,14 +22,14 @@ contract Ownable {
* account.
*/
constructor() public {
owner_ = msg.sender;
_owner = msg.sender;
}
/**
* @return the address of the owner.
*/
function owner() public view returns(address) {
return owner_;
return _owner;
}
/**
......@@ -44,7 +44,7 @@ contract Ownable {
* @return true if `msg.sender` is the owner of the contract.
*/
function isOwner() public view returns(bool) {
return msg.sender == owner_;
return msg.sender == _owner;
}
/**
......@@ -54,25 +54,25 @@ contract Ownable {
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner_);
owner_ = address(0);
emit OwnershipRenounced(_owner);
_owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
* @param newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner_, _newOwner);
owner_ = _newOwner;
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
......@@ -6,30 +6,30 @@ pragma solidity ^0.4.24;
* @dev A Secondary contract can only be used by its primary account (the one that created it)
*/
contract Secondary {
address private primary_;
address private _primary;
/**
* @dev Sets the primary account to the one that is creating the Secondary contract.
*/
constructor() public {
primary_ = msg.sender;
_primary = msg.sender;
}
/**
* @dev Reverts if called from any account other than the primary.
*/
modifier onlyPrimary() {
require(msg.sender == primary_);
require(msg.sender == _primary);
_;
}
function primary() public view returns (address) {
return primary_;
return _primary;
}
function transferPrimary(address _recipient) public onlyPrimary {
require(_recipient != address(0));
function transferPrimary(address recipient) public onlyPrimary {
require(recipient != address(0));
primary_ = _recipient;
_primary = recipient;
}
}
......@@ -11,12 +11,12 @@ contract ConditionalEscrow is Escrow {
/**
* @dev Returns whether an address is allowed to withdraw their funds. To be
* implemented by derived contracts.
* @param _payee The destination address of the funds.
* @param payee The destination address of the funds.
*/
function withdrawalAllowed(address _payee) public view returns (bool);
function withdrawalAllowed(address payee) public view returns (bool);
function withdraw(address _payee) public {
require(withdrawalAllowed(_payee));
super.withdraw(_payee);
function withdraw(address payee) public {
require(withdrawalAllowed(payee));
super.withdraw(payee);
}
}
......@@ -17,35 +17,35 @@ contract Escrow is Secondary {
event Deposited(address indexed payee, uint256 weiAmount);
event Withdrawn(address indexed payee, uint256 weiAmount);
mapping(address => uint256) private deposits_;
mapping(address => uint256) private _deposits;
function depositsOf(address _payee) public view returns (uint256) {
return deposits_[_payee];
function depositsOf(address payee) public view returns (uint256) {
return _deposits[payee];
}
/**
* @dev Stores the sent amount as credit to be withdrawn.
* @param _payee The destination address of the funds.
* @param payee The destination address of the funds.
*/
function deposit(address _payee) public onlyPrimary payable {
function deposit(address payee) public onlyPrimary payable {
uint256 amount = msg.value;
deposits_[_payee] = deposits_[_payee].add(amount);
_deposits[payee] = _deposits[payee].add(amount);
emit Deposited(_payee, amount);
emit Deposited(payee, amount);
}
/**
* @dev Withdraw accumulated balance for a payee.
* @param _payee The address whose funds will be withdrawn and transferred to.
* @param payee The address whose funds will be withdrawn and transferred to.
*/
function withdraw(address _payee) public onlyPrimary {
uint256 payment = deposits_[_payee];
function withdraw(address payee) public onlyPrimary {
uint256 payment = _deposits[payee];
assert(address(this).balance >= payment);
deposits_[_payee] = 0;
_deposits[payee] = 0;
_payee.transfer(payment);
payee.transfer(payment);
emit Withdrawn(_payee, payment);
emit Withdrawn(payee, payment);
}
}
......@@ -9,34 +9,34 @@ import "./Escrow.sol";
* contract and use _asyncTransfer instead of send or transfer.
*/
contract PullPayment {
Escrow private escrow;
Escrow private _escrow;
constructor() public {
escrow = new Escrow();
_escrow = new Escrow();
}
/**
* @dev Withdraw accumulated balance.
* @param _payee Whose balance will be withdrawn.
* @param payee Whose balance will be withdrawn.
*/
function withdrawPayments(address _payee) public {
escrow.withdraw(_payee);
function withdrawPayments(address payee) public {
_escrow.withdraw(payee);
}
/**
* @dev Returns the credit owed to an address.
* @param _dest The creditor's address.
* @param dest The creditor's address.
*/
function payments(address _dest) public view returns (uint256) {
return escrow.depositsOf(_dest);
function payments(address dest) public view returns (uint256) {
return _escrow.depositsOf(dest);
}
/**
* @dev Called by the payer to store the sent amount as credit to be pulled.
* @param _dest The destination address of the funds.
* @param _amount The amount to transfer.
* @param dest The destination address of the funds.
* @param amount The amount to transfer.
*/
function _asyncTransfer(address _dest, uint256 _amount) internal {
escrow.deposit.value(_amount)(_dest);
function _asyncTransfer(address dest, uint256 amount) internal {
_escrow.deposit.value(amount)(dest);
}
}
......@@ -16,40 +16,40 @@ contract RefundEscrow is Secondary, ConditionalEscrow {
event Closed();
event RefundsEnabled();
State private state_;
address private beneficiary_;
State private _state;
address private _beneficiary;
/**
* @dev Constructor.
* @param _beneficiary The beneficiary of the deposits.
* @param beneficiary The beneficiary of the deposits.
*/
constructor(address _beneficiary) public {
require(_beneficiary != address(0));
beneficiary_ = _beneficiary;
state_ = State.Active;
constructor(address beneficiary) public {
require(beneficiary != address(0));
_beneficiary = beneficiary;
_state = State.Active;
}
/**
* @return the current state of the escrow.
*/
function state() public view returns (State) {
return state_;
return _state;
}
/**
* @return the beneficiary of the escrow.
*/
function beneficiary() public view returns (address) {
return beneficiary_;
return _beneficiary;
}
/**
* @dev Stores funds that may later be refunded.
* @param _refundee The address funds will be sent to if a refund occurs.
* @param refundee The address funds will be sent to if a refund occurs.
*/
function deposit(address _refundee) public payable {
require(state_ == State.Active);
super.deposit(_refundee);
function deposit(address refundee) public payable {
require(_state == State.Active);
super.deposit(refundee);
}
/**
......@@ -57,8 +57,8 @@ contract RefundEscrow is Secondary, ConditionalEscrow {
* further deposits.
*/
function close() public onlyPrimary {
require(state_ == State.Active);
state_ = State.Closed;
require(_state == State.Active);
_state = State.Closed;
emit Closed();
}
......@@ -66,8 +66,8 @@ contract RefundEscrow is Secondary, ConditionalEscrow {
* @dev Allows for refunds to take place, rejecting further deposits.
*/
function enableRefunds() public onlyPrimary {
require(state_ == State.Active);
state_ = State.Refunding;
require(_state == State.Active);
_state = State.Refunding;
emit RefundsEnabled();
}
......@@ -75,14 +75,14 @@ contract RefundEscrow is Secondary, ConditionalEscrow {
* @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;
function withdrawalAllowed(address payee) public view returns (bool) {
return _state == State.Refunding;
}
}
......@@ -11,22 +11,22 @@ import "../math/SafeMath.sol";
contract SplitPayment {
using SafeMath for uint256;
uint256 private totalShares_ = 0;
uint256 private totalReleased_ = 0;
uint256 private _totalShares = 0;
uint256 private _totalReleased = 0;
mapping(address => uint256) private shares_;
mapping(address => uint256) private released_;
address[] private payees_;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
/**
* @dev Constructor
*/
constructor(address[] _payees, uint256[] _shares) public payable {
require(_payees.length == _shares.length);
require(_payees.length > 0);
constructor(address[] payees, uint256[] shares) public payable {
require(payees.length == shares.length);
require(payees.length > 0);
for (uint256 i = 0; i < _payees.length; i++) {
_addPayee(_payees[i], _shares[i]);
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares[i]);
}
}
......@@ -39,72 +39,72 @@ contract SplitPayment {
* @return the total shares of the contract.
*/
function totalShares() public view returns(uint256) {
return totalShares_;
return _totalShares;
}
/**
* @return the total amount already released.
*/
function totalReleased() public view returns(uint256) {
return totalReleased_;
return _totalReleased;
}
/**
* @return the shares of an account.
*/
function shares(address _account) public view returns(uint256) {
return shares_[_account];
function shares(address account) public view returns(uint256) {
return _shares[account];
}
/**
* @return the amount already released to an account.
*/
function released(address _account) public view returns(uint256) {
return released_[_account];
function released(address account) public view returns(uint256) {
return _released[account];
}
/**
* @return the address of a payee.
*/
function payee(uint256 index) public view returns(address) {
return payees_[index];
return _payees[index];
}
/**
* @dev Release one of the payee's proportional payment.
* @param _payee Whose payments will be released.
* @param account Whose payments will be released.
*/
function release(address _payee) public {
require(shares_[_payee] > 0);
function release(address account) public {
require(_shares[account] > 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[account]).div(
_totalShares).sub(
_released[account]
);
require(payment != 0);
assert(address(this).balance >= payment);
released_[_payee] = released_[_payee].add(payment);
totalReleased_ = totalReleased_.add(payment);
_released[account] = _released[account].add(payment);
_totalReleased = _totalReleased.add(payment);
_payee.transfer(payment);
account.transfer(payment);
}
/**
* @dev Add a new payee to the contract.
* @param _payee The address of the payee to add.
* @param _shares The number of shares owned by the payee.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address _payee, uint256 _shares) internal {
require(_payee != address(0));
require(_shares > 0);
require(shares_[_payee] == 0);
payees_.push(_payee);
shares_[_payee] = _shares;
totalShares_ = totalShares_.add(_shares);
function _addPayee(address account, uint256 shares_) internal {
require(account != address(0));
require(shares_ > 0);
require(_shares[account] == 0);
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares.add(shares_);
}
}
......@@ -13,27 +13,27 @@ contract ERC20Burnable is ERC20 {
/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
* @param value The amount of token to be burned.
*/
function burn(uint256 _value) public {
_burn(msg.sender, _value);
function burn(uint256 value) public {
_burn(msg.sender, value);
}
/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param _from address The address which you want to send tokens from
* @param _value uint256 The amount of token to be burned
* @param from address The address which you want to send tokens from
* @param value uint256 The amount of token to be burned
*/
function burnFrom(address _from, uint256 _value) public {
_burnFrom(_from, _value);
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}
/**
* @dev Overrides ERC20._burn in order for burn and burnFrom to emit
* an additional Burn event.
*/
function _burn(address _who, uint256 _value) internal {
super._burn(_who, _value);
emit TokensBurned(_who, _value);
function _burn(address who, uint256 value) internal {
super._burn(who, value);
emit TokensBurned(who, value);
}
}
......@@ -9,38 +9,38 @@ import "./ERC20Mintable.sol";
*/
contract ERC20Capped is ERC20Mintable {
uint256 private cap_;
uint256 private _cap;
constructor(uint256 _cap)
constructor(uint256 cap)
public
{
require(_cap > 0);
cap_ = _cap;
require(cap > 0);
_cap = cap;
}
/**
* @return the cap for the token minting.
*/
function cap() public view returns(uint256) {
return cap_;
return _cap;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @param to The address that will receive the minted tokens.
* @param amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address _to,
uint256 _amount
address to,
uint256 amount
)
public
returns (bool)
{
require(totalSupply().add(_amount) <= cap_);
require(totalSupply().add(amount) <= _cap);
return super.mint(_to, _amount);
return super.mint(to, amount);
}
}
......@@ -10,34 +10,34 @@ import "./IERC20.sol";
* just as on Ethereum all the operations are done in wei.
*/
contract ERC20Detailed is IERC20 {
string private name_;
string private symbol_;
uint8 private decimals_;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor(string _name, string _symbol, uint8 _decimals) public {
name_ = _name;
symbol_ = _symbol;
decimals_ = _decimals;
constructor(string name, string symbol, uint8 decimals) public {
_name = name;
_symbol = symbol;
_decimals = decimals;
}
/**
* @return the name of the token.
*/
function name() public view returns(string) {
return name_;
return _name;
}
/**
* @return the symbol of the token.
*/
function symbol() public view returns(string) {
return symbol_;
return _symbol;
}
/**
* @return the number of decimals of the token.
*/
function decimals() public view returns(uint8) {
return decimals_;
return _decimals;
}
}
......@@ -12,10 +12,10 @@ contract ERC20Mintable is ERC20, MinterRole {
event Minted(address indexed to, uint256 amount);
event MintingFinished();
bool private mintingFinished_ = false;
bool private _mintingFinished = false;
modifier onlyBeforeMintingFinished() {
require(!mintingFinished_);
require(!_mintingFinished);
_;
}
......@@ -23,26 +23,26 @@ contract ERC20Mintable is ERC20, MinterRole {
* @return true if the minting is finished.
*/
function mintingFinished() public view returns(bool) {
return mintingFinished_;
return _mintingFinished;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @param to The address that will receive the minted tokens.
* @param amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address _to,
uint256 _amount
address to,
uint256 amount
)
public
onlyMinter
onlyBeforeMintingFinished
returns (bool)
{
_mint(_to, _amount);
emit Minted(_to, _amount);
_mint(to, amount);
emit Minted(to, amount);
return true;
}
......@@ -56,7 +56,7 @@ contract ERC20Mintable is ERC20, MinterRole {
onlyBeforeMintingFinished
returns (bool)
{
mintingFinished_ = true;
_mintingFinished = true;
emit MintingFinished();
return true;
}
......
......@@ -11,58 +11,58 @@ import "../../lifecycle/Pausable.sol";
contract ERC20Pausable is ERC20, Pausable {
function transfer(
address _to,
uint256 _value
address to,
uint256 value
)
public
whenNotPaused
returns (bool)
{
return super.transfer(_to, _value);
return super.transfer(to, value);
}
function transferFrom(
address _from,
address _to,
uint256 _value
address from,
address to,
uint256 value
)
public
whenNotPaused
returns (bool)
{
return super.transferFrom(_from, _to, _value);
return super.transferFrom(from, to, value);
}
function approve(
address _spender,
uint256 _value
address spender,
uint256 value
)
public
whenNotPaused
returns (bool)
{
return super.approve(_spender, _value);
return super.approve(spender, value);
}
function increaseAllowance(
address _spender,
uint _addedValue
address spender,
uint addedValue
)
public
whenNotPaused
returns (bool success)
{
return super.increaseAllowance(_spender, _addedValue);
return super.increaseAllowance(spender, addedValue);
}
function decreaseAllowance(
address _spender,
uint _subtractedValue
address spender,
uint subtractedValue
)
public
whenNotPaused
returns (bool success)
{
return super.decreaseAllowance(_spender, _subtractedValue);
return super.decreaseAllowance(spender, subtractedValue);
}
}
......@@ -8,17 +8,17 @@ pragma solidity ^0.4.24;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address _who) external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address _owner, address _spender)
function allowance(address owner, address spender)
external view returns (uint256);
function transfer(address _to, uint256 _value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function approve(address _spender, uint256 _value)
function approve(address spender, uint256 value)
external returns (bool);
function transferFrom(address _from, address _to, uint256 _value)
function transferFrom(address from, address to, uint256 value)
external returns (bool);
event Transfer(
......
......@@ -12,33 +12,33 @@ import "./IERC20.sol";
*/
library SafeERC20 {
function safeTransfer(
IERC20 _token,
address _to,
uint256 _value
IERC20 token,
address to,
uint256 value
)
internal
{
require(_token.transfer(_to, _value));
require(token.transfer(to, value));
}
function safeTransferFrom(
IERC20 _token,
address _from,
address _to,
uint256 _value
IERC20 token,
address from,
address to,
uint256 value
)
internal
{
require(_token.transferFrom(_from, _to, _value));
require(token.transferFrom(from, to, value));
}
function safeApprove(
IERC20 _token,
address _spender,
uint256 _value
IERC20 token,
address spender,
uint256 value
)
internal
{
require(_token.approve(_spender, _value));
require(token.approve(spender, value));
}
}
......@@ -12,47 +12,47 @@ contract TokenTimelock {
using SafeERC20 for IERC20;
// ERC20 basic token contract being held
IERC20 private token_;
IERC20 private _token;
// beneficiary of tokens after they are released
address private beneficiary_;
address private _beneficiary;
// timestamp when token release is enabled
uint256 private releaseTime_;
uint256 private _releaseTime;
constructor(
IERC20 _token,
address _beneficiary,
uint256 _releaseTime
IERC20 token,
address beneficiary,
uint256 releaseTime
)
public
{
// solium-disable-next-line security/no-block-members
require(_releaseTime > block.timestamp);
token_ = _token;
beneficiary_ = _beneficiary;
releaseTime_ = _releaseTime;
require(releaseTime > block.timestamp);
_token = token;
_beneficiary = beneficiary;
_releaseTime = releaseTime;
}
/**
* @return the token being held.
*/
function token() public view returns(IERC20) {
return token_;
return _token;
}
/**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view returns(address) {
return beneficiary_;
return _beneficiary;
}
/**
* @return the time when the tokens are released.
*/
function releaseTime() public view returns(uint256) {
return releaseTime_;
return _releaseTime;
}
/**
......@@ -60,11 +60,11 @@ contract TokenTimelock {
*/
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);
}
}
......@@ -4,10 +4,10 @@ import "./ERC721.sol";
contract ERC721Burnable is ERC721 {
function burn(uint256 _tokenId)
function burn(uint256 tokenId)
public
{
require(_isApprovedOrOwner(msg.sender, _tokenId));
_burn(ownerOf(_tokenId), _tokenId);
require(_isApprovedOrOwner(msg.sender, tokenId));
_burn(ownerOf(tokenId), tokenId);
}
}
......@@ -12,10 +12,10 @@ contract ERC721Mintable is ERC721, MinterRole {
event Minted(address indexed to, uint256 tokenId);
event MintingFinished();
bool private mintingFinished_ = false;
bool private _mintingFinished = false;
modifier onlyBeforeMintingFinished() {
require(!mintingFinished_);
require(!_mintingFinished);
_;
}
......@@ -23,41 +23,41 @@ contract ERC721Mintable is ERC721, MinterRole {
* @return true if the minting is finished.
*/
function mintingFinished() public view returns(bool) {
return mintingFinished_;
return _mintingFinished;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _tokenId The token id to mint.
* @param to The address that will receive the minted tokens.
* @param tokenId The token id to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address _to,
uint256 _tokenId
address to,
uint256 tokenId
)
public
onlyMinter
onlyBeforeMintingFinished
returns (bool)
{
_mint(_to, _tokenId);
emit Minted(_to, _tokenId);
_mint(to, tokenId);
emit Minted(to, tokenId);
return true;
}
function mintWithTokenURI(
address _to,
uint256 _tokenId,
string _tokenURI
address to,
uint256 tokenId,
string tokenURI
)
public
onlyMinter
onlyBeforeMintingFinished
returns (bool)
{
mint(_to, _tokenId);
_setTokenURI(_tokenId, _tokenURI);
mint(to, tokenId);
_setTokenURI(tokenId, tokenURI);
return true;
}
......@@ -71,7 +71,7 @@ contract ERC721Mintable is ERC721, MinterRole {
onlyBeforeMintingFinished
returns (bool)
{
mintingFinished_ = true;
_mintingFinished = true;
emit MintingFinished();
return true;
}
......
......@@ -10,33 +10,33 @@ import "../../lifecycle/Pausable.sol";
**/
contract ERC721Pausable is ERC721Basic, Pausable {
function approve(
address _to,
uint256 _tokenId
address to,
uint256 tokenId
)
public
whenNotPaused
{
super.approve(_to, _tokenId);
super.approve(to, tokenId);
}
function setApprovalForAll(
address _to,
bool _approved
address to,
bool approved
)
public
whenNotPaused
{
super.setApprovalForAll(_to, _approved);
super.setApprovalForAll(to, approved);
}
function transferFrom(
address _from,
address _to,
uint256 _tokenId
address from,
address to,
uint256 tokenId
)
public
whenNotPaused
{
super.transferFrom(_from, _to, _tokenId);
super.transferFrom(from, to, tokenId);
}
}
......@@ -10,14 +10,14 @@ import "./IERC721Basic.sol";
contract IERC721Enumerable is IERC721Basic {
function totalSupply() public view returns (uint256);
function tokenOfOwnerByIndex(
address _owner,
uint256 _index
address owner,
uint256 index
)
public
view
returns (uint256 _tokenId);
returns (uint256 tokenId);
function tokenByIndex(uint256 _index) public view returns (uint256);
function tokenByIndex(uint256 index) public view returns (uint256);
}
......@@ -26,9 +26,9 @@ contract IERC721Enumerable is IERC721Basic {
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract IERC721Metadata is IERC721Basic {
function name() external view returns (string _name);
function symbol() external view returns (string _symbol);
function tokenURI(uint256 _tokenId) public view returns (string);
function name() external view returns (string);
function symbol() external view returns (string);
function tokenURI(uint256 tokenId) public view returns (string);
}
......
......@@ -25,26 +25,26 @@ contract IERC721Basic is IERC165 {
bool approved
);
function balanceOf(address _owner) public view returns (uint256 _balance);
function ownerOf(uint256 _tokenId) public view returns (address _owner);
function balanceOf(address owner) public view returns (uint256 balance);
function ownerOf(uint256 tokenId) public view returns (address owner);
function approve(address _to, uint256 _tokenId) public;
function getApproved(uint256 _tokenId)
public view returns (address _operator);
function approve(address to, uint256 tokenId) public;
function getApproved(uint256 tokenId)
public view returns (address operator);
function setApprovalForAll(address _operator, bool _approved) public;
function isApprovedForAll(address _owner, address _operator)
function setApprovalForAll(address operator, bool approved) public;
function isApprovedForAll(address owner, address operator)
public view returns (bool);
function transferFrom(address _from, address _to, uint256 _tokenId) public;
function safeTransferFrom(address _from, address _to, uint256 _tokenId)
function transferFrom(address from, address to, uint256 tokenId) public;
function safeTransferFrom(address from, address to, uint256 tokenId)
public;
function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes _data
address from,
address to,
uint256 tokenId,
bytes data
)
public;
}
......@@ -15,17 +15,17 @@ contract IERC721Receiver {
* returned can be obtained as `this.onERC721Received.selector`. This
* function MAY throw to revert and reject the transfer.
* Note: the ERC721 contract address is always the message sender.
* @param _operator The address which called `safeTransferFrom` function
* @param _from The address which previously owned the token
* @param _tokenId The NFT identifier which is being transferred
* @param _data Additional data with no specified format
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes _data
address operator,
address from,
uint256 tokenId,
bytes data
)
public
returns(bytes4);
......
......@@ -10,10 +10,10 @@ library Address {
* Returns whether the target address is a contract
* @dev This function will return false if invoked during the constructor of a contract,
* as the code is not actually created until after the constructor finishes.
* @param _account address of the account to check
* @param account address of the account to check
* @return whether the target address is a contract
*/
function isContract(address _account) internal view returns (bool) {
function isContract(address account) internal view returns (bool) {
uint256 size;
// XXX Currently there is no better way to check if there is a contract in an address
// than to check the size of the code at that address.
......@@ -22,7 +22,7 @@ library Address {
// TODO Check this again before the Serenity release, because all addresses will be
// contracts then.
// solium-disable-next-line security/no-inline-assembly
assembly { size := extcodesize(_account) }
assembly { size := extcodesize(account) }
return size > 0;
}
......
......@@ -19,11 +19,11 @@ library AutoIncrementing {
uint256 prevId; // default: 0
}
function nextId(Counter storage _counter)
function nextId(Counter storage counter)
internal
returns (uint256)
{
_counter.prevId = _counter.prevId + 1;
return _counter.prevId;
counter.prevId = counter.prevId + 1;
return counter.prevId;
}
}
......@@ -10,7 +10,7 @@ pragma solidity ^0.4.24;
contract ReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private guardCounter = 1;
uint256 private _guardCounter = 1;
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
......@@ -21,10 +21,10 @@ contract ReentrancyGuard {
* wrapper marked as `nonReentrant`.
*/
modifier nonReentrant() {
guardCounter += 1;
uint256 localCounter = guardCounter;
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == guardCounter);
require(localCounter == _guardCounter);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment