Skip to content

docs(cache): document contract-cache layer and add-a-reader recipe#489

Open
Tobi-8 wants to merge 1 commit into
Remitwise-Org:mainfrom
Tobi-8:docs/contract-cache-guide
Open

docs(cache): document contract-cache layer and add-a-reader recipe#489
Tobi-8 wants to merge 1 commit into
Remitwise-Org:mainfrom
Tobi-8:docs/contract-cache-guide

Conversation

@Tobi-8

@Tobi-8 Tobi-8 commented Jun 17, 2026

Copy link
Copy Markdown

Description

The frontend's contract cache layer (lib/cache/contract-cache.ts) and registry required clear documentation to prevent misuse (e.g., caching write operations or post-transfer balances, or setting improper TTLs) and help contributors confidently add new cached reads.

This PR introduces comprehensive documentation for the caching subsystem without altering its core behavior.

Changes Made

  • TSDoc Added: Documented public functions across lib/cache/contract-cache.ts and lib/cache/registry.ts detailing parameters, invalidation, safety protocols, and TTL semantics.
  • Cache Guide Created: Added docs/contract-cache.md which thoroughly explains:
    • The read/cache/invalidate lifecycle.
    • The manual invalidation API endpoint.
    • A step-by-step recipe for safely adding a new cached read.
    • Critical edge cases (e.g., what must never be cached).
  • README Cross-link: Linked the new caching guide under the Project Structure section in the main README.md.
  • Test Fixes: Fixed a bug in tests/unit/cached-wrappers.test.ts where mock Stellar addresses were 58 characters long. They have been updated to 56 characters so they validate seamlessly against the STELLAR_ADDRESS_REGEX.

Verification

  • All unit tests (including conceptual cache tests) pass locally (npm run test:unit).
  • Linter passes on all modified files without warnings (npm run lint).

closes #477

Adds TSDoc to cache/registry plus docs/contract-cache.md covering TTL,
invalidation, and a step-by-step new cached read recipe.
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.

Add JSDoc/TSDoc and a usage guide for the cached contract-read layer (lib/contracts + lib/cache/contract-cache.ts)

1 participant