@@ -4,9 +4,14 @@ import bs58 from 'bs58';
44import { TTLCache } from './cache' ;
55
66const nonceCache = new TTLCache < string > ( 300 ) ; // 5min TTL for nonces
7- const usageCache = new TTLCache < number > ( 3600 ) ; // 1hr window for rate limiting
7+ const usageCache = new TTLCache < number > ( 86400 ) ; // 24hr window for rate limiting
88
9- const MAX_SCANS_PER_HOUR = 10 ;
9+ const MAX_SCANS_PER_DAY = 3 ;
10+
11+ // Wallets exempt from rate limits (admin/dev wallets)
12+ const UNLIMITED_WALLETS = new Set ( [
13+ '5rSwWRfqGvnQaiJpW3sb3YKLbxtjVxgc4yrvrHNeNwE2' ,
14+ ] ) ;
1015
1116function getJwtSecret ( ) : string {
1217 const secret = process . env . JWT_SECRET ;
@@ -64,8 +69,14 @@ export function verifyToken(token: string): string | null {
6469
6570/** Check if a wallet has remaining rate limit */
6671export function checkRateLimit ( wallet : string ) : boolean {
72+ if ( UNLIMITED_WALLETS . has ( wallet ) ) return true ;
6773 const usage = usageCache . get ( wallet ) || 0 ;
68- return usage < MAX_SCANS_PER_HOUR ;
74+ return usage < MAX_SCANS_PER_DAY ;
75+ }
76+
77+ /** Check if a wallet has unlimited access */
78+ export function isUnlimited ( wallet : string ) : boolean {
79+ return UNLIMITED_WALLETS . has ( wallet ) ;
6980}
7081
7182/** Increment scan usage for a wallet */
@@ -77,7 +88,7 @@ export function incrementUsage(wallet: string): void {
7788/** Get remaining scans for a wallet */
7889export function getRemainingScans ( wallet : string ) : number {
7990 const usage = usageCache . get ( wallet ) || 0 ;
80- return Math . max ( 0 , MAX_SCANS_PER_HOUR - usage ) ;
91+ return Math . max ( 0 , MAX_SCANS_PER_DAY - usage ) ;
8192}
8293
8394/** Get current usage count for a wallet */
@@ -86,4 +97,4 @@ export function getUsageCount(wallet: string): number {
8697}
8798
8899/** The max scans per hour constant */
89- export const SCANS_LIMIT = MAX_SCANS_PER_HOUR ;
100+ export const SCANS_LIMIT = MAX_SCANS_PER_DAY ;
0 commit comments