Skip to content

Commit 5768201

Browse files
xqftjrchatrucJuArce
authored
chore(claim): move state update before call (#1645)
Co-authored-by: Javier Rodríguez Chatruc <[email protected]> Co-authored-by: Julian Arce <[email protected]>
1 parent 6d79fc7 commit 5768201

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

claim_contracts/src/ClaimableAirdrop.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ contract ClaimableAirdrop is
112112

113113
require(verifies, "Invalid Merkle proof");
114114

115+
// Done before the transfer call to make sure the reentrancy bug is not possible
116+
hasClaimed[msg.sender] = true;
117+
115118
bool success = IERC20(tokenProxy).transferFrom(
116119
tokenDistributor,
117120
msg.sender,
@@ -120,8 +123,6 @@ contract ClaimableAirdrop is
120123

121124
require(success, "Failed to transfer funds");
122125

123-
hasClaimed[msg.sender] = true;
124-
125126
emit TokensClaimed(msg.sender, amount);
126127
}
127128

0 commit comments

Comments
 (0)