-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import { IClaimable } from "pt-v5-claimable-interface/interfaces/IClaimable.sol"; | ||
import { Claimer } from "../../src/Claimer.sol"; | ||
|
||
contract ReentrancyMock is IClaimable { | ||
|
||
address public claimer; | ||
address public badGuy; | ||
bytes public reentrancyCalldata; | ||
|
||
constructor(address claimer_) { | ||
claimer = claimer_; | ||
} | ||
|
||
function claimPrize( | ||
address _winner, | ||
uint8 _tier, | ||
uint32 _prizeIndex, | ||
uint96 _reward, | ||
address _rewardRecipient | ||
) external returns (uint256) { | ||
if (_winner == badGuy) { | ||
(bool success, bytes memory data) = claimer.call(reentrancyCalldata); | ||
require(success == false, "reentrancy succeeded..."); | ||
assembly { | ||
revert(add(32, data), mload(data)) | ||
} | ||
} | ||
return 1; | ||
} | ||
|
||
function setReentrancyClaimInfo( | ||
address _badGuy, | ||
IClaimable _vault, | ||
uint8 _tier, | ||
address[] calldata _winners, | ||
uint32[][] calldata _prizeIndices, | ||
address _feeRecipient, | ||
uint256 _minFeePerClaim | ||
) external returns (uint256) { | ||
badGuy = _badGuy; | ||
reentrancyCalldata = abi.encodeWithSelector( | ||
Claimer.claimPrizes.selector, | ||
_vault, | ||
_tier, | ||
_winners, | ||
_prizeIndices, | ||
_feeRecipient, | ||
_minFeePerClaim | ||
); | ||
} | ||
|
||
} |