@metamask-previews/core-backend 12.3.0-preview-5990812f2 → 12.3.0-preview-7fb08ad32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +3 -5
  2. package/dist/api/test-utils.d.ts +29 -0
  3. package/dist/api/test-utils.d.ts.map +1 -0
  4. package/dist/api/test-utils.js +64 -0
  5. package/dist/api/test-utils.js.map +1 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +8 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/ws/ChannelSubscriptionManager.d.ts +92 -0
  11. package/dist/ws/ChannelSubscriptionManager.d.ts.map +1 -0
  12. package/dist/ws/ChannelSubscriptionManager.js +390 -0
  13. package/dist/ws/ChannelSubscriptionManager.js.map +1 -0
  14. package/dist/ws/launchpad/LaunchpadTokenDetailsService-method-action-types.d.ts +35 -0
  15. package/dist/ws/launchpad/LaunchpadTokenDetailsService-method-action-types.d.ts.map +1 -0
  16. package/dist/ws/launchpad/LaunchpadTokenDetailsService-method-action-types.js +6 -0
  17. package/dist/ws/launchpad/LaunchpadTokenDetailsService-method-action-types.js.map +1 -0
  18. package/dist/ws/launchpad/LaunchpadTokenDetailsService.d.ts +115 -0
  19. package/dist/ws/launchpad/LaunchpadTokenDetailsService.d.ts.map +1 -0
  20. package/dist/ws/launchpad/LaunchpadTokenDetailsService.js +193 -0
  21. package/dist/ws/launchpad/LaunchpadTokenDetailsService.js.map +1 -0
  22. package/dist/ws/launchpad/index.d.ts +6 -0
  23. package/dist/ws/launchpad/index.d.ts.map +1 -0
  24. package/dist/ws/launchpad/index.js +4 -0
  25. package/dist/ws/launchpad/index.js.map +1 -0
  26. package/dist/ws/launchpad/normalize.d.ts +37 -0
  27. package/dist/ws/launchpad/normalize.d.ts.map +1 -0
  28. package/dist/ws/launchpad/normalize.js +125 -0
  29. package/dist/ws/launchpad/normalize.js.map +1 -0
  30. package/dist/ws/launchpad/types.d.ts +132 -0
  31. package/dist/ws/launchpad/types.d.ts.map +1 -0
  32. package/dist/ws/launchpad/types.js +11 -0
  33. package/dist/ws/launchpad/types.js.map +1 -0
  34. package/dist/ws/ohlcv/OHLCVService.d.ts +5 -2
  35. package/dist/ws/ohlcv/OHLCVService.d.ts.map +1 -1
  36. package/dist/ws/ohlcv/OHLCVService.js +40 -319
  37. package/dist/ws/ohlcv/OHLCVService.js.map +1 -1
  38. package/package.json +19 -16
package/CHANGELOG.md CHANGED
@@ -9,14 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Added
11
11
 
