@metamask-previews/core-backend 5.1.1-preview-e7b1aa6 → 5.1.1-preview-27e39dd44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +0 -23
  2. package/README.md +55 -60
  3. package/dist/api/accounts/client.cjs +163 -358
  4. package/dist/api/accounts/client.cjs.map +1 -1
  5. package/dist/api/accounts/client.d.cts +12 -198
  6. package/dist/api/accounts/client.d.cts.map +1 -1
  7. package/dist/api/accounts/client.d.mts +12 -198
  8. package/dist/api/accounts/client.d.mts.map +1 -1
  9. package/dist/api/accounts/client.mjs +164 -359
  10. package/dist/api/accounts/client.mjs.map +1 -1
  11. package/dist/api/index.cjs +1 -2
  12. package/dist/api/index.cjs.map +1 -1
  13. package/dist/api/index.d.cts +1 -1
  14. package/dist/api/index.d.cts.map +1 -1
  15. package/dist/api/index.d.mts +1 -1
  16. package/dist/api/index.d.mts.map +1 -1
  17. package/dist/api/index.mjs +1 -1
  18. package/dist/api/index.mjs.map +1 -1
  19. package/dist/api/prices/client.cjs +140 -398
  20. package/dist/api/prices/client.cjs.map +1 -1
  21. package/dist/api/prices/client.d.cts +3 -215
  22. package/dist/api/prices/client.d.cts.map +1 -1
  23. package/dist/api/prices/client.d.mts +3 -215
  24. package/dist/api/prices/client.d.mts.map +1 -1
  25. package/dist/api/prices/client.mjs +140 -398
  26. package/dist/api/prices/client.mjs.map +1 -1
  27. package/dist/api/shared-types.cjs +1 -18
  28. package/dist/api/shared-types.cjs.map +1 -1
  29. package/dist/api/shared-types.d.cts +3 -23
  30. package/dist/api/shared-types.d.cts.map +1 -1
  31. package/dist/api/shared-types.d.mts +3 -23
  32. package/dist/api/shared-types.d.mts.map +1 -1
  33. package/dist/api/shared-types.mjs +0 -16
  34. package/dist/api/shared-types.mjs.map +1 -1
  35. package/dist/api/token/client.cjs +77 -232
  36. package/dist/api/token/client.cjs.map +1 -1
  37. package/dist/api/token/client.d.cts +0 -165
  38. package/dist/api/token/client.d.cts.map +1 -1
  39. package/dist/api/token/client.d.mts +0 -165
  40. package/dist/api/token/client.d.mts.map +1 -1
  41. package/dist/api/token/client.mjs +77 -232
  42. package/dist/api/token/client.mjs.map +1 -1
  43. package/dist/api/tokens/client.cjs +23 -64
  44. package/dist/api/tokens/client.cjs.map +1 -1
  45. package/dist/api/tokens/client.d.cts +0 -24
  46. package/dist/api/tokens/client.d.cts.map +1 -1
  47. package/dist/api/tokens/client.d.mts +0 -24
  48. package/dist/api/tokens/client.d.mts.map +1 -1
  49. package/dist/api/tokens/client.mjs +23 -64
  50. package/dist/api/tokens/client.mjs.map +1 -1
  51. package/dist/index.cjs +1 -8
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.d.cts +1 -3
  54. package/dist/index.d.cts.map +1 -1
  55. package/dist/index.d.mts +1 -3
  56. package/dist/index.d.mts.map +1 -1
  57. package/dist/index.mjs +1 -5
  58. package/dist/index.mjs.map +1 -1
  59. package/package.json +2 -1
  60. package/dist/ApiPlatformClientService-method-action-types.cjs +0 -7
  61. package/dist/ApiPlatformClientService-method-action-types.cjs.map +0 -1
  62. package/dist/ApiPlatformClientService-method-action-types.d.cts +0 -21
  63. package/dist/ApiPlatformClientService-method-action-types.d.cts.map +0 -1
  64. package/dist/ApiPlatformClientService-method-action-types.d.mts +0 -21
  65. package/dist/ApiPlatformClientService-method-action-types.d.mts.map +0 -1
  66. package/dist/ApiPlatformClientService-method-action-types.mjs +0 -6
  67. package/dist/ApiPlatformClientService-method-action-types.mjs.map +0 -1
  68. package/dist/ApiPlatformClientService.cjs +0 -82
  69. package/dist/ApiPlatformClientService.cjs.map +0 -1
  70. package/dist/ApiPlatformClientService.d.cts +0 -86
  71. package/dist/ApiPlatformClientService.d.cts.map +0 -1
  72. package/dist/ApiPlatformClientService.d.mts +0 -86
  73. package/dist/ApiPlatformClientService.d.mts.map +0 -1
  74. package/dist/ApiPlatformClientService.mjs +0 -78
  75. package/dist/ApiPlatformClientService.mjs.map +0 -1
@@ -12,7 +12,6 @@
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.PricesApiClient = void 0;
14
14
  const base_client_1 = require("../base-client.cjs");
