@eluvio/elv-client-js 3.2.22 → 3.2.23

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.
@@ -22,7 +22,7 @@ var WalletConfiguration = {
22
22
  appUrl: "https://wallet.contentfabric.io"
23
23
  }
24
24
  },
25
- __MARKETPLACE_ORDER: ["dolly-marketplace", "oc-marketplace", "maskverse-marketplace", "emp-marketplace", "microsoft", "indieflix-marketplace", "angels-airwaves-marketplace"]
25
+ __MARKETPLACE_ORDER: ["PREVIEW", "wwe-marketplace-main", "maskverse-marketplace", "dolly-marketplace", "oc-marketplace", "cirkay-marketplace", "emp-marketplace", "microsoft", "indieflix-marketplace", "angels-airwaves-marketplace"]
26
26
  }; // No production environment on demo
27
27
 
28
28
  WalletConfiguration.demo.production = WalletConfiguration.demo.staging; // Allow demo to be referred to as demov3
@@ -77,6 +77,7 @@ var FormatNFTDetails = function FormatNFTDetails(entry) {
77
77
  ContractId: "ictr".concat(Utils.AddressToHash(info.contract_addr)),
78
78
  ContractName: info.contract_name,
79
79
  Cap: info.cap,
80
+ Offers: info.offers || [],
80
81
  TokenIdStr: info.token_id_str,
81
82
  TokenUri: info.token_uri,
82
83
  TokenOrdinal: info.ordinal,
@@ -52,6 +52,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
52
52
  network = _ref.network,
53
53
  mode = _ref.mode,
54
54
  marketplaceInfo = _ref.marketplaceInfo,
55
+ previewMarketplaceHash = _ref.previewMarketplaceHash,
55
56
  storeAuthToken = _ref.storeAuthToken;
56
57
 
57
58
  _classCallCheck(this, ElvWalletClient);
@@ -67,6 +68,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
67
68
  this.publicStaticToken = client.staticToken;
68
69
  this.storeAuthToken = storeAuthToken;
69
70
  this.selectedMarketplaceInfo = marketplaceInfo;
71
+ this.previewMarketplaceId = previewMarketplaceHash ? Utils.DecodeVersionHash(previewMarketplaceHash).objectId : undefined;
72
+ this.previewMarketplaceHash = previewMarketplaceHash;
70
73
  this.availableMarketplaces = {};
71
74
  this.availableMarketplacesById = {};
72
75
  this.marketplaceHashes = {};
@@ -967,7 +970,6 @@ var ElvWalletClient = /*#__PURE__*/function () {
967
970
 
968
971
  return SignMetamask;
969
972
  }() // Internal loading methods
970
- // If marketplace slug is specified, load only that marketplace. Otherwise load all
971
973
 
972
974
  }, {
973
975
  key: "LoadAvailableMarketplaces",
@@ -978,6 +980,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
978
980
  var forceReload,
979
981
  mainSiteHash,
980
982
  metadata,
983
+ previewTenantSlug,
984
+ previewMarketplaceSlug,
985
+ previewMarketplaceMetadata,
981
986
  availableMarketplaces,
982
987
  availableMarketplacesById,
983
988
  _args12 = arguments;
@@ -1019,13 +1024,75 @@ var ElvWalletClient = /*#__PURE__*/function () {
1019
1024
 
1020
1025
  case 8:
1021
1026
  metadata = _context12.sent;
1027
+
1028
+ if (!this.previewMarketplaceId) {
1029
+ _context12.next = 24;
1030
+ break;
1031
+ }
1032
+
1033
+ previewTenantSlug = "PREVIEW";
1034
+ Object.keys(metadata || {}).forEach(function (tenantSlug) {
1035
+ return Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
1036
+ var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
1037
+
1038
+ var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
1039
+
1040
+ if (objectId === _this4.previewMarketplaceId) {
1041
+ // Marketplace exists in site meta
1042
+ previewTenantSlug = tenantSlug;
1043
+ previewMarketplaceSlug = marketplaceSlug; // Deployed marketplace is same as preview marketplace
1044
+
1045
+ if (versionHash === _this4.previewMarketplaceHash) {
1046
+ previewMarketplaceMetadata = metadata[tenantSlug].marketplaces[marketplaceSlug];
1047
+ }
1048
+ }
1049
+ });
1050
+ }); // Marketplace not present in branch, or preview version is different - Load metadata directly
1051
+
1052
+ if (previewMarketplaceMetadata) {
1053
+ _context12.next = 17;
1054
+ break;
1055
+ }
1056
+
1057
+ _context12.next = 15;
1058
+ return this.client.ContentObjectMetadata({
1059
+ versionHash: this.previewMarketplaceHash,
1060
+ metadataSubtree: "public/asset_metadata",
1061
+ produceLinkUrls: true,
1062
+ authorizationToken: this.publicStaticToken,
1063
+ noAuth: true,
1064
+ select: ["slug", "info/tenant_id", "info/tenant_name", "info/branding"],
1065
+ remove: ["info/branding/custom_css"]
1066
+ });
1067
+
1068
+ case 15:
1069
+ previewMarketplaceMetadata = _context12.sent;
1070
+
1071
+ if (!previewMarketplaceSlug) {
1072
+ previewMarketplaceSlug = previewMarketplaceMetadata.slug;
1073
+ }
1074
+
1075
+ case 17:
1076
+ previewMarketplaceMetadata["."] = {
1077
+ source: this.previewMarketplaceHash
1078
+ };
1079
+ previewMarketplaceMetadata.info["."] = {
1080
+ source: this.previewMarketplaceHash
1081
+ };
1082
+ previewMarketplaceMetadata.info.branding.preview = true;
1083
+ previewMarketplaceMetadata.info.branding.show = true;
1084
+ metadata[previewTenantSlug] = metadata[previewTenantSlug] || {};
1085
+ metadata[previewTenantSlug].marketplaces = metadata[previewTenantSlug].marketplaces || {};
1086
+ metadata[previewTenantSlug].marketplaces[previewMarketplaceSlug] = previewMarketplaceMetadata;
1087
+
1088
+ case 24:
1022
1089
  availableMarketplaces = _objectSpread({}, this.availableMarketplaces || {});
