Skip to content

Commit

Permalink
blocklist feature
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTxbi committed Feb 24, 2025
1 parent 0ed9841 commit 6d9eacc
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion smart-contracts/contracts/Airdrops.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
error NOT_AUTHORIZED();
error NOT_OWNER();
error ALREADY_CLAIMED();
error USER_BLOCKED();

/**
* @notice Interface for the Airdrops contract that handles campaign management and token claims
Expand Down Expand Up @@ -49,6 +50,9 @@ contract Airdrops is IAirdrops {
/// @notice Mapping of Merkle tree leaves that have been claimed.
mapping(bytes32 => bytes32) public claimedLeafs;

/// @notice Mapping of addresses that are blocklisted.
mapping(address => bool) public blocklist;

/// @notice Emitted when a campaign is set.
event CampaignSet(string indexed campaignName, bytes32 merkleRoot);
/// @notice Emitted when a recipient signs the TOS.
Expand Down Expand Up @@ -144,7 +148,8 @@ contract Airdrops is IAirdrops {
uint256 amount,
bytes calldata proof
) external override {
// Removed check for msg.sender equality to recipient to allow claims on behalf of someone else.
// Blocked users are not allowed to claim tokens.
if (blocklist[recipient]) revert USER_BLOCKED();

// Ensure the TOS has been signed. The stored pseudo transaction hash must be non-zero.
if (signedTos[campaignName][recipient] == bytes32(0)) revert NOT_AUTHORIZED();
Expand Down Expand Up @@ -174,6 +179,22 @@ contract Airdrops is IAirdrops {
emit TokensClaimed(campaignName, recipient, amount);
}

/**
* @notice Adds an address to the blocklist.
* @param user The address to be added to the blocklist.
*/
function addToBlocklist(address user) external onlyOwner {
blocklist[user] = true;
}

/**
* @notice Removes an address from the blocklist.
* @param user The address to be removed from the blocklist.
*/
function removeFromBlocklist(address user) external onlyOwner {
blocklist[user] = false;
}

/**
* @notice Internal helper to convert a bytes blob into an array of bytes32.
* @param data The concatenated bytes (proof) to be split.
Expand Down

0 comments on commit 6d9eacc

Please sign in to comment.