15
- const shared_types_1 = require("../shared-types.cjs");
16
15
  /**
17
16
  * Prices API Client.
18
17
  * Provides methods for interacting with the Price API.
@@ -33,80 +32,36 @@ class PricesApiClient extends base_client_1.BaseApiClient {
33
32
  // SUPPORTED NETWORKS
34
33
  // ==========================================================================
35
34
  /**
36
- * Returns the TanStack Query options object for price v1 supported networks.
35
+ * Get price supported networks (v1 endpoint).
37
36
  *
38
37
  * @param options - Fetch options including cache settings.
39
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
38
+ * @returns The supported networks response.
40
39
  */
41
- getPriceV1SupportedNetworksQueryOptions(options) {
42
- return {
40
+ async fetchPriceV1SupportedNetworks(options) {
41
+ return this.queryClient.fetchQuery({
43
42
  queryKey: ['prices', 'v1SupportedNetworks'],
44
43
  queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/supportedNetworks', { signal }),
45
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
46
44
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.SUPPORTED_NETWORKS,
47
45
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.EXTENDED,
48
- };
46
+ });
49
47
  }
50
48
  /**
51
- * Get price supported networks (v1 endpoint).
49
+ * Get price supported networks in CAIP format (v2 endpoint).
52
50
  *
53
51
  * @param options - Fetch options including cache settings.
54
52
  * @returns The supported networks response.
55
53
  */
56
- async fetchPriceV1SupportedNetworks(options) {
57
- return this.queryClient.fetchQuery(this.getPriceV1SupportedNetworksQueryOptions(options));
58
- }
59
- /**
60
- * Returns the TanStack Query options object for price v2 supported networks.
61
- *
62
- * @param options - Fetch options including cache settings.
63
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
64
- */
65
- getPriceV2SupportedNetworksQueryOptions(options) {
66
- return {
54
+ async fetchPriceV2SupportedNetworks(options) {
55
+ return this.queryClient.fetchQuery({
67
56
  queryKey: ['prices', 'v2SupportedNetworks'],
68
57
  queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v2/supportedNetworks', { signal }),
69
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
70
58
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.SUPPORTED_NETWORKS,
71
59
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.EXTENDED,
72
- };
73
- }
74
- /**
75
- * Get price supported networks in CAIP format (v2 endpoint).
76
- *
77
- * @param options - Fetch options including cache settings.
78
- * @returns The supported networks response.
79
- */
80
- async fetchPriceV2SupportedNetworks(options) {
81
- return this.queryClient.fetchQuery(this.getPriceV2SupportedNetworksQueryOptions(options));
60
+ });
82
61
  }
83
62
  // ==========================================================================
84
63
  // EXCHANGE RATES
85
64
  // ==========================================================================
86
- /**
87
- * Returns the TanStack Query options object for v1 exchange rates.
88
- *
89
- * @param baseCurrency - The base currency code.
90
- * @param options - Fetch options including cache settings.
91
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
92
- */
93
- getV1ExchangeRatesQueryOptions(baseCurrency, options) {
94
- return {
95
- queryKey: ['prices', 'v1ExchangeRates', baseCurrency],
96
- queryFn: async ({ signal, }) => {
97
- if (baseCurrency === '') {
98
- return {};
99
- }
100
- return this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates', {
101
- signal,
102
- params: { baseCurrency },
103
- });
104
- },
105
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
106
- staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.EXCHANGE_RATES,
107
- gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
108
- };
109
- }
110
65
  /**
111
66
  * Get all exchange rates for a base currency (v1 endpoint).
112
67
  *
@@ -115,25 +70,15 @@ class PricesApiClient extends base_client_1.BaseApiClient {
115
70
  * @returns The exchange rates response.
116
71
  */
117
72
  async fetchV1ExchangeRates(baseCurrency, options) {
118
- if (baseCurrency === '') {
119
- return {};
120
- }
121
- return this.queryClient.fetchQuery(this.getV1ExchangeRatesQueryOptions(baseCurrency, options));
122
- }
123
- /**
124
- * Returns the TanStack Query options object for v1 fiat exchange rates.
125
- *
126
- * @param options - Fetch options including cache settings.
127
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
128
- */
129
- getV1FiatExchangeRatesQueryOptions(options) {
130
- return {
131
- queryKey: ['prices', 'v1FiatExchangeRates'],
132
- queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates/fiat', { signal }),
133
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
73
+ return this.queryClient.fetchQuery({
74
+ queryKey: ['prices', 'v1ExchangeRates', baseCurrency],
75
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates', {
76
+ signal,
77
+ params: { baseCurrency },
78
+ }),
134
79
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.EXCHANGE_RATES,
135
80
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
136
- };
81
+ });
137
82
  }
138
83
  /**
139
84
  * Get fiat exchange rates (v1 endpoint).
@@ -142,22 +87,12 @@ class PricesApiClient extends base_client_1.BaseApiClient {
142
87
  * @returns The exchange rates response.
143
88
  */
