[BUG] Contract spec caching doesn't invalidate when switching the configured network, serving a mainnet-cached spec while connected to testnet

Open Beginner friendly
#1,000 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start by locating the contract-spec cache and the code that builds its spec:{contractId} key. Check how the configured network is represented when the contract client is initialized or switched. Include that network identifier in the key, then verify that switching networks with the same contract ID uses a separate cached spec.

Written by the indexing model from the issue text.

Description

bug core difficulty: medium good first issue priority: medium sdk

Description

The contract-spec cache is keyed only by contract ID, not by network, so if an app switches its client from mainnet to testnet mid-session (e.g. a dev tool with a network switcher) while using the same contract ID value on both networks, it can serve the wrong network's cached spec.

Component

contract

Steps to Reproduce

  1. Initialize a contract client against mainnet for a given contract ID, populating the spec cache.
  2. Switch the client's network to testnet using the same contract ID.
  3. Make an invocation.

Expected Behavior

The contract-spec cache key should include the network, not just the contract ID.

Actual Behavior

Switching networks with the same contract ID can silently use the wrong network's cached spec, which could produce confusing invocation errors or, worse, an invocation built against the wrong ABI.

Environment

  • SDK version: 0.3.x
  • Node version: 20.x, 22.x
  • OS: macOS / Linux
  • Network: TESTNET

Code Example

// Not applicable — reproduced via API inspection, not a standalone snippet.

Error Output

The cache key is `spec:{contractId}` without a network component.

Difficulty

🟡 Medium

Additional Context

Include the network identifier in the contract-spec cache key.

Dominant language
TypeScript
Stars
0
Forks
73
Avg merge
6h 26m
Merged PRs (30d)
37

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from trustflow-protocol/trustflow-sdk

All issues in trustflow-protocol/trustflow-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.