* Add StandardBurnableToken implementation BurnableToken that extends from StandardToken and adds a burnFrom method that decrements allowance. Equivalent to a transferFrom plus burn in a single operation. * Return event object from expectEvent helper * Add comment on Approval event in burnFrom function * Improvements on burnable token tests - Inject initial balance as a parameter to the behaviour - Use expectEvent helper for assertions on events - Use chai bignumber for numbers - Change to bdd-style assertions
25 lines
862 B
Solidity
25 lines
862 B
Solidity
pragma solidity ^0.4.18;
|
|
|
|
import "./BurnableToken.sol";
|
|
import "./StandardToken.sol";
|
|
|
|
/**
|
|
* @title Standard Burnable Token
|
|
* @dev Adds burnFrom method to ERC20 implementations
|
|
*/
|
|
contract StandardBurnableToken is BurnableToken, StandardToken {
|
|
|
|
/**
|
|
* @dev Burns a specific amount of tokens from the target address and decrements allowance
|
|
* @param _from address The address which you want to send tokens from
|
|
* @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);
|
|
}
|
|
}
|