@eluvio/elv-client-js 3.2.15 → 3.2.19

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.
@@ -26,6 +26,8 @@ var _require2 = require("./Utils"),
26
26
  FormatNFT = _require2.FormatNFT,
27
27
  ActionPopup = _require2.ActionPopup;
28
28
 
29
+ var HTTPClient = require("../HttpClient");
30
+
29
31
  var UrlJoin = require("url-join");
30
32
 
31
33
  var Utils = require("../Utils");
@@ -45,7 +47,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
45
47
  "use strict";
46
48
 
47
49
  function ElvWalletClient(_ref) {
48
- var client = _ref.client,
50
+ var appId = _ref.appId,
51
+ client = _ref.client,
49
52
  network = _ref.network,
50
53
  mode = _ref.mode,
51
54
  marketplaceInfo = _ref.marketplaceInfo,
@@ -53,6 +56,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
53
56
 
54
57
  _classCallCheck(this, ElvWalletClient);
55
58
 
59
+ this.appId = appId;
56
60
  this.client = client;
57
61
  this.loggedIn = false;
58
62
  this.network = network;
@@ -65,7 +69,11 @@ var ElvWalletClient = /*#__PURE__*/function () {
65
69
  this.selectedMarketplaceInfo = marketplaceInfo;
66
70
  this.availableMarketplaces = {};
67
71
  this.availableMarketplacesById = {};
68
- this.marketplaceHashes = {}; // Caches
72
+ this.marketplaceHashes = {};
73
+ this.stateStoreUrls = Configuration[network].stateStoreUrls;
74
+ this.stateStoreClient = new HTTPClient({
75
+ uris: this.stateStoreUrls
76
+ }); // Caches
69
77
 
70
78
  this.cachedMarketplaces = {};
71
79
  this.cachedCSS = {};
@@ -96,8 +104,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
96
104
  *
97
105
  * Specify tenantSlug and marketplaceSlug to automatically associate this tenant with a particular marketplace.
98
106
  *
107
+ *
99
108
  * @methodGroup Initialization
100
109
  * @namedParams
110
+ * @param {string} appId - A string identifying your app. This is used for namespacing user profile data.
101
111
  * @param {string} network=main - Name of the Fabric network to use (`main`, `demo`)
102
112
  * @param {string} mode=production - Environment to use (`production`, `staging`)
103
113
  * @param {Object=} marketplaceParams - Marketplace parameters
@@ -311,6 +321,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
311
321
  /**
312
322
  * Direct the user to the Eluvio Media Wallet login page.
313
323
  *
324
+ * For redirect login, the authorization token will be included in the URL parameters of the callbackUrl. Simply re-initialize the wallet client and it will authorize with this token,
325
+ * or you can retrieve the parameter (`elvToken`) yourself and use it in the <a href="#Authenticate">Authenticate</a> method.
326
+ *
314
327
  * <b>NOTE:</b> The domain of the opening window (popup flow) or domain of the `callbackUrl` (redirect flow) MUST be allowed in the metadata of the specified marketplace.
315
328
  *
316
329
  * @methodGroup Login
@@ -1194,10 +1207,11 @@ var ElvWalletClient = /*#__PURE__*/function () {
1194
1207
 
1195
1208
  case 14:
1196
1209
  item.nftTemplateMetadata = (item.nft_template || {}).nft || {};
1210
+ item.nftTemplateHash = ((item.nft_template || {})["."] || {}).source;
1197
1211
  item.itemIndex = index;
1198
1212
  return _context14.abrupt("return", item);
1199
1213
 
1200
- case 17:
1214
+ case 18:
1201
1215
  case "end":
1202
1216
  return _context14.stop();
1203
1217
  }
@@ -1265,6 +1279,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
1265
1279
  key: "FilteredQuery",
1266
1280
  value: function () {
1267
1281
  var _FilteredQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
1282
+ var _this6 = this;
1283
+
1268
1284
  var _ref14,
1269
1285
  _ref14$mode,
1270
1286
  mode,
@@ -1284,9 +1300,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
1284
1300
  priceRange,
1285
1301
  tokenIdRange,
1286
1302
  capLimit,
1303
+ userAddress,
1287
1304
  sellerAddress,
1288
1305
  _ref14$lastNDays,
1289
1306
  lastNDays,
1307
+ _ref14$includeCheckou,
1308
+ includeCheckoutLocked,
1290
1309
  _ref14$start,
1291
1310
  start,
1292
1311
  _ref14$limit,
@@ -1305,49 +1324,58 @@ var ElvWalletClient = /*#__PURE__*/function () {
1305
1324
  while (1) {
1306
1325
  switch (_context16.prev = _context16.next) {
1307
1326
  case 0:
1308
- _ref14 = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {}, _ref14$mode = _ref14.mode, mode = _ref14$mode === void 0 ? "listings" : _ref14$mode, _ref14$sortBy = _ref14.sortBy, sortBy = _ref14$sortBy === void 0 ? "created" : _ref14$sortBy, _ref14$sortDesc = _ref14.sortDesc, sortDesc = _ref14$sortDesc === void 0 ? false : _ref14$sortDesc, filter = _ref14.filter, editionFilters = _ref14.editionFilters, attributeFilters = _ref14.attributeFilters, contractAddress = _ref14.contractAddress, tokenId = _ref14.tokenId, currency = _ref14.currency, marketplaceParams = _ref14.marketplaceParams, tenantId = _ref14.tenantId, collectionIndexes = _ref14.collectionIndexes, priceRange = _ref14.priceRange, tokenIdRange = _ref14.tokenIdRange, capLimit = _ref14.capLimit, sellerAddress = _ref14.sellerAddress, _ref14$lastNDays = _ref14.lastNDays, lastNDays = _ref14$lastNDays === void 0 ? -1 : _ref14$lastNDays, _ref14$start = _ref14.start, start = _ref14$start === void 0 ? 0 : _ref14$start, _ref14$limit = _ref14.limit, limit = _ref14$limit === void 0 ? 50 : _ref14$limit;
1327
+ _ref14 = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {}, _ref14$mode = _ref14.mode, mode = _ref14$mode === void 0 ? "listings" : _ref14$mode, _ref14$sortBy = _ref14.sortBy, sortBy = _ref14$sortBy === void 0 ? "created" : _ref14$sortBy, _ref14$sortDesc = _ref14.sortDesc, sortDesc = _ref14$sortDesc === void 0 ? false : _ref14$sortDesc, filter = _ref14.filter, editionFilters = _ref14.editionFilters, attributeFilters = _ref14.attributeFilters, contractAddress = _ref14.contractAddress, tokenId = _ref14.tokenId, currency = _ref14.currency, marketplaceParams = _ref14.marketplaceParams, tenantId = _ref14.tenantId, collectionIndexes = _ref14.collectionIndexes, priceRange = _ref14.priceRange, tokenIdRange = _ref14.tokenIdRange, capLimit = _ref14.capLimit, userAddress = _ref14.userAddress, sellerAddress = _ref14.sellerAddress, _ref14$lastNDays = _ref14.lastNDays, lastNDays = _ref14$lastNDays === void 0 ? -1 : _ref14$lastNDays, _ref14$includeCheckou = _ref14.includeCheckoutLocked, includeCheckoutLocked = _ref14$includeCheckou === void 0 ? false : _ref14$includeCheckou, _ref14$start = _ref14.start, start = _ref14$start === void 0 ? 0 : _ref14$start, _ref14$limit = _ref14.limit, limit = _ref14$limit === void 0 ? 50 : _ref14$limit;
1309
1328
  collectionIndexes = (collectionIndexes || []).map(function (i) {
1310
1329
  return parseInt(i);
1311
1330
  });
1312
1331
  params = {
1313
- sort_by: sortBy,
1314
- sort_descending: sortDesc,
1315
1332
  start: start,
1316
- limit: limit
1333
+ limit: limit,
1334
+ sort_descending: sortDesc
1317
1335
  };
1318
1336
 
1337
+ if (mode !== "leaderboard") {
1338
+ params.sort_by = sortBy;
1339
+ }
1340
+
1341
+ if (mode.includes("listings") && includeCheckoutLocked) {
1342
+ params.checkout = true;
1343
+ }
1344
+
1319
1345
  if (!marketplaceParams) {
1320
- _context16.next = 11;
1346
+ _context16.next = 13;
1321
1347
  break;
1322
1348
  }
1323
1349
 
1324
- _context16.next = 6;
1350
+ _context16.next = 8;
1325
1351
  return this.MarketplaceInfo({
1326
1352
  marketplaceParams: marketplaceParams
1327
1353
  });
1328
1354
 
1329
- case 6:
1355
+ case 8:
1330
1356
  marketplaceInfo = _context16.sent;
1331
1357
 
1332
1358
  if (!(collectionIndexes.length > 0)) {
1333
- _context16.next = 11;
1359
+ _context16.next = 13;
1334
1360
  break;
1335
1361
  }
1336
1362
 
1337
- _context16.next = 10;
1363
+ _context16.next = 12;
1338
1364
  return this.Marketplace({
1339
1365
  marketplaceParams: marketplaceParams
1340
1366
  });
1341
1367
 
1342
- case 10:
1368
+ case 12:
1343
1369
  marketplace = _context16.sent;
1344
1370
 
1345
- case 11:
1346
- _context16.prev = 11;
1371
+ case 13:
1372
+ _context16.prev = 13;
1347
1373
  filters = [];
1348
1374
 
1349
1375
  if (sellerAddress) {
1350
1376
  filters.push("seller:eq:".concat(this.client.utils.FormatAddress(sellerAddress)));
1377
+ } else if (userAddress && mode !== "owned") {
1378
+ filters.push("addr:eq:".concat(this.client.utils.FormatAddress(userAddress)));
1351
1379
  }
1352
1380
 
1353
1381
  if (marketplace && collectionIndexes.length >= 0) {
@@ -1373,7 +1401,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1373
1401
  }
1374
1402
  });
1375
1403
  });
1376
- } else if (mode !== "owned" && marketplaceInfo || tenantId) {
1404
+ } else if (marketplaceInfo || tenantId) {
1377
1405
  filters.push("tenant:eq:".concat(marketplaceInfo ? marketplaceInfo.tenantId : tenantId));
1378
1406
  }
1379
1407
 
@@ -1388,11 +1416,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
1388
1416
  filters.push("token:eq:".concat(tokenId));
1389
1417
  }
1390
1418
  } else if (filter) {
1391
- if (mode.includes("listing")) {
1419
+ if (mode === "listing") {
1392
1420
  filters.push("nft/display_name:eq:".concat(filter));
1393
1421
  } else if (mode === "owned") {
1394
- filters.push("meta:@>:{\"display_name\":\"".concat(filter, "\"}"));
1395
- params.exact = false;
1422
+ filters.push("meta/display_name:eq:".concat(filter));
1396
1423
  } else {
1397
1424
  filters.push("name:eq:".concat(filter));
1398
1425
  }
@@ -1457,89 +1484,87 @@ var ElvWalletClient = /*#__PURE__*/function () {
1457
1484
  }
1458
1485
 
1459
1486
  _context16.t0 = mode;
1460
- _context16.next = _context16.t0 === "owned" ? 26 : _context16.t0 === "listings" ? 29 : _context16.t0 === "transfers" ? 31 : _context16.t0 === "sales" ? 35 : _context16.t0 === "listing-stats" ? 38 : _context16.t0 === "sales-stats" ? 40 : 42;
1487
+ _context16.next = _context16.t0 === "owned" ? 28 : _context16.t0 === "listings" ? 30 : _context16.t0 === "transfers" ? 32 : _context16.t0 === "sales" ? 36 : _context16.t0 === "listing-stats" ? 40 : _context16.t0 === "sales-stats" ? 42 : _context16.t0 === "leaderboard" ? 45 : 47;
1461
1488
  break;
1462
1489
 
1463
- case 26:
1464
- path = UrlJoin("as", "wlt", "nfts");
1465
-
1466
- if (marketplaceInfo) {
1467
- path = UrlJoin("as", "wlt", "nfts", marketplaceInfo.tenantId);
1468
- }
1469
-
1470
- return _context16.abrupt("break", 42);
1490
+ case 28:
1491
+ path = UrlJoin("as", "wlt", userAddress || this.UserAddress());
1492
+ return _context16.abrupt("break", 47);
1471
1493
 
1472
- case 29:
1494
+ case 30:
1473
1495
  path = UrlJoin("as", "mkt", "f");
1474
- return _context16.abrupt("break", 42);
1496
+ return _context16.abrupt("break", 47);
1475
1497
 
1476
- case 31:
1498
+ case 32:
1477
1499
  path = UrlJoin("as", "mkt", "hst", "f");
1478
1500
  filters.push("action:eq:TRANSFERRED");
1479
1501
  filters.push("action:eq:SOLD");
1480
- return _context16.abrupt("break", 42);
1502
+ return _context16.abrupt("break", 47);
1481
1503
 
1482
- case 35:
1504
+ case 36:
1483
1505
  path = UrlJoin("as", "mkt", "hst", "f");
1484
1506
  filters.push("action:eq:SOLD");
1485
- return _context16.abrupt("break", 42);
1507
+ filters.push("seller:co:0x");
1508
+ return _context16.abrupt("break", 47);
1486
1509
 
1487
- case 38:
1510
+ case 40:
1488
1511
  path = UrlJoin("as", "mkt", "stats", "listed");
1489
- return _context16.abrupt("break", 42);
1512
+ return _context16.abrupt("break", 47);
1490
1513
 
1491
- case 40:
1514
+ case 42:
1492
1515
  path = UrlJoin("as", "mkt", "stats", "sold");
1493
- return _context16.abrupt("break", 42);
1516
+ filters.push("seller:co:0x");
1517
+ return _context16.abrupt("break", 47);
1494
1518
 
1495
- case 42:
1519
+ case 45:
1520
+ path = UrlJoin("as", "wlt", "leaders");
1521
+ return _context16.abrupt("break", 47);
1522
+
1523
+ case 47:
1496
1524
  if (filters.length > 0) {
1497
1525
  params.filter = filters;
1498
1526
  }
1499
1527
 
1500
1528
  if (!mode.includes("stats")) {
1501
- _context16.next = 47;
1529
+ _context16.next = 52;
1502
1530
  break;
1503
1531
  }
1504
1532
 
1505
- _context16.next = 46;
1533
+ _context16.next = 51;
1506
1534
  return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
1507
1535
  path: path,
1508
1536
  method: "GET",
1509
1537
  queryParams: params
1510
1538
  }));
1511
1539
 
1512
- case 46:
1540
+ case 51:
1513
1541
  return _context16.abrupt("return", _context16.sent);
1514
1542
 
1515
- case 47:
1543
+ case 52:
1516
1544
  _context16.t2 = Utils;
1517
- _context16.next = 50;
1545
+ _context16.next = 55;
1518
1546
  return this.client.authClient.MakeAuthServiceRequest({
1519
1547
  path: path,
1520
1548
  method: "GET",
1521
- queryParams: params,
1522
- headers: mode === "owned" ? {
1523
- Authorization: "Bearer ".concat(this.AuthToken())
1524
- } : {}
1549
+ queryParams: params
1525
1550
  });
1526
1551
 
1527
- case 50:
1552
+ case 55:
1528
1553
  _context16.t3 = _context16.sent;
1529
- _context16.next = 53;
1554
+ _context16.next = 58;
1530
1555
  return _context16.t2.ResponseToJson.call(_context16.t2, _context16.t3);
1531
1556
 
1532
- case 53:
1557
+ case 58:
1533
1558
  _context16.t1 = _context16.sent;
1534
1559
 
1535
1560
  if (_context16.t1) {
1536
- _context16.next = 56;
1561
+ _context16.next = 61;
1537
1562
  break;
1538
1563
  }
1539
1564
 
1540
1565
  _context16.t1 = [];
1541
1566
 
1542
- case 56:
1567
+ case 61:
1543
1568
  _ref16 = _context16.t1;
1544
1569
  contents = _ref16.contents;
1545
1570
  paging = _ref16.paging;
@@ -1551,16 +1576,16 @@ var ElvWalletClient = /*#__PURE__*/function () {
1551
1576
  more: paging.total > start + limit
1552
1577
  },
1553
1578
  results: (contents || []).map(function (item) {
1554
- return ["owned", "listings"].includes(mode) ? FormatNFT(item) : item;
1579
+ return ["owned", "listings"].includes(mode) ? FormatNFT(_this6, item) : item;
1555
1580
  })
1556
1581
  });
1557
1582
 
1558
- case 62:
1559
- _context16.prev = 62;
1560
- _context16.t4 = _context16["catch"](11);
1583
+ case 67:
1584
+ _context16.prev = 67;
1585
+ _context16.t4 = _context16["catch"](13);
1561
1586
 
1562
1587
  if (!(_context16.t4.status && _context16.t4.status.toString() === "404")) {
1563
- _context16.next = 66;
1588
+ _context16.next = 71;
1564
1589
  break;
1565
1590
  }
1566
1591
 
@@ -1574,15 +1599,15 @@ var ElvWalletClient = /*#__PURE__*/function () {
1574
1599
  results: []
1575
1600
  });
