@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
@@ -14,7 +14,6 @@
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AccountsApiClient = void 0;
16
16
  const base_client_1 = require("../base-client.cjs");
17
- const shared_types_1 = require("../shared-types.cjs");
18
17
  /**
19
18
  * Accounts API Client.
20
19
  * Provides methods for interacting with the Accounts API.
@@ -43,68 +42,48 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
43
42
  // SUPPORTED NETWORKS
44
43
  // ==========================================================================
45
44
  /**
46
- * Returns the TanStack Query options object for v1 supported networks.
45
+ * Get list of supported networks (v1 endpoint).
47
46
  *
48
47
  * @param options - Fetch options including cache settings.
49
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
48
+ * @returns The list of supported networks.
50
49
  */
51
- getV1SupportedNetworksQueryOptions(options) {
52
- return {
50
+ async fetchV1SupportedNetworks(options) {
51
+ return this.queryClient.fetchQuery({
53
52
  queryKey: ['accounts', 'v1SupportedNetworks'],
54
53
  queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v1/supportedNetworks', { signal }),
55
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
56
54
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.SUPPORTED_NETWORKS,
57
55
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.EXTENDED,
58
- };
56
+ });
59
57
  }
60
58
  /**
61
- * Get list of supported networks (v1 endpoint).
59
+ * Get list of supported networks (v2 endpoint).
62
60
  *
63
61
  * @param options - Fetch options including cache settings.
64
62
  * @returns The list of supported networks.
65
63
  */
66
- async fetchV1SupportedNetworks(options) {
67
- return this.queryClient.fetchQuery(this.getV1SupportedNetworksQueryOptions(options));
68
- }
69
- /**
70
- * Returns the TanStack Query options object for v2 supported networks.
71
- *
72
- * @param options - Fetch options including cache settings.
73
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
74
- */
75
- getV2SupportedNetworksQueryOptions(options) {
76
- return {
64
+ async fetchV2SupportedNetworks(options) {
65
+ return this.queryClient.fetchQuery({
77
66
  queryKey: ['accounts', 'v2SupportedNetworks'],
78
67
  queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v2/supportedNetworks', { signal }),
79
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
80
68
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.SUPPORTED_NETWORKS,
81
69
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.EXTENDED,
82
- };
83
- }
84
- /**
85
- * Get list of supported networks (v2 endpoint).
86
- *
87
- * @param options - Fetch options including cache settings.
88
- * @returns The list of supported networks.
89
- */
90
- async fetchV2SupportedNetworks(options) {
91
- return this.queryClient.fetchQuery(this.getV2SupportedNetworksQueryOptions(options));
70
+ });
92
71
  }
93
72
  // ==========================================================================
94
73
  // ACTIVE NETWORKS
95
74
  // ==========================================================================
96
75
  /**
97
- * Returns the TanStack Query options object for v2 active networks.
76
+ * Get active networks by CAIP-10 account IDs (v2 endpoint).
98
77
  *
99
78
  * @param accountIds - Array of CAIP-10 account IDs.
100
79
  * @param queryOptions - Query filter options.
101
80
  * @param queryOptions.filterMMListTokens - Whether to filter MM list tokens.
102
81
  * @param queryOptions.networks - Networks to filter by.
103
82
  * @param options - Fetch options including cache settings.
104
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
83
+ * @returns The active networks response.
105
84
  */
106
- getV2ActiveNetworksQueryOptions(accountIds, queryOptions, options) {
107
- return {
85
+ async fetchV2ActiveNetworks(accountIds, queryOptions, options) {
86
+ return this.queryClient.fetchQuery({
108
87
  queryKey: [
109
88
  'accounts',
110
89
  'v2ActiveNetworks',
@@ -116,57 +95,32 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
116
95
  },
117
96
  },
118
97
  ],
119
- queryFn: async ({ signal, }) => {
120
- if (accountIds.length === 0) {
121
- return { activeNetworks: [] };
122
- }
123
- return this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v2/activeNetworks', {
124
- signal,
125
- params: {
126
- accountIds,
127
- filterMMListTokens: queryOptions?.filterMMListTokens,
128
- networks: queryOptions?.networks,
129
- },
130
- });
131
- },
132
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
98
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v2/activeNetworks', {
99
+ signal,
100
+ params: {
101
+ accountIds,
102
+ filterMMListTokens: queryOptions?.filterMMListTokens,
103
+ networks: queryOptions?.networks,
104
+ },
105
+ }),
133
106
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.NETWORKS,
134
107
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
135
- };
136
- }
137
- /**
138
- * Get active networks by CAIP-10 account IDs (v2 endpoint).
139
- *
140
- * @param accountIds - Array of CAIP-10 account IDs.
141
- * @param queryOptions - Query filter options.
142
- * @param queryOptions.filterMMListTokens - Whether to filter MM list tokens.
143
- * @param queryOptions.networks - Networks to filter by.
144
- * @param options - Fetch options including cache settings.
145
- * @returns The active networks response.
146
- */
147
- async fetchV2ActiveNetworks(accountIds, queryOptions, options) {
148
- if (accountIds.length === 0) {
149
- return { activeNetworks: [] };
150
- }
151
- return this.queryClient.fetchQuery(this.getV2ActiveNetworksQueryOptions(accountIds, queryOptions, options));
108
+ });
152
109
  }
