Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into HEAD
  • Loading branch information
Leo Arias committed Aug 29, 2018
commit cab1ed11a0e1f9fcdfd7640511bc8b771a6ebcdf
38 changes: 26 additions & 12 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,39 @@ Any exception or additions specific to our project are documented below.
```
function test(uint256 _testParameter1, uint256 _testParameter2) {
...
}
```
}
```

* Internal state variables should have an underscore suffix: by internal state
variable we mean any variable with no modifier or with the internal or private
modifiers whose scope is not a function. For instance, variables that are
declared in a function should not follow this rule.


```
contract myContract{
```
contract myContract{

uint256 internalVar_;
uint256 public publicVar;
uint256 internalVar_;
uint256 public publicVar;

function test(uint256 _testParameter1, uint256 _testParameter2) {
uint256 functionVar;
...
}
function test(uint256 _testParameter1, uint256 _testParameter2) {
uint256 functionVar;
...
}

}
```

* Events should be emitted immediately after the state change that they
represent, and consequently they should be named in past tense.

```
function _burn(address _who, uint256 _value) internal {
super._burn(_who, _value);
emit TokensBurned(_who, _value);
}
```

}
```
Some standards (e.g. ERC20) use present tense, and in those cases the
standard specification prevails.
>>>>>>> master
4 changes: 1 addition & 3 deletions contracts/examples/SimpleToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ contract SimpleToken is StandardToken {
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances_[msg.sender] = INITIAL_SUPPLY;
emit Transfer(address(0), msg.sender, INITIAL_SUPPLY);
_mint(msg.sender, INITIAL_SUPPLY);
}

}
3 changes: 1 addition & 2 deletions contracts/mocks/BurnableTokenMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import "../token/ERC20/BurnableToken.sol";
contract BurnableTokenMock is BurnableToken {

constructor(address _initialAccount, uint256 _initialBalance) public {
balances_[_initialAccount] = _initialBalance;
totalSupply_ = _initialBalance;
_mint(_initialAccount, _initialBalance);
}

}
3 changes: 1 addition & 2 deletions contracts/mocks/ERC223TokenMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ contract ERC223ContractInterface {
contract ERC223TokenMock is StandardToken {

constructor(address _initialAccount, uint256 _initialBalance) public {
balances_[_initialAccount] = _initialBalance;
totalSupply_ = _initialBalance;
_mint(_initialAccount, _initialBalance);
}

// ERC223 compatible transfer function (except the name)
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/PausableTokenMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../token/ERC20/PausableToken.sol";
contract PausableTokenMock is PausableToken {

constructor(address _initialAccount, uint _initialBalance) public {
balances_[_initialAccount] = _initialBalance;
_mint(_initialAccount, _initialBalance);
}

}
15 changes: 13 additions & 2 deletions contracts/mocks/StandardTokenMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ import "../token/ERC20/StandardToken.sol";
contract StandardTokenMock is StandardToken {

constructor(address _initialAccount, uint256 _initialBalance) public {
balances_[_initialAccount] = _initialBalance;
totalSupply_ = _initialBalance;
_mint(_initialAccount, _initialBalance);
}

function mint(address _account, uint256 _amount) public {
_mint(_account, _amount);
}

function burn(address _account, uint256 _amount) public {
_burn(_account, _amount);
}

function burnFrom(address _account, uint256 _amount) public {
_burnFrom(_account, _amount);
}

}
16 changes: 3 additions & 13 deletions contracts/token/ERC20/BurnableToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,15 @@ contract BurnableToken is StandardToken {
* @param _value uint256 The amount of token to be burned
*/
function burnFrom(address _from, uint256 _value) public {
require(_value <= allowed_[_from][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value);
_burn(_from, _value);
_burnFrom(_from, _value);
}

/**
* @dev Overrides StandardToken._burn in order for burn and burnFrom to emit
* an additional Burn event.
*/
function _burn(address _who, uint256 _value) internal {
require(_value <= balances_[_who]);
// no need to require value <= totalSupply, since that would imply the
// sender's balance is greater than the totalSupply, which *should* be an assertion failure

balances_[_who] = balances_[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
super._burn(_who, _value);
emit TokensBurned(_who, _value);
}
}
3 changes: 1 addition & 2 deletions contracts/token/ERC20/MintableToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ contract MintableToken is StandardToken, Ownable {
canMint
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances_[_to] = balances_[_to].add(_amount);
_mint(_to, _amount);
emit Mint(_to, _amount);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/ERC20/StandardToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import "../../math/SafeMath.sol";
contract StandardToken is ERC20 {
using SafeMath for uint256;

mapping(address => uint256) balances_;
mapping (address => uint256) private balances_;

mapping (address => mapping (address => uint256)) internal allowed_;
mapping (address => mapping (address => uint256)) private allowed_;

uint256 private totalSupply_;

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.