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