144
89
  async fetchV1FiatExchangeRates(options) {
145
- return this.queryClient.fetchQuery(this.getV1FiatExchangeRatesQueryOptions(options));
146
- }
147
- /**
148
- * Returns the TanStack Query options object for v1 crypto exchange rates.
149
- *
150
- * @param options - Fetch options including cache settings.
151
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
152
- */
153
- getV1CryptoExchangeRatesQueryOptions(options) {
154
- return {
155
- queryKey: ['prices', 'v1CryptoExchangeRates'],
156
- queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates/crypto', { signal }),
157
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
90
+ return this.queryClient.fetchQuery({
91
+ queryKey: ['prices', 'v1FiatExchangeRates'],
92
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates/fiat', { signal }),
158
93
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.EXCHANGE_RATES,
159
94
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
160
- };
95
+ });
161
96
  }
162
97
  /**
163
98
  * Get crypto exchange rates (v1 endpoint).
@@ -166,39 +101,16 @@ class PricesApiClient extends base_client_1.BaseApiClient {
166
101
  * @returns The exchange rates response.
167
102
  */
168
103
  async fetchV1CryptoExchangeRates(options) {
169
- return this.queryClient.fetchQuery(this.getV1CryptoExchangeRatesQueryOptions(options));
104
+ return this.queryClient.fetchQuery({
105
+ queryKey: ['prices', 'v1CryptoExchangeRates'],
106
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates/crypto', { signal }),
107
+ staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.EXCHANGE_RATES,
108
+ gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
109
+ });
170
110
  }
171
111
  // ==========================================================================
172
112
  // V1 SPOT PRICES (CoinGecko ID based)
173
113
  // ==========================================================================
174
- /**
175
- * Returns the TanStack Query options object for v1 spot prices by coin IDs.
176
- *
177
- * @param coinIds - Array of CoinGecko coin IDs.
178
- * @param options - Fetch options including cache settings.
179
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
180
- */
181
- getV1SpotPricesByCoinIdsQueryOptions(coinIds, options) {
182
- return {
183
- queryKey: [
184
- 'prices',
185
- 'v1SpotPricesByCoinIds',
186
- { coinIds: [...coinIds].sort() },
187
- ],
188
- queryFn: async ({ signal, }) => {
189
- if (coinIds.length === 0) {
190
- return {};
191
- }
192
- return this.fetch(base_client_1.API_URLS.PRICES, '/v1/spot-prices', {
193
- signal,
194
- params: { coinIds },
195
- });
196
- },
197
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
198
- staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
199
- gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
200
- };
201
- }
202
114
  /**
203
115
  * Get spot prices by CoinGecko coin IDs (v1 endpoint).
204
116
  *
@@ -210,32 +122,19 @@ class PricesApiClient extends base_client_1.BaseApiClient {
210
122
  if (coinIds.length === 0) {
211
123
  return {};
212
124
  }
213
- return this.queryClient.fetchQuery(this.getV1SpotPricesByCoinIdsQueryOptions(coinIds, options));
214
- }
215
- /**
216
- * Returns the TanStack Query options object for v1 spot price by coin ID.
217
- *
218
- * @param coinId - The CoinGecko coin ID.
219
- * @param currency - The currency for prices.
220
- * @param options - Fetch options including cache settings.
221
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
222
- */
223
- getV1SpotPriceByCoinIdQueryOptions(coinId, currency = 'usd', options) {
224
- return {
225
- queryKey: ['prices', 'v1SpotPriceByCoinId', coinId, currency],
226
- queryFn: async ({ signal, }) => {
227
- if (coinId === '') {
228
- return { id: '', price: 0 };
229
- }
230
- return this.fetch(base_client_1.API_URLS.PRICES, `/v1/spot-prices/${coinId}`, {
231
- signal,
232
- params: { vsCurrency: currency },
233
- });
234
- },
235
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
125
+ return this.queryClient.fetchQuery({
126
+ queryKey: [
127
+ 'prices',
128
+ 'v1SpotPricesByCoinIds',
129
+ { coinIds: [...coinIds].sort() },
130
+ ],
131
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/spot-prices', {
132
+ signal,
133
+ params: { coinIds },
134
+ }),
236
135
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
237
136
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
238
- };
137
+ });
239
138
  }
240
139
  /**
241
140
  * Get spot price for a single CoinGecko coin ID (v1 endpoint).
@@ -246,13 +145,21 @@ class PricesApiClient extends base_client_1.BaseApiClient {
246
145
  * @returns The spot price data.
247
146
  */
