@eluvio/elv-client-js 3.2.5 → 3.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- var _typeof = require("@babel/runtime/helpers/typeof");
2
-
3
1
  var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
4
2
 
5
3
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
6
4
 
7
5
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
8
6
 
7
+ var _typeof = require("@babel/runtime/helpers/typeof");
8
+
9
9
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
10
10
 
11
11
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
@@ -29,6 +29,8 @@ var _require2 = require("./Utils"),
29
29
  var UrlJoin = require("url-join");
30
30
 
31
31
  var Utils = require("../Utils");
32
+
33
+ var Ethers = require("ethers");
32
34
  /**
33
35
  * Use the <a href="#.Initialize">Initialize</a> method to initialize a new client.
34
36
  *
@@ -97,10 +99,186 @@ var ElvWalletClient = /*#__PURE__*/function () {
97
99
  */
98
100
 
99
101
  }, {
100
- key: "LogIn",
102
+ key: "CanSign",
101
103
  value:
102
104
  /* Login and authorization */
103
105
 
106
+ /**
107
+ * Check if this client can sign without opening a popup.
108
+ *
109
+ * Generally, Eluvio custodial wallet users will require a popup prompt, while Metamask and custom OAuth users will not.
110
+ *
111
+ * @methodGroup Signatures
112
+ * @returns {boolean} - Whether or not this client can sign a message without a popup.
113
+ */
114
+ function CanSign() {
115
+ if (!this.loggedIn) {
116
+ return false;
117
+ }
118
+
119
+ return !!this.__authorization.clusterToken || !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
120
+ }
121
+ /**
122
+ * <b><i>Requires login</i></b>
123
+ *
124
+ * Request the current user sign the specified message.
125
+ *
126
+ * If this client is not able to perform the signature (Eluvio custodial OAuth users), a popup will be opened and the user will be prompted to sign.
127
+ *
128
+ * To check if the signature can be done without a popup, use the <a href="#CanSign">CanSign</a> method.
129
+ *
130
+ * @methodGroup Signatures
131
+ * @namedParams
132
+ * @param {string} message - The message to sign
133
+ *
134
+ * @throws - If the user rejects the signature or closes the popup, an error will be thrown.
135
+ *
136
+ * @returns {Promise<string>} - The signature of the message
137
+ */
138
+
139
+ }, {
140
+ key: "PersonalSign",
141
+ value: function () {
142
+ var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
143
+ var message, parameters, url;
144
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
145
+ while (1) {
146
+ switch (_context3.prev = _context3.next) {
147
+ case 0:
148
+ message = _ref2.message;
149
+
150
+ if (this.loggedIn) {
151
+ _context3.next = 3;
152
+ break;
153
+ }
154
+
155
+ throw Error("ElvWalletClient: Unable to perform signature - Not logged in");
156
+
157
+ case 3:
158
+ if (!this.CanSign()) {
159
+ _context3.next = 17;
160
+ break;
161
+ }
162
+
163
+ if (!this.__authorization.clusterToken) {
164
+ _context3.next = 12;
165
+ break;
166
+ }
167
+
168
+ // Custodial wallet sign
169
+ message = _typeof(message) === "object" ? JSON.stringify(message) : message;
170
+ message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
171
+ _context3.next = 9;
172
+ return this.client.authClient.Sign(message);
173
+
174
+ case 9:
175
+ return _context3.abrupt("return", _context3.sent);
176
+
177
+ case 12:
178
+ if (!(this.UserInfo().walletName.toLowerCase() === "metamask")) {
179
+ _context3.next = 16;
180
+ break;
181
+ }
182
+
183
+ return _context3.abrupt("return", this.SignMetamask({
184
+ message: message,
185
+ address: this.UserAddress()
186
+ }));
187
+
188
+ case 16:
189
+ throw Error("ElvWalletClient: Unable to sign");
190
+
191
+ case 17:
192
+ parameters = {
193
+ action: "personal-sign",
194
+ message: message,
195
+ logIn: true
196
+ };
197
+ url = new URL(this.appUrl);
198
+ url.hash = UrlJoin("/action", "sign", Utils.B58(JSON.stringify(parameters)));
199
+ url.searchParams.set("origin", window.location.origin);
200
+ _context3.next = 23;
201
+ return new Promise( /*#__PURE__*/function () {
202
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
203
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
204
+ while (1) {
205
+ switch (_context2.prev = _context2.next) {
206
+ case 0:
207
+ _context2.next = 2;
208
+ return ActionPopup({
209
+ mode: "tab",
210
+ url: url.toString(),
211
+ onCancel: function onCancel() {
212
+ return reject("User cancelled sign");
213
+ },
214
+ onMessage: function () {
215
+ var _onMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, Close) {
216
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
217
+ while (1) {
218
+ switch (_context.prev = _context.next) {
219
+ case 0:
220
+ if (!(!event || !event.data || event.data.type !== "FlowResponse")) {
221
+ _context.next = 2;
222
+ break;
223
+ }
224
+
225
+ return _context.abrupt("return");
226
+
227
+ case 2:
228
+ try {
229
+ resolve(event.data.response);
230
+ } catch (error) {
231
+ reject(error);
232
+ } finally {
233
+ Close();
234
+ }
235
+
236
+ case 3:
237
+ case "end":
238
+ return _context.stop();
239
+ }
240
+ }
241
+ }, _callee);
242
+ }));
243
+
244
+ function onMessage(_x4, _x5) {
245
+ return _onMessage.apply(this, arguments);
246
+ }
247
+
248
+ return onMessage;
249
+ }()
250
+ });
251
+
252
+ case 2:
253
+ case "end":
254
+ return _context2.stop();
255
+ }
256
+ }
257
+ }, _callee2);
258
+ }));
259
+
260
+ return function (_x2, _x3) {
261
+ return _ref3.apply(this, arguments);
262
+ };
263
+ }());
264
+
265
+ case 23:
266
+ return _context3.abrupt("return", _context3.sent);
267
+
268
+ case 24:
269
+ case "end":
270
+ return _context3.stop();
271
+ }
272
+ }
273
+ }, _callee3, this);
274
+ }));
275
+
276
+ function PersonalSign(_x) {
277
+ return _PersonalSign.apply(this, arguments);
278
+ }
279
+
280
+ return PersonalSign;
281
+ }()
104
282
  /**
105
283
  * Direct the user to the Eluvio Media Wallet login page.
106
284
  *
@@ -119,17 +297,20 @@ var ElvWalletClient = /*#__PURE__*/function () {
119
297
  *
120
298
  * @throws - If using the popup flow and the user closes the popup, this method will throw an error.
121
299
  */
122
- function () {
123
- var _LogIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
300
+
301
+ }, {
302
+ key: "LogIn",
303
+ value: function () {
304
+ var _LogIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref4) {
124
305
  var _this = this;
125
306
 
126
- var _ref2$method, method, provider, _ref2$mode, mode, callbackUrl, marketplaceParams, _ref2$clearLogin, clearLogin, callback, loginUrl;
307
+ var _ref4$method, method, provider, _ref4$mode, mode, callbackUrl, marketplaceParams, _ref4$clearLogin, clearLogin, callback, loginUrl;
127
308
 
128
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
309
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
129
310
  while (1) {
130
- switch (_context3.prev = _context3.next) {
311
+ switch (_context6.prev = _context6.next) {
131
312
  case 0:
132
- _ref2$method = _ref2.method, method = _ref2$method === void 0 ? "redirect" : _ref2$method, provider = _ref2.provider, _ref2$mode = _ref2.mode, mode = _ref2$mode === void 0 ? "login" : _ref2$mode, callbackUrl = _ref2.callbackUrl, marketplaceParams = _ref2.marketplaceParams, _ref2$clearLogin = _ref2.clearLogin, clearLogin = _ref2$clearLogin === void 0 ? false : _ref2$clearLogin, callback = _ref2.callback;
313
+ _ref4$method = _ref4.method, method = _ref4$method === void 0 ? "redirect" : _ref4$method, provider = _ref4.provider, _ref4$mode = _ref4.mode, mode = _ref4$mode === void 0 ? "login" : _ref4$mode, callbackUrl = _ref4.callbackUrl, marketplaceParams = _ref4.marketplaceParams, _ref4$clearLogin = _ref4.clearLogin, clearLogin = _ref4$clearLogin === void 0 ? false : _ref4$clearLogin, callback = _ref4.callback;
133
314
  loginUrl = new URL(this.appUrl);
134
315
  loginUrl.hash = "/login";
135
316
  loginUrl.searchParams.set("origin", window.location.origin);
@@ -144,22 +325,22 @@ var ElvWalletClient = /*#__PURE__*/function () {
144
325
  }
145
326
 
146
327
  if (!marketplaceParams) {
147
- _context3.next = 15;
328
+ _context6.next = 15;
148
329
  break;
149
330
  }
150
331
 
151
- _context3.t0 = loginUrl.searchParams;
152
- _context3.next = 11;
332
+ _context6.t0 = loginUrl.searchParams;
333
+ _context6.next = 11;
153
334
  return this.MarketplaceInfo({
154
335
  marketplaceParams: marketplaceParams
155
336
  });
156
337
 
157
338
  case 11:
158
- _context3.t1 = _context3.sent.marketplaceHash;
339
+ _context6.t1 = _context6.sent.marketplaceHash;
159
340
 
160
- _context3.t0.set.call(_context3.t0, "mid", _context3.t1);
341
+ _context6.t0.set.call(_context6.t0, "mid", _context6.t1);
161
342
 
162
- _context3.next = 16;
343
+ _context6.next = 16;
163
344
  break;
164
345
 
165
346
  case 15:
@@ -173,7 +354,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
173
354
  }
174
355
 
175
356
  if (!(method === "redirect")) {
176
- _context3.next = 24;
357
+ _context6.next = 24;
177
358
  break;
178
359
  }
179
360
 
@@ -181,20 +362,20 @@ var ElvWalletClient = /*#__PURE__*/function () {
181
362
  loginUrl.searchParams.set("source", "origin");
182
363
  loginUrl.searchParams.set("redirect", callbackUrl);
183
364
  window.location = loginUrl;
184
- _context3.next = 28;
365
+ _context6.next = 28;
185
366
  break;
186
367
 
187
368
  case 24:
188
369
  loginUrl.searchParams.set("response", "message");
189
370
  loginUrl.searchParams.set("source", "parent");
190
- _context3.next = 28;
371
+ _context6.next = 28;
191
372
  return new Promise( /*#__PURE__*/function () {
192
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
193
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
373
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(resolve, reject) {
374
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
194
375
  while (1) {
195
- switch (_context2.prev = _context2.next) {
376
+ switch (_context5.prev = _context5.next) {
196
377
  case 0:
197
- _context2.next = 2;
378
+ _context5.next = 2;
198
379
  return ActionPopup({
199
380
  mode: "tab",
200
381
  url: loginUrl.toString(),
@@ -202,64 +383,64 @@ var ElvWalletClient = /*#__PURE__*/function () {
202
383
  return reject("User cancelled login");
203
384
  },
204
385
  onMessage: function () {
205
- var _onMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, Close) {
206
- return _regeneratorRuntime.wrap(function _callee$(_context) {
386
+ var _onMessage2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(event, Close) {
387
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
207
388
  while (1) {
208
- switch (_context.prev = _context.next) {
389
+ switch (_context4.prev = _context4.next) {
209
390
  case 0:
210
391
  if (!(!event || !event.data || event.data.type !== "LoginResponse")) {
211
- _context.next = 2;
392
+ _context4.next = 2;
212
393
  break;
213
394
  }
214
395
 
215
- return _context.abrupt("return");
396
+ return _context4.abrupt("return");
216
397
 
217
398
  case 2:
218
- _context.prev = 2;
399
+ _context4.prev = 2;
219
400
 
220
401
  if (!callback) {
221
- _context.next = 8;
402
+ _context4.next = 8;
222
403
  break;
223
404
  }
224
405
 
225
- _context.next = 6;
406
+ _context4.next = 6;
226
407
  return callback(event.data.params);
227
408
 
228
409
  case 6:
229
- _context.next = 10;
410
+ _context4.next = 10;
230
411
  break;
231
412
 
232
413
  case 8:
233
- _context.next = 10;
414
+ _context4.next = 10;
234
415
  return _this.Authenticate({
235
416
  token: event.data.params.clientSigningToken || event.data.params.clientAuthToken
236
417
  });
237
418
 
238
419
  case 10:
239
420
  resolve();
240
- _context.next = 16;
421
+ _context4.next = 16;
241
422
  break;
242
423
 
243
424
  case 13:
244
- _context.prev = 13;
245
- _context.t0 = _context["catch"](2);
246
- reject(_context.t0);
425
+ _context4.prev = 13;
426
+ _context4.t0 = _context4["catch"](2);
427
+ reject(_context4.t0);
247
428
 
248
429
  case 16:
249
- _context.prev = 16;
430
+ _context4.prev = 16;
250
431
  Close();
251
- return _context.finish(16);
432
+ return _context4.finish(16);
252
433
 
253
434
  case 19:
254
435
  case "end":
255
- return _context.stop();
436
+ return _context4.stop();
256
437
  }
257
438
  }
258
- }, _callee, null, [[2, 13, 16, 19]]);
439
+ }, _callee4, null, [[2, 13, 16, 19]]);
259
440
  }));
260
441
 
261
- function onMessage(_x4, _x5) {
262
- return _onMessage.apply(this, arguments);
442
+ function onMessage(_x9, _x10) {
443
+ return _onMessage2.apply(this, arguments);
263
444
  }
264
445
 
265
446
  return onMessage;
@@ -268,26 +449,26 @@ var ElvWalletClient = /*#__PURE__*/function () {
268
449
 
269
450
  case 2:
270
451
  case "end":
271
- return _context2.stop();
452
+ return _context5.stop();
272
453
  }
273
454
  }
274
- }, _callee2);
455
+ }, _callee5);
275
456
  }));
276
457
 
277
- return function (_x2, _x3) {
278
- return _ref3.apply(this, arguments);
458
+ return function (_x7, _x8) {
459
+ return _ref5.apply(this, arguments);
279
460
  };
280
461
  }());
281
462
 
282
463
  case 28:
283
464
  case "end":
284
- return _context3.stop();
465
+ return _context6.stop();
285
466
  }
286
467
  }
287
- }, _callee3, this);
468
+ }, _callee6, this);
288
469
  }));
289
470
 
290
- function LogIn(_x) {
471
+ function LogIn(_x6) {
291
472
  return _LogIn.apply(this, arguments);
292
473
  }
293
474
 
@@ -323,53 +504,57 @@ var ElvWalletClient = /*#__PURE__*/function () {
323
504
  }, {
324
505
  key: "Authenticate",
325
506
  value: function () {
326
- var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref4) {
507
+ var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref6) {
327
508
  var token, decodedToken;
328
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
509
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
329
510
  while (1) {
330
- switch (_context4.prev = _context4.next) {
511
+ switch (_context7.prev = _context7.next) {
331
512
  case 0:
332
- token = _ref4.token;
333
- _context4.prev = 1;
513
+ token = _ref6.token;
514
+ _context7.prev = 1;
334
515
  decodedToken = JSON.parse(this.utils.FromB58ToStr(token)) || {};
335
- _context4.next = 8;
516
+ _context7.next = 8;
336
517
  break;
337
518
 
338
519
  case 5:
339
- _context4.prev = 5;
340
- _context4.t0 = _context4["catch"](1);
520
+ _context7.prev = 5;
521
+ _context7.t0 = _context7["catch"](1);
341
522
  throw new Error("Invalid authorization token " + token);
342
523
 
343
524
  case 8:
344
525
  if (!(!decodedToken.expiresAt || Date.now() > decodedToken.expiresAt)) {
345
- _context4.next = 10;
526
+ _context7.next = 10;
346
527
  break;
347
528
  }
348
529
 
349
530
  throw Error("ElvWalletClient: Provided authorization token has expired");
350
531
 
351
532
  case 10:
352
- this.client.SetStaticToken({
353
- token: decodedToken.fabricToken
354
- });
355
-
356
- if (decodedToken.clusterToken) {
357
- this.client.SetRemoteSigner({
358
- authToken: decodedToken.clusterToken
359
- });
533
+ if (!decodedToken.clusterToken) {
534
+ _context7.next = 13;
535
+ break;
360
536
  }
361
537
 
362
- return _context4.abrupt("return", this.SetAuthorization(decodedToken));
538
+ _context7.next = 13;
539
+ return this.client.SetRemoteSigner({
540
+ authToken: decodedToken.clusterToken
541
+ });
363
542
 
364
543
  case 13:
544
+ this.client.SetStaticToken({
545
+ token: decodedToken.fabricToken
546
+ });
547
+ return _context7.abrupt("return", this.SetAuthorization(decodedToken));
548
+
549
+ case 15:
365
550
  case "end":
366
- return _context4.stop();
551
+ return _context7.stop();
367
552
  }
368
553
  }
369
- }, _callee4, this, [[1, 5]]);
554
+ }, _callee7, this, [[1, 5]]);
370
555
  }));
