Skip to content

Document and TSDoc the cached contract-read wrappers (insurance-cached, remittance-split-cached) and their validation contract #655

Description

@Baskarayelu

📋 Description

The cached read wrappers lib/contracts/insurance-cached.ts and lib/contracts/remittance-split-cached.ts sit between API routes and the raw contract reads, adding LRU caching (via lib/cache/contract-cache.ts), per-method TTLs (e.g. getActivePolicies 45s, getSplit 60s), input validation (Stellar address regex, policy-id format, integer amounts), and error-code preservation (INVALID_ADDRESS, NOT_FOUND). This validation/caching contract is non-obvious and undocumented.

Why this matters: a contributor calling the raw vs cached function has no guidance on which to use, what TTL applies, what inputs are rejected, or which error codes propagate. The cascading cache (calculateSplit reuses getSplit's cache) is especially easy to misuse. A focused doc + TSDoc makes the layer safe to consume.

🎯 Requirements & Context

Functional requirements

  • Add docs/cached-contract-reads.md explaining: when to use cached vs raw reads, the per-method TTLs (cross-reference the CACHE_TTL table in lib/cache/contract-cache.ts), and the cascading cache behavior.
  • Document the validation rules each wrapper enforces and the error codes it preserves vs wraps.
  • Add/improve TSDoc on every exported function in the two cached modules (params, throws, cache behavior).
  • Include a "gotchas" section (e.g. invalidation, integer-only amounts, address format).
  • Cross-link from lib/README.md.

Context & constraints

  • Verify TTLs and validation against the source before documenting.
  • Docs + TSDoc only; no behavior change.

🛠️ Suggested Execution

1. Branch

git checkout -b docs/cached-contract-reads

2. Write & verify

npx tsc --noEmit
npm run lint
  • Confirm each documented TTL/validation matches code.

Example commit message

docs(contracts): document cached read wrappers + validation/TTL contract

Adds docs/cached-contract-reads.md and TSDoc for insurance-cached and
remittance-split-cached, including cascading-cache gotchas.

✅ Acceptance Criteria & Guidelines

Requirement Target
Cached-vs-raw guidance + TTLs documented Required
Validation rules + error-code behavior documented Required
TSDoc on all exported functions Required
References match source Required
npx tsc --noEmit + npm run lint clean Required
Timeframe 96 hours from assignment

💬 Community & Support

Questions — join the RemitWise contributor community on Discord: https://discord.gg/CtQuPZFMA

Comment when you pick this up. 🚀

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions