@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.
- package/CHANGELOG.md +0 -23
- package/README.md +55 -60
- package/dist/api/accounts/client.cjs +163 -358
- package/dist/api/accounts/client.cjs.map +1 -1
- package/dist/api/accounts/client.d.cts +12 -198
- package/dist/api/accounts/client.d.cts.map +1 -1
- package/dist/api/accounts/client.d.mts +12 -198
- package/dist/api/accounts/client.d.mts.map +1 -1
- package/dist/api/accounts/client.mjs +164 -359
- package/dist/api/accounts/client.mjs.map +1 -1
- package/dist/api/index.cjs +1 -2
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +1 -1
- package/dist/api/index.d.cts.map +1 -1
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.d.mts.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/prices/client.cjs +140 -398
- package/dist/api/prices/client.cjs.map +1 -1
- package/dist/api/prices/client.d.cts +3 -215
- package/dist/api/prices/client.d.cts.map +1 -1
- package/dist/api/prices/client.d.mts +3 -215
- package/dist/api/prices/client.d.mts.map +1 -1
- package/dist/api/prices/client.mjs +140 -398
- package/dist/api/prices/client.mjs.map +1 -1
- package/dist/api/shared-types.cjs +1 -18
- package/dist/api/shared-types.cjs.map +1 -1
- package/dist/api/shared-types.d.cts +3 -23
- package/dist/api/shared-types.d.cts.map +1 -1
- package/dist/api/shared-types.d.mts +3 -23
- package/dist/api/shared-types.d.mts.map +1 -1
- package/dist/api/shared-types.mjs +0 -16
- package/dist/api/shared-types.mjs.map +1 -1
- package/dist/api/token/client.cjs +77 -232
- package/dist/api/token/client.cjs.map +1 -1
- package/dist/api/token/client.d.cts +0 -165
- package/dist/api/token/client.d.cts.map +1 -1
- package/dist/api/token/client.d.mts +0 -165
- package/dist/api/token/client.d.mts.map +1 -1
- package/dist/api/token/client.mjs +77 -232
- package/dist/api/token/client.mjs.map +1 -1
- package/dist/api/tokens/client.cjs +23 -64
- package/dist/api/tokens/client.cjs.map +1 -1
- package/dist/api/tokens/client.d.cts +0 -24
- package/dist/api/tokens/client.d.cts.map +1 -1
- package/dist/api/tokens/client.d.mts +0 -24
- package/dist/api/tokens/client.d.mts.map +1 -1
- package/dist/api/tokens/client.mjs +23 -64
- package/dist/api/tokens/client.mjs.map +1 -1
- package/dist/index.cjs +1 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/dist/ApiPlatformClientService-method-action-types.cjs +0 -7
- package/dist/ApiPlatformClientService-method-action-types.cjs.map +0 -1
- package/dist/ApiPlatformClientService-method-action-types.d.cts +0 -21
- package/dist/ApiPlatformClientService-method-action-types.d.cts.map +0 -1
- package/dist/ApiPlatformClientService-method-action-types.d.mts +0 -21
- package/dist/ApiPlatformClientService-method-action-types.d.mts.map +0 -1
- package/dist/ApiPlatformClientService-method-action-types.mjs +0 -6
- package/dist/ApiPlatformClientService-method-action-types.mjs.map +0 -1
- package/dist/ApiPlatformClientService.cjs +0 -82
- package/dist/ApiPlatformClientService.cjs.map +0 -1
- package/dist/ApiPlatformClientService.d.cts +0 -86
- package/dist/ApiPlatformClientService.d.cts.map +0 -1
- package/dist/ApiPlatformClientService.d.mts +0 -86
- package/dist/ApiPlatformClientService.d.mts.map +0 -1
- package/dist/ApiPlatformClientService.mjs +0 -78
- 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
|
-
*
|
|
45
|
+
* Get list of supported networks (v1 endpoint).
|
|
47
46
|
*
|
|
48
47
|
* @param options - Fetch options including cache settings.
|
|
49
|
-
* @returns
|
|
48
|
+
* @returns The list of supported networks.
|
|
50
49
|
*/
|
|
51
|
-
|
|
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 (
|
|
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
|
|
67
|
-
return this.queryClient.fetchQuery(
|
|
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
|
-
*
|
|
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
|
|
83
|
+
* @returns The active networks response.
|
|
105
84
|
*/
|
|
106
|
-
|
|
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:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
*
|
|
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
|
|
120
|
+
* @returns The account balances response.
|
|
167
121
|
*/
|
|
168
|
-
|
|
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:
|
|
185
|
-
|
|
186
|
-
|
|
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
|
|
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
|
|
216
|
-
|
|
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
|
-
'
|
|
161
|
+
'v2',
|
|
236
162
|
{
|
|
237
|
-
|
|
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:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
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
|
-
'
|
|
199
|
+
'v4',
|
|
293
200
|
{
|
|
294
|
-
|
|
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:
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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
|
-
*
|
|
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
|
|
271
|
+
* @returns The transaction details.
|
|
352
272
|
*/
|
|
353
|
-
|
|
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
|
-
*
|
|
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
|
|
305
|
+
* @returns The account transactions response.
|
|
403
306
|
*/
|
|
404
|
-
|
|
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:
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
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 (
|
|
336
|
+
* Get multi-account transactions (v4 endpoint).
|
|
440
337
|
*
|
|
441
|
-
* @param
|
|
338
|
+
* @param accountIds - Array of CAIP-10 account IDs.
|
|
442
339
|
* @param queryOptions - Query filter options.
|
|
443
|
-
* @param queryOptions.
|
|
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
|
|
347
|
+
* @returns The multi-account transactions response.
|
|
478
348
|
*/
|
|
479
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
*
|
|
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
|
|
431
|
+
* @returns The NFTs response.
|
|
584
432
|
*/
|
|
585
|
-
|
|
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:
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
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
|
-
*
|
|
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
|
|
467
|
+
* @returns The tokens response.
|
|
642
468
|
*/
|
|
643
|
-
|
|
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:
|
|
657
|
-
|
|
658
|
-
|
|
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;
|