Skip to content

fix(client): clear balance cache on switchNetwork (#449) - #480

Open
aazminu wants to merge 1 commit into
trustflow-protocol:mainfrom
aazminu:fix/449
Open

aazminu wants to merge 1 commit into
trustflow-protocol:mainfrom
aazminu:fix/449

Conversation

@aazminu

@aazminu aazminu commented Oct 15, 2026

Copy link
Copy Markdown

Pull Request

Description

Clear this.balanceCache inside TrustFlowClient.switchNetwork(network) so cached balance entries (both bare address keys and multi-account accountId:address keys) do not leak stale balances across network switches within the cache TTL window. Also document the cache invalidation behavior in switchNetwork's JSDoc and add unit tests covering balance cache invalidation on network switch.

Linked Issue

Closes #449

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change - see docs/VERSIONING.md; add a ### Breaking Changes changelog entry and a docs/UPGRADING.md section)
  • Documentation update
  • Dependency update
  • Refactor (no functional changes)

Checklist

Code Quality

  • TypeScript strict mode: no any types in public APIs
  • All public functions have JSDoc comments
  • Code follows the project's style (run npm run format:check to verify)
  • Linting passes: npm run lint
  • Type checking passes: npm run typecheck (and npm run typecheck:tests if tests were modified)

Testing

  • Tests added or updated for new/changed functionality
  • Tests pass: npm run test
  • Test coverage maintained or improved (run npm run test:coverage to check)
  • No unrelated test changes

Documentation

  • CHANGELOG.md updated with entry under [Unreleased] section, formatted as:
    - Issue #449: Clear cached balances in `TrustFlowClient.switchNetwork` so cached entries do not leak across networks.
  • README updated if user-facing features changed
  • API documentation (docs/API.md) updated if public API changed
  • Architecture documentation (docs/ARCHITECTURE.md) updated if module structure/patterns changed
  • JSDoc comments are clear and include examples for complex functions

General

  • No console.log() or debug code left behind
  • No unrelated files committed
  • Branch follows convention: fix/[issue-number] or feature/[description]
  • Commit messages are descriptive and reference issue numbers where applicable

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.

switchNetwork does not clear the balance cache, leaking stale balances across networks

1 participant