248
147
  async fetchV1SpotPriceByCoinId(coinId, currency = 'usd', options) {
249
- return this.queryClient.fetchQuery(this.getV1SpotPriceByCoinIdQueryOptions(coinId, currency, options));
148
+ return this.queryClient.fetchQuery({
149
+ queryKey: ['prices', 'v1SpotPriceByCoinId', coinId, currency],
150
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/spot-prices/${coinId}`, {
151
+ signal,
152
+ params: { vsCurrency: currency },
153
+ }),
154
+ staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
155
+ gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
156
+ });
250
157
  }
251
158
  // ==========================================================================
252
159
  // V1 SPOT PRICES (Token Address based)
253
160
  // ==========================================================================
254
161
  /**
255
- * Returns the TanStack Query options object for v1 token prices.
162
+ * Get spot prices for tokens on a chain (v1 endpoint).
256
163
  *
257
164
  * @param chainId - The chain ID (hex format).
258
165
  * @param tokenAddresses - Array of token addresses.
@@ -260,12 +167,15 @@ class PricesApiClient extends base_client_1.BaseApiClient {
260
167
  * @param queryOptions.currency - The currency for prices.
261
168
  * @param queryOptions.includeMarketData - Whether to include market data.
262
169
  * @param options - Fetch options including cache settings.
263
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
170
+ * @returns The token prices by address.
264
171
  */
265
- getV1TokenPricesQueryOptions(chainId, tokenAddresses, queryOptions, options) {
172
+ async fetchV1TokenPrices(chainId, tokenAddresses, queryOptions, options) {
173
+ if (tokenAddresses.length === 0) {
174
+ return {};
175
+ }
266
176
  const chainIdDecimal = parseInt(chainId, 16);
267
177
  const currency = queryOptions?.currency ?? 'usd';
268
- return {
178
+ return this.queryClient.fetchQuery({
269
179
  queryKey: [
270
180
  'prices',
271
181
  'v1TokenPrices',
@@ -276,82 +186,49 @@ class PricesApiClient extends base_client_1.BaseApiClient {
276
186
  includeMarketData: queryOptions?.includeMarketData,
277
187
  },
278
188
  ],
279
- queryFn: async ({ signal, }) => {
280
- if (chainId === '' || tokenAddresses.length === 0) {
281
- return {};
282
- }
283
- return this.fetch(base_client_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/spot-prices`, {
284
- signal,
285
- params: {
286
- tokenAddresses,
287
- vsCurrency: currency,
288
- includeMarketData: queryOptions?.includeMarketData,
289
- },
290
- });
291
- },
292
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
189
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/spot-prices`, {
190
+ signal,
191
+ params: {
192
+ tokenAddresses,
193
+ vsCurrency: currency,
194
+ includeMarketData: queryOptions?.includeMarketData,
195
+ },
196
+ }),
293
197
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
294
198
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
295
- };
296
- }
297
- /**
298
- * Get spot prices for tokens on a chain (v1 endpoint).
299
- *
300
- * @param chainId - The chain ID (hex format).
301
- * @param tokenAddresses - Array of token addresses.
302
- * @param queryOptions - Query options.
303
- * @param queryOptions.currency - The currency for prices.
304
- * @param queryOptions.includeMarketData - Whether to include market data.
305
- * @param options - Fetch options including cache settings.
306
- * @returns The token prices by address.
307
- */
308
- async fetchV1TokenPrices(chainId, tokenAddresses, queryOptions, options) {
309
- if (chainId === '' || tokenAddresses.length === 0) {
310
- return {};
311
- }
312
- return this.queryClient.fetchQuery(this.getV1TokenPricesQueryOptions(chainId, tokenAddresses, queryOptions, options));
199
+ });
313
200
  }
314
201
  /**
315
- * Returns the TanStack Query options object for v1 token price.
202
+ * Get spot price for a single token (v1 endpoint).
316
203
  *
317
204
  * @param chainId - The chain ID (hex format).
318
205
  * @param tokenAddress - The token address.
319
206
  * @param currency - The currency for prices.
320
207
  * @param options - Fetch options including cache settings.
321
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
208
+ * @returns The market data or undefined.
322
209
  */
323
- getV1TokenPriceQueryOptions(chainId, tokenAddress, currency = 'usd', options) {
210
+ async fetchV1TokenPrice(chainId, tokenAddress, currency = 'usd', options) {
324
211
  const chainIdDecimal = parseInt(chainId, 16);
325
- return {
326
- queryKey: ['prices', 'v1TokenPrice', chainId, tokenAddress, currency],
327
- queryFn: async ({ signal, }) => {
328
- return this.fetch(base_client_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/spot-prices/${tokenAddress}`, {
212
+ try {
213
+ return await this.queryClient.fetchQuery({
214
+ queryKey: ['prices', 'v1TokenPrice', chainId, tokenAddress, currency],
215
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/spot-prices/${tokenAddress}`, {
329
216
  signal,
330
217
  params: { vsCurrency: currency },
331
- });
332
- },
333
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
334
- staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
335
- gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
336
- };
337
- }
338
- /**
339
- * Get spot price for a single token (v1 endpoint).
340
- *
341
- * @param chainId - The chain ID (hex format).
342
- * @param tokenAddress - The token address.
343
- * @param currency - The currency for prices.
344
- * @param options - Fetch options including cache settings.
345
- * @returns The market data.
346
- */
347
- async fetchV1TokenPrice(chainId, tokenAddress, currency = 'usd', options) {
348
- return this.queryClient.fetchQuery(this.getV1TokenPriceQueryOptions(chainId, tokenAddress, currency, options));
218
+ }),
219
+ staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
220
+ gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
221
+ });
222
+ }
223
+ catch {
224
+ return undefined;
225
+ }
349
226
  }
350
227
  // ==========================================================================
351
228
  // V2 SPOT PRICES
352
229
  // ==========================================================================
353
230
  /**
354
- * Returns the TanStack Query options object for v2 spot prices.
231
+ * Get spot prices for tokens on a chain with market data (v2 endpoint).
355
232
  *
356
233
  * @param chainId - The chain ID (hex format).
357
234
  * @param tokenAddresses - Array of token addresses.
@@ -359,13 +236,16 @@ class PricesApiClient extends base_client_1.BaseApiClient {
359
236
  * @param queryOptions.currency - The currency for prices.
360
237
  * @param queryOptions.includeMarketData - Whether to include market data.
361
238
  * @param options - Fetch options including cache settings.
362
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
239
+ * @returns The spot prices with market data.
363
240
  */
364
- getV2SpotPricesQueryOptions(chainId, tokenAddresses, queryOptions, options) {
241
+ async fetchV2SpotPrices(chainId, tokenAddresses, queryOptions, options) {
242
+ if (tokenAddresses.length === 0) {
243
+ return {};
244
+ }
365
245
  const chainIdDecimal = parseInt(chainId, 16);
366
246
  const currency = queryOptions?.currency ?? 'usd';
367
247
  const includeMarketData = queryOptions?.includeMarketData ?? true;
368
- return {
248
+ return this.queryClient.fetchQuery({
369
249
  queryKey: [
370
250
  'prices',
371
251
  'v2SpotPrices',
@@ -376,46 +256,23 @@ class PricesApiClient extends base_client_1.BaseApiClient {
376
256
  includeMarketData,
377
257
  },
378
258
  ],
379
- queryFn: async ({ signal, }) => {
380
- if (chainId === '' || tokenAddresses.length === 0) {
381
- return {};
382
- }
383
- return this.fetch(base_client_1.API_URLS.PRICES, `/v2/chains/${chainIdDecimal}/spot-prices`, {
384
- signal,
385
- params: {
386
- tokenAddresses,
387
- vsCurrency: currency,
388
- includeMarketData: queryOptions?.includeMarketData ?? true,
389
- },
390
- });
391
- },
392
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
259
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v2/chains/${chainIdDecimal}/spot-prices`, {
260
+ signal,
261
+ params: {
262
+ tokenAddresses,
263
+ vsCurrency: currency,
264
+ includeMarketData: queryOptions?.includeMarketData ?? true,
265
+ },
266
+ }),
393
267
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
394
268
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
395
- };
396
- }
397
- /**
398
- * Get spot prices for tokens on a chain with market data (v2 endpoint).
399
- *
400
- * @param chainId - The chain ID (hex format).
401
- * @param tokenAddresses - Array of token addresses.
402
- * @param queryOptions - Query options.
403
- * @param queryOptions.currency - The currency for prices.
404
- * @param queryOptions.includeMarketData - Whether to include market data.
405
- * @param options - Fetch options including cache settings.
406
- * @returns The spot prices with market data.
407
- */
408
- async fetchV2SpotPrices(chainId, tokenAddresses, queryOptions, options) {
409
- if (chainId === '' || tokenAddresses.length === 0) {
410
- return {};
411
- }
412
- return this.queryClient.fetchQuery(this.getV2SpotPricesQueryOptions(chainId, tokenAddresses, queryOptions, options));
269
+ });
413
270
  }
