Skip to content

Commit

Permalink
feat(protocol): allow ERC20Airdrop.delegateBySig to fail (#16622)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Apr 4, 2024
1 parent 4516d0a commit d375cc1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/protocol/contracts/team/airdrop/ERC20Airdrop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "./MerkleClaimable.sol";
contract ERC20Airdrop is MerkleClaimable {
using SafeERC20 for IERC20;

/// @notice The address of the token contract.
/// @notice The address of the Taiko token contract.
address public token;

/// @notice The address of the vault contract.
Expand Down Expand Up @@ -72,6 +72,8 @@ contract ERC20Airdrop is MerkleClaimable {
// client can change the data to call delegateBySig for another user.
(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) =
abi.decode(delegationData, (address, uint256, uint256, uint8, bytes32, bytes32));
IVotes(_token).delegateBySig(delegatee, nonce, expiry, v, r, s);

// Allow delegateBySig to fail to avoid potential frontfun
try IVotes(token).delegateBySig(delegatee, nonce, expiry, v, r, s) { } catch { }
}
}
8 changes: 4 additions & 4 deletions packages/protocol/contracts/team/airdrop/ERC20Airdrop2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ contract ERC20Airdrop2 is MerkleClaimable {
/// @notice The address of the vault contract.
address public vault;

/// @notice Length of the withdrawal window.
uint64 public withdrawalWindow;

/// @notice Represents the token amount for which the user has claimed.
mapping(address addr => uint256 amountClaimed) public claimedAmount;

/// @notice Represents the already withdrawn amount.
mapping(address addr => uint256 amountWithdrawn) public withdrawnAmount;

/// @notice Length of the withdrawal window.
uint64 public withdrawalWindow;

uint256[45] private __gap;
uint256[46] private __gap;

/// @notice Event emitted when a user withdraws their tokens.
/// @param user The address of the user.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/team/airdrop/ERC20Airdrop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ contract TestERC20Airdrop is TaikoTest {

delegation = abi.encode(delegatee, nonce, expiry, v, r, s);

vm.expectRevert(); // signature invalid
// vm.expectRevert(); // signature invalid
vm.prank(Lily, Lily);
airdrop.claimAndDelegate(Lily, 100, merkleProof, delegation);
}
Expand Down

0 comments on commit d375cc1

Please sign in to comment.