@imtbl/sdk 0.1.7 → 0.1.8-alpha.1

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.
@@ -0,0 +1,1258 @@
1
+ import globalAxios from 'axios';
2
+
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /**
6
+ * Immutable X API
7
+ * Immutable Multi Rollup API
8
+ *
9
+ * The version of the OpenAPI document: 1.0.0
10
+ * Contact: support@immutable.com
11
+ *
12
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
13
+ * https://openapi-generator.tech
14
+ * Do not edit the class manually.
15
+ */
16
+ // Some imports not used depending on template conditions
17
+ // @ts-ignore
18
+ const BASE_PATH = "https://indexer-mr.dev.imtbl.com".replace(/\/+$/, "");
19
+ /**
20
+ *
21
+ * @export
22
+ * @class BaseAPI
23
+ */
24
+ class BaseAPI {
25
+ basePath;
26
+ axios;
27
+ configuration;
28
+ constructor(configuration, basePath = BASE_PATH, axios = globalAxios) {
29
+ this.basePath = basePath;
30
+ this.axios = axios;
31
+ if (configuration) {
32
+ this.configuration = configuration;
33
+ this.basePath = configuration.basePath || this.basePath;
34
+ }
35
+ }
36
+ }
37
+ /**
38
+ *
39
+ * @export
40
+ * @class RequiredError
41
+ * @extends {Error}
42
+ */
43
+ class RequiredError extends Error {
44
+ field;
45
+ name = "RequiredError";
46
+ constructor(field, msg) {
47
+ super(msg);
48
+ this.field = field;
49
+ }
50
+ }
51
+
52
+ /* tslint:disable */
53
+ /* eslint-disable */
54
+ /**
55
+ * Immutable X API
56
+ * Immutable Multi Rollup API
57
+ *
58
+ * The version of the OpenAPI document: 1.0.0
59
+ * Contact: support@immutable.com
60
+ *
61
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
62
+ * https://openapi-generator.tech
63
+ * Do not edit the class manually.
64
+ */
65
+ /**
66
+ *
67
+ * @export
68
+ */
69
+ const DUMMY_BASE_URL = 'https://example.com';
70
+ /**
71
+ *
72
+ * @throws {RequiredError}
73
+ * @export
74
+ */
75
+ const assertParamExists = function (functionName, paramName, paramValue) {
76
+ if (paramValue === null || paramValue === undefined) {
77
+ throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
78
+ }
79
+ };
80
+ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
81
+ if (typeof parameter === "object") {
82
+ if (Array.isArray(parameter)) {
83
+ parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
84
+ }
85
+ else {
86
+ Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
87
+ }
88
+ }
89
+ else {
90
+ if (urlSearchParams.has(key)) {
91
+ urlSearchParams.append(key, parameter);
92
+ }
93
+ else {
94
+ urlSearchParams.set(key, parameter);
95
+ }
96
+ }
97
+ }
98
+ /**
99
+ *
100
+ * @export
101
+ */
102
+ const setSearchParams = function (url, ...objects) {
103
+ const searchParams = new URLSearchParams(url.search);
104
+ setFlattenedQueryParams(searchParams, objects);
105
+ url.search = searchParams.toString();
106
+ };
107
+ /**
108
+ *
109
+ * @export
110
+ */
111
+ const toPathString = function (url) {
112
+ return url.pathname + url.search + url.hash;
113
+ };
114
+ /**
115
+ *
116
+ * @export
117
+ */
118
+ const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
119
+ return (axios = globalAxios, basePath = BASE_PATH) => {
120
+ const axiosRequestArgs = { ...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url };
121
+ return axios.request(axiosRequestArgs);
122
+ };
123
+ };
124
+
125
+ /* tslint:disable */
126
+ /* eslint-disable */
127
+ /**
128
+ * Immutable X API
129
+ * Immutable Multi Rollup API
130
+ *
131
+ * The version of the OpenAPI document: 1.0.0
132
+ * Contact: support@immutable.com
133
+ *
134
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
135
+ * https://openapi-generator.tech
136
+ * Do not edit the class manually.
137
+ */
138
+ /**
139
+ * ActivitiesApi - axios parameter creator
140
+ * @export
141
+ */
142
+ const ActivitiesApiAxiosParamCreator = function (configuration) {
143
+ return {
144
+ /**
145
+ * Get a single activity by ID
146
+ * @summary Get a single activity by ID
147
+ * @param {string} chainName The name of chain
148
+ * @param {string} activityId The id of activity
149
+ * @param {*} [options] Override http request option.
150
+ * @throws {RequiredError}
151
+ */
152
+ getActivity: async (chainName, activityId, options = {}) => {
153
+ // verify required parameter 'chainName' is not null or undefined
154
+ assertParamExists('getActivity', 'chainName', chainName);
155
+ // verify required parameter 'activityId' is not null or undefined
156
+ assertParamExists('getActivity', 'activityId', activityId);
157
+ const localVarPath = `/v1/chains/{chain_name}/activities/{activity_id}`
158
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)))
159
+ .replace(`{${"activity_id"}}`, encodeURIComponent(String(activityId)));
160
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
161
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
162
+ let baseOptions;
163
+ if (configuration) {
164
+ baseOptions = configuration.baseOptions;
165
+ }
166
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
167
+ const localVarHeaderParameter = {};
168
+ const localVarQueryParameter = {};
169
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
170
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
171
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
172
+ return {
173
+ url: toPathString(localVarUrlObj),
174
+ options: localVarRequestOptions,
175
+ };
176
+ },
177
+ /**
178
+ * List all activities
179
+ * @summary List all activities
180
+ * @param {string} chainName The name of chain
181
+ * @param {string} [contractAddress] The contract address of NFT or ERC20 Token
182
+ * @param {string} [tokenId] An `uint256` token id as string
183
+ * @param {string} [accountAddress] The account address activity contains
184
+ * @param {ActivityType} [activityType] The activity type
185
+ * @param {string} [fromIndexedAt] From indexed at including given date
186
+ * @param {string} [toIndexedAt] To indexed at including given date
187
+ * @param {string} [transactionHash] The transaction hash of activity
188
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
189
+ * @param {number} [pageSize] Maximum number of items to return
190
+ * @param {*} [options] Override http request option.
191
+ * @throws {RequiredError}
192
+ */
193
+ listActivities: async (chainName, contractAddress, tokenId, accountAddress, activityType, fromIndexedAt, toIndexedAt, transactionHash, pageCursor, pageSize, options = {}) => {
194
+ // verify required parameter 'chainName' is not null or undefined
195
+ assertParamExists('listActivities', 'chainName', chainName);
196
+ const localVarPath = `/v1/chains/{chain_name}/activities`
197
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
198
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
199
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
200
+ let baseOptions;
201
+ if (configuration) {
202
+ baseOptions = configuration.baseOptions;
203
+ }
204
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
205
+ const localVarHeaderParameter = {};
206
+ const localVarQueryParameter = {};
207
+ if (contractAddress !== undefined) {
208
+ localVarQueryParameter['contract_address'] = contractAddress;
209
+ }
210
+ if (tokenId !== undefined) {
211
+ localVarQueryParameter['token_id'] = tokenId;
212
+ }
213
+ if (accountAddress !== undefined) {
214
+ localVarQueryParameter['account_address'] = accountAddress;
215
+ }
216
+ if (activityType !== undefined) {
217
+ localVarQueryParameter['activity_type'] = activityType;
218
+ }
219
+ if (fromIndexedAt !== undefined) {
220
+ localVarQueryParameter['from_indexed_at'] = (fromIndexedAt instanceof Date) ?
221
+ fromIndexedAt.toISOString() :
222
+ fromIndexedAt;
223
+ }
224
+ if (toIndexedAt !== undefined) {
225
+ localVarQueryParameter['to_indexed_at'] = (toIndexedAt instanceof Date) ?
226
+ toIndexedAt.toISOString() :
227
+ toIndexedAt;
228
+ }
229
+ if (transactionHash !== undefined) {
230
+ localVarQueryParameter['transaction_hash'] = transactionHash;
231
+ }
232
+ if (pageCursor !== undefined) {
233
+ localVarQueryParameter['page_cursor'] = pageCursor;
234
+ }
235
+ if (pageSize !== undefined) {
236
+ localVarQueryParameter['page_size'] = pageSize;
237
+ }
238
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
239
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
240
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
241
+ return {
242
+ url: toPathString(localVarUrlObj),
243
+ options: localVarRequestOptions,
244
+ };
245
+ },
246
+ };
247
+ };
248
+ /**
249
+ * ActivitiesApi - functional programming interface
250
+ * @export
251
+ */
252
+ const ActivitiesApiFp = function (configuration) {
253
+ const localVarAxiosParamCreator = ActivitiesApiAxiosParamCreator(configuration);
254
+ return {
255
+ /**
256
+ * Get a single activity by ID
257
+ * @summary Get a single activity by ID
258
+ * @param {string} chainName The name of chain
259
+ * @param {string} activityId The id of activity
260
+ * @param {*} [options] Override http request option.
261
+ * @throws {RequiredError}
262
+ */
263
+ async getActivity(chainName, activityId, options) {
264
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getActivity(chainName, activityId, options);
265
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
266
+ },
267
+ /**
268
+ * List all activities
269
+ * @summary List all activities
270
+ * @param {string} chainName The name of chain
271
+ * @param {string} [contractAddress] The contract address of NFT or ERC20 Token
272
+ * @param {string} [tokenId] An `uint256` token id as string
273
+ * @param {string} [accountAddress] The account address activity contains
274
+ * @param {ActivityType} [activityType] The activity type
275
+ * @param {string} [fromIndexedAt] From indexed at including given date
276
+ * @param {string} [toIndexedAt] To indexed at including given date
277
+ * @param {string} [transactionHash] The transaction hash of activity
278
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
279
+ * @param {number} [pageSize] Maximum number of items to return
280
+ * @param {*} [options] Override http request option.
281
+ * @throws {RequiredError}
282
+ */
283
+ async listActivities(chainName, contractAddress, tokenId, accountAddress, activityType, fromIndexedAt, toIndexedAt, transactionHash, pageCursor, pageSize, options) {
284
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listActivities(chainName, contractAddress, tokenId, accountAddress, activityType, fromIndexedAt, toIndexedAt, transactionHash, pageCursor, pageSize, options);
285
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
286
+ },
287
+ };
288
+ };
289
+ /**
290
+ * ActivitiesApi - object-oriented interface
291
+ * @export
292
+ * @class ActivitiesApi
293
+ * @extends {BaseAPI}
294
+ */
295
+ class ActivitiesApi extends BaseAPI {
296
+ /**
297
+ * Get a single activity by ID
298
+ * @summary Get a single activity by ID
299
+ * @param {ActivitiesApiGetActivityRequest} requestParameters Request parameters.
300
+ * @param {*} [options] Override http request option.
301
+ * @throws {RequiredError}
302
+ * @memberof ActivitiesApi
303
+ */
304
+ getActivity(requestParameters, options) {
305
+ return ActivitiesApiFp(this.configuration).getActivity(requestParameters.chainName, requestParameters.activityId, options).then((request) => request(this.axios, this.basePath));
306
+ }
307
+ /**
308
+ * List all activities
309
+ * @summary List all activities
310
+ * @param {ActivitiesApiListActivitiesRequest} requestParameters Request parameters.
311
+ * @param {*} [options] Override http request option.
312
+ * @throws {RequiredError}
313
+ * @memberof ActivitiesApi
314
+ */
315
+ listActivities(requestParameters, options) {
316
+ return ActivitiesApiFp(this.configuration).listActivities(requestParameters.chainName, requestParameters.contractAddress, requestParameters.tokenId, requestParameters.accountAddress, requestParameters.activityType, requestParameters.fromIndexedAt, requestParameters.toIndexedAt, requestParameters.transactionHash, requestParameters.pageCursor, requestParameters.pageSize, options).then((request) => request(this.axios, this.basePath));
317
+ }
318
+ }
319
+
320
+ /* tslint:disable */
321
+ /* eslint-disable */
322
+ /**
323
+ * Immutable X API
324
+ * Immutable Multi Rollup API
325
+ *
326
+ * The version of the OpenAPI document: 1.0.0
327
+ * Contact: support@immutable.com
328
+ *
329
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
330
+ * https://openapi-generator.tech
331
+ * Do not edit the class manually.
332
+ */
333
+ /**
334
+ * ChainsApi - axios parameter creator
335
+ * @export
336
+ */
337
+ const ChainsApiAxiosParamCreator = function (configuration) {
338
+ return {
339
+ /**
340
+ * List supported chains
341
+ * @summary List supported chains
342
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
343
+ * @param {number} [pageSize] Maximum number of items to return
344
+ * @param {*} [options] Override http request option.
345
+ * @throws {RequiredError}
346
+ */
347
+ listChains: async (pageCursor, pageSize, options = {}) => {
348
+ const localVarPath = `/v1/chains`;
349
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
350
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
351
+ let baseOptions;
352
+ if (configuration) {
353
+ baseOptions = configuration.baseOptions;
354
+ }
355
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
356
+ const localVarHeaderParameter = {};
357
+ const localVarQueryParameter = {};
358
+ if (pageCursor !== undefined) {
359
+ localVarQueryParameter['page_cursor'] = pageCursor;
360
+ }
361
+ if (pageSize !== undefined) {
362
+ localVarQueryParameter['page_size'] = pageSize;
363
+ }
364
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
365
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
366
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
367
+ return {
368
+ url: toPathString(localVarUrlObj),
369
+ options: localVarRequestOptions,
370
+ };
371
+ },
372
+ };
373
+ };
374
+ /**
375
+ * ChainsApi - functional programming interface
376
+ * @export
377
+ */
378
+ const ChainsApiFp = function (configuration) {
379
+ const localVarAxiosParamCreator = ChainsApiAxiosParamCreator(configuration);
380
+ return {
381
+ /**
382
+ * List supported chains
383
+ * @summary List supported chains
384
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
385
+ * @param {number} [pageSize] Maximum number of items to return
386
+ * @param {*} [options] Override http request option.
387
+ * @throws {RequiredError}
388
+ */
389
+ async listChains(pageCursor, pageSize, options) {
390
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listChains(pageCursor, pageSize, options);
391
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
392
+ },
393
+ };
394
+ };
395
+ /**
396
+ * ChainsApi - object-oriented interface
397
+ * @export
398
+ * @class ChainsApi
399
+ * @extends {BaseAPI}
400
+ */
401
+ class ChainsApi extends BaseAPI {
402
+ /**
403
+ * List supported chains
404
+ * @summary List supported chains
405
+ * @param {ChainsApiListChainsRequest} requestParameters Request parameters.
406
+ * @param {*} [options] Override http request option.
407
+ * @throws {RequiredError}
408
+ * @memberof ChainsApi
409
+ */
410
+ listChains(requestParameters = {}, options) {
411
+ return ChainsApiFp(this.configuration).listChains(requestParameters.pageCursor, requestParameters.pageSize, options).then((request) => request(this.axios, this.basePath));
412
+ }
413
+ }
414
+
415
+ /* tslint:disable */
416
+ /* eslint-disable */
417
+ /**
418
+ * Immutable X API
419
+ * Immutable Multi Rollup API
420
+ *
421
+ * The version of the OpenAPI document: 1.0.0
422
+ * Contact: support@immutable.com
423
+ *
424
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
425
+ * https://openapi-generator.tech
426
+ * Do not edit the class manually.
427
+ */
428
+ /**
429
+ * CollectionsApi - axios parameter creator
430
+ * @export
431
+ */
432
+ const CollectionsApiAxiosParamCreator = function (configuration) {
433
+ return {
434
+ /**
435
+ * Get collection by contract address
436
+ * @summary Get collection by contract address
437
+ * @param {string} contractAddress The address contract
438
+ * @param {string} chainName The name of chain
439
+ * @param {*} [options] Override http request option.
440
+ * @throws {RequiredError}
441
+ */
442
+ getCollection: async (contractAddress, chainName, options = {}) => {
443
+ // verify required parameter 'contractAddress' is not null or undefined
444
+ assertParamExists('getCollection', 'contractAddress', contractAddress);
445
+ // verify required parameter 'chainName' is not null or undefined
446
+ assertParamExists('getCollection', 'chainName', chainName);
447
+ const localVarPath = `/v1/chains/{chain_name}/collections/{contract_address}`
448
+ .replace(`{${"contract_address"}}`, encodeURIComponent(String(contractAddress)))
449
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
450
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
451
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
452
+ let baseOptions;
453
+ if (configuration) {
454
+ baseOptions = configuration.baseOptions;
455
+ }
456
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
457
+ const localVarHeaderParameter = {};
458
+ const localVarQueryParameter = {};
459
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
460
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
461
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
462
+ return {
463
+ url: toPathString(localVarUrlObj),
464
+ options: localVarRequestOptions,
465
+ };
466
+ },
467
+ /**
468
+ * List all collections
469
+ * @summary List all collections
470
+ * @param {string} chainName The name of chain
471
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
472
+ * @param {number} [pageSize] Maximum number of items to return
473
+ * @param {*} [options] Override http request option.
474
+ * @throws {RequiredError}
475
+ */
476
+ listCollections: async (chainName, pageCursor, pageSize, options = {}) => {
477
+ // verify required parameter 'chainName' is not null or undefined
478
+ assertParamExists('listCollections', 'chainName', chainName);
479
+ const localVarPath = `/v1/chains/{chain_name}/collections`
480
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
481
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
482
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
483
+ let baseOptions;
484
+ if (configuration) {
485
+ baseOptions = configuration.baseOptions;
486
+ }
487
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
488
+ const localVarHeaderParameter = {};
489
+ const localVarQueryParameter = {};
490
+ if (pageCursor !== undefined) {
491
+ localVarQueryParameter['page_cursor'] = pageCursor;
492
+ }
493
+ if (pageSize !== undefined) {
494
+ localVarQueryParameter['page_size'] = pageSize;
495
+ }
496
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
497
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
498
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
499
+ return {
500
+ url: toPathString(localVarUrlObj),
501
+ options: localVarRequestOptions,
502
+ };
503
+ },
504
+ };
505
+ };
506
+ /**
507
+ * CollectionsApi - functional programming interface
508
+ * @export
509
+ */
510
+ const CollectionsApiFp = function (configuration) {
511
+ const localVarAxiosParamCreator = CollectionsApiAxiosParamCreator(configuration);
512
+ return {
513
+ /**
514
+ * Get collection by contract address
515
+ * @summary Get collection by contract address
516
+ * @param {string} contractAddress The address contract
517
+ * @param {string} chainName The name of chain
518
+ * @param {*} [options] Override http request option.
519
+ * @throws {RequiredError}
520
+ */
521
+ async getCollection(contractAddress, chainName, options) {
522
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getCollection(contractAddress, chainName, options);
523
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
524
+ },
525
+ /**
526
+ * List all collections
527
+ * @summary List all collections
528
+ * @param {string} chainName The name of chain
529
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
530
+ * @param {number} [pageSize] Maximum number of items to return
531
+ * @param {*} [options] Override http request option.
532
+ * @throws {RequiredError}
533
+ */
534
+ async listCollections(chainName, pageCursor, pageSize, options) {
535
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listCollections(chainName, pageCursor, pageSize, options);
536
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
537
+ },
538
+ };
539
+ };
540
+ /**
541
+ * CollectionsApi - object-oriented interface
542
+ * @export
543
+ * @class CollectionsApi
544
+ * @extends {BaseAPI}
545
+ */
546
+ class CollectionsApi extends BaseAPI {
547
+ /**
548
+ * Get collection by contract address
549
+ * @summary Get collection by contract address
550
+ * @param {CollectionsApiGetCollectionRequest} requestParameters Request parameters.
551
+ * @param {*} [options] Override http request option.
552
+ * @throws {RequiredError}
553
+ * @memberof CollectionsApi
554
+ */
555
+ getCollection(requestParameters, options) {
556
+ return CollectionsApiFp(this.configuration).getCollection(requestParameters.contractAddress, requestParameters.chainName, options).then((request) => request(this.axios, this.basePath));
557
+ }
558
+ /**
559
+ * List all collections
560
+ * @summary List all collections
561
+ * @param {CollectionsApiListCollectionsRequest} requestParameters Request parameters.
562
+ * @param {*} [options] Override http request option.
563
+ * @throws {RequiredError}
564
+ * @memberof CollectionsApi
565
+ */
566
+ listCollections(requestParameters, options) {
567
+ return CollectionsApiFp(this.configuration).listCollections(requestParameters.chainName, requestParameters.pageCursor, requestParameters.pageSize, options).then((request) => request(this.axios, this.basePath));
568
+ }
569
+ }
570
+
571
+ /* tslint:disable */
572
+ /* eslint-disable */
573
+ /**
574
+ * Immutable X API
575
+ * Immutable Multi Rollup API
576
+ *
577
+ * The version of the OpenAPI document: 1.0.0
578
+ * Contact: support@immutable.com
579
+ *
580
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
581
+ * https://openapi-generator.tech
582
+ * Do not edit the class manually.
583
+ */
584
+ /**
585
+ * NftOwnersApi - axios parameter creator
586
+ * @export
587
+ */
588
+ const NftOwnersApiAxiosParamCreator = function (configuration) {
589
+ return {
590
+ /**
591
+ * List NFT owners by token ID
592
+ * @summary List NFT owners by token ID
593
+ * @param {string} contractAddress The address of contract
594
+ * @param {string} tokenId An `uint256` token id as string
595
+ * @param {string} chainName The name of chain
596
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
597
+ * @param {number} [pageSize] Maximum number of items to return
598
+ * @param {*} [options] Override http request option.
599
+ * @throws {RequiredError}
600
+ */
601
+ listNFTOwners: async (contractAddress, tokenId, chainName, pageCursor, pageSize, options = {}) => {
602
+ // verify required parameter 'contractAddress' is not null or undefined
603
+ assertParamExists('listNFTOwners', 'contractAddress', contractAddress);
604
+ // verify required parameter 'tokenId' is not null or undefined
605
+ assertParamExists('listNFTOwners', 'tokenId', tokenId);
606
+ // verify required parameter 'chainName' is not null or undefined
607
+ assertParamExists('listNFTOwners', 'chainName', chainName);
608
+ const localVarPath = `/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}/owners`
609
+ .replace(`{${"contract_address"}}`, encodeURIComponent(String(contractAddress)))
610
+ .replace(`{${"token_id"}}`, encodeURIComponent(String(tokenId)))
611
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
612
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
613
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
614
+ let baseOptions;
615
+ if (configuration) {
616
+ baseOptions = configuration.baseOptions;
617
+ }
618
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
619
+ const localVarHeaderParameter = {};
620
+ const localVarQueryParameter = {};
621
+ if (pageCursor !== undefined) {
622
+ localVarQueryParameter['page_cursor'] = pageCursor;
623
+ }
624
+ if (pageSize !== undefined) {
625
+ localVarQueryParameter['page_size'] = pageSize;
626
+ }
627
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
628
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
629
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
630
+ return {
631
+ url: toPathString(localVarUrlObj),
632
+ options: localVarRequestOptions,
633
+ };
634
+ },
635
+ };
636
+ };
637
+ /**
638
+ * NftOwnersApi - functional programming interface
639
+ * @export
640
+ */
641
+ const NftOwnersApiFp = function (configuration) {
642
+ const localVarAxiosParamCreator = NftOwnersApiAxiosParamCreator(configuration);
643
+ return {
644
+ /**
645
+ * List NFT owners by token ID
646
+ * @summary List NFT owners by token ID
647
+ * @param {string} contractAddress The address of contract
648
+ * @param {string} tokenId An `uint256` token id as string
649
+ * @param {string} chainName The name of chain
650
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
651
+ * @param {number} [pageSize] Maximum number of items to return
652
+ * @param {*} [options] Override http request option.
653
+ * @throws {RequiredError}
654
+ */
655
+ async listNFTOwners(contractAddress, tokenId, chainName, pageCursor, pageSize, options) {
656
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listNFTOwners(contractAddress, tokenId, chainName, pageCursor, pageSize, options);
657
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
658
+ },
659
+ };
660
+ };
661
+ /**
662
+ * NftOwnersApi - object-oriented interface
663
+ * @export
664
+ * @class NftOwnersApi
665
+ * @extends {BaseAPI}
666
+ */
667
+ class NftOwnersApi extends BaseAPI {
668
+ /**
669
+ * List NFT owners by token ID
670
+ * @summary List NFT owners by token ID
671
+ * @param {NftOwnersApiListNFTOwnersRequest} requestParameters Request parameters.
672
+ * @param {*} [options] Override http request option.
673
+ * @throws {RequiredError}
674
+ * @memberof NftOwnersApi
675
+ */
676
+ listNFTOwners(requestParameters, options) {
677
+ return NftOwnersApiFp(this.configuration).listNFTOwners(requestParameters.contractAddress, requestParameters.tokenId, requestParameters.chainName, requestParameters.pageCursor, requestParameters.pageSize, options).then((request) => request(this.axios, this.basePath));
678
+ }
679
+ }
680
+
681
+ /* tslint:disable */
682
+ /* eslint-disable */
683
+ /**
684
+ * Immutable X API
685
+ * Immutable Multi Rollup API
686
+ *
687
+ * The version of the OpenAPI document: 1.0.0
688
+ * Contact: support@immutable.com
689
+ *
690
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
691
+ * https://openapi-generator.tech
692
+ * Do not edit the class manually.
693
+ */
694
+ /**
695
+ * NftsApi - axios parameter creator
696
+ * @export
697
+ */
698
+ const NftsApiAxiosParamCreator = function (configuration) {
699
+ return {
700
+ /**
701
+ * Get NFT by token ID
702
+ * @summary Get NFT by token ID
703
+ * @param {string} contractAddress The address of NFT contract
704
+ * @param {string} tokenId An `uint256` token id as string
705
+ * @param {string} chainName The name of chain
706
+ * @param {*} [options] Override http request option.
707
+ * @throws {RequiredError}
708
+ */
709
+ getNFT: async (contractAddress, tokenId, chainName, options = {}) => {
710
+ // verify required parameter 'contractAddress' is not null or undefined
711
+ assertParamExists('getNFT', 'contractAddress', contractAddress);
712
+ // verify required parameter 'tokenId' is not null or undefined
713
+ assertParamExists('getNFT', 'tokenId', tokenId);
714
+ // verify required parameter 'chainName' is not null or undefined
715
+ assertParamExists('getNFT', 'chainName', chainName);
716
+ const localVarPath = `/v1/chains/{chain_name}/collections/{contract_address}/nfts/{token_id}`
717
+ .replace(`{${"contract_address"}}`, encodeURIComponent(String(contractAddress)))
718
+ .replace(`{${"token_id"}}`, encodeURIComponent(String(tokenId)))
719
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
720
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
721
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
722
+ let baseOptions;
723
+ if (configuration) {
724
+ baseOptions = configuration.baseOptions;
725
+ }
726
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
727
+ const localVarHeaderParameter = {};
728
+ const localVarQueryParameter = {};
729
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
730
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
731
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
732
+ return {
733
+ url: toPathString(localVarUrlObj),
734
+ options: localVarRequestOptions,
735
+ };
736
+ },
737
+ /**
738
+ * List NFTs by contract address
739
+ * @summary List NFTs by contract address
740
+ * @param {string} contractAddress Contract address
741
+ * @param {string} chainName The name of chain
742
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
743
+ * @param {number} [pageSize] Maximum number of items to return
744
+ * @param {*} [options] Override http request option.
745
+ * @throws {RequiredError}
746
+ */
747
+ listNFTs: async (contractAddress, chainName, pageCursor, pageSize, options = {}) => {
748
+ // verify required parameter 'contractAddress' is not null or undefined
749
+ assertParamExists('listNFTs', 'contractAddress', contractAddress);
750
+ // verify required parameter 'chainName' is not null or undefined
751
+ assertParamExists('listNFTs', 'chainName', chainName);
752
+ const localVarPath = `/v1/chains/{chain_name}/collections/{contract_address}/nfts`
753
+ .replace(`{${"contract_address"}}`, encodeURIComponent(String(contractAddress)))
754
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
755
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
756
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
757
+ let baseOptions;
758
+ if (configuration) {
759
+ baseOptions = configuration.baseOptions;
760
+ }
761
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
762
+ const localVarHeaderParameter = {};
763
+ const localVarQueryParameter = {};
764
+ if (pageCursor !== undefined) {
765
+ localVarQueryParameter['page_cursor'] = pageCursor;
766
+ }
767
+ if (pageSize !== undefined) {
768
+ localVarQueryParameter['page_size'] = pageSize;
769
+ }
770
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
771
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
772
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
773
+ return {
774
+ url: toPathString(localVarUrlObj),
775
+ options: localVarRequestOptions,
776
+ };
777
+ },
778
+ /**
779
+ * List NFTs by account address
780
+ * @summary List NFTs by account address
781
+ * @param {string} accountAddress Account address
782
+ * @param {string} chainName The name of chain
783
+ * @param {string} [contractAddress] The address of contract
784
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
785
+ * @param {number} [pageSize] Maximum number of items to return
786
+ * @param {*} [options] Override http request option.
787
+ * @throws {RequiredError}
788
+ */
789
+ listNFTsByAccountAddress: async (accountAddress, chainName, contractAddress, pageCursor, pageSize, options = {}) => {
790
+ // verify required parameter 'accountAddress' is not null or undefined
791
+ assertParamExists('listNFTsByAccountAddress', 'accountAddress', accountAddress);
792
+ // verify required parameter 'chainName' is not null or undefined
793
+ assertParamExists('listNFTsByAccountAddress', 'chainName', chainName);
794
+ const localVarPath = `/v1/chains/{chain_name}/accounts/{account_address}/nfts`
795
+ .replace(`{${"account_address"}}`, encodeURIComponent(String(accountAddress)))
796
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
797
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
798
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
799
+ let baseOptions;
800
+ if (configuration) {
801
+ baseOptions = configuration.baseOptions;
802
+ }
803
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
804
+ const localVarHeaderParameter = {};
805
+ const localVarQueryParameter = {};
806
+ if (contractAddress !== undefined) {
807
+ localVarQueryParameter['contract_address'] = contractAddress;
808
+ }
809
+ if (pageCursor !== undefined) {
810
+ localVarQueryParameter['page_cursor'] = pageCursor;
811
+ }
812
+ if (pageSize !== undefined) {
813
+ localVarQueryParameter['page_size'] = pageSize;
814
+ }
815
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
816
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
817
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
818
+ return {
819
+ url: toPathString(localVarUrlObj),
820
+ options: localVarRequestOptions,
821
+ };
822
+ },
823
+ };
824
+ };
825
+ /**
826
+ * NftsApi - functional programming interface
827
+ * @export
828
+ */
829
+ const NftsApiFp = function (configuration) {
830
+ const localVarAxiosParamCreator = NftsApiAxiosParamCreator(configuration);
831
+ return {
832
+ /**
833
+ * Get NFT by token ID
834
+ * @summary Get NFT by token ID
835
+ * @param {string} contractAddress The address of NFT contract
836
+ * @param {string} tokenId An `uint256` token id as string
837
+ * @param {string} chainName The name of chain
838
+ * @param {*} [options] Override http request option.
839
+ * @throws {RequiredError}
840
+ */
841
+ async getNFT(contractAddress, tokenId, chainName, options) {
842
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getNFT(contractAddress, tokenId, chainName, options);
843
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
844
+ },
845
+ /**
846
+ * List NFTs by contract address
847
+ * @summary List NFTs by contract address
848
+ * @param {string} contractAddress Contract address
849
+ * @param {string} chainName The name of chain
850
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
851
+ * @param {number} [pageSize] Maximum number of items to return
852
+ * @param {*} [options] Override http request option.
853
+ * @throws {RequiredError}
854
+ */
855
+ async listNFTs(contractAddress, chainName, pageCursor, pageSize, options) {
856
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listNFTs(contractAddress, chainName, pageCursor, pageSize, options);
857
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
858
+ },
859
+ /**
860
+ * List NFTs by account address
861
+ * @summary List NFTs by account address
862
+ * @param {string} accountAddress Account address
863
+ * @param {string} chainName The name of chain
864
+ * @param {string} [contractAddress] The address of contract
865
+ * @param {string} [pageCursor] Base64 encoded page cursor to retrieve previous or next page. Use the value returned in the response.
866
+ * @param {number} [pageSize] Maximum number of items to return
867
+ * @param {*} [options] Override http request option.
868
+ * @throws {RequiredError}
869
+ */
870
+ async listNFTsByAccountAddress(accountAddress, chainName, contractAddress, pageCursor, pageSize, options) {
871
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listNFTsByAccountAddress(accountAddress, chainName, contractAddress, pageCursor, pageSize, options);
872
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
873
+ },
874
+ };
875
+ };
876
+ /**
877
+ * NftsApi - object-oriented interface
878
+ * @export
879
+ * @class NftsApi
880
+ * @extends {BaseAPI}
881
+ */
882
+ class NftsApi extends BaseAPI {
883
+ /**
884
+ * Get NFT by token ID
885
+ * @summary Get NFT by token ID
886
+ * @param {NftsApiGetNFTRequest} requestParameters Request parameters.
887
+ * @param {*} [options] Override http request option.
888
+ * @throws {RequiredError}
889
+ * @memberof NftsApi
890
+ */
891
+ getNFT(requestParameters, options) {
892
+ return NftsApiFp(this.configuration).getNFT(requestParameters.contractAddress, requestParameters.tokenId, requestParameters.chainName, options).then((request) => request(this.axios, this.basePath));
893
+ }
894
+ /**
895
+ * List NFTs by contract address
896
+ * @summary List NFTs by contract address
897
+ * @param {NftsApiListNFTsRequest} requestParameters Request parameters.
898
+ * @param {*} [options] Override http request option.
899
+ * @throws {RequiredError}
900
+ * @memberof NftsApi
901
+ */
902
+ listNFTs(requestParameters, options) {
903
+ return NftsApiFp(this.configuration).listNFTs(requestParameters.contractAddress, requestParameters.chainName, requestParameters.pageCursor, requestParameters.pageSize, options).then((request) => request(this.axios, this.basePath));
904
+ }
905
+ /**
906
+ * List NFTs by account address
907
+ * @summary List NFTs by account address
908
+ * @param {NftsApiListNFTsByAccountAddressRequest} requestParameters Request parameters.
909
+ * @param {*} [options] Override http request option.
910
+ * @throws {RequiredError}
911
+ * @memberof NftsApi
912
+ */
913
+ listNFTsByAccountAddress(requestParameters, options) {
914
+ return NftsApiFp(this.configuration).listNFTsByAccountAddress(requestParameters.accountAddress, requestParameters.chainName, requestParameters.contractAddress, requestParameters.pageCursor, requestParameters.pageSize, options).then((request) => request(this.axios, this.basePath));
915
+ }
916
+ }
917
+
918
+ /* tslint:disable */
919
+ /* eslint-disable */
920
+ /**
921
+ * Immutable X API
922
+ * Immutable Multi Rollup API
923
+ *
924
+ * The version of the OpenAPI document: 1.0.0
925
+ * Contact: support@immutable.com
926
+ *
927
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
928
+ * https://openapi-generator.tech
929
+ * Do not edit the class manually.
930
+ */
931
+ class Configuration {
932
+ /**
933
+ * parameter for apiKey security
934
+ * @param name security name
935
+ * @memberof Configuration
936
+ */
937
+ apiKey;
938
+ /**
939
+ * parameter for basic security
940
+ *
941
+ * @type {string}
942
+ * @memberof Configuration
943
+ */
944
+ username;
945
+ /**
946
+ * parameter for basic security
947
+ *
948
+ * @type {string}
949
+ * @memberof Configuration
950
+ */
951
+ password;
952
+ /**
953
+ * parameter for oauth2 security
954
+ * @param name security name
955
+ * @param scopes oauth2 scope
956
+ * @memberof Configuration
957
+ */
958
+ accessToken;
959
+ /**
960
+ * override base path
961
+ *
962
+ * @type {string}
963
+ * @memberof Configuration
964
+ */
965
+ basePath;
966
+ /**
967
+ * base options for axios calls
968
+ *
969
+ * @type {any}
970
+ * @memberof Configuration
971
+ */
972
+ baseOptions;
973
+ /**
974
+ * The FormData constructor that will be used to create multipart form data
975
+ * requests. You can inject this here so that execution environments that
976
+ * do not support the FormData class can still run the generated client.
977
+ *
978
+ * @type {new () => FormData}
979
+ */
980
+ formDataCtor;
981
+ constructor(param = {}) {
982
+ this.apiKey = param.apiKey;
983
+ this.username = param.username;
984
+ this.password = param.password;
985
+ this.accessToken = param.accessToken;
986
+ this.basePath = param.basePath;
987
+ this.baseOptions = param.baseOptions;
988
+ this.formDataCtor = param.formDataCtor;
989
+ }
990
+ /**
991
+ * Check if the given MIME is a JSON MIME.
992
+ * JSON MIME examples:
993
+ * application/json
994
+ * application/json; charset=UTF8
995
+ * APPLICATION/JSON
996
+ * application/vnd.company+json
997
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
998
+ * @return True if the given MIME is JSON, false otherwise.
999
+ */
1000
+ isJsonMime(mime) {
1001
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
1002
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
1003
+ }
1004
+ }
1005
+
1006
+ var Environment;
1007
+ (function (Environment) {
1008
+ Environment["PRODUCTION"] = "production";
1009
+ Environment["SANDBOX"] = "sandbox";
1010
+ })(Environment || (Environment = {}));
1011
+
1012
+ /**
1013
+ * Custom Error class that is returned from the API when a request fails
1014
+ */
1015
+ class APIError extends Error {
1016
+ code;
1017
+ details;
1018
+ link;
1019
+ traceId;
1020
+ constructor({ message, code, details, link, trace_id: traceId, }) {
1021
+ super(message);
1022
+ this.code = code;
1023
+ this.details = details;
1024
+ this.link = link;
1025
+ this.traceId = traceId;
1026
+ }
1027
+ }
1028
+
1029
+ /* eslint-disable implicit-arrow-linebreak */
1030
+ const defaultHeaders = {
1031
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.1.8-alpha.1',
1032
+ };
1033
+ /**
1034
+ * createAPIConfiguration to create a custom APIConfiguration
1035
+ * other than the production and sandbox defined below.
1036
+ */
1037
+ const createAPIConfiguration = ({ basePath, headers: baseHeaders, }) => {
1038
+ if (!basePath.trim()) {
1039
+ throw Error('basePath can not be empty');
1040
+ }
1041
+ const headers = { ...(baseHeaders || {}), ...defaultHeaders };
1042
+ const configParams = {
1043
+ basePath,
1044
+ baseOptions: { headers },
1045
+ };
1046
+ return new Configuration(configParams);
1047
+ };
1048
+ const production = () => createAPIConfiguration({
1049
+ basePath: 'https://indexer-mr.dev.imtbl.com/v1', // TODO update before mainnet release
1050
+ });
1051
+ const sandbox = () => createAPIConfiguration({
1052
+ basePath: 'https://indexer-mr.dev.imtbl.com/v1', // TODO update before testnet release
1053
+ });
1054
+ class BlockchainDataConfiguration {
1055
+ apiConfig;
1056
+ baseConfig;
1057
+ constructor({ baseConfig, overrides }) {
1058
+ this.baseConfig = baseConfig;
1059
+ if (overrides) {
1060
+ this.apiConfig = createAPIConfiguration(overrides);
1061
+ }
1062
+ else {
1063
+ switch (baseConfig.environment) {
1064
+ case Environment.SANDBOX: {
1065
+ this.apiConfig = sandbox();
1066
+ break;
1067
+ }
1068
+ case Environment.PRODUCTION: {
1069
+ this.apiConfig = production();
1070
+ break;
1071
+ }
1072
+ default: {
1073
+ this.apiConfig = sandbox();
1074
+ }
1075
+ }
1076
+ }
1077
+ }
1078
+ }
1079
+
1080
+ /* eslint-disable @typescript-eslint/naming-convention */
1081
+ /**
1082
+ * [Formats an error in the APIError shape](https://axios-http.com/docs/handling_errors)
1083
+ * @param error - The Error object thrown by the request
1084
+ * @returns APIError
1085
+ */
1086
+ function formatError(error) {
1087
+ if (globalAxios.isAxiosError(error) && error.response) {
1088
+ const apiError = error.response.data;
1089
+ if (apiError.code && apiError.message) {
1090
+ return new APIError({
1091
+ code: apiError.code,
1092
+ message: apiError.message,
1093
+ details: apiError.details || null,
1094
+ link: apiError.link || '',
1095
+ trace_id: apiError.trace_id || '',
1096
+ });
1097
+ }
1098
+ return new APIError({
1099
+ code: error.code ?? error.response?.status.toString() ?? 'unknown_error_code',
1100
+ message: String(error),
1101
+ details: null,
1102
+ link: '',
1103
+ trace_id: '',
1104
+ });
1105
+ }
1106
+ return new APIError({
1107
+ code: 'unknown_error_code',
1108
+ message: String(error),
1109
+ details: null,
1110
+ link: '',
1111
+ trace_id: '',
1112
+ });
1113
+ }
1114
+
1115
+ class BlockchainData {
1116
+ config;
1117
+ activities;
1118
+ chains;
1119
+ collections;
1120
+ nfts;
1121
+ nftOwners;
1122
+ constructor(moduleConfig) {
1123
+ this.config = new BlockchainDataConfiguration(moduleConfig);
1124
+ this.activities = new ActivitiesApi(this.config.apiConfig);
1125
+ this.chains = new ChainsApi(this.config.apiConfig);
1126
+ this.collections = new CollectionsApi(this.config.apiConfig);
1127
+ this.nfts = new NftsApi(this.config.apiConfig);
1128
+ this.nftOwners = new NftOwnersApi(this.config.apiConfig);
1129
+ }
1130
+ /**
1131
+ * List all activities
1132
+ * @param request - the request object containing the parameters to be provided in the API request
1133
+ * @returns a promise that resolves with a list of activities
1134
+ * @throws {@link index.APIError}
1135
+ */
1136
+ async listActivities(request) {
1137
+ return await this.activities
1138
+ .listActivities(request)
1139
+ .then((res) => res.data)
1140
+ .catch((err) => {
1141
+ throw formatError(err);
1142
+ });
1143
+ }
1144
+ /**
1145
+ * Get a single activity by ID
1146
+ * @param request - the request object containing the parameters to be provided in the API request
1147
+ * @returns a promise that resolves with a single activity
1148
+ * @throws {@link index.APIError}
1149
+ */
1150
+ async getActivity(request) {
1151
+ return await this.activities
1152
+ .getActivity(request)
1153
+ .then((res) => res.data)
1154
+ .catch((err) => {
1155
+ throw formatError(err);
1156
+ });
1157
+ }
1158
+ /**
1159
+ * List supported chains
1160
+ * @param request - the request object containing the parameters to be provided in the API request
1161
+ * @returns a promise that resolves with a list of supported chains
1162
+ * @throws {@link index.APIError}
1163
+ */
1164
+ async listChains(request) {
1165
+ return await this.chains
1166
+ .listChains(request)
1167
+ .then((res) => res.data)
1168
+ .catch((err) => {
1169
+ throw formatError(err);
1170
+ });
1171
+ }
1172
+ /**
1173
+ * List all collections
1174
+ * @param request - the request object containing the parameters to be provided in the API request
1175
+ * @returns a promise that resolves with a list of collections
1176
+ * @throws {@link index.APIError}
1177
+ */
1178
+ async listCollections(request) {
1179
+ return await this.collections
1180
+ .listCollections(request)
1181
+ .then((res) => res.data)
1182
+ .catch((err) => {
1183
+ throw formatError(err);
1184
+ });
1185
+ }
1186
+ /**
1187
+ * Get collection by contract address
1188
+ * @param request - the request object containing the parameters to be provided in the API request
1189
+ * @returns a promise that resolves with a single collection
1190
+ * @throws {@link index.APIError}
1191
+ */
1192
+ async getCollection(request) {
1193
+ return await this.collections
1194
+ .getCollection(request)
1195
+ .then((res) => res.data)
1196
+ .catch((err) => {
1197
+ throw formatError(err);
1198
+ });
1199
+ }
1200
+ /**
1201
+ * Get NFT by token ID
1202
+ * @param request - the request object containing the parameters to be provided in the API request
1203
+ * @returns a promise that resolves with a single NFT
1204
+ * @throws {@link index.APIError}
1205
+ */
1206
+ async getNFT(request) {
1207
+ return await this.nfts
1208
+ .getNFT(request)
1209
+ .then((res) => res.data)
1210
+ .catch((err) => {
1211
+ throw formatError(err);
1212
+ });
1213
+ }
1214
+ /**
1215
+ * List NFTs by contract address
1216
+ * @param request - the request object containing the parameters to be provided in the API request
1217
+ * @returns a promise that resolves with a list of NFTs
1218
+ * @throws {@link index.APIError}
1219
+ */
1220
+ async listNFTs(request) {
1221
+ return await this.nfts
1222
+ .listNFTs(request)
1223
+ .then((res) => res.data)
1224
+ .catch((err) => {
1225
+ throw formatError(err);
1226
+ });
1227
+ }
1228
+ /**
1229
+ * List NFTs by account address
1230
+ * @param request - the request object containing the parameters to be provided in the API request
1231
+ * @returns a promise that resolves with a list of NFTs
1232
+ * @throws {@link index.APIError}
1233
+ */
1234
+ async listNFTsByAccountAddress(request) {
1235
+ return await this.nfts
1236
+ .listNFTsByAccountAddress(request)
1237
+ .then((res) => res.data)
1238
+ .catch((err) => {
1239
+ throw formatError(err);
1240
+ });
1241
+ }
1242
+ /**
1243
+ * List NFT owners by token ID
1244
+ * @param request - the request object containing the parameters to be provided in the API request
1245
+ * @returns a promise that resolves with a list of NFT owners
1246
+ * @throws {@link index.APIError}
1247
+ */
1248
+ async listNFTOwners(request) {
1249
+ return await this.nftOwners
1250
+ .listNFTOwners(request)
1251
+ .then((res) => res.data)
1252
+ .catch((err) => {
1253
+ throw formatError(err);
1254
+ });
1255
+ }
1256
+ }
1257
+
1258
+ export { APIError, BlockchainData };