-
Notifications
You must be signed in to change notification settings - Fork 555
Airdrop #628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Airdrop #628
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #628 +/- ##
==========================================
+ Coverage 64.72% 65.26% +0.54%
==========================================
Files 216 217 +1
Lines 6702 6847 +145
==========================================
+ Hits 4338 4469 +131
- Misses 2364 2378 +14 ☔ View full report in Codecov by Sentry. |
function airdropERC20WithSignature(AirdropRequestERC20 calldata req, bytes calldata signature) external { | ||
// verify expiration timestamp | ||
if (req.expirationTimestamp < block.timestamp) { | ||
revert AirdropRequestExpired(req.expirationTimestamp); | ||
} | ||
|
||
if (processed[req.uid]) { | ||
revert AirdropRequestAlreadyProcessed(); | ||
} | ||
|
||
// verify data | ||
if (!_verifyRequestSignerERC20(req, signature)) { | ||
revert AirdropRequestInvalidSigner(); | ||
} | ||
|
||
processed[req.uid] = true; | ||
|
||
uint256 len = req.contents.length; | ||
address _from = owner(); | ||
|
||
for (uint256 i = 0; i < len; i++) { | ||
SafeTransferLib.safeTransferFrom( | ||
req.tokenAddress, | ||
_from, | ||
req.contents[i].recipient, | ||
req.contents[i].amount | ||
); | ||
} | ||
|
||
emit Airdrop(req.tokenAddress); | ||
} |
Check failure
Code scanning / Slither
Arbitrary `from` in transferFrom
function claimERC20(address _token, address _receiver, uint256 _quantity, bytes32[] calldata _proofs) external { | ||
bytes32 claimHash = _getClaimHashERC20(_receiver, _token); | ||
uint256 conditionId = tokenConditionId[_token]; | ||
|
||
if (claimed[conditionId][claimHash]) { | ||
revert AirdropAlreadyClaimed(); | ||
} | ||
|
||
bytes32 _tokenMerkleRoot = tokenMerkleRoot[_token]; | ||
if (_tokenMerkleRoot == bytes32(0)) { | ||
revert AirdropNoMerkleRoot(); | ||
} | ||
|
||
bool valid = MerkleProofLib.verify( | ||
_proofs, | ||
_tokenMerkleRoot, | ||
keccak256(abi.encodePacked(_receiver, _quantity)) | ||
); | ||
if (!valid) { | ||
revert AirdropInvalidProof(); | ||
} | ||
|
||
claimed[conditionId][claimHash] = true; | ||
|
||
SafeTransferLib.safeTransferFrom(_token, owner(), _receiver, _quantity); | ||
|
||
emit AirdropClaimed(_token, _receiver); | ||
} |
Check failure
Code scanning / Slither
Arbitrary `from` in transferFrom
function airdropERC721(address _tokenAddress, AirdropContentERC721[] calldata _contents) external onlyOwner { | ||
uint256 len = _contents.length; | ||
|
||
for (uint256 i = 0; i < len; i++) { | ||
IERC721(_tokenAddress).safeTransferFrom(msg.sender, _contents[i].recipient, _contents[i].tokenId); | ||
} | ||
|
||
emit Airdrop(_tokenAddress); | ||
} |
Check notice
Code scanning / Slither
Calls inside a loop
function airdropERC1155WithSignature(AirdropRequestERC1155 calldata req, bytes calldata signature) external { | ||
// verify expiration timestamp | ||
if (req.expirationTimestamp < block.timestamp) { | ||
revert AirdropRequestExpired(req.expirationTimestamp); | ||
} | ||
|
||
if (processed[req.uid]) { | ||
revert AirdropRequestAlreadyProcessed(); | ||
} | ||
|
||
// verify data | ||
if (!_verifyRequestSignerERC1155(req, signature)) { | ||
revert AirdropRequestInvalidSigner(); | ||
} | ||
|
||
processed[req.uid] = true; | ||
|
||
address _from = owner(); | ||
uint256 len = req.contents.length; | ||
|
||
for (uint256 i = 0; i < len; i++) { | ||
IERC1155(req.tokenAddress).safeTransferFrom( | ||
_from, | ||
req.contents[i].recipient, | ||
req.contents[i].tokenId, | ||
req.contents[i].amount, | ||
"" | ||
); | ||
} | ||
|
||
emit Airdrop(req.tokenAddress); | ||
} |
Check notice
Code scanning / Slither
Calls inside a loop
function airdropERC1155(address _tokenAddress, AirdropContentERC1155[] calldata _contents) external onlyOwner { | ||
uint256 len = _contents.length; | ||
|
||
for (uint256 i = 0; i < len; i++) { | ||
IERC1155(_tokenAddress).safeTransferFrom( | ||
msg.sender, | ||
_contents[i].recipient, | ||
_contents[i].tokenId, | ||
_contents[i].amount, | ||
"" | ||
); | ||
} | ||
|
||
emit Airdrop(_tokenAddress); | ||
} |
Check notice
Code scanning / Slither
Calls inside a loop
function airdropERC721WithSignature(AirdropRequestERC721 calldata req, bytes calldata signature) external { | ||
// verify expiration timestamp | ||
if (req.expirationTimestamp < block.timestamp) { | ||
revert AirdropRequestExpired(req.expirationTimestamp); | ||
} | ||
|
||
if (processed[req.uid]) { | ||
revert AirdropRequestAlreadyProcessed(); | ||
} | ||
|
||
// verify data | ||
if (!_verifyRequestSignerERC721(req, signature)) { | ||
revert AirdropRequestInvalidSigner(); | ||
} | ||
|
||
processed[req.uid] = true; | ||
|
||
address _from = owner(); | ||
uint256 len = req.contents.length; | ||
|
||
for (uint256 i = 0; i < len; i++) { | ||
IERC721(req.tokenAddress).safeTransferFrom(_from, req.contents[i].recipient, req.contents[i].tokenId); | ||
} | ||
|
||
emit Airdrop(req.tokenAddress); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function airdropERC1155(address _tokenAddress, AirdropContentERC1155[] calldata _contents) external onlyOwner { | ||
uint256 len = _contents.length; | ||
|
||
for (uint256 i = 0; i < len; i++) { | ||
IERC1155(_tokenAddress).safeTransferFrom( | ||
msg.sender, | ||
_contents[i].recipient, | ||
_contents[i].tokenId, | ||
_contents[i].amount, | ||
"" | ||
); | ||
} | ||
|
||
emit Airdrop(_tokenAddress); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function claimERC1155( | ||
address _token, | ||
address _receiver, | ||
uint256 _tokenId, | ||
uint256 _quantity, | ||
bytes32[] calldata _proofs | ||
) external { | ||
bytes32 claimHash = _getClaimHashERC1155(_receiver, _token, _tokenId); | ||
uint256 conditionId = tokenConditionId[_token]; | ||
|
||
if (claimed[conditionId][claimHash]) { | ||
revert AirdropAlreadyClaimed(); | ||
} | ||
|
||
bytes32 _tokenMerkleRoot = tokenMerkleRoot[_token]; | ||
if (_tokenMerkleRoot == bytes32(0)) { | ||
revert AirdropNoMerkleRoot(); | ||
} | ||
|
||
bool valid = MerkleProofLib.verify( | ||
_proofs, | ||
_tokenMerkleRoot, | ||
keccak256(abi.encodePacked(_receiver, _tokenId, _quantity)) | ||
); | ||
if (!valid) { | ||
revert AirdropInvalidProof(); | ||
} | ||
|
||
claimed[conditionId][claimHash] = true; | ||
|
||
IERC1155(_token).safeTransferFrom(owner(), _receiver, _tokenId, _quantity, ""); | ||
|
||
emit AirdropClaimed(_token, _receiver); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function airdropERC721(address _tokenAddress, AirdropContentERC721[] calldata _contents) external onlyOwner { | ||
uint256 len = _contents.length; | ||
|
||
for (uint256 i = 0; i < len; i++) { | ||
IERC721(_tokenAddress).safeTransferFrom(msg.sender, _contents[i].recipient, _contents[i].tokenId); | ||
} | ||
|
||
emit Airdrop(_tokenAddress); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function airdropNativeToken(AirdropContentERC20[] calldata _contents) external payable onlyOwner { | ||
uint256 len = _contents.length; | ||
uint256 nativeTokenAmount; | ||
|
||
for (uint256 i = 0; i < len; i++) { | ||
nativeTokenAmount += _contents[i].amount; | ||
(bool success, ) = _contents[i].recipient.call{ value: _contents[i].amount }(""); | ||
if (!success) { | ||
revert AirdropFailed(); | ||
} | ||
} | ||
|
||
if (nativeTokenAmount != msg.value) { | ||
revert AirdropValueMismatch(); | ||
} | ||
|
||
emit Airdrop(NATIVE_TOKEN_ADDRESS); | ||
} |
Check warning
Code scanning / Slither
Low-level calls
No description provided.