Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
b6943263
Commit
b6943263
authored
Aug 29, 2018
by
viquezclaudio
Committed by
Leo Arias
Aug 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added "_" sufix to internal variables (#1171)
parent
1c57637f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
48 deletions
+67
-48
CODE_STYLE.md
CODE_STYLE.md
+18
-0
RefundableCrowdsale.sol
contracts/crowdsale/distribution/RefundableCrowdsale.sol
+7
-7
SupportsInterfaceWithLookup.sol
contracts/introspection/SupportsInterfaceWithLookup.sol
+3
-3
ERC721ReceiverMock.sol
contracts/mocks/ERC721ReceiverMock.sol
+6
-6
Escrow.sol
contracts/payment/Escrow.sol
+5
-5
StandardToken.sol
contracts/token/ERC20/StandardToken.sol
+28
-27
No files found.
CODE_STYLE.md
View file @
b6943263
...
@@ -24,6 +24,24 @@ Any exception or additions specific to our project are documented below.
...
@@ -24,6 +24,24 @@ Any exception or additions specific to our project are documented below.
}
}
```
```
*
Internal and private state variables should have an underscore suffix.
```
contract TestContract {
uint256 internal internalVar_;
uint256 private privateVar_;
}
```
Variables declared in a function should not follow this rule.
```
function test() {
uint256 functionVar;
...
}
```
*
Events should be emitted immediately after the state change that they
*
Events should be emitted immediately after the state change that they
represent, and consequently they should be named in past tense.
represent, and consequently they should be named in past tense.
...
...
contracts/crowdsale/distribution/RefundableCrowdsale.sol
View file @
b6943263
...
@@ -18,7 +18,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -18,7 +18,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
uint256 public goal;
uint256 public goal;
// refund escrow used to hold funds while crowdsale is running
// refund escrow used to hold funds while crowdsale is running
RefundEscrow private escrow;
RefundEscrow private escrow
_
;
/**
/**
* @dev Constructor, creates RefundEscrow.
* @dev Constructor, creates RefundEscrow.
...
@@ -26,7 +26,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -26,7 +26,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
*/
*/
constructor(uint256 _goal) public {
constructor(uint256 _goal) public {
require(_goal > 0);
require(_goal > 0);
escrow = new RefundEscrow(wallet);
escrow
_
= new RefundEscrow(wallet);
goal = _goal;
goal = _goal;
}
}
...
@@ -37,7 +37,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -37,7 +37,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
require(isFinalized);
require(isFinalized);
require(!goalReached());
require(!goalReached());
escrow.withdraw(msg.sender);
escrow
_
.withdraw(msg.sender);
}
}
/**
/**
...
@@ -53,10 +53,10 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -53,10 +53,10 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
*/
*/
function finalization() internal {
function finalization() internal {
if (goalReached()) {
if (goalReached()) {
escrow.close();
escrow
_
.close();
escrow.beneficiaryWithdraw();
escrow
_
.beneficiaryWithdraw();
} else {
} else {
escrow.enableRefunds();
escrow
_
.enableRefunds();
}
}
super.finalization();
super.finalization();
...
@@ -66,7 +66,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -66,7 +66,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
* @dev Overrides Crowdsale fund forwarding, sending funds to escrow.
* @dev Overrides Crowdsale fund forwarding, sending funds to escrow.
*/
*/
function _forwardFunds() internal {
function _forwardFunds() internal {
escrow.deposit.value(msg.value)(msg.sender);
escrow
_
.deposit.value(msg.value)(msg.sender);
}
}
}
}
contracts/introspection/SupportsInterfaceWithLookup.sol
View file @
b6943263
...
@@ -19,7 +19,7 @@ contract SupportsInterfaceWithLookup is ERC165 {
...
@@ -19,7 +19,7 @@ contract SupportsInterfaceWithLookup is ERC165 {
/**
/**
* @dev a mapping of interface id to whether or not it's supported
* @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
* @dev A contract implementing SupportsInterfaceWithLookup
...
@@ -39,7 +39,7 @@ contract SupportsInterfaceWithLookup is ERC165 {
...
@@ -39,7 +39,7 @@ contract SupportsInterfaceWithLookup is ERC165 {
view
view
returns (bool)
returns (bool)
{
{
return supportedInterfaces[_interfaceId];
return supportedInterfaces
_
[_interfaceId];
}
}
/**
/**
...
@@ -49,6 +49,6 @@ contract SupportsInterfaceWithLookup is ERC165 {
...
@@ -49,6 +49,6 @@ contract SupportsInterfaceWithLookup is ERC165 {
internal
internal
{
{
require(_interfaceId != 0xffffffff);
require(_interfaceId != 0xffffffff);
supportedInterfaces[_interfaceId] = true;
supportedInterfaces
_
[_interfaceId] = true;
}
}
}
}
contracts/mocks/ERC721ReceiverMock.sol
View file @
b6943263
...
@@ -4,8 +4,8 @@ import "../token/ERC721/ERC721Receiver.sol";
...
@@ -4,8 +4,8 @@ import "../token/ERC721/ERC721Receiver.sol";
contract ERC721ReceiverMock is ERC721Receiver {
contract ERC721ReceiverMock is ERC721Receiver {
bytes4 retval;
bytes4 retval
_
;
bool reverts;
bool reverts
_
;
event Received(
event Received(
address _operator,
address _operator,
...
@@ -16,8 +16,8 @@ contract ERC721ReceiverMock is ERC721Receiver {
...
@@ -16,8 +16,8 @@ contract ERC721ReceiverMock is ERC721Receiver {
);
);
constructor(bytes4 _retval, bool _reverts) public {
constructor(bytes4 _retval, bool _reverts) public {
retval = _retval;
retval
_
= _retval;
reverts = _reverts;
reverts
_
= _reverts;
}
}
function onERC721Received(
function onERC721Received(
...
@@ -29,7 +29,7 @@ contract ERC721ReceiverMock is ERC721Receiver {
...
@@ -29,7 +29,7 @@ contract ERC721ReceiverMock is ERC721Receiver {
public
public
returns(bytes4)
returns(bytes4)
{
{
require(!reverts);
require(!reverts
_
);
emit Received(
emit Received(
_operator,
_operator,
_from,
_from,
...
@@ -37,6 +37,6 @@ contract ERC721ReceiverMock is ERC721Receiver {
...
@@ -37,6 +37,6 @@ contract ERC721ReceiverMock is ERC721Receiver {
_data,
_data,
gasleft() // msg.gas was deprecated in solidityv0.4.21
gasleft() // msg.gas was deprecated in solidityv0.4.21
);
);
return retval;
return retval
_
;
}
}
}
}
contracts/payment/Escrow.sol
View file @
b6943263
...
@@ -17,10 +17,10 @@ contract Escrow is Ownable {
...
@@ -17,10 +17,10 @@ contract Escrow is Ownable {
event Deposited(address indexed payee, uint256 weiAmount);
event Deposited(address indexed payee, uint256 weiAmount);
event Withdrawn(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) {
function depositsOf(address _payee) public view returns (uint256) {
return deposits[_payee];
return deposits
_
[_payee];
}
}
/**
/**
...
@@ -29,7 +29,7 @@ contract Escrow is Ownable {
...
@@ -29,7 +29,7 @@ contract Escrow is Ownable {
*/
*/
function deposit(address _payee) public onlyOwner payable {
function deposit(address _payee) public onlyOwner payable {
uint256 amount = msg.value;
uint256 amount = msg.value;
deposits
[_payee] = deposits
[_payee].add(amount);
deposits
_[_payee] = deposits_
[_payee].add(amount);
emit Deposited(_payee, amount);
emit Deposited(_payee, amount);
}
}
...
@@ -39,10 +39,10 @@ contract Escrow is Ownable {
...
@@ -39,10 +39,10 @@ contract Escrow is Ownable {
* @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 onlyOwner {
function withdraw(address _payee) public onlyOwner {
uint256 payment = deposits[_payee];
uint256 payment = deposits
_
[_payee];
assert(address(this).balance >= payment);
assert(address(this).balance >= payment);
deposits[_payee] = 0;
deposits
_
[_payee] = 0;
_payee.transfer(payment);
_payee.transfer(payment);
...
...
contracts/token/ERC20/StandardToken.sol
View file @
b6943263
...
@@ -14,9 +14,9 @@ import "../../math/SafeMath.sol";
...
@@ -14,9 +14,9 @@ import "../../math/SafeMath.sol";
contract StandardToken is ERC20 {
contract StandardToken is ERC20 {
using SafeMath for uint256;
using SafeMath for uint256;
mapping (address => uint256) private balances;
mapping (address => uint256) private balances
_
;
mapping (address => mapping (address => uint256)) private allowed;
mapping (address => mapping (address => uint256)) private allowed
_
;
uint256 private totalSupply_;
uint256 private totalSupply_;
...
@@ -33,7 +33,7 @@ contract StandardToken is ERC20 {
...
@@ -33,7 +33,7 @@ contract StandardToken is ERC20 {
* @return An uint256 representing the amount owned by the passed address.
* @return An uint256 representing the amount owned by the passed address.
*/
*/
function balanceOf(address _owner) public view returns (uint256) {
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
return balances
_
[_owner];
}
}
/**
/**
...
@@ -50,7 +50,7 @@ contract StandardToken is ERC20 {
...
@@ -50,7 +50,7 @@ contract StandardToken is ERC20 {
view
view
returns (uint256)
returns (uint256)
{
{
return allowed[_owner][_spender];
return allowed
_
[_owner][_spender];
}
}
/**
/**
...
@@ -59,11 +59,11 @@ contract StandardToken is ERC20 {
...
@@ -59,11 +59,11 @@ contract StandardToken is ERC20 {
* @param _value The amount to be transferred.
* @param _value The amount to be transferred.
*/
*/
function transfer(address _to, uint256 _value) public returns (bool) {
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances[msg.sender]);
require(_value <= balances
_
[msg.sender]);
require(_to != address(0));
require(_to != address(0));
balances
[msg.sender] = balances
[msg.sender].sub(_value);
balances
_[msg.sender] = balances_
[msg.sender].sub(_value);
balances
[_to] = balances
[_to].add(_value);
balances
_[_to] = balances_
[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value);
return true;
return true;
}
}
...
@@ -78,7 +78,7 @@ contract StandardToken is ERC20 {
...
@@ -78,7 +78,7 @@ contract StandardToken is ERC20 {
* @param _value The amount of tokens to be spent.
* @param _value The amount of tokens to be spent.
*/
*/
function approve(address _spender, uint256 _value) public returns (bool) {
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
allowed
_
[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
emit Approval(msg.sender, _spender, _value);
return true;
return true;
}
}
...
@@ -97,20 +97,20 @@ contract StandardToken is ERC20 {
...
@@ -97,20 +97,20 @@ contract StandardToken is ERC20 {
public
public
returns (bool)
returns (bool)
{
{
require(_value <= balances[_from]);
require(_value <= balances
_
[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_value <= allowed
_
[_from][msg.sender]);
require(_to != address(0));
require(_to != address(0));
balances
[_from] = balances
[_from].sub(_value);
balances
_[_from] = balances_
[_from].sub(_value);
balances
[_to] = balances
[_to].add(_value);
balances
_[_to] = balances_
[_to].add(_value);
allowed
[_from][msg.sender] = allowed
[_from][msg.sender].sub(_value);
allowed
_[_from][msg.sender] = allowed_
[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
emit Transfer(_from, _to, _value);
return true;
return true;
}
}
/**
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* approve should be called when allowed
_
[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* the first transaction is mined)
* From MonolithDAO Token.sol
* From MonolithDAO Token.sol
...
@@ -124,15 +124,15 @@ contract StandardToken is ERC20 {
...
@@ -124,15 +124,15 @@ contract StandardToken is ERC20 {
public
public
returns (bool)
returns (bool)
{
{
allowed[msg.sender][_spender] = (
allowed
_
[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
allowed
_
[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
emit Approval(msg.sender, _spender, allowed
_
[msg.sender][_spender]);
return true;
return true;
}
}
/**
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* approve should be called when allowed
_
[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* the first transaction is mined)
* From MonolithDAO Token.sol
* From MonolithDAO Token.sol
...
@@ -146,13 +146,13 @@ contract StandardToken is ERC20 {
...
@@ -146,13 +146,13 @@ contract StandardToken is ERC20 {
public
public
returns (bool)
returns (bool)
{
{
uint256 oldValue = allowed[msg.sender][_spender];
uint256 oldValue = allowed
_
[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
allowed
_
[msg.sender][_spender] = 0;
} else {
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
allowed
_
[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
emit Approval(msg.sender, _spender, allowed
_
[msg.sender][_spender]);
return true;
return true;
}
}
...
@@ -166,7 +166,7 @@ contract StandardToken is ERC20 {
...
@@ -166,7 +166,7 @@ contract StandardToken is ERC20 {
function _mint(address _account, uint256 _amount) internal {
function _mint(address _account, uint256 _amount) internal {
require(_account != 0);
require(_account != 0);
totalSupply_ = totalSupply_.add(_amount);
totalSupply_ = totalSupply_.add(_amount);
balances
[_account] = balances
[_account].add(_amount);
balances
_[_account] = balances_
[_account].add(_amount);
emit Transfer(address(0), _account, _amount);
emit Transfer(address(0), _account, _amount);
}
}
...
@@ -178,10 +178,10 @@ contract StandardToken is ERC20 {
...
@@ -178,10 +178,10 @@ contract StandardToken is ERC20 {
*/
*/
function _burn(address _account, uint256 _amount) internal {
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(_account != 0);
require(_amount <= balances[_account]);
require(_amount <= balances
_
[_account]);
totalSupply_ = totalSupply_.sub(_amount);
totalSupply_ = totalSupply_.sub(_amount);
balances
[_account] = balances
[_account].sub(_amount);
balances
_[_account] = balances_
[_account].sub(_amount);
emit Transfer(_account, address(0), _amount);
emit Transfer(_account, address(0), _amount);
}
}
...
@@ -193,11 +193,12 @@ contract StandardToken is ERC20 {
...
@@ -193,11 +193,12 @@ contract StandardToken is ERC20 {
* @param _amount The amount that will be burnt.
* @param _amount The amount that will be burnt.
*/
*/
function _burnFrom(address _account, uint256 _amount) internal {
function _burnFrom(address _account, uint256 _amount) internal {
require(_amount <= allowed[_account][msg.sender]);
require(_amount <= allowed
_
[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
// this function needs to emit an event with the updated approval.
allowed[_account][msg.sender] = allowed[_account][msg.sender].sub(_amount);
allowed_[_account][msg.sender] = allowed_[_account][msg.sender].sub(
_amount);
_burn(_account, _amount);
_burn(_account, _amount);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment