@eluvio/elv-client-js 3.2.2 → 3.2.4

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.
@@ -1,1828 +0,0 @@
1
- var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
-
3
- var _regeneratorRuntime = require("@babel/runtime/regenerator");
4
-
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
6
-
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8
-
9
- var Utils = require("../Utils");
10
-
11
- var UrlJoin = require("url-join");
12
-
13
- var _require = require("./Utils"),
14
- FormatNFTDetails = _require.FormatNFTDetails,
15
- FormatNFTMetadata = _require.FormatNFTMetadata,
16
- FormatNFT = _require.FormatNFT;
17
- /**
18
- * Methods
19
- *
20
- * @module ClientMethods
21
- */
22
-
23
- /* USER INFO */
24
-
25
- /**
26
- * <b><i>Requires login</i></b>
27
- *
28
- * Retrieve information about the user, including the address, wallet type, and (for custodial users) email address.
29
- *
30
- * @methodGroup User
31
- *
32
- * @returns {Object} - User info
33
- */
34
-
35
-
36
- exports.UserInfo = function () {
37
- if (!this.loggedIn) {
38
- return;
39
- }
40
-
41
- return {
42
- address: this.UserAddress(),
43
- email: this.__authorization.email,
44
- walletType: this.__authorization.walletType,
45
- walletName: this.__authorization.walletName
46
- };
47
- };
48
- /**
49
- * <b><i>Requires login</i></b>
50
- *
51
- * Retrieve the address of the current user.
52
- *
53
- * @methodGroup User
54
- *
55
- * @returns {string} - The address of the current user
56
- */
57
-
58
-
59
- exports.UserAddress = function () {
60
- if (!this.loggedIn) {
61
- return;
62
- }
63
-
64
- return this.client.utils.DecodeSignedToken(this.AuthToken()).payload.adr;
65
- };
66
- /**
67
- * <b><i>Requires login</i></b>
68
- *
69
- * Retrieve the fund balances for the current user
70
- *
71
- * @methodGroup User
72
- * @returns {Promise<{Object}>} - Returns balances for the user. All values are in USD.
73
- * <ul>
74
- * <li>- totalWalletBalance - Total balance of the users sales and wallet balance purchases</li>
75
- * <li>- availableWalletBalance - Balance available for purchasing items</li>
76
- * <li>- pendingWalletBalance - Balance unavailable for purchasing items</li>
77
- * <li>- withdrawableWalletBalance - Amount that is available for withdrawal</li>
78
- * <li>- usedBalance - <i>(Only included if user has set up Solana link with the Phantom wallet)</i> Available USDC balance of the user's Solana wallet</li>
79
- * </ul>
80
- */
81
-
82
-
83
- exports.UserWalletBalance = function _callee() {
84
- var checkOnboard,
85
- _ref,
86
- balance,
87
- usage_hold,
88
- payout_hold,
89
- stripe_id,
90
- stripe_payouts_enabled,
91
- userStripeId,
92
- userStripeEnabled,
93
- totalWalletBalance,
94
- availableWalletBalance,
95
- pendingWalletBalance,
96
- withdrawableWalletBalance,
97
- rootUrl,
98
- balances,
99
- _args = arguments;
100
-
101
- return _regeneratorRuntime.async(function _callee$(_context) {
102
- while (1) {
103
- switch (_context.prev = _context.next) {
104
- case 0:
105
- checkOnboard = _args.length > 0 && _args[0] !== undefined ? _args[0] : false;
106
-
107
- if (this.loggedIn) {
108
- _context.next = 3;
109
- break;
110
- }
111
-
112
- return _context.abrupt("return");
113
-
114
- case 3:
115
- _context.t0 = _regeneratorRuntime;
116
- _context.t1 = this.client.utils;
117
- _context.next = 7;
118
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
119
- path: UrlJoin("as", "wlt", "mkt", "bal"),
120
- method: "GET",
121
- headers: {
122
- Authorization: "Bearer ".concat(this.AuthToken())
123
- }
124
- }));
125
-
126
- case 7:
127
- _context.t2 = _context.sent;
128
- _context.t3 = _context.t1.ResponseToJson.call(_context.t1, _context.t2);
129
- _context.next = 11;
130
- return _context.t0.awrap.call(_context.t0, _context.t3);
131
-
132
- case 11:
133
- _ref = _context.sent;
134
- balance = _ref.balance;
135
- usage_hold = _ref.usage_hold;
136
- payout_hold = _ref.payout_hold;
137
- stripe_id = _ref.stripe_id;
138
- stripe_payouts_enabled = _ref.stripe_payouts_enabled;
139
- userStripeId = stripe_id;
140
- userStripeEnabled = stripe_payouts_enabled;
141
- totalWalletBalance = parseFloat(balance || 0);
142
- availableWalletBalance = Math.max(0, this.totalWalletBalance - parseFloat(usage_hold || 0));
143
- pendingWalletBalance = Math.max(0, this.totalWalletBalance - this.availableWalletBalance);
144
- withdrawableWalletBalance = Math.max(0, this.totalWalletBalance - parseFloat(payout_hold || 0));
145
-
146
- if (!(checkOnboard && stripe_id && !stripe_payouts_enabled)) {
147
- _context.next = 30;
148
- break;
149
- }
150
-
151
- // Refresh stripe enabled flag
152
- rootUrl = new URL(UrlJoin(window.location.origin, window.location.pathname)).toString();
153
- _context.next = 27;
154
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
155
- path: UrlJoin("as", "wlt", "onb", "stripe"),
156
- method: "POST",
157
- body: {
158
- country: "US",
159
- mode: this.mode,
160
- refresh_url: rootUrl.toString(),
161
- return_url: rootUrl.toString()
162
- },
163
- headers: {
164
- Authorization: "Bearer ".concat(this.AuthToken())
165
- }
166
- }));
167
-
168
- case 27:
169
- _context.next = 29;
170
- return _regeneratorRuntime.awrap(this.UserWalletBalance(false));
171
-
172
- case 29:
173
- return _context.abrupt("return", _context.sent);
174
-
175
- case 30:
176
- balances = {
177
- totalWalletBalance: totalWalletBalance,
178
- availableWalletBalance: availableWalletBalance,
179
- pendingWalletBalance: pendingWalletBalance,
180
- withdrawableWalletBalance: withdrawableWalletBalance
181
- };
182
-
183
- if (userStripeEnabled) {
184
- balances.userStripeId = userStripeId;
185
- balances.userStripeEnabled = userStripeEnabled;
186
- } // TODO: integrate
187
-
188
- /*
189
- if(cryptoStore.usdcConnected) {
190
- balances.usdcBalance = cryptoStore.phantomUSDCBalance;
191
- }
192
- */
193
-
194
-
195
- return _context.abrupt("return", balances);
196
-
197
- case 33:
198
- case "end":
199
- return _context.stop();
200
- }
201
- }
202
- }, null, this);
203
- };
204
- /**
205
- * <b><i>Requires login</i></b>
206
- *
207
- * Returns basic contract info about the items the current user owns, organized by contract address + token ID
208
- *
209
- * This method is significantly faster than <a href="#.UserItems">UserItems</a>, but does not include any NFT metadata.
210
- *
211
- * @methodGroup User
212
- *
213
- * @returns {Promise<Object>} - Basic info about all owned items.
214
- */
215
-
216
-
217
- exports.UserItemInfo = function _callee2() {
218
- var _this = this;
219
-
220
- var accountId, nftInfo;
221
- return _regeneratorRuntime.async(function _callee2$(_context2) {
222
- while (1) {
223
- switch (_context2.prev = _context2.next) {
224
- case 0:
225
- if (this.loggedIn) {
226
- _context2.next = 2;
227
- break;
228
- }
229
-
230
- return _context2.abrupt("return", {});
231
-
232
- case 2:
233
- accountId = "iusr".concat(Utils.AddressToHash(this.UserAddress()));
234
- _context2.next = 5;
235
- return _regeneratorRuntime.awrap(this.client.ethClient.MakeProviderCall({
236
- methodName: "send",
237
- args: ["elv_getAccountProfile", [this.client.contentSpaceId, accountId]]
238
- }));
239
-
240
- case 5:
241
- this.profileData = _context2.sent;
242
-
243
- if (!(!this.profileData || !this.profileData.NFTs)) {
244
- _context2.next = 8;
245
- break;
246
- }
247
-
248
- return _context2.abrupt("return", {});
249
-
250
- case 8:
251
- nftInfo = {};
252
- Object.keys(this.profileData.NFTs).map(function (tenantId) {
253
- return _this.profileData.NFTs[tenantId].forEach(function (details) {
254
- var versionHash = (details.TokenUri || "").split("/").find(function (s) {
255
- return (s || "").startsWith("hq__");
256
- });
257
-
258
- if (!versionHash) {
259
- return;
260
- }
261
-
262
- if (details.TokenHold) {
263
- details.TokenHoldDate = new Date(parseInt(details.TokenHold) * 1000);
264
- }
265
-
266
- var contractAddress = Utils.FormatAddress(details.ContractAddr);
267
- var key = "".concat(contractAddress, "-").concat(details.TokenIdStr);
268
- nftInfo[key] = _objectSpread({}, details, {
269
- ContractAddr: Utils.FormatAddress(details.ContractAddr),
270
- ContractId: "ictr".concat(Utils.AddressToHash(details.ContractAddr)),
271
- VersionHash: versionHash
272
- });
273
- });
274
- });
275
- this.nftInfo = nftInfo;
276
- return _context2.abrupt("return", this.nftInfo);
277
-
278
- case 12:
279
- case "end":
280
- return _context2.stop();
281
- }
282
- }
283
- }, null, this);
284
- };
285
- /**
286
- * <b><i>Requires login</i></b>
287
- *
288
- * Retrieve items owned by the current user matching the specified parameters.
289
- *
290
- * @methodGroup User
291
- * @namedParams
292
- * @param {integer=} start=0 - PAGINATION: Index from which the results should start
293
- * @param {integer=} limit=50 - PAGINATION: Maximum number of results to return
294
- * @param {string=} sortBy="created" - Sort order. Options: `default`, `meta/display_name`
295
- * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
296
- * @param {string=} filter - Filter results by item name.
297
- * @param {string=} contractAddress - Filter results by the address of the NFT contract
298
- * @param {string=} tokenId - Filter by token ID (if filtering by contract address)
299
- * @param {Object=} marketplaceParams - Filter results by marketplace
300
- * @param {integer=} collectionIndex - If filtering by marketplace, filter by collection. The index refers to the index in the array `marketplace.collections`
301
- *
302
- * @returns {Promise<Object>} - Results of the query and pagination info
303
- */
304
-
305
-
306
- exports.UserItems = function _callee3() {
307
- var _args3 = arguments;
308
- return _regeneratorRuntime.async(function _callee3$(_context3) {
309
- while (1) {
310
- switch (_context3.prev = _context3.next) {
311
- case 0:
312
- return _context3.abrupt("return", this.FilteredQuery(_objectSpread({
313
- mode: "owned"
314
- }, _args3[0] || {})));
315
-
316
- case 1:
317
- case "end":
318
- return _context3.stop();
319
- }
320
- }
321
- }, null, this);
322
- };
323
- /**
324
- * Return all listings for the current user. Not paginated.
325
- *
326
- * @methodGroup User
327
- * @namedParams
328
- * @param {string=} sortBy="created" - Sort order. Options: `created`, `info/token_id`, `info/ordinal`, `price`, `nft/display_name`
329
- * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
330
- * @param {Object=} marketplaceParams - Filter results by marketplace
331
- * @param {string=} contractAddress - Filter results by the address of the NFT contract
332
- * @param {string=} tokenId - Filter by token ID (if filtering by contract address)
333
- *
334
- * @returns {Promise<Array<Object>>} - List of current user's listings
335
- */
336
-
337
-
338
- exports.UserListings = function _callee4() {
339
- var _ref2,
340
- _ref2$sortBy,
341
- sortBy,
342
- _ref2$sortDesc,
343
- sortDesc,
344
- contractAddress,
345
- tokenId,
346
- marketplaceParams,
347
- _args4 = arguments;
348
-
349
- return _regeneratorRuntime.async(function _callee4$(_context4) {
350
- while (1) {
351
- switch (_context4.prev = _context4.next) {
352
- case 0:
353
- _ref2 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref2$sortBy = _ref2.sortBy, sortBy = _ref2$sortBy === void 0 ? "created" : _ref2$sortBy, _ref2$sortDesc = _ref2.sortDesc, sortDesc = _ref2$sortDesc === void 0 ? false : _ref2$sortDesc, contractAddress = _ref2.contractAddress, tokenId = _ref2.tokenId, marketplaceParams = _ref2.marketplaceParams;
354
- _context4.next = 3;
355
- return _regeneratorRuntime.awrap(this.FilteredQuery({
356
- mode: "listings",
357
- start: 0,
358
- limit: 10000,
359
- sortBy: sortBy,
360
- sortDesc: sortDesc,
361
- sellerAddress: this.UserAddress(),
362
- marketplaceParams: marketplaceParams,
363
- contractAddress: contractAddress,
364
- tokenId: tokenId
365
- }));
366
-
367
- case 3:
368
- return _context4.abrupt("return", _context4.sent.results);
369
-
370
- case 4:
371
- case "end":
372
- return _context4.stop();
373
- }
374
- }
375
- }, null, this);
376
- };
377
- /**
378
- * Return all sales for the current user. Not paginated.
379
- *
380
- * @methodGroup User
381
- * @namedParams
382
- * @param {string=} sortBy="created" - Sort order. Options: `created`, `price`, `name`
383
- * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
384
- * @param {Object=} marketplaceParams - Filter results by marketplace
385
- * @param {string=} contractAddress - Filter results by the address of the NFT contract
386
- * @param {string=} tokenId - Filter by token ID (if filtering by contract address)
387
- * @param {integer=} lastNDays - Filter by results listed in the past N days
388
- *
389
- * @returns {Promise<Array<Object>>} - List of current user's sales
390
- */
391
-
392
-
393
- exports.UserSales = function _callee5() {
394
- var _ref3,
395
- _ref3$sortBy,
396
- sortBy,
397
- _ref3$sortDesc,
398
- sortDesc,
399
- contractAddress,
400
- tokenId,
401
- marketplaceParams,
402
- _args5 = arguments;
403
-
404
- return _regeneratorRuntime.async(function _callee5$(_context5) {
405
- while (1) {
406
- switch (_context5.prev = _context5.next) {
407
- case 0:
408
- _ref3 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref3$sortBy = _ref3.sortBy, sortBy = _ref3$sortBy === void 0 ? "created" : _ref3$sortBy, _ref3$sortDesc = _ref3.sortDesc, sortDesc = _ref3$sortDesc === void 0 ? false : _ref3$sortDesc, contractAddress = _ref3.contractAddress, tokenId = _ref3.tokenId, marketplaceParams = _ref3.marketplaceParams;
409
- _context5.next = 3;
410
- return _regeneratorRuntime.awrap(this.FilteredQuery({
411
- mode: "sales",
412
- start: 0,
413
- limit: 10000,
414
- sortBy: sortBy,
415
- sortDesc: sortDesc,
416
- sellerAddress: this.UserAddress(),
417
- marketplaceParams: marketplaceParams,
418
- contractAddress: contractAddress,
419
- tokenId: tokenId
420
- }));
421
-
422
- case 3:
423
- return _context5.abrupt("return", _context5.sent.results);
424
-
425
- case 4:
426
- case "end":
427
- return _context5.stop();
428
- }
429
- }
430
- }, null, this);
431
- };
432
- /* TENANT */
433
-
434
- /**
435
- * Retrieve configuration information about the specified tenant, or the tenant associated with the specified contract.
436
- *
437
- * This information includes the royalty rate the tenant receives for secondary sales.
438
- *
439
- * @methodGroup Tenants
440
- * @namedParams
441
- * @param {string=} tenantId - The ID of the tenant for which to retrieve configuration
442
- * @param {string=} contractAddress - The ID of an nft contract for which to retrieve configuration
443
- *
444
- * @returns {Promise<{Object}>} - The tenant configuration
445
- */
446
-
447
-
448
- exports.TenantConfiguration = function _callee6(_ref4) {
449
- var tenantId, contractAddress;
450
- return _regeneratorRuntime.async(function _callee6$(_context6) {
451
- while (1) {
452
- switch (_context6.prev = _context6.next) {
453
- case 0:
454
- tenantId = _ref4.tenantId, contractAddress = _ref4.contractAddress;
455
- _context6.prev = 1;
456
- _context6.next = 4;
457
- return _regeneratorRuntime.awrap(this.utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
458
- path: contractAddress ? UrlJoin("as", "config", "nft", contractAddress) : UrlJoin("as", "config", "tnt", tenantId),
459
- method: "GET"
460
- })));
461
-
462
- case 4:
463
- return _context6.abrupt("return", _context6.sent);
464
-
465
- case 7:
466
- _context6.prev = 7;
467
- _context6.t0 = _context6["catch"](1);
468
- this.Log("Failed to load tenant configuration", true);
469
- this.Log(_context6.t0, true);
470
- return _context6.abrupt("return", {});
471
-
472
- case 12:
473
- case "end":
474
- return _context6.stop();
475
- }
476
- }
477
- }, null, this, [[1, 7]]);
478
- };
479
- /* MARKETPLACE */
480
-
481
- /**
482
- * Retrieve available stock for the specified marketplace, organized by SKU.
483
- *
484
- * If a user is logged in, stock information will also include how many of that item the user has purchased.
485
- *
486
- * @methodGroup Marketplaces
487
- * @namedParams
488
- * @param {Object} marketplaceParams - Parameters of the marketplace
489
- *
490
- * @returns {Promise<Object>} - Stock info for items in the marketplace
491
- */
492
-
493
-
494
- exports.MarketplaceStock = function _callee7(_ref5) {
495
- var marketplaceParams, tenantId, marketplaceInfo;
496
- return _regeneratorRuntime.async(function _callee7$(_context7) {
497
- while (1) {
498
- switch (_context7.prev = _context7.next) {
499
- case 0:
500
- marketplaceParams = _ref5.marketplaceParams, tenantId = _ref5.tenantId;
501
-
502
- if (!tenantId) {
503
- marketplaceInfo = this.MarketplaceInfo({
504
- marketplaceParams: marketplaceParams
505
- });
506
- tenantId = marketplaceInfo.tenantId;
507
- }
508
-
509
- if (!this.loggedIn) {
510
- _context7.next = 6;
511
- break;
512
- }
513
-
514
- _context7.next = 5;
515
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
516
- path: UrlJoin("as", "wlt", "nft", "info", tenantId),
517
- method: "GET",
518
- headers: {
519
- Authorization: "Bearer ".concat(this.AuthToken())
520
- }
521
- })));
522
-
523
- case 5:
524
- return _context7.abrupt("return", _context7.sent);
525
-
526
- case 6:
527
- _context7.next = 8;
528
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
529
- path: UrlJoin("as", "nft", "stock", tenantId),
530
- method: "GET"
531
- })));
532
-
533
- case 8:
534
- return _context7.abrupt("return", _context7.sent);
535
-
536
- case 9:
537
- case "end":
538
- return _context7.stop();
539
- }
540
- }
541
- }, null, this);
542
- };
543
- /**
544
- * Retrieve basic information about a specific available marketplace with the specified tenant/marketplace slug, ID, or hash.
545
- *
546
- * Includes the slugs, ID and hash of the marketplace, as well as branding information.
547
- *
548
- * To retrieve full metadata for the marketplace, use the <a href="#.Marketplace">Marketplace</a> method.
549
- *
550
- * @methodGroup Marketplaces
551
- * @namedParams
552
- * @param {Object} marketplaceParams - Parameters of the marketplace
553
- *
554
- * @returns {Promise<Object>} - Info about the marketplace
555
- */
556
-
557
-
558
- exports.MarketplaceInfo = function (_ref6) {
559
- var marketplaceParams = _ref6.marketplaceParams;
560
-
561
- var _ref7 = marketplaceParams || {},
562
- tenantSlug = _ref7.tenantSlug,
563
- marketplaceSlug = _ref7.marketplaceSlug,
564
- marketplaceId = _ref7.marketplaceId,
565
- marketplaceHash = _ref7.marketplaceHash;
566
-
567
- var marketplaceInfo;
568
-
569
- if (tenantSlug && marketplaceSlug) {
570
- marketplaceInfo = (this.availableMarketplaces[tenantSlug] || {})[marketplaceSlug];
571
- } else {
572
- marketplaceInfo = this.availableMarketplacesById[marketplaceId || this.client.utils.DecodeVersionHash(marketplaceHash).objectId];
573
- }
574
-
575
- if (!marketplaceInfo) {
576
- throw Error("Eluvio Wallet Client: Unable to find marketplace with parameters ".concat(JSON.stringify(arguments)));
577
- }
578
-
579
- return marketplaceInfo;
580
- };
581
- /**
582
- * Retrieve custom CSS for the specified marketplace
583
- *
584
- * @methodGroup Marketplaces
585
- * @namedParams
586
- * @param {Object} marketplaceParams - Parameters of the marketplace
587
- *
588
- * @returns {Promise<string>} - The CSS of the marketplace
589
- */
590
-
591
-
592
- exports.MarketplaceCSS = function _callee8(_ref8) {
593
- var marketplaceParams, marketplaceInfo, marketplaceHash;
594
- return _regeneratorRuntime.async(function _callee8$(_context8) {
595
- while (1) {
596
- switch (_context8.prev = _context8.next) {
597
- case 0:
598
- marketplaceParams = _ref8.marketplaceParams;
599
- marketplaceInfo = this.MarketplaceInfo({
600
- marketplaceParams: marketplaceParams
601
- });
602
- marketplaceHash = marketplaceInfo.marketplaceHash;
603
-
604
- if (this.cachedCSS[marketplaceHash]) {
605
- _context8.next = 7;
606
- break;
607
- }
608
-
609
- _context8.next = 6;
610
- return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
611
- versionHash: marketplaceHash,
612
- metadataSubtree: "public/asset_metadata/info/branding/custom_css",
613
- authorizationToken: this.publicStaticToken,
614
- noAuth: true
615
- }));
616
-
617
- case 6:
618
- this.cachedCSS[marketplaceHash] = _context8.sent;
619
-
620
- case 7:
621
- return _context8.abrupt("return", this.cachedCSS[marketplaceHash] || "");
622
-
623
- case 8:
624
- case "end":
625
- return _context8.stop();
626
- }
627
- }
628
- }, null, this);
629
- };
630
- /**
631
- * Retrieve info about all available marketplaces
632
- *
633
- * @methodGroup Marketplaces
634
- * @namedParams
635
- * @param {boolean=} organizeById - By default, the returned marketplace info is organized by tenant and marketplace slug. If this option is enabled, the marketplaces will be organized by marketplace ID instead.
636
- * @param {boolean=} forceReload=false - If specified, a new request will be made to check the currently available marketplaces instead of returning cached info
637
- *
638
- * @returns {Promise<{Object}>} - Info about available marketplaces
639
- */
640
-
641
-
642
- exports.AvailableMarketplaces = function _callee9() {
643
- var _ref9,
644
- organizeById,
645
- _ref9$forceReload,
646
- forceReload,
647
- _args9 = arguments;
648
-
649
- return _regeneratorRuntime.async(function _callee9$(_context9) {
650
- while (1) {
651
- switch (_context9.prev = _context9.next) {
652
- case 0:
653
- _ref9 = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {}, organizeById = _ref9.organizeById, _ref9$forceReload = _ref9.forceReload, forceReload = _ref9$forceReload === void 0 ? false : _ref9$forceReload;
654
-
655
- if (!forceReload) {
656
- _context9.next = 4;
657
- break;
658
- }
659
-
660
- _context9.next = 4;
661
- return _regeneratorRuntime.awrap(this.LoadAvailableMarketplaces(true));
662
-
663
- case 4:
664
- return _context9.abrupt("return", _objectSpread({}, organizeById ? this.availableMarketplacesById : this.availableMarketplaces));
665
-
666
- case 5:
667
- case "end":
668
- return _context9.stop();
669
- }
670
- }
671
- }, null, this);
672
- };
673
- /**
674
- * Retrieve full information about the specified marketplace
675
- *
676
- * <b><i>Note</i></b> - Upon changing login state, the marketplace should be retrieved again as permission info in marketplace items may be different depending on the current user's permissions.
677
- *
678
- * @methodGroup Marketplaces
679
- * @namedParams
680
- * @param {Object} marketplaceParams - Parameters of the marketplace
681
- *
682
- * @returns {Promise<Object>} - The full information for the marketplace
683
- */
684
-
685
-
686
- exports.Marketplace = function _callee10(_ref10) {
687
- var marketplaceParams;
688
- return _regeneratorRuntime.async(function _callee10$(_context10) {
689
- while (1) {
690
- switch (_context10.prev = _context10.next) {
691
- case 0:
692
- marketplaceParams = _ref10.marketplaceParams;
693
- return _context10.abrupt("return", this.LoadMarketplace(marketplaceParams));
694
-
695
- case 2:
696
- case "end":
697
- return _context10.stop();
698
- }
699
- }
700
- }, null, this);
701
- };
702
- /* NFTS */
703
-
704
- /**
705
- * Load full info for the specified NFT
706
- *
707
- * @methodGroup Items
708
- * @namedParams
709
- * @param {string} contractAddress - The contract address of the NFT
710
- * @param {string} tokenId - The token ID of the NFT
711
- */
712
-
713
-
714
- exports.NFT = function _callee11(_ref11) {
715
- var tokenId, contractAddress, nft;
716
- return _regeneratorRuntime.async(function _callee11$(_context11) {
717
- while (1) {
718
- switch (_context11.prev = _context11.next) {
719
- case 0:
720
- tokenId = _ref11.tokenId, contractAddress = _ref11.contractAddress;
721
- _context11.t0 = FormatNFTDetails;
722
- _context11.next = 4;
723
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
724
- path: UrlJoin("as", "nft", "info", contractAddress, tokenId),
725
- method: "GET"
726
- })));
727
-
728
- case 4:
729
- _context11.t1 = _context11.sent;
730
- nft = (0, _context11.t0)(_context11.t1);
731
- _context11.t2 = _objectSpread;
732
- _context11.t3 = {};
733
- _context11.next = 10;
734
- return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
735
- versionHash: nft.details.VersionHash,
736
- metadataSubtree: "public/asset_metadata/nft",
737
- produceLinkUrls: true
738
- }));
739
-
740
- case 10:
741
- _context11.t4 = _context11.sent;
742
-
743
- if (_context11.t4) {
744
- _context11.next = 13;
745
- break;
746
- }
747
-
748
- _context11.t4 = {};
749
-
750
- case 13:
751
- _context11.t5 = _context11.t4;
752
- _context11.t6 = {};
753
- _context11.t7 = nft.metadata || {};
754
- nft.metadata = (0, _context11.t2)(_context11.t3, _context11.t5, _context11.t6, _context11.t7);
755
- _context11.next = 19;
756
- return _regeneratorRuntime.awrap(this.TenantConfiguration({
757
- contractAddress: contractAddress
758
- }));
759
-
760
- case 19:
761
- nft.config = _context11.sent;
762
- return _context11.abrupt("return", FormatNFTMetadata(nft));
763
-
764
- case 21:
765
- case "end":
766
- return _context11.stop();
767
- }
768
- }
769
- }, null, this);
770
- };
771
- /** LISTINGS */
772
-
773
- /**
774
- * Retrieve the status of the specified listing
775
- *
776
- * @methodGroup Listings
777
- * @namedParams
778
- * @param {string=} listingId - The ID of the listing
779
- *
780
- * @returns {Promise<Object>} - The status of the listing
781
- */
782
-
783
-
784
- exports.ListingStatus = function _callee12(_ref12) {
785
- var listingId;
786
- return _regeneratorRuntime.async(function _callee12$(_context12) {
787
- while (1) {
788
- switch (_context12.prev = _context12.next) {
789
- case 0:
790
- listingId = _ref12.listingId;
791
- _context12.prev = 1;
792
- _context12.t0 = _regeneratorRuntime;
793
- _context12.t1 = Utils;
794
- _context12.next = 6;
795
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
796
- path: UrlJoin("as", "mkt", "status", listingId),
797
- method: "GET"
798
- }));
799
-
800
- case 6:
801
- _context12.t2 = _context12.sent;
802
- _context12.t3 = _context12.t1.ResponseToJson.call(_context12.t1, _context12.t2);
803
- _context12.next = 10;
804
- return _context12.t0.awrap.call(_context12.t0, _context12.t3);
805
-
806
- case 10:
807
- return _context12.abrupt("return", _context12.sent);
808
-
809
- case 13:
810
- _context12.prev = 13;
811
- _context12.t4 = _context12["catch"](1);
812
-
813
- if (!(_context12.t4.status === 404)) {
814
- _context12.next = 17;
815
- break;
816
- }
817
-
818
- return _context12.abrupt("return");
819
-
820
- case 17:
821
- throw _context12.t4;
822
-
823
- case 18:
824
- case "end":
825
- return _context12.stop();
826
- }
827
- }
828
- }, null, this, [[1, 13]]);
829
- };
830
- /**
831
- * Retrieve a specific listing
832
- *
833
- * NOTE: When a listing is sold or deleted, it will no longer be queryable with this API. Use <a href="#.ListingStatus">ListingStatus</a> instead.
834
- *
835
- * @methodGroup Listings
836
- * @namedParams
837
- * @param {string=} listingId - The ID of the listing
838
- *
839
- * @returns {Promise<Object>} - The listing
840
- */
841
-
842
-
843
- exports.Listing = function _callee13(_ref13) {
844
- var listingId;
845
- return _regeneratorRuntime.async(function _callee13$(_context13) {
846
- while (1) {
847
- switch (_context13.prev = _context13.next) {
848
- case 0:
849
- listingId = _ref13.listingId;
850
- _context13.t0 = FormatNFT;
851
- _context13.t1 = _regeneratorRuntime;
852
- _context13.t2 = Utils;
853
- _context13.next = 6;
854
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
855
- path: UrlJoin("as", "mkt", "l", listingId),
856
- method: "GET"
857
- }));
858
-
859
- case 6:
860
- _context13.t3 = _context13.sent;
861
- _context13.t4 = _context13.t2.ResponseToJson.call(_context13.t2, _context13.t3);
862
- _context13.next = 10;
863
- return _context13.t1.awrap.call(_context13.t1, _context13.t4);
864
-
865
- case 10:
866
- _context13.t5 = _context13.sent;
867
- return _context13.abrupt("return", (0, _context13.t0)(_context13.t5));
868
-
869
- case 12:
870
- case "end":
871
- return _context13.stop();
872
- }
873
- }
874
- }, null, this);
875
- };
876
- /**
877
- * Retrieve listings matching the specified parameters.
878
- *
879
- * @methodGroup Listings
880
- * @namedParams
881
- * @param {integer=} start=0 - PAGINATION: Index from which the results should start
882
- * @param {integer=} limit=50 - PAGINATION: Maximum number of results to return
883
- * @param {string=} sortBy="created" - Sort order. Options: `created`, `info/token_id`, `info/ordinal`, `price`, `nft/display_name`
884
- * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
885
- * @param {string=} filter - Filter results by item name.
886
- * <br /><br />
887
- * NOTE: This string must be an <b>exact match</b> on the item name.
888
- * You can retrieve all available item names from the <a href="#.ListingNames">ListingNames method</a>.
889
- * @param {string=} editionFilter - Filter results by item edition.
890
- * <br /><br />
891
- * NOTE: This string must be an <b>exact match</b> on the edition name.
892
- * You can retrieve all available item edition names from the <a href="#.ListingEditionNames">ListingEditionNames method</a>.
893
- * @param {Array<Object>} attributeFilters - Filter results by item attributes. Each entry should include name and value (e.g. `[{name: "attribute-name", value: "attribute-value"}]`)
894
- * <br /><br />
895
- * NOTE: These filters must be an <b>exact match</b> on the attribute name and value.
896
- * You can retrieve all available item attributes from the <a href="#.ListingAttributes">ListingAttributes method</a>.
897
- * @param {string=} sellerAddress - Filter by a specific seller
898
- * @param {string=} contractAddress - Filter results by the address of the NFT contract
899
- * @param {string=} tokenId - Filter by token ID (if filtering by contract address)
900
- * @param {string=} currency - Filter results by purchase currency. Available options: `usdc`
901
- * @param {Object=} marketplaceParams - Filter results by marketplace
902
- * @param {integer=} collectionIndex - If filtering by marketplace, filter by collection. The index refers to the index in the array `marketplace.collections`
903
- * @param {integer=} lastNDays - Filter by results listed in the past N days
904
- *
905
- * @returns {Promise<Object>} - Results of the query and pagination info
906
- */
907
-
908
-
909
- exports.Listings = function _callee14() {
910
- var _args14 = arguments;
911
- return _regeneratorRuntime.async(function _callee14$(_context14) {
912
- while (1) {
913
- switch (_context14.prev = _context14.next) {
914
- case 0:
915
- return _context14.abrupt("return", this.FilteredQuery(_objectSpread({
916
- mode: "listings"
917
- }, _args14[0] || {})));
918
-
919
- case 1:
920
- case "end":
921
- return _context14.stop();
922
- }
923
- }
924
- }, null, this);
925
- };
926
- /**
927
- * Retrieve stats for listings matching the specified parameters.
928
- *
929
- * @methodGroup Listings
930
- * @namedParams
931
- * @param {integer=} start=0 - PAGINATION: Index from which the results should start
932
- * @param {integer=} limit=50 - PAGINATION: Maximum number of results to return
933
- * @param {string=} sortBy="created" - Sort order. Options: `created`, `info/token_id`, `info/ordinal`, `price`, `nft/display_name`
934
- * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
935
- * @param {string=} filter - Filter results by item name.
936
- * <br /><br />
937
- * NOTE: This string must be an <b>exact match</b> on the item name.
938
- * You can retrieve all available item names from the <a href="#.ListingNames">ListingNames method</a>.
939
- * @param {string=} editionFilter - Filter results by item edition.
940
- * <br /><br />
941
- * NOTE: This string must be an <b>exact match</b> on the edition name.
942
- * You can retrieve all available item edition names from the <a href="#.ListingEditionNames">ListingEditionNames method</a>.
943
- * @param {Array<Object>} attributeFilters - Filter results by item attributes. Each entry should include name and value (e.g. `[{name: "attribute-name", value: "attribute-value"}]`)
944
- * <br /><br />
945
- * NOTE: These filters must be an <b>exact match</b> on the attribute name and value.
946
- * You can retrieve all available item attributes from the <a href="#.ListingAttributes">ListingAttributes method</a>.
947
- * @param {string=} sellerAddress - Filter by a specific seller
948
- * @param {string=} contractAddress - Filter results by the address of the NFT contract
949
- * @param {string=} tokenId - Filter by token ID (if filtering by contract address)
950
- * @param {string=} currency - Filter results by purchase currency. Available options: `usdc`
951
- * @param {Object=} marketplaceParams - Filter results by marketplace
952
- * @param {integer=} collectionIndex - If filtering by marketplace, filter by collection. The index refers to the index in the array `marketplace.collections`
953
- * @param {integer=} lastNDays - Filter by results listed in the past N days
954
- *
955
- * @returns {Promise<Object>} - Statistics about listings. All prices in USD.
956
- */
957
-
958
-
959
- exports.ListingStats = function _callee15() {
960
- var _args15 = arguments;
961
- return _regeneratorRuntime.async(function _callee15$(_context15) {
962
- while (1) {
963
- switch (_context15.prev = _context15.next) {
964
- case 0:
965
- return _context15.abrupt("return", this.FilteredQuery(_objectSpread({
966
- mode: "listing-stats"
967
- }, _args15[0] || {})));
968
-
969
- case 1:
970
- case "end":
971
- return _context15.stop();
972
- }
973
- }
974
- }, null, this);
975
- };
976
- /**
977
- * Retrieve sales matching the specified parameters.
978
- *
979
- * @methodGroup Listings
980
- * @namedParams
981
- * @param {integer=} start=0 - PAGINATION: Index from which the results should start
982
- * @param {integer=} limit=50 - PAGINATION: Maximum number of results to return
983
- * @param {string=} sortBy="created" - Sort order. Options: `created`, `price`, `name`
984
- * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
985
- * @param {string=} filter - Filter results by item name.
986
- * <br /><br />
987
- * NOTE: This string must be an <b>exact match</b> on the item name.
988
- * You can retrieve all available item names from the <a href="#.ListingNames">ListingNames method</a>.
989
- * @param {string=} editionFilter - Filter results by item edition.
990
- * <br /><br />
991
- * NOTE: This string must be an <b>exact match</b> on the edition name.
992
- * You can retrieve all available item edition names from the <a href="#.ListingEditionNames">ListingEditionNames method</a>.
993
- * @param {Array<Object>} attributeFilters - Filter results by item attributes. Each entry should include name and value (e.g. `[{name: "attribute-name", value: "attribute-value"}]`)
994
- * <br /><br />
995
- * NOTE: These filters must be an <b>exact match</b> on the attribute name and value.
996
- * You can retrieve all available item attributes from the <a href="#.ListingAttributes">ListingAttributes method</a>.
997
- * @param {string=} sellerAddress - Filter by a specific seller
998
- * @param {string=} contractAddress - Filter results by the address of the NFT contract
999
- * @param {string=} tokenId - Filter by token ID (if filtering by contract address)
1000
- * @param {string=} currency - Filter results by purchase currency. Available options: `usdc`
1001
- * @param {Object=} marketplaceParams - Filter results by marketplace
1002
- * @param {integer=} collectionIndex - If filtering by marketplace, filter by collection. The index refers to the index in the array `marketplace.collections`
1003
- * @param {integer=} lastNDays - Filter by results listed in the past N days
1004
- *
1005
- * @returns {Promise<Object>} - Results of the query and pagination info
1006
- */
1007
-
1008
-
1009
- exports.Sales = function _callee16() {
1010
- var _args16 = arguments;
1011
- return _regeneratorRuntime.async(function _callee16$(_context16) {
1012
- while (1) {
1013
- switch (_context16.prev = _context16.next) {
1014
- case 0:
1015
- return _context16.abrupt("return", this.FilteredQuery(_objectSpread({
1016
- mode: "sales"
1017
- }, _args16[0] || {})));
1018
-
1019
- case 1:
1020
- case "end":
1021
- return _context16.stop();
1022
- }
1023
- }
1024
- }, null, this);
1025
- };
1026
- /**
1027
- * Retrieve stats for listings matching the specified parameters.
1028
- *
1029
- * @methodGroup Listings
1030
- * @namedParams
1031
- * @param {integer=} start=0 - PAGINATION: Index from which the results should start
1032
- * @param {integer=} limit=50 - PAGINATION: Maximum number of results to return
1033
- * @param {string=} sortBy="created" -
1034
- * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
1035
- * @param {string=} filter - Filter results by item name.
1036
- * <br /><br />
1037
- * NOTE: This string must be an <b>exact match</b> on the item name.
1038
- * You can retrieve all available item names from the <a href="#.ListingNames">ListingNames method</a>.
1039
- * @param {string=} editionFilter - Filter results by item edition.
1040
- * <br /><br />
1041
- * NOTE: This string must be an <b>exact match</b> on the edition name.
1042
- * You can retrieve all available item edition names from the <a href="#.ListingEditionNames">ListingEditionNames method</a>.
1043
- * @param {Array<Object>} attributeFilters - Filter results by item attributes. Each entry should include name and value (e.g. `[{name: "attribute-name", value: "attribute-value"}]`)
1044
- * <br /><br />
1045
- * NOTE: These filters must be an <b>exact match</b> on the attribute name and value.
1046
- * You can retrieve all available item attributes from the <a href="#.ListingAttributes">ListingAttributes method</a>.
1047
- * @param {string=} sellerAddress - Filter by a specific seller
1048
- * @param {string=} contractAddress - Filter results by the address of the NFT contract
1049
- * @param {string=} tokenId - Filter by token ID (if filtering by contract address)
1050
- * @param {string=} currency - Filter results by purchase currency. Available options: `usdc`
1051
- * @param {Object=} marketplaceParams - Filter results by marketplace
1052
- * @param {integer=} collectionIndex - If filtering by marketplace, filter by collection. The index refers to the index in the array `marketplace.collections`
1053
- * @param {integer=} lastNDays - Filter by results listed in the past N days
1054
- *
1055
- * @returns {Promise<Object>} - Statistics about sales. All prices in USD.
1056
- */
1057
-
1058
-
1059
- exports.SalesStats = function _callee17() {
1060
- var _args17 = arguments;
1061
- return _regeneratorRuntime.async(function _callee17$(_context17) {
1062
- while (1) {
1063
- switch (_context17.prev = _context17.next) {
1064
- case 0:
1065
- return _context17.abrupt("return", this.FilteredQuery(_objectSpread({
1066
- mode: "sales-stats"
1067
- }, _args17[0] || {})));
1068
-
1069
- case 1:
1070
- case "end":
1071
- return _context17.stop();
1072
- }
1073
- }
1074
- }, null, this);
1075
- };
1076
- /**
1077
- * <b><i>Requires login</i></b>
1078
- *
1079
- * Create or update a listing for the specified item
1080
- *
1081
- * @methodGroup Listings
1082
- * @namedParams
1083
- * @param {string} contractAddress - The NFT contract address of the item
1084
- * @param {string} tokenId - The token ID of the item
1085
- * @param {number} price - The price of the listing, in USD
1086
- * @param {string=} listingId - (When editing a listing) The ID of the existing listing
1087
- *
1088
- * @returns {Promise<string>} - The listing ID of the created listing
1089
- */
1090
-
1091
-
1092
- exports.CreateListing = function _callee18(_ref14) {
1093
- var contractAddress, tokenId, price, listingId;
1094
- return _regeneratorRuntime.async(function _callee18$(_context18) {
1095
- while (1) {
1096
- switch (_context18.prev = _context18.next) {
1097
- case 0:
1098
- contractAddress = _ref14.contractAddress, tokenId = _ref14.tokenId, price = _ref14.price, listingId = _ref14.listingId;
1099
- contractAddress = Utils.FormatAddress(contractAddress);
1100
-
1101
- if (!listingId) {
1102
- _context18.next = 14;
1103
- break;
1104
- }
1105
-
1106
- _context18.t0 = _regeneratorRuntime;
1107
- _context18.t1 = Utils;
1108
- _context18.next = 7;
1109
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
1110
- path: UrlJoin("as", "wlt", "mkt"),
1111
- method: "PUT",
1112
- body: {
1113
- id: listingId,
1114
- price: parseFloat(price)
1115
- },
1116
- headers: {
1117
- Authorization: "Bearer ".concat(this.AuthToken())
1118
- }
1119
- }));
1120
-
1121
- case 7:
1122
- _context18.t2 = _context18.sent;
1123
- _context18.t3 = _context18.t1.ResponseToFormat.call(_context18.t1, "text", _context18.t2);
1124
- _context18.next = 11;
1125
- return _context18.t0.awrap.call(_context18.t0, _context18.t3);
1126
-
1127
- case 11:
1128
- return _context18.abrupt("return", _context18.sent);
1129
-
1130
- case 14:
1131
- _context18.t4 = _regeneratorRuntime;
1132
- _context18.t5 = Utils;
1133
- _context18.next = 18;
1134
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
1135
- path: UrlJoin("as", "wlt", "mkt"),
1136
- method: "POST",
1137
- body: {
1138
- contract: contractAddress,
1139
- token: tokenId,
1140
- price: parseFloat(price)
1141
- },
1142
- headers: {
1143
- Authorization: "Bearer ".concat(this.AuthToken())
1144
- }
1145
- }));
1146
-
1147
- case 18:
1148
- _context18.t6 = _context18.sent;
1149
- _context18.t7 = _context18.t5.ResponseToJson.call(_context18.t5, _context18.t6);
1150
- _context18.next = 22;
1151
- return _context18.t4.awrap.call(_context18.t4, _context18.t7);
1152
-
1153
- case 22:
1154
- return _context18.abrupt("return", _context18.sent);
1155
-
1156
- case 23:
1157
- case "end":
1158
- return _context18.stop();
1159
- }
1160
- }
1161
- }, null, this);
1162
- };
1163
- /**
1164
- * <b><i>Requires login</i></b>
1165
- *
1166
- * Remove the specified listing
1167
- *
1168
- * @methodGroup Listings
1169
- * @namedParams
1170
- * @param {string} listingId - The ID of the listing to remove
1171
- */
1172
-
1173
-
1174
- exports.RemoveListing = function _callee19(_ref15) {
1175
- var listingId;
1176
- return _regeneratorRuntime.async(function _callee19$(_context19) {
1177
- while (1) {
1178
- switch (_context19.prev = _context19.next) {
1179
- case 0:
1180
- listingId = _ref15.listingId;
1181
- _context19.next = 3;
1182
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
1183
- path: UrlJoin("as", "wlt", "mkt", listingId),
1184
- method: "DELETE",
1185
- headers: {
1186
- Authorization: "Bearer ".concat(this.AuthToken())
1187
- }
1188
- }));
1189
-
1190
- case 3:
1191
- case "end":
1192
- return _context19.stop();
1193
- }
1194
- }
1195
- }, null, this);
1196
- };
1197
- /**
1198
- * Retrieve all valid names for filtering listings. Full item names are required for filtering listing results by name.
1199
- *
1200
- * Specify marketplace information to filter the results to only items offered in that marketplace.
1201
- *
1202
- * @methodGroup Listings
1203
- * @namedParams
1204
- * @param {Object} marketplaceParams - Parameters of a marketplace to filter results by
1205
- *
1206
- * @returns {Promise<Array<String>>} - A list of item names
1207
- */
1208
-
1209
-
1210
- exports.ListingNames = function _callee20(_ref16) {
1211
- var marketplaceParams, tenantId;
1212
- return _regeneratorRuntime.async(function _callee20$(_context20) {
1213
- while (1) {
1214
- switch (_context20.prev = _context20.next) {
1215
- case 0:
1216
- marketplaceParams = _ref16.marketplaceParams;
1217
-
1218
- if (!marketplaceParams) {
1219
- _context20.next = 5;
1220
- break;
1221
- }
1222
-
1223
- _context20.next = 4;
1224
- return _regeneratorRuntime.awrap(this.MarketplaceInfo({
1225
- marketplaceParams: marketplaceParams
1226
- }));
1227
-
1228
- case 4:
1229
- tenantId = _context20.sent.tenantId;
1230
-
1231
- case 5:
1232
- _context20.t0 = _regeneratorRuntime;
1233
- _context20.t1 = Utils;
1234
- _context20.next = 9;
1235
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
1236
- path: UrlJoin("as", "mkt", "names"),
1237
- method: "GET",
1238
- queryParams: tenantId ? {
1239
- filter: "tenant:eq:".concat(tenantId)
1240
- } : {}
1241
- }));
1242
-
1243
- case 9:
1244
- _context20.t2 = _context20.sent;
1245
- _context20.t3 = _context20.t1.ResponseToJson.call(_context20.t1, _context20.t2);
1246
- _context20.next = 13;
1247
- return _context20.t0.awrap.call(_context20.t0, _context20.t3);
1248
-
1249
- case 13:
1250
- return _context20.abrupt("return", _context20.sent);
1251
-
1252
- case 14:
1253
- case "end":
1254
- return _context20.stop();
1255
- }
1256
- }
1257
- }, null, this);
1258
- };
1259
- /**
1260
- * Retrieve all valid edition names of the specified item. Full item edition names are required for filtering listing results by edition.
1261
- *
1262
- * @methodGroup Listings
1263
- * @namedParams
1264
- * @param {string} displayName - Display name of the item from which to request edition names
1265
- *
1266
- * @returns {Promise<Array<String>>} - A list of item editions
1267
- */
1268
-
1269
-
1270
- exports.ListingEditionNames = function _callee21(_ref17) {
1271
- var displayName;
1272
- return _regeneratorRuntime.async(function _callee21$(_context21) {
1273
- while (1) {
1274
- switch (_context21.prev = _context21.next) {
1275
- case 0:
1276
- displayName = _ref17.displayName;
1277
- _context21.t0 = _regeneratorRuntime;
1278
- _context21.t1 = Utils;
1279
- _context21.next = 5;
1280
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
1281
- path: UrlJoin("as", "mkt", "editions"),
1282
- queryParams: {
1283
- filter: "nft/display_name:eq:".concat(displayName)
1284
- },
1285
- method: "GET"
1286
- }));
1287
-
1288
- case 5:
1289
- _context21.t2 = _context21.sent;
1290
- _context21.t3 = _context21.t1.ResponseToJson.call(_context21.t1, _context21.t2);
1291
- _context21.next = 9;
1292
- return _context21.t0.awrap.call(_context21.t0, _context21.t3);
1293
-
1294
- case 9:
1295
- return _context21.abrupt("return", _context21.sent);
1296
-
1297
- case 10:
1298
- case "end":
1299
- return _context21.stop();
1300
- }
1301
- }
1302
- }, null, this);
1303
- };
1304
- /**
1305
- * Retrieve names of all valid attributes for listed tiems. Full attribute names and values are required for filtering listing results by attributes.
1306
- *
1307
- * Specify marketplace information to filter the results to only items offered in that marketplace.
1308
- *
1309
- * @methodGroup Listings
1310
- * @namedParams
1311
- * @param {Object=} marketplaceParams - Parameters of a marketplace to filter results by
1312
- * @param {string=} displayName - Display name of the item from which to request attributes
1313
- *
1314
- * @returns {Promise<Array<String>>} - A list of valid attributes
1315
- */
1316
-
1317
-
1318
- exports.ListingAttributes = function _callee22() {
1319
- var _ref18,
1320
- marketplaceParams,
1321
- displayName,
1322
- filters,
1323
- attributes,
1324
- _args22 = arguments;
1325
-
1326
- return _regeneratorRuntime.async(function _callee22$(_context22) {
1327
- while (1) {
1328
- switch (_context22.prev = _context22.next) {
1329
- case 0:
1330
- _ref18 = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {}, marketplaceParams = _ref18.marketplaceParams, displayName = _ref18.displayName;
1331
- filters = [];
1332
-
1333
- if (!marketplaceParams) {
1334
- _context22.next = 10;
1335
- break;
1336
- }
1337
-
1338
- _context22.t0 = filters;
1339
- _context22.t1 = "tenant:eq:";
1340
- _context22.next = 7;
1341
- return _regeneratorRuntime.awrap(this.MarketplaceInfo({
1342
- marketplaceParams: marketplaceParams
1343
- }));
1344
-
1345
- case 7:
1346
- _context22.t2 = _context22.sent.tenantId;
1347
- _context22.t3 = _context22.t1.concat.call(_context22.t1, _context22.t2);
1348
-
1349
- _context22.t0.push.call(_context22.t0, _context22.t3);
1350
-
1351
- case 10:
1352
- if (displayName) {
1353
- filters.push("nft/display_name:eq:".concat(displayName));
1354
- }
1355
-
1356
- _context22.t4 = _regeneratorRuntime;
1357
- _context22.t5 = Utils;
1358
- _context22.next = 15;
1359
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
1360
- path: UrlJoin("as", "mkt", "attributes"),
1361
- method: "GET",
1362
- queryParams: {
1363
- filter: filters
1364
- }
1365
- }));
1366
-
1367
- case 15:
1368
- _context22.t6 = _context22.sent;
1369
- _context22.t7 = _context22.t5.ResponseToJson.call(_context22.t5, _context22.t6);
1370
- _context22.next = 19;
1371
- return _context22.t4.awrap.call(_context22.t4, _context22.t7);
1372
-
1373
- case 19:
1374
- attributes = _context22.sent;
1375
- return _context22.abrupt("return", attributes.map(function (_ref19) {
1376
- var trait_type = _ref19.trait_type,
1377
- values = _ref19.values;
1378
- return {
1379
- name: trait_type,
1380
- values: values
1381
- };
1382
- }).filter(function (_ref20) {
1383
- var name = _ref20.name;
1384
- return !["Content Fabric Hash", "Total Minted Supply", "Creator"].includes(name);
1385
- }));
1386
-
1387
- case 21:
1388
- case "end":
1389
- return _context22.stop();
1390
- }
1391
- }
1392
- }, null, this);
1393
- };
1394
- /* MINTING STATUS */
1395
-
1396
- /**
1397
- * Return status of the specified listing purchase
1398
- *
1399
- * @methodGroup Status
1400
- * @namedParams
1401
- * @param {string} listingId - The ID of the listing
1402
- * @param {string} confirmationId - The confirmation ID of the purchase
1403
- *
1404
- * @returns {Promise<Object>} - The status of the purchase
1405
- */
1406
-
1407
-
1408
- exports.ListingPurchaseStatus = function _callee23(_ref21) {
1409
- var listingId, confirmationId, listingStatus, statuses;
1410
- return _regeneratorRuntime.async(function _callee23$(_context23) {
1411
- while (1) {
1412
- switch (_context23.prev = _context23.next) {
1413
- case 0:
1414
- listingId = _ref21.listingId, confirmationId = _ref21.confirmationId;
1415
- _context23.prev = 1;
1416
- _context23.next = 4;
1417
- return _regeneratorRuntime.awrap(this.ListingStatus({
1418
- listingId: listingId
1419
- }));
1420
-
1421
- case 4:
1422
- listingStatus = _context23.sent;
1423
-
1424
- if (listingStatus) {
1425
- _context23.next = 7;
1426
- break;
1427
- }
1428
-
1429
- throw Error("Unable to find info for listing " + listingId);
1430
-
1431
- case 7:
1432
- _context23.next = 9;
1433
- return _regeneratorRuntime.awrap(this.MintingStatus({
1434
- tenantId: listingStatus.tenant
1435
- }));
1436
-
1437
- case 9:
1438
- statuses = _context23.sent;
1439
- return _context23.abrupt("return", statuses.find(function (status) {
1440
- return status.op === "nft-transfer" && status.extra && status.extra[0] === confirmationId;
1441
- }) || {
1442
- status: "none"
1443
- });
1444
-
1445
- case 13:
1446
- _context23.prev = 13;
1447
- _context23.t0 = _context23["catch"](1);
1448
- this.Log(_context23.t0, true);
1449
- return _context23.abrupt("return", {
1450
- status: "unknown"
1451
- });
1452
-
1453
- case 17:
1454
- case "end":
1455
- return _context23.stop();
1456
- }
1457
- }
1458
- }, null, this, [[1, 13]]);
1459
- };
1460
- /**
1461
- * Return status of the specified marketplace purchase
1462
- *
1463
- * @methodGroup Status
1464
- * @namedParams
1465
- * @param {Object} marketplaceParams - Parameters of the marketplace
1466
- * @param {string} confirmationId - The confirmation ID of the purchase
1467
- *
1468
- * @returns {Promise<Object>} - The minting status of the purchaseed item(s)
1469
- */
1470
-
1471
-
1472
- exports.PurchaseStatus = function _callee24(_ref22) {
1473
- var marketplaceParams, confirmationId, marketplaceInfo, statuses;
1474
- return _regeneratorRuntime.async(function _callee24$(_context24) {
1475
- while (1) {
1476
- switch (_context24.prev = _context24.next) {
1477
- case 0:
1478
- marketplaceParams = _ref22.marketplaceParams, confirmationId = _ref22.confirmationId;
1479
- _context24.prev = 1;
1480
- _context24.next = 4;
1481
- return _regeneratorRuntime.awrap(this.MarketplaceInfo({
1482
- marketplaceParams: marketplaceParams
1483
- }));
1484
-
1485
- case 4:
1486
- marketplaceInfo = _context24.sent;
1487
- _context24.next = 7;
1488
- return _regeneratorRuntime.awrap(this.MintingStatus({
1489
- tenantId: marketplaceInfo.tenant_id
1490
- }));
1491
-
1492
- case 7:
1493
- statuses = _context24.sent;
1494
- return _context24.abrupt("return", statuses.find(function (status) {
1495
- return status.op === "nft-buy" && status.confirmationId === confirmationId;
1496
- }) || {
1497
- status: "none"
1498
- });
1499
-
1500
- case 11:
1501
- _context24.prev = 11;
1502
- _context24.t0 = _context24["catch"](1);
1503
- this.Log(_context24.t0, true);
1504
- return _context24.abrupt("return", {
1505
- status: "unknown"
1506
- });
1507
-
1508
- case 15:
1509
- case "end":
1510
- return _context24.stop();
1511
- }
1512
- }
1513
- }, null, this, [[1, 11]]);
1514
- };
1515
- /**
1516
- * Return status of the specified item claim
1517
- *
1518
- * @methodGroup Status
1519
- * @namedParams
1520
- * @param {Object} marketplaceParams - Parameters of the marketplace
1521
- * @param {string} sku - The SKU of the item claimed
1522
- *
1523
- * @returns {Promise<Object>} - The minting status of the claim
1524
- */
1525
-
1526
-
1527
- exports.ClaimStatus = function _callee25(_ref23) {
1528
- var marketplaceParams, sku, marketplaceInfo, statuses;
1529
- return _regeneratorRuntime.async(function _callee25$(_context25) {
1530
- while (1) {
1531
- switch (_context25.prev = _context25.next) {
1532
- case 0:
1533
- marketplaceParams = _ref23.marketplaceParams, sku = _ref23.sku;
1534
- _context25.prev = 1;
1535
- _context25.next = 4;
1536
- return _regeneratorRuntime.awrap(this.MarketplaceInfo({
1537
- marketplaceParams: marketplaceParams
1538
- }));
1539
-
1540
- case 4:
1541
- marketplaceInfo = _context25.sent;
1542
- _context25.next = 7;
1543
- return _regeneratorRuntime.awrap(this.MintingStatus({
1544
- tenantId: marketplaceInfo.tenantId
1545
- }));
1546
-
1547
- case 7:
1548
- statuses = _context25.sent;
1549
- return _context25.abrupt("return", statuses.find(function (status) {
1550
- return status.op === "nft-claim" && status.marketplaceId === marketplaceInfo.marketplaceId && status.confirmationId === sku;
1551
- }) || {
1552
- status: "none"
1553
- });
1554
-
1555
- case 11:
1556
- _context25.prev = 11;
1557
- _context25.t0 = _context25["catch"](1);
1558
- this.Log(_context25.t0, true);
1559
- return _context25.abrupt("return", {
1560
- status: "unknown"
1561
- });
1562
-
1563
- case 15:
1564
- case "end":
1565
- return _context25.stop();
1566
- }
1567
- }
1568
- }, null, this, [[1, 11]]);
1569
- };
1570
- /**
1571
- * Return status of the specified pack opening
1572
- *
1573
- * @methodGroup Status
1574
- * @namedParams
1575
- * @param {string} contractAddress - The NFT contract address of the opened pack
1576
- * @param {string} tokenId - The token ID of the opened pack
1577
- *
1578
- * @returns {Promise<Object>} - The status of the pack opening
1579
- */
1580
-
1581
-
1582
- exports.PackOpenStatus = function _callee26(_ref24) {
1583
- var contractAddress, tokenId, tenantConfig, statuses;
1584
- return _regeneratorRuntime.async(function _callee26$(_context26) {
1585
- while (1) {
1586
- switch (_context26.prev = _context26.next) {
1587
- case 0:
1588
- contractAddress = _ref24.contractAddress, tokenId = _ref24.tokenId;
1589
- _context26.prev = 1;
1590
- _context26.next = 4;
1591
- return _regeneratorRuntime.awrap(this.TenantConfiguration({
1592
- contractAddress: contractAddress
1593
- }));
1594
-
1595
- case 4:
1596
- tenantConfig = _context26.sent;
1597
- _context26.next = 7;
1598
- return _regeneratorRuntime.awrap(this.MintingStatus({
1599
- tenantId: tenantConfig.tenant
1600
- }));
1601
-
1602
- case 7:
1603
- statuses = _context26.sent;
1604
- return _context26.abrupt("return", statuses.find(function (status) {
1605
- return status.op === "nft-open" && Utils.EqualAddress(contractAddress, status.address) && status.tokenId === tokenId;
1606
- }) || {
1607
- status: "none"
1608
- });
1609
-
1610
- case 11:
1611
- _context26.prev = 11;
1612
- _context26.t0 = _context26["catch"](1);
1613
- this.Log(_context26.t0, true);
1614
- return _context26.abrupt("return", {
1615
- status: "unknown"
1616
- });
1617
-
1618
- case 15:
1619
- case "end":
1620
- return _context26.stop();
1621
- }
1622
- }
1623
- }, null, this, [[1, 11]]);
1624
- };
1625
- /**
1626
- * Return status of the specified collection redemption
1627
- *
1628
- * @methodGroup Status
1629
- * @namedParams
1630
- * @param {Object} marketplaceParams - Parameters of the marketplace
1631
- * @param {string} confirmationId - The confirmation ID of the redemption
1632
- *
1633
- * @returns {Promise<Object>} - The status of the collection redemption
1634
- */
1635
-
1636
-
1637
- exports.CollectionRedemptionStatus = function _callee27(_ref25) {
1638
- var marketplaceParams, confirmationId, statuses;
1639
- return _regeneratorRuntime.async(function _callee27$(_context27) {
1640
- while (1) {
1641
- switch (_context27.prev = _context27.next) {
1642
- case 0:
1643
- marketplaceParams = _ref25.marketplaceParams, confirmationId = _ref25.confirmationId;
1644
- _context27.prev = 1;
1645
- _context27.next = 4;
1646
- return _regeneratorRuntime.awrap(this.MintingStatus({
1647
- marketplaceParams: marketplaceParams
1648
- }));
1649
-
1650
- case 4:
1651
- statuses = _context27.sent;
1652
- return _context27.abrupt("return", statuses.find(function (status) {
1653
- return status.op === "nft-redeem" && status.confirmationId === confirmationId;
1654
- }) || {
1655
- status: "none"
1656
- });
1657
-
1658
- case 8:
1659
- _context27.prev = 8;
1660
- _context27.t0 = _context27["catch"](1);
1661
- this.Log(_context27.t0, true);
1662
- return _context27.abrupt("return", {
1663
- status: "unknown"
1664
- });
1665
-
1666
- case 12:
1667
- case "end":
1668
- return _context27.stop();
1669
- }
1670
- }
1671
- }, null, this, [[1, 8]]);
1672
- };
1673
- /* EVENTS */
1674
-
1675
-
1676
- exports.LoadDrop = function _callee28(_ref26) {
1677
- var _this2 = this;
1678
-
1679
- var tenantSlug, eventSlug, dropId, mainSiteHash, event, eventId;
1680
- return _regeneratorRuntime.async(function _callee28$(_context28) {
1681
- while (1) {
1682
- switch (_context28.prev = _context28.next) {
1683
- case 0:
1684
- tenantSlug = _ref26.tenantSlug, eventSlug = _ref26.eventSlug, dropId = _ref26.dropId;
1685
-
1686
- if (!this.drops) {
1687
- this.drops = {};
1688
- }
1689
-
1690
- if (!this.drops[tenantSlug]) {
1691
- this.drops[tenantSlug] = {};
1692
- }
1693
-
1694
- if (!this.drops[tenantSlug][eventSlug]) {
1695
- this.drops[tenantSlug][eventSlug] = {};
1696
- }
1697
-
1698
- if (this.drops[tenantSlug][eventSlug][dropId]) {
1699
- _context28.next = 16;
1700
- break;
1701
- }
1702
-
1703
- _context28.next = 7;
1704
- return _regeneratorRuntime.awrap(this.client.LatestVersionHash({
1705
- objectId: this.mainSiteId
1706
- }));
1707
-
1708
- case 7:
1709
- mainSiteHash = _context28.sent;
1710
- _context28.next = 10;
1711
- return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
1712
- versionHash: mainSiteHash,
1713
- metadataSubtree: UrlJoin("public", "asset_metadata", "tenants", tenantSlug, "sites", eventSlug, "info"),
1714
- resolveLinks: true,
1715
- linkDepthLimit: 2,
1716
- resolveIncludeSource: true,
1717
- produceLinkUrls: true,
1718
- select: [".", "drops"],
1719
- noAuth: true
1720
- }));
1721
-
1722
- case 10:
1723
- _context28.t0 = _context28.sent;
1724
-
1725
- if (_context28.t0) {
1726
- _context28.next = 13;
1727
- break;
1728
- }
1729
-
1730
- _context28.t0 = [];
1731
-
1732
- case 13:
1733
- event = _context28.t0;
1734
- eventId = Utils.DecodeVersionHash(event["."].source).objectId;
1735
- event.drops.forEach(function (drop) {
1736
- drop = _objectSpread({}, drop, {
1737
- eventId: eventId
1738
- });
1739
- _this2.drops[tenantSlug][eventSlug][drop.uuid] = drop;
1740
- _this2.drops[drop.uuid] = drop;
1741
- });
1742
-
1743
- case 16:
1744
- return _context28.abrupt("return", this.drops[dropId]);
1745
-
1746
- case 17:
1747
- case "end":
1748
- return _context28.stop();
1749
- }
1750
- }
1751
- }, null, this);
1752
- };
1753
-
1754
- exports.SubmitDropVote = function _callee29(_ref27) {
1755
- var marketplaceParams, eventId, dropId, sku, marketplaceInfo;
1756
- return _regeneratorRuntime.async(function _callee29$(_context29) {
1757
- while (1) {
1758
- switch (_context29.prev = _context29.next) {
1759
- case 0:
1760
- marketplaceParams = _ref27.marketplaceParams, eventId = _ref27.eventId, dropId = _ref27.dropId, sku = _ref27.sku;
1761
- _context29.next = 3;
1762
- return _regeneratorRuntime.awrap(this.MarketplaceInfo({
1763
- marketplaceParams: marketplaceParams
1764
- }));
1765
-
1766
- case 3:
1767
- marketplaceInfo = _context29.sent;
1768
- _context29.next = 6;
1769
- return _regeneratorRuntime.awrap(this.client.authClient.MakeAuthServiceRequest({
1770
- path: UrlJoin("as", "wlt", "act", marketplaceInfo.tenant_id),
1771
- method: "POST",
1772
- body: {
1773
- op: "vote-drop",
1774
- evt: eventId,
1775
- id: dropId,
1776
- itm: sku
1777
- },
1778
- headers: {
1779
- Authorization: "Bearer ".concat(this.AuthToken())
1780
- }
1781
- }));
1782
-
1783
- case 6:
1784
- case "end":
1785
- return _context29.stop();
1786
- }
1787
- }
1788
- }, null, this);
1789
- };
1790
-
1791
- exports.DropStatus = function _callee30(_ref28) {
1792
- var marketplace, eventId, dropId, response;
1793
- return _regeneratorRuntime.async(function _callee30$(_context30) {
1794
- while (1) {
1795
- switch (_context30.prev = _context30.next) {
1796
- case 0:
1797
- marketplace = _ref28.marketplace, eventId = _ref28.eventId, dropId = _ref28.dropId;
1798
- _context30.prev = 1;
1799
- _context30.next = 4;
1800
- return _regeneratorRuntime.awrap(Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
1801
- path: UrlJoin("as", "wlt", "act", marketplace.tenant_id, eventId, dropId),
1802
- method: "GET",
1803
- headers: {
1804
- Authorization: "Bearer ".concat(this.AuthToken())
1805
- }
1806
- })));
1807
-
1808
- case 4:
1809
- response = _context30.sent;
1810
- return _context30.abrupt("return", response.sort(function (a, b) {
1811
- return a.ts > b.ts ? 1 : -1;
1812
- })[0] || {
1813
- status: "none"
1814
- });
1815
-
1816
- case 8:
1817
- _context30.prev = 8;
1818
- _context30.t0 = _context30["catch"](1);
1819
- this.Log(_context30.t0, true);
1820
- return _context30.abrupt("return", "");
1821
-
1822
- case 12:
1823
- case "end":
1824
- return _context30.stop();
1825
- }
1826
- }
1827
- }, null, this, [[1, 8]]);
1828
- };