diff options
author | chriseth <chris@ethereum.org> | 2017-01-23 21:58:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-23 21:58:07 +0800 |
commit | 318fbb2604c69dc6eef438aad37b12b99586b198 (patch) | |
tree | d63a7bb18adfefc09b83ff706150732058b9415c | |
parent | c6207e27613f9664c0d79a7c7d91048ec6fc8bfc (diff) | |
download | dexon-solidity-318fbb2604c69dc6eef438aad37b12b99586b198.tar.gz dexon-solidity-318fbb2604c69dc6eef438aad37b12b99586b198.tar.zst dexon-solidity-318fbb2604c69dc6eef438aad37b12b99586b198.zip |
Fix transferFrom.
-rw-r--r-- | std/StandardToken.sol | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/std/StandardToken.sol b/std/StandardToken.sol index f59e04ac..4dad8541 100644 --- a/std/StandardToken.sol +++ b/std/StandardToken.sol @@ -22,19 +22,23 @@ contract StandardToken is Token { } function transfer(address _to, uint256 _value) returns (bool success) { - if (balance[msg.sender] >= _value && balance[_to] + _value >= balance[_to]) { - balance[msg.sender] -= _value; - balance[_to] += _value; - Transfer(msg.sender, _to, _value); + return doTransfer(msg.sender, _to, _value); + } + + function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { + if (m_allowance[_from][msg.sender] >= _value) { + if (doTransfer(_from, _to, _value)) { + m_allowance[_from][msg.sender] -= _value; + } return true; } else { return false; } } - function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { - if (m_allowance[_from][msg.sender] >= _value && balance[_to] + _value >= balance[_to]) { - m_allowance[_from][msg.sender] -= _value; + function doTransfer(address _from, address _to, uint _value) internal returns (bool success) { + if (balance[_from] >= _value && balance[_to] + _value >= balance[_to]) { + balance[_from] -= _value; balance[_to] += _value; Transfer(_from, _to, _value); return true; |