-
-
Notifications
You must be signed in to change notification settings - Fork 249
feat(core-backend): add package #6722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I see that a new PR was created for this package. I looked through this PR and made some comments as it relates to conventions throughout the rest of this monorepo. Take a look and let me know your thoughts.
5b566ef
to
1257213
Compare
a179f5c
to
7a73ee0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fully reviewed the API, and it seems to be organized well. I left more comments, but I think they are all nitpicks at this point. LGTM.
6670c5b
to
bc80f5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
## Release @metamask/core-backend@1.0.0 This PR releases the initial version of the `@metamask/core-backend` package. ### 📦 Package Overview `@metamask/core-backend` provides core backend services for MetaMask, serving as the data layer between Backend services (REST APIs, WebSocket services) and Frontend applications (Extension, Mobile). This package enables authenticated real-time data delivery with type-safe controller integration. ### ✨ What's New in v1.0.0 This is the **initial release** of the package, introducing: #### Core Services - **BackendWebSocketService** - WebSocket client providing authenticated real-time data delivery with: - Connection management and automatic reconnection with exponential backoff - Message routing and subscription management - Authentication integration with `AuthenticationController` - Type-safe messenger-based API for controller integration - **AccountActivityService** - High-level service for monitoring account activity with: - Real-time account activity monitoring via WebSocket subscriptions - Balance update notifications for integration with `TokenBalancesController` - Chain status change notifications for dynamic polling coordination - Account subscription management with automatic cleanup #### Infrastructure - **Type definitions** - Comprehensive TypeScript types for transactions, balances, WebSocket messages, and service configurations - **Logging infrastructure** - Structured logging with module-specific loggers for debugging and monitoring ### 📄 Changelog See [CHANGELOG.md](https://github.com/MetaMask/core/blob/main/packages/core-backend/CHANGELOG.md) for full details. ### 🔗 Related PR - Initial implementation: #6722 ### ✅ Release Checklist - [x] Version bump is correct (1.0.0 for initial release) - [x] Changelog entries are accurate and comprehensive - [x] All changes are properly documented - [x] Package is ready for publication - [x] No additional changes from `main` need to be incorporated ### 📚 Documentation - [Package README](https://github.com/MetaMask/core/blob/main/packages/core-backend/README.md) - [Architecture documentation](https://github.com/MetaMask/core/blob/main/packages/core-backend/README.md#architecture--design) ---
## Release @metamask/core-backend@1.0.0 This PR releases the initial version of the `@metamask/core-backend` package. ### 📦 Package Overview `@metamask/core-backend` provides core backend services for MetaMask, serving as the data layer between Backend services (REST APIs, WebSocket services) and Frontend applications (Extension, Mobile). This package enables authenticated real-time data delivery with type-safe controller integration. ### ✨ What's New in v1.0.0 This is the **initial release** of the package, introducing: #### Core Services - **BackendWebSocketService** - WebSocket client providing authenticated real-time data delivery with: - Connection management and automatic reconnection with exponential backoff - Message routing and subscription management - Authentication integration with `AuthenticationController` - Type-safe messenger-based API for controller integration - **AccountActivityService** - High-level service for monitoring account activity with: - Real-time account activity monitoring via WebSocket subscriptions - Balance update notifications for integration with `TokenBalancesController` - Chain status change notifications for dynamic polling coordination - Account subscription management with automatic cleanup #### Infrastructure - **Type definitions** - Comprehensive TypeScript types for transactions, balances, WebSocket messages, and service configurations - **Logging infrastructure** - Structured logging with module-specific loggers for debugging and monitoring ### 📄 Changelog See [CHANGELOG.md](https://github.com/MetaMask/core/blob/main/packages/core-backend/CHANGELOG.md) for full details. ### 🔗 Related PR - Initial implementation: #6722 ### ✅ Release Checklist - [x] Version bump is correct (1.0.0 for initial release) - [x] Changelog entries are accurate and comprehensive - [x] All changes are properly documented - [x] Package is ready for publication - [x] No additional changes from `main` need to be incorporated ### 📚 Documentation - [Package README](https://github.com/MetaMask/core/blob/main/packages/core-backend/README.md) - [Architecture documentation](https://github.com/MetaMask/core/blob/main/packages/core-backend/README.md#architecture--design) --- <!-- CURSOR_SUMMARY --> > [!NOTE] > Publishes initial @metamask/core-backend v1.0.0 with changelog updates and bumps monorepo version to 606.0.0. > > - **Releases**: > - `@metamask/core-backend@1.0.0`: initial release; adds formal changelog section and release links in `packages/core-backend/CHANGELOG.md`. > - **Versioning**: > - Monorepo `package.json` version bumped `605.0.0` -> `606.0.0`. > - `packages/core-backend/package.json` version set `0.0.0` -> `1.0.0`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 0d6d6dd. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Follow-up of #6490
PR focusing on merging the core-backend package first
Explanation
What is the current state, and why does it need to change?
Currently, MetaMask relies on polling-based HTTP requests to fetch blockchain data like account balances and transaction updates. This approach has several limitations:
What is the solution and how does it work?
This PR introduces the
@metamask/core-backend
package - a new data layer platform that bridges backend services with MetaMask frontend applications through efficient WebSocket-based real-time communication.The solution provides:
BackendWebSocketService: Low-level WebSocket connection management with automatic reconnection, authentication integration, and intelligent message routing
AccountActivityService: High-level service for real-time account activity monitoring
Intelligent Fallback Strategy: Dynamic coordination with existing HTTP polling controllers - when WebSocket is connected, polling intervals increase from 20s to 10 minutes; when disconnected, polling returns to 20s with immediate balance fetches
Key architectural benefits:
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, highlighting breaking changes as necessary
I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
Note
Adds the new @metamask/core-backend package providing a WebSocket client and account activity service, with types, tests, docs, and repo wiring.
packages/core-backend
(new):BackendWebSocketService
: authenticated WS client with reconnection, request/response, subscriptions, channel callbacks, and connection-state events.AccountActivityService
: real-time account activity (transactions/balances), system notifications, selected-account resubscription, and supported-chain fetching/caching.transactions
,balances
, messages), logger, exports, README, CHANGELOG, LICENSE, Jest config, TypeDoc, tsconfigs.core-backend
.tsconfig*.json
) andyarn.lock
.Written by Cursor Bugbot for commit 19edb84. This will update automatically on new commits. Configure here.