Make ERC827 methods payable (#838)
* Make ERC827 methods payable * Suppress linter errors * Add some ERC827 payable tests * Remove failOnBuy method from MessageHelper * Fix linter warning * Fix tests
This commit is contained in:
committed by
Augusto Lemble
parent
16535fbb87
commit
8f2a4785cb
@ -12,8 +12,8 @@ import "../ERC20/ERC20.sol";
|
||||
* @dev approvals.
|
||||
*/
|
||||
contract ERC827 is ERC20 {
|
||||
function approveAndCall( address _spender, uint256 _value, bytes _data) public returns (bool);
|
||||
function transferAndCall( address _to, uint256 _value, bytes _data) public returns (bool);
|
||||
function approveAndCall( address _spender, uint256 _value, bytes _data) public payable returns (bool);
|
||||
function transferAndCall( address _to, uint256 _value, bytes _data) public payable returns (bool);
|
||||
function transferFromAndCall(
|
||||
address _from,
|
||||
address _to,
|
||||
@ -21,5 +21,6 @@ contract ERC827 is ERC20 {
|
||||
bytes _data
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (bool);
|
||||
}
|
||||
|
||||
@ -34,12 +34,13 @@ contract ERC827Token is ERC827, StandardToken {
|
||||
*
|
||||
* @return true if the call function was executed successfully
|
||||
*/
|
||||
function approveAndCall(address _spender, uint256 _value, bytes _data) public returns (bool) {
|
||||
function approveAndCall(address _spender, uint256 _value, bytes _data) public payable returns (bool) {
|
||||
require(_spender != address(this));
|
||||
|
||||
super.approve(_spender, _value);
|
||||
|
||||
require(_spender.call(_data));
|
||||
// solium-disable-next-line security/no-call-value
|
||||
require(_spender.call.value(msg.value)(_data));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -54,12 +55,13 @@ contract ERC827Token is ERC827, StandardToken {
|
||||
*
|
||||
* @return true if the call function was executed successfully
|
||||
*/
|
||||
function transferAndCall(address _to, uint256 _value, bytes _data) public returns (bool) {
|
||||
function transferAndCall(address _to, uint256 _value, bytes _data) public payable returns (bool) {
|
||||
require(_to != address(this));
|
||||
|
||||
super.transfer(_to, _value);
|
||||
|
||||
require(_to.call(_data));
|
||||
// solium-disable-next-line security/no-call-value
|
||||
require(_to.call.value(msg.value)(_data));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -80,13 +82,14 @@ contract ERC827Token is ERC827, StandardToken {
|
||||
uint256 _value,
|
||||
bytes _data
|
||||
)
|
||||
public returns (bool)
|
||||
public payable returns (bool)
|
||||
{
|
||||
require(_to != address(this));
|
||||
|
||||
super.transferFrom(_from, _to, _value);
|
||||
|
||||
require(_to.call(_data));
|
||||
// solium-disable-next-line security/no-call-value
|
||||
require(_to.call.value(msg.value)(_data));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -103,12 +106,13 @@ contract ERC827Token is ERC827, StandardToken {
|
||||
* @param _addedValue The amount of tokens to increase the allowance by.
|
||||
* @param _data ABI-encoded contract call to call `_spender` address.
|
||||
*/
|
||||
function increaseApprovalAndCall(address _spender, uint _addedValue, bytes _data) public returns (bool) {
|
||||
function increaseApprovalAndCall(address _spender, uint _addedValue, bytes _data) public payable returns (bool) {
|
||||
require(_spender != address(this));
|
||||
|
||||
super.increaseApproval(_spender, _addedValue);
|
||||
|
||||
require(_spender.call(_data));
|
||||
// solium-disable-next-line security/no-call-value
|
||||
require(_spender.call.value(msg.value)(_data));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -126,12 +130,13 @@ contract ERC827Token is ERC827, StandardToken {
|
||||
* @param _subtractedValue The amount of tokens to decrease the allowance by.
|
||||
* @param _data ABI-encoded contract call to call `_spender` address.
|
||||
*/
|
||||
function decreaseApprovalAndCall(address _spender, uint _subtractedValue, bytes _data) public returns (bool) {
|
||||
function decreaseApprovalAndCall(address _spender, uint _subtractedValue, bytes _data) public payable returns (bool) {
|
||||
require(_spender != address(this));
|
||||
|
||||
super.decreaseApproval(_spender, _subtractedValue);
|
||||
|
||||
require(_spender.call(_data));
|
||||
// solium-disable-next-line security/no-call-value
|
||||
require(_spender.call.value(msg.value)(_data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user