371
556
 
372
- function Authenticate(_x6) {
557
+ function Authenticate(_x11) {
373
558
  return _Authenticate.apply(this, arguments);
374
559
  }
375
560
 
@@ -398,28 +583,28 @@ var ElvWalletClient = /*#__PURE__*/function () {
398
583
  }, {
399
584
  key: "AuthenticateOAuth",
400
585
  value: function () {
401
- var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
402
- var idToken, tenantId, email, _ref5$shareEmail, shareEmail, _ref5$tokenDuration, tokenDuration, expiresAt, fabricToken, address, decodedToken;
586
+ var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref7) {
587
+ var idToken, tenantId, email, _ref7$shareEmail, shareEmail, _ref7$tokenDuration, tokenDuration, expiresAt, fabricToken, address, decodedToken;
403
588
 
404
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
589
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
405
590
  while (1) {
406
- switch (_context5.prev = _context5.next) {
591
+ switch (_context8.prev = _context8.next) {
407
592
  case 0:
408
- idToken = _ref5.idToken, tenantId = _ref5.tenantId, email = _ref5.email, _ref5$shareEmail = _ref5.shareEmail, shareEmail = _ref5$shareEmail === void 0 ? false : _ref5$shareEmail, _ref5$tokenDuration = _ref5.tokenDuration, tokenDuration = _ref5$tokenDuration === void 0 ? 24 : _ref5$tokenDuration;
593
+ idToken = _ref7.idToken, tenantId = _ref7.tenantId, email = _ref7.email, _ref7$shareEmail = _ref7.shareEmail, shareEmail = _ref7$shareEmail === void 0 ? false : _ref7$shareEmail, _ref7$tokenDuration = _ref7.tokenDuration, tokenDuration = _ref7$tokenDuration === void 0 ? 24 : _ref7$tokenDuration;
409
594
 
410
595
  if (!(!tenantId && this.selectedMarketplaceInfo)) {
411
- _context5.next = 5;
596
+ _context8.next = 5;
412
597
  break;
413
598
  }
414
599
 
415
- _context5.next = 4;
600
+ _context8.next = 4;
416
601
  return this.AvailableMarketplaces();
417
602
 
418
603
  case 4:
419
604
  tenantId = this.selectedMarketplaceInfo.tenantId;
420
605
 
421
606
  case 5:
422
- _context5.next = 7;
607
+ _context8.next = 7;
423
608
  return this.client.SetRemoteSigner({
424
609
  idToken: idToken,
425
610
  tenantId: tenantId,
@@ -431,36 +616,36 @@ var ElvWalletClient = /*#__PURE__*/function () {
431
616
 
432
617
  case 7:
433
618
  expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
434
- _context5.next = 10;
619
+ _context8.next = 10;
435
620
  return this.client.CreateFabricToken({
436
621
  duration: tokenDuration * 60 * 60 * 1000
437
622
  });
438
623
 
439
624
  case 10:
440
- fabricToken = _context5.sent;
625
+ fabricToken = _context8.sent;
441
626
  address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
442
627
 
443
628
  if (email) {
444
- _context5.next = 21;
629
+ _context8.next = 21;
445
630
  break;
446
631
  }
447
632
 
448
- _context5.prev = 13;
633
+ _context8.prev = 13;
449
634
  decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
450
635
  email = decodedToken.email;
451
- _context5.next = 21;
636
+ _context8.next = 21;
452
637
  break;
453
638
 
454
639
  case 18:
455
- _context5.prev = 18;
456
- _context5.t0 = _context5["catch"](13);
640
+ _context8.prev = 18;
641
+ _context8.t0 = _context8["catch"](13);
457
642
  throw Error("Failed to decode ID token");
458
643
 
459
644
  case 21:
460
645
  this.client.SetStaticToken({
461
646
  token: fabricToken
462
647
  });
463
- return _context5.abrupt("return", {
648
+ return _context8.abrupt("return", {
464
649
  authToken: this.SetAuthorization({
465
650
  fabricToken: fabricToken,
466
651
  tenantId: tenantId,
@@ -484,13 +669,13 @@ var ElvWalletClient = /*#__PURE__*/function () {
484
669
 
485
670
  case 23:
486
671
  case "end":
487
- return _context5.stop();
672
+ return _context8.stop();
488
673
  }
489
674
  }
490
- }, _callee5, this, [[13, 18]]);
675
+ }, _callee8, this, [[13, 18]]);
491
676
  }));
492
677
 
493
- function AuthenticateOAuth(_x7) {
678
+ function AuthenticateOAuth(_x12) {
494
679
  return _AuthenticateOAuth.apply(this, arguments);
495
680
  }
496
681
 
@@ -513,16 +698,16 @@ var ElvWalletClient = /*#__PURE__*/function () {
513
698
  }, {
514
699
  key: "AuthenticateExternalWallet",
515
700
  value: function () {
516
- var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref6) {
701
+ var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref8) {
517
702
  var _this2 = this;
518
703
 
519
- var address, _ref6$tokenDuration, tokenDuration, _ref6$walletName, walletName, Sign, expiresAt, fabricToken;
704
+ var address, _ref8$tokenDuration, tokenDuration, _ref8$walletName, walletName, Sign, expiresAt, fabricToken;
520
705
 
521
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
706
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
522
707
  while (1) {
523
- switch (_context7.prev = _context7.next) {
708
+ switch (_context10.prev = _context10.next) {
524
709
  case 0:
525
- address = _ref6.address, _ref6$tokenDuration = _ref6.tokenDuration, tokenDuration = _ref6$tokenDuration === void 0 ? 24 : _ref6$tokenDuration, _ref6$walletName = _ref6.walletName, walletName = _ref6$walletName === void 0 ? "Metamask" : _ref6$walletName, Sign = _ref6.Sign;
710
+ address = _ref8.address, _ref8$tokenDuration = _ref8.tokenDuration, tokenDuration = _ref8$tokenDuration === void 0 ? 24 : _ref8$tokenDuration, _ref8$walletName = _ref8.walletName, walletName = _ref8$walletName === void 0 ? "Metamask" : _ref8$walletName, Sign = _ref8.Sign;
526
711
 
527
712
  if (!address) {
528
713
  address = window.ethereum.selectedAddress;
@@ -532,32 +717,32 @@ var ElvWalletClient = /*#__PURE__*/function () {
532
717
 
533
718
  if (!Sign) {
534
719
  Sign = /*#__PURE__*/function () {
535
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(message) {
536
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
720
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(message) {
721
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
537
722
  while (1) {
538
- switch (_context6.prev = _context6.next) {
723
+ switch (_context9.prev = _context9.next) {
539
724
  case 0:
540
- return _context6.abrupt("return", _this2.SignMetamask({
725
+ return _context9.abrupt("return", _this2.SignMetamask({
541
726
  message: message,
542
727
  address: address
543
728
  }));
544
729
 
545
730
  case 1:
546
731
  case "end":
547
- return _context6.stop();
732
+ return _context9.stop();
548
733
  }
549
734
  }
550
- }, _callee6);
735
+ }, _callee9);
551
736
  }));
552
737
 
553
- return function Sign(_x9) {
554
- return _ref7.apply(this, arguments);
738
+ return function Sign(_x14) {
739
+ return _ref9.apply(this, arguments);
555
740
  };
556
741
  }();
557
742
  }
558
743
 
559
744
  expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
560
- _context7.next = 7;
745
+ _context10.next = 7;
561
746
  return this.client.CreateFabricToken({
562
747
  address: address,
563
748
  duration: tokenDuration * 60 * 60 * 1000,
@@ -566,8 +751,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
566
751
  });
567
752
 
568
753
  case 7:
569
- fabricToken = _context7.sent;
570
- return _context7.abrupt("return", this.SetAuthorization({
754
+ fabricToken = _context10.sent;
755
+ return _context10.abrupt("return", this.SetAuthorization({
571
756
  fabricToken: fabricToken,
572
757
  address: address,
573
758
  expiresAt: expiresAt,
@@ -577,13 +762,13 @@ var ElvWalletClient = /*#__PURE__*/function () {
577
762
 
578
763
  case 9:
579
764
  case "end":
580
- return _context7.stop();
765
+ return _context10.stop();
581
766
  }
582
767
  }
583
- }, _callee7, this);
768
+ }, _callee10, this);
584
769
  }));
585
770
 
586
- function AuthenticateExternalWallet(_x8) {
771
+ function AuthenticateExternalWallet(_x13) {
587
772
  return _AuthenticateExternalWallet.apply(this, arguments);
588
773
  }
589
774
 
@@ -617,15 +802,15 @@ var ElvWalletClient = /*#__PURE__*/function () {
617
802
  }
618
803
  }, {
619
804
  key: "SetAuthorization",
620
- value: function SetAuthorization(_ref8) {
621
- var clusterToken = _ref8.clusterToken,
622
- fabricToken = _ref8.fabricToken,
623
- tenantId = _ref8.tenantId,
624
- address = _ref8.address,
625
- email = _ref8.email,
626
- expiresAt = _ref8.expiresAt,
627
- walletType = _ref8.walletType,
628
- walletName = _ref8.walletName;
805
+ value: function SetAuthorization(_ref10) {
806
+ var clusterToken = _ref10.clusterToken,
807
+ fabricToken = _ref10.fabricToken,
808
+ tenantId = _ref10.tenantId,
809
+ address = _ref10.address,
810
+ email = _ref10.email,
811
+ expiresAt = _ref10.expiresAt,
812
+ walletType = _ref10.walletType,
813
+ walletName = _ref10.walletName;
629
814
  address = this.client.utils.FormatAddress(address);
630
815
  this.__authorization = {
631
816
  fabricToken: fabricToken,
@@ -656,47 +841,57 @@ var ElvWalletClient = /*#__PURE__*/function () {
656
841
  }, {
657
842
  key: "SignMetamask",
658
843
  value: function () {
659
- var _SignMetamask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref9) {
660
- var message, address, from;
661
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
844
+ var _SignMetamask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref11) {
845
+ var message, address, accounts;
846
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
662
847
  while (1) {
663
- switch (_context8.prev = _context8.next) {
848
+ switch (_context11.prev = _context11.next) {
664
849
  case 0:
665
- message = _ref9.message, address = _ref9.address;
850
+ message = _ref11.message, address = _ref11.address;
666
851
 
667
852
  if (window.ethereum) {
668
- _context8.next = 3;
853
+ _context11.next = 3;
669
854
  break;
670
855
  }
671
856
 
672
857
  throw Error("ElvWalletClient: Unable to initialize - Metamask not available");
673
858
 
674
859
  case 3:
675
- _context8.next = 5;
860
+ address = address || this.UserAddress();
861
+ _context11.next = 6;
676
862
  return window.ethereum.request({
677
863
  method: "eth_requestAccounts"
678
864
  });
679
865
 
680
- case 5:
681
- from = address || window.ethereum.selectedAddress;
682
- _context8.next = 8;
866
+ case 6:
867
+ accounts = _context11.sent;
868
+
869
+ if (!(address && !Utils.EqualAddress(accounts[0], address))) {
870
+ _context11.next = 9;
871
+ break;
872
+ }
873
+
874
+ throw Error("ElvWalletClient: Incorrect MetaMask account selected. Expected ".concat(address, ", got ").concat(accounts[0]));
875
+
876
+ case 9:
877
+ _context11.next = 11;
683
878
  return window.ethereum.request({
684
879
  method: "personal_sign",
685
- params: [message, from, ""]
880
+ params: [message, address, ""]
686
881
  });
687
882
 
688
- case 8:
689
- return _context8.abrupt("return", _context8.sent);
883
+ case 11:
884
+ return _context11.abrupt("return", _context11.sent);
690
885
 
691
- case 9:
886
+ case 12:
692
887
  case "end":
693
- return _context8.stop();
888
+ return _context11.stop();
694
889
  }
695
890
  }
696
- }, _callee8);
891
+ }, _callee11, this);
697
892
  }));
698
893
 
699
- function SignMetamask(_x10) {
894
+ function SignMetamask(_x15) {
700
895
  return _SignMetamask.apply(this, arguments);
701
896
  }
702
897
 
@@ -707,7 +902,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
707
902
  }, {
708
903
  key: "LoadAvailableMarketplaces",
709
904
  value: function () {
710
- var _LoadAvailableMarketplaces = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
905
+ var _LoadAvailableMarketplaces = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
711
906
  var _this3 = this;
712
907
 
713
908
  var forceReload,
@@ -715,29 +910,29 @@ var ElvWalletClient = /*#__PURE__*/function () {
715
910
  metadata,
716
911
  availableMarketplaces,
717
912
  availableMarketplacesById,
718
- _args9 = arguments;
719
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
913
+ _args12 = arguments;
914
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
720
915
  while (1) {
721
- switch (_context9.prev = _context9.next) {
916
+ switch (_context12.prev = _context12.next) {
722
917
  case 0:
723
- forceReload = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : false;
918
+ forceReload = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : false;
724
919
 
725
920
  if (!(!forceReload && Object.keys(this.availableMarketplaces) > 0)) {
726
- _context9.next = 3;
921
+ _context12.next = 3;
727
922
  break;
728
923
  }
729
924
 
730
- return _context9.abrupt("return");
925
+ return _context12.abrupt("return");
731
926
 
732
927
  case 3:
733
- _context9.next = 5;
928
+ _context12.next = 5;
734
929
  return this.client.LatestVersionHash({
735
930
  objectId: this.mainSiteId
736
931
  });
737
932
 
738
933
  case 5:
739
- mainSiteHash = _context9.sent;
740
- _context9.next = 8;
934
+ mainSiteHash = _context12.sent;
935
+ _context12.next = 8;
741
936
  return this.client.ContentObjectMetadata({
742
937
  versionHash: mainSiteHash,
743
938
  metadataSubtree: "public/asset_metadata/tenants",
@@ -753,7 +948,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
753
948
  });
754
949
 
755
950
  case 8:
756
- metadata = _context9.sent;
951
+ metadata = _context12.sent;
757
952
  availableMarketplaces = _objectSpread({}, this.availableMarketplaces || {});
758
953
  availableMarketplacesById = _objectSpread({}, this.availableMarketplacesById || {});
759
954
  Object.keys(metadata || {}).forEach(function (tenantSlug) {
@@ -801,10 +996,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
801
996
 
802
997
  case 14:
803
998
  case "end":
804
- return _context9.stop();
999
+ return _context12.stop();
805
1000
  }
806
1001
  }
807
- }, _callee9, this);
1002
+ }, _callee12, this);
808
1003
  }));
809
1004
 
810
1005
  function LoadAvailableMarketplaces() {
@@ -817,21 +1012,21 @@ var ElvWalletClient = /*#__PURE__*/function () {
817
1012
  }, {
818
1013
  key: "LatestMarketplaceHash",
819
1014
  value: function () {
820
- var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref10) {
1015
+ var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref12) {
821
1016
  var tenantSlug, marketplaceSlug, mainSiteHash, marketplaceLink;
822
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
1017
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
823
1018
  while (1) {
824
- switch (_context10.prev = _context10.next) {
1019
+ switch (_context13.prev = _context13.next) {
825
1020
  case 0:
826
- tenantSlug = _ref10.tenantSlug, marketplaceSlug = _ref10.marketplaceSlug;
827
- _context10.next = 3;
1021
+ tenantSlug = _ref12.tenantSlug, marketplaceSlug = _ref12.marketplaceSlug;
1022
+ _context13.next = 3;
828
1023
  return this.client.LatestVersionHash({
829
1024
  objectId: this.mainSiteId
830
1025
  });
831
1026
 
832
1027
  case 3:
833
- mainSiteHash = _context10.sent;
834
- _context10.next = 6;
1028
+ mainSiteHash = _context13.sent;
1029
+ _context13.next = 6;
835
1030
  return this.client.ContentObjectMetadata({
836
1031
  versionHash: mainSiteHash,
837
1032
  metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", tenantSlug, "marketplaces", marketplaceSlug),
@@ -839,18 +1034,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
839
1034
  });
840
1035
 
841
1036
  case 6:
842
- marketplaceLink = _context10.sent;
843
- return _context10.abrupt("return", LinkTargetHash(marketplaceLink));
1037
+ marketplaceLink = _context13.sent;
1038
+ return _context13.abrupt("return", LinkTargetHash(marketplaceLink));
844
1039
 
845
1040
  case 8:
846
1041
  case "end":
847
- return _context10.stop();
1042
+ return _context13.stop();
848
1043
  }
849
1044
  }
850
- }, _callee10, this);
1045
+ }, _callee13, this);
851
1046
  }));
852
1047
 
853
- function LatestMarketplaceHash(_x11) {
1048
+ function LatestMarketplaceHash(_x16) {
854
1049
  return _LatestMarketplaceHash.apply(this, arguments);
855
1050
  }
856
1051
 
@@ -859,37 +1054,37 @@ var ElvWalletClient = /*#__PURE__*/function () {
859
1054
  }, {
860
1055
  key: "LoadMarketplace",
861
1056
  value: function () {
862
- var _LoadMarketplace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(marketplaceParams) {
1057
+ var _LoadMarketplace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(marketplaceParams) {
863
1058
  var _this4 = this;
864
1059
 
865
1060
  var marketplaceInfo, marketplaceId, marketplaceHash, marketplace;
866
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
1061
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
867
1062
  while (1) {
868
- switch (_context12.prev = _context12.next) {
1063
+ switch (_context15.prev = _context15.next) {
869
1064
  case 0:
870
1065
  marketplaceInfo = this.MarketplaceInfo({
871
1066
  marketplaceParams: marketplaceParams
872
1067
  });
873
1068
  marketplaceId = marketplaceInfo.marketplaceId;
874
- _context12.next = 4;
1069
+ _context15.next = 4;
875
1070
  return this.LatestMarketplaceHash({
876
1071
  tenantSlug: marketplaceInfo.tenantSlug,
877
1072
  marketplaceSlug: marketplaceInfo.marketplaceSlug
878
1073
  });
879
1074
 
880
1075
  case 4:
881
- marketplaceHash = _context12.sent;
1076
+ marketplaceHash = _context15.sent;
882
1077
 
883
1078
  if (this.cachedMarketplaces[marketplaceId] && this.cachedMarketplaces[marketplaceId].versionHash !== marketplaceHash) {
884
1079
  delete this.cachedMarketplaces[marketplaceId];
885
1080
  }
886
1081
 
887
1082
  if (this.cachedMarketplaces[marketplaceId]) {
888
- _context12.next = 19;
1083
+ _context15.next = 19;
889
1084
  break;
890
1085
  }
891
1086
 
892
- _context12.next = 9;
1087
+ _context15.next = 9;
893
1088
  return this.client.ContentObjectMetadata({
894
1089
  versionHash: marketplaceHash,
895
1090
  metadataSubtree: "public/asset_metadata/info",
@@ -902,31 +1097,31 @@ var ElvWalletClient = /*#__PURE__*/function () {
902
1097
  });
903
1098
 
904
1099
  case 9:
905
- marketplace = _context12.sent;
906
- _context12.next = 12;
1100
+ marketplace = _context15.sent;
1101
+ _context15.next = 12;
907
1102
  return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
908
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(item, index) {
909
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
1103
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(item, index) {
1104
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
910
1105
  while (1) {
911
- switch (_context11.prev = _context11.next) {
1106
+ switch (_context14.prev = _context14.next) {
912
1107
  case 0:
913
1108
  if (!item.requires_permissions) {
914
- _context11.next = 14;
1109
+ _context14.next = 14;
915
1110
  break;
916
1111
  }
917
1112
 
918
1113
  if (_this4.loggedIn) {
919
- _context11.next = 5;
1114
+ _context14.next = 5;
920
1115
  break;
921
1116
  }
922
1117
 
923
1118
  item.authorized = false;
924
- _context11.next = 14;
1119
+ _context14.next = 14;
925
1120
  break;
926
1121
 
927
1122
  case 5:
928
- _context11.prev = 5;
929
- _context11.next = 8;
1123
+ _context14.prev = 5;
1124
+ _context14.next = 8;
930
1125
  return _this4.client.ContentObjectMetadata({
931
1126
  versionHash: LinkTargetHash(item.nft_template),
932
1127
  metadataSubtree: "permissioned"
@@ -934,34 +1129,34 @@ var ElvWalletClient = /*#__PURE__*/function () {
934
1129
 
935
1130
  case 8:
936
1131
  item.authorized = true;
937
- _context11.next = 14;
1132
+ _context14.next = 14;
938
1133
  break;
939
1134
 
940
1135
  case 11:
941
- _context11.prev = 11;
942
- _context11.t0 = _context11["catch"](5);
1136
+ _context14.prev = 11;
1137
+ _context14.t0 = _context14["catch"](5);
943
1138
  item.authorized = false;
944
1139
 
945
1140
  case 14:
946
1141
  item.nftTemplateMetadata = (item.nft_template || {}).nft || {};
947
1142
  item.itemIndex = index;
948
- return _context11.abrupt("return", item);
1143
+ return _context14.abrupt("return", item);
949
1144
 
950
1145
  case 17:
951
1146
  case "end":
952
- return _context11.stop();
1147
+ return _context14.stop();
953
1148
  }
954
1149
  }
955
- }, _callee11, null, [[5, 11]]);
1150
+ }, _callee14, null, [[5, 11]]);
956
1151
  }));
957
1152
 
958
- return function (_x13, _x14) {
959
- return _ref11.apply(this, arguments);
1153
+ return function (_x18, _x19) {
1154
+ return _ref13.apply(this, arguments);
960
1155
  };
961
1156
  }()));
962
1157
 
963
1158
  case 12:
964
- marketplace.items = _context12.sent;
1159
+ marketplace.items = _context15.sent;
965
1160
  marketplace.collections = (marketplace.collections || []).map(function (collection, collectionIndex) {
966
1161
  return _objectSpread(_objectSpread({}, collection), {}, {
967
1162
  collectionIndex: collectionIndex
@@ -995,17 +1190,17 @@ var ElvWalletClient = /*#__PURE__*/function () {
995
1190
  this.cachedMarketplaces[marketplaceId] = marketplace;
996
1191
 
997
1192
  case 19:
998
- return _context12.abrupt("return", this.cachedMarketplaces[marketplaceId]);
1193
+ return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
999
1194
 
1000
1195
  case 20:
1001
1196
  case "end":
1002
- return _context12.stop();
1197
+ return _context15.stop();
1003
1198
  }
1004
1199
  }
1005
- }, _callee12, this);
1200
+ }, _callee15, this);
1006
1201
  }));
1007
1202
 
1008
- function LoadMarketplace(_x12) {
1203
+ function LoadMarketplace(_x17) {
1009
1204
  return _LoadMarketplace.apply(this, arguments);
1010
1205
  }
1011
1206
 
@@ -1014,13 +1209,13 @@ var ElvWalletClient = /*#__PURE__*/function () {
1014
1209
  }, {
1015
1210
  key: "FilteredQuery",
1016
1211
  value: function () {
1017
- var _FilteredQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
1018
- var _ref12,
1019
- _ref12$mode,
1212
+ var _FilteredQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
1213
+ var _ref14,
1214
+ _ref14$mode,
1020
1215
  mode,
1021
- _ref12$sortBy,
1216
+ _ref14$sortBy,
1022
1217
  sortBy,
1023
- _ref12$sortDesc,
1218
+ _ref14$sortDesc,
1024
1219
  sortDesc,
1025
1220
  filter,
1026
1221
  editionFilter,
@@ -1030,14 +1225,14 @@ var ElvWalletClient = /*#__PURE__*/function () {
1030
1225
  currency,
1031
1226
  marketplaceParams,
1032
1227
  tenantId,
1033
- _ref12$collectionInde,
1228
+ _ref14$collectionInde,
1034
1229
  collectionIndex,
1035
1230
  sellerAddress,
1036
- _ref12$lastNDays,
1231
+ _ref14$lastNDays,
1037
1232
  lastNDays,
1038
- _ref12$start,
1233
+ _ref14$start,
1039
1234
  start,
1040
- _ref12$limit,
1235
+ _ref14$limit,
1041
1236
  limit,
1042
1237
  params,
1043
1238
  marketplaceInfo,
@@ -1045,16 +1240,16 @@ var ElvWalletClient = /*#__PURE__*/function () {
1045
1240
  filters,
1046
1241
  collection,
1047
1242
  path,
1048
- _ref14,
1243
+ _ref16,
1049
1244
  contents,
1050
1245
  paging,
1051
- _args13 = arguments;
1246
+ _args16 = arguments;
1052
1247
 
1053
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
1248
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
1054
1249
  while (1) {
1055
- switch (_context13.prev = _context13.next) {
1250
+ switch (_context16.prev = _context16.next) {
1056
1251
  case 0:
1057
- _ref12 = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {}, _ref12$mode = _ref12.mode, mode = _ref12$mode === void 0 ? "listings" : _ref12$mode, _ref12$sortBy = _ref12.sortBy, sortBy = _ref12$sortBy === void 0 ? "created" : _ref12$sortBy, _ref12$sortDesc = _ref12.sortDesc, sortDesc = _ref12$sortDesc === void 0 ? false : _ref12$sortDesc, filter = _ref12.filter, editionFilter = _ref12.editionFilter, attributeFilters = _ref12.attributeFilters, contractAddress = _ref12.contractAddress, tokenId = _ref12.tokenId, currency = _ref12.currency, marketplaceParams = _ref12.marketplaceParams, tenantId = _ref12.tenantId, _ref12$collectionInde = _ref12.collectionIndex, collectionIndex = _ref12$collectionInde === void 0 ? -1 : _ref12$collectionInde, sellerAddress = _ref12.sellerAddress, _ref12$lastNDays = _ref12.lastNDays, lastNDays = _ref12$lastNDays === void 0 ? -1 : _ref12$lastNDays, _ref12$start = _ref12.start, start = _ref12$start === void 0 ? 0 : _ref12$start, _ref12$limit = _ref12.limit, limit = _ref12$limit === void 0 ? 50 : _ref12$limit;
1252
+ _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, editionFilter = _ref14.editionFilter, attributeFilters = _ref14.attributeFilters, contractAddress = _ref14.contractAddress, tokenId = _ref14.tokenId, currency = _ref14.currency, marketplaceParams = _ref14.marketplaceParams, tenantId = _ref14.tenantId, _ref14$collectionInde = _ref14.collectionIndex, collectionIndex = _ref14$collectionInde === void 0 ? -1 : _ref14$collectionInde, 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;
1058
1253
  collectionIndex = parseInt(collectionIndex);
1059
1254
  params = {
1060
1255
  sort_by: sortBy,
@@ -1064,33 +1259,33 @@ var ElvWalletClient = /*#__PURE__*/function () {
1064
1259
  };
1065
1260
 
1066
1261
  if (!marketplaceParams) {
1067
- _context13.next = 11;
1262
+ _context16.next = 11;
1068
1263
  break;
1069
1264
  }
1070
1265
 
1071
- _context13.next = 6;
1266
+ _context16.next = 6;
1072
1267
  return this.MarketplaceInfo({
1073
1268
  marketplaceParams: marketplaceParams
1074
1269
  });
1075
1270
 
1076
1271
  case 6:
1077
- marketplaceInfo = _context13.sent;
1272
+ marketplaceInfo = _context16.sent;
1078
1273
 
1079
1274
  if (!(collectionIndex >= 0)) {
1080
- _context13.next = 11;
1275
+ _context16.next = 11;
1081
1276
  break;
1082
1277
  }
1083
1278
 
1084
- _context13.next = 10;
1279
+ _context16.next = 10;
1085
1280
  return this.Marketplace({
1086
1281
  marketplaceParams: marketplaceParams
1087
1282
  });
1088
1283
 
1089
1284
  case 10:
1090
- marketplace = _context13.sent;
1285
+ marketplace = _context16.sent;
1091
1286
 
1092
1287
  case 11:
1093
- _context13.prev = 11;
1288
+ _context16.prev = 11;
1094
1289
  filters = [];
1095
1290
 
1096
1291
  if (sellerAddress) {
@@ -1098,7 +1293,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1098
1293
  }
1099
1294
 
1100
1295
  if (!(marketplace && collectionIndex >= 0)) {
1101
- _context13.next = 25;
1296
+ _context16.next = 25;
1102
1297
  break;
1103
1298
  }
1104
1299
 
@@ -1124,19 +1319,19 @@ var ElvWalletClient = /*#__PURE__*/function () {
1124
1319
  }); // No valid items, so there must not be anything relevant in the collection
1125
1320
 
1126
1321
  if (!(filters.length === 0)) {
1127
- _context13.next = 23;
1322
+ _context16.next = 23;
1128
1323
  break;
1129
1324
  }
1130
1325
 
1131
1326
  if (!mode.includes("stats")) {
1132
- _context13.next = 22;
1327
+ _context16.next = 22;
1133
1328
  break;
1134
1329
  }
1135
1330
 
1136
- return _context13.abrupt("return", {});
1331
+ return _context16.abrupt("return", {});
1137
1332
 
1138
1333
  case 22:
1139
- return _context13.abrupt("return", {
1334
+ return _context16.abrupt("return", {
1140
1335
  paging: {
1141
1336
  start: params.start,
1142
1337
  limit: params.limit,
@@ -1147,7 +1342,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1147
1342
  });
1148
1343
 
1149
1344
  case 23:
1150
- _context13.next = 26;
1345
+ _context16.next = 26;
1151
1346
  break;
1152
1347
 
1153
1348
  case 25:
@@ -1189,9 +1384,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
1189
1384
  }
1190
1385
 
1191
1386
  if (attributeFilters) {
1192
- attributeFilters.map(function (_ref13) {
1193
- var name = _ref13.name,
1194
- value = _ref13.value;
1387
+ attributeFilters.map(function (_ref15) {
1388
+ var name = _ref15.name,
1389
+ value = _ref15.value;
1195
1390
 
1196
1391
  if (!name || !value) {
1197
1392
  return;
@@ -1209,8 +1404,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
1209
1404
  filters.push("created:gt:".concat((Date.now() / 1000 - lastNDays * 24 * 60 * 60).toFixed(0)));
1210
1405
  }
1211
1406
 
1212
- _context13.t0 = mode;
1213
- _context13.next = _context13.t0 === "owned" ? 34 : _context13.t0 === "listings" ? 37 : _context13.t0 === "sales" ? 39 : _context13.t0 === "listing-stats" ? 42 : _context13.t0 === "sales-stats" ? 44 : 46;
1407
+ _context16.t0 = mode;
1408
+ _context16.next = _context16.t0 === "owned" ? 34 : _context16.t0 === "listings" ? 37 : _context16.t0 === "transfers" ? 39 : _context16.t0 === "sales" ? 41 : _context16.t0 === "listing-stats" ? 44 : _context16.t0 === "sales-stats" ? 46 : 48;
1214
1409
  break;
1215
1410
 
1216
1411
  case 34:
@@ -1220,48 +1415,52 @@ var ElvWalletClient = /*#__PURE__*/function () {
1220
1415
  path = UrlJoin("as", "wlt", "nfts", marketplaceInfo.tenantId);
1221
1416
  }
1222
1417
 
1223
- return _context13.abrupt("break", 46);
1418
+ return _context16.abrupt("break", 48);
1224
1419
 
1225
1420
  case 37:
1226
1421
  path = UrlJoin("as", "mkt", "f");
1227
- return _context13.abrupt("break", 46);
1422
+ return _context16.abrupt("break", 48);
1228
1423
 
1229
1424
  case 39:
1425
+ path = UrlJoin("as", "mkt", "hst", "f");
1426
+ return _context16.abrupt("break", 48);
1427
+
1428
+ case 41:
1230
1429
  path = UrlJoin("as", "mkt", "hst", "f");
1231
1430
  filters.push("action:eq:SOLD");
1232
- return _context13.abrupt("break", 46);
1431
+ return _context16.abrupt("break", 48);
1233
1432
 
1234
- case 42:
1433
+ case 44:
1235
1434
  path = UrlJoin("as", "mkt", "stats", "listed");
1236
- return _context13.abrupt("break", 46);
1435
+ return _context16.abrupt("break", 48);
1237
1436
 
1238
- case 44:
1437
+ case 46:
1239
1438
  path = UrlJoin("as", "mkt", "stats", "sold");
1240
- return _context13.abrupt("break", 46);
1439
+ return _context16.abrupt("break", 48);
1241
1440
 
1242
- case 46:
1441
+ case 48:
1243
1442
  if (filters.length > 0) {
1244
1443
  params.filter = filters;
1245
1444
  }
1246
1445
 
1247
1446
  if (!mode.includes("stats")) {
1248
- _context13.next = 51;
1447
+ _context16.next = 53;
1249
1448
  break;
1250
1449
  }
1251
1450
 
1252
- _context13.next = 50;
1451
+ _context16.next = 52;
1253
1452
  return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
1254
1453
  path: path,
1255
1454
  method: "GET",
1256
1455
  queryParams: params
1257
1456
  }));
1258
1457
 
1259
- case 50:
1260
- return _context13.abrupt("return", _context13.sent);
1458
+ case 52:
1459
+ return _context16.abrupt("return", _context16.sent);
1261
1460
 
1262
- case 51:
1263
- _context13.t2 = Utils;
1264
- _context13.next = 54;
1461
+ case 53:
1462
+ _context16.t2 = Utils;
1463
+ _context16.next = 56;
1265
1464
  return this.client.authClient.MakeAuthServiceRequest({
1266
1465
  path: path,
1267
1466
  method: "GET",
@@ -1271,26 +1470,26 @@ var ElvWalletClient = /*#__PURE__*/function () {
1271
1470
  } : {}
1272
1471
  });
1273
1472
 
1274
- case 54:
1275
- _context13.t3 = _context13.sent;
1276
- _context13.next = 57;
1277
- return _context13.t2.ResponseToJson.call(_context13.t2, _context13.t3);
1473
+ case 56:
1474
+ _context16.t3 = _context16.sent;
1475
+ _context16.next = 59;
1476
+ return _context16.t2.ResponseToJson.call(_context16.t2, _context16.t3);
1278
1477
 
1279
- case 57:
1280
- _context13.t1 = _context13.sent;
1478
+ case 59:
1479
+ _context16.t1 = _context16.sent;
1281
1480
 
1282
- if (_context13.t1) {
1283
- _context13.next = 60;
1481
+ if (_context16.t1) {
1482
+ _context16.next = 62;
1284
1483
  break;
1285
1484
  }
1286
1485
 
1287
- _context13.t1 = [];
1486
+ _context16.t1 = [];
1288
1487
 
1289
- case 60:
1290
- _ref14 = _context13.t1;
1291
- contents = _ref14.contents;
1292
- paging = _ref14.paging;
1293
- return _context13.abrupt("return", {
1488
+ case 62:
1489
+ _ref16 = _context16.t1;
1490
+ contents = _ref16.contents;
1491
+ paging = _ref16.paging;
1492
+ return _context16.abrupt("return", {
1294
1493
  paging: {
1295
1494
  start: params.start,
1296
1495
  limit: params.limit,
@@ -1302,16 +1501,16 @@ var ElvWalletClient = /*#__PURE__*/function () {
1302
1501
  })
1303
1502
  });
1304
1503
 
1305
- case 66:
1306
- _context13.prev = 66;
1307
- _context13.t4 = _context13["catch"](11);
1504
+ case 68:
1505
+ _context16.prev = 68;
1506
+ _context16.t4 = _context16["catch"](11);
1308
1507
 
1309
- if (!(_context13.t4.status && _context13.t4.status.toString() === "404")) {
1310
- _context13.next = 70;
1508
+ if (!(_context16.t4.status && _context16.t4.status.toString() === "404")) {
1509
+ _context16.next = 72;
1311
1510
  break;
1312
1511
  }
1313
1512
 
1314
- return _context13.abrupt("return", {
1513
+ return _context16.abrupt("return", {
1315
1514
  paging: {
1316
1515
  start: params.start,
1317
1516
  limit: params.limit,
@@ -1321,15 +1520,15 @@ var ElvWalletClient = /*#__PURE__*/function () {
1321
1520
  results: []
1322
1521
  });
1323
1522
 
1324
- case 70:
1325
- throw _context13.t4;
1523
+ case 72:
1524
+ throw _context16.t4;
1326
1525
 
1327
- case 71:
1526
+ case 73:
1328
1527
  case "end":
1329
- return _context13.stop();
1528
+ return _context16.stop();
1330
1529
  }
1331
1530
  }
1332
- }, _callee13, this, [[11, 66]]);
1531
+ }, _callee16, this, [[11, 68]]);
1333
1532
  }));
1334
1533
 
1335
1534
  function FilteredQuery() {
@@ -1341,31 +1540,31 @@ var ElvWalletClient = /*#__PURE__*/function () {
1341
1540
  }, {
1342
1541
  key: "MintingStatus",
1343
1542
  value: function () {
1344
- var _MintingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref15) {
1543
+ var _MintingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref17) {
1345
1544
  var marketplaceParams, tenantId, marketplaceInfo, response;
1346
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1545
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1347
1546
  while (1) {
1348
- switch (_context14.prev = _context14.next) {
1547
+ switch (_context17.prev = _context17.next) {
1349
1548
  case 0:
1350
- marketplaceParams = _ref15.marketplaceParams, tenantId = _ref15.tenantId;
1549
+ marketplaceParams = _ref17.marketplaceParams, tenantId = _ref17.tenantId;
1351
1550
 
1352
1551
  if (tenantId) {
1353
- _context14.next = 6;
1552
+ _context17.next = 6;
1354
1553
  break;
1355
1554
  }
1356
1555
 
1357
- _context14.next = 4;
1556
+ _context17.next = 4;
1358
1557
  return this.MarketplaceInfo({
1359
1558
  marketplaceParams: marketplaceParams || this.selectedMarketplaceInfo
1360
1559
  });
1361
1560
 
1362
1561
  case 4:
1363
- marketplaceInfo = _context14.sent;
1562
+ marketplaceInfo = _context17.sent;
1364
1563
  tenantId = marketplaceInfo.tenantId;
1365
1564
 
1366
1565
  case 6:
1367
- _context14.prev = 6;
1368
- _context14.next = 9;
1566
+ _context17.prev = 6;
1567
+ _context17.next = 9;
1369
1568
  return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
1370
1569
  path: UrlJoin("as", "wlt", "status", "act", tenantId),
1371
1570
  method: "GET",
@@ -1375,8 +1574,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
1375
1574
  }));
1376
1575
 
1377
1576
  case 9:
1378
- response = _context14.sent;
1379
- return _context14.abrupt("return", response.map(function (status) {
1577
+ response = _context17.sent;
1578
+ return _context17.abrupt("return", response.map(function (status) {
1380
1579
  var _status$op$split = status.op.split(":"),
1381
1580
  _status$op$split2 = _slicedToArray(_status$op$split, 3),
1382
1581
  op = _status$op$split2[0],
@@ -1420,21 +1619,21 @@ var ElvWalletClient = /*#__PURE__*/function () {
1420
1619
  }));
1421
1620
 
1422
1621
  case 13:
1423
- _context14.prev = 13;
1424
- _context14.t0 = _context14["catch"](6);
1622
+ _context17.prev = 13;
1623
+ _context17.t0 = _context17["catch"](6);
1425
1624
  this.Log("Failed to retrieve minting status", true);
1426
- this.Log(_context14.t0);
1427
- return _context14.abrupt("return", []);
1625
+ this.Log(_context17.t0);
1626
+ return _context17.abrupt("return", []);
1428
1627
 
1429
1628
  case 18:
1430
1629
  case "end":
1431
- return _context14.stop();
1630
+ return _context17.stop();
1432
1631
  }
1433
1632
  }
1434
- }, _callee14, this, [[6, 13]]);
1633
+ }, _callee17, this, [[6, 13]]);
1435
1634
  }));
1436
1635
 
1437
- function MintingStatus(_x15) {
1636
+ function MintingStatus(_x20) {
1438
1637
  return _MintingStatus.apply(this, arguments);
1439
1638
  }
1440
1639
 
@@ -1443,18 +1642,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
1443
1642
  }], [{
1444
1643
  key: "Initialize",
1445
1644
  value: function () {
1446
- var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref16) {
1447
- var _ref16$network, network, _ref16$mode, mode, marketplaceParams, _ref16$storeAuthToken, storeAuthToken, _ref17, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, client, walletClient, url, savedToken;
1645
+ var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
1646
+ var _ref18$network, network, _ref18$mode, mode, marketplaceParams, _ref18$storeAuthToken, storeAuthToken, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, client, walletClient, url, savedToken;
1448
1647
 
1449
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1648
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1450
1649
  while (1) {
1451
- switch (_context15.prev = _context15.next) {
1650
+ switch (_context18.prev = _context18.next) {
1452
1651
  case 0:
1453
- _ref16$network = _ref16.network, network = _ref16$network === void 0 ? "main" : _ref16$network, _ref16$mode = _ref16.mode, mode = _ref16$mode === void 0 ? "production" : _ref16$mode, marketplaceParams = _ref16.marketplaceParams, _ref16$storeAuthToken = _ref16.storeAuthToken, storeAuthToken = _ref16$storeAuthToken === void 0 ? true : _ref16$storeAuthToken;
1454
- _ref17 = marketplaceParams || {}, tenantSlug = _ref17.tenantSlug, marketplaceSlug = _ref17.marketplaceSlug, marketplaceId = _ref17.marketplaceId, marketplaceHash = _ref17.marketplaceHash;
1652
+ _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;
1653
+ _ref19 = marketplaceParams || {}, tenantSlug = _ref19.tenantSlug, marketplaceSlug = _ref19.marketplaceSlug, marketplaceId = _ref19.marketplaceId, marketplaceHash = _ref19.marketplaceHash;
1455
1654
 
1456
1655
  if (Configuration[network]) {
1457
- _context15.next = 6;
1656
+ _context18.next = 6;
1458
1657
  break;
1459
1658
  }
1460
1659
 
@@ -1462,21 +1661,21 @@ var ElvWalletClient = /*#__PURE__*/function () {
1462
1661
 
1463
1662
  case 6:
1464
1663
  if (Configuration[network][mode]) {
1465
- _context15.next = 8;
1664
+ _context18.next = 8;
1466
1665
  break;
1467
1666
  }
1468
1667
 
1469
1668
  throw Error("ElvWalletClient: Invalid mode ".concat(mode));
1470
1669
 
1471
1670
  case 8:
1472
- _context15.next = 10;
1671
+ _context18.next = 10;
1473
1672
  return ElvClient.FromNetworkName({
1474
1673
  networkName: network,
1475
1674
  assumeV3: true
1476
1675
  });
1477
1676
 
1478
1677
  case 10:
1479
- client = _context15.sent;
1678
+ client = _context18.sent;
1480
1679
  walletClient = new ElvWalletClient({
1481
1680
  client: client,
1482
1681
  network: network,
@@ -1491,18 +1690,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
1491
1690
  });
1492
1691
 
1493
1692
  if (!(window && window.location && window.location.href)) {
1494
- _context15.next = 31;
1693
+ _context18.next = 31;
1495
1694
  break;
1496
1695
  }
1497
1696
 
1498
1697
  url = new URL(window.location.href);
1499
1698
 
1500
1699
  if (!url.searchParams.get("elvToken")) {
1501
- _context15.next = 21;
1700
+ _context18.next = 21;
1502
1701
  break;
1503
1702
  }
1504
1703
 
1505
- _context15.next = 17;
1704
+ _context18.next = 17;
1506
1705
  return walletClient.Authenticate({
1507
1706
  token: url.searchParams.get("elvToken")
1508
1707
  });
@@ -1510,53 +1709,53 @@ var ElvWalletClient = /*#__PURE__*/function () {
1510
1709
  case 17:
1511
1710
  url.searchParams["delete"]("elvToken");
1512
1711
  window.history.replaceState("", "", url);
1513
- _context15.next = 31;
1712
+ _context18.next = 31;
1514
1713
  break;
1515
1714
 
1516
1715
  case 21:
1517
1716
  if (!(storeAuthToken && typeof localStorage !== "undefined")) {
1518
- _context15.next = 31;
1717
+ _context18.next = 31;
1519
1718
  break;
1520
1719
  }
1521
1720
 
1522
- _context15.prev = 22;
1721
+ _context18.prev = 22;
1523
1722
  // Load saved auth token
1524
1723
  savedToken = localStorage.getItem("__elv-token-".concat(network));
1525
1724
 
1526
1725
  if (!savedToken) {
1527
- _context15.next = 27;
1726
+ _context18.next = 27;
1528
1727
  break;
1529
1728
  }
1530
1729
 
1531
- _context15.next = 27;
1730
+ _context18.next = 27;
1532
1731
  return walletClient.Authenticate({
1533
1732
  token: savedToken
1534
1733
  });
1535
1734
 
1536
1735
  case 27:
1537
- _context15.next = 31;
1736
+ _context18.next = 31;
1538
1737
  break;
1539
1738
 
1540
1739
  case 29:
1541
- _context15.prev = 29;
1542
- _context15.t0 = _context15["catch"](22);
1740
+ _context18.prev = 29;
1741
+ _context18.t0 = _context18["catch"](22);
1543
1742
 
1544
1743
  case 31:
1545
- _context15.next = 33;
1744
+ _context18.next = 33;
1546
1745
  return walletClient.LoadAvailableMarketplaces();
1547
1746
 
1548
1747
  case 33:
1549
- return _context15.abrupt("return", walletClient);
1748
+ return _context18.abrupt("return", walletClient);
1550
1749
 
1551
1750
  case 34:
1552
1751
  case "end":
1553
- return _context15.stop();
1752
+ return _context18.stop();
1554
1753
  }
1555
1754
  }
1556
- }, _callee15, null, [[22, 29]]);
1755
+ }, _callee18, null, [[22, 29]]);
1557
1756
  }));
1558
1757
 
1559
- function Initialize(_x16) {
1758
+ function Initialize(_x21) {
1560
1759
  return _Initialize.apply(this, arguments);
1561
1760
  }
1562
1761