From 23703280ee21d283093812fd1b2166c65de3b187 Mon Sep 17 00:00:00 2001 From: Jorge Izquierdo Date: Mon, 6 Mar 2017 11:02:57 +0100 Subject: [PATCH] Check if tokens are transaferable on approve --- contracts/token/VestedToken.sol | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/contracts/token/VestedToken.sol b/contracts/token/VestedToken.sol index 7cbc41b64..e9985591d 100644 --- a/contracts/token/VestedToken.sol +++ b/contracts/token/VestedToken.sol @@ -15,6 +15,19 @@ contract VestedToken is StandardToken { mapping (address => TokenGrant[]) public grants; + modifier canTransfer(uint _value) { + if (_value > transferableTokens(msg.sender, uint64(now))) throw; + _; + } + + function transfer(address _to, uint _value) canTransfer(_value) returns (bool success) { + return super.transfer(_to, _value); + } + + function approve(address _spender, uint _value) canTransfer(_value) returns (bool success) { + return super.approve(_spender, _value); + } + function grantVestedTokens( address _to, uint256 _value, @@ -126,12 +139,4 @@ contract VestedToken is StandardToken { return safeSub(balances[holder], nonVested); } - - function transfer(address _to, uint _value) returns (bool success) { - if (_value > transferableTokens(msg.sender, uint64(now))) { - throw; - } - - return super.transfer(_to, _value); - } }