@imtbl/sdk 0.0.1-alpha.3 → 0.1.0-alpha

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,510 @@
1
+ import { ImmutableX, Config } from '@imtbl/core-sdk';
2
+ export { createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey } from '@imtbl/core-sdk';
3
+
4
+ var Environment;
5
+ (function (Environment) {
6
+ Environment["PRODUCTION"] = "production";
7
+ Environment["SANDBOX"] = "sandbox";
8
+ })(Environment || (Environment = {}));
9
+
10
+ // Set `sdkVersion` on config
11
+ const PRODUCTION = () => {
12
+ return Config.createConfig({
13
+ basePath: 'https://api.x.immutable.com',
14
+ chainID: 1,
15
+ coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9',
16
+ registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c',
17
+ sdkVersion: 'ts-immutable-sdk-0.1.0-alpha',
18
+ });
19
+ };
20
+ // Set `sdkVersion` on config
21
+ const SANDBOX = () => {
22
+ return Config.createConfig({
23
+ basePath: 'https://api.sandbox.x.immutable.com',
24
+ chainID: 5,
25
+ coreContractAddress: '0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623',
26
+ registrationContractAddress: '0x1C97Ada273C9A52253f463042f29117090Cd7D83',
27
+ sdkVersion: 'ts-immutable-sdk-0.1.0-alpha',
28
+ });
29
+ };
30
+ class ImxConfiguration {
31
+ immutableXConfig;
32
+ baseConfig;
33
+ constructor({ baseConfig, overrides }) {
34
+ this.baseConfig = baseConfig;
35
+ if (overrides) {
36
+ this.immutableXConfig = overrides.immutableXConfig;
37
+ }
38
+ else {
39
+ switch (baseConfig.environment) {
40
+ case Environment.SANDBOX: {
41
+ this.immutableXConfig = SANDBOX();
42
+ break;
43
+ }
44
+ case Environment.PRODUCTION: {
45
+ this.immutableXConfig = PRODUCTION();
46
+ break;
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ class ImmutableXClient {
54
+ immutableX;
55
+ depositsApi;
56
+ mintsApi;
57
+ ordersApi;
58
+ tokensApi;
59
+ tradesApi;
60
+ transfersApi;
61
+ exchangeApi;
62
+ nftCheckoutPrimaryApi;
63
+ usersApi;
64
+ withdrawalsApi;
65
+ balanceApi;
66
+ assetApi;
67
+ collectionApi;
68
+ metadataApi;
69
+ metadataRefreshesApi;
70
+ projectsApi;
71
+ constructor(config) {
72
+ const imxConfig = new ImxConfiguration(config);
73
+ this.immutableX = new ImmutableX(imxConfig.immutableXConfig);
74
+ this.depositsApi = this.immutableX.depositsApi;
75
+ this.mintsApi = this.immutableX.mintsApi;
76
+ this.ordersApi = this.immutableX.ordersApi;
77
+ this.tokensApi = this.immutableX.tokensApi;
78
+ this.tradesApi = this.immutableX.tradesApi;
79
+ this.transfersApi = this.immutableX.transfersApi;
80
+ this.exchangeApi = this.immutableX.exchangeApi;
81
+ this.usersApi = this.immutableX.usersApi;
82
+ this.withdrawalsApi = this.immutableX.withdrawalsApi;
83
+ this.balanceApi = this.immutableX.balanceApi;
84
+ this.assetApi = this.immutableX.assetApi;
85
+ this.collectionApi = this.immutableX.collectionApi;
86
+ this.metadataApi = this.immutableX.metadataApi;
87
+ this.metadataRefreshesApi = this.immutableX.metadataRefreshesApi;
88
+ this.nftCheckoutPrimaryApi = this.immutableX.nftCheckoutPrimaryApi;
89
+ this.projectsApi = this.immutableX.projectsApi;
90
+ }
91
+ /**
92
+ * Get details of a Deposit with the given ID
93
+ * @param request - the request object containing the parameters to be provided in the API request
94
+ * @returns a promise that resolves with the requested Deposit
95
+ * @throws {@link index.IMXError}
96
+ */
97
+ getDeposit(request) {
98
+ return this.immutableX.getDeposit(request);
99
+ }
100
+ /**
101
+ * Get a list of Deposits
102
+ * @param request - optional request object containing the parameters to be provided in the API request
103
+ * @returns a promise that resolves with the requested list of Deposits
104
+ * @throws {@link index.IMXError}
105
+ */
106
+ listDeposits(request) {
107
+ return this.immutableX.listDeposits(request);
108
+ }
109
+ /**
110
+ * Get Stark keys for a registered User
111
+ * @param ethAddress - the eth address of the User
112
+ * @returns a promise that resolves with the requested User
113
+ * @throws {@link index.IMXError}
114
+ */
115
+ getUser(ethAddress) {
116
+ return this.immutableX.getUser(ethAddress);
117
+ }
118
+ /**
119
+ * Get details of an Asset
120
+ * @param request - the request object containing the parameters to be provided in the API request
121
+ * @returns a promise that resolves with the requested Asset
122
+ * @throws {@link index.IMXError}
123
+ */
124
+ getAsset(request) {
125
+ return this.immutableX.getAsset(request);
126
+ }
127
+ /**
128
+ * Get a list of Assets
129
+ * @param request - optional request object containing the parameters to be provided in the API request
130
+ * @returns a promise that resolves with the requested list of Assets
131
+ * @throws {@link index.IMXError}
132
+ */
133
+ listAssets(request) {
134
+ return this.immutableX.listAssets(request);
135
+ }
136
+ /**
137
+ * Create a Collection
138
+ * @param ethSigner - the L1 signer
139
+ * @param request - the request object to be provided in the API request
140
+ * @returns a promise that resolves with the created Collection
141
+ * @throws {@link index.IMXError}
142
+ */
143
+ createCollection(ethSigner, request) {
144
+ return this.immutableX.createCollection(ethSigner, request);
145
+ }
146
+ /**
147
+ * Get details of a Collection at the given address
148
+ * @param request - the request object containing the parameters to be provided in the API request
149
+ * @returns a promise that resolves with the requested Collection
150
+ * @throws {@link index.IMXError}
151
+ */
152
+ getCollection(request) {
153
+ return this.immutableX.getCollection(request);
154
+ }
155
+ /**
156
+ * Get a list of Collection filters
157
+ * @param request - the request object containing the parameters to be provided in the API request
158
+ * @returns a promise that resolves with the requested list of Collection Filters
159
+ * @throws {@link index.IMXError}
160
+ */
161
+ listCollectionFilters(request) {
162
+ return this.immutableX.listCollectionFilters(request);
163
+ }
164
+ /**
165
+ * Get a list of Collections
166
+ * @param request - optional request object containing the parameters to be provided in the API request
167
+ * @returns a promise that resolves with the requested list of Collections
168
+ * @throws {@link index.IMXError}
169
+ */
170
+ listCollections(request) {
171
+ return this.collectionApi.listCollections(request).then((res) => res.data);
172
+ }
173
+ /**
174
+ * Update a Collection
175
+ * @param ethSigner - the L1 signer
176
+ * @param collectionAddress - the Collection contract address
177
+ * @param request - the request object containing the parameters to be provided in the API request
178
+ * @returns a promise that resolves with the updated Collection
179
+ * @throws {@link index.IMXError}
180
+ */
181
+ updateCollection(ethSigner, collectionAddress, request) {
182
+ return this.immutableX.updateCollection(ethSigner, collectionAddress, request);
183
+ }
184
+ /**
185
+ * Add metadata schema to Collection
186
+ * @param ethSigner - the L1 signer
187
+ * @param collectionAddress - the Collection contract address
188
+ * @param request - the request object containing the parameters to be provided in the API request
189
+ * @returns a promise that resolves with the SuccessResponse if successful
190
+ * @throws {@link index.IMXError}
191
+ */
192
+ addMetadataSchemaToCollection(ethSigner, collectionAddress, request) {
193
+ return this.immutableX.addMetadataSchemaToCollection(ethSigner, collectionAddress, request);
194
+ }
195
+ /**
196
+ * Get Metadata schema
197
+ * @param request - the request object containing the parameters to be provided in the API request
198
+ * @returns a promise that resolves with the requested Metadata schema
199
+ * @throws {@link index.IMXError}
200
+ */
201
+ getMetadataSchema(request) {
202
+ return this.immutableX.getMetadataSchema(request);
203
+ }
204
+ /**
205
+ * Update metadata schema by name
206
+ * @param ethSigner - the L1 signer
207
+ * @param collectionAddress - the Collection contract address
208
+ * @param name - the Metadata schema name
209
+ * @param request - the request object containing the parameters to be provided in the API request
210
+ * @returns a promise that resolves with the SuccessResponse if successful
211
+ * @throws {@link index.IMXError}
212
+ */
213
+ updateMetadataSchemaByName(ethSigner, collectionAddress, name, request) {
214
+ return this.immutableX.updateMetadataSchemaByName(ethSigner, collectionAddress, name, request);
215
+ }
216
+ /**
217
+ * Get a list of metadata refreshes
218
+ * @param ethSigner - the L1 signer
219
+ * @param collectionAddress - the Collection contract address
220
+ * @param pageSize - the page size of the result
221
+ * @param cursor - the cursor
222
+ * @returns a promise that resolves with the requested metadata refreshes
223
+ * @throws {@link index.IMXError}
224
+ */
225
+ listMetadataRefreshes(ethSigner, collectionAddress, pageSize, cursor) {
226
+ return this.immutableX.listMetadataRefreshes(ethSigner, collectionAddress, pageSize, cursor);
227
+ }
228
+ /**
229
+ * Get a list of metadata refresh errors
230
+ * @param ethSigner - the L1 signer
231
+ * @param refreshId - the metadata refresh ID
232
+ * @param pageSize - the page size of the result
233
+ * @param cursor - the cursor
234
+ * @returns a promise that resolves with the requested metadata refresh errors
235
+ * @throws {@link index.IMXError}
236
+ */
237
+ getMetadataRefreshErrors(ethSigner, refreshId, pageSize, cursor) {
238
+ return this.immutableX.getMetadataRefreshErrors(ethSigner, refreshId, pageSize, cursor);
239
+ }
240
+ /**
241
+ * Get a list of metadata refresh results
242
+ * @param ethSigner - the L1 signer
243
+ * @param refreshId - the metadata refresh ID
244
+ * @returns a promise that resolves with the requested metadata refresh results
245
+ * @throws {@link index.IMXError}
246
+ */
247
+ getMetadataRefreshResults(ethSigner, refreshId) {
248
+ return this.immutableX.getMetadataRefreshResults(ethSigner, refreshId);
249
+ }
250
+ /**
251
+ * Request a metadata refresh
252
+ * @param ethSigner - the L1 signer
253
+ * @param request the request object containing the parameters to be provided in the API request
254
+ * @returns a promise that resolves with the requested metadata refresh
255
+ * @throws {@link index.IMXError}
256
+ */
257
+ createMetadataRefresh(ethSigner, request) {
258
+ return this.immutableX.createMetadataRefresh(ethSigner, request);
259
+ }
260
+ /**
261
+ * Create a Project
262
+ * @param ethSigner - the L1 signer
263
+ * @param request - the request object containing the parameters to be provided in the API request
264
+ * @returns a promise that resolves with the created Project
265
+ * @throws {@link index.IMXError}
266
+ */
267
+ async createProject(ethSigner, request) {
268
+ return this.immutableX.createProject(ethSigner, request);
269
+ }
270
+ /**
271
+ * Get a Project
272
+ * @param ethSigner - the L1 signer
273
+ * @param id - the Project ID
274
+ * @returns a promise that resolves with the requested Project
275
+ * @throws {@link index.IMXError}
276
+ */
277
+ async getProject(ethSigner, id) {
278
+ return this.immutableX.getProject(ethSigner, id);
279
+ }
280
+ /**
281
+ * Get Projects owned by the given User
282
+ * @param ethSigner - the L1 signer
283
+ * @param pageSize - the page size of the result
284
+ * @param cursor - the cursor
285
+ * @param orderBy - the property to sort by
286
+ * @param direction - direction to sort (asc/desc)
287
+ * @returns a promise that resolves with the requested Projects
288
+ * @throws {@link index.IMXError}
289
+ */
290
+ async getProjects(ethSigner, pageSize, cursor, orderBy, direction) {
291
+ return this.immutableX.getProjects(ethSigner, pageSize, cursor, orderBy, direction);
292
+ }
293
+ /**
294
+ * Get the token Balances of the User
295
+ * @param request - the request object containing the parameters to be provided in the API request
296
+ * @returns a promise that resolves with the requested Balance
297
+ * @throws {@link index.IMXError}
298
+ */
299
+ getBalance(request) {
300
+ return this.immutableX.getBalance(request);
301
+ }
302
+ /**
303
+ * Get a list of Balances for given User
304
+ * @param request the request object containing the parameters to be provided in the API request
305
+ * @returns a promise that resolves with the requested list of Balances
306
+ * @throws {@link index.IMXError}
307
+ */
308
+ listBalances(request) {
309
+ return this.immutableX.listBalances(request);
310
+ }
311
+ /**
312
+ * Get details of a Mint with the given ID
313
+ * @param request the request object containing the parameters to be provided in the API request
314
+ * @returns a promise that resolves with the requested Mint
315
+ * @throws {@link index.IMXError}
316
+ */
317
+ getMint(request) {
318
+ return this.immutableX.getMint(request);
319
+ }
320
+ /**
321
+ * Get a list of Mints
322
+ * @param request optional request object containing the parameters to be provided in the API request
323
+ * @returns a promise that resolves with the requested list of Mints
324
+ * @throws {@link index.IMXError}
325
+ */
326
+ listMints(request) {
327
+ return this.immutableX.listMints(request);
328
+ }
329
+ /**
330
+ * Mint tokens in a batch with fees
331
+ * @param ethSigner - the L1 signer
332
+ * @param request - the request object to be provided in the API request
333
+ * @returns a promise that resolves with the minted tokens
334
+ * @throws {@link index.IMXError}
335
+ */
336
+ mint(ethSigner, request) {
337
+ return this.immutableX.mint(ethSigner, request);
338
+ }
339
+ /**
340
+ * Get a list of Withdrawals
341
+ * @param request - optional request object containing the parameters to be provided in the API request
342
+ * @returns a promise that resolves with the requested list of Withdrawals
343
+ * @throws {@link index.IMXError}
344
+ */
345
+ listWithdrawals(request) {
346
+ return this.immutableX.listWithdrawals(request);
347
+ }
348
+ /**
349
+ * Get details of Withdrawal with the given ID
350
+ * @param request - the request object containing the parameters to be provided in the API request
351
+ * @returns a promise that resolves with the requested Withdrawal
352
+ * @throws {@link index.IMXError}
353
+ */
354
+ getWithdrawal(request) {
355
+ return this.immutableX.getWithdrawal(request);
356
+ }
357
+ /**
358
+ * Get details of an Order with the given ID
359
+ * @param request - the request object containing the parameters to be provided in the API request
360
+ * @returns a promise that resolves with the requested Order
361
+ * @throws {@link index.IMXError}
362
+ */
363
+ getOrder(request) {
364
+ return this.immutableX.getOrder(request);
365
+ }
366
+ /**
367
+ * Get a list of Orders
368
+ * @param request - optional request object containing the parameters to be provided in the API request
369
+ * @returns a promise that resolves with the requested list of Orders
370
+ * @throws {@link index.IMXError}
371
+ */
372
+ listOrders(request) {
373
+ return this.immutableX.listOrders(request);
374
+ }
375
+ /**
376
+ * Get details of a Trade with the given ID
377
+ * @param request - the request object containing the parameters to be provided in the API request
378
+ * @returns a promise that resolves with the requested Trade
379
+ * @throws {@link index.IMXError}
380
+ */
381
+ getTrade(request) {
382
+ return this.immutableX.getTrade(request);
383
+ }
384
+ /**
385
+ * Get a list of Trades
386
+ * @param request - optional request object containing the parameters to be provided in the API request
387
+ * @returns a promise that resolves with the requested list of Trades
388
+ * @throws {@link index.IMXError}
389
+ */
390
+ listTrades(request) {
391
+ return this.immutableX.listTrades(request);
392
+ }
393
+ /**
394
+ * Get details of a Token
395
+ * @param request - the request object containing the parameters to be provided in the API request
396
+ * @returns a promise that resolves with the requested Token
397
+ * @throws {@link index.IMXError}
398
+ */
399
+ getToken(request) {
400
+ return this.immutableX.getToken(request);
401
+ }
402
+ /**
403
+ * Get a list of Tokens
404
+ * @param request - optional request object containing the parameters to be provided in the API request
405
+ * @returns a promise that resolves with the requested list of Tokens
406
+ * @throws {@link index.IMXError}
407
+ */
408
+ listTokens(request) {
409
+ return this.immutableX.listTokens(request);
410
+ }
411
+ /**
412
+ * Get details of a Transfer with the given ID
413
+ * @param request - the request object containing the parameters to be provided in the API request
414
+ * @returns a promise that resolves with the requested Transfer
415
+ * @throws {@link index.IMXError}
416
+ */
417
+ getTransfer(request) {
418
+ return this.immutableX.getTransfer(request);
419
+ }
420
+ /**
421
+ * Get a list of Transfers
422
+ * @param request - optional request object containing the parameters to be provided in the API request
423
+ * @returns a promise that resolves with the requested list of Transfers
424
+ * @throws {@link index.IMXError}
425
+ */
426
+ listTransfers(request) {
427
+ return this.immutableX.listTransfers(request);
428
+ }
429
+ /**
430
+ * Create a new Exchange transaction
431
+ * @param request - the request object to be provided in the API request
432
+ * @returns a promise that resolves with the created Exchange Transaction
433
+ * @throws {@link index.IMXError}
434
+ */
435
+ createExchange(request) {
436
+ return this.immutableX.createExchange(request).then((res) => res.data);
437
+ }
438
+ /**
439
+ * Get an Exchange transaction
440
+ * @param request - the request object to be provided in the API request
441
+ * @returns a promise that resolves with the Exchange Transaction
442
+ * @throws {@link index.IMXError}
443
+ */
444
+ getExchange(request) {
445
+ return this.immutableX.getExchange(request).then((res) => res.data);
446
+ }
447
+ /**
448
+ * Get Exchange transactions
449
+ * @param request - the request object to be provided in the API request
450
+ * @returns a promise that resolves with Exchange Transactions
451
+ * @throws {@link index.IMXError}
452
+ */
453
+ getExchanges(request) {
454
+ return this.immutableX.getExchanges(request).then((res) => res.data);
455
+ }
456
+ /**
457
+ * Create a new Transfer request
458
+ * @param walletConnection - the pair of Eth/Stark signers
459
+ * @param request - the request object to be provided in the API request
460
+ * @returns a promise that resolves with the created Exchange Transfer
461
+ * @throws {@link index.IMXError}
462
+ */
463
+ exchangeTransfer(walletConnection, request) {
464
+ return this.immutableX.exchangeTransfer(walletConnection, request);
465
+ }
466
+ /**
467
+ * Create a new nft primary transaction
468
+ * @param request - the request object to be provided in the API request
469
+ * @returns a promise that resolves with the created nft primary Transaction
470
+ * @throws {@link index.IMXError}
471
+ */
472
+ createNftPrimary(request) {
473
+ return this.immutableX.createNftPrimary(request).then((res) => res.data);
474
+ }
475
+ /**
476
+ * Get nft primary supported currencies and their limits
477
+ * @param request - the request object to be provided in the API request
478
+ * @returns a promise that resolves with nft primary Currencies
479
+ * @throws {@link index.IMXError}
480
+ */
481
+ getCurrenciesNFTCheckoutPrimary(request) {
482
+ return this.immutableX
483
+ .getCurrenciesNFTCheckoutPrimary(request)
484
+ .then((res) => res.data);
485
+ }
486
+ /**
487
+ * Get nft primary transaction by transaction id
488
+ * @param request - the request object to be provided in the API request
489
+ * @returns a promise that resolves with nft primary transaction
490
+ * @throws {@link index.IMXError}
491
+ */
492
+ getNftPrimaryTransaction(request) {
493
+ return this.immutableX
494
+ .getNftPrimaryTransaction(request)
495
+ .then((res) => res.data);
496
+ }
497
+ /**
498
+ * Get list of nft primary transactions
499
+ * @param request - the request object to be provided in the API request
500
+ * @returns a promise that resolves with nft primary transaction
501
+ * @throws {@link index.IMXError}
502
+ */
503
+ getNftPrimaryTransactions(request) {
504
+ return this.immutableX
505
+ .getNftPrimaryTransactions(request)
506
+ .then((res) => res.data);
507
+ }
508
+ }
509
+
510
+ export { ImmutableXClient };