@eluvio/elv-client-js 3.2.14 → 3.2.18

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.
@@ -53,7 +53,7 @@ exports.UserAddress = function() {
53
53
  * Retrieve the fund balances for the current user
54
54
  *
55
55
  * @methodGroup User
56
- * @returns {Promise<{Object}>} - Returns balances for the user. All values are in USD.
56
+ * @returns {Promise<Object>} - Returns balances for the user. All values are in USD.
57
57
  * <ul>
58
58
  * <li>- totalWalletBalance - Total balance of the users sales and wallet balance purchases</li>
59
59
  * <li>- availableWalletBalance - Balance available for purchasing items</li>
@@ -180,13 +180,110 @@ exports.UserItemInfo = async function ({userAddress}={}) {
180
180
  };
181
181
 
182
182
 
183
+ /**
184
+ * Retrieve all valid names for filtering user items. Full item names are required for filtering results by name.
185
+ *
186
+ * Specify marketplace information to filter the results to only items offered in that marketplace.
187
+ *
188
+ * @methodGroup User
189
+ * @namedParams
190
+ * @param {string=} userAddress - Address of a user
191
+ * @param {Object=} marketplaceParams - Parameters of a marketplace to filter results by
192
+ *
193
+ * @returns {Promise<Array<String>>} - A list of item names
194
+ */
195
+ exports.UserItemNames = async function({marketplaceParams, userAddress}={}) {
196
+ let filters = [];
197
+ if(marketplaceParams) {
198
+ filters.push(`tenant:eq:${(await this.MarketplaceInfo({marketplaceParams})).tenantId}`);
199
+ }
200
+
201
+ if(userAddress) {
202
+ filters.push(`wlt:eq:${Utils.FormatAddress(userAddress)}`);
203
+ }
204
+
205
+ return await Utils.ResponseToJson(
206
+ await this.client.authClient.MakeAuthServiceRequest({
207
+ path: UrlJoin("as", "wlt", "names"),
208
+ method: "GET",
209
+ queryParams: { filter: filters }
210
+ })
211
+ );
212
+ };
213
+
214
+ /**
215
+ * Retrieve all valid edition names for filtering the specified item. Full edition names are required for filtering results by edition.
216
+ *
217
+ * Specify marketplace information to filter the results to only items offered in that marketplace.
218
+ *
219
+ * @methodGroup User
220
+ * @namedParams
221
+ * @param {string} displayName - Name of an item
222
+ *
223
+ * @returns {Promise<Array<String>>} - A list of item editions
224
+ */
225
+ exports.UserItemEditionNames = async function({displayName}) {
226
+ return await Utils.ResponseToJson(
227
+ await this.client.authClient.MakeAuthServiceRequest({
228
+ path: UrlJoin("as", "wlt", "editions"),
229
+ method: "GET",
230
+ queryParams: { filter: `meta/display_name:eq:${displayName}` }
231
+ })
232
+ );
233
+ };
234
+
235
+ /**
236
+ * Retrieve all valid attribute names and values. Full attribute names and values are required for filtering results by attribute.
237
+ *
238
+ * Specify marketplace information to filter the results to only items offered in that marketplace.
239
+ *
240
+ * @methodGroup User
241
+ * @namedParams
242
+ * @param {string=} userAddress - Address of a user
243
+ * @param {string=} displayName - Name of an item
244
+ * @param {Object=} marketplaceParams - Parameters of a marketplace to filter results by
245
+ *
246
+ * @returns {Promise<Array<String>>} - A list of item names
247
+ */
248
+ exports.UserItemAttributes = async function({marketplaceParams, displayName, userAddress}={}) {
249
+ let filters = [];
250
+ if(marketplaceParams) {
251
+ filters.push(`tenant:eq:${(await this.MarketplaceInfo({marketplaceParams})).tenantId}`);
252
+ }
253
+
254
+ if(userAddress) {
255
+ filters.push(`wlt:eq:${Utils.FormatAddress(userAddress)}`);
256
+ }
257
+
258
+ if(displayName) {
259
+ filters.push(`meta/display_name:eq:${displayName}`);
260
+ }
261
+
262
+ const attributes = await Utils.ResponseToJson(
263
+ await this.client.authClient.MakeAuthServiceRequest({
264
+ path: UrlJoin("as", "wlt", "attributes"),
265
+ method: "GET",
266
+ queryParams: {
267
+ filter: filters
268
+ }
269
+ })
270
+ );
271
+
272
+ return attributes
273
+ .map(({trait_type, values}) => ({ name: trait_type, values }))
274
+ .filter(({name}) =>
275
+ !["Content Fabric Hash", "Total Minted Supply", "Creator"].includes(name)
276
+ );
277
+ };
278
+
183
279
  /**
184
280
  * <b><i>Requires login</i></b>
185
281
  *
186
- * Retrieve items owned by the current user matching the specified parameters.
282
+ * Retrieve items owned by the specified or current user matching the specified parameters.
187
283
  *
188
284
  * @methodGroup User
189
285
  * @namedParams
286
+ * @param {string=} userAddress - Address of a user. If not specified, will return results for current user
190
287
  * @param {integer=} start=0 - PAGINATION: Index from which the results should start
191
288
  * @param {integer=} limit=50 - PAGINATION: Maximum number of results to return
192
289
  * @param {string=} sortBy="created" - Sort order. Options: `default`, `meta/display_name`
@@ -208,6 +305,7 @@ exports.UserItems = async function() {
208
305
  *
209
306
  * @methodGroup User
210
307
  * @namedParams
308
+ * @param {string=} userAddress - Address of a user. If not specified, will return results for current user
211
309
  * @param {string=} sortBy="created" - Sort order. Options: `created`, `info/token_id`, `info/ordinal`, `price`, `nft/display_name`
212
310
  * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
213
311
  * @param {Object=} marketplaceParams - Filter results by marketplace
@@ -216,7 +314,7 @@ exports.UserItems = async function() {
216
314
  *
217
315
  * @returns {Promise<Array<Object>>} - List of current user's listings
218
316
  */
219
- exports.UserListings = async function({sortBy="created", sortDesc=false, contractAddress, tokenId, marketplaceParams}={}) {
317
+ exports.UserListings = async function({userAddress, sortBy="created", sortDesc=false, contractAddress, tokenId, marketplaceParams}={}) {
220
318
  return (
221
319
  await this.FilteredQuery({
222
320
  mode: "listings",
@@ -224,10 +322,11 @@ exports.UserListings = async function({sortBy="created", sortDesc=false, contrac
224
322
  limit: 10000,
225
323
  sortBy,
226
324
  sortDesc,
227
- sellerAddress: this.UserAddress(),
325
+ sellerAddress: userAddress || this.UserAddress(),
228
326
  marketplaceParams,
229
327
  contractAddress,
230
- tokenId
328
+ tokenId,
329
+ includeCheckoutLocked: true
231
330
  })
232
331
  ).results;
233
332
  };
@@ -237,6 +336,7 @@ exports.UserListings = async function({sortBy="created", sortDesc=false, contrac
237
336
  *
238
337
  * @methodGroup User
239
338
  * @namedParams
339
+ * @param {string=} userAddress - Address of a user. If not specified, will return results for current user
240
340
  * @param {string=} sortBy="created" - Sort order. Options: `created`, `price`, `name`
241
341
  * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
242
342
  * @param {Object=} marketplaceParams - Filter results by marketplace
@@ -246,7 +346,7 @@ exports.UserListings = async function({sortBy="created", sortDesc=false, contrac
246
346
  *
247
347
  * @returns {Promise<Array<Object>>} - List of current user's sales
248
348
  */
249
- exports.UserSales = async function({sortBy="created", sortDesc=false, contractAddress, tokenId, marketplaceParams}={}) {
349
+ exports.UserSales = async function({userAddress, sortBy="created", sortDesc=false, contractAddress, tokenId, marketplaceParams}={}) {
250
350
  return (
251
351
  await this.FilteredQuery({
252
352
  mode: "sales",
@@ -254,7 +354,7 @@ exports.UserSales = async function({sortBy="created", sortDesc=false, contractAd
254
354
  limit: 10000,
255
355
  sortBy,
256
356
  sortDesc,
257
- sellerAddress: this.UserAddress(),
357
+ sellerAddress: userAddress || this.UserAddress(),
258
358
  marketplaceParams,
259
359
  contractAddress,
260
360
  tokenId
@@ -267,6 +367,7 @@ exports.UserSales = async function({sortBy="created", sortDesc=false, contractAd
267
367
  *
268
368
  * @methodGroup User
269
369
  * @namedParams
370
+ * @param {string=} userAddress - Address of a user. If not specified, will return results for current user
270
371
  * @param {string=} sortBy="created" - Sort order. Options: `created`, `price`, `name`
271
372
  * @param {boolean=} sortDesc=false - Sort results descending instead of ascending
272
373
  * @param {Object=} marketplaceParams - Filter results by marketplace
@@ -276,7 +377,7 @@ exports.UserSales = async function({sortBy="created", sortDesc=false, contractAd
276
377
  *
277
378
  * @returns {Promise<Array<Object>>} - List of current user's sales
278
379
  */
279
- exports.UserTransfers = async function({sortBy="created", sortDesc=false, contractAddress, tokenId, marketplaceParams}={}) {
380
+ exports.UserTransfers = async function({userAddress, sortBy="created", sortDesc=false, contractAddress, tokenId, marketplaceParams}={}) {
280
381
  return (
281
382
  await this.FilteredQuery({
282
383
  mode: "transfers",
@@ -284,7 +385,7 @@ exports.UserTransfers = async function({sortBy="created", sortDesc=false, contra
284
385
  limit: 10000,
285
386
  sortBy,
286
387
  sortDesc,
287
- sellerAddress: this.UserAddress(),
388
+ sellerAddress: userAddress || this.UserAddress(),
288
389
  marketplaceParams,
289
390
  contractAddress,
290
391
  tokenId
@@ -304,7 +405,7 @@ exports.UserTransfers = async function({sortBy="created", sortDesc=false, contra
304
405
  * @param {string=} tenantId - The ID of the tenant for which to retrieve configuration
305
406
  * @param {string=} contractAddress - The ID of an nft contract for which to retrieve configuration
306
407
  *
307
- * @returns {Promise<{Object}>} - The tenant configuration
408
+ * @returns {Promise<Object>} - The tenant configuration
308
409
  */
309
410
  exports.TenantConfiguration = async function({tenantId, contractAddress}) {
310
411
  try {
@@ -428,7 +529,7 @@ exports.MarketplaceCSS = async function ({marketplaceParams}) {
428
529
  * @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.
429
530
  * @param {boolean=} forceReload=false - If specified, a new request will be made to check the currently available marketplaces instead of returning cached info
430
531
  *
431
- * @returns {Promise<{Object}>} - Info about available marketplaces
532
+ * @returns {Promise<Object>} - Info about available marketplaces
432
533
  */
433
534
  exports.AvailableMarketplaces = async function ({organizeById, forceReload=false}={}) {
434
535
  if(forceReload) {
@@ -507,7 +608,7 @@ exports.NFT = async function({tokenId, contractAddress}) {
507
608
 
508
609
  nft.config = await this.TenantConfiguration({contractAddress});
509
610
 
510
- return FormatNFTMetadata(nft);
611
+ return FormatNFTMetadata(this, nft);
511
612
  };
512
613
 
513
614
  /**
@@ -580,6 +681,7 @@ exports.ListingStatus = async function({listingId}) {
580
681
  */
581
682
  exports.Listing = async function({listingId}) {
582
683
  return FormatNFT(
684
+ this,
583
685
  await Utils.ResponseToJson(
584
686
  await this.client.authClient.MakeAuthServiceRequest({
585
687
  path: UrlJoin("as", "mkt", "l", listingId),
@@ -619,6 +721,7 @@ exports.Listing = async function({listingId}) {
619
721
  * @param {Object=} marketplaceParams - Filter results by marketplace
620
722
  * @param {Array<integer>=} collectionIndexes - If filtering by marketplace, filter by collection(s). The index refers to the index in the array `marketplace.collections`
621
723
  * @param {integer=} lastNDays - Filter by results listed in the past N days
724
+ * @param {boolean=} includeCheckoutLocked - If specified, listings which are currently in the checkout process (and not so currently purchasable) will be included in the results. By default they are excluded.
622
725
  *
623
726
  * @returns {Promise<Object>} - Results of the query and pagination info
624
727
  */
@@ -767,6 +870,41 @@ exports.SalesStats = async function() {
767
870
  return this.FilteredQuery({mode: "sales-stats", ...(arguments[0] || {})});
768
871
  };
769
872
 
873
+ /**
874
+ * Get the leaderboard rankings for the specified marketplace. If user address is specified, will return the ranking for the specified user (if present)
875
+ *
876
+ * @methodGroup Leaderboard
877
+ * @namedParams
878
+ * @param {Object=} marketplaceParams - Filter results by marketplace
879
+ * @param {string=} userAddress - Retrieve the ranking for a specific user
880
+ * @param {integer=} start=0 - PAGINATION: Index from which the results should start
881
+ * @param {integer=} limit=50 - PAGINATION: Maximum number of results to return
882
+ *
883
+ * @returns {Promise<Array|Object>} - Returns a list of leaderboard rankings or, if userAddress is specified, ranking for that user.
884
+ */
885
+ exports.Leaderboard = async function({userAddress, marketplaceParams}) {
886
+ if(userAddress) {
887
+ let params = {
888
+ addr: Utils.FormatAddress(userAddress)
889
+ };
890
+
891
+ if(marketplaceParams) {
892
+ params.filter = [`tenant:eq:${(await this.MarketplaceInfo({marketplaceParams})).tenantId}`];
893
+ }
894
+
895
+ return ((await Utils.ResponseToJson(
896
+ await this.client.authClient.MakeAuthServiceRequest({
897
+ path: UrlJoin("as", "wlt", "ranks"),
898
+ method: "GET",
899
+ queryParams: params
900
+ })
901
+ )) || [])[0];
902
+ }
903
+
904
+ return this.FilteredQuery({mode: "leaderboard", ...(arguments[0] || {})});
905
+ };
906
+
907
+
770
908
 
771
909
  /**
772
910
  * <b><i>Requires login</i></b>
@@ -888,7 +1026,7 @@ exports.ListingEditionNames = async function({displayName}) {
888
1026
  };
889
1027
 
890
1028
  /**
891
- * Retrieve names of all valid attributes for listed tiems. Full attribute names and values are required for filtering listing results by attributes.
1029
+ * Retrieve names of all valid attributes for listed items. Full attribute names and values are required for filtering listing results by attributes.
892
1030
  *
893
1031
  * Specify marketplace information to filter the results to only items offered in that marketplace.
894
1032
  *
@@ -1,6 +1,7 @@
1
1
  let WalletConfiguration = {
2
2
  demo: {
3
3
  configUrl: "https://demov3.net955210.contentfabric.io/config",
4
+ stateStoreUrls: ["https://appsvc.svc.eluv.io/dv3"],
4
5
  staging: {
5
6
  siteId: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG",
6
7
  purchaseMode: "develop",
@@ -9,6 +10,7 @@ let WalletConfiguration = {
9
10
  },
10
11
  main: {
11
12
  configUrl: "https://main.net955305.contentfabric.io/config",
13
+ stateStoreUrls: ["https://appsvc.svc.eluv.io/main"],
12
14
  staging: {
13
15
  siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
14
16
  purchaseMode: "production",
@@ -0,0 +1,182 @@
1
+ const Utils = require("../Utils");
2
+ const UrlJoin = require("url-join");
3
+
4
+ const StateStorePath = ({network, path}) => {
5
+ return UrlJoin(network === "main" ? "/main" : "/dv3", path);
6
+ };
7
+
8
+ const UserProfilePath = ({network, appId, userAddress, key, type, mode}) => {
9
+ return StateStorePath({network, path: UrlJoin(type === "app" ? "app" : "usr", type === "app" ? appId : "", userAddress, mode === "public" ? "pub" : "pri", key || "")});
10
+ };
11
+
12
+ /**
13
+ * Methods related to getting and setting user profile data.
14
+ *
15
+ * @module ProfileMethods
16
+ */
17
+
18
+ /**
19
+ * Retrieve user profile metadata for the specified user
20
+ *
21
+ * @methodGroup ProfileMetadata
22
+ * @namedParams
23
+ * @param {string=} type="app" - Specify `app` or `user` metadata.
24
+ * @param {string=} mode="public" - Specify `public` or `private` metadata. If private is specified, you may only retrieve metadata for the current user.
25
+ * @param {string=} appId - Namespace to use for the metadata, if retrieving app metadata. Uses the app ID specified on client initialization by default.
26
+ * @param {string=} userAddress - User to retrieve metadata for. If not specified, will retrieve metadata for the current user
27
+ * @param {string=} key - The metadata key to retrieve
28
+ *
29
+ * @returns {Promise<Object|String>} - Returns the specified metadata
30
+ */
31
+ exports.ProfileMetadata = async function({type="app", mode="public", appId, userAddress, key}) {
32
+ try {
33
+ const response = await this.stateStoreClient.Request({
34
+ path: UserProfilePath({
35
+ network: this.network,
36
+ appId: appId || this.appId,
37
+ userAddress: userAddress || this.UserAddress(),
38
+ type,
39
+ mode,
40
+ key
41
+ }),
42
+ headers: mode === "private" ?
43
+ {Authorization: `Bearer ${this.AuthToken()}`} : undefined
44
+ });
45
+
46
+ if(!response.ok) {
47
+ throw response;
48
+ }
49
+
50
+ return (await Utils.ResponseToJson(response))[key];
51
+ } catch(error) {
52
+ if(error.status === 404) {
53
+ return undefined;
54
+ }
55
+
56
+ throw error;
57
+ }
58
+ };
59
+
60
+ /**
61
+ * Set user profile metadata for the current user
62
+ *
63
+ * @methodGroup ProfileMetadata
64
+ * @namedParams
65
+ * @param {string=} type="app" - Specify `app` or `user` metadata.
66
+ * @param {string=} mode="public" - Specify `public` or `private` metadata.
67
+ * @param {string=} appId - Namespace to use for the metadata, if retrieving app metadata. Uses the app ID specified on client initialization by default.
68
+ * @param {string} key - The metadata key to set
69
+ * @param {string} value - The metadata value to set
70
+ */
71
+ exports.SetProfileMetadata = async function({type="app", mode="public", appId, key, value}) {
72
+ await this.stateStoreClient.Request({
73
+ method: "POST",
74
+ path: UserProfilePath({
75
+ network: this.network,
76
+ appId: appId || this.appId,
77
+ userAddress: this.UserAddress(),
78
+ type,
79
+ mode,
80
+ key
81
+ }),
82
+ body: value,
83
+ bodyType: typeof value === "object" ? "JSON" : "string",
84
+ headers: {
85
+ Authorization: `Bearer ${this.AuthToken()}`
86
+ }
87
+ });
88
+ };
89
+
90
+
91
+ /**
92
+ * Remove user profile metadata for the current user
93
+ *
94
+ * @methodGroup ProfileMetadata
95
+ * @namedParams
96
+ * @param {string=} type="app" - Specify `app` or `user` metadata.
97
+ * @param {string=} mode="public" - Specify `public` or `private` metadata.
98
+ * @param {string=} appId - Namespace to use for the metadata, if retrieving app metadata.. Uses the app ID specified on client initialization by default.
99
+ * @param {string} key - The metadata key to set
100
+ * @param {string} value - The metadata value to set
101
+ */
102
+ exports.RemoveProfileMetadata = async function({type="app", mode="public", appId, key, value}) {
103
+ await this.stateStoreClient.Request({
104
+ method: "DELETE",
105
+ path: UserProfilePath({
106
+ network: this.network,
107
+ appId: appId || this.appId,
108
+ userAddress: this.UserAddress(),
109
+ type,
110
+ mode,
111
+ key
112
+ }),
113
+ body: value,
114
+ headers: {
115
+ Authorization: `Bearer ${this.AuthToken()}`
116
+ }
117
+ });
118
+ };
119
+
120
+ /**
121
+ * Retrieve profile info for the specified user, including address, username and profile image (if set)
122
+ *
123
+ * @methodGroup Profile
124
+ * @param {string=} userAddress - Address of the user
125
+ * @param {string=} userName - Username of the user
126
+ *
127
+ * @returns {Promise<Object>} - Profile info of the specified user
128
+ */
129
+ exports.Profile = async function({userAddress, userName}) {
130
+ if(userName) {
131
+ userAddress = await this.UserNameToAddress({userName});
132
+ }
133
+
134
+ if(!userAddress) {
135
+ throw Error("Eluvio Wallet Client: Unable to determine profile - user address not specified");
136
+ }
137
+
138
+ if(!userName) {
139
+ userName = await this.ProfileMetadata({type: "user", userAddress, key: "username"});
140
+ }
141
+
142
+ const imageUrl = await this.ProfileMetadata({type: "user", userAddress, key: "icon_url"});
143
+
144
+ return {
145
+ userAddress: Utils.FormatAddress(userAddress),
146
+ userName,
147
+ imageUrl
148
+ };
149
+ };
150
+
151
+ exports.UserNameToAddress = async function({userName}) {
152
+ try {
153
+ const response = await this.stateStoreClient.Request({
154
+ method: "GET",
155
+ path: StateStorePath({network: this.network, path: UrlJoin("usr", "profile_for_username", userName)}),
156
+ });
157
+
158
+ if(!response.ok) {
159
+ throw response;
160
+ }
161
+
162
+ return (await Utils.ResponseToJson(response)).address;
163
+ } catch(error) {
164
+ if(error.status !== 404) {
165
+ throw error;
166
+ }
167
+ }
168
+
169
+ return undefined;
170
+ };
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
@@ -23,6 +23,24 @@ const RarityToPercentage = (rarity) => {
23
23
  return percentage;
24
24
  };
25
25
 
26
+ const LinkTargetHash = function(link) {
27
+ if(!link) { return; }
28
+
29
+ if(link["."] && link["."].source) {
30
+ return link["."].source;
31
+ }
32
+
33
+ if(link["/"] && link["/"].startsWith("/qfab/")) {
34
+ return link["/"].split("/").find(segment => segment.startsWith("hq__"));
35
+ }
36
+
37
+ if(link["."] && link["."].container) {
38
+ return link["."].container;
39
+ }
40
+ };
41
+
42
+ exports.LinkTargetHash = LinkTargetHash;
43
+
26
44
  // Format NFT or listing result into consistent format
27
45
  const FormatNFTDetails = function(entry) {
28
46
  const isListing = !!entry.id;
@@ -70,7 +88,7 @@ const FormatNFTDetails = function(entry) {
70
88
  exports.FormatNFTDetails = FormatNFTDetails;
71
89
 
72
90
 
73
- const FormatNFTMetadata = function(nft) {
91
+ const FormatNFTMetadata = function(walletClient, nft) {
74
92
  nft.formatted = true;
75
93
 
76
94
  // Surface relevant details to top level
@@ -105,10 +123,13 @@ const FormatNFTMetadata = function(nft) {
105
123
 
106
124
  let embedUrl = new URL("https://embed.v3.contentfabric.io");
107
125
  embedUrl.searchParams.set("p", "");
108
- embedUrl.searchParams.set("net", rootStore.network === "demo" ? "demo" : "main");
109
- embedUrl.searchParams.set("ath", rootStore.authToken);
126
+ embedUrl.searchParams.set("net", walletClient.network === "demo" ? "demo" : "main");
110
127
 
111
- if(mediaType === "video") {
128
+ if(media.requires_permissions) {
129
+ embedUrl.searchParams.set("ath", walletClient.AuthToken());
130
+ }
131
+
132
+ if(["video", "audio"].includes(mediaType)) {
112
133
  embedUrl.searchParams.set("vid", LinkTargetHash(media.media_link));
113
134
  embedUrl.searchParams.set("ct", "h");
114
135
  embedUrl.searchParams.set("ap", "");
@@ -123,6 +144,7 @@ const FormatNFTMetadata = function(nft) {
123
144
  embed_url: embedUrl.toString()
124
145
  };
125
146
  } catch(error) {
147
+ walletClient.Log(error, true);
126
148
  return media;
127
149
  }
128
150
  });
@@ -134,8 +156,7 @@ const FormatNFTMetadata = function(nft) {
134
156
  if(nft.metadata.pack_options && nft.metadata.pack_options[key]) {
135
157
  let embedUrl = new URL("https://embed.v3.contentfabric.io");
136
158
  embedUrl.searchParams.set("p", "");
137
- embedUrl.searchParams.set("net", rootStore.network === "demo" ? "demo" : "main");
138
- embedUrl.searchParams.set("ath", rootStore.authToken || rootStore.staticToken);
159
+ embedUrl.searchParams.set("net", walletClient.network === "demo" ? "demo" : "main");
139
160
  embedUrl.searchParams.set("vid", LinkTargetHash(nft.metadata.pack_options[key]));
140
161
  embedUrl.searchParams.set("ap", "");
141
162
 
@@ -155,27 +176,11 @@ const FormatNFTMetadata = function(nft) {
155
176
 
156
177
  exports.FormatNFTMetadata = FormatNFTMetadata;
157
178
 
158
- exports.FormatNFT = function (item) {
159
- return FormatNFTMetadata(FormatNFTDetails(item));
179
+ exports.FormatNFT = function (walletClient, item) {
180
+ return FormatNFTMetadata(walletClient, FormatNFTDetails(item));
160
181
  };
161
182
 
162
183
 
163
- exports.LinkTargetHash = function(link) {
164
- if(!link) { return; }
165
-
166
- if(link["."] && link["."].source) {
167
- return link["."].source;
168
- }
169
-
170
- if(link["/"] && link["/"].startsWith("/qfab/")) {
171
- return link["/"].split("/").find(segment => segment.startsWith("hq__"));
172
- }
173
-
174
- if(link["."] && link["."].container) {
175
- return link["."].container;
176
- }
177
- };
178
-
179
184
  // https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen
180
185
  const Popup = ({url, title, w, h}) => {
181
186
  // Fixes dual-screen position