If I call a function in another contract that doesn't return a boolean, but has throw() invariant checks, is it safe to assume the function finished properly if the transaction isn't reverted? I ask in the case of a token transfer being called by another contract, since there is no way to know within the contract if the token contract was a success. (ERC-20)
Assume the rest of SampleToken is filled out according to ERC-20 standards.......
contract SampleToken {
/* Send coins */
function transfer(address _to, uint256 _value) {
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
}
}
contract LockContract {
function lockTokens(uint256 _period, uint256 _amount)
external
returns (bool) {
require (sampleToken.transferFrom(msg.sender, this, _amount)); // Tokens are now transfered into this contract
return true;
}
function unlockTokens(uint256 _amountLocked)
external
returns (bool) {
sampleToken.transfer(msg.sender, _amountLocked); // This doesn't return boolean, but will throw if error
return true;
}
}