Skip to content

chore: change TransactionService use in memory cache#53

Open
stanleyyconsensys wants to merge 1 commit intomainfrom
chore/use-inmemory-cache
Open

chore: change TransactionService use in memory cache#53
stanleyyconsensys wants to merge 1 commit intomainfrom
chore/use-inmemory-cache

Conversation

@stanleyyconsensys
Copy link
Copy Markdown
Collaborator

@stanleyyconsensys stanleyyconsensys commented May 6, 2026

Explanation

This PR updates the Snap’s service wiring to use an in-memory cache for TransactionService instead of a state-backed cache, aligning its caching behavior with other services (e.g., PriceService) and avoiding writing transaction-related cache entries into persisted Snap state.

the reason using memory cache is becoz state cache causing some issue on race condition

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Snap’s service wiring to use an in-memory cache for TransactionService instead of a state-backed cache, aligning its caching behavior with other services (e.g., PriceService) and avoiding writing transaction-related cache entries into persisted Snap state.

Changes:

  • Replace StateCache with InMemoryCache for TransactionService caching.
  • Remove the unused StateCache import from the Snap context composition.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 92 to 98
const transactionService = new TransactionService({
logger,
transactionRepository,
networkService,
transactionBuilder,
cache: new StateCache(state, logger, '__cache__transaction'),
cache: new InMemoryCache(noOpLogger),
});
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need

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.

3 participants