make StandardToken state variables private
This commit is contained in:
@ -25,21 +25,11 @@ 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);
|
||||
}
|
||||
|
||||
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);
|
||||
super._burn(_who, _value);
|
||||
emit Burn(_who, _value);
|
||||
emit Transfer(_who, address(0), _value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ contract CappedToken is MintableToken {
|
||||
public
|
||||
returns (bool)
|
||||
{
|
||||
require(totalSupply_.add(_amount) <= cap);
|
||||
require(totalSupply().add(_amount) <= cap);
|
||||
|
||||
return super.mint(_to, _amount);
|
||||
}
|
||||
|
||||
@ -41,10 +41,8 @@ contract MintableToken is StandardToken, Ownable {
|
||||
canMint
|
||||
returns (bool)
|
||||
{
|
||||
totalSupply_ = totalSupply_.add(_amount);
|
||||
balances[_to] = balances[_to].add(_amount);
|
||||
emit Mint(_to, _amount);
|
||||
emit Transfer(address(0), _to, _amount);
|
||||
_mint(_to, _amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -14,11 +14,11 @@ 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 totalSupply_;
|
||||
uint256 private totalSupply_;
|
||||
|
||||
/**
|
||||
* @dev Total number of tokens in existence
|
||||
@ -156,4 +156,22 @@ contract StandardToken is ERC20 {
|
||||
return true;
|
||||
}
|
||||
|
||||
function _mint(address _account, uint256 _amount) internal {
|
||||
totalSupply_ = totalSupply_.add(_amount);
|
||||
balances[_account] = balances[_account].add(_amount);
|
||||
emit Transfer(address(0), _account, _amount);
|
||||
}
|
||||
|
||||
function _burn(address _account, uint256 _amount) internal {
|
||||
totalSupply_ = totalSupply_.sub(_amount);
|
||||
balances[_account] = balances[_account].sub(_amount);
|
||||
emit Transfer(_account, address(0), _amount);
|
||||
}
|
||||
|
||||
function _burnFrom(address _account, uint256 _amount) internal {
|
||||
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
|
||||
// this function needs to emit an event with the updated approval.
|
||||
allowed[_account][msg.sender] = allowed[_account][msg.sender].sub(_amount);
|
||||
_burn(_account, _amount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user