Skip to content

Commit

Permalink
add reentrancy guard (#12447)
Browse files Browse the repository at this point in the history
Signed-off-by: Borja Aranda <[email protected]>
  • Loading branch information
Francisco de Borja Aranda Castillejo committed Mar 19, 2024
1 parent dfcd7aa commit ee06eb2
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ contract LinkAvailableBalanceMonitor is AccessControl, AutomationCompatibleInter
for (uint256 idx = 0; idx < targetAddresses.length; idx++) {
address targetAddress = targetAddresses[idx];
contractToFund = s_targets[targetAddress];
s_targets[targetAddress].lastTopUpTimestamp = uint56(block.timestamp);
if (
localBalance >= contractToFund.topUpAmount &&
_needsFunding(
Expand All @@ -278,12 +279,12 @@ contract LinkAvailableBalanceMonitor is AccessControl, AutomationCompatibleInter
bool success = i_linkToken.transfer(targetAddress, contractToFund.topUpAmount);
if (success) {
localBalance -= contractToFund.topUpAmount;
s_targets[targetAddress].lastTopUpTimestamp = uint56(block.timestamp);
emit TopUpSucceeded(targetAddress);
} else {
emit TopUpFailed(targetAddress);
}
} else {
s_targets[targetAddress].lastTopUpTimestamp = contractToFund.lastTopUpTimestamp;
emit TopUpBlocked(targetAddress);
}
}
Expand Down

0 comments on commit ee06eb2

Please sign in to comment.