153
110
  // ==========================================================================
154
111
  // BALANCES
155
112
  // ==========================================================================
156
113
  /**
157
- * Returns the TanStack Query options object for v2 balances.
114
+ * Get account balances for a single address (v2 endpoint).
158
115
  *
159
116
  * @param address - The account address.
160
117
  * @param queryOptions - Query filter options.
161
118
  * @param queryOptions.networks - Networks to filter by.
162
- * @param queryOptions.filterSupportedTokens - Whether to filter supported tokens.
163
- * @param queryOptions.includeTokenAddresses - Token addresses to include.
164
- * @param queryOptions.includeStakedAssets - Whether to include staked assets.
165
119
  * @param options - Fetch options including cache settings.
166
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
120
+ * @returns The account balances response.
167
121
  */
168
- getV2BalancesQueryOptions(address, queryOptions, options) {
169
- return {
122
+ async fetchV2Balances(address, queryOptions, options) {
123
+ return this.queryClient.fetchQuery({
170
124
  queryKey: [
171
125
  'accounts',
172
126
  'balances',
@@ -176,32 +130,19 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
176
130
  options: queryOptions && {
177
131
  ...queryOptions,
178
132
  networks: queryOptions.networks && [...queryOptions.networks].sort(),
179
- includeTokenAddresses: queryOptions.includeTokenAddresses &&
180
- [...queryOptions.includeTokenAddresses].sort(),
181
133
  },
182
134
  },
183
135
  ],
184
- queryFn: async ({ signal, }) => {
185
- if (address === '') {
186
- return { count: 0, balances: [], unprocessedNetworks: [] };
187
- }
188
- return this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/balances`, {
189
- signal,
190
- params: {
191
- networks: queryOptions?.networks,
192
- filterSupportedTokens: queryOptions?.filterSupportedTokens,
193
- includeTokenAddresses: queryOptions?.includeTokenAddresses,
194
- includeStakedAssets: queryOptions?.includeStakedAssets,
195
- },
196
- });
197
- },
198
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
136
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/balances`, {
137
+ signal,
138
+ params: { networks: queryOptions?.networks },
139
+ }),
199
140
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.BALANCES,
200
141
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
201
- };
142
+ });
202
143
  }
203
144
  /**
204
- * Get account balances for a single address (v2 endpoint).
145
+ * Get account balances with additional options (v2 endpoint).
205
146
  *
206
147
  * @param address - The account address.
207
148
  * @param queryOptions - Query filter options.
@@ -212,51 +153,34 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
212
153
  * @param options - Fetch options including cache settings.
213
154
  * @returns The account balances response.
214
155
  */
