Skip to content

Commit

Permalink
add expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Aug 23, 2024
1 parent 14c0b78 commit d8f3834
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contract InstantRewards is Ownable, Pausable, ReentrancyGuard {
struct ClaimData {
address to;
Signature signature;
uint256 sigExpiration;
bytes32 taskId;
uint256 amount;
}
Expand All @@ -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();
Expand All @@ -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


// 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);
}
Expand Down

0 comments on commit d8f3834

Please sign in to comment.