Unverified Commit 687dc19a by Tal Ater Committed by GitHub

Documented increaseApproval() and decreaseApproval()

parent ddcae625
...@@ -62,10 +62,14 @@ contract StandardToken is ERC20, BasicToken { ...@@ -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 * 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
* @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) { function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
...@@ -73,6 +77,16 @@ contract StandardToken is ERC20, BasicToken { ...@@ -73,6 +77,16 @@ contract StandardToken is ERC20, BasicToken {
return true; 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) { function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender]; uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) { if (_subtractedValue > oldValue) {
......
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