1023
1090
  availableMarketplacesById = _objectSpread({}, this.availableMarketplacesById || {});
1024
1091
  Object.keys(metadata || {}).forEach(function (tenantSlug) {
1025
1092
  try {
1026
- availableMarketplaces[tenantSlug] = {
1093
+ availableMarketplaces[tenantSlug] = metadata[tenantSlug]["."] ? {
1027
1094
  versionHash: metadata[tenantSlug]["."].source
1028
- };
1095
+ } : {};
1029
1096
  Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
1030
1097
  try {
1031
1098
  var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
@@ -1062,7 +1129,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1062
1129
  this.availableMarketplaces = availableMarketplaces;
1063
1130
  this.availableMarketplacesById = availableMarketplacesById;
1064
1131
 
1065
- case 14:
1132
+ case 29:
1066
1133
  case "end":
1067
1134
  return _context12.stop();
1068
1135
  }
@@ -1081,31 +1148,47 @@ var ElvWalletClient = /*#__PURE__*/function () {
1081
1148
  key: "LatestMarketplaceHash",
1082
1149
  value: function () {
1083
1150
  var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref12) {
1084
- var tenantSlug, marketplaceSlug, mainSiteHash, marketplaceLink;
1151
+ var marketplaceParams, marketplaceInfo, mainSiteHash, marketplaceLink;
1085
1152
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
1086
1153
  while (1) {
1087
1154
  switch (_context13.prev = _context13.next) {
1088
1155
  case 0:
1089
- tenantSlug = _ref12.tenantSlug, marketplaceSlug = _ref12.marketplaceSlug;
1156
+ marketplaceParams = _ref12.marketplaceParams;
1090
1157
  _context13.next = 3;
1158
+ return this.MarketplaceInfo({
1159
+ marketplaceParams: marketplaceParams
1160
+ });
1161
+
1162
+ case 3:
1163
+ marketplaceInfo = _context13.sent;
1164
+
1165
+ if (!(this.previewMarketplaceId && this.previewMarketplaceId === marketplaceInfo.marketplaceId)) {
1166
+ _context13.next = 6;
1167
+ break;
1168
+ }
1169
+
1170
+ return _context13.abrupt("return", this.availableMarketplaces[marketplaceInfo.tenantSlug][marketplaceInfo.marketplaceSlug]["."].source);
1171
+
1172
+ case 6:
1173
+ _context13.next = 8;
1091
1174
  return this.client.LatestVersionHash({
1092
1175
  objectId: this.mainSiteId
1093
1176
  });
1094
1177
 
1095
- case 3:
1178
+ case 8:
1096
1179
  mainSiteHash = _context13.sent;
1097
- _context13.next = 6;
1180
+ _context13.next = 11;
1098
1181
  return this.client.ContentObjectMetadata({
1099
1182
  versionHash: mainSiteHash,
1100
- metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", tenantSlug, "marketplaces", marketplaceSlug),
1183
+ metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "marketplaces", marketplaceInfo.marketplaceSlug),
1101
1184
  resolveLinks: false
1102
1185
  });
1103
1186
 
1104
- case 6:
1187
+ case 11:
1105
1188
  marketplaceLink = _context13.sent;
1106
1189
  return _context13.abrupt("return", LinkTargetHash(marketplaceLink));
1107
1190
 
1108
- case 8:
1191
+ case 13:
1109
1192
  case "end":
1110
1193
  return _context13.stop();
1111
1194
  }
@@ -1136,8 +1219,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1136
1219
  marketplaceId = marketplaceInfo.marketplaceId;
1137
1220
  _context15.next = 4;
1138
1221
  return this.LatestMarketplaceHash({
1139
- tenantSlug: marketplaceInfo.tenantSlug,
1140
- marketplaceSlug: marketplaceInfo.marketplaceSlug
1222
+ marketplaceParams: marketplaceParams
1141
1223
  });
1142
1224
 
1143
1225
  case 4:
@@ -1148,7 +1230,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1148
1230
  }
1149
1231
 
1150
1232
  if (this.cachedMarketplaces[marketplaceId]) {
1151
- _context15.next = 19;
1233
+ _context15.next = 20;
1152
1234
  break;
1153
1235
  }
1154
1236
 
@@ -1233,7 +1315,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
1233
1315
  });
1234
1316
  marketplace.retrievedAt = Date.now();
1235
1317
  marketplace.marketplaceId = marketplaceId;
1236
- marketplace.versionHash = marketplaceHash; // Generate embed URLs for pack opening animations
1318
+ marketplace.versionHash = marketplaceHash;
1319
+
1320
+ if (this.previewMarketplaceId && marketplaceId === this.previewMarketplaceId) {
1321
+ marketplace.branding.preview = true;
1322
+ } // Generate embed URLs for pack opening animations
1323
+
1237
1324
 
1238
1325
  ["purchase_animation", "purchase_animation__mobile", "reveal_animation", "reveal_animation_mobile"].forEach(function (key) {
1239
1326
  try {
@@ -1258,10 +1345,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
1258
1345
  });
1259
1346
  this.cachedMarketplaces[marketplaceId] = marketplace;
1260
1347
 
1261
- case 19:
1348
+ case 20:
1262
1349
  return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
1263
1350
 
1264
- case 20:
1351
+ case 21:
1265
1352
  case "end":
1266
1353
  return _context15.stop();
1267
1354
  }
@@ -1416,7 +1503,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1416
1503
  filters.push("token:eq:".concat(tokenId));
1417
1504
  }
1418
1505
  } else if (filter) {
1419
- if (mode === "listing") {
1506
+ if (mode.includes("listing")) {
1420
1507
  filters.push("nft/display_name:eq:".concat(filter));
1421
1508
  } else if (mode === "owned") {
1422
1509
  filters.push("meta/display_name:eq:".concat(filter));
@@ -1721,13 +1808,13 @@ var ElvWalletClient = /*#__PURE__*/function () {
1721
1808
  key: "Initialize",
1722
1809
  value: function () {
1723
1810
  var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
1724
- var _ref18$appId, appId, _ref18$network, network, _ref18$mode, mode, marketplaceParams, _ref18$storeAuthToken, storeAuthToken, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, client, walletClient, url, savedToken;
1811
+ var _ref18$appId, appId, _ref18$network, network, _ref18$mode, mode, marketplaceParams, previewMarketplaceId, _ref18$storeAuthToken, storeAuthToken, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, client, previewMarketplaceHash, walletClient, url, savedToken;
1725
1812
 
1726
1813
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1727
1814
  while (1) {
1728
1815
  switch (_context18.prev = _context18.next) {
1729
1816
  case 0:
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;
1817
+ _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, previewMarketplaceId = _ref18.previewMarketplaceId, _ref18$storeAuthToken = _ref18.storeAuthToken, storeAuthToken = _ref18$storeAuthToken === void 0 ? true : _ref18$storeAuthToken;
1731
1818
  _ref19 = marketplaceParams || {}, tenantSlug = _ref19.tenantSlug, marketplaceSlug = _ref19.marketplaceSlug, marketplaceId = _ref19.marketplaceId, marketplaceHash = _ref19.marketplaceHash;
1732
1819
 
1733
1820
  if (Configuration[network]) {
@@ -1754,6 +1841,22 @@ var ElvWalletClient = /*#__PURE__*/function () {
1754
1841
 
1755
1842
  case 10:
1756
1843
  client = _context18.sent;
1844
+ previewMarketplaceHash = previewMarketplaceId;
1845
+
1846
+ if (!(previewMarketplaceHash && !previewMarketplaceHash.startsWith("hq__"))) {
1847
+ _context18.next = 16;
1848
+ break;
1849
+ }
1850
+
1851
+ _context18.next = 15;
1852
+ return client.LatestVersionHash({
1853
+ objectId: previewMarketplaceId
1854
+ });
1855
+
1856
+ case 15:
1857
+ previewMarketplaceHash = _context18.sent;
1858
+
1859
+ case 16:
1757
1860
  walletClient = new ElvWalletClient({
1758
1861
  appId: appId,
1759
1862
  client: client,
@@ -1765,73 +1868,74 @@ var ElvWalletClient = /*#__PURE__*/function () {
1765
1868
  marketplaceId: marketplaceHash ? client.utils.DecodeVersionHash(marketplaceHash).objectId : marketplaceId,
1766
1869
  marketplaceHash: marketplaceHash
1767
1870
  },
1871
+ previewMarketplaceHash: previewMarketplaceHash,
1768
1872
  storeAuthToken: storeAuthToken
1769
1873
  });
1770
1874
 
1771
1875
  if (!(inBrowser && window.location && window.location.href)) {
1772
- _context18.next = 31;
1876
+ _context18.next = 36;
1773
1877
  break;
1774
1878
  }
1775
1879
 
1776
1880
  url = new URL(window.location.href);
1777
1881
 
1778
1882
  if (!url.searchParams.get("elvToken")) {
1779
- _context18.next = 21;
1883
+ _context18.next = 26;
1780
1884
  break;
1781
1885
  }
1782
1886
 
1783
- _context18.next = 17;
1887
+ _context18.next = 22;
1784
1888
  return walletClient.Authenticate({
1785
1889
  token: url.searchParams.get("elvToken")
1786
1890
  });
1787
1891
 
1788
- case 17:
1892
+ case 22:
1789
1893
  url.searchParams["delete"]("elvToken");
1790
1894
  window.history.replaceState("", "", url);
1791
- _context18.next = 31;
1895
+ _context18.next = 36;
1792
1896
  break;
1793
1897
 
1794
- case 21:
1898
+ case 26:
1795
1899
  if (!(storeAuthToken && typeof localStorage !== "undefined")) {
1796
- _context18.next = 31;
1900
+ _context18.next = 36;
1797
1901
  break;
1798
1902
  }
1799
1903
 
1800
- _context18.prev = 22;
1904
+ _context18.prev = 27;
1801
1905
  // Load saved auth token
1802
1906
  savedToken = localStorage.getItem("__elv-token-".concat(network));
1803
1907
 
1804
1908
  if (!savedToken) {
1805
- _context18.next = 27;
1909
+ _context18.next = 32;
1806
1910
  break;
1807
1911
  }
1808
1912
 
1809
- _context18.next = 27;
1913
+ _context18.next = 32;
1810
1914
  return walletClient.Authenticate({
1811
1915
  token: savedToken
1812
1916
  });
1813
1917
 
1814
- case 27:
1815
- _context18.next = 31;
1918
+ case 32:
1919
+ _context18.next = 36;
1816
1920
  break;
1817
1921
 
1818
- case 29:
1819
- _context18.prev = 29;
1820
- _context18.t0 = _context18["catch"](22);
1922
+ case 34:
1923
+ _context18.prev = 34;
1924
+ _context18.t0 = _context18["catch"](27);
1821
1925
 
1822
- case 31:
1823
- _context18.next = 33;
1926
+ case 36:
1927
+ _context18.next = 38;
1824
1928
  return walletClient.LoadAvailableMarketplaces();
1825
1929
 
1826
- case 33:
1930
+ case 38:
1827
1931
  return _context18.abrupt("return", walletClient);
1828
1932
 
1829
- case 34:
1933
+ case 39:
1830
1934
  case "end":
1831
1935
  return _context18.stop();
1832
1936
  }
1833
1937
  }
1834
- }, _callee18, null, [[22, 29]]);
1938
+ }, _callee18, null, [[27, 34]]);
1835
1939
  }));