414
271
  // ==========================================================================
415
272
  // V3 SPOT PRICES (CAIP-19 based)
416
273
  // ==========================================================================
417
274
  /**
418
- * Returns the TanStack Query options object for v3 spot prices.
275
+ * Get spot prices by CAIP-19 asset IDs (v3 endpoint).
419
276
  *
420
277
  * @param assetIds - Array of CAIP-19 asset IDs.
421
278
  * @param queryOptions - Query options.
@@ -423,13 +280,16 @@ class PricesApiClient extends base_client_1.BaseApiClient {
423
280
  * @param queryOptions.includeMarketData - Whether to include market data.
424
281
  * @param queryOptions.cacheOnly - Whether to use cache only.
425
282
  * @param options - Fetch options including cache settings.
426
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
283
+ * @returns The spot prices response.
427
284
  */
428
- getV3SpotPricesQueryOptions(assetIds, queryOptions, options) {
285
+ async fetchV3SpotPrices(assetIds, queryOptions, options) {
286
+ if (assetIds.length === 0) {
287
+ return {};
288
+ }
429
289
  const currency = queryOptions?.currency ?? 'usd';
430
290
  const includeMarketData = queryOptions?.includeMarketData ?? true;
431
291
  const cacheOnly = queryOptions?.cacheOnly ?? false;
432
- return {
292
+ return this.queryClient.fetchQuery({
433
293
  queryKey: [
434
294
  'prices',
435
295
  'v3SpotPrices',
@@ -440,47 +300,24 @@ class PricesApiClient extends base_client_1.BaseApiClient {
440
300
  cacheOnly,
441
301
  },
442
302
  ],
443
- queryFn: async ({ signal, }) => {
444
- if (assetIds.length === 0) {
445
- return {};
446
- }
447
- return this.fetch(base_client_1.API_URLS.PRICES, '/v3/spot-prices', {
448
- signal,
449
- params: {
450
- assetIds,
451
- vsCurrency: currency,
452
- includeMarketData,
453
- cacheOnly,
454
- },
455
- });
456
- },
457
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
303
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v3/spot-prices', {
304
+ signal,
305
+ params: {
306
+ assetIds,
307
+ vsCurrency: currency,
308
+ includeMarketData,
309
+ cacheOnly,
310
+ },
311
+ }),
458
312
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
459
313
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
460
- };
461
- }
462
- /**
463
- * Get spot prices by CAIP-19 asset IDs (v3 endpoint).
464
- *
465
- * @param assetIds - Array of CAIP-19 asset IDs.
466
- * @param queryOptions - Query options.
467
- * @param queryOptions.currency - The currency for prices.
468
- * @param queryOptions.includeMarketData - Whether to include market data.
469
- * @param queryOptions.cacheOnly - Whether to use cache only.
470
- * @param options - Fetch options including cache settings.
471
- * @returns The spot prices response.
472
- */
473
- async fetchV3SpotPrices(assetIds, queryOptions, options) {
474
- if (assetIds.length === 0) {
475
- return {};
476
- }
477
- return this.queryClient.fetchQuery(this.getV3SpotPricesQueryOptions(assetIds, queryOptions, options));
314
+ });
478
315
  }