215
- async fetchV2Balances(address, queryOptions, options) {
216
- if (address === '') {
217
- return { count: 0, balances: [], unprocessedNetworks: [] };
218
- }
219
- return this.queryClient.fetchQuery(this.getV2BalancesQueryOptions(address, queryOptions, options));
220
- }
221
- /**
222
- * Returns the TanStack Query options object for v4 multi-account balances.
223
- *
224
- * @param accountAddresses - Array of account addresses.
225
- * @param queryOptions - Query filter options.
226
- * @param queryOptions.networks - Networks to filter by.
227
- * @param options - Fetch options including cache settings.
228
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
229
- */
230
- getV4MultiAccountBalancesQueryOptions(accountAddresses, queryOptions, options) {
231
- return {
156
+ async fetchV2BalancesWithOptions(address, queryOptions, options) {
157
+ return this.queryClient.fetchQuery({
232
158
  queryKey: [
233
159
  'accounts',
234
160
  'balances',
235
- 'v4',
161
+ 'v2',
236
162
  {
237
- accountAddresses: [...accountAddresses].sort(),
163
+ address,
238
164
  options: queryOptions && {
239
165
  ...queryOptions,
240
166
  networks: queryOptions.networks && [...queryOptions.networks].sort(),
167
+ includeTokenAddresses: queryOptions.includeTokenAddresses &&
168
+ [...queryOptions.includeTokenAddresses].sort(),
241
169
  },
242
170
  },
243
171
  ],
244
- queryFn: async ({ signal, }) => {
245
- if (accountAddresses.length === 0) {
246
- return { count: 0, balances: [], unprocessedNetworks: [] };
247
- }
248
- return this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v4/multiaccount/balances', {
249
- signal,
250
- params: {
251
- accountAddresses,
252
- networks: queryOptions?.networks,
253
- },
254
- });
255
- },
256
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
172
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/balances`, {
173
+ signal,
174
+ params: {
175
+ networks: queryOptions?.networks,
176
+ filterSupportedTokens: queryOptions?.filterSupportedTokens,
177
+ includeTokenAddresses: queryOptions?.includeTokenAddresses,
178
+ includeStakedAssets: queryOptions?.includeStakedAssets,
179
+ },
180
+ }),
257
181
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.BALANCES,
258
182
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
259
- };
183
+ });
260
184
  }
261
185
  /**
262
186
  * Get balances for multiple accounts (v4 endpoint).
@@ -268,54 +192,29 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
268
192
  * @returns The multi-account balances response.
269
193
  */
270
194
  async fetchV4MultiAccountBalances(accountAddresses, queryOptions, options) {
271
- if (accountAddresses.length === 0) {
272
- return { count: 0, balances: [], unprocessedNetworks: [] };
273
- }
274
- return this.queryClient.fetchQuery(this.getV4MultiAccountBalancesQueryOptions(accountAddresses, queryOptions, options));
275
- }
276
- /**
277
- * Returns the TanStack Query options object for v5 multi-account balances.
278
- *
279
- * @param accountIds - Array of CAIP-10 account IDs.
280
- * @param queryOptions - Query filter options.
281
- * @param queryOptions.filterMMListTokens - Whether to filter MM list tokens.
282
- * @param queryOptions.networks - Networks to filter by.
283
- * @param queryOptions.includeStakedAssets - Whether to include staked assets.
284
- * @param options - Fetch options including cache settings.
285
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
286
- */
287
- getV5MultiAccountBalancesQueryOptions(accountIds, queryOptions, options) {
288
- return {
195
+ return this.queryClient.fetchQuery({
289
196
  queryKey: [
290
197
  'accounts',
291
198
  'balances',
292
- 'v5',
199
+ 'v4',
293
200
  {
294
- accountIds: [...accountIds].sort(),
201
+ accountAddresses: [...accountAddresses].sort(),
295
202
  options: queryOptions && {
296
203
  ...queryOptions,
297
204
  networks: queryOptions.networks && [...queryOptions.networks].sort(),
298
205
  },
299
206
  },
300
207
  ],
301
- queryFn: async ({ signal, }) => {
302
- if (accountIds.length === 0) {
303
- return { count: 0, unprocessedNetworks: [], balances: [] };
304
- }
305
- return this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v5/multiaccount/balances', {
306
- signal,
307
- params: {
308
- accountIds,
309
- networks: queryOptions?.networks,
310
- filterMMListTokens: queryOptions?.filterMMListTokens,
311
- includeStakedAssets: queryOptions?.includeStakedAssets,
312
- },
313
- });
314
- },
315
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
208
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v4/multiaccount/balances', {
209
+ signal,
210
+ params: {
211
+ accountAddresses,
212
+ networks: queryOptions?.networks,
213
+ },
214
+ }),
316
215
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.BALANCES,
317
216
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
318
- };
217
+ });
319
218
  }
320
219
  /**
321
220
  * Get balances for multiple accounts using CAIP-10 IDs (v5 endpoint).
@@ -329,16 +228,37 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
329
228
  * @returns The multi-account balances response.
330
229
  */
331
230
  async fetchV5MultiAccountBalances(accountIds, queryOptions, options) {
332
- if (accountIds.length === 0) {
333
- return { count: 0, unprocessedNetworks: [], balances: [] };
334
- }
335
- return this.queryClient.fetchQuery(this.getV5MultiAccountBalancesQueryOptions(accountIds, queryOptions, options));
231
+ return this.queryClient.fetchQuery({
232
+ queryKey: [
233
+ 'accounts',
234
+ 'balances',
235
+ 'v5',
236
+ {
237
+ accountIds: [...accountIds].sort(),
238
+ options: queryOptions && {
239
+ ...queryOptions,
240
+ networks: queryOptions.networks && [...queryOptions.networks].sort(),
241
+ },
242
+ },
243
+ ],
244
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v5/multiaccount/balances', {
245
+ signal,
246
+ params: {
247
+ accountIds,
248
+ networks: queryOptions?.networks,
249
+ filterMMListTokens: queryOptions?.filterMMListTokens,
250
+ includeStakedAssets: queryOptions?.includeStakedAssets,
251
+ },
252
+ }),
253
+ staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.BALANCES,
254
+ gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
255
+ });
336
256
  }
337
257
  // ==========================================================================
338
258
  // TRANSACTIONS
339
259
  // ==========================================================================
340
260
  /**
341
- * Returns the TanStack Query options object for v1 transaction by hash.
261
+ * Get a specific transaction by hash (v1 endpoint).
342
262
  *
343
263
  * @param chainId - The chain ID.
344
264
  * @param txHash - The transaction hash.
@@ -348,10 +268,10 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
348
268
  * @param queryOptions.includeTxMetadata - Whether to include transaction metadata.
349
269
  * @param queryOptions.lang - Language for metadata.
350
270
  * @param options - Fetch options including cache settings.
351
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
271
+ * @returns The transaction details.
352
272
  */
353
- getV1TransactionByHashQueryOptions(chainId, txHash, queryOptions, options) {
354
- return {
273
+ async fetchV1TransactionByHash(chainId, txHash, queryOptions, options) {
274
+ return this.queryClient.fetchQuery({
355
275
  queryKey: [
356
276
  'accounts',
357
277
  'transactions',
@@ -367,29 +287,12 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
367
287
  lang: queryOptions?.lang,
368
288
  },
369
289
  }),
370
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
371
290
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.TRANSACTIONS,
372
291
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
373
- };
374
- }
375
- /**
376
- * Get a specific transaction by hash (v1 endpoint).
377
- *
378
- * @param chainId - The chain ID.
379
- * @param txHash - The transaction hash.
380
- * @param queryOptions - Query filter options.
381
- * @param queryOptions.includeLogs - Whether to include logs.
382
- * @param queryOptions.includeValueTransfers - Whether to include value transfers.
383
- * @param queryOptions.includeTxMetadata - Whether to include transaction metadata.
384
- * @param queryOptions.lang - Language for metadata.
385
- * @param options - Fetch options including cache settings.
386
- * @returns The transaction details.
387
- */
388
- async fetchV1TransactionByHash(chainId, txHash, queryOptions, options) {
389
- return this.queryClient.fetchQuery(this.getV1TransactionByHashQueryOptions(chainId, txHash, queryOptions, options));
292
+ });
390
293
  }
391
294
  /**
392
- * Returns the TanStack Query options object for v1 account transactions.
295
+ * Get account transactions (v1 endpoint).
393
296
  *
394
297
  * @param address - The account address.
395
298
  * @param queryOptions - Query filter options.
@@ -399,10 +302,10 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
399
302
  * @param queryOptions.endTimestamp - End timestamp filter.
400
303
  * @param queryOptions.sortDirection - Sort direction (ASC/DESC).
401
304
  * @param options - Fetch options including cache settings.
402
- * @returns TanStack Query options for use with useQuery, useInfiniteQuery, useSuspenseQuery, etc.
305
+ * @returns The account transactions response.
403
306
  */
404
- getV1AccountTransactionsQueryOptions(address, queryOptions, options) {
405
- return {
307
+ async fetchV1AccountTransactions(address, queryOptions, options) {
308
+ return this.queryClient.fetchQuery({
406
309
  queryKey: [
407
310
  'accounts',
408
311
  'transactions',
@@ -415,75 +318,42 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
415
318
  },
416
319
  },
417
320
  ],
418
- queryFn: async ({ signal, }) => {
419
- if (address === '') {
420
- return { data: [], pageInfo: { count: 0, hasNextPage: false } };
421
- }
422
- return this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v1/accounts/${address}/transactions`, {
423
- signal,
424
- params: {
425
- networks: queryOptions?.chainIds,
426
- cursor: queryOptions?.cursor,
427
- startTimestamp: queryOptions?.startTimestamp,
428
- endTimestamp: queryOptions?.endTimestamp,
429
- sortDirection: queryOptions?.sortDirection,
430
- },
431
- });
432
- },
433
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
321
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v1/accounts/${address}/transactions`, {
322
+ signal,
323
+ params: {
324
+ networks: queryOptions?.chainIds,
325
+ cursor: queryOptions?.cursor,
326
+ startTimestamp: queryOptions?.startTimestamp,
327
+ endTimestamp: queryOptions?.endTimestamp,
328
+ sortDirection: queryOptions?.sortDirection,
329
+ },
330
+ }),
434
331
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.TRANSACTIONS,
435
332
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
436
- };
333
+ });
437
334
  }
438
335
  /**
439
- * Get account transactions (v1 endpoint).
336
+ * Get multi-account transactions (v4 endpoint).
440
337
  *
441
- * @param address - The account address.
338
+ * @param accountIds - Array of CAIP-10 account IDs.
442
339
  * @param queryOptions - Query filter options.
443
- * @param queryOptions.chainIds - Chain IDs to filter by.
340
+ * @param queryOptions.networks - Networks to filter by.
444
341
  * @param queryOptions.cursor - Pagination cursor.
445
- * @param queryOptions.startTimestamp - Start timestamp filter.
446
- * @param queryOptions.endTimestamp - End timestamp filter.
447
- * @param queryOptions.sortDirection - Sort direction (ASC/DESC).
448
- * @param options - Fetch options including cache settings.
449
- * @returns The account transactions response.
450
- */
451
- async fetchV1AccountTransactions(address, queryOptions, options) {
452
- if (address === '') {
453
- return { data: [], pageInfo: { count: 0, hasNextPage: false } };
454
- }
455
- return this.queryClient.fetchQuery(this.getV1AccountTransactionsQueryOptions(address, queryOptions, options));
456
- }
457
- /**
458
- * Returns the TanStack Query options object for v4 multi-account transactions.
459
- * Use this with `queryClient.fetchQuery()`, `useQuery()`, `useInfiniteQuery()`,
460
- * `useSuspenseQuery()`, etc. for flexibility across query permutations.
461
- *
462
- * @param accountAddresses - Array of CAIP-10 account addresses.
463
- * @param queryOptions - Query filter options.
464
- * @param queryOptions.networks - Comma-separated CAIP-2 network IDs.
465
- * @param queryOptions.startTimestamp - Start timestamp (epoch) from which to return results.
466
- * @param queryOptions.endTimestamp - End timestamp (epoch) for which to return results.
467
- * @param queryOptions.cursor - Pagination cursor (deprecated, use after).
468
- * @param queryOptions.limit - Maximum number of transactions to request (default 50).
469
- * @param queryOptions.after - JWT containing the endCursor for the query.
470
- * @param queryOptions.before - JWT containing the startCursor for the query.
471
342
  * @param queryOptions.sortDirection - Sort direction (ASC/DESC).
472
343
  * @param queryOptions.includeLogs - Whether to include logs.
344
+ * @param queryOptions.includeValueTransfers - Whether to include value transfers.
473
345
  * @param queryOptions.includeTxMetadata - Whether to include transaction metadata.
474
- * @param queryOptions.maxLogsPerTx - Maximum number of logs per transaction.
475
- * @param queryOptions.lang - Language for transaction category (default "en").
476
346
  * @param options - Fetch options including cache settings.
477
- * @returns Query options object compatible with fetchQuery/useQuery/useInfiniteQuery.
347
+ * @returns The multi-account transactions response.
478
348
  */
479
- getV4MultiAccountTransactionsQueryOptions(accountAddresses, queryOptions, options) {
480
- return {
349
+ async fetchV4MultiAccountTransactions(accountIds, queryOptions, options) {
350
+ return this.queryClient.fetchQuery({
481
351
  queryKey: [
482
352
  'accounts',
483
353
  'transactions',
484
354
  'v4MultiAccount',
485
355
  {
486
- accountAddresses: [...accountAddresses].sort(),
356
+ accountIds: [...accountIds].sort(),
487
357
  options: queryOptions && {
488
358
  ...queryOptions,
489
359
  networks: queryOptions.networks && [...queryOptions.networks].sort(),
@@ -493,70 +363,22 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
493
363
  queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, '/v4/multiaccount/transactions', {
494
364
  signal,
495
365
  params: {
496
- accountAddresses,
366
+ accountIds,
497
367
  networks: queryOptions?.networks,
498
- startTimestamp: queryOptions?.startTimestamp,
499
- endTimestamp: queryOptions?.endTimestamp,
500
368
  cursor: queryOptions?.cursor,
501
- limit: queryOptions?.limit,
502
- after: queryOptions?.after,
503
- before: queryOptions?.before,
504
369
  sortDirection: queryOptions?.sortDirection,
505
370
  includeLogs: queryOptions?.includeLogs,
371
+ includeValueTransfers: queryOptions?.includeValueTransfers,
506
372
  includeTxMetadata: queryOptions?.includeTxMetadata,
507
- maxLogsPerTx: queryOptions?.maxLogsPerTx,
508
- lang: queryOptions?.lang,
509
373
  },
510
374
  }),
511
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
512
375
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.TRANSACTIONS,
513
376
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
514
- };
515
- }
516
- /**
517
- * Get multi-account transactions (v4 endpoint).
518
- *
519
- * @param accountAddresses - Array of CAIP-10 account addresses.
520
- * @param queryOptions - Query filter options.
521
- * @param queryOptions.networks - Comma-separated CAIP-2 network IDs.
522
- * @param queryOptions.startTimestamp - Start timestamp (epoch) from which to return results.
523
- * @param queryOptions.endTimestamp - End timestamp (epoch) for which to return results.
524
- * @param queryOptions.cursor - Pagination cursor (deprecated, use after).
525
- * @param queryOptions.limit - Maximum number of transactions to request (default 50).
526
- * @param queryOptions.after - JWT containing the endCursor for the query.
527
- * @param queryOptions.before - JWT containing the startCursor for the query.
528
- * @param queryOptions.sortDirection - Sort direction (ASC/DESC).
529
- * @param queryOptions.includeLogs - Whether to include logs.
530
- * @param queryOptions.includeTxMetadata - Whether to include transaction metadata.
531
- * @param queryOptions.maxLogsPerTx - Maximum number of logs per transaction.
532
- * @param queryOptions.lang - Language for transaction category (default "en").
533
- * @param options - Fetch options including cache settings.
534
- * @returns The multi-account transactions response.
535
- */
536
- async fetchV4MultiAccountTransactions(accountAddresses, queryOptions, options) {
537
- return this.queryClient.fetchQuery(this.getV4MultiAccountTransactionsQueryOptions(accountAddresses, queryOptions, options));
377
+ });
538
378
  }
539
379
  // ==========================================================================
540
380
  // RELATIONSHIPS
541
381
  // ==========================================================================
542
- /**
543
- * Returns the TanStack Query options object for v1 account relationship.
544
- *
545
- * @param chainId - The chain ID.
546
- * @param from - The from address.
547
- * @param to - The to address.
548
- * @param options - Fetch options including cache settings.
549
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
550
- */
551
- getV1AccountRelationshipQueryOptions(chainId, from, to, options) {
552
- return {
553
- queryKey: ['accounts', 'v1Relationship', chainId, from, to],
554
- queryFn: async ({ signal, }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v1/networks/${chainId}/accounts/${from}/relationships/${to}`, { signal }),
555
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
556
- staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.DEFAULT,
557
- gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
558
- };
559
- }
560
382
  /**
561
383
  * Get account address relationship (v1 endpoint).
562
384
  *
@@ -567,23 +389,49 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
567
389
  * @returns The account relationship result.
568
390
  */
