Merge pull request #610 from TalAter/master

Documented increaseApproval() and decreaseApproval()
pull/608/merge
Francisco Giordano 7 years ago committed by GitHub
commit 9af6ad5ddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      contracts/token/StandardToken.sol

@ -62,10 +62,14 @@ contract StandardToken is ERC20, BasicToken {
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* 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
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
@ -73,6 +77,16 @@ contract StandardToken is ERC20, BasicToken {
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* 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
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {

Loading…
Cancel
Save