479
316
  // ==========================================================================
480
317
  // V1 HISTORICAL PRICES
481
318
  // ==========================================================================
482
319
  /**
483
- * Returns the TanStack Query options object for v1 historical prices by coin ID.
320
+ * Get historical prices by CoinGecko coin ID (v1 endpoint).
484
321
  *
485
322
  * @param coinId - The CoinGecko coin ID.
486
323
  * @param queryOptions - Query options.
@@ -489,10 +326,10 @@ class PricesApiClient extends base_client_1.BaseApiClient {
489
326
  * @param queryOptions.from - Start timestamp.
490
327
  * @param queryOptions.to - End timestamp.
491
328
  * @param options - Fetch options including cache settings.
492
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
329
+ * @returns The historical prices response.
493
330
  */
494
- getV1HistoricalPricesByCoinIdQueryOptions(coinId, queryOptions, options) {
495
- return {
331
+ async fetchV1HistoricalPricesByCoinId(coinId, queryOptions, options) {
332
+ return this.queryClient.fetchQuery({
496
333
  queryKey: ['prices', 'v1HistoricalByCoinId', coinId, queryOptions],
497
334
  queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/historical-prices/${coinId}`, {
498
335
  signal,
@@ -503,28 +340,12 @@ class PricesApiClient extends base_client_1.BaseApiClient {
503
340
  to: queryOptions?.to,
504
341
  },
505
342
  }),
506
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
507
343
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
508
344
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
509
- };
510
- }
511
- /**
512
- * Get historical prices by CoinGecko coin ID (v1 endpoint).
513
- *
514
- * @param coinId - The CoinGecko coin ID.
515
- * @param queryOptions - Query options.
516
- * @param queryOptions.currency - The currency for prices.
517
- * @param queryOptions.timePeriod - The time period.
518
- * @param queryOptions.from - Start timestamp.
519
- * @param queryOptions.to - End timestamp.
520
- * @param options - Fetch options including cache settings.
521
- * @returns The historical prices response.
522
- */
523
- async fetchV1HistoricalPricesByCoinId(coinId, queryOptions, options) {
524
- return this.queryClient.fetchQuery(this.getV1HistoricalPricesByCoinIdQueryOptions(coinId, queryOptions, options));
345
+ });
525
346
  }
526
347
  /**
527
- * Returns the TanStack Query options object for v1 historical prices by token addresses.
348
+ * Get historical prices for tokens on a chain (v1 endpoint).
528
349
  *
529
350
  * @param chainId - The chain ID (hex format).
530
351
  * @param tokenAddresses - Array of token addresses.
@@ -534,11 +355,11 @@ class PricesApiClient extends base_client_1.BaseApiClient {
534
355
  * @param queryOptions.from - Start timestamp.
535
356
  * @param queryOptions.to - End timestamp.
536
357
  * @param options - Fetch options including cache settings.
537
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
358
+ * @returns The historical prices response.
538
359
  */
539
- getV1HistoricalPricesByTokenAddressesQueryOptions(chainId, tokenAddresses, queryOptions, options) {
360
+ async fetchV1HistoricalPricesByTokenAddresses(chainId, tokenAddresses, queryOptions, options) {
540
361
  const chainIdDecimal = parseInt(chainId, 16);
541
- return {
362
+ return this.queryClient.fetchQuery({
542
363
  queryKey: [
543
364
  'prices',
544
365
  'v1HistoricalByTokenAddresses',
@@ -558,29 +379,12 @@ class PricesApiClient extends base_client_1.BaseApiClient {
558
379
  to: queryOptions?.to,
559
380
  },
560
381
  }),
561
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
562
382
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
563
383
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
564
- };
565
- }
566
- /**
567
- * Get historical prices for tokens on a chain (v1 endpoint).
568
- *
569
- * @param chainId - The chain ID (hex format).
570
- * @param tokenAddresses - Array of token addresses.
571
- * @param queryOptions - Query options.
572
- * @param queryOptions.currency - The currency for prices.
573
- * @param queryOptions.timePeriod - The time period.
574
- * @param queryOptions.from - Start timestamp.
575
- * @param queryOptions.to - End timestamp.
576
- * @param options - Fetch options including cache settings.
577
- * @returns The historical prices response.
578
- */
579
- async fetchV1HistoricalPricesByTokenAddresses(chainId, tokenAddresses, queryOptions, options) {
580
- return this.queryClient.fetchQuery(this.getV1HistoricalPricesByTokenAddressesQueryOptions(chainId, tokenAddresses, queryOptions, options));
384
+ });
581
385
  }
582
386
  /**
583
- * Returns the TanStack Query options object for v1 historical prices.
387
+ * Get historical prices for a single token (v1 endpoint).
584
388
  *
585
389
  * @param chainId - The chain ID (hex format).
586
390
  * @param tokenAddress - The token address.
@@ -588,13 +392,13 @@ class PricesApiClient extends base_client_1.BaseApiClient {
588
392
  * @param queryOptions.currency - The currency for prices.
589
393
  * @param queryOptions.timeRange - The time range.
590
394
  * @param options - Fetch options including cache settings.
591
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
395
+ * @returns The historical prices response.
592
396
  */
593
- getV1HistoricalPricesQueryOptions(chainId, tokenAddress, queryOptions, options) {
397
+ async fetchV1HistoricalPrices(chainId, tokenAddress, queryOptions, options) {
594
398
  const chainIdDecimal = parseInt(chainId, 16);
595
399
  const currency = queryOptions?.currency ?? 'usd';
596
400
  const timeRange = queryOptions?.timeRange ?? '7d';
597
- return {
401
+ return this.queryClient.fetchQuery({
598
402
  queryKey: [
599
403
  'prices',
600
404
  'v1Historical',
@@ -610,30 +414,15 @@ class PricesApiClient extends base_client_1.BaseApiClient {
610
414
  timePeriod: timeRange,
611
415
  },
612
416
  }),
613
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
614
417
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
615
418
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
616
- };
617
- }
618
- /**
619
- * Get historical prices for a single token (v1 endpoint).
620
- *
621
- * @param chainId - The chain ID (hex format).
622
- * @param tokenAddress - The token address.
623
- * @param queryOptions - Query options.
624
- * @param queryOptions.currency - The currency for prices.
625
- * @param queryOptions.timeRange - The time range.
626
- * @param options - Fetch options including cache settings.
627
- * @returns The historical prices response.
628
- */
629
- async fetchV1HistoricalPrices(chainId, tokenAddress, queryOptions, options) {
630
- return this.queryClient.fetchQuery(this.getV1HistoricalPricesQueryOptions(chainId, tokenAddress, queryOptions, options));
419
+ });
631
420
  }
632
421
  // ==========================================================================
633
422
  // V3 HISTORICAL PRICES
634
423
  // ==========================================================================
635
424
  /**
636
- * Returns the TanStack Query options object for v3 historical prices.
425
+ * Get historical prices by CAIP-19 asset ID (v3 endpoint).
637
426
  *
638
427
  * @param chainId - The CAIP-2 chain ID.
639
428
  * @param assetType - The asset type portion of CAIP-19.
@@ -644,10 +433,10 @@ class PricesApiClient extends base_client_1.BaseApiClient {
644
433
  * @param queryOptions.to - End timestamp.
645
434
  * @param queryOptions.interval - Data interval.
646
435
  * @param options - Fetch options including cache settings.
647
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
436
+ * @returns The historical prices response.
648
437
  */
649
- getV3HistoricalPricesQueryOptions(chainId, assetType, queryOptions, options) {
650
- return {
438
+ async fetchV3HistoricalPrices(chainId, assetType, queryOptions, options) {
439
+ return this.queryClient.fetchQuery({
651
440
  queryKey: ['prices', 'v3Historical', chainId, assetType, queryOptions],
652
441
  queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v3/historical-prices/${chainId}/${assetType}`, {
653
442
  signal,
@@ -659,45 +448,27 @@ class PricesApiClient extends base_client_1.BaseApiClient {
659
448
  interval: queryOptions?.interval,
660
449
  },
661
450
  }),
662
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
663
451
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
664
452
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
665
- };
666
- }
667
- /**
668
- * Get historical prices by CAIP-19 asset ID (v3 endpoint).
669
- *
670
- * @param chainId - The CAIP-2 chain ID.
671
- * @param assetType - The asset type portion of CAIP-19.
672
- * @param queryOptions - Query options.
673
- * @param queryOptions.currency - The currency for prices.
674
- * @param queryOptions.timePeriod - The time period.
675
- * @param queryOptions.from - Start timestamp.
676
- * @param queryOptions.to - End timestamp.
677
- * @param queryOptions.interval - Data interval.
678
- * @param options - Fetch options including cache settings.
679
- * @returns The historical prices response.
680
- */
681
- async fetchV3HistoricalPrices(chainId, assetType, queryOptions, options) {
682
- return this.queryClient.fetchQuery(this.getV3HistoricalPricesQueryOptions(chainId, assetType, queryOptions, options));
453
+ });
683
454
  }
