Skip to content

Commit f5df11f

Browse files
committed
call external functions only after state changes
1 parent b980a5c commit f5df11f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

contracts/TokenLock.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ contract TokenLock is OwnableUpgradeable, IERC20 {
5151
revert DepositPeriodOver();
5252
}
5353

54+
balanceOf[msg.sender] += amount;
55+
totalSupply += amount;
56+
5457
if (!token.transferFrom(msg.sender, address(this), amount)) {
5558
revert TransferFailed();
5659
}
57-
balanceOf[msg.sender] += amount;
58-
totalSupply += amount;
5960

6061
emit Transfer(msg.sender, address(this), amount);
6162
}
@@ -75,6 +76,7 @@ contract TokenLock is OwnableUpgradeable, IERC20 {
7576

7677
balanceOf[msg.sender] -= amount;
7778
totalSupply -= amount;
79+
7880
if (!token.transfer(msg.sender, amount)) {
7981
revert TransferFailed();
8082
}

0 commit comments

Comments
 (0)