Skip to content

Conversation

@jpuri
Copy link
Contributor

@jpuri jpuri commented Jan 21, 2026

Explanation

This PR implements enhanced transaction history retrieval for the IncomingTransactionHelper. When the enhanced_history_retrieval feature flag is enabled and WebSocket is connected, incoming transactions are fetched via event-driven updates instead of polling, reducing unnecessary API calls and improving responsiveness.

References

Ref: https://github.com/MetaMask/MetaMask-planning/issues/6682

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

Note

Introduces enhanced, event-driven incoming transaction history retrieval.

  • New WebSocket mode in IncomingTransactionHelper subscribes to BackendWebSocketService:connectionStateChanged, AccountActivityService:transactionUpdated, and AccountsController:selectedAccountChange; polling is skipped when enabled
  • Adds isIncomingTransactionsUseWebsocketsEnabled feature flag and tests; retains legacy polling when disabled
  • Extends AllowedEvents in TransactionController and adds @metamask/core-backend dependency plus TS project references
  • Updates changelog and test coverage for connection, account change, and error handling paths

Written by Cursor Bugbot for commit 8453f3b. This will update automatically on new commits. Configure here.

@jpuri jpuri marked this pull request as ready for review January 23, 2026 01:59
@jpuri jpuri requested review from a team as code owners January 23, 2026 01:59
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.


readonly #updateTransactions?: boolean;

readonly #isEnhancedHistoryEnabled: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Minor, alphabetical properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Variable name is changed now.

let connectionStateChangedHandler: (info: WebSocketConnectionInfo) => void;
let selectedAccountChangedHandler: () => void;

beforeEach(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Minor, we usually avoid nested beforeEach and variables in describe to help readability and reuse.

Copy link
Contributor Author

@jpuri jpuri Jan 23, 2026

Choose a reason for hiding this comment

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

I made the beforeEach small but these test cases need different mocking for feature flag thus this nested beforeEach is needed.

*/
export enum FeatureFlag {
EIP7702 = 'confirmations_eip_7702',
EnhancedHistoryRetrieval = 'enhanced_history_retrieval',
Copy link
Member

Choose a reason for hiding this comment

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

Since this is a stand alone boolean, can we instead re-use confirmations_incoming_transactions?

And could we be more specific with the property name, such as useWebsockets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I updated the PR

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@jpuri jpuri requested a review from matthewwalsh0 January 23, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants