@metamask-previews/core-backend 9.0.0-preview-3866c0ff1 → 9.0.0-preview-e3275932a
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.
- package/CHANGELOG.md +0 -1
- package/dist/ApiPlatformClientService-method-action-types.cjs +7 -0
- package/dist/ApiPlatformClientService-method-action-types.cjs.map +1 -0
- package/dist/{ApiPlatformClientService-method-action-types.d.ts → ApiPlatformClientService-method-action-types.d.cts} +2 -2
- package/dist/ApiPlatformClientService-method-action-types.d.cts.map +1 -0
- package/dist/ApiPlatformClientService-method-action-types.d.mts +21 -0
- package/dist/ApiPlatformClientService-method-action-types.d.mts.map +1 -0
- package/dist/{ApiPlatformClientService-method-action-types.js → ApiPlatformClientService-method-action-types.mjs} +1 -1
- package/dist/ApiPlatformClientService-method-action-types.mjs.map +1 -0
- package/dist/ApiPlatformClientService.cjs +82 -0
- package/dist/ApiPlatformClientService.cjs.map +1 -0
- package/dist/{ApiPlatformClientService.d.ts → ApiPlatformClientService.d.cts} +5 -5
- package/dist/ApiPlatformClientService.d.cts.map +1 -0
- package/dist/ApiPlatformClientService.d.mts +86 -0
- package/dist/ApiPlatformClientService.d.mts.map +1 -0
- package/dist/{ApiPlatformClientService.js → ApiPlatformClientService.mjs} +21 -9
- package/dist/ApiPlatformClientService.mjs.map +1 -0
- package/dist/api/ApiPlatformClient.cjs +177 -0
- package/dist/api/{ApiPlatformClient.js.map → ApiPlatformClient.cjs.map} +1 -1
- package/dist/api/{ApiPlatformClient.d.ts → ApiPlatformClient.d.cts} +8 -8
- package/dist/api/ApiPlatformClient.d.cts.map +1 -0
- package/dist/api/ApiPlatformClient.d.mts +127 -0
- package/dist/api/ApiPlatformClient.d.mts.map +1 -0
- package/dist/api/{ApiPlatformClient.js → ApiPlatformClient.mjs} +45 -53
- package/dist/api/ApiPlatformClient.mjs.map +1 -0
- package/dist/api/accounts/client.cjs +850 -0
- package/dist/api/accounts/client.cjs.map +1 -0
- package/dist/api/accounts/{client.d.ts → client.d.cts} +5 -5
- package/dist/api/accounts/client.d.cts.map +1 -0
- package/dist/api/accounts/client.d.mts +500 -0
- package/dist/api/accounts/client.d.mts.map +1 -0
- package/dist/api/accounts/{client.js → client.mjs} +3 -3
- package/dist/api/accounts/client.mjs.map +1 -0
- package/dist/api/accounts/index.cjs +11 -0
- package/dist/api/accounts/index.cjs.map +1 -0
- package/dist/api/accounts/{index.d.ts → index.d.cts} +4 -4
- package/dist/api/accounts/index.d.cts.map +1 -0
- package/dist/api/accounts/index.d.mts +7 -0
- package/dist/api/accounts/index.d.mts.map +1 -0
- package/dist/api/accounts/index.mjs +6 -0
- package/dist/api/accounts/index.mjs.map +1 -0
- package/dist/api/accounts/types.cjs +22 -0
- package/dist/api/accounts/types.cjs.map +1 -0
- package/dist/api/accounts/{types.d.ts → types.d.cts} +3 -3
- package/dist/api/accounts/types.d.cts.map +1 -0
- package/dist/api/accounts/types.d.mts +286 -0
- package/dist/api/accounts/types.d.mts.map +1 -0
- package/dist/api/accounts/{types.js → types.mjs} +1 -1
- package/dist/api/accounts/types.mjs.map +1 -0
- package/dist/api/base-client.cjs +151 -0
- package/dist/api/base-client.cjs.map +1 -0
- package/dist/api/{base-client.d.ts → base-client.d.cts} +5 -6
- package/dist/api/base-client.d.cts.map +1 -0
- package/dist/api/base-client.d.mts +54 -0
- package/dist/api/base-client.d.mts.map +1 -0
- package/dist/api/{base-client.js → base-client.mjs} +32 -23
- package/dist/api/base-client.mjs.map +1 -0
- package/dist/api/index.cjs +37 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/{index.d.ts → index.d.cts} +14 -14
- package/dist/api/index.d.cts.map +1 -0
- package/dist/api/index.d.mts +18 -0
- package/dist/api/index.d.mts.map +1 -0
- package/dist/api/index.mjs +18 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/api/prices/client.cjs +779 -0
- package/dist/api/prices/client.cjs.map +1 -0
- package/dist/api/prices/{client.d.ts → client.d.cts} +5 -5
- package/dist/api/prices/client.d.cts.map +1 -0
- package/dist/api/prices/client.d.mts +447 -0
- package/dist/api/prices/client.d.mts.map +1 -0
- package/dist/api/prices/{client.js → client.mjs} +3 -3
- package/dist/api/prices/client.mjs.map +1 -0
- package/dist/api/prices/index.cjs +9 -0
- package/dist/api/prices/index.cjs.map +1 -0
- package/dist/api/prices/{index.d.ts → index.d.cts} +3 -3
- package/dist/api/prices/index.d.cts.map +1 -0
- package/dist/api/prices/index.d.mts +6 -0
- package/dist/api/prices/index.d.mts.map +1 -0
- package/dist/api/prices/index.mjs +5 -0
- package/dist/api/prices/index.mjs.map +1 -0
- package/dist/api/prices/types.cjs +7 -0
- package/dist/api/prices/types.cjs.map +1 -0
- package/dist/api/prices/{types.d.ts → types.d.cts} +1 -1
- package/dist/api/prices/types.d.cts.map +1 -0
- package/dist/api/prices/types.d.mts +61 -0
- package/dist/api/prices/types.d.mts.map +1 -0
- package/dist/api/prices/{types.js → types.mjs} +1 -1
- package/dist/api/prices/types.mjs.map +1 -0
- package/dist/api/shared-types.cjs +110 -0
- package/dist/api/shared-types.cjs.map +1 -0
- package/dist/api/{shared-types.d.ts → shared-types.d.cts} +6 -6
- package/dist/api/shared-types.d.cts.map +1 -0
- package/dist/api/shared-types.d.mts +151 -0
- package/dist/api/shared-types.d.mts.map +1 -0
- package/dist/api/{shared-types.js → shared-types.mjs} +2 -6
- package/dist/api/shared-types.mjs.map +1 -0
- package/dist/api/test-utils.cjs +70 -0
- package/dist/api/test-utils.cjs.map +1 -0
- package/dist/api/{test-utils.d.ts → test-utils.d.cts} +3 -2
- package/dist/api/test-utils.d.cts.map +1 -0
- package/dist/api/test-utils.d.mts +30 -0
- package/dist/api/test-utils.d.mts.map +1 -0
- package/dist/api/{test-utils.js → test-utils.mjs} +3 -3
- package/dist/api/test-utils.mjs.map +1 -0
- package/dist/api/token/client.cjs +500 -0
- package/dist/api/token/client.cjs.map +1 -0
- package/dist/api/token/{client.d.ts → client.d.cts} +5 -5
- package/dist/api/token/client.d.cts.map +1 -0
- package/dist/api/token/client.d.mts +362 -0
- package/dist/api/token/client.d.mts.map +1 -0
- package/dist/api/token/{client.js → client.mjs} +3 -3
- package/dist/api/token/client.mjs.map +1 -0
- package/dist/api/token/index.cjs +9 -0
- package/dist/api/token/index.cjs.map +1 -0
- package/dist/api/token/{index.d.ts → index.d.cts} +3 -3
- package/dist/api/token/index.d.cts.map +1 -0
- package/dist/api/token/index.d.mts +6 -0
- package/dist/api/token/index.d.mts.map +1 -0
- package/dist/api/token/index.mjs +5 -0
- package/dist/api/token/index.mjs.map +1 -0
- package/dist/api/token/types.cjs +7 -0
- package/dist/api/token/types.cjs.map +1 -0
- package/dist/api/token/{types.d.ts → types.d.cts} +1 -1
- package/dist/api/token/types.d.cts.map +1 -0
- package/dist/api/token/types.d.mts +124 -0
- package/dist/api/token/types.d.mts.map +1 -0
- package/dist/api/token/{types.js → types.mjs} +1 -1
- package/dist/api/token/types.mjs.map +1 -0
- package/dist/api/tokens/client.cjs +132 -0
- package/dist/api/tokens/client.cjs.map +1 -0
- package/dist/api/tokens/{client.d.ts → client.d.cts} +5 -5
- package/dist/api/tokens/client.d.cts.map +1 -0
- package/dist/api/tokens/client.d.mts +69 -0
- package/dist/api/tokens/client.d.mts.map +1 -0
- package/dist/api/tokens/{client.js → client.mjs} +3 -3
- package/dist/api/tokens/client.mjs.map +1 -0
- package/dist/api/tokens/index.cjs +9 -0
- package/dist/api/tokens/index.cjs.map +1 -0
- package/dist/api/tokens/{index.d.ts → index.d.cts} +3 -3
- package/dist/api/tokens/index.d.cts.map +1 -0
- package/dist/api/tokens/index.d.mts +6 -0
- package/dist/api/tokens/index.d.mts.map +1 -0
- package/dist/api/tokens/index.mjs +5 -0
- package/dist/api/tokens/index.mjs.map +1 -0
- package/dist/api/tokens/types.cjs +7 -0
- package/dist/api/tokens/types.cjs.map +1 -0
- package/dist/api/tokens/{types.d.ts → types.d.cts} +1 -1
- package/dist/api/tokens/types.d.cts.map +1 -0
- package/dist/api/tokens/types.d.mts +87 -0
- package/dist/api/tokens/types.d.mts.map +1 -0
- package/dist/api/tokens/{types.js → types.mjs} +1 -1
- package/dist/api/tokens/types.mjs.map +1 -0
- package/dist/index.cjs +55 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.ts → index.d.cts} +12 -12
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/{index.js → index.mjs} +6 -6
- package/dist/index.mjs.map +1 -0
- package/dist/logger.cjs +7 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +5 -0
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +5 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/logger.mjs +4 -0
- package/dist/logger.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +1 -1
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +73 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/ws/AccountActivityService.cjs +437 -0
- package/dist/ws/AccountActivityService.cjs.map +1 -0
- package/dist/ws/{AccountActivityService.d.ts → AccountActivityService.d.cts} +10 -10
- package/dist/ws/AccountActivityService.d.cts.map +1 -0
- package/dist/ws/AccountActivityService.d.mts +136 -0
- package/dist/ws/AccountActivityService.d.mts.map +1 -0
- package/dist/ws/AccountActivityService.mjs +433 -0
- package/dist/ws/AccountActivityService.mjs.map +1 -0
- package/dist/ws/BackendWebSocketService-method-action-types.cjs +7 -0
- package/dist/ws/BackendWebSocketService-method-action-types.cjs.map +1 -0
- package/dist/ws/{BackendWebSocketService-method-action-types.d.ts → BackendWebSocketService-method-action-types.d.cts} +2 -2
- package/dist/ws/BackendWebSocketService-method-action-types.d.cts.map +1 -0
- package/dist/ws/BackendWebSocketService-method-action-types.d.mts +252 -0
- package/dist/ws/BackendWebSocketService-method-action-types.d.mts.map +1 -0
- package/dist/ws/{BackendWebSocketService-method-action-types.js → BackendWebSocketService-method-action-types.mjs} +1 -1
- package/dist/ws/BackendWebSocketService-method-action-types.mjs.map +1 -0
- package/dist/ws/BackendWebSocketService.cjs +1062 -0
- package/dist/ws/BackendWebSocketService.cjs.map +1 -0
- package/dist/ws/{BackendWebSocketService.d.ts → BackendWebSocketService.d.cts} +7 -7
- package/dist/ws/BackendWebSocketService.d.cts.map +1 -0
- package/dist/ws/BackendWebSocketService.d.mts +406 -0
- package/dist/ws/BackendWebSocketService.d.mts.map +1 -0
- package/dist/ws/BackendWebSocketService.mjs +1057 -0
- package/dist/ws/BackendWebSocketService.mjs.map +1 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs +7 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs.map +1 -0
- package/dist/ws/ohlcv/{OHLCVService-method-action-types.d.ts → OHLCVService-method-action-types.d.cts} +2 -2
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.cts.map +1 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts +35 -0
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts.map +1 -0
- package/dist/ws/ohlcv/{OHLCVService-method-action-types.js → OHLCVService-method-action-types.mjs} +1 -1
- package/dist/ws/ohlcv/OHLCVService-method-action-types.mjs.map +1 -0
- package/dist/ws/ohlcv/OHLCVService.cjs +471 -0
- package/dist/ws/ohlcv/OHLCVService.cjs.map +1 -0
- package/dist/ws/ohlcv/{OHLCVService.d.ts → OHLCVService.d.cts} +9 -9
- package/dist/ws/ohlcv/OHLCVService.d.cts.map +1 -0
- package/dist/ws/ohlcv/OHLCVService.d.mts +111 -0
- package/dist/ws/ohlcv/OHLCVService.d.mts.map +1 -0
- package/dist/ws/ohlcv/OHLCVService.mjs +467 -0
- package/dist/ws/ohlcv/OHLCVService.mjs.map +1 -0
- package/dist/ws/ohlcv/index.cjs +9 -0
- package/dist/ws/ohlcv/index.cjs.map +1 -0
- package/dist/ws/ohlcv/{index.d.ts → index.d.cts} +5 -5
- package/dist/ws/ohlcv/index.d.cts.map +1 -0
- package/dist/ws/ohlcv/index.d.mts +5 -0
- package/dist/ws/ohlcv/index.d.mts.map +1 -0
- package/dist/ws/ohlcv/index.mjs +3 -0
- package/dist/ws/ohlcv/index.mjs.map +1 -0
- package/dist/ws/ohlcv/types.cjs +6 -0
- package/dist/ws/ohlcv/types.cjs.map +1 -0
- package/dist/ws/ohlcv/{types.d.ts → types.d.cts} +1 -1
- package/dist/ws/ohlcv/types.d.cts.map +1 -0
- package/dist/ws/ohlcv/types.d.mts +32 -0
- package/dist/ws/ohlcv/types.d.mts.map +1 -0
- package/dist/ws/ohlcv/{types.js → types.mjs} +1 -1
- package/dist/ws/ohlcv/types.mjs.map +1 -0
- package/package.json +16 -12
- package/dist/ApiPlatformClientService-method-action-types.d.ts.map +0 -1
- package/dist/ApiPlatformClientService-method-action-types.js.map +0 -1
- package/dist/ApiPlatformClientService.d.ts.map +0 -1
- package/dist/ApiPlatformClientService.js.map +0 -1
- package/dist/api/ApiPlatformClient.d.ts.map +0 -1
- package/dist/api/accounts/client.d.ts.map +0 -1
- package/dist/api/accounts/client.js.map +0 -1
- package/dist/api/accounts/index.d.ts.map +0 -1
- package/dist/api/accounts/index.js +0 -6
- package/dist/api/accounts/index.js.map +0 -1
- package/dist/api/accounts/types.d.ts.map +0 -1
- package/dist/api/accounts/types.js.map +0 -1
- package/dist/api/base-client.d.ts.map +0 -1
- package/dist/api/base-client.js.map +0 -1
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -18
- package/dist/api/index.js.map +0 -1
- package/dist/api/prices/client.d.ts.map +0 -1
- package/dist/api/prices/client.js.map +0 -1
- package/dist/api/prices/index.d.ts.map +0 -1
- package/dist/api/prices/index.js +0 -5
- package/dist/api/prices/index.js.map +0 -1
- package/dist/api/prices/types.d.ts.map +0 -1
- package/dist/api/prices/types.js.map +0 -1
- package/dist/api/shared-types.d.ts.map +0 -1
- package/dist/api/shared-types.js.map +0 -1
- package/dist/api/test-utils.d.ts.map +0 -1
- package/dist/api/test-utils.js.map +0 -1
- package/dist/api/token/client.d.ts.map +0 -1
- package/dist/api/token/client.js.map +0 -1
- package/dist/api/token/index.d.ts.map +0 -1
- package/dist/api/token/index.js +0 -5
- package/dist/api/token/index.js.map +0 -1
- package/dist/api/token/types.d.ts.map +0 -1
- package/dist/api/token/types.js.map +0 -1
- package/dist/api/tokens/client.d.ts.map +0 -1
- package/dist/api/tokens/client.js.map +0 -1
- package/dist/api/tokens/index.d.ts.map +0 -1
- package/dist/api/tokens/index.js +0 -5
- package/dist/api/tokens/index.js.map +0 -1
- package/dist/api/tokens/types.d.ts.map +0 -1
- package/dist/api/tokens/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts +0 -4
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -4
- package/dist/logger.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/ws/AccountActivityService.d.ts.map +0 -1
- package/dist/ws/AccountActivityService.js +0 -472
- package/dist/ws/AccountActivityService.js.map +0 -1
- package/dist/ws/BackendWebSocketService-method-action-types.d.ts.map +0 -1
- package/dist/ws/BackendWebSocketService-method-action-types.js.map +0 -1
- package/dist/ws/BackendWebSocketService.d.ts.map +0 -1
- package/dist/ws/BackendWebSocketService.js +0 -1191
- package/dist/ws/BackendWebSocketService.js.map +0 -1
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.ts.map +0 -1
- package/dist/ws/ohlcv/OHLCVService-method-action-types.js.map +0 -1
- package/dist/ws/ohlcv/OHLCVService.d.ts.map +0 -1
- package/dist/ws/ohlcv/OHLCVService.js +0 -471
- package/dist/ws/ohlcv/OHLCVService.js.map +0 -1
- package/dist/ws/ohlcv/index.d.ts.map +0 -1
- package/dist/ws/ohlcv/index.js +0 -3
- package/dist/ws/ohlcv/index.js.map +0 -1
- package/dist/ws/ohlcv/types.d.ts.map +0 -1
- package/dist/ws/ohlcv/types.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
-
- **BREAKING:** Bump minimum Node.js version to 22 ([#9168](https://github.com/MetaMask/core/pull/9168))
|
|
13
12
|
- Bump `@metamask/remote-feature-flag-controller` from `^6.0.0` to `^6.1.0` ([#9980](https://github.com/MetaMask/core/pull/9980))
|
|
14
13
|
|
|
15
14
|
## [9.0.0]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClientService-method-action-types.cjs","sourceRoot":"","sources":["../src/ApiPlatformClientService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ApiPlatformClientService } from './ApiPlatformClientService.js';\n\n/**\n * Returns the shared ApiPlatformClient instance.\n *\n * Use this via the messenger: `messenger.call('ApiPlatformClientService:getApiPlatformClient')`.\n *\n * @returns The ApiPlatformClient instance (accounts, prices, token, tokens).\n */\nexport type ApiPlatformClientServiceGetApiPlatformClientAction = {\n type: `ApiPlatformClientService:getApiPlatformClient`;\n handler: ApiPlatformClientService['getApiPlatformClient'];\n};\n\n/**\n * Union of all ApiPlatformClientService action types.\n */\nexport type ApiPlatformClientServiceMethodActions =\n ApiPlatformClientServiceGetApiPlatformClientAction;\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* This file is auto generated.
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
|
-
import type { ApiPlatformClientService } from
|
|
5
|
+
import type { ApiPlatformClientService } from "./ApiPlatformClientService.cjs";
|
|
6
6
|
/**
|
|
7
7
|
* Returns the shared ApiPlatformClient instance.
|
|
8
8
|
*
|
|
@@ -18,4 +18,4 @@ export type ApiPlatformClientServiceGetApiPlatformClientAction = {
|
|
|
18
18
|
* Union of all ApiPlatformClientService action types.
|
|
19
19
|
*/
|
|
20
20
|
export type ApiPlatformClientServiceMethodActions = ApiPlatformClientServiceGetApiPlatformClientAction;
|
|
21
|
-
//# sourceMappingURL=ApiPlatformClientService-method-action-types.d.
|
|
21
|
+
//# sourceMappingURL=ApiPlatformClientService-method-action-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClientService-method-action-types.d.cts","sourceRoot":"","sources":["../src/ApiPlatformClientService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAsC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC/C,kDAAkD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { ApiPlatformClientService } from "./ApiPlatformClientService.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Returns the shared ApiPlatformClient instance.
|
|
8
|
+
*
|
|
9
|
+
* Use this via the messenger: `messenger.call('ApiPlatformClientService:getApiPlatformClient')`.
|
|
10
|
+
*
|
|
11
|
+
* @returns The ApiPlatformClient instance (accounts, prices, token, tokens).
|
|
12
|
+
*/
|
|
13
|
+
export type ApiPlatformClientServiceGetApiPlatformClientAction = {
|
|
14
|
+
type: `ApiPlatformClientService:getApiPlatformClient`;
|
|
15
|
+
handler: ApiPlatformClientService['getApiPlatformClient'];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Union of all ApiPlatformClientService action types.
|
|
19
|
+
*/
|
|
20
|
+
export type ApiPlatformClientServiceMethodActions = ApiPlatformClientServiceGetApiPlatformClientAction;
|
|
21
|
+
//# sourceMappingURL=ApiPlatformClientService-method-action-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClientService-method-action-types.d.mts","sourceRoot":"","sources":["../src/ApiPlatformClientService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAsC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC/D,IAAI,EAAE,+CAA+C,CAAC;IACtD,OAAO,EAAE,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC/C,kDAAkD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClientService-method-action-types.mjs","sourceRoot":"","sources":["../src/ApiPlatformClientService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { ApiPlatformClientService } from './ApiPlatformClientService.js';\n\n/**\n * Returns the shared ApiPlatformClient instance.\n *\n * Use this via the messenger: `messenger.call('ApiPlatformClientService:getApiPlatformClient')`.\n *\n * @returns The ApiPlatformClient instance (accounts, prices, token, tokens).\n */\nexport type ApiPlatformClientServiceGetApiPlatformClientAction = {\n type: `ApiPlatformClientService:getApiPlatformClient`;\n handler: ApiPlatformClientService['getApiPlatformClient'];\n};\n\n/**\n * Union of all ApiPlatformClientService action types.\n */\nexport type ApiPlatformClientServiceMethodActions =\n ApiPlatformClientServiceGetApiPlatformClientAction;\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _ApiPlatformClientService_messenger, _ApiPlatformClientService_client;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ApiPlatformClientService = exports.apiPlatformClientServiceName = void 0;
|
|
16
|
+
const index_js_1 = require("./api/index.cjs");
|
|
17
|
+
// === GENERAL ===
|
|
18
|
+
/**
|
|
19
|
+
* The name of the {@link ApiPlatformClientService}, used to namespace the
|
|
20
|
+
* service's actions and events.
|
|
21
|
+
*/
|
|
22
|
+
exports.apiPlatformClientServiceName = 'ApiPlatformClientService';
|
|
23
|
+
// === MESSENGER ===
|
|
24
|
+
const MESSENGER_EXPOSED_METHODS = ['getApiPlatformClient'];
|
|
25
|
+
// === SERVICE DEFINITION ===
|
|
26
|
+
/**
|
|
27
|
+
* Service that provides access to {@link ApiPlatformClient} via the messenger.
|
|
28
|
+
*
|
|
29
|
+
* Consumers obtain the client by calling the `ApiPlatformClientService:getApiPlatformClient`
|
|
30
|
+
* action, then use it for accounts, prices, token, and tokens API calls.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { Messenger } from '@metamask/messenger';
|
|
36
|
+
* import {
|
|
37
|
+
* ApiPlatformClientService,
|
|
38
|
+
* type ApiPlatformClientServiceActions,
|
|
39
|
+
* type ApiPlatformClientServiceEvents,
|
|
40
|
+
* } from '@metamask/core-backend';
|
|
41
|
+
*
|
|
42
|
+
* const rootMessenger = new Messenger<'Root', ApiPlatformClientServiceActions, ApiPlatformClientServiceEvents>({ namespace: 'Root' });
|
|
43
|
+
* const serviceMessenger = new Messenger<
|
|
44
|
+
* 'ApiPlatformClientService',
|
|
45
|
+
* ApiPlatformClientServiceActions,
|
|
46
|
+
* ApiPlatformClientServiceEvents,
|
|
47
|
+
* typeof rootMessenger
|
|
48
|
+
* >({ namespace: 'ApiPlatformClientService', parent: rootMessenger });
|
|
49
|
+
*
|
|
50
|
+
* new ApiPlatformClientService({
|
|
51
|
+
* messenger: serviceMessenger,
|
|
52
|
+
* clientProduct: 'metamask-extension',
|
|
53
|
+
* getBearerToken: async () => token,
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* const client = rootMessenger.call('ApiPlatformClientService:getApiPlatformClient');
|
|
57
|
+
* const balances = await client.accounts.fetchV5MultiAccountBalances(accountIds);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
class ApiPlatformClientService {
|
|
61
|
+
constructor({ messenger, ...clientOptions }) {
|
|
62
|
+
_ApiPlatformClientService_messenger.set(this, void 0);
|
|
63
|
+
_ApiPlatformClientService_client.set(this, void 0);
|
|
64
|
+
this.name = exports.apiPlatformClientServiceName;
|
|
65
|
+
__classPrivateFieldSet(this, _ApiPlatformClientService_messenger, messenger, "f");
|
|
66
|
+
__classPrivateFieldSet(this, _ApiPlatformClientService_client, new index_js_1.ApiPlatformClient(clientOptions), "f");
|
|
67
|
+
__classPrivateFieldGet(this, _ApiPlatformClientService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Returns the shared ApiPlatformClient instance.
|
|
71
|
+
*
|
|
72
|
+
* Use this via the messenger: `messenger.call('ApiPlatformClientService:getApiPlatformClient')`.
|
|
73
|
+
*
|
|
74
|
+
* @returns The ApiPlatformClient instance (accounts, prices, token, tokens).
|
|
75
|
+
*/
|
|
76
|
+
getApiPlatformClient() {
|
|
77
|
+
return __classPrivateFieldGet(this, _ApiPlatformClientService_client, "f");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ApiPlatformClientService = ApiPlatformClientService;
|
|
81
|
+
_ApiPlatformClientService_messenger = new WeakMap(), _ApiPlatformClientService_client = new WeakMap();
|
|
82
|
+
//# sourceMappingURL=ApiPlatformClientService.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClientService.cjs","sourceRoot":"","sources":["../src/ApiPlatformClientService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,8CAAmD;AAInD,kBAAkB;AAElB;;;GAGG;AACU,QAAA,4BAA4B,GAAG,0BAA0B,CAAC;AAEvE,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,sBAAsB,CAAU,CAAC;AA2CpE,6BAA6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAa,wBAAwB;IAOnC,YAAY,EACV,SAAS,EACT,GAAG,aAAa,EACgB;QAPzB,sDAA8C;QAE9C,mDAA2B;QAMlC,IAAI,CAAC,IAAI,GAAG,oCAA4B,CAAC;QACzC,uBAAA,IAAI,uCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,oCAAW,IAAI,4BAAiB,CAAC,aAAa,CAAC,MAAA,CAAC;QAEpD,uBAAA,IAAI,2CAAW,CAAC,4BAA4B,CAC1C,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,oBAAoB;QAClB,OAAO,uBAAA,IAAI,wCAAQ,CAAC;IACtB,CAAC;CACF;AA/BD,4DA+BC","sourcesContent":["import type { Messenger } from '@metamask/messenger';\n\nimport { ApiPlatformClient } from './api/index.js';\nimport type { ApiPlatformClientOptions } from './api/index.js';\nimport type { ApiPlatformClientServiceMethodActions } from './ApiPlatformClientService-method-action-types.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ApiPlatformClientService}, used to namespace the\n * service's actions and events.\n */\nexport const apiPlatformClientServiceName = 'ApiPlatformClientService';\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['getApiPlatformClient'] as const;\n\n/**\n * Actions that {@link ApiPlatformClientService} exposes to other consumers.\n */\nexport type ApiPlatformClientServiceActions =\n ApiPlatformClientServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link ApiPlatformClientServiceMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link ApiPlatformClientService} exposes to other consumers.\n */\nexport type ApiPlatformClientServiceEvents = never;\n\n/**\n * Events from other messengers that {@link ApiPlatformClientService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link ApiPlatformClientService}.\n */\nexport type ApiPlatformClientServiceMessenger = Messenger<\n typeof apiPlatformClientServiceName,\n ApiPlatformClientServiceActions | AllowedActions,\n ApiPlatformClientServiceEvents | AllowedEvents\n>;\n\n// === SERVICE OPTIONS ===\n\n/**\n * Options for constructing {@link ApiPlatformClientService}.\n */\nexport type ApiPlatformClientServiceOptions = {\n /** The messenger suited for this service. */\n messenger: ApiPlatformClientServiceMessenger;\n} & ApiPlatformClientOptions;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Service that provides access to {@link ApiPlatformClient} via the messenger.\n *\n * Consumers obtain the client by calling the `ApiPlatformClientService:getApiPlatformClient`\n * action, then use it for accounts, prices, token, and tokens API calls.\n *\n * @example\n *\n * ```ts\n * import { Messenger } from '@metamask/messenger';\n * import {\n * ApiPlatformClientService,\n * type ApiPlatformClientServiceActions,\n * type ApiPlatformClientServiceEvents,\n * } from '@metamask/core-backend';\n *\n * const rootMessenger = new Messenger<'Root', ApiPlatformClientServiceActions, ApiPlatformClientServiceEvents>({ namespace: 'Root' });\n * const serviceMessenger = new Messenger<\n * 'ApiPlatformClientService',\n * ApiPlatformClientServiceActions,\n * ApiPlatformClientServiceEvents,\n * typeof rootMessenger\n * >({ namespace: 'ApiPlatformClientService', parent: rootMessenger });\n *\n * new ApiPlatformClientService({\n * messenger: serviceMessenger,\n * clientProduct: 'metamask-extension',\n * getBearerToken: async () => token,\n * });\n *\n * const client = rootMessenger.call('ApiPlatformClientService:getApiPlatformClient');\n * const balances = await client.accounts.fetchV5MultiAccountBalances(accountIds);\n * ```\n */\nexport class ApiPlatformClientService {\n readonly name: typeof apiPlatformClientServiceName;\n\n readonly #messenger: ApiPlatformClientServiceMessenger;\n\n readonly #client: ApiPlatformClient;\n\n constructor({\n messenger,\n ...clientOptions\n }: ApiPlatformClientServiceOptions) {\n this.name = apiPlatformClientServiceName;\n this.#messenger = messenger;\n this.#client = new ApiPlatformClient(clientOptions);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Returns the shared ApiPlatformClient instance.\n *\n * Use this via the messenger: `messenger.call('ApiPlatformClientService:getApiPlatformClient')`.\n *\n * @returns The ApiPlatformClient instance (accounts, prices, token, tokens).\n */\n getApiPlatformClient(): ApiPlatformClient {\n return this.#client;\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Messenger } from
|
|
2
|
-
import { ApiPlatformClient } from
|
|
3
|
-
import type { ApiPlatformClientOptions } from
|
|
4
|
-
import type { ApiPlatformClientServiceMethodActions } from
|
|
1
|
+
import type { Messenger } from "@metamask/messenger";
|
|
2
|
+
import { ApiPlatformClient } from "./api/index.cjs";
|
|
3
|
+
import type { ApiPlatformClientOptions } from "./api/index.cjs";
|
|
4
|
+
import type { ApiPlatformClientServiceMethodActions } from "./ApiPlatformClientService-method-action-types.cjs";
|
|
5
5
|
/**
|
|
6
6
|
* The name of the {@link ApiPlatformClientService}, used to namespace the
|
|
7
7
|
* service's actions and events.
|
|
@@ -83,4 +83,4 @@ export declare class ApiPlatformClientService {
|
|
|
83
83
|
getApiPlatformClient(): ApiPlatformClient;
|
|
84
84
|
}
|
|
85
85
|
export {};
|
|
86
|
-
//# sourceMappingURL=ApiPlatformClientService.d.
|
|
86
|
+
//# sourceMappingURL=ApiPlatformClientService.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClientService.d.cts","sourceRoot":"","sources":["../src/ApiPlatformClientService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,iBAAiB,EAAE,wBAAuB;AACnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAuB;AAC/D,OAAO,KAAK,EAAE,qCAAqC,EAAE,2DAA0D;AAI/G;;;GAGG;AACH,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AAMvE;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACzC,qCAAqC,CAAC;AAExC;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAEnD;;GAEG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,4BAA4B,EACnC,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAIF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,6CAA6C;IAC7C,SAAS,EAAE,iCAAiC,CAAC;CAC9C,GAAG,wBAAwB,CAAC;AAI7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,wBAAwB;;IACnC,QAAQ,CAAC,IAAI,EAAE,OAAO,4BAA4B,CAAC;gBAMvC,EACV,SAAS,EACT,GAAG,aAAa,EACjB,EAAE,+BAA+B;IAWlC;;;;;;OAMG;IACH,oBAAoB,IAAI,iBAAiB;CAG1C"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Messenger } from "@metamask/messenger";
|
|
2
|
+
import { ApiPlatformClient } from "./api/index.mjs";
|
|
3
|
+
import type { ApiPlatformClientOptions } from "./api/index.mjs";
|
|
4
|
+
import type { ApiPlatformClientServiceMethodActions } from "./ApiPlatformClientService-method-action-types.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* The name of the {@link ApiPlatformClientService}, used to namespace the
|
|
7
|
+
* service's actions and events.
|
|
8
|
+
*/
|
|
9
|
+
export declare const apiPlatformClientServiceName = "ApiPlatformClientService";
|
|
10
|
+
/**
|
|
11
|
+
* Actions that {@link ApiPlatformClientService} exposes to other consumers.
|
|
12
|
+
*/
|
|
13
|
+
export type ApiPlatformClientServiceActions = ApiPlatformClientServiceMethodActions;
|
|
14
|
+
/**
|
|
15
|
+
* Actions from other messengers that {@link ApiPlatformClientServiceMessenger} calls.
|
|
16
|
+
*/
|
|
17
|
+
type AllowedActions = never;
|
|
18
|
+
/**
|
|
19
|
+
* Events that {@link ApiPlatformClientService} exposes to other consumers.
|
|
20
|
+
*/
|
|
21
|
+
export type ApiPlatformClientServiceEvents = never;
|
|
22
|
+
/**
|
|
23
|
+
* Events from other messengers that {@link ApiPlatformClientService} subscribes to.
|
|
24
|
+
*/
|
|
25
|
+
type AllowedEvents = never;
|
|
26
|
+
/**
|
|
27
|
+
* The messenger which is restricted to actions and events accessed by
|
|
28
|
+
* {@link ApiPlatformClientService}.
|
|
29
|
+
*/
|
|
30
|
+
export type ApiPlatformClientServiceMessenger = Messenger<typeof apiPlatformClientServiceName, ApiPlatformClientServiceActions | AllowedActions, ApiPlatformClientServiceEvents | AllowedEvents>;
|
|
31
|
+
/**
|
|
32
|
+
* Options for constructing {@link ApiPlatformClientService}.
|
|
33
|
+
*/
|
|
34
|
+
export type ApiPlatformClientServiceOptions = {
|
|
35
|
+
/** The messenger suited for this service. */
|
|
36
|
+
messenger: ApiPlatformClientServiceMessenger;
|
|
37
|
+
} & ApiPlatformClientOptions;
|
|
38
|
+
/**
|
|
39
|
+
* Service that provides access to {@link ApiPlatformClient} via the messenger.
|
|
40
|
+
*
|
|
41
|
+
* Consumers obtain the client by calling the `ApiPlatformClientService:getApiPlatformClient`
|
|
42
|
+
* action, then use it for accounts, prices, token, and tokens API calls.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { Messenger } from '@metamask/messenger';
|
|
48
|
+
* import {
|
|
49
|
+
* ApiPlatformClientService,
|
|
50
|
+
* type ApiPlatformClientServiceActions,
|
|
51
|
+
* type ApiPlatformClientServiceEvents,
|
|
52
|
+
* } from '@metamask/core-backend';
|
|
53
|
+
*
|
|
54
|
+
* const rootMessenger = new Messenger<'Root', ApiPlatformClientServiceActions, ApiPlatformClientServiceEvents>({ namespace: 'Root' });
|
|
55
|
+
* const serviceMessenger = new Messenger<
|
|
56
|
+
* 'ApiPlatformClientService',
|
|
57
|
+
* ApiPlatformClientServiceActions,
|
|
58
|
+
* ApiPlatformClientServiceEvents,
|
|
59
|
+
* typeof rootMessenger
|
|
60
|
+
* >({ namespace: 'ApiPlatformClientService', parent: rootMessenger });
|
|
61
|
+
*
|
|
62
|
+
* new ApiPlatformClientService({
|
|
63
|
+
* messenger: serviceMessenger,
|
|
64
|
+
* clientProduct: 'metamask-extension',
|
|
65
|
+
* getBearerToken: async () => token,
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* const client = rootMessenger.call('ApiPlatformClientService:getApiPlatformClient');
|
|
69
|
+
* const balances = await client.accounts.fetchV5MultiAccountBalances(accountIds);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare class ApiPlatformClientService {
|
|
73
|
+
#private;
|
|
74
|
+
readonly name: typeof apiPlatformClientServiceName;
|
|
75
|
+
constructor({ messenger, ...clientOptions }: ApiPlatformClientServiceOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Returns the shared ApiPlatformClient instance.
|
|
78
|
+
*
|
|
79
|
+
* Use this via the messenger: `messenger.call('ApiPlatformClientService:getApiPlatformClient')`.
|
|
80
|
+
*
|
|
81
|
+
* @returns The ApiPlatformClient instance (accounts, prices, token, tokens).
|
|
82
|
+
*/
|
|
83
|
+
getApiPlatformClient(): ApiPlatformClient;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=ApiPlatformClientService.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClientService.d.mts","sourceRoot":"","sources":["../src/ApiPlatformClientService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,iBAAiB,EAAE,wBAAuB;AACnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAuB;AAC/D,OAAO,KAAK,EAAE,qCAAqC,EAAE,2DAA0D;AAI/G;;;GAGG;AACH,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AAMvE;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACzC,qCAAqC,CAAC;AAExC;;GAEG;AACH,KAAK,cAAc,GAAG,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAEnD;;GAEG;AACH,KAAK,aAAa,GAAG,KAAK,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,4BAA4B,EACnC,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAIF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,6CAA6C;IAC7C,SAAS,EAAE,iCAAiC,CAAC;CAC9C,GAAG,wBAAwB,CAAC;AAI7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,wBAAwB;;IACnC,QAAQ,CAAC,IAAI,EAAE,OAAO,4BAA4B,CAAC;gBAMvC,EACV,SAAS,EACT,GAAG,aAAa,EACjB,EAAE,+BAA+B;IAWlC;;;;;;OAMG;IACH,oBAAoB,IAAI,iBAAiB;CAG1C"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ApiPlatformClientService_messenger, _ApiPlatformClientService_client;
|
|
13
|
+
import { ApiPlatformClient } from "./api/index.mjs";
|
|
2
14
|
// === GENERAL ===
|
|
3
15
|
/**
|
|
4
16
|
* The name of the {@link ApiPlatformClientService}, used to namespace the
|
|
@@ -43,14 +55,13 @@ const MESSENGER_EXPOSED_METHODS = ['getApiPlatformClient'];
|
|
|
43
55
|
* ```
|
|
44
56
|
*/
|
|
45
57
|
export class ApiPlatformClientService {
|
|
46
|
-
name;
|
|
47
|
-
#messenger;
|
|
48
|
-
#client;
|
|
49
58
|
constructor({ messenger, ...clientOptions }) {
|
|
59
|
+
_ApiPlatformClientService_messenger.set(this, void 0);
|
|
60
|
+
_ApiPlatformClientService_client.set(this, void 0);
|
|
50
61
|
this.name = apiPlatformClientServiceName;
|
|
51
|
-
this
|
|
52
|
-
this
|
|
53
|
-
this
|
|
62
|
+
__classPrivateFieldSet(this, _ApiPlatformClientService_messenger, messenger, "f");
|
|
63
|
+
__classPrivateFieldSet(this, _ApiPlatformClientService_client, new ApiPlatformClient(clientOptions), "f");
|
|
64
|
+
__classPrivateFieldGet(this, _ApiPlatformClientService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
54
65
|
}
|
|
55
66
|
/**
|
|
56
67
|
* Returns the shared ApiPlatformClient instance.
|
|
@@ -60,7 +71,8 @@ export class ApiPlatformClientService {
|
|
|
60
71
|
* @returns The ApiPlatformClient instance (accounts, prices, token, tokens).
|
|
61
72
|
*/
|
|
62
73
|
getApiPlatformClient() {
|
|
63
|
-
return this
|
|
74
|
+
return __classPrivateFieldGet(this, _ApiPlatformClientService_client, "f");
|
|
64
75
|
}
|
|
65
76
|
}
|
|
66
|
-
|
|
77
|
+
_ApiPlatformClientService_messenger = new WeakMap(), _ApiPlatformClientService_client = new WeakMap();
|
|
78
|
+
//# sourceMappingURL=ApiPlatformClientService.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClientService.mjs","sourceRoot":"","sources":["../src/ApiPlatformClientService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,iBAAiB,EAAE,wBAAuB;AAInD,kBAAkB;AAElB;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAEvE,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG,CAAC,sBAAsB,CAAU,CAAC;AA2CpE,6BAA6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,wBAAwB;IAOnC,YAAY,EACV,SAAS,EACT,GAAG,aAAa,EACgB;QAPzB,sDAA8C;QAE9C,mDAA2B;QAMlC,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,uBAAA,IAAI,uCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,oCAAW,IAAI,iBAAiB,CAAC,aAAa,CAAC,MAAA,CAAC;QAEpD,uBAAA,IAAI,2CAAW,CAAC,4BAA4B,CAC1C,IAAI,EACJ,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,oBAAoB;QAClB,OAAO,uBAAA,IAAI,wCAAQ,CAAC;IACtB,CAAC;CACF","sourcesContent":["import type { Messenger } from '@metamask/messenger';\n\nimport { ApiPlatformClient } from './api/index.js';\nimport type { ApiPlatformClientOptions } from './api/index.js';\nimport type { ApiPlatformClientServiceMethodActions } from './ApiPlatformClientService-method-action-types.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link ApiPlatformClientService}, used to namespace the\n * service's actions and events.\n */\nexport const apiPlatformClientServiceName = 'ApiPlatformClientService';\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = ['getApiPlatformClient'] as const;\n\n/**\n * Actions that {@link ApiPlatformClientService} exposes to other consumers.\n */\nexport type ApiPlatformClientServiceActions =\n ApiPlatformClientServiceMethodActions;\n\n/**\n * Actions from other messengers that {@link ApiPlatformClientServiceMessenger} calls.\n */\ntype AllowedActions = never;\n\n/**\n * Events that {@link ApiPlatformClientService} exposes to other consumers.\n */\nexport type ApiPlatformClientServiceEvents = never;\n\n/**\n * Events from other messengers that {@link ApiPlatformClientService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger which is restricted to actions and events accessed by\n * {@link ApiPlatformClientService}.\n */\nexport type ApiPlatformClientServiceMessenger = Messenger<\n typeof apiPlatformClientServiceName,\n ApiPlatformClientServiceActions | AllowedActions,\n ApiPlatformClientServiceEvents | AllowedEvents\n>;\n\n// === SERVICE OPTIONS ===\n\n/**\n * Options for constructing {@link ApiPlatformClientService}.\n */\nexport type ApiPlatformClientServiceOptions = {\n /** The messenger suited for this service. */\n messenger: ApiPlatformClientServiceMessenger;\n} & ApiPlatformClientOptions;\n\n// === SERVICE DEFINITION ===\n\n/**\n * Service that provides access to {@link ApiPlatformClient} via the messenger.\n *\n * Consumers obtain the client by calling the `ApiPlatformClientService:getApiPlatformClient`\n * action, then use it for accounts, prices, token, and tokens API calls.\n *\n * @example\n *\n * ```ts\n * import { Messenger } from '@metamask/messenger';\n * import {\n * ApiPlatformClientService,\n * type ApiPlatformClientServiceActions,\n * type ApiPlatformClientServiceEvents,\n * } from '@metamask/core-backend';\n *\n * const rootMessenger = new Messenger<'Root', ApiPlatformClientServiceActions, ApiPlatformClientServiceEvents>({ namespace: 'Root' });\n * const serviceMessenger = new Messenger<\n * 'ApiPlatformClientService',\n * ApiPlatformClientServiceActions,\n * ApiPlatformClientServiceEvents,\n * typeof rootMessenger\n * >({ namespace: 'ApiPlatformClientService', parent: rootMessenger });\n *\n * new ApiPlatformClientService({\n * messenger: serviceMessenger,\n * clientProduct: 'metamask-extension',\n * getBearerToken: async () => token,\n * });\n *\n * const client = rootMessenger.call('ApiPlatformClientService:getApiPlatformClient');\n * const balances = await client.accounts.fetchV5MultiAccountBalances(accountIds);\n * ```\n */\nexport class ApiPlatformClientService {\n readonly name: typeof apiPlatformClientServiceName;\n\n readonly #messenger: ApiPlatformClientServiceMessenger;\n\n readonly #client: ApiPlatformClient;\n\n constructor({\n messenger,\n ...clientOptions\n }: ApiPlatformClientServiceOptions) {\n this.name = apiPlatformClientServiceName;\n this.#messenger = messenger;\n this.#client = new ApiPlatformClient(clientOptions);\n\n this.#messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Returns the shared ApiPlatformClient instance.\n *\n * Use this via the messenger: `messenger.call('ApiPlatformClientService:getApiPlatformClient')`.\n *\n * @returns The ApiPlatformClient instance (accounts, prices, token, tokens).\n */\n getApiPlatformClient(): ApiPlatformClient {\n return this.#client;\n }\n}\n"]}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ApiPlatformClient - MetaMask API Platform Client
|
|
4
|
+
*
|
|
5
|
+
* A comprehensive API client that uses @tanstack/query-core directly for:
|
|
6
|
+
* - Automatic request deduplication
|
|
7
|
+
* - Intelligent caching
|
|
8
|
+
* - Automatic retries with exponential backoff
|
|
9
|
+
*
|
|
10
|
+
* Provides unified access to all MetaMask backend APIs:
|
|
11
|
+
* - Accounts API (accounts.api.cx.metamask.io)
|
|
12
|
+
* - Price API (price.api.cx.metamask.io)
|
|
13
|
+
* - Token API (token.api.cx.metamask.io)
|
|
14
|
+
* - Tokens API (tokens.api.cx.metamask.io)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const client = new ApiPlatformClient({
|
|
19
|
+
* clientProduct: 'metamask-extension',
|
|
20
|
+
* getBearerToken: async () => token,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Access API methods through sub-clients
|
|
24
|
+
* const networks = await client.accounts.fetchV2SupportedNetworks();
|
|
25
|
+
* const balances = await client.accounts.fetchV5MultiAccountBalances(accountIds);
|
|
26
|
+
* const prices = await client.prices.fetchV3SpotPrices(assetIds);
|
|
27
|
+
* const tokenList = await client.token.fetchTokenList(1);
|
|
28
|
+
* const assets = await client.tokens.fetchV3Assets(assetIds);
|
|
29
|
+
*
|
|
30
|
+
* // Cache management
|
|
31
|
+
* await client.invalidateAll(); // Invalidate all caches
|
|
32
|
+
* await client.invalidateAuthToken(); // Invalidate auth token
|
|
33
|
+
* await client.accounts.invalidateBalances(); // Domain-specific via sub-client
|
|
34
|
+
* await client.prices.invalidatePrices(); // Domain-specific via sub-client
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
38
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
39
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
40
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
41
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
42
|
+
};
|
|
43
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
44
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
45
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
46
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
47
|
+
};
|
|
48
|
+
var _ApiPlatformClient_sharedQueryClient;
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.createApiPlatformClient = exports.ApiPlatformClient = void 0;
|
|
51
|
+
const query_core_1 = require("@tanstack/query-core");
|
|
52
|
+
// Import API clients from subfolders
|
|
53
|
+
const index_js_1 = require("./accounts/index.cjs");
|
|
54
|
+
const base_client_js_1 = require("./base-client.cjs");
|
|
55
|
+
const index_js_2 = require("./prices/index.cjs");
|
|
56
|
+
const shared_types_js_1 = require("./shared-types.cjs");
|
|
57
|
+
const index_js_3 = require("./token/index.cjs");
|
|
58
|
+
const index_js_4 = require("./tokens/index.cjs");
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// UNIFIED API CLIENT
|
|
61
|
+
// ============================================================================
|
|
62
|
+
/**
|
|
63
|
+
* MetaMask API Platform Client with TanStack Query caching.
|
|
64
|
+
* Provides cached access to all MetaMask backend APIs through a unified interface.
|
|
65
|
+
*
|
|
66
|
+
* Access API methods through the sub-clients:
|
|
67
|
+
* - `client.accounts` - Accounts API (balances, transactions, NFTs, etc.)
|
|
68
|
+
* - `client.prices` - Prices API (spot prices, exchange rates, historical prices)
|
|
69
|
+
* - `client.token` - Token API (token metadata, trending, top gainers)
|
|
70
|
+
* - `client.tokens` - Tokens API (bulk asset operations, supported networks)
|
|
71
|
+
*/
|
|
72
|
+
class ApiPlatformClient {
|
|
73
|
+
constructor(options) {
|
|
74
|
+
/**
|
|
75
|
+
* Shared QueryClient instance used by all sub-clients.
|
|
76
|
+
*/
|
|
77
|
+
_ApiPlatformClient_sharedQueryClient.set(this, void 0);
|
|
78
|
+
// Create or use provided QueryClient - shared by all sub-clients
|
|
79
|
+
__classPrivateFieldSet(this, _ApiPlatformClient_sharedQueryClient, options.queryClient ??
|
|
80
|
+
new query_core_1.QueryClient({
|
|
81
|
+
defaultOptions: {
|
|
82
|
+
queries: {
|
|
83
|
+
staleTime: shared_types_js_1.STALE_TIMES.DEFAULT,
|
|
84
|
+
gcTime: shared_types_js_1.GC_TIMES.DEFAULT,
|
|
85
|
+
retry: shared_types_js_1.shouldRetry,
|
|
86
|
+
retryDelay: shared_types_js_1.calculateRetryDelay,
|
|
87
|
+
refetchOnWindowFocus: false,
|
|
88
|
+
networkMode: 'always',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
}), "f");
|
|
92
|
+
// Pass the shared QueryClient to all sub-clients
|
|
93
|
+
const sharedOptions = {
|
|
94
|
+
...options,
|
|
95
|
+
queryClient: __classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f"),
|
|
96
|
+
};
|
|
97
|
+
this.accounts = new index_js_1.AccountsApiClient(sharedOptions);
|
|
98
|
+
this.prices = new index_js_2.PricesApiClient(sharedOptions);
|
|
99
|
+
this.token = new index_js_3.TokenApiClient(sharedOptions);
|
|
100
|
+
this.tokens = new index_js_4.TokensApiClient(sharedOptions);
|
|
101
|
+
}
|
|
102
|
+
// ==========================================================================
|
|
103
|
+
// CACHE MANAGEMENT (operates on shared QueryClient)
|
|
104
|
+
// ==========================================================================
|
|
105
|
+
/**
|
|
106
|
+
* Get the underlying QueryClient (for advanced usage).
|
|
107
|
+
*
|
|
108
|
+
* @returns The underlying QueryClient instance.
|
|
109
|
+
*/
|
|
110
|
+
get queryClient() {
|
|
111
|
+
return __classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f");
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get cached data for a query key.
|
|
115
|
+
*
|
|
116
|
+
* @param queryKey - The query key to look up.
|
|
117
|
+
* @returns The cached data or undefined.
|
|
118
|
+
*/
|
|
119
|
+
getCachedData(queryKey) {
|
|
120
|
+
return __classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f").getQueryData(queryKey);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Set cached data for a query key.
|
|
124
|
+
*
|
|
125
|
+
* @param queryKey - The query key to set data for.
|
|
126
|
+
* @param data - The data to cache.
|
|
127
|
+
*/
|
|
128
|
+
setCachedData(queryKey, data) {
|
|
129
|
+
__classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f").setQueryData(queryKey, data);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Check if a query is currently fetching.
|
|
133
|
+
*
|
|
134
|
+
* @param queryKey - The query key to check.
|
|
135
|
+
* @returns True if the query is currently fetching.
|
|
136
|
+
*/
|
|
137
|
+
isFetching(queryKey) {
|
|
138
|
+
return __classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f").isFetching({ queryKey }) > 0;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Clear all cached data across all sub-clients.
|
|
142
|
+
*/
|
|
143
|
+
clear() {
|
|
144
|
+
__classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f").clear();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Invalidate all queries across all sub-clients.
|
|
148
|
+
*/
|
|
149
|
+
async invalidateAll() {
|
|
150
|
+
await __classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f").invalidateQueries();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Invalidate the cached auth token.
|
|
154
|
+
* Call this when the user logs out or the token expires.
|
|
155
|
+
*
|
|
156
|
+
* Uses resetQueries() instead of invalidateQueries() to completely remove
|
|
157
|
+
* the cached value, ensuring the next request fetches a fresh token immediately.
|
|
158
|
+
*/
|
|
159
|
+
async invalidateAuthToken() {
|
|
160
|
+
await __classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f").resetQueries({
|
|
161
|
+
queryKey: base_client_js_1.authQueryKeys.bearerToken(),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.ApiPlatformClient = ApiPlatformClient;
|
|
166
|
+
_ApiPlatformClient_sharedQueryClient = new WeakMap();
|
|
167
|
+
/**
|
|
168
|
+
* Factory function to create an ApiPlatformClient.
|
|
169
|
+
*
|
|
170
|
+
* @param options - Configuration options for the client.
|
|
171
|
+
* @returns A new ApiPlatformClient instance.
|
|
172
|
+
*/
|
|
173
|
+
function createApiPlatformClient(options) {
|
|
174
|
+
return new ApiPlatformClient(options);
|
|
175
|
+
}
|
|
176
|
+
exports.createApiPlatformClient = createApiPlatformClient;
|
|
177
|
+
//# sourceMappingURL=ApiPlatformClient.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiPlatformClient.
|
|
1
|
+
{"version":3,"file":"ApiPlatformClient.cjs","sourceRoot":"","sources":["../../src/api/ApiPlatformClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;;;;;;;;;;;;;AAEH,qDAAmD;AAGnD,qCAAqC;AACrC,mDAAwD;AACxD,sDAAiD;AACjD,iDAAoD;AACpD,wDAK2B;AAE3B,gDAAkD;AAClD,iDAAoD;AAEpD,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IA8B5B,YAAY,OAAiC;QAL7C;;WAEG;QACM,uDAAgC;QAGvC,iEAAiE;QACjE,uBAAA,IAAI,wCACF,OAAO,CAAC,WAAW;YACnB,IAAI,wBAAW,CAAC;gBACd,cAAc,EAAE;oBACd,OAAO,EAAE;wBACP,SAAS,EAAE,6BAAW,CAAC,OAAO;wBAC9B,MAAM,EAAE,0BAAQ,CAAC,OAAO;wBACxB,KAAK,EAAE,6BAAW;wBAClB,UAAU,EAAE,qCAAmB;wBAC/B,oBAAoB,EAAE,KAAK;wBAC3B,WAAW,EAAE,QAAQ;qBACtB;iBACF;aACF,CAAC,MAAA,CAAC;QAEL,iDAAiD;QACjD,MAAM,aAAa,GAA6B;YAC9C,GAAG,OAAO;YACV,WAAW,EAAE,uBAAA,IAAI,4CAAmB;SACrC,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,IAAI,4BAAiB,CAAC,aAAa,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,IAAI,0BAAe,CAAC,aAAa,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAc,CAAC,aAAa,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,0BAAe,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC;IAED,6EAA6E;IAC7E,oDAAoD;IACpD,6EAA6E;IAE7E;;;;OAIG;IACH,IAAI,WAAW;QACb,OAAO,uBAAA,IAAI,4CAAmB,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAa,QAAkB;QAC1C,OAAO,uBAAA,IAAI,4CAAmB,CAAC,YAAY,CAAa,QAAQ,CAAC,CAAC;IACpE,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAa,QAAkB,EAAE,IAAgB;QAC5D,uBAAA,IAAI,4CAAmB,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,QAAkB;QAC3B,OAAO,uBAAA,IAAI,4CAAmB,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,KAAK;QACH,uBAAA,IAAI,4CAAmB,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa;QACjB,MAAM,uBAAA,IAAI,4CAAmB,CAAC,iBAAiB,EAAE,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB;QACvB,MAAM,uBAAA,IAAI,4CAAmB,CAAC,YAAY,CAAC;YACzC,QAAQ,EAAE,8BAAa,CAAC,WAAW,EAAE;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AAhID,8CAgIC;;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,OAAiC;IAEjC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAJD,0DAIC","sourcesContent":["/**\n * ApiPlatformClient - MetaMask API Platform Client\n *\n * A comprehensive API client that uses @tanstack/query-core directly for:\n * - Automatic request deduplication\n * - Intelligent caching\n * - Automatic retries with exponential backoff\n *\n * Provides unified access to all MetaMask backend APIs:\n * - Accounts API (accounts.api.cx.metamask.io)\n * - Price API (price.api.cx.metamask.io)\n * - Token API (token.api.cx.metamask.io)\n * - Tokens API (tokens.api.cx.metamask.io)\n *\n * @example\n * ```typescript\n * const client = new ApiPlatformClient({\n * clientProduct: 'metamask-extension',\n * getBearerToken: async () => token,\n * });\n *\n * // Access API methods through sub-clients\n * const networks = await client.accounts.fetchV2SupportedNetworks();\n * const balances = await client.accounts.fetchV5MultiAccountBalances(accountIds);\n * const prices = await client.prices.fetchV3SpotPrices(assetIds);\n * const tokenList = await client.token.fetchTokenList(1);\n * const assets = await client.tokens.fetchV3Assets(assetIds);\n *\n * // Cache management\n * await client.invalidateAll(); // Invalidate all caches\n * await client.invalidateAuthToken(); // Invalidate auth token\n * await client.accounts.invalidateBalances(); // Domain-specific via sub-client\n * await client.prices.invalidatePrices(); // Domain-specific via sub-client\n * ```\n */\n\nimport { QueryClient } from '@tanstack/query-core';\nimport type { QueryKey } from '@tanstack/query-core';\n\n// Import API clients from subfolders\nimport { AccountsApiClient } from './accounts/index.js';\nimport { authQueryKeys } from './base-client.js';\nimport { PricesApiClient } from './prices/index.js';\nimport {\n STALE_TIMES,\n GC_TIMES,\n shouldRetry,\n calculateRetryDelay,\n} from './shared-types.js';\nimport type { ApiPlatformClientOptions } from './shared-types.js';\nimport { TokenApiClient } from './token/index.js';\nimport { TokensApiClient } from './tokens/index.js';\n\n// ============================================================================\n// UNIFIED API CLIENT\n// ============================================================================\n\n/**\n * MetaMask API Platform Client with TanStack Query caching.\n * Provides cached access to all MetaMask backend APIs through a unified interface.\n *\n * Access API methods through the sub-clients:\n * - `client.accounts` - Accounts API (balances, transactions, NFTs, etc.)\n * - `client.prices` - Prices API (spot prices, exchange rates, historical prices)\n * - `client.token` - Token API (token metadata, trending, top gainers)\n * - `client.tokens` - Tokens API (bulk asset operations, supported networks)\n */\nexport class ApiPlatformClient {\n /**\n * Accounts API client.\n * Provides methods for balances, transactions, relationships, NFTs, and token discovery.\n */\n readonly accounts: AccountsApiClient;\n\n /**\n * Prices API client.\n * Provides methods for spot prices, exchange rates, and historical prices.\n */\n readonly prices: PricesApiClient;\n\n /**\n * Token API client.\n * Provides methods for token metadata, networks, trending tokens, and top assets.\n */\n readonly token: TokenApiClient;\n\n /**\n * Tokens API client.\n * Provides methods for bulk asset operations and supported networks.\n */\n readonly tokens: TokensApiClient;\n\n /**\n * Shared QueryClient instance used by all sub-clients.\n */\n readonly #sharedQueryClient: QueryClient;\n\n constructor(options: ApiPlatformClientOptions) {\n // Create or use provided QueryClient - shared by all sub-clients\n this.#sharedQueryClient =\n options.queryClient ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIMES.DEFAULT,\n gcTime: GC_TIMES.DEFAULT,\n retry: shouldRetry,\n retryDelay: calculateRetryDelay,\n refetchOnWindowFocus: false,\n networkMode: 'always',\n },\n },\n });\n\n // Pass the shared QueryClient to all sub-clients\n const sharedOptions: ApiPlatformClientOptions = {\n ...options,\n queryClient: this.#sharedQueryClient,\n };\n\n this.accounts = new AccountsApiClient(sharedOptions);\n this.prices = new PricesApiClient(sharedOptions);\n this.token = new TokenApiClient(sharedOptions);\n this.tokens = new TokensApiClient(sharedOptions);\n }\n\n // ==========================================================================\n // CACHE MANAGEMENT (operates on shared QueryClient)\n // ==========================================================================\n\n /**\n * Get the underlying QueryClient (for advanced usage).\n *\n * @returns The underlying QueryClient instance.\n */\n get queryClient(): QueryClient {\n return this.#sharedQueryClient;\n }\n\n /**\n * Get cached data for a query key.\n *\n * @param queryKey - The query key to look up.\n * @returns The cached data or undefined.\n */\n getCachedData<CachedData>(queryKey: QueryKey): CachedData | undefined {\n return this.#sharedQueryClient.getQueryData<CachedData>(queryKey);\n }\n\n /**\n * Set cached data for a query key.\n *\n * @param queryKey - The query key to set data for.\n * @param data - The data to cache.\n */\n setCachedData<CachedData>(queryKey: QueryKey, data: CachedData): void {\n this.#sharedQueryClient.setQueryData(queryKey, data);\n }\n\n /**\n * Check if a query is currently fetching.\n *\n * @param queryKey - The query key to check.\n * @returns True if the query is currently fetching.\n */\n isFetching(queryKey: QueryKey): boolean {\n return this.#sharedQueryClient.isFetching({ queryKey }) > 0;\n }\n\n /**\n * Clear all cached data across all sub-clients.\n */\n clear(): void {\n this.#sharedQueryClient.clear();\n }\n\n /**\n * Invalidate all queries across all sub-clients.\n */\n async invalidateAll(): Promise<void> {\n await this.#sharedQueryClient.invalidateQueries();\n }\n\n /**\n * Invalidate the cached auth token.\n * Call this when the user logs out or the token expires.\n *\n * Uses resetQueries() instead of invalidateQueries() to completely remove\n * the cached value, ensuring the next request fetches a fresh token immediately.\n */\n async invalidateAuthToken(): Promise<void> {\n await this.#sharedQueryClient.resetQueries({\n queryKey: authQueryKeys.bearerToken(),\n });\n }\n}\n\n/**\n * Factory function to create an ApiPlatformClient.\n *\n * @param options - Configuration options for the client.\n * @returns A new ApiPlatformClient instance.\n */\nexport function createApiPlatformClient(\n options: ApiPlatformClientOptions,\n): ApiPlatformClient {\n return new ApiPlatformClient(options);\n}\n"]}
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
* await client.prices.invalidatePrices(); // Domain-specific via sub-client
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
import { QueryClient } from
|
|
37
|
-
import type { QueryKey } from
|
|
38
|
-
import { AccountsApiClient } from
|
|
39
|
-
import { PricesApiClient } from
|
|
40
|
-
import type { ApiPlatformClientOptions } from
|
|
41
|
-
import { TokenApiClient } from
|
|
42
|
-
import { TokensApiClient } from
|
|
36
|
+
import { QueryClient } from "@tanstack/query-core";
|
|
37
|
+
import type { QueryKey } from "@tanstack/query-core";
|
|
38
|
+
import { AccountsApiClient } from "./accounts/index.cjs";
|
|
39
|
+
import { PricesApiClient } from "./prices/index.cjs";
|
|
40
|
+
import type { ApiPlatformClientOptions } from "./shared-types.cjs";
|
|
41
|
+
import { TokenApiClient } from "./token/index.cjs";
|
|
42
|
+
import { TokensApiClient } from "./tokens/index.cjs";
|
|
43
43
|
/**
|
|
44
44
|
* MetaMask API Platform Client with TanStack Query caching.
|
|
45
45
|
* Provides cached access to all MetaMask backend APIs through a unified interface.
|
|
@@ -124,4 +124,4 @@ export declare class ApiPlatformClient {
|
|
|
124
124
|
* @returns A new ApiPlatformClient instance.
|
|
125
125
|
*/
|
|
126
126
|
export declare function createApiPlatformClient(options: ApiPlatformClientOptions): ApiPlatformClient;
|
|
127
|
-
//# sourceMappingURL=ApiPlatformClient.d.
|
|
127
|
+
//# sourceMappingURL=ApiPlatformClient.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiPlatformClient.d.cts","sourceRoot":"","sources":["../../src/api/ApiPlatformClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,WAAW,EAAE,6BAA6B;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,6BAA6B;AAGrD,OAAO,EAAE,iBAAiB,EAAE,6BAA4B;AAExD,OAAO,EAAE,eAAe,EAAE,2BAA0B;AAOpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,2BAA0B;AAClE,OAAO,EAAE,cAAc,EAAE,0BAAyB;AAClD,OAAO,EAAE,eAAe,EAAE,2BAA0B;AAMpD;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAOrB,OAAO,EAAE,wBAAwB;IAiC7C;;;;OAIG;IACH,IAAI,WAAW,IAAI,WAAW,CAE7B;IAED;;;;;OAKG;IACH,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;IAIrE;;;;;OAKG;IACH,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAIrE;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAIvC;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAIpC;;;;;;OAMG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;CAK3C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,iBAAiB,CAEnB"}
|