Add increase and decrease approval functions to ERC827 with tests
This commit is contained in:
@ -78,4 +78,48 @@ contract ERC827 is StandardToken {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Addition to StandardToken methods. Increase the amount of tokens that
|
||||
* an owner allowed to a spender and execute a call with the sent data.
|
||||
*
|
||||
* 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.
|
||||
* @param _data ABI-encoded contract call to call `_spender` address.
|
||||
*/
|
||||
function increaseApproval(address _spender, uint _addedValue, bytes _data) public returns (bool) {
|
||||
require(_spender != address(this));
|
||||
|
||||
super.approve(_spender, _addedValue);
|
||||
|
||||
require(_spender.call(_data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Addition to StandardToken methods. Decrease the amount of tokens that
|
||||
* an owner allowed to a spender and execute a call with the sent data.
|
||||
*
|
||||
* 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.
|
||||
* @param _data ABI-encoded contract call to call `_spender` address.
|
||||
*/
|
||||
function decreaseApproval(address _spender, uint _subtractedValue, bytes _data) public returns (bool) {
|
||||
require(_spender != address(this));
|
||||
|
||||
super.decreaseApproval(_spender, _subtractedValue);
|
||||
|
||||
require(_spender.call(_data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user