Skip to content

fix: remove no-op clearCache and fix cachedAt typing in claimable service#605

Open
wheval wants to merge 1 commit into
LabsCrypt:mainfrom
wheval:fix/issues-547
Open

fix: remove no-op clearCache and fix cachedAt typing in claimable service#605
wheval wants to merge 1 commit into
LabsCrypt:mainfrom
wheval:fix/issues-547

Conversation

@wheval
Copy link
Copy Markdown
Contributor

@wheval wheval commented Jun 1, 2026

📌 Summary

Removes the misleading no-op clearCache() method from ClaimableAmountService and fixes the type hole on cache-hit responses by declaring cachedAt on ClaimableAmountResult.

🎯 Purpose / Motivation

clearCache() was exported but did nothing, which could mislead callers into thinking cached claimable values were being invalidated. On cache hits, the service returned { ...cachedEntry, cached: true, cachedAt } as any, bypassing TypeScript because cachedAt was not part of the declared result type.

🛠️ Changes Made

  • Removed the empty clearCache() method (no callers in the codebase).
  • Added cachedAt?: string to ClaimableAmountResult so cache-hit metadata is typed correctly.
  • Removed the as any cast on the cache-hit return path.

🧪 How to Test

  1. From backend/, run npm test -- claimable.service.test.ts.
  2. Confirm all tests pass, especially the cache behavior test (uses cache for repeated request with same stream state + timestamp).
  3. Optionally call getClaimableAmount twice with the same input and verify the second response has cached: true and an ISO cachedAt string when served from cache.

⚠️ Breaking Changes

  • None. clearCache() had no references; cachedAt remains optional on responses.

🔗 Related Issues

Closes #547

✅ Checklist

  • Code builds successfully
  • Tests added/updated
  • No console errors
  • Documentation updated (if needed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] claimable.service: remove no-op clearCache() and 'cachedAt as any' type hole

1 participant