-
Notifications
You must be signed in to change notification settings - Fork 230
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
1 parent
14c0b78
commit d8f3834
Showing
1 changed file
with
9 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ contract InstantRewards is Ownable, Pausable, ReentrancyGuard { | |
struct ClaimData { | ||
address to; | ||
Signature signature; | ||
uint256 sigExpiration; | ||
bytes32 taskId; | ||
uint256 amount; | ||
} | ||
|
@@ -28,6 +29,7 @@ contract InstantRewards is Ownable, Pausable, ReentrancyGuard { | |
event Claimed(address indexed to, bytes32 indexed taskId, uint256 amount); | ||
|
||
error InvalidSigner(); | ||
error SignatureExpired(); | ||
error InvalidAddress(); | ||
error TaskAlreadyClaimed(); | ||
error TransferFailed(); | ||
|
@@ -51,11 +53,17 @@ contract InstantRewards is Ownable, Pausable, ReentrancyGuard { | |
); | ||
|
||
if (signerAddress != messageSigner) revert InvalidSigner(); | ||
if (block.timestamp > claimData.sigExpiration) revert SignatureExpired(); | ||
} | ||
Check notice Code scanning / Slither Block timestamp Low
InstantRewards._verify(InstantRewards.ClaimData) uses timestamp for comparisons
Dangerous comparisons: - block.timestamp > claimData.sigExpiration |
||
|
||
// Function to compute the hash of the data and tasks for a token | ||
function _calculateHash(ClaimData memory claimData) private pure returns (bytes32) { | ||
bytes memory encodedData = abi.encode(claimData.to, claimData.taskId, claimData.amount); | ||
bytes memory encodedData = abi.encode( | ||
claimData.to, | ||
claimData.sigExpiration, | ||
claimData.taskId, | ||
claimData.amount | ||
); | ||
|
||
return keccak256(encodedData); | ||
} | ||
|