@imtbl/sdk 0.1.3 → 0.1.4-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.
- package/dist/checkout_sdk.d.ts +932 -0
- package/dist/checkout_sdk.js +609 -0
- package/dist/checkout_widgets.d.ts +14458 -0
- package/dist/checkout_widgets.js +200 -0
- package/dist/immutablex_client.js +2 -2
- package/dist/index.cjs +1794 -40
- package/dist/index.d.ts +15188 -8
- package/dist/index.js +1795 -45
- package/dist/passport.d.ts +9935 -154
- package/dist/passport.js +520 -31
- package/dist/provider.d.ts +962 -0
- package/dist/provider.js +1139 -0
- package/package.json +13 -1
package/dist/passport.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Configuration, UsersApi, TransfersApi, OrdersApi, ExchangesApi, TradesApi, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
|
|
2
1
|
import { UserManager } from 'oidc-client-ts';
|
|
3
2
|
import { ethers } from 'ethers';
|
|
4
3
|
import { Magic } from 'magic-sdk';
|
|
5
4
|
import { OpenIdExtension } from '@magic-ext/oidc';
|
|
6
5
|
import BN from 'bn.js';
|
|
7
6
|
import * as encUtils from 'enc-utils';
|
|
7
|
+
import { ImmutableX, Config, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
|
|
8
8
|
|
|
9
9
|
// used to sign message with L1 keys. Used for registration
|
|
10
10
|
function serializeEthSignature(sig) {
|
|
@@ -73,6 +73,506 @@ var Environment;
|
|
|
73
73
|
Environment["SANDBOX"] = "sandbox";
|
|
74
74
|
})(Environment || (Environment = {}));
|
|
75
75
|
|
|
76
|
+
// Set `sdkVersion` on config
|
|
77
|
+
const PRODUCTION = () => {
|
|
78
|
+
return Config.createConfig({
|
|
79
|
+
basePath: 'https://api.x.immutable.com',
|
|
80
|
+
chainID: 1,
|
|
81
|
+
coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9',
|
|
82
|
+
registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c',
|
|
83
|
+
sdkVersion: 'ts-immutable-sdk-0.1.4-alpha',
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
// Set `sdkVersion` on config
|
|
87
|
+
const SANDBOX = () => {
|
|
88
|
+
return Config.createConfig({
|
|
89
|
+
basePath: 'https://api.sandbox.x.immutable.com',
|
|
90
|
+
chainID: 5,
|
|
91
|
+
coreContractAddress: '0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623',
|
|
92
|
+
registrationContractAddress: '0x1C97Ada273C9A52253f463042f29117090Cd7D83',
|
|
93
|
+
sdkVersion: 'ts-immutable-sdk-0.1.4-alpha',
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
class ImxConfiguration {
|
|
97
|
+
immutableXConfig;
|
|
98
|
+
baseConfig;
|
|
99
|
+
constructor({ baseConfig, overrides }) {
|
|
100
|
+
this.baseConfig = baseConfig;
|
|
101
|
+
if (overrides) {
|
|
102
|
+
this.immutableXConfig = overrides.immutableXConfig;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
switch (baseConfig.environment) {
|
|
106
|
+
case Environment.SANDBOX: {
|
|
107
|
+
this.immutableXConfig = SANDBOX();
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
case Environment.PRODUCTION: {
|
|
111
|
+
this.immutableXConfig = PRODUCTION();
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
class ImmutableXClient {
|
|
120
|
+
immutableX;
|
|
121
|
+
depositsApi;
|
|
122
|
+
mintsApi;
|
|
123
|
+
ordersApi;
|
|
124
|
+
tokensApi;
|
|
125
|
+
tradesApi;
|
|
126
|
+
transfersApi;
|
|
127
|
+
exchangeApi;
|
|
128
|
+
nftCheckoutPrimaryApi;
|
|
129
|
+
usersApi;
|
|
130
|
+
withdrawalsApi;
|
|
131
|
+
balanceApi;
|
|
132
|
+
assetApi;
|
|
133
|
+
collectionApi;
|
|
134
|
+
metadataApi;
|
|
135
|
+
metadataRefreshesApi;
|
|
136
|
+
projectsApi;
|
|
137
|
+
constructor(config) {
|
|
138
|
+
const imxConfig = new ImxConfiguration(config);
|
|
139
|
+
this.immutableX = new ImmutableX(imxConfig.immutableXConfig);
|
|
140
|
+
this.depositsApi = this.immutableX.depositsApi;
|
|
141
|
+
this.mintsApi = this.immutableX.mintsApi;
|
|
142
|
+
this.ordersApi = this.immutableX.ordersApi;
|
|
143
|
+
this.tokensApi = this.immutableX.tokensApi;
|
|
144
|
+
this.tradesApi = this.immutableX.tradesApi;
|
|
145
|
+
this.transfersApi = this.immutableX.transfersApi;
|
|
146
|
+
this.exchangeApi = this.immutableX.exchangeApi;
|
|
147
|
+
this.usersApi = this.immutableX.usersApi;
|
|
148
|
+
this.withdrawalsApi = this.immutableX.withdrawalsApi;
|
|
149
|
+
this.balanceApi = this.immutableX.balanceApi;
|
|
150
|
+
this.assetApi = this.immutableX.assetApi;
|
|
151
|
+
this.collectionApi = this.immutableX.collectionApi;
|
|
152
|
+
this.metadataApi = this.immutableX.metadataApi;
|
|
153
|
+
this.metadataRefreshesApi = this.immutableX.metadataRefreshesApi;
|
|
154
|
+
this.nftCheckoutPrimaryApi = this.immutableX.nftCheckoutPrimaryApi;
|
|
155
|
+
this.projectsApi = this.immutableX.projectsApi;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get details of a Deposit with the given ID
|
|
159
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
160
|
+
* @returns a promise that resolves with the requested Deposit
|
|
161
|
+
* @throws {@link index.IMXError}
|
|
162
|
+
*/
|
|
163
|
+
getDeposit(request) {
|
|
164
|
+
return this.immutableX.getDeposit(request);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get a list of Deposits
|
|
168
|
+
* @param request - optional request object containing the parameters to be provided in the API request
|
|
169
|
+
* @returns a promise that resolves with the requested list of Deposits
|
|
170
|
+
* @throws {@link index.IMXError}
|
|
171
|
+
*/
|
|
172
|
+
listDeposits(request) {
|
|
173
|
+
return this.immutableX.listDeposits(request);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get Stark keys for a registered User
|
|
177
|
+
* @param ethAddress - the eth address of the User
|
|
178
|
+
* @returns a promise that resolves with the requested User
|
|
179
|
+
* @throws {@link index.IMXError}
|
|
180
|
+
*/
|
|
181
|
+
getUser(ethAddress) {
|
|
182
|
+
return this.immutableX.getUser(ethAddress);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get details of an Asset
|
|
186
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
187
|
+
* @returns a promise that resolves with the requested Asset
|
|
188
|
+
* @throws {@link index.IMXError}
|
|
189
|
+
*/
|
|
190
|
+
getAsset(request) {
|
|
191
|
+
return this.immutableX.getAsset(request);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get a list of Assets
|
|
195
|
+
* @param request - optional request object containing the parameters to be provided in the API request
|
|
196
|
+
* @returns a promise that resolves with the requested list of Assets
|
|
197
|
+
* @throws {@link index.IMXError}
|
|
198
|
+
*/
|
|
199
|
+
listAssets(request) {
|
|
200
|
+
return this.immutableX.listAssets(request);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Create a Collection
|
|
204
|
+
* @param ethSigner - the L1 signer
|
|
205
|
+
* @param request - the request object to be provided in the API request
|
|
206
|
+
* @returns a promise that resolves with the created Collection
|
|
207
|
+
* @throws {@link index.IMXError}
|
|
208
|
+
*/
|
|
209
|
+
createCollection(ethSigner, request) {
|
|
210
|
+
return this.immutableX.createCollection(ethSigner, request);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get details of a Collection at the given address
|
|
214
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
215
|
+
* @returns a promise that resolves with the requested Collection
|
|
216
|
+
* @throws {@link index.IMXError}
|
|
217
|
+
*/
|
|
218
|
+
getCollection(request) {
|
|
219
|
+
return this.immutableX.getCollection(request);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Get a list of Collection filters
|
|
223
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
224
|
+
* @returns a promise that resolves with the requested list of Collection Filters
|
|
225
|
+
* @throws {@link index.IMXError}
|
|
226
|
+
*/
|
|
227
|
+
listCollectionFilters(request) {
|
|
228
|
+
return this.immutableX.listCollectionFilters(request);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get a list of Collections
|
|
232
|
+
* @param request - optional request object containing the parameters to be provided in the API request
|
|
233
|
+
* @returns a promise that resolves with the requested list of Collections
|
|
234
|
+
* @throws {@link index.IMXError}
|
|
235
|
+
*/
|
|
236
|
+
listCollections(request) {
|
|
237
|
+
return this.collectionApi.listCollections(request).then((res) => res.data);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Update a Collection
|
|
241
|
+
* @param ethSigner - the L1 signer
|
|
242
|
+
* @param collectionAddress - the Collection contract address
|
|
243
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
244
|
+
* @returns a promise that resolves with the updated Collection
|
|
245
|
+
* @throws {@link index.IMXError}
|
|
246
|
+
*/
|
|
247
|
+
updateCollection(ethSigner, collectionAddress, request) {
|
|
248
|
+
return this.immutableX.updateCollection(ethSigner, collectionAddress, request);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Add metadata schema to Collection
|
|
252
|
+
* @param ethSigner - the L1 signer
|
|
253
|
+
* @param collectionAddress - the Collection contract address
|
|
254
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
255
|
+
* @returns a promise that resolves with the SuccessResponse if successful
|
|
256
|
+
* @throws {@link index.IMXError}
|
|
257
|
+
*/
|
|
258
|
+
addMetadataSchemaToCollection(ethSigner, collectionAddress, request) {
|
|
259
|
+
return this.immutableX.addMetadataSchemaToCollection(ethSigner, collectionAddress, request);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Get Metadata schema
|
|
263
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
264
|
+
* @returns a promise that resolves with the requested Metadata schema
|
|
265
|
+
* @throws {@link index.IMXError}
|
|
266
|
+
*/
|
|
267
|
+
getMetadataSchema(request) {
|
|
268
|
+
return this.immutableX.getMetadataSchema(request);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Update metadata schema by name
|
|
272
|
+
* @param ethSigner - the L1 signer
|
|
273
|
+
* @param collectionAddress - the Collection contract address
|
|
274
|
+
* @param name - the Metadata schema name
|
|
275
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
276
|
+
* @returns a promise that resolves with the SuccessResponse if successful
|
|
277
|
+
* @throws {@link index.IMXError}
|
|
278
|
+
*/
|
|
279
|
+
updateMetadataSchemaByName(ethSigner, collectionAddress, name, request) {
|
|
280
|
+
return this.immutableX.updateMetadataSchemaByName(ethSigner, collectionAddress, name, request);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Get a list of metadata refreshes
|
|
284
|
+
* @param ethSigner - the L1 signer
|
|
285
|
+
* @param collectionAddress - the Collection contract address
|
|
286
|
+
* @param pageSize - the page size of the result
|
|
287
|
+
* @param cursor - the cursor
|
|
288
|
+
* @returns a promise that resolves with the requested metadata refreshes
|
|
289
|
+
* @throws {@link index.IMXError}
|
|
290
|
+
*/
|
|
291
|
+
listMetadataRefreshes(ethSigner, collectionAddress, pageSize, cursor) {
|
|
292
|
+
return this.immutableX.listMetadataRefreshes(ethSigner, collectionAddress, pageSize, cursor);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Get a list of metadata refresh errors
|
|
296
|
+
* @param ethSigner - the L1 signer
|
|
297
|
+
* @param refreshId - the metadata refresh ID
|
|
298
|
+
* @param pageSize - the page size of the result
|
|
299
|
+
* @param cursor - the cursor
|
|
300
|
+
* @returns a promise that resolves with the requested metadata refresh errors
|
|
301
|
+
* @throws {@link index.IMXError}
|
|
302
|
+
*/
|
|
303
|
+
getMetadataRefreshErrors(ethSigner, refreshId, pageSize, cursor) {
|
|
304
|
+
return this.immutableX.getMetadataRefreshErrors(ethSigner, refreshId, pageSize, cursor);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Get a list of metadata refresh results
|
|
308
|
+
* @param ethSigner - the L1 signer
|
|
309
|
+
* @param refreshId - the metadata refresh ID
|
|
310
|
+
* @returns a promise that resolves with the requested metadata refresh results
|
|
311
|
+
* @throws {@link index.IMXError}
|
|
312
|
+
*/
|
|
313
|
+
getMetadataRefreshResults(ethSigner, refreshId) {
|
|
314
|
+
return this.immutableX.getMetadataRefreshResults(ethSigner, refreshId);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Request a metadata refresh
|
|
318
|
+
* @param ethSigner - the L1 signer
|
|
319
|
+
* @param request the request object containing the parameters to be provided in the API request
|
|
320
|
+
* @returns a promise that resolves with the requested metadata refresh
|
|
321
|
+
* @throws {@link index.IMXError}
|
|
322
|
+
*/
|
|
323
|
+
createMetadataRefresh(ethSigner, request) {
|
|
324
|
+
return this.immutableX.createMetadataRefresh(ethSigner, request);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Create a Project
|
|
328
|
+
* @param ethSigner - the L1 signer
|
|
329
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
330
|
+
* @returns a promise that resolves with the created Project
|
|
331
|
+
* @throws {@link index.IMXError}
|
|
332
|
+
*/
|
|
333
|
+
async createProject(ethSigner, request) {
|
|
334
|
+
return this.immutableX.createProject(ethSigner, request);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Get a Project
|
|
338
|
+
* @param ethSigner - the L1 signer
|
|
339
|
+
* @param id - the Project ID
|
|
340
|
+
* @returns a promise that resolves with the requested Project
|
|
341
|
+
* @throws {@link index.IMXError}
|
|
342
|
+
*/
|
|
343
|
+
async getProject(ethSigner, id) {
|
|
344
|
+
return this.immutableX.getProject(ethSigner, id);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Get Projects owned by the given User
|
|
348
|
+
* @param ethSigner - the L1 signer
|
|
349
|
+
* @param pageSize - the page size of the result
|
|
350
|
+
* @param cursor - the cursor
|
|
351
|
+
* @param orderBy - the property to sort by
|
|
352
|
+
* @param direction - direction to sort (asc/desc)
|
|
353
|
+
* @returns a promise that resolves with the requested Projects
|
|
354
|
+
* @throws {@link index.IMXError}
|
|
355
|
+
*/
|
|
356
|
+
async getProjects(ethSigner, pageSize, cursor, orderBy, direction) {
|
|
357
|
+
return this.immutableX.getProjects(ethSigner, pageSize, cursor, orderBy, direction);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Get the token Balances of the User
|
|
361
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
362
|
+
* @returns a promise that resolves with the requested Balance
|
|
363
|
+
* @throws {@link index.IMXError}
|
|
364
|
+
*/
|
|
365
|
+
getBalance(request) {
|
|
366
|
+
return this.immutableX.getBalance(request);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Get a list of Balances for given User
|
|
370
|
+
* @param request the request object containing the parameters to be provided in the API request
|
|
371
|
+
* @returns a promise that resolves with the requested list of Balances
|
|
372
|
+
* @throws {@link index.IMXError}
|
|
373
|
+
*/
|
|
374
|
+
listBalances(request) {
|
|
375
|
+
return this.immutableX.listBalances(request);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Get details of a Mint with the given ID
|
|
379
|
+
* @param request the request object containing the parameters to be provided in the API request
|
|
380
|
+
* @returns a promise that resolves with the requested Mint
|
|
381
|
+
* @throws {@link index.IMXError}
|
|
382
|
+
*/
|
|
383
|
+
getMint(request) {
|
|
384
|
+
return this.immutableX.getMint(request);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Get a list of Mints
|
|
388
|
+
* @param request optional request object containing the parameters to be provided in the API request
|
|
389
|
+
* @returns a promise that resolves with the requested list of Mints
|
|
390
|
+
* @throws {@link index.IMXError}
|
|
391
|
+
*/
|
|
392
|
+
listMints(request) {
|
|
393
|
+
return this.immutableX.listMints(request);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Mint tokens in a batch with fees
|
|
397
|
+
* @param ethSigner - the L1 signer
|
|
398
|
+
* @param request - the request object to be provided in the API request
|
|
399
|
+
* @returns a promise that resolves with the minted tokens
|
|
400
|
+
* @throws {@link index.IMXError}
|
|
401
|
+
*/
|
|
402
|
+
mint(ethSigner, request) {
|
|
403
|
+
return this.immutableX.mint(ethSigner, request);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Get a list of Withdrawals
|
|
407
|
+
* @param request - optional request object containing the parameters to be provided in the API request
|
|
408
|
+
* @returns a promise that resolves with the requested list of Withdrawals
|
|
409
|
+
* @throws {@link index.IMXError}
|
|
410
|
+
*/
|
|
411
|
+
listWithdrawals(request) {
|
|
412
|
+
return this.immutableX.listWithdrawals(request);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Get details of Withdrawal with the given ID
|
|
416
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
417
|
+
* @returns a promise that resolves with the requested Withdrawal
|
|
418
|
+
* @throws {@link index.IMXError}
|
|
419
|
+
*/
|
|
420
|
+
getWithdrawal(request) {
|
|
421
|
+
return this.immutableX.getWithdrawal(request);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Get details of an Order with the given ID
|
|
425
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
426
|
+
* @returns a promise that resolves with the requested Order
|
|
427
|
+
* @throws {@link index.IMXError}
|
|
428
|
+
*/
|
|
429
|
+
getOrder(request) {
|
|
430
|
+
return this.immutableX.getOrder(request);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Get a list of Orders
|
|
434
|
+
* @param request - optional request object containing the parameters to be provided in the API request
|
|
435
|
+
* @returns a promise that resolves with the requested list of Orders
|
|
436
|
+
* @throws {@link index.IMXError}
|
|
437
|
+
*/
|
|
438
|
+
listOrders(request) {
|
|
439
|
+
return this.immutableX.listOrders(request);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Get details of a Trade with the given ID
|
|
443
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
444
|
+
* @returns a promise that resolves with the requested Trade
|
|
445
|
+
* @throws {@link index.IMXError}
|
|
446
|
+
*/
|
|
447
|
+
getTrade(request) {
|
|
448
|
+
return this.immutableX.getTrade(request);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Get a list of Trades
|
|
452
|
+
* @param request - optional request object containing the parameters to be provided in the API request
|
|
453
|
+
* @returns a promise that resolves with the requested list of Trades
|
|
454
|
+
* @throws {@link index.IMXError}
|
|
455
|
+
*/
|
|
456
|
+
listTrades(request) {
|
|
457
|
+
return this.immutableX.listTrades(request);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Get details of a Token
|
|
461
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
462
|
+
* @returns a promise that resolves with the requested Token
|
|
463
|
+
* @throws {@link index.IMXError}
|
|
464
|
+
*/
|
|
465
|
+
getToken(request) {
|
|
466
|
+
return this.immutableX.getToken(request);
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Get a list of Tokens
|
|
470
|
+
* @param request - optional request object containing the parameters to be provided in the API request
|
|
471
|
+
* @returns a promise that resolves with the requested list of Tokens
|
|
472
|
+
* @throws {@link index.IMXError}
|
|
473
|
+
*/
|
|
474
|
+
listTokens(request) {
|
|
475
|
+
return this.immutableX.listTokens(request);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Get details of a Transfer with the given ID
|
|
479
|
+
* @param request - the request object containing the parameters to be provided in the API request
|
|
480
|
+
* @returns a promise that resolves with the requested Transfer
|
|
481
|
+
* @throws {@link index.IMXError}
|
|
482
|
+
*/
|
|
483
|
+
getTransfer(request) {
|
|
484
|
+
return this.immutableX.getTransfer(request);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Get a list of Transfers
|
|
488
|
+
* @param request - optional request object containing the parameters to be provided in the API request
|
|
489
|
+
* @returns a promise that resolves with the requested list of Transfers
|
|
490
|
+
* @throws {@link index.IMXError}
|
|
491
|
+
*/
|
|
492
|
+
listTransfers(request) {
|
|
493
|
+
return this.immutableX.listTransfers(request);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Create a new Exchange transaction
|
|
497
|
+
* @param request - the request object to be provided in the API request
|
|
498
|
+
* @returns a promise that resolves with the created Exchange Transaction
|
|
499
|
+
* @throws {@link index.IMXError}
|
|
500
|
+
*/
|
|
501
|
+
createExchange(request) {
|
|
502
|
+
return this.immutableX.createExchange(request).then((res) => res.data);
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Get an Exchange transaction
|
|
506
|
+
* @param request - the request object to be provided in the API request
|
|
507
|
+
* @returns a promise that resolves with the Exchange Transaction
|
|
508
|
+
* @throws {@link index.IMXError}
|
|
509
|
+
*/
|
|
510
|
+
getExchange(request) {
|
|
511
|
+
return this.immutableX.getExchange(request).then((res) => res.data);
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Get Exchange transactions
|
|
515
|
+
* @param request - the request object to be provided in the API request
|
|
516
|
+
* @returns a promise that resolves with Exchange Transactions
|
|
517
|
+
* @throws {@link index.IMXError}
|
|
518
|
+
*/
|
|
519
|
+
getExchanges(request) {
|
|
520
|
+
return this.immutableX.getExchanges(request).then((res) => res.data);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Create a new Transfer request
|
|
524
|
+
* @param walletConnection - the pair of Eth/Stark signers
|
|
525
|
+
* @param request - the request object to be provided in the API request
|
|
526
|
+
* @returns a promise that resolves with the created Exchange Transfer
|
|
527
|
+
* @throws {@link index.IMXError}
|
|
528
|
+
*/
|
|
529
|
+
exchangeTransfer(walletConnection, request) {
|
|
530
|
+
return this.immutableX.exchangeTransfer(walletConnection, request);
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Create a new nft primary transaction
|
|
534
|
+
* @param request - the request object to be provided in the API request
|
|
535
|
+
* @returns a promise that resolves with the created nft primary Transaction
|
|
536
|
+
* @throws {@link index.IMXError}
|
|
537
|
+
*/
|
|
538
|
+
createNftPrimary(request) {
|
|
539
|
+
return this.immutableX.createNftPrimary(request).then((res) => res.data);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Get nft primary supported currencies and their limits
|
|
543
|
+
* @param request - the request object to be provided in the API request
|
|
544
|
+
* @returns a promise that resolves with nft primary Currencies
|
|
545
|
+
* @throws {@link index.IMXError}
|
|
546
|
+
*/
|
|
547
|
+
getCurrenciesNFTCheckoutPrimary(request) {
|
|
548
|
+
return this.immutableX
|
|
549
|
+
.getCurrenciesNFTCheckoutPrimary(request)
|
|
550
|
+
.then((res) => res.data);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Get nft primary transaction by transaction id
|
|
554
|
+
* @param request - the request object to be provided in the API request
|
|
555
|
+
* @returns a promise that resolves with nft primary transaction
|
|
556
|
+
* @throws {@link index.IMXError}
|
|
557
|
+
*/
|
|
558
|
+
getNftPrimaryTransaction(request) {
|
|
559
|
+
return this.immutableX
|
|
560
|
+
.getNftPrimaryTransaction(request)
|
|
561
|
+
.then((res) => res.data);
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Get list of nft primary transactions
|
|
565
|
+
* @param request - the request object to be provided in the API request
|
|
566
|
+
* @returns a promise that resolves with nft primary transaction
|
|
567
|
+
* @throws {@link index.IMXError}
|
|
568
|
+
*/
|
|
569
|
+
getNftPrimaryTransactions(request) {
|
|
570
|
+
return this.immutableX
|
|
571
|
+
.getNftPrimaryTransactions(request)
|
|
572
|
+
.then((res) => res.data);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
76
576
|
var PassportErrorType;
|
|
77
577
|
(function (PassportErrorType) {
|
|
78
578
|
PassportErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
|
|
@@ -648,29 +1148,20 @@ async function createTrade({ request, tradesApi, user, starkSigner, passportConf
|
|
|
648
1148
|
class PassportImxProvider {
|
|
649
1149
|
user;
|
|
650
1150
|
starkSigner;
|
|
651
|
-
transfersApi;
|
|
652
|
-
ordersApi;
|
|
653
1151
|
passportConfig;
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
constructor({ user, starkSigner, passportConfig }) {
|
|
1152
|
+
immutableXClient;
|
|
1153
|
+
constructor({ user, starkSigner, passportConfig, immutableXClient, }) {
|
|
657
1154
|
this.user = user;
|
|
658
1155
|
this.starkSigner = starkSigner;
|
|
659
1156
|
this.passportConfig = passportConfig;
|
|
660
|
-
|
|
661
|
-
basePath: passportConfig.imxApiBasePath,
|
|
662
|
-
});
|
|
663
|
-
this.transfersApi = new TransfersApi(apiConfig);
|
|
664
|
-
this.ordersApi = new OrdersApi(apiConfig);
|
|
665
|
-
this.exchangesApi = new ExchangesApi(apiConfig);
|
|
666
|
-
this.tradesApi = new TradesApi(apiConfig);
|
|
1157
|
+
this.immutableXClient = immutableXClient;
|
|
667
1158
|
}
|
|
668
1159
|
async transfer(request) {
|
|
669
1160
|
return transfer({
|
|
670
1161
|
request,
|
|
671
1162
|
user: this.user,
|
|
672
1163
|
starkSigner: this.starkSigner,
|
|
673
|
-
transfersApi: this.transfersApi,
|
|
1164
|
+
transfersApi: this.immutableXClient.transfersApi,
|
|
674
1165
|
passportConfig: this.passportConfig,
|
|
675
1166
|
});
|
|
676
1167
|
}
|
|
@@ -685,7 +1176,7 @@ class PassportImxProvider {
|
|
|
685
1176
|
request,
|
|
686
1177
|
user: this.user,
|
|
687
1178
|
starkSigner: this.starkSigner,
|
|
688
|
-
ordersApi: this.ordersApi,
|
|
1179
|
+
ordersApi: this.immutableXClient.ordersApi,
|
|
689
1180
|
passportConfig: this.passportConfig,
|
|
690
1181
|
});
|
|
691
1182
|
}
|
|
@@ -694,7 +1185,7 @@ class PassportImxProvider {
|
|
|
694
1185
|
request,
|
|
695
1186
|
user: this.user,
|
|
696
1187
|
starkSigner: this.starkSigner,
|
|
697
|
-
ordersApi: this.ordersApi,
|
|
1188
|
+
ordersApi: this.immutableXClient.ordersApi,
|
|
698
1189
|
passportConfig: this.passportConfig,
|
|
699
1190
|
});
|
|
700
1191
|
}
|
|
@@ -703,7 +1194,7 @@ class PassportImxProvider {
|
|
|
703
1194
|
request,
|
|
704
1195
|
user: this.user,
|
|
705
1196
|
starkSigner: this.starkSigner,
|
|
706
|
-
tradesApi: this.tradesApi,
|
|
1197
|
+
tradesApi: this.immutableXClient.tradesApi,
|
|
707
1198
|
passportConfig: this.passportConfig,
|
|
708
1199
|
});
|
|
709
1200
|
}
|
|
@@ -712,7 +1203,7 @@ class PassportImxProvider {
|
|
|
712
1203
|
request,
|
|
713
1204
|
user: this.user,
|
|
714
1205
|
starkSigner: this.starkSigner,
|
|
715
|
-
transfersApi: this.transfersApi,
|
|
1206
|
+
transfersApi: this.immutableXClient.transfersApi,
|
|
716
1207
|
passportConfig: this.passportConfig,
|
|
717
1208
|
});
|
|
718
1209
|
}
|
|
@@ -721,7 +1212,7 @@ class PassportImxProvider {
|
|
|
721
1212
|
request,
|
|
722
1213
|
user: this.user,
|
|
723
1214
|
starkSigner: this.starkSigner,
|
|
724
|
-
exchangesApi: this.
|
|
1215
|
+
exchangesApi: this.immutableXClient.exchangeApi,
|
|
725
1216
|
});
|
|
726
1217
|
}
|
|
727
1218
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -768,7 +1259,6 @@ class PassportConfiguration {
|
|
|
768
1259
|
passportDomain;
|
|
769
1260
|
magicPublishableApiKey;
|
|
770
1261
|
magicProviderId;
|
|
771
|
-
imxApiBasePath;
|
|
772
1262
|
oidcConfiguration;
|
|
773
1263
|
baseConfig;
|
|
774
1264
|
constructor({ baseConfig, overrides, ...oidcConfiguration }) {
|
|
@@ -786,14 +1276,12 @@ class PassportConfiguration {
|
|
|
786
1276
|
'magicPublishableApiKey',
|
|
787
1277
|
'magicProviderId',
|
|
788
1278
|
'passportDomain',
|
|
789
|
-
'imxApiBasePath',
|
|
790
1279
|
], 'overrides');
|
|
791
1280
|
this.network = overrides.network;
|
|
792
1281
|
this.authenticationDomain = overrides.authenticationDomain;
|
|
793
1282
|
this.passportDomain = overrides.passportDomain;
|
|
794
1283
|
this.magicPublishableApiKey = overrides.magicPublishableApiKey;
|
|
795
1284
|
this.magicProviderId = overrides.magicProviderId;
|
|
796
|
-
this.imxApiBasePath = overrides.imxApiBasePath;
|
|
797
1285
|
}
|
|
798
1286
|
else {
|
|
799
1287
|
switch (baseConfig.environment) {
|
|
@@ -803,7 +1291,6 @@ class PassportConfiguration {
|
|
|
803
1291
|
this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
|
|
804
1292
|
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
805
1293
|
this.passportDomain = 'https://passport.sandbox.immutable.com';
|
|
806
|
-
this.imxApiBasePath = 'https://api.sandbox.x.immutable.com';
|
|
807
1294
|
break;
|
|
808
1295
|
}
|
|
809
1296
|
case Environment.PRODUCTION: {
|
|
@@ -812,7 +1299,6 @@ class PassportConfiguration {
|
|
|
812
1299
|
this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
|
|
813
1300
|
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
814
1301
|
this.passportDomain = 'https://passport.immutable.com';
|
|
815
|
-
this.imxApiBasePath = 'https://api.x.immutable.com';
|
|
816
1302
|
break;
|
|
817
1303
|
}
|
|
818
1304
|
}
|
|
@@ -857,11 +1343,16 @@ class Passport {
|
|
|
857
1343
|
authManager;
|
|
858
1344
|
magicAdapter;
|
|
859
1345
|
config;
|
|
1346
|
+
immutableXClient;
|
|
860
1347
|
constructor(passportModuleConfiguration) {
|
|
861
|
-
|
|
862
|
-
this.config = passportConfiguration;
|
|
1348
|
+
this.config = new PassportConfiguration(passportModuleConfiguration);
|
|
863
1349
|
this.authManager = new AuthManager(this.config);
|
|
864
1350
|
this.magicAdapter = new MagicAdapter(this.config);
|
|
1351
|
+
this.immutableXClient =
|
|
1352
|
+
passportModuleConfiguration.overrides?.immutableXClient ||
|
|
1353
|
+
new ImmutableXClient({
|
|
1354
|
+
baseConfig: passportModuleConfiguration.baseConfig,
|
|
1355
|
+
});
|
|
865
1356
|
}
|
|
866
1357
|
async getImxProvider(user) {
|
|
867
1358
|
if (!user || !user.idToken) {
|
|
@@ -876,6 +1367,7 @@ class Passport {
|
|
|
876
1367
|
user: updatedUser,
|
|
877
1368
|
starkSigner,
|
|
878
1369
|
passportConfig: this.config,
|
|
1370
|
+
immutableXClient: this.immutableXClient,
|
|
879
1371
|
});
|
|
880
1372
|
}
|
|
881
1373
|
const userWithEtherKey = user;
|
|
@@ -883,6 +1375,7 @@ class Passport {
|
|
|
883
1375
|
user: userWithEtherKey,
|
|
884
1376
|
starkSigner,
|
|
885
1377
|
passportConfig: this.config,
|
|
1378
|
+
immutableXClient: this.immutableXClient,
|
|
886
1379
|
});
|
|
887
1380
|
}
|
|
888
1381
|
async connectImxSilent() {
|
|
@@ -915,14 +1408,10 @@ class Passport {
|
|
|
915
1408
|
return user?.accessToken;
|
|
916
1409
|
}
|
|
917
1410
|
async registerUser(userAdminKeySigner, starkSigner, jwt) {
|
|
918
|
-
const configuration = new Configuration({
|
|
919
|
-
basePath: this.config.imxApiBasePath,
|
|
920
|
-
});
|
|
921
|
-
const usersApi = new UsersApi(configuration);
|
|
922
1411
|
await registerPassport({
|
|
923
1412
|
ethSigner: userAdminKeySigner,
|
|
924
1413
|
starkSigner,
|
|
925
|
-
usersApi,
|
|
1414
|
+
usersApi: this.immutableXClient.usersApi,
|
|
926
1415
|
}, jwt);
|
|
927
1416
|
const updatedUser = await this.authManager.requestRefreshTokenAfterRegistration();
|
|
928
1417
|
if (!updatedUser) {
|