1576
1601
 
1577
- case 66:
1602
+ case 71:
1578
1603
  throw _context16.t4;
1579
1604
 
1580
- case 67:
1605
+ case 72:
1581
1606
  case "end":
1582
1607
  return _context16.stop();
1583
1608
  }
1584
1609
  }
1585
- }, _callee16, this, [[11, 62]]);
1610
+ }, _callee16, this, [[13, 67]]);
1586
1611
  }));
1587
1612
 
1588
1613
  function FilteredQuery() {
@@ -1696,13 +1721,13 @@ var ElvWalletClient = /*#__PURE__*/function () {
1696
1721
  key: "Initialize",
1697
1722
  value: function () {
1698
1723
  var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
1699
- var _ref18$network, network, _ref18$mode, mode, marketplaceParams, _ref18$storeAuthToken, storeAuthToken, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, client, walletClient, url, savedToken;
1724
+ var _ref18$appId, appId, _ref18$network, network, _ref18$mode, mode, marketplaceParams, _ref18$storeAuthToken, storeAuthToken, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, client, walletClient, url, savedToken;
1700
1725
 
1701
1726
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1702
1727
  while (1) {
1703
1728
  switch (_context18.prev = _context18.next) {
1704
1729
  case 0:
1705
- _ref18$network = _ref18.network, network = _ref18$network === void 0 ? "main" : _ref18$network, _ref18$mode = _ref18.mode, mode = _ref18$mode === void 0 ? "production" : _ref18$mode, marketplaceParams = _ref18.marketplaceParams, _ref18$storeAuthToken = _ref18.storeAuthToken, storeAuthToken = _ref18$storeAuthToken === void 0 ? true : _ref18$storeAuthToken;
1730
+ _ref18$appId = _ref18.appId, appId = _ref18$appId === void 0 ? "general" : _ref18$appId, _ref18$network = _ref18.network, network = _ref18$network === void 0 ? "main" : _ref18$network, _ref18$mode = _ref18.mode, mode = _ref18$mode === void 0 ? "production" : _ref18$mode, marketplaceParams = _ref18.marketplaceParams, _ref18$storeAuthToken = _ref18.storeAuthToken, storeAuthToken = _ref18$storeAuthToken === void 0 ? true : _ref18$storeAuthToken;
1706
1731
  _ref19 = marketplaceParams || {}, tenantSlug = _ref19.tenantSlug, marketplaceSlug = _ref19.marketplaceSlug, marketplaceId = _ref19.marketplaceId, marketplaceHash = _ref19.marketplaceHash;
1707
1732
 
1708
1733
  if (Configuration[network]) {
@@ -1730,6 +1755,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1730
1755
  case 10:
1731
1756
  client = _context18.sent;
1732
1757
  walletClient = new ElvWalletClient({
1758
+ appId: appId,
1733
1759
  client: client,
1734
1760
  network: network,
1735
1761
  mode: mode,
@@ -1820,4 +1846,5 @@ var ElvWalletClient = /*#__PURE__*/function () {
1820
1846
  }();
1821
1847
 
1822
1848
  Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
1849
+ Object.assign(ElvWalletClient.prototype, require("./Profile"));
1823
1850
  exports.ElvWalletClient = ElvWalletClient;