12
- - Add support for Node.js 26 ([#10981](https://github.com/MetaMask/core/pull/10981))
12
+ - Add `LaunchpadTokenDetailsService` for real-time launchpad token detail streaming over the shared backend WebSocket, exposing `subscribe`/`unsubscribe` by `assetId` and publishing `tokenUpdated`, `statusChanged`, and `subscriptionError` events, along with `LAUNCHPAD_TDP_SERVICE_ALLOWED_ACTIONS`/`LAUNCHPAD_TDP_SERVICE_ALLOWED_EVENTS` and launchpad event types/normalizers (`parseBatch`, `normalizeEvent`, `buildChannel`) ([#10884](https://github.com/MetaMask/core/pull/10884))
13
+ - Add `ChannelSubscriptionManager`, a reusable per-channel WebSocket subscription lifecycle helper (reference counting, grace-period unsubscribe, unsubscribe retry, and resubscribe on reconnect) shared by `OHLCVService` and `LaunchpadTokenDetailsService` ([#10884](https://github.com/MetaMask/core/pull/10884))
13
14
 
14
15
  ### Changed
15
16
 
16
- - Stop publishing the `api/test-utils` test helper, which was never reachable through the package's `exports` field ([#10916](https://github.com/MetaMask/core/pull/10916))
17
- - Bump `@metamask/account-tree-controller` from `^11.0.1` to `^11.2.0` ([#10891](https://github.com/MetaMask/core/pull/10891), [#10925](https://github.com/MetaMask/core/pull/10925), [#11092](https://github.com/MetaMask/core/pull/11092))
18
- - Bump `@metamask/profile-sync-controller` from `^34.0.3` to `^36.0.0` ([#10905](https://github.com/MetaMask/core/pull/10905), [#10925](https://github.com/MetaMask/core/pull/10925), [#11092](https://github.com/MetaMask/core/pull/11092))
19
- - Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107))
17
+ - Refactor `OHLCVService` to delegate its subscription lifecycle to the shared `ChannelSubscriptionManager` via composition, with no change to its public API or published events ([#10884](https://github.com/MetaMask/core/pull/10884))
20
18
 
21
19
  ## [12.3.0]
22
20
 
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Shared test utilities for API client tests.
3
+ */
4
+ import { ApiPlatformClient } from './ApiPlatformClient.js';
5
+ export declare const mockFetch: jest.Mock<any, any, any>;
6
+ /**
7
+ * Helper to create a mock Response.
8
+ *
9
+ * @param data - The response data to return from json().
10
+ * @param status - HTTP status code.
11
+ * @param statusText - HTTP status text.
12
+ * @returns A mocked Response object.
13
+ */
14
+ export declare const createMockResponse: <ResponseData>(data: ResponseData, status?: number, statusText?: string) => Response;
15
+ /**
16
+ * Creates a fresh ApiPlatformClient for testing with disabled caching/retry.
17
+ *
18
+ * @returns A new ApiPlatformClient instance configured for testing.
19
+ */
20
+ export declare function createTestClient(): ApiPlatformClient;
21
+ /**
22
+ * Setup function to be called in beforeEach.
23
+ *
24
+ * @returns An object containing a fresh test client.
25
+ */
26
+ export declare function setupTestEnvironment(): {
27
+ client: ApiPlatformClient;
28
+ };
29
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/api/test-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,eAAO,MAAM,SAAS,0BAAY,CAAC;AAGnC;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAY,QACvC,YAAY,2CAGjB,QAiBwB,CAAC;AAE5B;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,CAcpD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,CAIpE"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Shared test utilities for API client tests.
3
+ */
4
+ import { QueryClient } from '@tanstack/query-core';
5
+ import { ApiPlatformClient } from './ApiPlatformClient.js';
6
+ // Mock fetch globally
7
+ export const mockFetch = jest.fn();
8
+ globalThis.fetch = mockFetch;
9
+ /**
10
+ * Helper to create a mock Response.
11
+ *
12
+ * @param data - The response data to return from json().
13
+ * @param status - HTTP status code.
14
+ * @param statusText - HTTP status text.
15
+ * @returns A mocked Response object.
16
+ */
17
+ export const createMockResponse = (data, status = 200, statusText = 'OK') => ({
18
+ ok: status >= 200 && status < 300,
19
+ status,
20
+ statusText,
21
+ json: jest.fn().mockResolvedValue(data),
22
+ headers: { get: jest.fn() },
23
+ redirected: false,
24
+ type: 'basic',
25
+ url: '',
26
+ clone: jest.fn(),
27
+ body: null,
28
+ bodyUsed: false,
29
+ arrayBuffer: jest.fn(),
30
+ blob: jest.fn(),
31
+ formData: jest.fn(),
32
+ text: jest.fn(),
33
+ });
34
+ /**
35
+ * Creates a fresh ApiPlatformClient for testing with disabled caching/retry.
36
+ *
37
+ * @returns A new ApiPlatformClient instance configured for testing.
38
+ */
39
+ export function createTestClient() {
40
+ return new ApiPlatformClient({
41
+ clientProduct: 'test-client',
42
+ clientVersion: '1.0.0',
43
+ queryClient: new QueryClient({
44
+ defaultOptions: {
45
+ queries: {
46
+ retry: false,
47
+ gcTime: 0,
48
+ staleTime: 0,
49
+ },
50
+ },
51
+ }),
52
+ });
53
+ }
54
+ /**
55
+ * Setup function to be called in beforeEach.
56
+ *
57
+ * @returns An object containing a fresh test client.
58
+ */
59
+ export function setupTestEnvironment() {
60
+ jest.clearAllMocks();
61
+ mockFetch.mockReset();
62
+ return { client: createTestClient() };
63
+ }
64
+ //# sourceMappingURL=test-utils.js.map
@@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O,EAAE;oBACP,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,CAAC;oBACT,SAAS,EAAE,CAAC;iBACb;aACF;SACF,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC,aAAa,EAAE,CAAC;IACrB,SAAS,CAAC,SAAS,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE,CAAC;AACxC,CAAC","sourcesContent":["/**\n * Shared test utilities for API client tests.\n */\n\nimport { QueryClient } from '@tanstack/query-core';\n\nimport { ApiPlatformClient } from './ApiPlatformClient.js';\n\n// Mock fetch globally\nexport const mockFetch = jest.fn();\n(globalThis as typeof globalThis & { fetch: jest.Mock }).fetch = mockFetch;\n\n/**\n * Helper to create a mock Response.\n *\n * @param data - The response data to return from json().\n * @param status - HTTP status code.\n * @param statusText - HTTP status text.\n * @returns A mocked Response object.\n */\nexport const createMockResponse = <ResponseData>(\n data: ResponseData,\n status = 200,\n statusText = 'OK',\n): Response =>\n ({\n ok: status >= 200 && status < 300,\n status,\n statusText,\n json: jest.fn().mockResolvedValue(data),\n headers: { get: jest.fn() },\n redirected: false,\n type: 'basic',\n url: '',\n clone: jest.fn(),\n body: null,\n bodyUsed: false,\n arrayBuffer: jest.fn(),\n blob: jest.fn(),\n formData: jest.fn(),\n text: jest.fn(),\n }) as unknown as Response;\n\n/**\n * Creates a fresh ApiPlatformClient for testing with disabled caching/retry.\n *\n * @returns A new ApiPlatformClient instance configured for testing.\n */\nexport function createTestClient(): ApiPlatformClient {\n return new ApiPlatformClient({\n clientProduct: 'test-client',\n clientVersion: '1.0.0',\n queryClient: new QueryClient({\n defaultOptions: {\n queries: {\n retry: false,\n gcTime: 0,\n staleTime: 0,\n },\n },\n }),\n });\n}\n\n/**\n * Setup function to be called in beforeEach.\n *\n * @returns An object containing a fresh test client.\n */\nexport function setupTestEnvironment(): { client: ApiPlatformClient } {\n jest.clearAllMocks();\n mockFetch.mockReset();\n return { client: createTestClient() };\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,10 @@ export { ApiPlatformClientService, apiPlatformClientServiceName, } from './ApiPl
7
7
  export type { ApiPlatformClientServiceOptions, ApiPlatformClientServiceActions, ApiPlatformClientServiceEvents, ApiPlatformClientServiceMessenger, } from './ApiPlatformClientService.js';
8
8
  export { OHLCVService, OHLCV_SERVICE_ALLOWED_ACTIONS, OHLCV_SERVICE_ALLOWED_EVENTS, } from './ws/ohlcv/index.js';
9
9
  export type { OHLCVBar, OHLCVSubscriptionOptions, OHLCVSystemNotificationData, OHLCVServiceOptions, OHLCVServiceActions, OHLCVServiceAllowedActions, OHLCVServiceBarUpdatedEvent, OHLCVServiceChainStatusChangedEvent, OHLCVServiceSubscriptionErrorEvent, OHLCVServiceEvents, OHLCVServiceAllowedEvents, OHLCVServiceMessenger, } from './ws/ohlcv/index.js';
10
+ export { ChannelSubscriptionManager } from './ws/ChannelSubscriptionManager.js';
11
+ export type { ChannelSubscriptionManagerMessenger, ChannelSubscriptionManagerOptions, ChannelSubscriptionOperation, } from './ws/ChannelSubscriptionManager.js';
12
+ export { LaunchpadTokenDetailsService, LAUNCHPAD_TDP_SERVICE_ALLOWED_ACTIONS, LAUNCHPAD_TDP_SERVICE_ALLOWED_EVENTS, buildChannel, normalizeEvent, parseBatch, LAUNCHPAD_SUBSCRIPTION_NAMESPACE, } from './ws/launchpad/index.js';
13
+ export type { LaunchpadSystemNotificationData, LaunchpadTokenDetailsServiceOptions, LaunchpadTokenDetailsServiceActions, LaunchpadTokenDetailsServiceAllowedActions, LaunchpadTokenDetailsServiceTokenUpdatedEvent, LaunchpadTokenDetailsServiceStatusChangedEvent, LaunchpadTokenDetailsServiceSubscriptionErrorEvent, LaunchpadTokenDetailsServiceEvents, LaunchpadTokenDetailsServiceAllowedEvents, LaunchpadTokenDetailsServiceMessenger, LaunchpadEventType, NumericLike, RawLaunchpadTokenEvent, LaunchpadTokenCreatedEvent, LaunchpadTokenStatsEvent, LaunchpadTokenMigratedEvent, LaunchpadTokenEvent, LaunchpadTokenDetailsSubscriptionOptions, } from './ws/launchpad/index.js';
10
14
  export { ApiPlatformClient, createApiPlatformClient, AccountsApiClient, PricesApiClient, TokenApiClient, TokensApiClient, API_URLS, STALE_TIMES, GC_TIMES, V6_DEFI_POSITION_TYPES, calculateRetryDelay, getQueryOptionsOverrides, shouldRetry, HttpError, } from './api/index.js';
11
15
  export type { ApiPlatformClientOptions, ApiUrls, FetchOptions, PageInfo, SupportedCurrency, MarketDataDetails, V5BalanceItem, V5BalancesResponse, V2BalanceItem, V2BalancesResponse, V4BalancesResponse, V6VsCurrency, V6DeFiPositionType, V6BalanceMetadata, V6StellarTokenBalanceMetadata, V6TokenBalanceMetadata, V6BalanceItem, V6BalancesResponse, V1SupportedNetworksResponse, V2SupportedNetworksResponse, V2ActiveNetworksResponse, V1TransactionByHashResponse, V1AccountTransactionsResponse, V4MultiAccountTransactionsResponse, ValueTransfer, V1AccountRelationshipResult, NftItem, V2NftsResponse, TokenDiscoveryItem, V2TokensResponse, V3SpotPricesResponse, CoinGeckoSpotPrice, ExchangeRateInfo, V1ExchangeRatesResponse, PriceSupportedNetworksResponse, PriceV1SupportedNetworksResponse, PriceV2SupportedNetworksResponse, V1HistoricalPricesResponse, V3HistoricalPricesResponse, TokenMetadata, TokenListQueryOptions, TokenV2SupportedNetworksResponse, V1TokenDescriptionResponse, NetworkInfo, TopAsset, TrendingSortBy, TrendingToken, TopGainersSortOption, TrendingSortOption, V1SuggestedOccurrenceFloorsResponse, V1TokenSupportedNetworksResponse, V2TokenSupportedNetworksResponse, V3AssetResponse, } from './api/index.js';
12
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,i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ACX,QAAQ,EACR,sBAAsB,EAEtB,mBAAmB,EACnB,wBAAwB,EACxB,WAAW,EAEX,SAAS,GACV,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAEV,wBAAwB,EACxB,OAAO,EACP,YAAY,EAEZ,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EAEjB,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,2BAA2B,EAC3B,6BAA6B,EAC7B,kCAAkC,EAClC,aAAa,EACb,2BAA2B,EAC3B,OAAO,EACP,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAEhB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,8BAA8B,EAC9B,gCAAgC,EAChC,gCAAgC,EAChC,0BAA0B,EAC1B,0BAA0B,EAE1B,aAAa,EACb,qBAAqB,EACrB,gCAAgC,EAChC,0BAA0B,EAC1B,WAAW,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,mCAAmC,EAEnC,gCAAgC,EAChC,gCAAgC,EAChC,eAAe,GAChB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EACV,8BAA8B,EAC9B,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,8BAA8B,EAC9B,kDAAkD,EAClD,6BAA6B,EAC7B,gCAAgC,GACjC,MAAM,iCAAi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dist/index.js CHANGED
@@ -16,6 +16,14 @@ export { ApiPlatformClientService, apiPlatformClientServiceName, } from './ApiPl
16
16
  // ============================================================================
17
17
  export { OHLCVService, OHLCV_SERVICE_ALLOWED_ACTIONS, OHLCV_SERVICE_ALLOWED_EVENTS, } from './ws/ohlcv/index.js';
18
18
  // ============================================================================
19
+ // CHANNEL SUBSCRIPTION MANAGER
20
+ // ============================================================================
21
+ export { ChannelSubscriptionManager } from './ws/ChannelSubscriptionManager.js';
22
+ // ============================================================================
23
+ // LAUNCHPAD TOKEN DETAILS SERVICE
24
+ // ============================================================================
25
+ export { LaunchpadTokenDetailsService, LAUNCHPAD_TDP_SERVICE_ALLOWED_ACTIONS, LAUNCHPAD_TDP_SERVICE_ALLOWED_EVENTS, buildChannel, normalizeEvent, parseBatch, LAUNCHPAD_SUBSCRIPTION_NAMESPACE, } from './ws/launchpad/index.js';
26
+ // ============================================================================
19
27
  // API PLATFORM CLIENT
20
28
  // ============================================================================
21
29
  export { ApiPlatformClient, createApiPlatformClient,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAiBzC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E,OAAO,EACL,sBAAsB,EACtB,wCAAwC,EACxC,uCAAuC,GACxC,MAAM,gCAAgC,CAAC;AA8BxC,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AASvC,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,OAAO,EACL,YAAY,EACZ,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAiB7B,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,OAAO,EACL,iBAAiB,EACjB,uBAAuB;AACvB,yBAAyB;AACzB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,eAAe;AACf,YAAY;AACZ,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,sBAAsB;AACtB,UAAU;AACV,mBAAmB,EACnB,wBAAwB,EACxB,WAAW;AACX,SAAS;AACT,SAAS,GACV,MAAM,gBAAgB,CAAC","sourcesContent":["// Core Backend Package Exports\n\n// ============================================================================\n// BACKEND WEBSOCKET SERVICE\n// ============================================================================\n\nexport {\n BackendWebSocketService,\n getCloseReason,\n WebSocketState,\n WebSocketEventType,\n} from './ws/BackendWebSocketService.js';\n\nexport type {\n BackendWebSocketServiceOptions,\n ClientRequestMessage,\n ServerResponseMessage,\n ServerNotificationMessage,\n WebSocketMessage,\n ChannelCallback,\n WebSocketSubscription,\n WebSocketConnectionInfo,\n BackendWebSocketServiceActions,\n BackendWebSocketServiceConnectionStateChangedEvent,\n BackendWebSocketServiceEvents,\n BackendWebSocketServiceMessenger,\n} from './ws/BackendWebSocketService.js';\n\n// ============================================================================\n// ACCOUNT ACTIVITY SERVICE\n// ============================================================================\n\nexport {\n AccountActivityService,\n ACCOUNT_ACTIVITY_SERVICE_ALLOWED_ACTIONS,\n ACCOUNT_ACTIVITY_SERVICE_ALLOWED_EVENTS,\n} from './ws/AccountActivityService.js';\n\nexport type {\n SystemNotificationData,\n SubscriptionOptions,\n AccountActivityServiceOptions,\n AccountActivityServiceActions,\n AllowedActions as AccountActivityServiceAllowedActions,\n AccountActivityServiceTransactionUpdatedEvent,\n AccountActivityServiceBalanceUpdatedEvent,\n AccountActivityServiceSubscriptionErrorEvent,\n AccountActivityServiceStatusChangedEvent,\n AccountActivityServiceEvents,\n AllowedEvents as AccountActivityServiceAllowedEvents,\n AccountActivityServiceMessenger,\n} from './ws/AccountActivityService.js';\n\n// ============================================================================\n// SHARED TYPES\n// ============================================================================\n\nexport type {\n Transaction,\n Asset,\n Balance,\n Transfer,\n BalanceUpdate,\n AccountActivityMessage,\n} from './types.js';\n\n// ============================================================================\n// API PLATFORM CLIENT SERVICE\n// ============================================================================\n\nexport {\n ApiPlatformClientService,\n apiPlatformClientServiceName,\n} from './ApiPlatformClientService.js';\n\nexport type {\n ApiPlatformClientServiceOptions,\n ApiPlatformClientServiceActions,\n ApiPlatformClientServiceEvents,\n ApiPlatformClientServiceMessenger,\n} from './ApiPlatformClientService.js';\n\n// ============================================================================\n// OHLCV SERVICE\n// ============================================================================\n\nexport {\n OHLCVService,\n OHLCV_SERVICE_ALLOWED_ACTIONS,\n OHLCV_SERVICE_ALLOWED_EVENTS,\n} from './ws/ohlcv/index.js';\n\nexport type {\n OHLCVBar,\n OHLCVSubscriptionOptions,\n OHLCVSystemNotificationData,\n OHLCVServiceOptions,\n OHLCVServiceActions,\n OHLCVServiceAllowedActions,\n OHLCVServiceBarUpdatedEvent,\n OHLCVServiceChainStatusChangedEvent,\n OHLCVServiceSubscriptionErrorEvent,\n OHLCVServiceEvents,\n OHLCVServiceAllowedEvents,\n OHLCVServiceMessenger,\n} from './ws/ohlcv/index.js';\n\n// ============================================================================\n// API PLATFORM CLIENT\n// ============================================================================\n\nexport {\n ApiPlatformClient,\n createApiPlatformClient,\n // Individual API clients\n AccountsApiClient,\n PricesApiClient,\n TokenApiClient,\n TokensApiClient,\n // Constants\n API_URLS,\n STALE_TIMES,\n GC_TIMES,\n V6_DEFI_POSITION_TYPES,\n // Helpers\n calculateRetryDelay,\n getQueryOptionsOverrides,\n shouldRetry,\n // Errors\n HttpError,\n} from './api/index.js';\n\n// ============================================================================\n// API PLATFORM CLIENT TYPES\n// ============================================================================\n\nexport type {\n // Client options\n ApiPlatformClientOptions,\n ApiUrls,\n FetchOptions,\n // Shared types\n PageInfo,\n SupportedCurrency,\n MarketDataDetails,\n // Accounts API types\n V5BalanceItem,\n V5BalancesResponse,\n V2BalanceItem,\n V2BalancesResponse,\n V4BalancesResponse,\n V6VsCurrency,\n V6DeFiPositionType,\n V6BalanceMetadata,\n V6StellarTokenBalanceMetadata,\n V6TokenBalanceMetadata,\n V6BalanceItem,\n V6BalancesResponse,\n V1SupportedNetworksResponse,\n V2SupportedNetworksResponse,\n V2ActiveNetworksResponse,\n V1TransactionByHashResponse,\n V1AccountTransactionsResponse,\n V4MultiAccountTransactionsResponse,\n ValueTransfer,\n V1AccountRelationshipResult,\n NftItem,\n V2NftsResponse,\n TokenDiscoveryItem,\n V2TokensResponse,\n // Prices API types\n V3SpotPricesResponse,\n CoinGeckoSpotPrice,\n ExchangeRateInfo,\n V1ExchangeRatesResponse,\n PriceSupportedNetworksResponse,\n PriceV1SupportedNetworksResponse,\n PriceV2SupportedNetworksResponse,\n V1HistoricalPricesResponse,\n V3HistoricalPricesResponse,\n // Token API types\n TokenMetadata,\n TokenListQueryOptions,\n TokenV2SupportedNetworksResponse,\n V1TokenDescriptionResponse,\n NetworkInfo,\n TopAsset,\n TrendingSortBy,\n TrendingToken,\n TopGainersSortOption,\n TrendingSortOption,\n V1SuggestedOccurrenceFloorsResponse,\n // Tokens API types\n V1TokenSupportedNetworksResponse,\n V2TokenSupportedNetworksResponse,\n V3AssetResponse,\n} from './api/index.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAiBzC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E,OAAO,EACL,sBAAsB,EACtB,wCAAwC,EACxC,uCAAuC,GACxC,MAAM,gCAAgC,CAAC;AA8BxC,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AASvC,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,OAAO,EACL,YAAY,EACZ,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAiB7B,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAQhF,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAE/E,OAAO,EACL,4BAA4B,EAC5B,qCAAqC,EACrC,oCAAoC,EACpC,YAAY,EACZ,cAAc,EACd,UAAU,EACV,gCAAgC,GACjC,MAAM,yBAAyB,CAAC;AAuBjC,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,OAAO,EACL,iBAAiB,EACjB,uBAAuB;AACvB,yBAAyB;AACzB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,eAAe;AACf,YAAY;AACZ,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,sBAAsB;AACtB,UAAU;AACV,mBAAmB,EACnB,wBAAwB,EACxB,WAAW;AACX,SAAS;AACT,SAAS,GACV,MAAM,gBAAgB,CAAC","sourcesContent":["// Core Backend Package Exports\n\n// ============================================================================\n// BACKEND WEBSOCKET SERVICE\n// ============================================================================\n\nexport {\n BackendWebSocketService,\n getCloseReason,\n WebSocketState,\n WebSocketEventType,\n} from './ws/BackendWebSocketService.js';\n\nexport type {\n BackendWebSocketServiceOptions,\n ClientRequestMessage,\n ServerResponseMessage,\n ServerNotificationMessage,\n WebSocketMessage,\n ChannelCallback,\n WebSocketSubscription,\n WebSocketConnectionInfo,\n BackendWebSocketServiceActions,\n BackendWebSocketServiceConnectionStateChangedEvent,\n BackendWebSocketServiceEvents,\n BackendWebSocketServiceMessenger,\n} from './ws/BackendWebSocketService.js';\n\n// ============================================================================\n// ACCOUNT ACTIVITY SERVICE\n// ============================================================================\n\nexport {\n AccountActivityService,\n ACCOUNT_ACTIVITY_SERVICE_ALLOWED_ACTIONS,\n ACCOUNT_ACTIVITY_SERVICE_ALLOWED_EVENTS,\n} from './ws/AccountActivityService.js';\n\nexport type {\n SystemNotificationData,\n SubscriptionOptions,\n AccountActivityServiceOptions,\n AccountActivityServiceActions,\n AllowedActions as AccountActivityServiceAllowedActions,\n AccountActivityServiceTransactionUpdatedEvent,\n AccountActivityServiceBalanceUpdatedEvent,\n AccountActivityServiceSubscriptionErrorEvent,\n AccountActivityServiceStatusChangedEvent,\n AccountActivityServiceEvents,\n AllowedEvents as AccountActivityServiceAllowedEvents,\n AccountActivityServiceMessenger,\n} from './ws/AccountActivityService.js';\n\n// ============================================================================\n// SHARED TYPES\n// ============================================================================\n\nexport type {\n Transaction,\n Asset,\n Balance,\n Transfer,\n BalanceUpdate,\n AccountActivityMessage,\n} from './types.js';\n\n// ============================================================================\n// API PLATFORM CLIENT SERVICE\n// ============================================================================\n\nexport {\n ApiPlatformClientService,\n apiPlatformClientServiceName,\n} from './ApiPlatformClientService.js';\n\nexport type {\n ApiPlatformClientServiceOptions,\n ApiPlatformClientServiceActions,\n ApiPlatformClientServiceEvents,\n ApiPlatformClientServiceMessenger,\n} from './ApiPlatformClientService.js';\n\n// ============================================================================\n// OHLCV SERVICE\n// ============================================================================\n\nexport {\n OHLCVService,\n OHLCV_SERVICE_ALLOWED_ACTIONS,\n OHLCV_SERVICE_ALLOWED_EVENTS,\n} from './ws/ohlcv/index.js';\n\nexport type {\n OHLCVBar,\n OHLCVSubscriptionOptions,\n OHLCVSystemNotificationData,\n OHLCVServiceOptions,\n OHLCVServiceActions,\n OHLCVServiceAllowedActions,\n OHLCVServiceBarUpdatedEvent,\n OHLCVServiceChainStatusChangedEvent,\n OHLCVServiceSubscriptionErrorEvent,\n OHLCVServiceEvents,\n OHLCVServiceAllowedEvents,\n OHLCVServiceMessenger,\n} from './ws/ohlcv/index.js';\n\n// ============================================================================\n// CHANNEL SUBSCRIPTION MANAGER\n// ============================================================================\n\nexport { ChannelSubscriptionManager } from './ws/ChannelSubscriptionManager.js';\n\nexport type {\n ChannelSubscriptionManagerMessenger,\n ChannelSubscriptionManagerOptions,\n ChannelSubscriptionOperation,\n} from './ws/ChannelSubscriptionManager.js';\n\n// ============================================================================\n// LAUNCHPAD TOKEN DETAILS SERVICE\n// ============================================================================\n\nexport {\n LaunchpadTokenDetailsService,\n LAUNCHPAD_TDP_SERVICE_ALLOWED_ACTIONS,\n LAUNCHPAD_TDP_SERVICE_ALLOWED_EVENTS,\n buildChannel,\n normalizeEvent,\n parseBatch,\n LAUNCHPAD_SUBSCRIPTION_NAMESPACE,\n} from './ws/launchpad/index.js';\n\nexport type {\n LaunchpadSystemNotificationData,\n LaunchpadTokenDetailsServiceOptions,\n LaunchpadTokenDetailsServiceActions,\n LaunchpadTokenDetailsServiceAllowedActions,\n LaunchpadTokenDetailsServiceTokenUpdatedEvent,\n LaunchpadTokenDetailsServiceStatusChangedEvent,\n LaunchpadTokenDetailsServiceSubscriptionErrorEvent,\n LaunchpadTokenDetailsServiceEvents,\n LaunchpadTokenDetailsServiceAllowedEvents,\n LaunchpadTokenDetailsServiceMessenger,\n LaunchpadEventType,\n NumericLike,\n RawLaunchpadTokenEvent,\n LaunchpadTokenCreatedEvent,\n LaunchpadTokenStatsEvent,\n LaunchpadTokenMigratedEvent,\n LaunchpadTokenEvent,\n LaunchpadTokenDetailsSubscriptionOptions,\n} from './ws/launchpad/index.js';\n\n// ============================================================================\n// API PLATFORM CLIENT\n// ============================================================================\n\nexport {\n ApiPlatformClient,\n createApiPlatformClient,\n // Individual API clients\n AccountsApiClient,\n PricesApiClient,\n TokenApiClient,\n TokensApiClient,\n // Constants\n API_URLS,\n STALE_TIMES,\n GC_TIMES,\n V6_DEFI_POSITION_TYPES,\n // Helpers\n calculateRetryDelay,\n getQueryOptionsOverrides,\n shouldRetry,\n // Errors\n HttpError,\n} from './api/index.js';\n\n// ============================================================================\n// API PLATFORM CLIENT TYPES\n// ============================================================================\n\nexport type {\n // Client options\n ApiPlatformClientOptions,\n ApiUrls,\n FetchOptions,\n // Shared types\n PageInfo,\n SupportedCurrency,\n MarketDataDetails,\n // Accounts API types\n V5BalanceItem,\n V5BalancesResponse,\n V2BalanceItem,\n V2BalancesResponse,\n V4BalancesResponse,\n V6VsCurrency,\n V6DeFiPositionType,\n V6BalanceMetadata,\n V6StellarTokenBalanceMetadata,\n V6TokenBalanceMetadata,\n V6BalanceItem,\n V6BalancesResponse,\n V1SupportedNetworksResponse,\n V2SupportedNetworksResponse,\n V2ActiveNetworksResponse,\n V1TransactionByHashResponse,\n V1AccountTransactionsResponse,\n V4MultiAccountTransactionsResponse,\n ValueTransfer,\n V1AccountRelationshipResult,\n NftItem,\n V2NftsResponse,\n TokenDiscoveryItem,\n V2TokensResponse,\n // Prices API types\n V3SpotPricesResponse,\n CoinGeckoSpotPrice,\n ExchangeRateInfo,\n V1ExchangeRatesResponse,\n PriceSupportedNetworksResponse,\n PriceV1SupportedNetworksResponse,\n PriceV2SupportedNetworksResponse,\n V1HistoricalPricesResponse,\n V3HistoricalPricesResponse,\n // Token API types\n TokenMetadata,\n TokenListQueryOptions,\n TokenV2SupportedNetworksResponse,\n V1TokenDescriptionResponse,\n NetworkInfo,\n TopAsset,\n TrendingSortBy,\n TrendingToken,\n TopGainersSortOption,\n TrendingSortOption,\n V1SuggestedOccurrenceFloorsResponse,\n // Tokens API types\n V1TokenSupportedNetworksResponse,\n V2TokenSupportedNetworksResponse,\n V3AssetResponse,\n} from './api/index.js';\n"]}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Shared per-channel WebSocket subscription lifecycle manager.
3
+ *
4
+ * Extracts the channel-agnostic subscription machinery that was originally part
5
+ * of {@link OHLCVService}: reference counting, grace-period unsubscribe,
6
+ * grace-period flush, unsubscribe retry with backoff + force reconnection,
7
+ * idempotency checks, resubscribe-on-reconnect, and optional system-notification
8
+ * channel registration.
9
+ *
10
+ * It is consumed by **composition** (not inheritance). Each domain service
11
+ * (e.g. OHLCV market data, Launchpad token details) constructs a manager,
12
+ * provides the channel-type namespace and a per-message callback, and keeps its
13
+ * own domain concerns (channel-string construction, payload parsing, published
14
+ * events). The manager talks to {@link BackendWebSocketService} exclusively
15
+ * through the messenger — no direct import of the class.
16
+ */
17
+ import type { Messenger } from '@metamask/messenger';
18
+ import type { BackendWebSocketServiceMethodActions } from './BackendWebSocketService-method-action-types.js';
19
+ import type { WebSocketConnectionInfo, BackendWebSocketServiceConnectionStateChangedEvent, ServerNotificationMessage } from './BackendWebSocketService.js';
20
+ /**
21
+ * Minimal messenger shape the manager requires: the `BackendWebSocketService:*`
22
+ * actions and the `connectionStateChanged` event. A host service's messenger
23
+ * (which has these delegated plus its own domain actions/events) satisfies this.
24
+ */
25
+ export type ChannelSubscriptionManagerMessenger = Messenger<string, BackendWebSocketServiceMethodActions, BackendWebSocketServiceConnectionStateChangedEvent>;
26
+ /** The kind of operation that failed, forwarded to `onSubscriptionError`. */
27
+ export type ChannelSubscriptionOperation = 'subscribe' | 'unsubscribe';
28
+ /**
29
+ * Configuration for a {@link ChannelSubscriptionManager}.
30
+ */
31
+ export type ChannelSubscriptionManagerOptions = {
32
+ /** Messenger used to reach {@link BackendWebSocketService}. */
33
+ messenger: ChannelSubscriptionManagerMessenger;
34
+ /** Channel type/namespace passed to `BackendWebSocketService:subscribe`. */
35
+ channelType: string;
36
+ /** Called for each subscription notification on a managed channel. */
37
+ onMessage: (channel: string, notification: ServerNotificationMessage) => void;
38
+ /** Called when a subscribe/unsubscribe operation fails. */
39
+ onSubscriptionError?: (channel: string, error: string, operation: ChannelSubscriptionOperation) => void;
40
+ /** Optional system-notifications channel to register a callback for on `init()`. */
41
+ systemNotificationsChannel?: string;
42
+ /** Handler invoked for messages on the system-notifications channel. */
43
+ onSystemNotification?: (notification: ServerNotificationMessage) => void;
44
+ /**
45
+ * Called on every connection state change, after the manager performs its own
46
+ * resubscribe-on-CONNECTED. Lets the host run domain reactions (e.g. marking
47
+ * tracked chains down on DISCONNECTED).
48
+ */
49
+ onConnectionStateChange?: (connectionInfo: WebSocketConnectionInfo) => void;
50
+ /** Prefix used in log lines (defaults to the channel type). */
51
+ logPrefix?: string;
52
+ /** Override the grace period (primarily for tests). */
53
+ gracePeriodMs?: number;
54
+ /** Override the unsubscribe retry backoff delays (primarily for tests). */
55
+ unsubRetryDelaysMs?: number[];
56
+ };
57
+ /**
58
+ * Manages the lifecycle of per-channel WebSocket subscriptions on top of the
59
+ * shared {@link BackendWebSocketService}.
60
+ */
61
+ export declare class ChannelSubscriptionManager {
62
+ #private;
63
+ constructor(options: ChannelSubscriptionManagerOptions);
64
+ /**
65
+ * Register the system-notifications channel callback, if configured.
66
+ */
67
+ init(): void;
68
+ /**
69
+ * Subscribe to a channel. If this is the first subscriber a WebSocket
70
+ * subscription is created; additional calls for the same channel only bump the
71
+ * reference count.
72
+ *
73
+ * @param channel - The fully-qualified channel name.
74
+ * @returns A promise that resolves once the subscription is established.
75
+ */
76
+ subscribe(channel: string): Promise<void>;
77
+ /**
78
+ * Unsubscribe from a channel. Decrements the reference count and, when it
79
+ * reaches zero, starts a grace-period timer before actually unsubscribing from
80
+ * the WebSocket to absorb rapid navigation patterns.
81
+ *
82
+ * @param channel - The fully-qualified channel name.
83
+ * @returns A promise that resolves once the unsubscription is processed.
84
+ */
85
+ unsubscribe(channel: string): Promise<void>;
86
+ /**
87
+ * Tear down all channel timers and, if configured, remove the
88
+ * system-notifications channel callback.
89
+ */
90
+ destroy(): void;
91
+ }
92
+ //# sourceMappingURL=ChannelSubscriptionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChannelSubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/ws/ChannelSubscriptionManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,kDAAkD,CAAC;AAC7G,O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