mirror of https://github.com/vacp2p/minime.git
Merge pull request #12 from Giveth/approveAndCallFix
Approve and call fix
This commit is contained in:
commit
a3204ab85a
|
@ -67,6 +67,10 @@ contract Controlled {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contract ApproveAndCallFallBack {
|
||||||
|
function receiveApproval(address from, uint256 _amount, address _token, bytes _data);
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev The actual token contract, the default controller is the msg.sender
|
/// @dev The actual token contract, the default controller is the msg.sender
|
||||||
/// that deploys the contract, so usually this token will be deployed by a
|
/// that deploys the contract, so usually this token will be deployed by a
|
||||||
/// token controller contract, which Giveth will call a "Campaign"
|
/// token controller contract, which Giveth will call a "Campaign"
|
||||||
|
@ -287,23 +291,15 @@ contract MiniMeToken is Controlled {
|
||||||
/// @return True if the function call was successful
|
/// @return True if the function call was successful
|
||||||
function approveAndCall(address _spender, uint256 _amount, bytes _extraData
|
function approveAndCall(address _spender, uint256 _amount, bytes _extraData
|
||||||
) returns (bool success) {
|
) returns (bool success) {
|
||||||
allowed[msg.sender][_spender] = _amount;
|
if (!approve(_spender, _amount)) throw;
|
||||||
Approval(msg.sender, _spender, _amount);
|
|
||||||
|
|
||||||
// This portion is copied from ConsenSys's Standard Token Contract. It
|
ApproveAndCallFallBack(_spender).receiveApproval(
|
||||||
// calls the receiveApproval function that is part of the contract that
|
|
||||||
// is being approved (`_spender`). The function should look like:
|
|
||||||
// `receiveApproval(address _from, uint256 _amount, address
|
|
||||||
// _tokenContract, bytes _extraData)` It is assumed that the call
|
|
||||||
// *should* succeed, otherwise the plain vanilla approve would be used
|
|
||||||
if(!_spender.call(
|
|
||||||
bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))),
|
|
||||||
msg.sender,
|
msg.sender,
|
||||||
_amount,
|
_amount,
|
||||||
this,
|
this,
|
||||||
_extraData
|
_extraData
|
||||||
)) { throw;
|
);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue