@metamask-previews/core-backend 7.0.0-preview-d548cc9a9 → 7.0.0-preview-11d78534e
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/dist/ApiPlatformClientService-method-action-types.cjs.map +1 -1
- package/dist/ApiPlatformClientService-method-action-types.d.cts.map +1 -1
- package/dist/ApiPlatformClientService-method-action-types.d.mts.map +1 -1
- package/dist/ApiPlatformClientService-method-action-types.mjs.map +1 -1
- package/dist/ApiPlatformClientService.cjs +2 -2
- package/dist/ApiPlatformClientService.cjs.map +1 -1
- package/dist/ApiPlatformClientService.d.cts.map +1 -1
- package/dist/ApiPlatformClientService.d.mts.map +1 -1
- package/dist/ApiPlatformClientService.mjs.map +1 -1
- package/dist/api/ApiPlatformClient.cjs +15 -15
- package/dist/api/ApiPlatformClient.cjs.map +1 -1
- package/dist/api/ApiPlatformClient.d.cts.map +1 -1
- package/dist/api/ApiPlatformClient.d.mts.map +1 -1
- package/dist/api/ApiPlatformClient.mjs.map +1 -1
- package/dist/api/accounts/client.cjs +59 -59
- package/dist/api/accounts/client.cjs.map +1 -1
- package/dist/api/accounts/client.d.cts.map +1 -1
- package/dist/api/accounts/client.d.mts.map +1 -1
- package/dist/api/accounts/client.mjs.map +1 -1
- package/dist/api/accounts/index.cjs +4 -4
- package/dist/api/accounts/index.cjs.map +1 -1
- package/dist/api/accounts/index.d.cts.map +1 -1
- package/dist/api/accounts/index.d.mts.map +1 -1
- package/dist/api/accounts/index.mjs.map +1 -1
- package/dist/api/accounts/types.cjs.map +1 -1
- package/dist/api/accounts/types.d.cts.map +1 -1
- package/dist/api/accounts/types.d.mts.map +1 -1
- package/dist/api/accounts/types.mjs.map +1 -1
- package/dist/api/base-client.cjs +11 -11
- package/dist/api/base-client.cjs.map +1 -1
- package/dist/api/base-client.d.cts.map +1 -1
- package/dist/api/base-client.d.mts.map +1 -1
- package/dist/api/base-client.mjs.map +1 -1
- package/dist/api/index.cjs +23 -23
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts.map +1 -1
- package/dist/api/index.d.mts.map +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/prices/client.cjs +71 -71
- package/dist/api/prices/client.cjs.map +1 -1
- package/dist/api/prices/client.d.cts.map +1 -1
- package/dist/api/prices/client.d.mts.map +1 -1
- package/dist/api/prices/client.mjs.map +1 -1
- package/dist/api/prices/index.cjs +2 -2
- package/dist/api/prices/index.cjs.map +1 -1
- package/dist/api/prices/index.d.cts.map +1 -1
- package/dist/api/prices/index.d.mts.map +1 -1
- package/dist/api/prices/index.mjs.map +1 -1
- package/dist/api/test-utils.cjs +2 -2
- package/dist/api/test-utils.cjs.map +1 -1
- package/dist/api/test-utils.d.cts.map +1 -1
- package/dist/api/test-utils.d.mts.map +1 -1
- package/dist/api/test-utils.mjs.map +1 -1
- package/dist/api/token/client.cjs +43 -43
- package/dist/api/token/client.cjs.map +1 -1
- package/dist/api/token/client.d.cts.map +1 -1
- package/dist/api/token/client.d.mts.map +1 -1
- package/dist/api/token/client.mjs.map +1 -1
- package/dist/api/token/index.cjs +2 -2
- package/dist/api/token/index.cjs.map +1 -1
- package/dist/api/token/index.d.cts.map +1 -1
- package/dist/api/token/index.d.mts.map +1 -1
- package/dist/api/token/index.mjs.map +1 -1
- package/dist/api/tokens/client.cjs +15 -15
- package/dist/api/tokens/client.cjs.map +1 -1
- package/dist/api/tokens/client.d.cts.map +1 -1
- package/dist/api/tokens/client.d.mts.map +1 -1
- package/dist/api/tokens/client.mjs.map +1 -1
- package/dist/api/tokens/index.cjs +2 -2
- package/dist/api/tokens/index.cjs.map +1 -1
- package/dist/api/tokens/index.d.cts.map +1 -1
- package/dist/api/tokens/index.d.mts.map +1 -1
- package/dist/api/tokens/index.mjs.map +1 -1
- package/dist/index.cjs +31 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/ws/AccountActivityService.cjs +6 -6
- package/dist/ws/AccountActivityService.cjs.map +1 -1
- package/dist/ws/AccountActivityService.d.cts +1 -1
- package/dist/ws/AccountActivityService.d.cts.map +1 -1
- package/dist/ws/AccountActivityService.d.mts +1 -1
- package/dist/ws/AccountActivityService.d.mts.map +1 -1
- package/dist/ws/AccountActivityService.mjs.map +1 -1
- package/dist/ws/BackendWebSocketService-method-action-types.cjs.map +1 -1
- package/dist/ws/BackendWebSocketService-method-action-types.d.cts.map +1 -1
- package/dist/ws/BackendWebSocketService-method-action-types.d.mts.map +1 -1
- package/dist/ws/BackendWebSocketService-method-action-types.mjs.map +1 -1
- package/dist/ws/BackendWebSocketService.cjs +2 -2
- package/dist/ws/BackendWebSocketService.cjs.map +1 -1
- package/dist/ws/BackendWebSocketService.d.cts.map +1 -1
- package/dist/ws/BackendWebSocketService.d.mts.map +1 -1
- package/dist/ws/BackendWebSocketService.mjs.map +1 -1
- package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs.map +1 -1
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.cts.map +1 -1
- package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts.map +1 -1
- package/dist/ws/ohlcv/OHLCVService-method-action-types.mjs.map +1 -1
- package/dist/ws/ohlcv/OHLCVService.cjs +5 -5
- package/dist/ws/ohlcv/OHLCVService.cjs.map +1 -1
- package/dist/ws/ohlcv/OHLCVService.d.cts +1 -1
- package/dist/ws/ohlcv/OHLCVService.d.cts.map +1 -1
- package/dist/ws/ohlcv/OHLCVService.d.mts +1 -1
- package/dist/ws/ohlcv/OHLCVService.d.mts.map +1 -1
- package/dist/ws/ohlcv/OHLCVService.mjs.map +1 -1
- package/dist/ws/ohlcv/index.cjs +5 -5
- package/dist/ws/ohlcv/index.cjs.map +1 -1
- package/dist/ws/ohlcv/index.d.cts.map +1 -1
- package/dist/ws/ohlcv/index.d.mts.map +1 -1
- package/dist/ws/ohlcv/index.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -1 +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';\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"]}
|
|
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"]}
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1 +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';\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"]}
|
|
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"]}
|
|
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _ApiPlatformClientService_messenger, _ApiPlatformClientService_client;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ApiPlatformClientService = exports.apiPlatformClientServiceName = void 0;
|
|
16
|
-
const
|
|
16
|
+
const index_js_1 = require("./api/index.cjs");
|
|
17
17
|
// === GENERAL ===
|
|
18
18
|
/**
|
|
19
19
|
* The name of the {@link ApiPlatformClientService}, used to namespace the
|
|
@@ -63,7 +63,7 @@ class ApiPlatformClientService {
|
|
|
63
63
|
_ApiPlatformClientService_client.set(this, void 0);
|
|
64
64
|
this.name = exports.apiPlatformClientServiceName;
|
|
65
65
|
__classPrivateFieldSet(this, _ApiPlatformClientService_messenger, messenger, "f");
|
|
66
|
-
__classPrivateFieldSet(this, _ApiPlatformClientService_client, new
|
|
66
|
+
__classPrivateFieldSet(this, _ApiPlatformClientService_client, new index_js_1.ApiPlatformClient(clientOptions), "f");
|
|
67
67
|
__classPrivateFieldGet(this, _ApiPlatformClientService_messenger, "f").registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiPlatformClientService.cjs","sourceRoot":"","sources":["../src/ApiPlatformClientService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,
|
|
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 +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,
|
|
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"}
|
|
@@ -1 +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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiPlatformClientService.mjs","sourceRoot":"","sources":["../src/ApiPlatformClientService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,OAAO,EAAE,iBAAiB,EAAE,
|
|
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"]}
|
|
@@ -50,12 +50,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.createApiPlatformClient = exports.ApiPlatformClient = void 0;
|
|
51
51
|
const query_core_1 = require("@tanstack/query-core");
|
|
52
52
|
// Import API clients from subfolders
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
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
59
|
// ============================================================================
|
|
60
60
|
// UNIFIED API CLIENT
|
|
61
61
|
// ============================================================================
|
|
@@ -80,10 +80,10 @@ class ApiPlatformClient {
|
|
|
80
80
|
new query_core_1.QueryClient({
|
|
81
81
|
defaultOptions: {
|
|
82
82
|
queries: {
|
|
83
|
-
staleTime:
|
|
84
|
-
gcTime:
|
|
85
|
-
retry:
|
|
86
|
-
retryDelay:
|
|
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
87
|
refetchOnWindowFocus: false,
|
|
88
88
|
networkMode: 'always',
|
|
89
89
|
},
|
|
@@ -94,10 +94,10 @@ class ApiPlatformClient {
|
|
|
94
94
|
...options,
|
|
95
95
|
queryClient: __classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f"),
|
|
96
96
|
};
|
|
97
|
-
this.accounts = new
|
|
98
|
-
this.prices = new
|
|
99
|
-
this.token = new
|
|
100
|
-
this.tokens = new
|
|
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
101
|
}
|
|
102
102
|
// ==========================================================================
|
|
103
103
|
// CACHE MANAGEMENT (operates on shared QueryClient)
|
|
@@ -158,7 +158,7 @@ class ApiPlatformClient {
|
|
|
158
158
|
*/
|
|
159
159
|
async invalidateAuthToken() {
|
|
160
160
|
await __classPrivateFieldGet(this, _ApiPlatformClient_sharedQueryClient, "f").resetQueries({
|
|
161
|
-
queryKey:
|
|
161
|
+
queryKey: base_client_js_1.authQueryKeys.bearerToken(),
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiPlatformClient.cjs","sourceRoot":"","sources":["../../src/api/ApiPlatformClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;;;;;;;;;;;;;AAEH,qDAAmD;AAGnD,qCAAqC;AACrC,
|
|
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"]}
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiPlatformClient.d.mts","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,
|
|
1
|
+
{"version":3,"file":"ApiPlatformClient.d.mts","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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiPlatformClient.mjs","sourceRoot":"","sources":["../../src/api/ApiPlatformClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;;;;;;;;;;;AAEH,OAAO,EAAE,WAAW,EAAE,6BAA6B;AAGnD,qCAAqC;AACrC,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"ApiPlatformClient.mjs","sourceRoot":"","sources":["../../src/api/ApiPlatformClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;;;;;;;;;;;AAEH,OAAO,EAAE,WAAW,EAAE,6BAA6B;AAGnD,qCAAqC;AACrC,OAAO,EAAE,iBAAiB,EAAE,6BAA4B;AACxD,OAAO,EAAE,aAAa,EAAE,0BAAyB;AACjD,OAAO,EAAE,eAAe,EAAE,2BAA0B;AACpD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,WAAW,EACX,mBAAmB,EACpB,2BAA0B;AAE3B,OAAO,EAAE,cAAc,EAAE,0BAAyB;AAClD,OAAO,EAAE,eAAe,EAAE,2BAA0B;AAEpD,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,OAAO,iBAAiB;IA8B5B,YAAY,OAAiC;QAL7C;;WAEG;QACM,uDAAgC;QAGvC,iEAAiE;QACjE,uBAAA,IAAI,wCACF,OAAO,CAAC,WAAW;YACnB,IAAI,WAAW,CAAC;gBACd,cAAc,EAAE;oBACd,OAAO,EAAE;wBACP,SAAS,EAAE,WAAW,CAAC,OAAO;wBAC9B,MAAM,EAAE,QAAQ,CAAC,OAAO;wBACxB,KAAK,EAAE,WAAW;wBAClB,UAAU,EAAE,mBAAmB;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,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAI,cAAc,CAAC,aAAa,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,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,aAAa,CAAC,WAAW,EAAE;SACtC,CAAC,CAAC;IACL,CAAC;CACF;;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAiC;IAEjC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC","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"]}
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AccountsApiClient = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const base_client_js_1 = require("../base-client.cjs");
|
|
17
|
+
const shared_types_js_1 = require("../shared-types.cjs");
|
|
18
18
|
/**
|
|
19
19
|
* Accounts API Client.
|
|
20
20
|
* Provides methods for interacting with the Accounts API.
|
|
21
21
|
*/
|
|
22
|
-
class AccountsApiClient extends
|
|
22
|
+
class AccountsApiClient extends base_client_js_1.BaseApiClient {
|
|
23
23
|
// ==========================================================================
|
|
24
24
|
// CACHE MANAGEMENT
|
|
25
25
|
// ==========================================================================
|
|
@@ -51,10 +51,10 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
51
51
|
getV1SupportedNetworksQueryOptions(options) {
|
|
52
52
|
return {
|
|
53
53
|
queryKey: ['accounts', 'v1SupportedNetworks'],
|
|
54
|
-
queryFn: ({ signal }) => this.fetch(
|
|
55
|
-
...(0,
|
|
56
|
-
staleTime: options?.staleTime ??
|
|
57
|
-
gcTime: options?.gcTime ??
|
|
54
|
+
queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.ACCOUNTS, '/v1/supportedNetworks', { signal }),
|
|
55
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
56
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.SUPPORTED_NETWORKS,
|
|
57
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.EXTENDED,
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
@@ -75,10 +75,10 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
75
75
|
getV2SupportedNetworksQueryOptions(options) {
|
|
76
76
|
return {
|
|
77
77
|
queryKey: ['accounts', 'v2SupportedNetworks'],
|
|
78
|
-
queryFn: ({ signal }) => this.fetch(
|
|
79
|
-
...(0,
|
|
80
|
-
staleTime: options?.staleTime ??
|
|
81
|
-
gcTime: options?.gcTime ??
|
|
78
|
+
queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.ACCOUNTS, '/v2/supportedNetworks', { signal }),
|
|
79
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
80
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.SUPPORTED_NETWORKS,
|
|
81
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.EXTENDED,
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -120,7 +120,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
120
120
|
if (accountIds.length === 0) {
|
|
121
121
|
return { activeNetworks: [] };
|
|
122
122
|
}
|
|
123
|
-
return this.fetch(
|
|
123
|
+
return this.fetch(base_client_js_1.API_URLS.ACCOUNTS, '/v2/activeNetworks', {
|
|
124
124
|
signal,
|
|
125
125
|
params: {
|
|
126
126
|
accountIds,
|
|
@@ -129,9 +129,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
129
129
|
},
|
|
130
130
|
});
|
|
131
131
|
},
|
|
132
|
-
...(0,
|
|
133
|
-
staleTime: options?.staleTime ??
|
|
134
|
-
gcTime: options?.gcTime ??
|
|
132
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
133
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.NETWORKS,
|
|
134
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
@@ -185,7 +185,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
185
185
|
if (address === '') {
|
|
186
186
|
return { count: 0, balances: [], unprocessedNetworks: [] };
|
|
187
187
|
}
|
|
188
|
-
return this.fetch(
|
|
188
|
+
return this.fetch(base_client_js_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/balances`, {
|
|
189
189
|
signal,
|
|
190
190
|
params: {
|
|
191
191
|
networks: queryOptions?.networks,
|
|
@@ -195,9 +195,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
195
195
|
},
|
|
196
196
|
});
|
|
197
197
|
},
|
|
198
|
-
...(0,
|
|
199
|
-
staleTime: options?.staleTime ??
|
|
200
|
-
gcTime: options?.gcTime ??
|
|
198
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
199
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.BALANCES,
|
|
200
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
@@ -245,7 +245,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
245
245
|
if (accountAddresses.length === 0) {
|
|
246
246
|
return { count: 0, balances: [], unprocessedNetworks: [] };
|
|
247
247
|
}
|
|
248
|
-
return this.fetch(
|
|
248
|
+
return this.fetch(base_client_js_1.API_URLS.ACCOUNTS, '/v4/multiaccount/balances', {
|
|
249
249
|
signal,
|
|
250
250
|
params: {
|
|
251
251
|
accountAddresses,
|
|
@@ -253,9 +253,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
253
253
|
},
|
|
254
254
|
});
|
|
255
255
|
},
|
|
256
|
-
...(0,
|
|
257
|
-
staleTime: options?.staleTime ??
|
|
258
|
-
gcTime: options?.gcTime ??
|
|
256
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
257
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.BALANCES,
|
|
258
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
/**
|
|
@@ -302,7 +302,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
302
302
|
if (accountIds.length === 0) {
|
|
303
303
|
return { count: 0, unprocessedNetworks: [], balances: [] };
|
|
304
304
|
}
|
|
305
|
-
return this.fetch(
|
|
305
|
+
return this.fetch(base_client_js_1.API_URLS.ACCOUNTS, '/v5/multiaccount/balances', {
|
|
306
306
|
signal,
|
|
307
307
|
params: {
|
|
308
308
|
accountIds,
|
|
@@ -312,9 +312,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
312
312
|
},
|
|
313
313
|
});
|
|
314
314
|
},
|
|
315
|
-
...(0,
|
|
316
|
-
staleTime: options?.staleTime ??
|
|
317
|
-
gcTime: options?.gcTime ??
|
|
315
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
316
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.BALANCES,
|
|
317
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
@@ -382,7 +382,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
382
382
|
accounts: [],
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
return this.fetch(
|
|
385
|
+
return this.fetch(base_client_js_1.API_URLS.ACCOUNTS, '/v6/multiaccount/balances', {
|
|
386
386
|
signal,
|
|
387
387
|
params: {
|
|
388
388
|
accountIds,
|
|
@@ -401,9 +401,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
401
401
|
},
|
|
402
402
|
});
|
|
403
403
|
},
|
|
404
|
-
...(0,
|
|
405
|
-
staleTime: options?.staleTime ??
|
|
406
|
-
gcTime: options?.gcTime ??
|
|
404
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
405
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.BALANCES,
|
|
406
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
409
|
/**
|
|
@@ -461,7 +461,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
461
461
|
'v1ByHash',
|
|
462
462
|
{ chainId, txHash, options: queryOptions },
|
|
463
463
|
],
|
|
464
|
-
queryFn: ({ signal }) => this.fetch(
|
|
464
|
+
queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.ACCOUNTS, `/v1/networks/${chainId}/transactions/${txHash}`, {
|
|
465
465
|
signal,
|
|
466
466
|
params: {
|
|
467
467
|
includeLogs: queryOptions?.includeLogs,
|
|
@@ -470,9 +470,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
470
470
|
lang: queryOptions?.lang,
|
|
471
471
|
},
|
|
472
472
|
}),
|
|
473
|
-
...(0,
|
|
474
|
-
staleTime: options?.staleTime ??
|
|
475
|
-
gcTime: options?.gcTime ??
|
|
473
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
474
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.TRANSACTIONS,
|
|
475
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
476
476
|
};
|
|
477
477
|
}
|
|
478
478
|
/**
|
|
@@ -522,7 +522,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
522
522
|
if (address === '') {
|
|
523
523
|
return { data: [], pageInfo: { count: 0, hasNextPage: false } };
|
|
524
524
|
}
|
|
525
|
-
return this.fetch(
|
|
525
|
+
return this.fetch(base_client_js_1.API_URLS.ACCOUNTS, `/v1/accounts/${address}/transactions`, {
|
|
526
526
|
signal,
|
|
527
527
|
params: {
|
|
528
528
|
networks: queryOptions?.chainIds,
|
|
@@ -533,9 +533,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
533
533
|
},
|
|
534
534
|
});
|
|
535
535
|
},
|
|
536
|
-
...(0,
|
|
537
|
-
staleTime: options?.staleTime ??
|
|
538
|
-
gcTime: options?.gcTime ??
|
|
536
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
537
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.TRANSACTIONS,
|
|
538
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
539
539
|
};
|
|
540
540
|
}
|
|
541
541
|
/**
|
|
@@ -593,7 +593,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
593
593
|
},
|
|
594
594
|
},
|
|
595
595
|
],
|
|
596
|
-
queryFn: ({ signal }) => this.fetch(
|
|
596
|
+
queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.ACCOUNTS, '/v4/multiaccount/transactions', {
|
|
597
597
|
signal,
|
|
598
598
|
params: {
|
|
599
599
|
accountAddresses,
|
|
@@ -611,9 +611,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
611
611
|
lang: queryOptions?.lang,
|
|
612
612
|
},
|
|
613
613
|
}),
|
|
614
|
-
...(0,
|
|
615
|
-
staleTime: options?.staleTime ??
|
|
616
|
-
gcTime: options?.gcTime ??
|
|
614
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
615
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.TRANSACTIONS,
|
|
616
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
617
617
|
};
|
|
618
618
|
}
|
|
619
619
|
/**
|
|
@@ -653,7 +653,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
653
653
|
lang: params.lang,
|
|
654
654
|
},
|
|
655
655
|
],
|
|
656
|
-
queryFn: ({ pageParam, signal, }) => this.fetch(
|
|
656
|
+
queryFn: ({ pageParam, signal, }) => this.fetch(base_client_js_1.API_URLS.ACCOUNTS, '/v4/multiaccount/transactions', {
|
|
657
657
|
signal,
|
|
658
658
|
params: {
|
|
659
659
|
accountAddresses: params.accountAddresses,
|
|
@@ -671,9 +671,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
671
671
|
}),
|
|
672
672
|
getNextPageParam: ({ pageInfo }) => pageInfo.hasNextPage ? pageInfo.endCursor : undefined,
|
|
673
673
|
initialPageParam: options?.initialPageParam,
|
|
674
|
-
...(0,
|
|
675
|
-
staleTime: options?.staleTime ??
|
|
676
|
-
gcTime: options?.gcTime ??
|
|
674
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
675
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.TRANSACTIONS,
|
|
676
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
677
677
|
};
|
|
678
678
|
}
|
|
679
679
|
/**
|
|
@@ -714,10 +714,10 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
714
714
|
getV1AccountRelationshipQueryOptions(chainId, from, to, options) {
|
|
715
715
|
return {
|
|
716
716
|
queryKey: ['accounts', 'v1Relationship', chainId, from, to],
|
|
717
|
-
queryFn: async ({ signal, }) => this.fetch(
|
|
718
|
-
...(0,
|
|
719
|
-
staleTime: options?.staleTime ??
|
|
720
|
-
gcTime: options?.gcTime ??
|
|
717
|
+
queryFn: async ({ signal, }) => this.fetch(base_client_js_1.API_URLS.ACCOUNTS, `/v1/networks/${chainId}/accounts/${from}/relationships/${to}`, { signal }),
|
|
718
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
719
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.DEFAULT,
|
|
720
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
721
721
|
};
|
|
722
722
|
}
|
|
723
723
|
/**
|
|
@@ -762,7 +762,7 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
762
762
|
if (address === '') {
|
|
763
763
|
return { data: [], pageInfo: { count: 0, hasNextPage: false } };
|
|
764
764
|
}
|
|
765
|
-
return this.fetch(
|
|
765
|
+
return this.fetch(base_client_js_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/nfts`, {
|
|
766
766
|
signal,
|
|
767
767
|
params: {
|
|
768
768
|
networks: queryOptions?.networks,
|
|
@@ -770,9 +770,9 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
770
770
|
},
|
|
771
771
|
});
|
|
772
772
|
},
|
|
773
|
-
...(0,
|
|
774
|
-
staleTime: options?.staleTime ??
|
|
775
|
-
gcTime: options?.gcTime ??
|
|
773
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
774
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.DEFAULT,
|
|
775
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
776
776
|
};
|
|
777
777
|
}
|
|
778
778
|
/**
|
|
@@ -820,14 +820,14 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
|
|
|
820
820
|
if (address === '') {
|
|
821
821
|
return { data: [] };
|
|
822
822
|
}
|
|
823
|
-
return this.fetch(
|
|
823
|
+
return this.fetch(base_client_js_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/tokens`, {
|
|
824
824
|
signal,
|
|
825
825
|
params: { networks: queryOptions?.networks },
|
|
826
826
|
});
|
|
827
827
|
},
|
|
828
|
-
...(0,
|
|
829
|
-
staleTime: options?.staleTime ??
|
|
830
|
-
gcTime: options?.gcTime ??
|
|
828
|
+
...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
|
|
829
|
+
staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.DEFAULT,
|
|
830
|
+
gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
|
|
831
831
|
};
|
|
832
832
|
}
|
|
833
833
|
/**
|