Skip to content

Commit

Permalink
remove failsafe and refund from eth airdrop
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaryash90 committed Mar 21, 2024
1 parent aa163a5 commit 556e78f
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions contracts/prebuilts/unaudited/airdrop/Airdrop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,13 @@ contract Airdrop is EIP712, Initializable, Ownable {
uint256 len = _contents.length;

uint256 nativeTokenAmount;
uint256 refundAmount;

for (uint256 i = 0; i < len; ) {
nativeTokenAmount += _contents[i].amount;

(bool success, ) = _contents[i].recipient.call{ value: _contents[i].amount }("");
if (!success) {
refundAmount += _contents[i].amount;
revert AirdropFailed();
}

unchecked {
Expand All @@ -162,13 +161,6 @@ contract Airdrop is EIP712, Initializable, Ownable {
if (nativeTokenAmount != msg.value) {
revert AirdropValueMismatch();
}

if (refundAmount > 0) {
// refund failed payments' amount to sender address
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool refundSuccess, ) = msg.sender.call{ value: refundAmount }("");
}
}

Check failure

Code scanning / Slither

Functions that send Ether to arbitrary destinations High

Check notice

Code scanning / Slither

Calls inside a loop Low

Check warning

Code scanning / Slither

Low-level calls Warning


function airdrop721(address _tokenAddress, AirdropContent721[] calldata _contents) external {
Expand Down Expand Up @@ -251,11 +243,9 @@ contract Airdrop is EIP712, Initializable, Ownable {
revert AirdropVerificationFailed();
}

address _from = owner();
uint256 len = req.contents.length;

uint256 nativeTokenAmount;
uint256 refundAmount;

for (uint256 i = 0; i < len; ) {
nativeTokenAmount += req.contents[i].amount;
Expand All @@ -267,7 +257,7 @@ contract Airdrop is EIP712, Initializable, Ownable {
(bool success, ) = req.contents[i].recipient.call{ value: req.contents[i].amount }("");

if (!success) {
refundAmount += req.contents[i].amount;
revert AirdropFailed();
}

unchecked {
Expand All @@ -278,13 +268,6 @@ contract Airdrop is EIP712, Initializable, Ownable {
if (nativeTokenAmount != msg.value) {
revert AirdropValueMismatch();
}

if (refundAmount > 0) {
// refund failed payments' amount to sender address
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool refundSuccess, ) = _from.call{ value: refundAmount }("");
}
}

Check failure

Code scanning / Slither

Functions that send Ether to arbitrary destinations High

Check notice

Code scanning / Slither

Calls inside a loop Low


function airdrop721WithSignature(AirdropRequest721 calldata req, bytes calldata signature) external {
Expand Down

0 comments on commit 556e78f

Please sign in to comment.