684
455
  // ==========================================================================
685
456
  // V1 HISTORICAL PRICE GRAPH
686
457
  // ==========================================================================
687
458
  /**
688
- * Returns the TanStack Query options object for v1 historical price graph by coin ID.
459
+ * Get historical price graph data by CoinGecko coin ID (v1 endpoint).
689
460
  *
690
461
  * @param coinId - The CoinGecko coin ID.
691
462
  * @param queryOptions - Query options.
692
463
  * @param queryOptions.currency - The currency for prices.
693
464
  * @param queryOptions.includeOHLC - Whether to include OHLC data.
694
465
  * @param options - Fetch options including cache settings.
695
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
466
+ * @returns The historical price graph response.
696
467
  */
697
- getV1HistoricalPriceGraphByCoinIdQueryOptions(coinId, queryOptions, options) {
468
+ async fetchV1HistoricalPriceGraphByCoinId(coinId, queryOptions, options) {
698
469
  const currency = queryOptions?.currency ?? 'usd';
699
470
  const includeOHLC = queryOptions?.includeOHLC ?? false;
700
- return {
471
+ return this.queryClient.fetchQuery({
701
472
  queryKey: ['prices', 'v1GraphByCoinId', coinId, currency, includeOHLC],
702
473
  queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/historical-prices-graph/${coinId}`, {
703
474
  signal,
@@ -706,26 +477,12 @@ class PricesApiClient extends base_client_1.BaseApiClient {
706
477
  includeOHLC,
707
478
  },
708
479
  }),
709
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
710
480
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
711
481
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
712
- };
713
- }
714
- /**
715
- * Get historical price graph data by CoinGecko coin ID (v1 endpoint).
716
- *
717
- * @param coinId - The CoinGecko coin ID.
718
- * @param queryOptions - Query options.
719
- * @param queryOptions.currency - The currency for prices.
720
- * @param queryOptions.includeOHLC - Whether to include OHLC data.
721
- * @param options - Fetch options including cache settings.
722
- * @returns The historical price graph response.
723
- */
724
- async fetchV1HistoricalPriceGraphByCoinId(coinId, queryOptions, options) {
725
- return this.queryClient.fetchQuery(this.getV1HistoricalPriceGraphByCoinIdQueryOptions(coinId, queryOptions, options));
482
+ });
726
483
  }
727
484
  /**
728
- * Returns the TanStack Query options object for v1 historical price graph by token address.
485
+ * Get historical price graph data by token address (v1 endpoint).
729
486
  *
730
487
  * @param chainId - The chain ID (hex format).
731
488
  * @param tokenAddress - The token address.
@@ -733,13 +490,13 @@ class PricesApiClient extends base_client_1.BaseApiClient {
733
490
  * @param queryOptions.currency - The currency for prices.
734
491
  * @param queryOptions.includeOHLC - Whether to include OHLC data.
735
492
  * @param options - Fetch options including cache settings.
736
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
493
+ * @returns The historical price graph response.
737
494
  */
738
- getV1HistoricalPriceGraphByTokenAddressQueryOptions(chainId, tokenAddress, queryOptions, options) {
495
+ async fetchV1HistoricalPriceGraphByTokenAddress(chainId, tokenAddress, queryOptions, options) {
739
496
  const chainIdDecimal = parseInt(chainId, 16);
740
497
  const currency = queryOptions?.currency ?? 'usd';
741
498
  const includeOHLC = queryOptions?.includeOHLC ?? false;
742
- return {
499
+ return this.queryClient.fetchQuery({
743
500
  queryKey: [
744
501
  'prices',
745
502
  'v1GraphByTokenAddress',
@@ -755,24 +512,9 @@ class PricesApiClient extends base_client_1.BaseApiClient {
755
512
  includeOHLC,
756
513
  },
757
514
  }),
758
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
759
515
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
760
516
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
761
- };
762
- }
763
- /**
764
- * Get historical price graph data by token address (v1 endpoint).
765
- *
766
- * @param chainId - The chain ID (hex format).
767
- * @param tokenAddress - The token address.
768
- * @param queryOptions - Query options.
769
- * @param queryOptions.currency - The currency for prices.
770
- * @param queryOptions.includeOHLC - Whether to include OHLC data.
771
- * @param options - Fetch options including cache settings.
772
- * @returns The historical price graph response.
773
- */
774
- async fetchV1HistoricalPriceGraphByTokenAddress(chainId, tokenAddress, queryOptions, options) {
775
- return this.queryClient.fetchQuery(this.getV1HistoricalPriceGraphByTokenAddressQueryOptions(chainId, tokenAddress, queryOptions, options));
517
+ });
776
518
  }
777
519
  }
778
520
  exports.PricesApiClient = PricesApiClient;