@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.
- package/dist/ElvClient-min.js +8 -8
- package/dist/ElvClient-node-min.js +2 -2
- 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 +504 -305
- 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 +99 -6
|
@@ -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,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
|
|
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
|
|
|
349
530
|
throw Error("ElvWalletClient: Provided authorization token has expired");
|
|
350
531
|
|
|
351
532
|
case 10:
|
|
352
|
-
|
|
353
|
-
|
|
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
|
-
|
|
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
|
|
551
|
+
return _context7.stop();
|
|
367
552
|
}
|
|
368
553
|
}
|
|
369
|
-
},
|
|
554
|
+
}, _callee7, this, [[1, 5]]);
|
|
370
555
|
}));
|
|
371
556
|
|
|
372
|
-
function Authenticate(
|
|
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
|
|
402
|
-
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;
|
|
403
588
|
|
|
404
|
-
return _regeneratorRuntime.wrap(function
|
|
589
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
405
590
|
while (1) {
|
|
406
|
-
switch (
|
|
591
|
+
switch (_context8.prev = _context8.next) {
|
|
407
592
|
case 0:
|
|
408
|
-
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;
|
|
409
594
|
|
|
410
595
|
if (!(!tenantId && this.selectedMarketplaceInfo)) {
|
|
411
|
-
|
|
596
|
+
_context8.next = 5;
|
|
412
597
|
break;
|
|
413
598
|
}
|
|
414
599
|
|
|
415
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
625
|
+
fabricToken = _context8.sent;
|
|
441
626
|
address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
|
|
442
627
|
|
|
443
628
|
if (email) {
|
|
444
|
-
|
|
629
|
+
_context8.next = 21;
|
|
445
630
|
break;
|
|
446
631
|
}
|
|
447
632
|
|
|
448
|
-
|
|
633
|
+
_context8.prev = 13;
|
|
449
634
|
decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
|
|
450
635
|
email = decodedToken.email;
|
|
451
|
-
|
|
636
|
+
_context8.next = 21;
|
|
452
637
|
break;
|
|
453
638
|
|
|
454
639
|
case 18:
|
|
455
|
-
|
|
456
|
-
|
|
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
|
|
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
|
|
672
|
+
return _context8.stop();
|
|
488
673
|
}
|
|
489
674
|
}
|
|
490
|
-
},
|
|
675
|
+
}, _callee8, this, [[13, 18]]);
|
|
491
676
|
}));
|
|
492
677
|
|
|
493
|
-
function AuthenticateOAuth(
|
|
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
|
|
701
|
+
var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref8) {
|
|
517
702
|
var _this2 = this;
|
|
518
703
|
|
|
519
|
-
var address,
|
|
704
|
+
var address, _ref8$tokenDuration, tokenDuration, _ref8$walletName, walletName, Sign, expiresAt, fabricToken;
|
|
520
705
|
|
|
521
|
-
return _regeneratorRuntime.wrap(function
|
|
706
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
522
707
|
while (1) {
|
|
523
|
-
switch (
|
|
708
|
+
switch (_context10.prev = _context10.next) {
|
|
524
709
|
case 0:
|
|
525
|
-
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;
|
|
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
|
|
536
|
-
return _regeneratorRuntime.wrap(function
|
|
720
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(message) {
|
|
721
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
537
722
|
while (1) {
|
|
538
|
-
switch (
|
|
723
|
+
switch (_context9.prev = _context9.next) {
|
|
539
724
|
case 0:
|
|
540
|
-
return
|
|
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
|
|
732
|
+
return _context9.stop();
|
|
548
733
|
}
|
|
549
734
|
}
|
|
550
|
-
},
|
|
735
|
+
}, _callee9);
|
|
551
736
|
}));
|
|
552
737
|
|
|
553
|
-
return function Sign(
|
|
554
|
-
return
|
|
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
|
-
|
|
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 =
|
|
570
|
-
return
|
|
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
|
|
765
|
+
return _context10.stop();
|
|
581
766
|
}
|
|
582
767
|
}
|
|
583
|
-
},
|
|
768
|
+
}, _callee10, this);
|
|
584
769
|
}));
|
|
585
770
|
|
|
586
|
-
function AuthenticateExternalWallet(
|
|
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(
|
|
621
|
-
var clusterToken =
|
|
622
|
-
fabricToken =
|
|
623
|
-
tenantId =
|
|
624
|
-
address =
|
|
625
|
-
email =
|
|
626
|
-
expiresAt =
|
|
627
|
-
walletType =
|
|
628
|
-
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
|
|
660
|
-
var message, address,
|
|
661
|
-
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) {
|
|
662
847
|
while (1) {
|
|
663
|
-
switch (
|
|
848
|
+
switch (_context11.prev = _context11.next) {
|
|
664
849
|
case 0:
|
|
665
|
-
message =
|
|
850
|
+
message = _ref11.message, address = _ref11.address;
|
|
666
851
|
|
|
667
852
|
if (window.ethereum) {
|
|
668
|
-
|
|
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
|
-
|
|
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
|
|
681
|
-
|
|
682
|
-
|
|
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,
|
|
880
|
+
params: [message, address, ""]
|
|
686
881
|
});
|
|
687
882
|
|
|
688
|
-
case
|
|
689
|
-
return
|
|
883
|
+
case 11:
|
|
884
|
+
return _context11.abrupt("return", _context11.sent);
|
|
690
885
|
|
|
691
|
-
case
|
|
886
|
+
case 12:
|
|
692
887
|
case "end":
|
|
693
|
-
return
|
|
888
|
+
return _context11.stop();
|
|
694
889
|
}
|
|
695
890
|
}
|
|
696
|
-
},
|
|
891
|
+
}, _callee11, this);
|
|
697
892
|
}));
|
|
698
893
|
|
|
699
|
-
function SignMetamask(
|
|
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
|
|
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
|
-
|
|
719
|
-
return _regeneratorRuntime.wrap(function
|
|
913
|
+
_args12 = arguments;
|
|
914
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
720
915
|
while (1) {
|
|
721
|
-
switch (
|
|
916
|
+
switch (_context12.prev = _context12.next) {
|
|
722
917
|
case 0:
|
|
723
|
-
forceReload =
|
|
918
|
+
forceReload = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : false;
|
|
724
919
|
|
|
725
920
|
if (!(!forceReload && Object.keys(this.availableMarketplaces) > 0)) {
|
|
726
|
-
|
|
921
|
+
_context12.next = 3;
|
|
727
922
|
break;
|
|
728
923
|
}
|
|
729
924
|
|
|
730
|
-
return
|
|
925
|
+
return _context12.abrupt("return");
|
|
731
926
|
|
|
732
927
|
case 3:
|
|
733
|
-
|
|
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 =
|
|
740
|
-
|
|
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 =
|
|
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
|
|
999
|
+
return _context12.stop();
|
|
805
1000
|
}
|
|
806
1001
|
}
|
|
807
|
-
},
|
|
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
|
|
1015
|
+
var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref12) {
|
|
821
1016
|
var tenantSlug, marketplaceSlug, mainSiteHash, marketplaceLink;
|
|
822
|
-
return _regeneratorRuntime.wrap(function
|
|
1017
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
823
1018
|
while (1) {
|
|
824
|
-
switch (
|
|
1019
|
+
switch (_context13.prev = _context13.next) {
|
|
825
1020
|
case 0:
|
|
826
|
-
tenantSlug =
|
|
827
|
-
|
|
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 =
|
|
834
|
-
|
|
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 =
|
|
843
|
-
return
|
|
1037
|
+
marketplaceLink = _context13.sent;
|
|
1038
|
+
return _context13.abrupt("return", LinkTargetHash(marketplaceLink));
|
|
844
1039
|
|
|
845
1040
|
case 8:
|
|
846
1041
|
case "end":
|
|
847
|
-
return
|
|
1042
|
+
return _context13.stop();
|
|
848
1043
|
}
|
|
849
1044
|
}
|
|
850
|
-
},
|
|
1045
|
+
}, _callee13, this);
|
|
851
1046
|
}));
|
|
852
1047
|
|
|
853
|
-
function LatestMarketplaceHash(
|
|
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
|
|
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
|
|
1061
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
867
1062
|
while (1) {
|
|
868
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
1083
|
+
_context15.next = 19;
|
|
889
1084
|
break;
|
|
890
1085
|
}
|
|
891
1086
|
|
|
892
|
-
|
|
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 =
|
|
906
|
-
|
|
1100
|
+
marketplace = _context15.sent;
|
|
1101
|
+
_context15.next = 12;
|
|
907
1102
|
return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
|
|
908
|
-
var
|
|
909
|
-
return _regeneratorRuntime.wrap(function
|
|
1103
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(item, index) {
|
|
1104
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
910
1105
|
while (1) {
|
|
911
|
-
switch (
|
|
1106
|
+
switch (_context14.prev = _context14.next) {
|
|
912
1107
|
case 0:
|
|
913
1108
|
if (!item.requires_permissions) {
|
|
914
|
-
|
|
1109
|
+
_context14.next = 14;
|
|
915
1110
|
break;
|
|
916
1111
|
}
|
|
917
1112
|
|
|
918
1113
|
if (_this4.loggedIn) {
|
|
919
|
-
|
|
1114
|
+
_context14.next = 5;
|
|
920
1115
|
break;
|
|
921
1116
|
}
|
|
922
1117
|
|
|
923
1118
|
item.authorized = false;
|
|
924
|
-
|
|
1119
|
+
_context14.next = 14;
|
|
925
1120
|
break;
|
|
926
1121
|
|
|
927
1122
|
case 5:
|
|
928
|
-
|
|
929
|
-
|
|
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
|
-
|
|
1132
|
+
_context14.next = 14;
|
|
938
1133
|
break;
|
|
939
1134
|
|
|
940
1135
|
case 11:
|
|
941
|
-
|
|
942
|
-
|
|
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
|
|
1143
|
+
return _context14.abrupt("return", item);
|
|
949
1144
|
|
|
950
1145
|
case 17:
|
|
951
1146
|
case "end":
|
|
952
|
-
return
|
|
1147
|
+
return _context14.stop();
|
|
953
1148
|
}
|
|
954
1149
|
}
|
|
955
|
-
},
|
|
1150
|
+
}, _callee14, null, [[5, 11]]);
|
|
956
1151
|
}));
|
|
957
1152
|
|
|
958
|
-
return function (
|
|
959
|
-
return
|
|
1153
|
+
return function (_x18, _x19) {
|
|
1154
|
+
return _ref13.apply(this, arguments);
|
|
960
1155
|
};
|
|
961
1156
|
}()));
|
|
962
1157
|
|
|
963
1158
|
case 12:
|
|
964
|
-
marketplace.items =
|
|
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
|
|
1193
|
+
return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
|
|
999
1194
|
|
|
1000
1195
|
case 20:
|
|
1001
1196
|
case "end":
|
|
1002
|
-
return
|
|
1197
|
+
return _context15.stop();
|
|
1003
1198
|
}
|
|
1004
1199
|
}
|
|
1005
|
-
},
|
|
1200
|
+
}, _callee15, this);
|
|
1006
1201
|
}));
|
|
1007
1202
|
|
|
1008
|
-
function LoadMarketplace(
|
|
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
|
|
1018
|
-
var
|
|
1019
|
-
|
|
1212
|
+
var _FilteredQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
1213
|
+
var _ref14,
|
|
1214
|
+
_ref14$mode,
|
|
1020
1215
|
mode,
|
|
1021
|
-
|
|
1216
|
+
_ref14$sortBy,
|
|
1022
1217
|
sortBy,
|
|
1023
|
-
|
|
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
|
-
|
|
1228
|
+
_ref14$collectionInde,
|
|
1034
1229
|
collectionIndex,
|
|
1035
1230
|
sellerAddress,
|
|
1036
|
-
|
|
1231
|
+
_ref14$lastNDays,
|
|
1037
1232
|
lastNDays,
|
|
1038
|
-
|
|
1233
|
+
_ref14$start,
|
|
1039
1234
|
start,
|
|
1040
|
-
|
|
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
|
-
|
|
1243
|
+
_ref16,
|
|
1049
1244
|
contents,
|
|
1050
1245
|
paging,
|
|
1051
|
-
|
|
1246
|
+
_args16 = arguments;
|
|
1052
1247
|
|
|
1053
|
-
return _regeneratorRuntime.wrap(function
|
|
1248
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1054
1249
|
while (1) {
|
|
1055
|
-
switch (
|
|
1250
|
+
switch (_context16.prev = _context16.next) {
|
|
1056
1251
|
case 0:
|
|
1057
|
-
|
|
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
|
-
|
|
1262
|
+
_context16.next = 11;
|
|
1068
1263
|
break;
|
|
1069
1264
|
}
|
|
1070
1265
|
|
|
1071
|
-
|
|
1266
|
+
_context16.next = 6;
|
|
1072
1267
|
return this.MarketplaceInfo({
|
|
1073
1268
|
marketplaceParams: marketplaceParams
|
|
1074
1269
|
});
|
|
1075
1270
|
|
|
1076
1271
|
case 6:
|
|
1077
|
-
marketplaceInfo =
|
|
1272
|
+
marketplaceInfo = _context16.sent;
|
|
1078
1273
|
|
|
1079
1274
|
if (!(collectionIndex >= 0)) {
|
|
1080
|
-
|
|
1275
|
+
_context16.next = 11;
|
|
1081
1276
|
break;
|
|
1082
1277
|
}
|
|
1083
1278
|
|
|
1084
|
-
|
|
1279
|
+
_context16.next = 10;
|
|
1085
1280
|
return this.Marketplace({
|
|
1086
1281
|
marketplaceParams: marketplaceParams
|
|
1087
1282
|
});
|
|
1088
1283
|
|
|
1089
1284
|
case 10:
|
|
1090
|
-
marketplace =
|
|
1285
|
+
marketplace = _context16.sent;
|
|
1091
1286
|
|
|
1092
1287
|
case 11:
|
|
1093
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1322
|
+
_context16.next = 23;
|
|
1128
1323
|
break;
|
|
1129
1324
|
}
|
|
1130
1325
|
|
|
1131
1326
|
if (!mode.includes("stats")) {
|
|
1132
|
-
|
|
1327
|
+
_context16.next = 22;
|
|
1133
1328
|
break;
|
|
1134
1329
|
}
|
|
1135
1330
|
|
|
1136
|
-
return
|
|
1331
|
+
return _context16.abrupt("return", {});
|
|
1137
1332
|
|
|
1138
1333
|
case 22:
|
|
1139
|
-
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
|
-
|
|
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 (
|
|
1193
|
-
var name =
|
|
1194
|
-
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
|
-
|
|
1213
|
-
|
|
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
|
|
1418
|
+
return _context16.abrupt("break", 48);
|
|
1224
1419
|
|
|
1225
1420
|
case 37:
|
|
1226
1421
|
path = UrlJoin("as", "mkt", "f");
|
|
1227
|
-
return
|
|
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
|
|
1431
|
+
return _context16.abrupt("break", 48);
|
|
1233
1432
|
|
|
1234
|
-
case
|
|
1433
|
+
case 44:
|
|
1235
1434
|
path = UrlJoin("as", "mkt", "stats", "listed");
|
|
1236
|
-
return
|
|
1435
|
+
return _context16.abrupt("break", 48);
|
|
1237
1436
|
|
|
1238
|
-
case
|
|
1437
|
+
case 46:
|
|
1239
1438
|
path = UrlJoin("as", "mkt", "stats", "sold");
|
|
1240
|
-
return
|
|
1439
|
+
return _context16.abrupt("break", 48);
|
|
1241
1440
|
|
|
1242
|
-
case
|
|
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
|
-
|
|
1447
|
+
_context16.next = 53;
|
|
1249
1448
|
break;
|
|
1250
1449
|
}
|
|
1251
1450
|
|
|
1252
|
-
|
|
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
|
|
1260
|
-
return
|
|
1458
|
+
case 52:
|
|
1459
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1261
1460
|
|
|
1262
|
-
case
|
|
1263
|
-
|
|
1264
|
-
|
|
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
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
return
|
|
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
|
|
1280
|
-
|
|
1478
|
+
case 59:
|
|
1479
|
+
_context16.t1 = _context16.sent;
|
|
1281
1480
|
|
|
1282
|
-
if (
|
|
1283
|
-
|
|
1481
|
+
if (_context16.t1) {
|
|
1482
|
+
_context16.next = 62;
|
|
1284
1483
|
break;
|
|
1285
1484
|
}
|
|
1286
1485
|
|
|
1287
|
-
|
|
1486
|
+
_context16.t1 = [];
|
|
1288
1487
|
|
|
1289
|
-
case
|
|
1290
|
-
|
|
1291
|
-
contents =
|
|
1292
|
-
paging =
|
|
1293
|
-
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
|
|
1306
|
-
|
|
1307
|
-
|
|
1504
|
+
case 68:
|
|
1505
|
+
_context16.prev = 68;
|
|
1506
|
+
_context16.t4 = _context16["catch"](11);
|
|
1308
1507
|
|
|
1309
|
-
if (!(
|
|
1310
|
-
|
|
1508
|
+
if (!(_context16.t4.status && _context16.t4.status.toString() === "404")) {
|
|
1509
|
+
_context16.next = 72;
|
|
1311
1510
|
break;
|
|
1312
1511
|
}
|
|
1313
1512
|
|
|
1314
|
-
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
|
|
1325
|
-
throw
|
|
1523
|
+
case 72:
|
|
1524
|
+
throw _context16.t4;
|
|
1326
1525
|
|
|
1327
|
-
case
|
|
1526
|
+
case 73:
|
|
1328
1527
|
case "end":
|
|
1329
|
-
return
|
|
1528
|
+
return _context16.stop();
|
|
1330
1529
|
}
|
|
1331
1530
|
}
|
|
1332
|
-
},
|
|
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
|
|
1543
|
+
var _MintingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref17) {
|
|
1345
1544
|
var marketplaceParams, tenantId, marketplaceInfo, response;
|
|
1346
|
-
return _regeneratorRuntime.wrap(function
|
|
1545
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1347
1546
|
while (1) {
|
|
1348
|
-
switch (
|
|
1547
|
+
switch (_context17.prev = _context17.next) {
|
|
1349
1548
|
case 0:
|
|
1350
|
-
marketplaceParams =
|
|
1549
|
+
marketplaceParams = _ref17.marketplaceParams, tenantId = _ref17.tenantId;
|
|
1351
1550
|
|
|
1352
1551
|
if (tenantId) {
|
|
1353
|
-
|
|
1552
|
+
_context17.next = 6;
|
|
1354
1553
|
break;
|
|
1355
1554
|
}
|
|
1356
1555
|
|
|
1357
|
-
|
|
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 =
|
|
1562
|
+
marketplaceInfo = _context17.sent;
|
|
1364
1563
|
tenantId = marketplaceInfo.tenantId;
|
|
1365
1564
|
|
|
1366
1565
|
case 6:
|
|
1367
|
-
|
|
1368
|
-
|
|
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 =
|
|
1379
|
-
return
|
|
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
|
-
|
|
1424
|
-
|
|
1622
|
+
_context17.prev = 13;
|
|
1623
|
+
_context17.t0 = _context17["catch"](6);
|
|
1425
1624
|
this.Log("Failed to retrieve minting status", true);
|
|
1426
|
-
this.Log(
|
|
1427
|
-
return
|
|
1625
|
+
this.Log(_context17.t0);
|
|
1626
|
+
return _context17.abrupt("return", []);
|
|
1428
1627
|
|
|
1429
1628
|
case 18:
|
|
1430
1629
|
case "end":
|
|
1431
|
-
return
|
|
1630
|
+
return _context17.stop();
|
|
1432
1631
|
}
|
|
1433
1632
|
}
|
|
1434
|
-
},
|
|
1633
|
+
}, _callee17, this, [[6, 13]]);
|
|
1435
1634
|
}));
|
|
1436
1635
|
|
|
1437
|
-
function MintingStatus(
|
|
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
|
|
1447
|
-
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;
|
|
1448
1647
|
|
|
1449
|
-
return _regeneratorRuntime.wrap(function
|
|
1648
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1450
1649
|
while (1) {
|
|
1451
|
-
switch (
|
|
1650
|
+
switch (_context18.prev = _context18.next) {
|
|
1452
1651
|
case 0:
|
|
1453
|
-
|
|
1454
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
1700
|
+
_context18.next = 21;
|
|
1502
1701
|
break;
|
|
1503
1702
|
}
|
|
1504
1703
|
|
|
1505
|
-
|
|
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
|
-
|
|
1712
|
+
_context18.next = 31;
|
|
1514
1713
|
break;
|
|
1515
1714
|
|
|
1516
1715
|
case 21:
|
|
1517
1716
|
if (!(storeAuthToken && typeof localStorage !== "undefined")) {
|
|
1518
|
-
|
|
1717
|
+
_context18.next = 31;
|
|
1519
1718
|
break;
|
|
1520
1719
|
}
|
|
1521
1720
|
|
|
1522
|
-
|
|
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
|
-
|
|
1726
|
+
_context18.next = 27;
|
|
1528
1727
|
break;
|
|
1529
1728
|
}
|
|
1530
1729
|
|
|
1531
|
-
|
|
1730
|
+
_context18.next = 27;
|
|
1532
1731
|
return walletClient.Authenticate({
|
|
1533
1732
|
token: savedToken
|
|
1534
1733
|
});
|
|
1535
1734
|
|
|
1536
1735
|
case 27:
|
|
1537
|
-
|
|
1736
|
+
_context18.next = 31;
|
|
1538
1737
|
break;
|
|
1539
1738
|
|
|
1540
1739
|
case 29:
|
|
1541
|
-
|
|
1542
|
-
|
|
1740
|
+
_context18.prev = 29;
|
|
1741
|
+
_context18.t0 = _context18["catch"](22);
|
|
1543
1742
|
|
|
1544
1743
|
case 31:
|
|
1545
|
-
|
|
1744
|
+
_context18.next = 33;
|
|
1546
1745
|
return walletClient.LoadAvailableMarketplaces();
|
|
1547
1746
|
|
|
1548
1747
|
case 33:
|
|
1549
|
-
return
|
|
1748
|
+
return _context18.abrupt("return", walletClient);
|
|
1550
1749
|
|
|
1551
1750
|
case 34:
|
|
1552
1751
|
case "end":
|
|
1553
|
-
return
|
|
1752
|
+
return _context18.stop();
|
|
1554
1753
|
}
|
|
1555
1754
|
}
|
|
1556
|
-
},
|
|
1755
|
+
}, _callee18, null, [[22, 29]]);
|
|
1557
1756
|
}));
|
|
1558
1757
|
|
|
1559
|
-
function Initialize(
|
|
1758
|
+
function Initialize(_x21) {
|
|
1560
1759
|
return _Initialize.apply(this, arguments);
|
|
1561
1760
|
}
|
|
1562
1761
|
|