1836
1940
 
1837
1941
  function Initialize(_x21) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.2.22",
3
+ "version": "3.2.23",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -977,6 +977,32 @@ exports.RemoveListing = async function({listingId}) {
977
977
  });
978
978
  };
979
979
 
980
+ /**
981
+ * Retrieve all valid names for filtering listing sales names. Full item names are required for filtering sales results by name.
982
+ *
983
+ * Specify marketplace information to filter the results to only items offered in that marketplace.
984
+ *
985
+ * @methodGroup Listings
986
+ * @namedParams
987
+ * @param {Object} marketplaceParams - Parameters of a marketplace to filter results by
988
+ *
989
+ * @returns {Promise<Array<String>>} - A list of item names
990
+ */
991
+ exports.SalesNames = async function({marketplaceParams}) {
992
+ let tenantId;
993
+ if(marketplaceParams) {
994
+ tenantId = (await this.MarketplaceInfo({marketplaceParams})).tenantId;
995
+ }
996
+
997
+ return await Utils.ResponseToJson(
998
+ await this.client.authClient.MakeAuthServiceRequest({
999
+ path: UrlJoin("as", "mkt", "names", "hst"),
1000
+ method: "GET",
1001
+ queryParams: tenantId ? { filter: `tenant:eq:${tenantId}` } : {}
1002
+ })
1003
+ );
1004
+ };
1005
+
980
1006
  /**
981
1007
  * Retrieve all valid names for filtering listings. Full item names are required for filtering listing results by name.
982
1008
  *