Check result of ERC20 transferFrom call

This commit is contained in:
Mark Spanbroek 2022-02-14 17:12:05 +01:00 committed by markspanbroek
parent 9e0d05965d
commit 2f59927b30
1 changed files with 6 additions and 1 deletions

View File

@ -26,8 +26,13 @@ contract Collateral {
totals.balance -= amount;
}
function transferFrom(address sender, uint256 amount) private {
address receiver = address(this);
require(token.transferFrom(sender, receiver, amount), "Transfer failed");
}
function deposit(uint256 amount) public invariant {
token.transferFrom(msg.sender, address(this), amount);
transferFrom(msg.sender, amount);
totals.deposited += amount;
add(msg.sender, amount);
}