569
391
  async fetchV1AccountRelationship(chainId, from, to, options) {
570
- return this.queryClient.fetchQuery(this.getV1AccountRelationshipQueryOptions(chainId, from, to, options));
392
+ return this.queryClient.fetchQuery({
393
+ queryKey: ['accounts', 'v1Relationship', chainId, from, to],
394
+ queryFn: async ({ signal }) => {
395
+ try {
396
+ return await this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v1/networks/${chainId}/accounts/${from}/relationships/${to}`, { signal });
397
+ }
398
+ catch (error) {
399
+ if (error instanceof base_client_1.HttpError && typeof error.body === 'object') {
400
+ const body = error.body;
401
+ if (body?.error &&
402
+ typeof body.error === 'object' &&
403
+ typeof body.error.code === 'string' &&
404
+ typeof body.error.message === 'string') {
405
+ return {
406
+ error: {
407
+ code: body.error.code,
408
+ message: body.error.message,
409
+ },
410
+ };
411
+ }
412
+ }
413
+ throw error;
414
+ }
415
+ },
416
+ staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.DEFAULT,
417
+ gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
418
+ });
571
419
  }
572
420
  // ==========================================================================
573
421
  // NFTs
574
422
  // ==========================================================================
575
423
  /**
576
- * Returns the TanStack Query options object for v2 account NFTs.
424
+ * Get NFTs owned by an account (v2 endpoint).
577
425
  *
578
426
  * @param address - The account address.
579
427
  * @param queryOptions - Query filter options.
580
428
  * @param queryOptions.networks - Networks to filter by.
581
429
  * @param queryOptions.cursor - Pagination cursor.
582
430
  * @param options - Fetch options including cache settings.
583
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
431
+ * @returns The NFTs response.
584
432
  */
585
- getV2AccountNftsQueryOptions(address, queryOptions, options) {
586
- return {
433
+ async fetchV2AccountNfts(address, queryOptions, options) {
434
+ return this.queryClient.fetchQuery({
587
435
  queryKey: [
588
436
  'accounts',
589
437
  'v2Nfts',
@@ -595,53 +443,31 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
595
443
  },
596
444
  },
597
445
  ],
598
- queryFn: async ({ signal, }) => {
599
- if (address === '') {
600
- return { data: [], pageInfo: { count: 0, hasNextPage: false } };
601
- }
602
- return this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/nfts`, {
603
- signal,
604
- params: {
605
- networks: queryOptions?.networks,
606
- cursor: queryOptions?.cursor,
607
- },
608
- });
609
- },
610
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
446
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/nfts`, {
447
+ signal,
448
+ params: {
449
+ networks: queryOptions?.networks,
450
+ cursor: queryOptions?.cursor,
451
+ },
452
+ }),
611
453
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.DEFAULT,
612
454
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
613
- };
614
- }
615
- /**
616
- * Get NFTs owned by an account (v2 endpoint).
617
- *
618
- * @param address - The account address.
619
- * @param queryOptions - Query filter options.
620
- * @param queryOptions.networks - Networks to filter by.
621
- * @param queryOptions.cursor - Pagination cursor.
622
- * @param options - Fetch options including cache settings.
623
- * @returns The NFTs response.
624
- */
625
- async fetchV2AccountNfts(address, queryOptions, options) {
626
- if (address === '') {
627
- return { data: [], pageInfo: { count: 0, hasNextPage: false } };
628
- }
629
- return this.queryClient.fetchQuery(this.getV2AccountNftsQueryOptions(address, queryOptions, options));
455
+ });
630
456
  }
631
457
  // ==========================================================================
632
458
  // TOKEN DISCOVERY
633
459
  // ==========================================================================
634
460
  /**
635
- * Returns the TanStack Query options object for v2 account tokens.
461
+ * Get ERC20 tokens detected for an account (v2 endpoint).
636
462
  *
637
463
  * @param address - The account address.
638
464
  * @param queryOptions - Query filter options.
639
465
  * @param queryOptions.networks - Networks to filter by.
640
466
  * @param options - Fetch options including cache settings.
641
- * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
467
+ * @returns The tokens response.
642
468
  */
643
- getV2AccountTokensQueryOptions(address, queryOptions, options) {
644
- return {
469
+ async fetchV2AccountTokens(address, queryOptions, options) {
470
+ return this.queryClient.fetchQuery({
645
471
  queryKey: [
646
472
  'accounts',
647
473
  'v2Tokens',
@@ -653,34 +479,13 @@ class AccountsApiClient extends base_client_1.BaseApiClient {
653
479
  },
654
480
  },
655
481
  ],
656
- queryFn: async ({ signal, }) => {
657
- if (address === '') {
658
- return { data: [] };
659
- }
660
- return this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/tokens`, {
661
- signal,
662
- params: { networks: queryOptions?.networks },
663
- });
664
- },
665
- ...(0, shared_types_1.getQueryOptionsOverrides)(options),
482
+ queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.ACCOUNTS, `/v2/accounts/${address}/tokens`, {
483
+ signal,
484
+ params: { networks: queryOptions?.networks },
485
+ }),
666
486
  staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.DEFAULT,
667
487
  gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
668
- };
669
- }
670
- /**
671
- * Get ERC20 tokens detected for an account (v2 endpoint).
672
- *
673
- * @param address - The account address.
674
- * @param queryOptions - Query filter options.
675
- * @param queryOptions.networks - Networks to filter by.
676
- * @param options - Fetch options including cache settings.
677
- * @returns The tokens response.
678
- */
679
- async fetchV2AccountTokens(address, queryOptions, options) {
680
- if (address === '') {
681
- return { data: [] };
682
- }
683
- return this.queryClient.fetchQuery(this.getV2AccountTokensQueryOptions(address, queryOptions, options));
488
+ });
684
489
  }
685
490
  }
686
491
  exports.AccountsApiClient = AccountsApiClient;