Description
This issue aims to address the implementation of TTL-Cached getBalance.
The core objective is to: Add opt-in TTL-based caching to TrustFlowClient.getBalance (src/client.ts), using the SDK's existing (currently unused) SimpleCache from src/utils/cache.ts, so repeated balance checks for the same address within a short window don't each trigger a fresh server.loadAccount(address) Horizon round-trip. TrustFlowClient.getBalance(address) currently calls this.server.loadAccount(address) on every single invocation with no caching layer — a UI polling balance every few seconds (exactly the pattern src/hooks/useBalance.ts sets up via its useEffect) generates a fresh Horizon request every time even if the balance hasn't changed. src/utils/cache.ts's SimpleCache<K, V> already implements exactly the TTL-expiry primitive this would need, but currently has no real call site anywhere in the codebase.
By completing this feature, we will ensure that the TrustFlow protocol maintains its high standards for security, usability, and decentralized logic. This issue requires careful attention to the SDK Wrapper architecture and adherence to the existing project conventions.
Component
SDK
Difficulty
🟡 Medium
Tasks
Acceptance Criteria
Estimated Time
2-3 days
Description
This issue aims to address the implementation of TTL-Cached getBalance.
The core objective is to: Add opt-in TTL-based caching to
TrustFlowClient.getBalance(src/client.ts), using the SDK's existing (currently unused)SimpleCachefromsrc/utils/cache.ts, so repeated balance checks for the same address within a short window don't each trigger a freshserver.loadAccount(address)Horizon round-trip.TrustFlowClient.getBalance(address)currently callsthis.server.loadAccount(address)on every single invocation with no caching layer — a UI polling balance every few seconds (exactly the patternsrc/hooks/useBalance.tssets up via itsuseEffect) generates a fresh Horizon request every time even if the balance hasn't changed.src/utils/cache.ts'sSimpleCache<K, V>already implements exactly the TTL-expiry primitive this would need, but currently has no real call site anywhere in the codebase.By completing this feature, we will ensure that the TrustFlow protocol maintains its high standards for security, usability, and decentralized logic. This issue requires careful attention to the SDK Wrapper architecture and adherence to the existing project conventions.
Component
SDK
Difficulty
🟡 Medium
Tasks
TrustFlowClient,SimpleCache)TrustFlowClient.getBalanceusingSimpleCache, with a sensible default TTL and a way to force a fresh fetch (e.g. a{ skipCache?: boolean }option)typedoccomments for the new featurenpm run buildto verify standard bundlingAcceptance Criteria
getBalancecall for the same address within the TTL window does not trigger a second Horizon requestEstimated Time
2-3 days