From 282380156e1732d3b08df483af9d82c165eb7b69 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Mon, 1 May 2017 17:32:33 +0200 Subject: [PATCH] Approve and call fix of the data param construction --- contracts/MiniMeToken.sol | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/contracts/MiniMeToken.sol b/contracts/MiniMeToken.sol index 28582ad..ada60a1 100644 --- a/contracts/MiniMeToken.sol +++ b/contracts/MiniMeToken.sol @@ -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 /// that deploys the contract, so usually this token will be deployed by a /// token controller contract, which Giveth will call a "Campaign" @@ -289,20 +293,13 @@ contract MiniMeToken is Controlled { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); - // This portion is copied from ConsenSys's Standard Token Contract. It - // 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)"))), + ApproveAndCallFallBack(_spender).receiveApproval( msg.sender, _amount, this, _extraData - )) { throw; - } + ); + return true; }