📋 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
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. 🚀
📋 Description
The cached read wrappers
lib/contracts/insurance-cached.tsandlib/contracts/remittance-split-cached.tssit between API routes and the raw contract reads, adding LRU caching (vialib/cache/contract-cache.ts), per-method TTLs (e.g.getActivePolicies45s,getSplit60s), 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.🎯 Requirements & Context
Functional requirements
docs/cached-contract-reads.mdexplaining: when to use cached vs raw reads, the per-method TTLs (cross-reference theCACHE_TTLtable inlib/cache/contract-cache.ts), and the cascading cache behavior.lib/README.md.Context & constraints
🛠️ Suggested Execution
1. Branch
2. Write & verify
Example commit message
✅ Acceptance Criteria & Guidelines
npx tsc --noEmit+npm run lintclean💬 Community & Support
Questions — join the RemitWise contributor community on Discord: https://discord.gg/CtQuPZFMA
Comment when you pick this up. 🚀