@eluvio/elv-client-js 3.2.4 → 3.2.5

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