Skip to content
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

Merged
merged 32 commits into from
Mar 25, 2024
Merged

Airdrop #628

merged 32 commits into from
Mar 25, 2024

Conversation

kumaryash90
Copy link
Member

No description provided.

Copy link

codecov bot commented Mar 18, 2024

Codecov Report

Attention: Patch coverage is 90.34483% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 65.26%. Comparing base (494edf8) to head (770874d).

❗ Current head 770874d differs from pull request most recent head 9fe8f19. Consider uploading reports for the commit 9fe8f19 to get more accurate results

Files Patch % Lines
contracts/prebuilts/unaudited/airdrop/Airdrop.sol 90.34% 14 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Comment on lines +183 to +191
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);
}
Comment on lines +272 to +303
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);
}
Comment on lines +193 to +207
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);
}
Comment on lines +245 to +270
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 Low

Comment on lines +193 to +207
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 Low

Comment on lines +363 to +396
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 Low

Comment on lines +183 to +191
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 Low

@kumaryash90 kumaryash90 merged commit b44b563 into main Mar 25, 2024
7 checks passed
@kumaryash90 kumaryash90 deleted the yash/airdrop-combined branch March 25, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants