Skip to content

Commit

Permalink
fix: added validation to ensure the timestamp range between fromBlock…
Browse files Browse the repository at this point in the history
… and toBlock is valid

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
  • Loading branch information
quiet-node committed Jan 27, 2025
1 parent 12899c7 commit e0cd6be
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ export class CommonService implements ICommonService {
params.timestamp.push(`lte:${toBlockResponse.timestamp.to}`);
toBlockNum = parseInt(toBlockResponse.number);

// Add timestamp range validation (7 days = 604800 seconds)
const timestampDiff = toBlockResponse.timestamp.to - fromBlockResponse.timestamp.from;
if (timestampDiff > 604800) {
throw predefined.TIMESTAMP_RANGE_TOO_LARGE(
`0x${fromBlockNum.toString(16)}`,
fromBlockResponse.timestamp.from,
`0x${toBlockNum.toString(16)}`,
toBlockResponse.timestamp.to,
);
}

if (fromBlockNum > toBlockNum) {
Expand Down

0 comments on commit e0cd6be

Please sign in to comment.