@eluvio/elv-client-js 4.0.5 → 4.0.7
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 +12 -11
- package/dist/ElvClient-node-min.js +12 -11
- package/dist/ElvFrameClient-min.js +12 -11
- package/dist/ElvPermissionsClient-min.js +10 -9
- package/dist/ElvWalletClient-min.js +12 -11
- package/dist/ElvWalletClient-node-min.js +11 -10
- package/dist/src/AuthorizationClient.js +1556 -2077
- package/dist/src/ContentObjectVerification.js +134 -185
- package/dist/src/Crypto.js +225 -322
- package/dist/src/ElvClient.js +823 -1117
- package/dist/src/ElvWallet.js +64 -106
- package/dist/src/EthClient.js +719 -974
- package/dist/src/FrameClient.js +222 -318
- package/dist/src/HttpClient.js +112 -154
- package/dist/src/Id.js +1 -6
- package/dist/src/LogMessage.js +4 -8
- package/dist/src/PermissionsClient.js +973 -1271
- package/dist/src/RemoteSigner.js +161 -232
- package/dist/src/UserProfileClient.js +781 -1038
- package/dist/src/Utils.js +160 -302
- package/dist/src/Validation.js +2 -17
- package/dist/src/client/ABRPublishing.js +772 -942
- package/dist/src/client/AccessGroups.js +849 -1095
- package/dist/src/client/ContentAccess.js +3263 -4132
- package/dist/src/client/ContentManagement.js +1811 -2283
- package/dist/src/client/Contracts.js +468 -614
- package/dist/src/client/Files.js +1505 -1845
- package/dist/src/client/NFT.js +94 -116
- package/dist/src/client/NTP.js +326 -425
- package/dist/src/index.js +2 -5
- package/dist/src/walletClient/ClientMethods.js +1348 -1735
- package/dist/src/walletClient/Configuration.js +4 -2
- package/dist/src/walletClient/Notifications.js +98 -127
- package/dist/src/walletClient/Profile.js +184 -246
- package/dist/src/walletClient/Utils.js +76 -122
- package/dist/src/walletClient/index.js +1168 -1493
- package/package.json +2 -2
- package/src/Crypto.js +1 -1
- package/src/ElvClient.js +1 -3
- package/src/Utils.js +1 -1
- package/testScripts/Test.js +0 -1
- package/utilities/NFTIngest.js +527 -0
- package/utilities/lib/concerns/LocalFile.js +2 -1
|
@@ -1,69 +1,50 @@
|
|
|
1
1
|
var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
|
|
2
|
-
|
|
3
2
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
4
|
-
|
|
5
3
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
6
|
-
|
|
7
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
8
|
-
|
|
9
5
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
10
|
-
|
|
11
6
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
12
|
-
|
|
13
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
14
|
-
|
|
15
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
|
|
17
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
|
|
19
10
|
var _require = require("../ElvClient"),
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
ElvClient = _require.ElvClient;
|
|
22
12
|
var Configuration = require("./Configuration");
|
|
23
|
-
|
|
24
13
|
var _require2 = require("./Utils"),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
LinkTargetHash = _require2.LinkTargetHash,
|
|
15
|
+
FormatNFT = _require2.FormatNFT,
|
|
16
|
+
ActionPopup = _require2.ActionPopup;
|
|
29
17
|
var HTTPClient = require("../HttpClient");
|
|
30
|
-
|
|
31
18
|
var UrlJoin = require("url-join");
|
|
32
|
-
|
|
33
19
|
var Utils = require("../Utils");
|
|
34
|
-
|
|
35
20
|
var Ethers = require("ethers");
|
|
36
|
-
|
|
37
21
|
var inBrowser = typeof window !== "undefined";
|
|
38
22
|
var embedded = inBrowser && window.top !== window.self;
|
|
39
23
|
var localStorageAvailable = false;
|
|
40
|
-
|
|
41
24
|
try {
|
|
42
25
|
typeof localStorage !== "undefined" && localStorage.getItem("test");
|
|
43
|
-
localStorageAvailable = true;
|
|
26
|
+
localStorageAvailable = true;
|
|
27
|
+
// eslint-disable-next-line no-empty
|
|
44
28
|
} catch (error) {}
|
|
29
|
+
|
|
45
30
|
/**
|
|
46
31
|
* Use the <a href="#.Initialize">Initialize</a> method to initialize a new client.
|
|
47
32
|
*
|
|
48
33
|
*
|
|
49
34
|
* See the Modules section on the sidebar for all client methods unrelated to login and authorization
|
|
50
35
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
36
|
var ElvWalletClient = /*#__PURE__*/function () {
|
|
54
37
|
"use strict";
|
|
55
38
|
|
|
56
39
|
function ElvWalletClient(_ref) {
|
|
57
40
|
var appId = _ref.appId,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
client = _ref.client,
|
|
42
|
+
network = _ref.network,
|
|
43
|
+
mode = _ref.mode,
|
|
44
|
+
marketplaceInfo = _ref.marketplaceInfo,
|
|
45
|
+
previewMarketplaceHash = _ref.previewMarketplaceHash,
|
|
46
|
+
storeAuthToken = _ref.storeAuthToken;
|
|
65
47
|
_classCallCheck(this, ElvWalletClient);
|
|
66
|
-
|
|
67
48
|
this.appId = appId;
|
|
68
49
|
this.client = client;
|
|
69
50
|
this.loggedIn = false;
|
|
@@ -84,19 +65,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
84
65
|
this.stateStoreUrls = Configuration[network].stateStoreUrls;
|
|
85
66
|
this.stateStoreClient = new HTTPClient({
|
|
86
67
|
uris: this.stateStoreUrls
|
|
87
|
-
});
|
|
68
|
+
});
|
|
88
69
|
|
|
70
|
+
// Caches
|
|
89
71
|
this.cachedMarketplaces = {};
|
|
90
72
|
this.cachedCSS = {};
|
|
91
73
|
this.utils = client.utils;
|
|
92
74
|
}
|
|
93
|
-
|
|
94
75
|
_createClass(ElvWalletClient, [{
|
|
95
76
|
key: "Log",
|
|
96
77
|
value: function Log(message) {
|
|
97
78
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
98
79
|
var errorObject = arguments.length > 2 ? arguments[2] : undefined;
|
|
99
|
-
|
|
100
80
|
if (error) {
|
|
101
81
|
// eslint-disable-next-line no-console
|
|
102
82
|
console.error("Eluvio Wallet Client:", message);
|
|
@@ -104,12 +84,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
104
84
|
// eslint-disable-next-line no-console
|
|
105
85
|
console.log("Eluvio Wallet Client:", message);
|
|
106
86
|
}
|
|
107
|
-
|
|
108
87
|
if (errorObject) {
|
|
109
88
|
// eslint-disable-next-line no-console
|
|
110
89
|
console.error(errorObject);
|
|
111
90
|
}
|
|
112
91
|
}
|
|
92
|
+
|
|
113
93
|
/**
|
|
114
94
|
* Initialize the wallet client.
|
|
115
95
|
*
|
|
@@ -127,11 +107,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
127
107
|
*
|
|
128
108
|
* @returns {Promise<ElvWalletClient>}
|
|
129
109
|
*/
|
|
130
|
-
|
|
131
110
|
}, {
|
|
132
111
|
key: "CanSign",
|
|
133
|
-
value:
|
|
134
|
-
/* Login and authorization */
|
|
112
|
+
value: /* Login and authorization */
|
|
135
113
|
|
|
136
114
|
/**
|
|
137
115
|
* Check if this client can sign without opening a popup.
|
|
@@ -145,9 +123,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
145
123
|
if (!this.loggedIn) {
|
|
146
124
|
return false;
|
|
147
125
|
}
|
|
148
|
-
|
|
149
126
|
return !!this.__authorization.clusterToken || inBrowser && !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
|
|
150
127
|
}
|
|
128
|
+
|
|
151
129
|
/**
|
|
152
130
|
* <b><i>Requires login</i></b>
|
|
153
131
|
*
|
|
@@ -165,169 +143,136 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
165
143
|
*
|
|
166
144
|
* @returns {Promise<string>} - The signature of the message
|
|
167
145
|
*/
|
|
168
|
-
|
|
169
146
|
}, {
|
|
170
147
|
key: "PersonalSign",
|
|
171
148
|
value: function () {
|
|
172
149
|
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
|
|
173
150
|
var message, parameters, url;
|
|
174
151
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
175
|
-
while (1) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}));
|
|
217
|
-
|
|
218
|
-
case 16:
|
|
219
|
-
throw Error("ElvWalletClient: Unable to sign");
|
|
220
|
-
|
|
221
|
-
case 17:
|
|
152
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
message = _ref2.message;
|
|
155
|
+
if (this.loggedIn) {
|
|
156
|
+
_context3.next = 3;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
throw Error("ElvWalletClient: Unable to perform signature - Not logged in");
|
|
160
|
+
case 3:
|
|
161
|
+
if (!this.CanSign()) {
|
|
162
|
+
_context3.next = 19;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
if (!this.__authorization.clusterToken) {
|
|
166
|
+
_context3.next = 12;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
// Custodial wallet sign
|
|
170
|
+
|
|
171
|
+
message = _typeof(message) === "object" ? JSON.stringify(message) : message;
|
|
172
|
+
message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
|
|
173
|
+
_context3.next = 9;
|
|
174
|
+
return this.client.authClient.Sign(message);
|
|
175
|
+
case 9:
|
|
176
|
+
return _context3.abrupt("return", _context3.sent);
|
|
177
|
+
case 12:
|
|
178
|
+
if (!(this.UserInfo().walletName.toLowerCase() === "metamask")) {
|
|
179
|
+
_context3.next = 16;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
return _context3.abrupt("return", this.SignMetamask({
|
|
183
|
+
message: message,
|
|
184
|
+
address: this.UserAddress()
|
|
185
|
+
}));
|
|
186
|
+
case 16:
|
|
187
|
+
throw Error("ElvWalletClient: Unable to sign");
|
|
188
|
+
case 17:
|
|
189
|
+
_context3.next = 21;
|
|
190
|
+
break;
|
|
191
|
+
case 19:
|
|
192
|
+
if (inBrowser) {
|
|
222
193
|
_context3.next = 21;
|
|
223
194
|
break;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
onCancel: function onCancel() {
|
|
263
|
-
return reject("User cancelled sign");
|
|
264
|
-
},
|
|
265
|
-
onMessage: function () {
|
|
266
|
-
var _onMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, Close) {
|
|
267
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
268
|
-
while (1) {
|
|
269
|
-
switch (_context.prev = _context.next) {
|
|
270
|
-
case 0:
|
|
271
|
-
if (!(!event || !event.data || event.data.type !== "FlowResponse")) {
|
|
272
|
-
_context.next = 2;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return _context.abrupt("return");
|
|
277
|
-
|
|
278
|
-
case 2:
|
|
279
|
-
try {
|
|
280
|
-
resolve(event.data.response);
|
|
281
|
-
} catch (error) {
|
|
282
|
-
reject(error);
|
|
283
|
-
} finally {
|
|
284
|
-
Close();
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
case 3:
|
|
288
|
-
case "end":
|
|
289
|
-
return _context.stop();
|
|
290
|
-
}
|
|
195
|
+
}
|
|
196
|
+
throw Error("ElvWalletClient: Unable to sign");
|
|
197
|
+
case 21:
|
|
198
|
+
parameters = {
|
|
199
|
+
action: "personal-sign",
|
|
200
|
+
message: message,
|
|
201
|
+
logIn: true
|
|
202
|
+
};
|
|
203
|
+
url = new URL(this.appUrl);
|
|
204
|
+
url.hash = UrlJoin("/action", "sign", Utils.B58(JSON.stringify(parameters)));
|
|
205
|
+
url.searchParams.set("origin", window.location.origin);
|
|
206
|
+
if (!(!embedded && window.location.origin === url.origin)) {
|
|
207
|
+
_context3.next = 27;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
throw Error("ElvWalletClient: Unable to sign");
|
|
211
|
+
case 27:
|
|
212
|
+
_context3.next = 29;
|
|
213
|
+
return new Promise( /*#__PURE__*/function () {
|
|
214
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
|
|
215
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
216
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
217
|
+
case 0:
|
|
218
|
+
_context2.next = 2;
|
|
219
|
+
return ActionPopup({
|
|
220
|
+
mode: "tab",
|
|
221
|
+
url: url.toString(),
|
|
222
|
+
onCancel: function onCancel() {
|
|
223
|
+
return reject("User cancelled sign");
|
|
224
|
+
},
|
|
225
|
+
onMessage: function () {
|
|
226
|
+
var _onMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, Close) {
|
|
227
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
228
|
+
while (1) switch (_context.prev = _context.next) {
|
|
229
|
+
case 0:
|
|
230
|
+
if (!(!event || !event.data || event.data.type !== "FlowResponse")) {
|
|
231
|
+
_context.next = 2;
|
|
232
|
+
break;
|
|
291
233
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
234
|
+
return _context.abrupt("return");
|
|
235
|
+
case 2:
|
|
236
|
+
try {
|
|
237
|
+
resolve(event.data.response);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
reject(error);
|
|
240
|
+
} finally {
|
|
241
|
+
Close();
|
|
242
|
+
}
|
|
243
|
+
case 3:
|
|
244
|
+
case "end":
|
|
245
|
+
return _context.stop();
|
|
297
246
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
return _context3.stop();
|
|
322
|
-
}
|
|
247
|
+
}, _callee);
|
|
248
|
+
}));
|
|
249
|
+
function onMessage(_x4, _x5) {
|
|
250
|
+
return _onMessage.apply(this, arguments);
|
|
251
|
+
}
|
|
252
|
+
return onMessage;
|
|
253
|
+
}()
|
|
254
|
+
});
|
|
255
|
+
case 2:
|
|
256
|
+
case "end":
|
|
257
|
+
return _context2.stop();
|
|
258
|
+
}
|
|
259
|
+
}, _callee2);
|
|
260
|
+
}));
|
|
261
|
+
return function (_x2, _x3) {
|
|
262
|
+
return _ref3.apply(this, arguments);
|
|
263
|
+
};
|
|
264
|
+
}());
|
|
265
|
+
case 29:
|
|
266
|
+
return _context3.abrupt("return", _context3.sent);
|
|
267
|
+
case 30:
|
|
268
|
+
case "end":
|
|
269
|
+
return _context3.stop();
|
|
323
270
|
}
|
|
324
271
|
}, _callee3, this);
|
|
325
272
|
}));
|
|
326
|
-
|
|
327
273
|
function PersonalSign(_x) {
|
|
328
274
|
return _PersonalSign.apply(this, arguments);
|
|
329
275
|
}
|
|
330
|
-
|
|
331
276
|
return PersonalSign;
|
|
332
277
|
}()
|
|
333
278
|
/**
|
|
@@ -351,181 +296,143 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
351
296
|
*
|
|
352
297
|
* @throws - If using the popup flow and the user closes the popup, this method will throw an error.
|
|
353
298
|
*/
|
|
354
|
-
|
|
355
299
|
}, {
|
|
356
300
|
key: "LogIn",
|
|
357
301
|
value: function () {
|
|
358
302
|
var _LogIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref4) {
|
|
359
303
|
var _this = this;
|
|
360
|
-
|
|
361
304
|
var _ref4$method, method, provider, _ref4$mode, mode, callbackUrl, marketplaceParams, _ref4$clearLogin, clearLogin, callback, loginUrl;
|
|
362
|
-
|
|
363
305
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
364
|
-
while (1) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (!marketplaceParams) {
|
|
382
|
-
_context6.next = 15;
|
|
383
|
-
break;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
_context6.t0 = loginUrl.searchParams;
|
|
387
|
-
_context6.next = 11;
|
|
388
|
-
return this.MarketplaceInfo({
|
|
389
|
-
marketplaceParams: marketplaceParams
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
case 11:
|
|
393
|
-
_context6.t1 = _context6.sent.marketplaceHash;
|
|
394
|
-
|
|
395
|
-
_context6.t0.set.call(_context6.t0, "mid", _context6.t1);
|
|
396
|
-
|
|
397
|
-
_context6.next = 16;
|
|
306
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
307
|
+
case 0:
|
|
308
|
+
_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;
|
|
309
|
+
loginUrl = new URL(this.appUrl);
|
|
310
|
+
loginUrl.hash = "/login";
|
|
311
|
+
loginUrl.searchParams.set("origin", window.location.origin);
|
|
312
|
+
loginUrl.searchParams.set("action", "login");
|
|
313
|
+
if (provider) {
|
|
314
|
+
loginUrl.searchParams.set("provider", provider);
|
|
315
|
+
}
|
|
316
|
+
if (mode) {
|
|
317
|
+
loginUrl.searchParams.set("mode", mode);
|
|
318
|
+
}
|
|
319
|
+
if (!marketplaceParams) {
|
|
320
|
+
_context6.next = 15;
|
|
398
321
|
break;
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
loginUrl.searchParams.set("
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
_context6.next =
|
|
322
|
+
}
|
|
323
|
+
_context6.t0 = loginUrl.searchParams;
|
|
324
|
+
_context6.next = 11;
|
|
325
|
+
return this.MarketplaceInfo({
|
|
326
|
+
marketplaceParams: marketplaceParams
|
|
327
|
+
});
|
|
328
|
+
case 11:
|
|
329
|
+
_context6.t1 = _context6.sent.marketplaceHash;
|
|
330
|
+
_context6.t0.set.call(_context6.t0, "mid", _context6.t1);
|
|
331
|
+
_context6.next = 16;
|
|
332
|
+
break;
|
|
333
|
+
case 15:
|
|
334
|
+
if ((this.selectedMarketplaceInfo || {}).marketplaceHash) {
|
|
335
|
+
loginUrl.searchParams.set("mid", this.selectedMarketplaceInfo.marketplaceHash);
|
|
336
|
+
}
|
|
337
|
+
case 16:
|
|
338
|
+
if (clearLogin) {
|
|
339
|
+
loginUrl.searchParams.set("clear", "");
|
|
340
|
+
}
|
|
341
|
+
if (!(method === "redirect")) {
|
|
342
|
+
_context6.next = 24;
|
|
420
343
|
break;
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
case 2:
|
|
453
|
-
_context4.prev = 2;
|
|
454
|
-
|
|
455
|
-
if (!callback) {
|
|
456
|
-
_context4.next = 8;
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
_context4.next = 6;
|
|
461
|
-
return callback(event.data.params);
|
|
462
|
-
|
|
463
|
-
case 6:
|
|
464
|
-
_context4.next = 10;
|
|
465
|
-
break;
|
|
466
|
-
|
|
467
|
-
case 8:
|
|
468
|
-
_context4.next = 10;
|
|
469
|
-
return _this.Authenticate({
|
|
470
|
-
token: event.data.params.clientSigningToken || event.data.params.clientAuthToken
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
case 10:
|
|
474
|
-
resolve();
|
|
475
|
-
_context4.next = 16;
|
|
476
|
-
break;
|
|
477
|
-
|
|
478
|
-
case 13:
|
|
479
|
-
_context4.prev = 13;
|
|
480
|
-
_context4.t0 = _context4["catch"](2);
|
|
481
|
-
reject(_context4.t0);
|
|
482
|
-
|
|
483
|
-
case 16:
|
|
484
|
-
_context4.prev = 16;
|
|
485
|
-
Close();
|
|
486
|
-
return _context4.finish(16);
|
|
487
|
-
|
|
488
|
-
case 19:
|
|
489
|
-
case "end":
|
|
490
|
-
return _context4.stop();
|
|
491
|
-
}
|
|
344
|
+
}
|
|
345
|
+
loginUrl.searchParams.set("response", "redirect");
|
|
346
|
+
loginUrl.searchParams.set("source", "origin");
|
|
347
|
+
loginUrl.searchParams.set("redirect", callbackUrl);
|
|
348
|
+
window.location = loginUrl;
|
|
349
|
+
_context6.next = 28;
|
|
350
|
+
break;
|
|
351
|
+
case 24:
|
|
352
|
+
loginUrl.searchParams.set("response", "message");
|
|
353
|
+
loginUrl.searchParams.set("source", "parent");
|
|
354
|
+
_context6.next = 28;
|
|
355
|
+
return new Promise( /*#__PURE__*/function () {
|
|
356
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(resolve, reject) {
|
|
357
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
358
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
359
|
+
case 0:
|
|
360
|
+
_context5.next = 2;
|
|
361
|
+
return ActionPopup({
|
|
362
|
+
mode: "tab",
|
|
363
|
+
url: loginUrl.toString(),
|
|
364
|
+
onCancel: function onCancel() {
|
|
365
|
+
return reject("User cancelled login");
|
|
366
|
+
},
|
|
367
|
+
onMessage: function () {
|
|
368
|
+
var _onMessage2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(event, Close) {
|
|
369
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
370
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
371
|
+
case 0:
|
|
372
|
+
if (!(!event || !event.data || event.data.type !== "LoginResponse")) {
|
|
373
|
+
_context4.next = 2;
|
|
374
|
+
break;
|
|
492
375
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
376
|
+
return _context4.abrupt("return");
|
|
377
|
+
case 2:
|
|
378
|
+
_context4.prev = 2;
|
|
379
|
+
if (!callback) {
|
|
380
|
+
_context4.next = 8;
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
_context4.next = 6;
|
|
384
|
+
return callback(event.data.params);
|
|
385
|
+
case 6:
|
|
386
|
+
_context4.next = 10;
|
|
387
|
+
break;
|
|
388
|
+
case 8:
|
|
389
|
+
_context4.next = 10;
|
|
390
|
+
return _this.Authenticate({
|
|
391
|
+
token: event.data.params.clientSigningToken || event.data.params.clientAuthToken
|
|
392
|
+
});
|
|
393
|
+
case 10:
|
|
394
|
+
resolve();
|
|
395
|
+
_context4.next = 16;
|
|
396
|
+
break;
|
|
397
|
+
case 13:
|
|
398
|
+
_context4.prev = 13;
|
|
399
|
+
_context4.t0 = _context4["catch"](2);
|
|
400
|
+
reject(_context4.t0);
|
|
401
|
+
case 16:
|
|
402
|
+
_context4.prev = 16;
|
|
403
|
+
Close();
|
|
404
|
+
return _context4.finish(16);
|
|
405
|
+
case 19:
|
|
406
|
+
case "end":
|
|
407
|
+
return _context4.stop();
|
|
498
408
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
409
|
+
}, _callee4, null, [[2, 13, 16, 19]]);
|
|
410
|
+
}));
|
|
411
|
+
function onMessage(_x9, _x10) {
|
|
412
|
+
return _onMessage2.apply(this, arguments);
|
|
413
|
+
}
|
|
414
|
+
return onMessage;
|
|
415
|
+
}()
|
|
416
|
+
});
|
|
417
|
+
case 2:
|
|
418
|
+
case "end":
|
|
419
|
+
return _context5.stop();
|
|
420
|
+
}
|
|
421
|
+
}, _callee5);
|
|
422
|
+
}));
|
|
423
|
+
return function (_x7, _x8) {
|
|
424
|
+
return _ref5.apply(this, arguments);
|
|
425
|
+
};
|
|
426
|
+
}());
|
|
427
|
+
case 28:
|
|
428
|
+
case "end":
|
|
429
|
+
return _context6.stop();
|
|
521
430
|
}
|
|
522
431
|
}, _callee6, this);
|
|
523
432
|
}));
|
|
524
|
-
|
|
525
433
|
function LogIn(_x6) {
|
|
526
434
|
return _LogIn.apply(this, arguments);
|
|
527
435
|
}
|
|
528
|
-
|
|
529
436
|
return LogIn;
|
|
530
437
|
}()
|
|
531
438
|
/**
|
|
@@ -533,20 +440,22 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
533
440
|
*
|
|
534
441
|
* @methodGroup Login
|
|
535
442
|
*/
|
|
536
|
-
|
|
537
443
|
}, {
|
|
538
444
|
key: "LogOut",
|
|
539
445
|
value: function LogOut() {
|
|
540
446
|
this.__authorization = {};
|
|
541
447
|
this.loggedIn = false;
|
|
542
|
-
this.cachedMarketplaces = {};
|
|
448
|
+
this.cachedMarketplaces = {};
|
|
543
449
|
|
|
450
|
+
// Delete saved auth token
|
|
544
451
|
if (localStorageAvailable) {
|
|
545
452
|
try {
|
|
546
|
-
localStorage.removeItem("__elv-token-".concat(this.network));
|
|
453
|
+
localStorage.removeItem("__elv-token-".concat(this.network));
|
|
454
|
+
// eslint-disable-next-line no-empty
|
|
547
455
|
} catch (error) {}
|
|
548
456
|
}
|
|
549
457
|
}
|
|
458
|
+
|
|
550
459
|
/**
|
|
551
460
|
* Authenticate with an ElvWalletClient authorization token
|
|
552
461
|
*
|
|
@@ -554,65 +463,53 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
554
463
|
* @namedParams
|
|
555
464
|
* @param {string} token - A previously generated ElvWalletClient authorization token;
|
|
556
465
|
*/
|
|
557
|
-
|
|
558
466
|
}, {
|
|
559
467
|
key: "Authenticate",
|
|
560
468
|
value: function () {
|
|
561
469
|
var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref6) {
|
|
562
470
|
var token, decodedToken;
|
|
563
471
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
564
|
-
while (1) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
472
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
473
|
+
case 0:
|
|
474
|
+
token = _ref6.token;
|
|
475
|
+
_context7.prev = 1;
|
|
476
|
+
decodedToken = JSON.parse(this.utils.FromB58ToStr(token)) || {};
|
|
477
|
+
_context7.next = 8;
|
|
478
|
+
break;
|
|
479
|
+
case 5:
|
|
480
|
+
_context7.prev = 5;
|
|
481
|
+
_context7.t0 = _context7["catch"](1);
|
|
482
|
+
throw new Error("Invalid authorization token " + token);
|
|
483
|
+
case 8:
|
|
484
|
+
if (!(!decodedToken.expiresAt || Date.now() > decodedToken.expiresAt)) {
|
|
485
|
+
_context7.next = 10;
|
|
571
486
|
break;
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
throw new Error("Invalid authorization token " + token);
|
|
577
|
-
|
|
578
|
-
case 8:
|
|
579
|
-
if (!(!decodedToken.expiresAt || Date.now() > decodedToken.expiresAt)) {
|
|
580
|
-
_context7.next = 10;
|
|
581
|
-
break;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
throw Error("ElvWalletClient: Provided authorization token has expired");
|
|
585
|
-
|
|
586
|
-
case 10:
|
|
587
|
-
if (!decodedToken.clusterToken) {
|
|
588
|
-
_context7.next = 13;
|
|
589
|
-
break;
|
|
590
|
-
}
|
|
591
|
-
|
|
487
|
+
}
|
|
488
|
+
throw Error("ElvWalletClient: Provided authorization token has expired");
|
|
489
|
+
case 10:
|
|
490
|
+
if (!decodedToken.clusterToken) {
|
|
592
491
|
_context7.next = 13;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
_context7.next = 13;
|
|
495
|
+
return this.client.SetRemoteSigner({
|
|
496
|
+
authToken: decodedToken.clusterToken,
|
|
497
|
+
signerURIs: decodedToken.signerURIs
|
|
498
|
+
});
|
|
499
|
+
case 13:
|
|
500
|
+
this.client.SetStaticToken({
|
|
501
|
+
token: decodedToken.fabricToken
|
|
502
|
+
});
|
|
503
|
+
return _context7.abrupt("return", this.SetAuthorization(_objectSpread({}, decodedToken)));
|
|
504
|
+
case 15:
|
|
505
|
+
case "end":
|
|
506
|
+
return _context7.stop();
|
|
608
507
|
}
|
|
609
508
|
}, _callee7, this, [[1, 5]]);
|
|
610
509
|
}));
|
|
611
|
-
|
|
612
510
|
function Authenticate(_x11) {
|
|
613
511
|
return _Authenticate.apply(this, arguments);
|
|
614
512
|
}
|
|
615
|
-
|
|
616
513
|
return Authenticate;
|
|
617
514
|
}()
|
|
618
515
|
/**
|
|
@@ -634,111 +531,94 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
634
531
|
* - signingToken - Identical to `authToken`, but also includes the ability to perform arbitrary signatures with the custodial wallet. This token should be protected and should not be
|
|
635
532
|
* shared with third parties.
|
|
636
533
|
*/
|
|
637
|
-
|
|
638
534
|
}, {
|
|
639
535
|
key: "AuthenticateOAuth",
|
|
640
536
|
value: function () {
|
|
641
537
|
var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref7) {
|
|
642
538
|
var idToken, tenantId, email, signerURIs, _ref7$shareEmail, shareEmail, tokenDuration, expiresAt, fabricToken, address, decodedToken;
|
|
643
|
-
|
|
644
539
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
645
|
-
while (1) {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
duration: tokenDuration * 60 * 60 * 1000
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
case 11:
|
|
682
|
-
fabricToken = _context8.sent;
|
|
683
|
-
address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
|
|
684
|
-
|
|
685
|
-
if (email) {
|
|
686
|
-
_context8.next = 22;
|
|
687
|
-
break;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
_context8.prev = 14;
|
|
691
|
-
decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
|
|
692
|
-
email = decodedToken.email;
|
|
540
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
541
|
+
case 0:
|
|
542
|
+
idToken = _ref7.idToken, tenantId = _ref7.tenantId, email = _ref7.email, signerURIs = _ref7.signerURIs, _ref7$shareEmail = _ref7.shareEmail, shareEmail = _ref7$shareEmail === void 0 ? false : _ref7$shareEmail;
|
|
543
|
+
tokenDuration = 24;
|
|
544
|
+
if (!(!tenantId && this.selectedMarketplaceInfo)) {
|
|
545
|
+
_context8.next = 6;
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
_context8.next = 5;
|
|
549
|
+
return this.AvailableMarketplaces();
|
|
550
|
+
case 5:
|
|
551
|
+
tenantId = this.selectedMarketplaceInfo.tenantId;
|
|
552
|
+
case 6:
|
|
553
|
+
_context8.next = 8;
|
|
554
|
+
return this.client.SetRemoteSigner({
|
|
555
|
+
idToken: idToken,
|
|
556
|
+
tenantId: tenantId,
|
|
557
|
+
signerURIs: signerURIs,
|
|
558
|
+
extraData: {
|
|
559
|
+
share_email: shareEmail
|
|
560
|
+
},
|
|
561
|
+
unsignedPublicAuth: true
|
|
562
|
+
});
|
|
563
|
+
case 8:
|
|
564
|
+
expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
565
|
+
_context8.next = 11;
|
|
566
|
+
return this.client.CreateFabricToken({
|
|
567
|
+
duration: tokenDuration * 60 * 60 * 1000
|
|
568
|
+
});
|
|
569
|
+
case 11:
|
|
570
|
+
fabricToken = _context8.sent;
|
|
571
|
+
address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
|
|
572
|
+
if (email) {
|
|
693
573
|
_context8.next = 22;
|
|
694
574
|
break;
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
575
|
+
}
|
|
576
|
+
_context8.prev = 14;
|
|
577
|
+
decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
|
|
578
|
+
email = decodedToken.email;
|
|
579
|
+
_context8.next = 22;
|
|
580
|
+
break;
|
|
581
|
+
case 19:
|
|
582
|
+
_context8.prev = 19;
|
|
583
|
+
_context8.t0 = _context8["catch"](14);
|
|
584
|
+
throw Error("Failed to decode ID token");
|
|
585
|
+
case 22:
|
|
586
|
+
this.client.SetStaticToken({
|
|
587
|
+
token: fabricToken
|
|
588
|
+
});
|
|
589
|
+
return _context8.abrupt("return", {
|
|
590
|
+
authToken: this.SetAuthorization({
|
|
591
|
+
fabricToken: fabricToken,
|
|
592
|
+
tenantId: tenantId,
|
|
593
|
+
address: address,
|
|
594
|
+
email: email,
|
|
595
|
+
expiresAt: expiresAt,
|
|
596
|
+
signerURIs: signerURIs,
|
|
597
|
+
walletType: "Custodial",
|
|
598
|
+
walletName: "Eluvio",
|
|
599
|
+
register: true
|
|
600
|
+
}),
|
|
601
|
+
signingToken: this.SetAuthorization({
|
|
602
|
+
clusterToken: this.client.signer.authToken,
|
|
603
|
+
fabricToken: fabricToken,
|
|
604
|
+
tenantId: tenantId,
|
|
605
|
+
address: address,
|
|
606
|
+
email: email,
|
|
607
|
+
expiresAt: expiresAt,
|
|
608
|
+
signerURIs: signerURIs,
|
|
609
|
+
walletType: "Custodial",
|
|
610
|
+
walletName: "Eluvio"
|
|
611
|
+
})
|
|
612
|
+
});
|
|
613
|
+
case 24:
|
|
614
|
+
case "end":
|
|
615
|
+
return _context8.stop();
|
|
734
616
|
}
|
|
735
617
|
}, _callee8, this, [[14, 19]]);
|
|
736
618
|
}));
|
|
737
|
-
|
|
738
619
|
function AuthenticateOAuth(_x12) {
|
|
739
620
|
return _AuthenticateOAuth.apply(this, arguments);
|
|
740
621
|
}
|
|
741
|
-
|
|
742
622
|
return AuthenticateOAuth;
|
|
743
623
|
}()
|
|
744
624
|
/**
|
|
@@ -754,85 +634,68 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
754
634
|
* @returns {Promise<string>} - Returns an authorization token that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
755
635
|
* Save this token to avoid having to reauthenticate. This token expires after 24 hours.
|
|
756
636
|
*/
|
|
757
|
-
|
|
758
637
|
}, {
|
|
759
638
|
key: "AuthenticateExternalWallet",
|
|
760
639
|
value: function () {
|
|
761
640
|
var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref8) {
|
|
762
641
|
var _this2 = this;
|
|
763
|
-
|
|
764
642
|
var address, _ref8$tokenDuration, tokenDuration, _ref8$walletName, walletName, Sign, expiresAt, fabricToken;
|
|
765
|
-
|
|
766
643
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
767
|
-
while (1) {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
fabricToken: fabricToken,
|
|
817
|
-
address: address,
|
|
818
|
-
expiresAt: expiresAt,
|
|
819
|
-
walletType: "External",
|
|
820
|
-
walletName: walletName,
|
|
821
|
-
register: true
|
|
822
|
-
}));
|
|
823
|
-
|
|
824
|
-
case 9:
|
|
825
|
-
case "end":
|
|
826
|
-
return _context10.stop();
|
|
827
|
-
}
|
|
644
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
645
|
+
case 0:
|
|
646
|
+
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;
|
|
647
|
+
if (!address) {
|
|
648
|
+
address = window.ethereum.selectedAddress;
|
|
649
|
+
}
|
|
650
|
+
address = this.utils.FormatAddress(address);
|
|
651
|
+
if (!Sign) {
|
|
652
|
+
Sign = /*#__PURE__*/function () {
|
|
653
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(message) {
|
|
654
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
655
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
656
|
+
case 0:
|
|
657
|
+
return _context9.abrupt("return", _this2.SignMetamask({
|
|
658
|
+
message: message,
|
|
659
|
+
address: address
|
|
660
|
+
}));
|
|
661
|
+
case 1:
|
|
662
|
+
case "end":
|
|
663
|
+
return _context9.stop();
|
|
664
|
+
}
|
|
665
|
+
}, _callee9);
|
|
666
|
+
}));
|
|
667
|
+
return function Sign(_x14) {
|
|
668
|
+
return _ref9.apply(this, arguments);
|
|
669
|
+
};
|
|
670
|
+
}();
|
|
671
|
+
}
|
|
672
|
+
expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
673
|
+
_context10.next = 7;
|
|
674
|
+
return this.client.CreateFabricToken({
|
|
675
|
+
address: address,
|
|
676
|
+
duration: tokenDuration * 60 * 60 * 1000,
|
|
677
|
+
Sign: Sign,
|
|
678
|
+
addEthereumPrefix: false
|
|
679
|
+
});
|
|
680
|
+
case 7:
|
|
681
|
+
fabricToken = _context10.sent;
|
|
682
|
+
return _context10.abrupt("return", this.SetAuthorization({
|
|
683
|
+
fabricToken: fabricToken,
|
|
684
|
+
address: address,
|
|
685
|
+
expiresAt: expiresAt,
|
|
686
|
+
walletType: "External",
|
|
687
|
+
walletName: walletName,
|
|
688
|
+
register: true
|
|
689
|
+
}));
|
|
690
|
+
case 9:
|
|
691
|
+
case "end":
|
|
692
|
+
return _context10.stop();
|
|
828
693
|
}
|
|
829
694
|
}, _callee10, this);
|
|
830
695
|
}));
|
|
831
|
-
|
|
832
696
|
function AuthenticateExternalWallet(_x13) {
|
|
833
697
|
return _AuthenticateExternalWallet.apply(this, arguments);
|
|
834
698
|
}
|
|
835
|
-
|
|
836
699
|
return AuthenticateExternalWallet;
|
|
837
700
|
}()
|
|
838
701
|
/**
|
|
@@ -842,14 +705,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
842
705
|
*
|
|
843
706
|
* @returns {string} - The client auth token
|
|
844
707
|
*/
|
|
845
|
-
|
|
846
708
|
}, {
|
|
847
709
|
key: "ClientAuthToken",
|
|
848
710
|
value: function ClientAuthToken() {
|
|
849
711
|
if (!this.loggedIn) {
|
|
850
712
|
return "";
|
|
851
713
|
}
|
|
852
|
-
|
|
853
714
|
return this.utils.B58(JSON.stringify(this.__authorization));
|
|
854
715
|
}
|
|
855
716
|
}, {
|
|
@@ -858,25 +719,23 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
858
719
|
if (!this.loggedIn) {
|
|
859
720
|
return this.publicStaticToken;
|
|
860
721
|
}
|
|
861
|
-
|
|
862
722
|
return this.__authorization.fabricToken;
|
|
863
723
|
}
|
|
864
724
|
}, {
|
|
865
725
|
key: "SetAuthorization",
|
|
866
726
|
value: function SetAuthorization(_ref10) {
|
|
867
727
|
var _this3 = this;
|
|
868
|
-
|
|
869
728
|
var clusterToken = _ref10.clusterToken,
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
729
|
+
fabricToken = _ref10.fabricToken,
|
|
730
|
+
tenantId = _ref10.tenantId,
|
|
731
|
+
address = _ref10.address,
|
|
732
|
+
email = _ref10.email,
|
|
733
|
+
expiresAt = _ref10.expiresAt,
|
|
734
|
+
signerURIs = _ref10.signerURIs,
|
|
735
|
+
walletType = _ref10.walletType,
|
|
736
|
+
walletName = _ref10.walletName,
|
|
737
|
+
_ref10$register = _ref10.register,
|
|
738
|
+
register = _ref10$register === void 0 ? false : _ref10$register;
|
|
880
739
|
address = this.client.utils.FormatAddress(address);
|
|
881
740
|
this.__authorization = {
|
|
882
741
|
fabricToken: fabricToken,
|
|
@@ -887,25 +746,21 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
887
746
|
walletType: walletType,
|
|
888
747
|
walletName: walletName
|
|
889
748
|
};
|
|
890
|
-
|
|
891
749
|
if (clusterToken) {
|
|
892
750
|
this.__authorization.clusterToken = clusterToken;
|
|
893
|
-
|
|
894
751
|
if (signerURIs) {
|
|
895
752
|
this.__authorization.signerURIs = signerURIs;
|
|
896
753
|
}
|
|
897
754
|
}
|
|
898
|
-
|
|
899
755
|
this.loggedIn = true;
|
|
900
756
|
this.cachedMarketplaces = {};
|
|
901
757
|
var token = this.ClientAuthToken();
|
|
902
|
-
|
|
903
758
|
if (this.storeAuthToken && localStorageAvailable) {
|
|
904
759
|
try {
|
|
905
|
-
localStorage.setItem("__elv-token-".concat(this.network), token);
|
|
760
|
+
localStorage.setItem("__elv-token-".concat(this.network), token);
|
|
761
|
+
// eslint-disable-next-line no-empty
|
|
906
762
|
} catch (error) {}
|
|
907
763
|
}
|
|
908
|
-
|
|
909
764
|
if (register) {
|
|
910
765
|
this.client.authClient.MakeAuthServiceRequest({
|
|
911
766
|
path: "/as/wlt/register",
|
|
@@ -917,7 +772,6 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
917
772
|
_this3.Log("Failed to register account: ", true, error);
|
|
918
773
|
});
|
|
919
774
|
}
|
|
920
|
-
|
|
921
775
|
return token;
|
|
922
776
|
}
|
|
923
777
|
}, {
|
|
@@ -926,289 +780,244 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
926
780
|
var _SignMetamask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref11) {
|
|
927
781
|
var message, address, accounts;
|
|
928
782
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
929
|
-
while (1) {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
method: "personal_sign",
|
|
962
|
-
params: [message, address, ""]
|
|
963
|
-
});
|
|
964
|
-
|
|
965
|
-
case 11:
|
|
966
|
-
return _context11.abrupt("return", _context11.sent);
|
|
967
|
-
|
|
968
|
-
case 12:
|
|
969
|
-
case "end":
|
|
970
|
-
return _context11.stop();
|
|
971
|
-
}
|
|
783
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
784
|
+
case 0:
|
|
785
|
+
message = _ref11.message, address = _ref11.address;
|
|
786
|
+
if (!(!inBrowser || !window.ethereum)) {
|
|
787
|
+
_context11.next = 3;
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
790
|
+
throw Error("ElvWalletClient: Unable to initialize - Metamask not available");
|
|
791
|
+
case 3:
|
|
792
|
+
address = address || this.UserAddress();
|
|
793
|
+
_context11.next = 6;
|
|
794
|
+
return window.ethereum.request({
|
|
795
|
+
method: "eth_requestAccounts"
|
|
796
|
+
});
|
|
797
|
+
case 6:
|
|
798
|
+
accounts = _context11.sent;
|
|
799
|
+
if (!(address && !Utils.EqualAddress(accounts[0], address))) {
|
|
800
|
+
_context11.next = 9;
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
throw Error("ElvWalletClient: Incorrect MetaMask account selected. Expected ".concat(address, ", got ").concat(accounts[0]));
|
|
804
|
+
case 9:
|
|
805
|
+
_context11.next = 11;
|
|
806
|
+
return window.ethereum.request({
|
|
807
|
+
method: "personal_sign",
|
|
808
|
+
params: [message, address, ""]
|
|
809
|
+
});
|
|
810
|
+
case 11:
|
|
811
|
+
return _context11.abrupt("return", _context11.sent);
|
|
812
|
+
case 12:
|
|
813
|
+
case "end":
|
|
814
|
+
return _context11.stop();
|
|
972
815
|
}
|
|
973
816
|
}, _callee11, this);
|
|
974
817
|
}));
|
|
975
|
-
|
|
976
818
|
function SignMetamask(_x15) {
|
|
977
819
|
return _SignMetamask.apply(this, arguments);
|
|
978
820
|
}
|
|
979
|
-
|
|
980
821
|
return SignMetamask;
|
|
981
822
|
}() // Internal loading methods
|
|
982
|
-
|
|
983
823
|
}, {
|
|
984
824
|
key: "LoadAvailableMarketplaces",
|
|
985
825
|
value: function () {
|
|
986
826
|
var _LoadAvailableMarketplaces = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
987
827
|
var _this4 = this;
|
|
988
|
-
|
|
989
828
|
var forceReload,
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
829
|
+
mainSiteHash,
|
|
830
|
+
metadata,
|
|
831
|
+
previewTenantSlug,
|
|
832
|
+
previewMarketplaceSlug,
|
|
833
|
+
previewMarketplaceMetadata,
|
|
834
|
+
availableMarketplaces,
|
|
835
|
+
availableMarketplacesById,
|
|
836
|
+
_args12 = arguments;
|
|
998
837
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
999
|
-
while (1) {
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
838
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
839
|
+
case 0:
|
|
840
|
+
forceReload = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : false;
|
|
841
|
+
if (!(!forceReload && Object.keys(this.availableMarketplaces) > 0)) {
|
|
842
|
+
_context12.next = 3;
|
|
843
|
+
break;
|
|
844
|
+
}
|
|
845
|
+
return _context12.abrupt("return");
|
|
846
|
+
case 3:
|
|
847
|
+
_context12.next = 5;
|
|
848
|
+
return this.client.LatestVersionHash({
|
|
849
|
+
objectId: this.mainSiteId
|
|
850
|
+
});
|
|
851
|
+
case 5:
|
|
852
|
+
mainSiteHash = _context12.sent;
|
|
853
|
+
_context12.next = 8;
|
|
854
|
+
return this.client.ContentObjectMetadata({
|
|
855
|
+
versionHash: mainSiteHash,
|
|
856
|
+
metadataSubtree: "public/asset_metadata/tenants",
|
|
857
|
+
resolveLinks: true,
|
|
858
|
+
linkDepthLimit: 2,
|
|
859
|
+
resolveIncludeSource: true,
|
|
860
|
+
resolveIgnoreErrors: true,
|
|
861
|
+
produceLinkUrls: true,
|
|
862
|
+
authorizationToken: this.publicStaticToken,
|
|
863
|
+
noAuth: true,
|
|
864
|
+
select: ["*/.", "*/marketplaces/*/.", "*/marketplaces/*/info/tenant_id", "*/marketplaces/*/info/tenant_name", "*/marketplaces/*/info/branding", "*/marketplaces/*/info/storefront/background", "*/marketplaces/*/info/storefront/background_mobile"],
|
|
865
|
+
remove: ["*/marketplaces/*/info/branding/custom_css"]
|
|
866
|
+
});
|
|
867
|
+
case 8:
|
|
868
|
+
metadata = _context12.sent;
|
|
869
|
+
if (!this.previewMarketplaceId) {
|
|
870
|
+
_context12.next = 24;
|
|
871
|
+
break;
|
|
872
|
+
}
|
|
873
|
+
previewTenantSlug = "PREVIEW";
|
|
874
|
+
Object.keys(metadata || {}).forEach(function (tenantSlug) {
|
|
875
|
+
return Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
|
|
876
|
+
var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
|
|
877
|
+
var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
|
|
878
|
+
if (objectId === _this4.previewMarketplaceId) {
|
|
879
|
+
// Marketplace exists in site meta
|
|
880
|
+
previewTenantSlug = tenantSlug;
|
|
881
|
+
previewMarketplaceSlug = marketplaceSlug;
|
|
882
|
+
|
|
883
|
+
// Deployed marketplace is same as preview marketplace
|
|
884
|
+
if (versionHash === _this4.previewMarketplaceHash) {
|
|
885
|
+
previewMarketplaceMetadata = metadata[tenantSlug].marketplaces[marketplaceSlug];
|
|
886
|
+
}
|
|
887
|
+
}
|
|
1032
888
|
});
|
|
889
|
+
});
|
|
1033
890
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
891
|
+
// Marketplace not present in branch, or preview version is different - Load metadata directly
|
|
892
|
+
if (previewMarketplaceMetadata) {
|
|
893
|
+
_context12.next = 17;
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
896
|
+
_context12.next = 15;
|
|
897
|
+
return this.client.ContentObjectMetadata({
|
|
898
|
+
versionHash: this.previewMarketplaceHash,
|
|
899
|
+
metadataSubtree: "public/asset_metadata",
|
|
900
|
+
produceLinkUrls: true,
|
|
901
|
+
authorizationToken: this.publicStaticToken,
|
|
902
|
+
noAuth: true,
|
|
903
|
+
select: ["slug", "info/tenant_id", "info/tenant_name", "info/branding"],
|
|
904
|
+
remove: ["info/branding/custom_css"]
|
|
905
|
+
});
|
|
906
|
+
case 15:
|
|
907
|
+
previewMarketplaceMetadata = _context12.sent;
|
|
908
|
+
if (!previewMarketplaceSlug) {
|
|
909
|
+
previewMarketplaceSlug = previewMarketplaceMetadata.slug;
|
|
910
|
+
}
|
|
911
|
+
case 17:
|
|
912
|
+
previewMarketplaceMetadata["."] = {
|
|
913
|
+
source: this.previewMarketplaceHash
|
|
914
|
+
};
|
|
915
|
+
previewMarketplaceMetadata.info["."] = {
|
|
916
|
+
source: this.previewMarketplaceHash
|
|
917
|
+
};
|
|
918
|
+
previewMarketplaceMetadata.info.branding.preview = true;
|
|
919
|
+
previewMarketplaceMetadata.info.branding.show = true;
|
|
920
|
+
metadata[previewTenantSlug] = metadata[previewTenantSlug] || {};
|
|
921
|
+
metadata[previewTenantSlug].marketplaces = metadata[previewTenantSlug].marketplaces || {};
|
|
922
|
+
metadata[previewTenantSlug].marketplaces[previewMarketplaceSlug] = previewMarketplaceMetadata;
|
|
923
|
+
case 24:
|
|
924
|
+
availableMarketplaces = _objectSpread({}, this.availableMarketplaces || {});
|
|
925
|
+
availableMarketplacesById = _objectSpread({}, this.availableMarketplacesById || {});
|
|
926
|
+
Object.keys(metadata || {}).forEach(function (tenantSlug) {
|
|
927
|
+
try {
|
|
928
|
+
availableMarketplaces[tenantSlug] = metadata[tenantSlug]["."] ? {
|
|
929
|
+
versionHash: metadata[tenantSlug]["."].source
|
|
930
|
+
} : {};
|
|
931
|
+
Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
|
|
932
|
+
try {
|
|
933
|
+
var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
|
|
934
|
+
var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
|
|
935
|
+
availableMarketplaces[tenantSlug][marketplaceSlug] = _objectSpread(_objectSpread({}, metadata[tenantSlug].marketplaces[marketplaceSlug].info || {}), {}, {
|
|
936
|
+
tenantName: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_name,
|
|
937
|
+
tenantId: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_id,
|
|
938
|
+
tenantSlug: tenantSlug,
|
|
939
|
+
marketplaceSlug: marketplaceSlug,
|
|
940
|
+
marketplaceId: objectId,
|
|
941
|
+
marketplaceHash: versionHash,
|
|
942
|
+
order: Configuration.__MARKETPLACE_ORDER.findIndex(function (slug) {
|
|
943
|
+
return slug === marketplaceSlug;
|
|
944
|
+
})
|
|
945
|
+
});
|
|
946
|
+
availableMarketplacesById[objectId] = availableMarketplaces[tenantSlug][marketplaceSlug];
|
|
947
|
+
_this4.marketplaceHashes[objectId] = versionHash;
|
|
1053
948
|
|
|
1054
|
-
|
|
1055
|
-
|
|
949
|
+
// Fill out selected marketplace info
|
|
950
|
+
if (_this4.selectedMarketplaceInfo) {
|
|
951
|
+
if (_this4.selectedMarketplaceInfo.tenantSlug === tenantSlug && _this4.selectedMarketplaceInfo.marketplaceSlug === marketplaceSlug || _this4.selectedMarketplaceInfo.marketplaceId === objectId) {
|
|
952
|
+
_this4.selectedMarketplaceInfo = availableMarketplaces[tenantSlug][marketplaceSlug];
|
|
953
|
+
}
|
|
1056
954
|
}
|
|
955
|
+
} catch (error) {
|
|
956
|
+
_this4.Log("Eluvio Wallet Client: Unable to load info for marketplace ".concat(tenantSlug, "/").concat(marketplaceSlug), true);
|
|
1057
957
|
}
|
|
1058
958
|
});
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
if (previewMarketplaceMetadata) {
|
|
1062
|
-
_context12.next = 17;
|
|
1063
|
-
break;
|
|
959
|
+
} catch (error) {
|
|
960
|
+
_this4.Log("Eluvio Wallet Client: Failed to load tenant info ".concat(tenantSlug), true, error);
|
|
1064
961
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
authorizationToken: this.publicStaticToken,
|
|
1072
|
-
noAuth: true,
|
|
1073
|
-
select: ["slug", "info/tenant_id", "info/tenant_name", "info/branding"],
|
|
1074
|
-
remove: ["info/branding/custom_css"]
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
case 15:
|
|
1078
|
-
previewMarketplaceMetadata = _context12.sent;
|
|
1079
|
-
|
|
1080
|
-
if (!previewMarketplaceSlug) {
|
|
1081
|
-
previewMarketplaceSlug = previewMarketplaceMetadata.slug;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
case 17:
|
|
1085
|
-
previewMarketplaceMetadata["."] = {
|
|
1086
|
-
source: this.previewMarketplaceHash
|
|
1087
|
-
};
|
|
1088
|
-
previewMarketplaceMetadata.info["."] = {
|
|
1089
|
-
source: this.previewMarketplaceHash
|
|
1090
|
-
};
|
|
1091
|
-
previewMarketplaceMetadata.info.branding.preview = true;
|
|
1092
|
-
previewMarketplaceMetadata.info.branding.show = true;
|
|
1093
|
-
metadata[previewTenantSlug] = metadata[previewTenantSlug] || {};
|
|
1094
|
-
metadata[previewTenantSlug].marketplaces = metadata[previewTenantSlug].marketplaces || {};
|
|
1095
|
-
metadata[previewTenantSlug].marketplaces[previewMarketplaceSlug] = previewMarketplaceMetadata;
|
|
1096
|
-
|
|
1097
|
-
case 24:
|
|
1098
|
-
availableMarketplaces = _objectSpread({}, this.availableMarketplaces || {});
|
|
1099
|
-
availableMarketplacesById = _objectSpread({}, this.availableMarketplacesById || {});
|
|
1100
|
-
Object.keys(metadata || {}).forEach(function (tenantSlug) {
|
|
1101
|
-
try {
|
|
1102
|
-
availableMarketplaces[tenantSlug] = metadata[tenantSlug]["."] ? {
|
|
1103
|
-
versionHash: metadata[tenantSlug]["."].source
|
|
1104
|
-
} : {};
|
|
1105
|
-
Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
|
|
1106
|
-
try {
|
|
1107
|
-
var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
|
|
1108
|
-
|
|
1109
|
-
var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
|
|
1110
|
-
|
|
1111
|
-
availableMarketplaces[tenantSlug][marketplaceSlug] = _objectSpread(_objectSpread({}, metadata[tenantSlug].marketplaces[marketplaceSlug].info || {}), {}, {
|
|
1112
|
-
tenantName: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_name,
|
|
1113
|
-
tenantId: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_id,
|
|
1114
|
-
tenantSlug: tenantSlug,
|
|
1115
|
-
marketplaceSlug: marketplaceSlug,
|
|
1116
|
-
marketplaceId: objectId,
|
|
1117
|
-
marketplaceHash: versionHash,
|
|
1118
|
-
order: Configuration.__MARKETPLACE_ORDER.findIndex(function (slug) {
|
|
1119
|
-
return slug === marketplaceSlug;
|
|
1120
|
-
})
|
|
1121
|
-
});
|
|
1122
|
-
availableMarketplacesById[objectId] = availableMarketplaces[tenantSlug][marketplaceSlug];
|
|
1123
|
-
_this4.marketplaceHashes[objectId] = versionHash; // Fill out selected marketplace info
|
|
1124
|
-
|
|
1125
|
-
if (_this4.selectedMarketplaceInfo) {
|
|
1126
|
-
if (_this4.selectedMarketplaceInfo.tenantSlug === tenantSlug && _this4.selectedMarketplaceInfo.marketplaceSlug === marketplaceSlug || _this4.selectedMarketplaceInfo.marketplaceId === objectId) {
|
|
1127
|
-
_this4.selectedMarketplaceInfo = availableMarketplaces[tenantSlug][marketplaceSlug];
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
} catch (error) {
|
|
1131
|
-
_this4.Log("Eluvio Wallet Client: Unable to load info for marketplace ".concat(tenantSlug, "/").concat(marketplaceSlug), true);
|
|
1132
|
-
}
|
|
1133
|
-
});
|
|
1134
|
-
} catch (error) {
|
|
1135
|
-
_this4.Log("Eluvio Wallet Client: Failed to load tenant info ".concat(tenantSlug), true, error);
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1138
|
-
this.availableMarketplaces = availableMarketplaces;
|
|
1139
|
-
this.availableMarketplacesById = availableMarketplacesById;
|
|
1140
|
-
|
|
1141
|
-
case 29:
|
|
1142
|
-
case "end":
|
|
1143
|
-
return _context12.stop();
|
|
1144
|
-
}
|
|
962
|
+
});
|
|
963
|
+
this.availableMarketplaces = availableMarketplaces;
|
|
964
|
+
this.availableMarketplacesById = availableMarketplacesById;
|
|
965
|
+
case 29:
|
|
966
|
+
case "end":
|
|
967
|
+
return _context12.stop();
|
|
1145
968
|
}
|
|
1146
969
|
}, _callee12, this);
|
|
1147
970
|
}));
|
|
1148
|
-
|
|
1149
971
|
function LoadAvailableMarketplaces() {
|
|
1150
972
|
return _LoadAvailableMarketplaces.apply(this, arguments);
|
|
1151
973
|
}
|
|
1152
|
-
|
|
1153
974
|
return LoadAvailableMarketplaces;
|
|
1154
975
|
}() // Get the hash of the currently linked marketplace
|
|
1155
|
-
|
|
1156
976
|
}, {
|
|
1157
977
|
key: "LatestMarketplaceHash",
|
|
1158
978
|
value: function () {
|
|
1159
979
|
var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref12) {
|
|
1160
980
|
var marketplaceParams, marketplaceInfo, mainSiteHash, marketplaceLink;
|
|
1161
981
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1162
|
-
while (1) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
case 11:
|
|
1197
|
-
marketplaceLink = _context13.sent;
|
|
1198
|
-
return _context13.abrupt("return", LinkTargetHash(marketplaceLink));
|
|
1199
|
-
|
|
1200
|
-
case 13:
|
|
1201
|
-
case "end":
|
|
1202
|
-
return _context13.stop();
|
|
1203
|
-
}
|
|
982
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
983
|
+
case 0:
|
|
984
|
+
marketplaceParams = _ref12.marketplaceParams;
|
|
985
|
+
_context13.next = 3;
|
|
986
|
+
return this.MarketplaceInfo({
|
|
987
|
+
marketplaceParams: marketplaceParams
|
|
988
|
+
});
|
|
989
|
+
case 3:
|
|
990
|
+
marketplaceInfo = _context13.sent;
|
|
991
|
+
if (!(this.previewMarketplaceId && this.previewMarketplaceId === marketplaceInfo.marketplaceId)) {
|
|
992
|
+
_context13.next = 6;
|
|
993
|
+
break;
|
|
994
|
+
}
|
|
995
|
+
return _context13.abrupt("return", this.availableMarketplaces[marketplaceInfo.tenantSlug][marketplaceInfo.marketplaceSlug]["."].source);
|
|
996
|
+
case 6:
|
|
997
|
+
_context13.next = 8;
|
|
998
|
+
return this.client.LatestVersionHash({
|
|
999
|
+
objectId: this.mainSiteId
|
|
1000
|
+
});
|
|
1001
|
+
case 8:
|
|
1002
|
+
mainSiteHash = _context13.sent;
|
|
1003
|
+
_context13.next = 11;
|
|
1004
|
+
return this.client.ContentObjectMetadata({
|
|
1005
|
+
versionHash: mainSiteHash,
|
|
1006
|
+
metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "marketplaces", marketplaceInfo.marketplaceSlug),
|
|
1007
|
+
resolveLinks: false
|
|
1008
|
+
});
|
|
1009
|
+
case 11:
|
|
1010
|
+
marketplaceLink = _context13.sent;
|
|
1011
|
+
return _context13.abrupt("return", LinkTargetHash(marketplaceLink));
|
|
1012
|
+
case 13:
|
|
1013
|
+
case "end":
|
|
1014
|
+
return _context13.stop();
|
|
1204
1015
|
}
|
|
1205
1016
|
}, _callee13, this);
|
|
1206
1017
|
}));
|
|
1207
|
-
|
|
1208
1018
|
function LatestMarketplaceHash(_x16) {
|
|
1209
1019
|
return _LatestMarketplaceHash.apply(this, arguments);
|
|
1210
1020
|
}
|
|
1211
|
-
|
|
1212
1021
|
return LatestMarketplaceHash;
|
|
1213
1022
|
}()
|
|
1214
1023
|
}, {
|
|
@@ -1216,164 +1025,137 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1216
1025
|
value: function () {
|
|
1217
1026
|
var _LoadMarketplace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(marketplaceParams) {
|
|
1218
1027
|
var _this5 = this;
|
|
1219
|
-
|
|
1220
1028
|
var marketplaceInfo, marketplaceId, marketplaceHash, marketplace;
|
|
1221
1029
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1222
|
-
while (1) {
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1265
|
-
while (1) {
|
|
1266
|
-
switch (_context14.prev = _context14.next) {
|
|
1267
|
-
case 0:
|
|
1268
|
-
if (!item.requires_permissions) {
|
|
1269
|
-
_context14.next = 14;
|
|
1270
|
-
break;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
if (_this5.loggedIn) {
|
|
1274
|
-
_context14.next = 5;
|
|
1275
|
-
break;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
_context14.next = 4;
|
|
1279
|
-
return _this5.client.CreateFabricToken({});
|
|
1280
|
-
|
|
1281
|
-
case 4:
|
|
1282
|
-
authorizationToken = _context14.sent;
|
|
1283
|
-
|
|
1284
|
-
case 5:
|
|
1285
|
-
_context14.prev = 5;
|
|
1286
|
-
_context14.next = 8;
|
|
1287
|
-
return _this5.client.ContentObjectMetadata({
|
|
1288
|
-
versionHash: LinkTargetHash(item.nft_template),
|
|
1289
|
-
metadataSubtree: "permissioned",
|
|
1290
|
-
authorizationToken: authorizationToken
|
|
1291
|
-
});
|
|
1292
|
-
|
|
1293
|
-
case 8:
|
|
1294
|
-
item.authorized = true;
|
|
1295
|
-
_context14.next = 14;
|
|
1296
|
-
break;
|
|
1297
|
-
|
|
1298
|
-
case 11:
|
|
1299
|
-
_context14.prev = 11;
|
|
1300
|
-
_context14.t0 = _context14["catch"](5);
|
|
1301
|
-
item.authorized = false;
|
|
1302
|
-
|
|
1303
|
-
case 14:
|
|
1304
|
-
item.nftTemplateMetadata = (item.nft_template || {}).nft || {};
|
|
1305
|
-
item.nftTemplateHash = ((item.nft_template || {})["."] || {}).source;
|
|
1306
|
-
item.itemIndex = index;
|
|
1307
|
-
return _context14.abrupt("return", item);
|
|
1308
|
-
|
|
1309
|
-
case 18:
|
|
1310
|
-
case "end":
|
|
1311
|
-
return _context14.stop();
|
|
1030
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1031
|
+
case 0:
|
|
1032
|
+
marketplaceInfo = this.MarketplaceInfo({
|
|
1033
|
+
marketplaceParams: marketplaceParams
|
|
1034
|
+
});
|
|
1035
|
+
marketplaceId = marketplaceInfo.marketplaceId;
|
|
1036
|
+
_context15.next = 4;
|
|
1037
|
+
return this.LatestMarketplaceHash({
|
|
1038
|
+
marketplaceParams: marketplaceParams
|
|
1039
|
+
});
|
|
1040
|
+
case 4:
|
|
1041
|
+
marketplaceHash = _context15.sent;
|
|
1042
|
+
if (this.cachedMarketplaces[marketplaceId] && this.cachedMarketplaces[marketplaceId].versionHash !== marketplaceHash) {
|
|
1043
|
+
delete this.cachedMarketplaces[marketplaceId];
|
|
1044
|
+
}
|
|
1045
|
+
if (this.cachedMarketplaces[marketplaceId]) {
|
|
1046
|
+
_context15.next = 21;
|
|
1047
|
+
break;
|
|
1048
|
+
}
|
|
1049
|
+
_context15.next = 9;
|
|
1050
|
+
return this.client.ContentObjectMetadata({
|
|
1051
|
+
versionHash: marketplaceHash,
|
|
1052
|
+
metadataSubtree: "public/asset_metadata/info",
|
|
1053
|
+
linkDepthLimit: 1,
|
|
1054
|
+
resolveLinks: true,
|
|
1055
|
+
resolveIgnoreErrors: true,
|
|
1056
|
+
resolveIncludeSource: true,
|
|
1057
|
+
produceLinkUrls: true,
|
|
1058
|
+
authorizationToken: this.publicStaticToken
|
|
1059
|
+
});
|
|
1060
|
+
case 9:
|
|
1061
|
+
marketplace = _context15.sent;
|
|
1062
|
+
_context15.next = 12;
|
|
1063
|
+
return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
|
|
1064
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(item, index) {
|
|
1065
|
+
var authorizationToken;
|
|
1066
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1067
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1068
|
+
case 0:
|
|
1069
|
+
if (!item.requires_permissions) {
|
|
1070
|
+
_context14.next = 14;
|
|
1071
|
+
break;
|
|
1312
1072
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
} catch (error) {}
|
|
1073
|
+
if (_this5.loggedIn) {
|
|
1074
|
+
_context14.next = 5;
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
_context14.next = 4;
|
|
1078
|
+
return _this5.client.CreateFabricToken({});
|
|
1079
|
+
case 4:
|
|
1080
|
+
authorizationToken = _context14.sent;
|
|
1081
|
+
case 5:
|
|
1082
|
+
_context14.prev = 5;
|
|
1083
|
+
_context14.next = 8;
|
|
1084
|
+
return _this5.client.ContentObjectMetadata({
|
|
1085
|
+
versionHash: LinkTargetHash(item.nft_template),
|
|
1086
|
+
metadataSubtree: "permissioned",
|
|
1087
|
+
authorizationToken: authorizationToken
|
|
1088
|
+
});
|
|
1089
|
+
case 8:
|
|
1090
|
+
item.authorized = true;
|
|
1091
|
+
_context14.next = 14;
|
|
1092
|
+
break;
|
|
1093
|
+
case 11:
|
|
1094
|
+
_context14.prev = 11;
|
|
1095
|
+
_context14.t0 = _context14["catch"](5);
|
|
1096
|
+
item.authorized = false;
|
|
1097
|
+
case 14:
|
|
1098
|
+
item.nftTemplateMetadata = (item.nft_template || {}).nft || {};
|
|
1099
|
+
item.nftTemplateHash = ((item.nft_template || {})["."] || {}).source;
|
|
1100
|
+
item.itemIndex = index;
|
|
1101
|
+
return _context14.abrupt("return", item);
|
|
1102
|
+
case 18:
|
|
1103
|
+
case "end":
|
|
1104
|
+
return _context14.stop();
|
|
1105
|
+
}
|
|
1106
|
+
}, _callee14, null, [[5, 11]]);
|
|
1107
|
+
}));
|
|
1108
|
+
return function (_x18, _x19) {
|
|
1109
|
+
return _ref13.apply(this, arguments);
|
|
1110
|
+
};
|
|
1111
|
+
}()));
|
|
1112
|
+
case 12:
|
|
1113
|
+
marketplace.items = _context15.sent;
|
|
1114
|
+
marketplace.collections = (marketplace.collections || []).map(function (collection, collectionIndex) {
|
|
1115
|
+
return _objectSpread(_objectSpread({}, collection), {}, {
|
|
1116
|
+
collectionIndex: collectionIndex
|
|
1359
1117
|
});
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1118
|
+
});
|
|
1119
|
+
marketplace.retrievedAt = Date.now();
|
|
1120
|
+
marketplace.marketplaceId = marketplaceId;
|
|
1121
|
+
marketplace.versionHash = marketplaceHash;
|
|
1122
|
+
marketplace.marketplaceHash = marketplaceHash;
|
|
1123
|
+
if (this.previewMarketplaceId && marketplaceId === this.previewMarketplaceId) {
|
|
1124
|
+
marketplace.branding.preview = true;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// Generate embed URLs for pack opening animations
|
|
1128
|
+
["purchase_animation", "purchase_animation__mobile", "reveal_animation", "reveal_animation_mobile"].forEach(function (key) {
|
|
1129
|
+
try {
|
|
1130
|
+
if (marketplace.storefront[key]) {
|
|
1131
|
+
var embedUrl = new URL("https://embed.v3.contentfabric.io");
|
|
1132
|
+
var targetHash = LinkTargetHash(marketplace.storefront[key]);
|
|
1133
|
+
embedUrl.searchParams.set("p", "");
|
|
1134
|
+
embedUrl.searchParams.set("net", _this5.network === "main" ? "main" : "demo");
|
|
1135
|
+
embedUrl.searchParams.set("ath", (_this5.__authorization || {}).authToken || _this5.publicStaticToken);
|
|
1136
|
+
embedUrl.searchParams.set("vid", targetHash);
|
|
1137
|
+
embedUrl.searchParams.set("ap", "");
|
|
1138
|
+
if (!key.startsWith("reveal")) {
|
|
1139
|
+
embedUrl.searchParams.set("m", "");
|
|
1140
|
+
embedUrl.searchParams.set("lp", "");
|
|
1141
|
+
}
|
|
1142
|
+
marketplace.storefront["".concat(key, "_embed_url")] = embedUrl.toString();
|
|
1143
|
+
}
|
|
1144
|
+
// eslint-disable-next-line no-empty
|
|
1145
|
+
} catch (error) {}
|
|
1146
|
+
});
|
|
1147
|
+
this.cachedMarketplaces[marketplaceId] = marketplace;
|
|
1148
|
+
case 21:
|
|
1149
|
+
return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
|
|
1150
|
+
case 22:
|
|
1151
|
+
case "end":
|
|
1152
|
+
return _context15.stop();
|
|
1369
1153
|
}
|
|
1370
1154
|
}, _callee15, this);
|
|
1371
1155
|
}));
|
|
1372
|
-
|
|
1373
1156
|
function LoadMarketplace(_x17) {
|
|
1374
1157
|
return _LoadMarketplace.apply(this, arguments);
|
|
1375
1158
|
}
|
|
1376
|
-
|
|
1377
1159
|
return LoadMarketplace;
|
|
1378
1160
|
}()
|
|
1379
1161
|
}, {
|
|
@@ -1381,344 +1163,286 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1381
1163
|
value: function () {
|
|
1382
1164
|
var _FilteredQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
1383
1165
|
var _this6 = this;
|
|
1384
|
-
|
|
1385
1166
|
var _ref14,
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1167
|
+
_ref14$mode,
|
|
1168
|
+
mode,
|
|
1169
|
+
_ref14$sortBy,
|
|
1170
|
+
sortBy,
|
|
1171
|
+
_ref14$sortDesc,
|
|
1172
|
+
sortDesc,
|
|
1173
|
+
filter,
|
|
1174
|
+
editionFilters,
|
|
1175
|
+
attributeFilters,
|
|
1176
|
+
contractAddress,
|
|
1177
|
+
tokenId,
|
|
1178
|
+
currency,
|
|
1179
|
+
marketplaceParams,
|
|
1180
|
+
tenantId,
|
|
1181
|
+
collectionIndexes,
|
|
1182
|
+
priceRange,
|
|
1183
|
+
tokenIdRange,
|
|
1184
|
+
capLimit,
|
|
1185
|
+
userAddress,
|
|
1186
|
+
sellerAddress,
|
|
1187
|
+
_ref14$lastNDays,
|
|
1188
|
+
lastNDays,
|
|
1189
|
+
_ref14$includeCheckou,
|
|
1190
|
+
includeCheckoutLocked,
|
|
1191
|
+
_ref14$start,
|
|
1192
|
+
start,
|
|
1193
|
+
_ref14$limit,
|
|
1194
|
+
limit,
|
|
1195
|
+
params,
|
|
1196
|
+
marketplaceInfo,
|
|
1197
|
+
marketplace,
|
|
1198
|
+
filters,
|
|
1199
|
+
path,
|
|
1200
|
+
_ref16,
|
|
1201
|
+
contents,
|
|
1202
|
+
paging,
|
|
1203
|
+
_args16 = arguments;
|
|
1424
1204
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1425
|
-
while (1) {
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
if (sellerAddress) {
|
|
1481
|
-
filters.push("seller:eq:".concat(this.client.utils.FormatAddress(sellerAddress)));
|
|
1482
|
-
} else if (userAddress && mode !== "owned") {
|
|
1483
|
-
filters.push("addr:eq:".concat(this.client.utils.FormatAddress(userAddress)));
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
if (marketplace && collectionIndexes.length >= 0) {
|
|
1487
|
-
collectionIndexes.forEach(function (collectionIndex) {
|
|
1488
|
-
var collection = marketplace.collections[collectionIndex];
|
|
1489
|
-
collection.items.forEach(function (sku) {
|
|
1490
|
-
if (!sku) {
|
|
1491
|
-
return;
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
var item = marketplace.items.find(function (item) {
|
|
1495
|
-
return item.sku === sku;
|
|
1496
|
-
});
|
|
1497
|
-
|
|
1498
|
-
if (!item) {
|
|
1499
|
-
return;
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
var address = Utils.SafeTraverse(item, "nft_template", "nft", "address");
|
|
1503
|
-
|
|
1504
|
-
if (address) {
|
|
1505
|
-
filters.push("".concat(mode === "owned" ? "contract_addr" : "contract", ":eq:").concat(Utils.FormatAddress(address)));
|
|
1506
|
-
}
|
|
1507
|
-
});
|
|
1508
|
-
});
|
|
1509
|
-
} else if (marketplaceInfo || tenantId) {
|
|
1510
|
-
filters.push("tenant:eq:".concat(marketplaceInfo ? marketplaceInfo.tenantId : tenantId));
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
if (contractAddress) {
|
|
1514
|
-
if (mode === "owned") {
|
|
1515
|
-
filters.push("contract_addr:eq:".concat(Utils.FormatAddress(contractAddress)));
|
|
1516
|
-
} else {
|
|
1517
|
-
filters.push("contract:eq:".concat(Utils.FormatAddress(contractAddress)));
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
if (tokenId) {
|
|
1521
|
-
filters.push("token:eq:".concat(tokenId));
|
|
1522
|
-
}
|
|
1523
|
-
} else if (filter) {
|
|
1524
|
-
if (mode.includes("listing")) {
|
|
1525
|
-
filters.push("nft/display_name:eq:".concat(filter));
|
|
1526
|
-
} else if (mode === "owned") {
|
|
1527
|
-
filters.push("meta/display_name:eq:".concat(filter));
|
|
1528
|
-
} else {
|
|
1529
|
-
filters.push("name:eq:".concat(filter));
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
if (editionFilters) {
|
|
1534
|
-
editionFilters.forEach(function (editionFilter) {
|
|
1535
|
-
if (mode.includes("listing")) {
|
|
1536
|
-
filters.push("nft/edition_name:eq:".concat(editionFilter));
|
|
1537
|
-
} else if (mode === "owned") {
|
|
1538
|
-
filters.push("meta:@>:{\"edition_name\":\"".concat(editionFilter, "\"}"));
|
|
1539
|
-
params.exact = false;
|
|
1540
|
-
} else {
|
|
1541
|
-
filters.push("edition:eq:".concat(editionFilter));
|
|
1205
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1206
|
+
case 0:
|
|
1207
|
+
_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, editionFilters = _ref14.editionFilters, attributeFilters = _ref14.attributeFilters, contractAddress = _ref14.contractAddress, tokenId = _ref14.tokenId, currency = _ref14.currency, marketplaceParams = _ref14.marketplaceParams, tenantId = _ref14.tenantId, collectionIndexes = _ref14.collectionIndexes, priceRange = _ref14.priceRange, tokenIdRange = _ref14.tokenIdRange, capLimit = _ref14.capLimit, userAddress = _ref14.userAddress, sellerAddress = _ref14.sellerAddress, _ref14$lastNDays = _ref14.lastNDays, lastNDays = _ref14$lastNDays === void 0 ? -1 : _ref14$lastNDays, _ref14$includeCheckou = _ref14.includeCheckoutLocked, includeCheckoutLocked = _ref14$includeCheckou === void 0 ? false : _ref14$includeCheckou, _ref14$start = _ref14.start, start = _ref14$start === void 0 ? 0 : _ref14$start, _ref14$limit = _ref14.limit, limit = _ref14$limit === void 0 ? 50 : _ref14$limit;
|
|
1208
|
+
collectionIndexes = (collectionIndexes || []).map(function (i) {
|
|
1209
|
+
return parseInt(i);
|
|
1210
|
+
});
|
|
1211
|
+
params = {
|
|
1212
|
+
start: start,
|
|
1213
|
+
limit: limit,
|
|
1214
|
+
sort_descending: sortDesc
|
|
1215
|
+
}; // Created isn't a valid sort mode for owned
|
|
1216
|
+
if (mode === "owned" && sortBy === "created") {
|
|
1217
|
+
sortBy = "default";
|
|
1218
|
+
}
|
|
1219
|
+
if (mode !== "leaderboard") {
|
|
1220
|
+
params.sort_by = sortBy;
|
|
1221
|
+
}
|
|
1222
|
+
if (mode.includes("listings") && includeCheckoutLocked) {
|
|
1223
|
+
params.checkout = true;
|
|
1224
|
+
}
|
|
1225
|
+
if (!marketplaceParams) {
|
|
1226
|
+
_context16.next = 14;
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1229
|
+
_context16.next = 9;
|
|
1230
|
+
return this.MarketplaceInfo({
|
|
1231
|
+
marketplaceParams: marketplaceParams
|
|
1232
|
+
});
|
|
1233
|
+
case 9:
|
|
1234
|
+
marketplaceInfo = _context16.sent;
|
|
1235
|
+
if (!(collectionIndexes.length > 0)) {
|
|
1236
|
+
_context16.next = 14;
|
|
1237
|
+
break;
|
|
1238
|
+
}
|
|
1239
|
+
_context16.next = 13;
|
|
1240
|
+
return this.Marketplace({
|
|
1241
|
+
marketplaceParams: marketplaceParams
|
|
1242
|
+
});
|
|
1243
|
+
case 13:
|
|
1244
|
+
marketplace = _context16.sent;
|
|
1245
|
+
case 14:
|
|
1246
|
+
_context16.prev = 14;
|
|
1247
|
+
filters = [];
|
|
1248
|
+
if (sellerAddress) {
|
|
1249
|
+
filters.push("seller:eq:".concat(this.client.utils.FormatAddress(sellerAddress)));
|
|
1250
|
+
} else if (userAddress && mode !== "owned") {
|
|
1251
|
+
filters.push("addr:eq:".concat(this.client.utils.FormatAddress(userAddress)));
|
|
1252
|
+
}
|
|
1253
|
+
if (marketplace && collectionIndexes.length >= 0) {
|
|
1254
|
+
collectionIndexes.forEach(function (collectionIndex) {
|
|
1255
|
+
var collection = marketplace.collections[collectionIndex];
|
|
1256
|
+
collection.items.forEach(function (sku) {
|
|
1257
|
+
if (!sku) {
|
|
1258
|
+
return;
|
|
1542
1259
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
attributeFilters.map(function (_ref15) {
|
|
1548
|
-
var name = _ref15.name,
|
|
1549
|
-
value = _ref15.value;
|
|
1550
|
-
|
|
1551
|
-
if (!name || !value) {
|
|
1260
|
+
var item = marketplace.items.find(function (item) {
|
|
1261
|
+
return item.sku === sku;
|
|
1262
|
+
});
|
|
1263
|
+
if (!item) {
|
|
1552
1264
|
return;
|
|
1553
1265
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1266
|
+
var address = Utils.SafeTraverse(item, "nft_template", "nft", "address");
|
|
1267
|
+
if (address) {
|
|
1268
|
+
filters.push("".concat(mode === "owned" ? "contract_addr" : "contract", ":eq:").concat(Utils.FormatAddress(address)));
|
|
1269
|
+
}
|
|
1556
1270
|
});
|
|
1271
|
+
});
|
|
1272
|
+
} else if (marketplaceInfo || tenantId) {
|
|
1273
|
+
filters.push("tenant:eq:".concat(marketplaceInfo ? marketplaceInfo.tenantId : tenantId));
|
|
1274
|
+
}
|
|
1275
|
+
if (contractAddress) {
|
|
1276
|
+
if (mode === "owned") {
|
|
1277
|
+
filters.push("contract_addr:eq:".concat(Utils.FormatAddress(contractAddress)));
|
|
1278
|
+
} else {
|
|
1279
|
+
filters.push("contract:eq:".concat(Utils.FormatAddress(contractAddress)));
|
|
1557
1280
|
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
filters.push("link_type:eq:sol");
|
|
1281
|
+
if (tokenId) {
|
|
1282
|
+
filters.push("token:eq:".concat(tokenId));
|
|
1561
1283
|
}
|
|
1562
|
-
|
|
1563
|
-
if (
|
|
1564
|
-
filters.push("
|
|
1284
|
+
} else if (filter) {
|
|
1285
|
+
if (mode.includes("listing")) {
|
|
1286
|
+
filters.push("nft/display_name:eq:".concat(filter));
|
|
1287
|
+
} else if (mode === "owned") {
|
|
1288
|
+
filters.push("meta/display_name:eq:".concat(filter));
|
|
1289
|
+
} else {
|
|
1290
|
+
filters.push("name:eq:".concat(filter));
|
|
1565
1291
|
}
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
if (tokenIdRange) {
|
|
1578
|
-
if (tokenIdRange.min) {
|
|
1579
|
-
filters.push("info/token_id:ge:".concat(parseInt(tokenIdRange.min)));
|
|
1292
|
+
}
|
|
1293
|
+
if (editionFilters) {
|
|
1294
|
+
editionFilters.forEach(function (editionFilter) {
|
|
1295
|
+
if (mode.includes("listing")) {
|
|
1296
|
+
filters.push("nft/edition_name:eq:".concat(editionFilter));
|
|
1297
|
+
} else if (mode === "owned") {
|
|
1298
|
+
filters.push("meta:@>:{\"edition_name\":\"".concat(editionFilter, "\"}"));
|
|
1299
|
+
params.exact = false;
|
|
1300
|
+
} else {
|
|
1301
|
+
filters.push("edition:eq:".concat(editionFilter));
|
|
1580
1302
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
if (attributeFilters) {
|
|
1306
|
+
attributeFilters.map(function (_ref15) {
|
|
1307
|
+
var name = _ref15.name,
|
|
1308
|
+
value = _ref15.value;
|
|
1309
|
+
if (!name || !value) {
|
|
1310
|
+
return;
|
|
1584
1311
|
}
|
|
1312
|
+
filters.push("nft/attributes/".concat(name, ":eq:").concat(value));
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
if (currency) {
|
|
1316
|
+
filters.push("link_type:eq:sol");
|
|
1317
|
+
}
|
|
1318
|
+
if (lastNDays && lastNDays > 0) {
|
|
1319
|
+
filters.push("created:gt:".concat((Date.now() / 1000 - lastNDays * 24 * 60 * 60).toFixed(0)));
|
|
1320
|
+
}
|
|
1321
|
+
if (priceRange) {
|
|
1322
|
+
if (priceRange.min) {
|
|
1323
|
+
filters.push("price:ge:".concat(parseFloat(priceRange.min)));
|
|
1585
1324
|
}
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
filters.push("info/cap:le:".concat(parseInt(capLimit)));
|
|
1325
|
+
if (priceRange.max) {
|
|
1326
|
+
filters.push("price:le:".concat(parseFloat(priceRange.max)));
|
|
1589
1327
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
case 29:
|
|
1596
|
-
path = UrlJoin("as", "wlt", userAddress || this.UserAddress());
|
|
1597
|
-
return _context16.abrupt("break", 48);
|
|
1598
|
-
|
|
1599
|
-
case 31:
|
|
1600
|
-
path = UrlJoin("as", "mkt", "f");
|
|
1601
|
-
return _context16.abrupt("break", 48);
|
|
1602
|
-
|
|
1603
|
-
case 33:
|
|
1604
|
-
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1605
|
-
filters.push("action:eq:TRANSFERRED");
|
|
1606
|
-
filters.push("action:eq:SOLD");
|
|
1607
|
-
return _context16.abrupt("break", 48);
|
|
1608
|
-
|
|
1609
|
-
case 37:
|
|
1610
|
-
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1611
|
-
filters.push("action:eq:SOLD");
|
|
1612
|
-
filters.push("seller:co:0x");
|
|
1613
|
-
return _context16.abrupt("break", 48);
|
|
1614
|
-
|
|
1615
|
-
case 41:
|
|
1616
|
-
path = UrlJoin("as", "mkt", "stats", "listed");
|
|
1617
|
-
return _context16.abrupt("break", 48);
|
|
1618
|
-
|
|
1619
|
-
case 43:
|
|
1620
|
-
path = UrlJoin("as", "mkt", "stats", "sold");
|
|
1621
|
-
filters.push("seller:co:0x");
|
|
1622
|
-
return _context16.abrupt("break", 48);
|
|
1623
|
-
|
|
1624
|
-
case 46:
|
|
1625
|
-
path = UrlJoin("as", "wlt", "leaders");
|
|
1626
|
-
return _context16.abrupt("break", 48);
|
|
1627
|
-
|
|
1628
|
-
case 48:
|
|
1629
|
-
if (filters.length > 0) {
|
|
1630
|
-
params.filter = filters;
|
|
1328
|
+
}
|
|
1329
|
+
if (tokenIdRange) {
|
|
1330
|
+
if (tokenIdRange.min) {
|
|
1331
|
+
filters.push("info/token_id:ge:".concat(parseInt(tokenIdRange.min)));
|
|
1631
1332
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
_context16.next = 53;
|
|
1635
|
-
break;
|
|
1333
|
+
if (tokenIdRange.max) {
|
|
1334
|
+
filters.push("info/token_id:le:".concat(parseInt(tokenIdRange.max)));
|
|
1636
1335
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1336
|
+
}
|
|
1337
|
+
if (capLimit) {
|
|
1338
|
+
filters.push("info/cap:le:".concat(parseInt(capLimit)));
|
|
1339
|
+
}
|
|
1340
|
+
_context16.t0 = mode;
|
|
1341
|
+
_context16.next = _context16.t0 === "owned" ? 29 : _context16.t0 === "listings" ? 31 : _context16.t0 === "transfers" ? 33 : _context16.t0 === "sales" ? 37 : _context16.t0 === "listing-stats" ? 41 : _context16.t0 === "sales-stats" ? 43 : _context16.t0 === "leaderboard" ? 46 : 48;
|
|
1342
|
+
break;
|
|
1343
|
+
case 29:
|
|
1344
|
+
path = UrlJoin("as", "wlt", userAddress || this.UserAddress());
|
|
1345
|
+
return _context16.abrupt("break", 48);
|
|
1346
|
+
case 31:
|
|
1347
|
+
path = UrlJoin("as", "mkt", "f");
|
|
1348
|
+
return _context16.abrupt("break", 48);
|
|
1349
|
+
case 33:
|
|
1350
|
+
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1351
|
+
filters.push("action:eq:TRANSFERRED");
|
|
1352
|
+
filters.push("action:eq:SOLD");
|
|
1353
|
+
return _context16.abrupt("break", 48);
|
|
1354
|
+
case 37:
|
|
1355
|
+
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1356
|
+
filters.push("action:eq:SOLD");
|
|
1357
|
+
filters.push("seller:co:0x");
|
|
1358
|
+
return _context16.abrupt("break", 48);
|
|
1359
|
+
case 41:
|
|
1360
|
+
path = UrlJoin("as", "mkt", "stats", "listed");
|
|
1361
|
+
return _context16.abrupt("break", 48);
|
|
1362
|
+
case 43:
|
|
1363
|
+
path = UrlJoin("as", "mkt", "stats", "sold");
|
|
1364
|
+
filters.push("seller:co:0x");
|
|
1365
|
+
return _context16.abrupt("break", 48);
|
|
1366
|
+
case 46:
|
|
1367
|
+
path = UrlJoin("as", "wlt", "leaders");
|
|
1368
|
+
return _context16.abrupt("break", 48);
|
|
1369
|
+
case 48:
|
|
1370
|
+
if (filters.length > 0) {
|
|
1371
|
+
params.filter = filters;
|
|
1372
|
+
}
|
|
1373
|
+
if (!mode.includes("stats")) {
|
|
1374
|
+
_context16.next = 53;
|
|
1375
|
+
break;
|
|
1376
|
+
}
|
|
1377
|
+
_context16.next = 52;
|
|
1378
|
+
return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
|
|
1379
|
+
path: path,
|
|
1380
|
+
method: "GET",
|
|
1381
|
+
queryParams: params
|
|
1382
|
+
}));
|
|
1383
|
+
case 52:
|
|
1384
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1385
|
+
case 53:
|
|
1386
|
+
_context16.t2 = Utils;
|
|
1387
|
+
_context16.next = 56;
|
|
1388
|
+
return this.client.authClient.MakeAuthServiceRequest({
|
|
1389
|
+
path: path,
|
|
1390
|
+
method: "GET",
|
|
1391
|
+
queryParams: params
|
|
1392
|
+
});
|
|
1393
|
+
case 56:
|
|
1394
|
+
_context16.t3 = _context16.sent;
|
|
1395
|
+
_context16.next = 59;
|
|
1396
|
+
return _context16.t2.ResponseToJson.call(_context16.t2, _context16.t3);
|
|
1397
|
+
case 59:
|
|
1398
|
+
_context16.t1 = _context16.sent;
|
|
1399
|
+
if (_context16.t1) {
|
|
1400
|
+
_context16.next = 62;
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
_context16.t1 = [];
|
|
1404
|
+
case 62:
|
|
1405
|
+
_ref16 = _context16.t1;
|
|
1406
|
+
contents = _ref16.contents;
|
|
1407
|
+
paging = _ref16.paging;
|
|
1408
|
+
return _context16.abrupt("return", {
|
|
1409
|
+
paging: {
|
|
1410
|
+
start: params.start,
|
|
1411
|
+
limit: params.limit,
|
|
1412
|
+
total: paging.total,
|
|
1413
|
+
more: paging.total > start + limit
|
|
1414
|
+
},
|
|
1415
|
+
results: (contents || []).map(function (item) {
|
|
1416
|
+
return ["owned", "listings"].includes(mode) ? FormatNFT(_this6, item) : item;
|
|
1417
|
+
})
|
|
1418
|
+
});
|
|
1419
|
+
case 68:
|
|
1420
|
+
_context16.prev = 68;
|
|
1421
|
+
_context16.t4 = _context16["catch"](14);
|
|
1422
|
+
if (!(_context16.t4.status && _context16.t4.status.toString() === "404")) {
|
|
1423
|
+
_context16.next = 72;
|
|
1424
|
+
break;
|
|
1425
|
+
}
|
|
1426
|
+
return _context16.abrupt("return", {
|
|
1427
|
+
paging: {
|
|
1428
|
+
start: params.start,
|
|
1429
|
+
limit: params.limit,
|
|
1430
|
+
total: 0,
|
|
1431
|
+
more: false
|
|
1432
|
+
},
|
|
1433
|
+
results: []
|
|
1434
|
+
});
|
|
1435
|
+
case 72:
|
|
1436
|
+
throw _context16.t4;
|
|
1437
|
+
case 73:
|
|
1438
|
+
case "end":
|
|
1439
|
+
return _context16.stop();
|
|
1714
1440
|
}
|
|
1715
1441
|
}, _callee16, this, [[14, 68]]);
|
|
1716
1442
|
}));
|
|
1717
|
-
|
|
1718
1443
|
function FilteredQuery() {
|
|
1719
1444
|
return _FilteredQuery.apply(this, arguments);
|
|
1720
1445
|
}
|
|
1721
|
-
|
|
1722
1446
|
return FilteredQuery;
|
|
1723
1447
|
}()
|
|
1724
1448
|
}, {
|
|
@@ -1727,99 +1451,83 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1727
1451
|
var _MintingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref17) {
|
|
1728
1452
|
var marketplaceParams, tenantId, marketplaceInfo, response;
|
|
1729
1453
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1730
|
-
while (1) {
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1454
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1455
|
+
case 0:
|
|
1456
|
+
marketplaceParams = _ref17.marketplaceParams, tenantId = _ref17.tenantId;
|
|
1457
|
+
if (tenantId) {
|
|
1458
|
+
_context17.next = 6;
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
_context17.next = 4;
|
|
1462
|
+
return this.MarketplaceInfo({
|
|
1463
|
+
marketplaceParams: marketplaceParams || this.selectedMarketplaceInfo
|
|
1464
|
+
});
|
|
1465
|
+
case 4:
|
|
1466
|
+
marketplaceInfo = _context17.sent;
|
|
1467
|
+
tenantId = marketplaceInfo.tenantId;
|
|
1468
|
+
case 6:
|
|
1469
|
+
_context17.prev = 6;
|
|
1470
|
+
_context17.next = 9;
|
|
1471
|
+
return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
|
|
1472
|
+
path: UrlJoin("as", "wlt", "status", "act", tenantId),
|
|
1473
|
+
method: "GET",
|
|
1474
|
+
headers: {
|
|
1475
|
+
Authorization: "Bearer ".concat(this.AuthToken())
|
|
1738
1476
|
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
}));
|
|
1759
|
-
|
|
1760
|
-
case 9:
|
|
1761
|
-
response = _context17.sent;
|
|
1762
|
-
return _context17.abrupt("return", response.map(function (status) {
|
|
1763
|
-
var _status$op$split = status.op.split(":"),
|
|
1764
|
-
_status$op$split2 = _slicedToArray(_status$op$split, 3),
|
|
1765
|
-
op = _status$op$split2[0],
|
|
1766
|
-
address = _status$op$split2[1],
|
|
1767
|
-
id = _status$op$split2[2];
|
|
1768
|
-
|
|
1769
|
-
address = address.startsWith("0x") ? Utils.FormatAddress(address) : address;
|
|
1770
|
-
var confirmationId, tokenId;
|
|
1771
|
-
|
|
1772
|
-
if (op === "nft-buy") {
|
|
1773
|
-
confirmationId = id;
|
|
1774
|
-
} else if (op === "nft-claim") {
|
|
1775
|
-
confirmationId = id;
|
|
1776
|
-
status.marketplaceId = address;
|
|
1777
|
-
|
|
1778
|
-
if (status.extra && status.extra["0"]) {
|
|
1779
|
-
address = status.extra.token_addr;
|
|
1780
|
-
tokenId = status.extra.token_id_str;
|
|
1781
|
-
}
|
|
1782
|
-
} else if (op === "nft-redeem") {
|
|
1783
|
-
confirmationId = status.op.split(":").slice(-1)[0];
|
|
1784
|
-
} else {
|
|
1785
|
-
tokenId = id;
|
|
1477
|
+
}));
|
|
1478
|
+
case 9:
|
|
1479
|
+
response = _context17.sent;
|
|
1480
|
+
return _context17.abrupt("return", response.map(function (status) {
|
|
1481
|
+
var _status$op$split = status.op.split(":"),
|
|
1482
|
+
_status$op$split2 = _slicedToArray(_status$op$split, 3),
|
|
1483
|
+
op = _status$op$split2[0],
|
|
1484
|
+
address = _status$op$split2[1],
|
|
1485
|
+
id = _status$op$split2[2];
|
|
1486
|
+
address = address.startsWith("0x") ? Utils.FormatAddress(address) : address;
|
|
1487
|
+
var confirmationId, tokenId;
|
|
1488
|
+
if (op === "nft-buy") {
|
|
1489
|
+
confirmationId = id;
|
|
1490
|
+
} else if (op === "nft-claim") {
|
|
1491
|
+
confirmationId = id;
|
|
1492
|
+
status.marketplaceId = address;
|
|
1493
|
+
if (status.extra && status.extra["0"]) {
|
|
1494
|
+
address = status.extra.token_addr;
|
|
1495
|
+
tokenId = status.extra.token_id_str;
|
|
1786
1496
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
})
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1497
|
+
} else if (op === "nft-redeem") {
|
|
1498
|
+
confirmationId = status.op.split(":").slice(-1)[0];
|
|
1499
|
+
} else {
|
|
1500
|
+
tokenId = id;
|
|
1501
|
+
}
|
|
1502
|
+
if (op === "nft-transfer") {
|
|
1503
|
+
confirmationId = status.extra && status.extra.trans_id;
|
|
1504
|
+
}
|
|
1505
|
+
return _objectSpread(_objectSpread({}, status), {}, {
|
|
1506
|
+
timestamp: new Date(status.ts),
|
|
1507
|
+
state: status.state && _typeof(status.state) === "object" ? Object.values(status.state) : status.state,
|
|
1508
|
+
extra: status.extra && _typeof(status.extra) === "object" ? Object.values(status.extra) : status.extra,
|
|
1509
|
+
confirmationId: confirmationId,
|
|
1510
|
+
op: op,
|
|
1511
|
+
address: address,
|
|
1512
|
+
tokenId: tokenId
|
|
1513
|
+
});
|
|
1514
|
+
}).sort(function (a, b) {
|
|
1515
|
+
return a.ts < b.ts ? 1 : -1;
|
|
1516
|
+
}));
|
|
1517
|
+
case 13:
|
|
1518
|
+
_context17.prev = 13;
|
|
1519
|
+
_context17.t0 = _context17["catch"](6);
|
|
1520
|
+
this.Log("Failed to retrieve minting status", true, _context17.t0);
|
|
1521
|
+
return _context17.abrupt("return", []);
|
|
1522
|
+
case 17:
|
|
1523
|
+
case "end":
|
|
1524
|
+
return _context17.stop();
|
|
1815
1525
|
}
|
|
1816
1526
|
}, _callee17, this, [[6, 13]]);
|
|
1817
1527
|
}));
|
|
1818
|
-
|
|
1819
1528
|
function MintingStatus(_x20) {
|
|
1820
1529
|
return _MintingStatus.apply(this, arguments);
|
|
1821
1530
|
}
|
|
1822
|
-
|
|
1823
1531
|
return MintingStatus;
|
|
1824
1532
|
}()
|
|
1825
1533
|
}], [{
|
|
@@ -1827,153 +1535,120 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1827
1535
|
value: function () {
|
|
1828
1536
|
var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
|
|
1829
1537
|
var client, _ref18$appId, appId, _ref18$network, network, _ref18$mode, mode, marketplaceParams, previewMarketplaceId, _ref18$storeAuthToken, storeAuthToken, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, previewMarketplaceHash, walletClient, url, savedToken;
|
|
1830
|
-
|
|
1831
1538
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1832
|
-
while (1) {
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
client: client,
|
|
1888
|
-
network: network,
|
|
1889
|
-
mode: mode,
|
|
1890
|
-
marketplaceInfo: {
|
|
1891
|
-
tenantSlug: tenantSlug,
|
|
1892
|
-
marketplaceSlug: marketplaceSlug,
|
|
1893
|
-
marketplaceId: marketplaceHash ? client.utils.DecodeVersionHash(marketplaceHash).objectId : marketplaceId,
|
|
1894
|
-
marketplaceHash: marketplaceHash
|
|
1895
|
-
},
|
|
1896
|
-
previewMarketplaceHash: previewMarketplaceHash,
|
|
1897
|
-
storeAuthToken: storeAuthToken
|
|
1898
|
-
});
|
|
1899
|
-
|
|
1900
|
-
if (!(inBrowser && window.location && window.location.href)) {
|
|
1901
|
-
_context18.next = 37;
|
|
1902
|
-
break;
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
url = new URL(window.location.href);
|
|
1906
|
-
|
|
1907
|
-
if (!url.searchParams.get("elvToken")) {
|
|
1908
|
-
_context18.next = 27;
|
|
1909
|
-
break;
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
_context18.next = 23;
|
|
1913
|
-
return walletClient.Authenticate({
|
|
1914
|
-
token: url.searchParams.get("elvToken")
|
|
1915
|
-
});
|
|
1916
|
-
|
|
1917
|
-
case 23:
|
|
1918
|
-
url.searchParams["delete"]("elvToken");
|
|
1919
|
-
window.history.replaceState("", "", url);
|
|
1539
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1540
|
+
case 0:
|
|
1541
|
+
client = _ref18.client, _ref18$appId = _ref18.appId, appId = _ref18$appId === void 0 ? "general" : _ref18$appId, _ref18$network = _ref18.network, network = _ref18$network === void 0 ? "main" : _ref18$network, _ref18$mode = _ref18.mode, mode = _ref18$mode === void 0 ? "production" : _ref18$mode, marketplaceParams = _ref18.marketplaceParams, previewMarketplaceId = _ref18.previewMarketplaceId, _ref18$storeAuthToken = _ref18.storeAuthToken, storeAuthToken = _ref18$storeAuthToken === void 0 ? true : _ref18$storeAuthToken;
|
|
1542
|
+
_ref19 = marketplaceParams || {}, tenantSlug = _ref19.tenantSlug, marketplaceSlug = _ref19.marketplaceSlug, marketplaceId = _ref19.marketplaceId, marketplaceHash = _ref19.marketplaceHash;
|
|
1543
|
+
if (Configuration[network]) {
|
|
1544
|
+
_context18.next = 6;
|
|
1545
|
+
break;
|
|
1546
|
+
}
|
|
1547
|
+
throw Error("ElvWalletClient: Invalid network ".concat(network));
|
|
1548
|
+
case 6:
|
|
1549
|
+
if (Configuration[network][mode]) {
|
|
1550
|
+
_context18.next = 8;
|
|
1551
|
+
break;
|
|
1552
|
+
}
|
|
1553
|
+
throw Error("ElvWalletClient: Invalid mode ".concat(mode));
|
|
1554
|
+
case 8:
|
|
1555
|
+
if (client) {
|
|
1556
|
+
_context18.next = 12;
|
|
1557
|
+
break;
|
|
1558
|
+
}
|
|
1559
|
+
_context18.next = 11;
|
|
1560
|
+
return ElvClient.FromNetworkName({
|
|
1561
|
+
networkName: network,
|
|
1562
|
+
assumeV3: true
|
|
1563
|
+
});
|
|
1564
|
+
case 11:
|
|
1565
|
+
client = _context18.sent;
|
|
1566
|
+
case 12:
|
|
1567
|
+
previewMarketplaceHash = previewMarketplaceId;
|
|
1568
|
+
if (!(previewMarketplaceHash && !previewMarketplaceHash.startsWith("hq__"))) {
|
|
1569
|
+
_context18.next = 17;
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
_context18.next = 16;
|
|
1573
|
+
return client.LatestVersionHash({
|
|
1574
|
+
objectId: previewMarketplaceId
|
|
1575
|
+
});
|
|
1576
|
+
case 16:
|
|
1577
|
+
previewMarketplaceHash = _context18.sent;
|
|
1578
|
+
case 17:
|
|
1579
|
+
walletClient = new ElvWalletClient({
|
|
1580
|
+
appId: appId,
|
|
1581
|
+
client: client,
|
|
1582
|
+
network: network,
|
|
1583
|
+
mode: mode,
|
|
1584
|
+
marketplaceInfo: {
|
|
1585
|
+
tenantSlug: tenantSlug,
|
|
1586
|
+
marketplaceSlug: marketplaceSlug,
|
|
1587
|
+
marketplaceId: marketplaceHash ? client.utils.DecodeVersionHash(marketplaceHash).objectId : marketplaceId,
|
|
1588
|
+
marketplaceHash: marketplaceHash
|
|
1589
|
+
},
|
|
1590
|
+
previewMarketplaceHash: previewMarketplaceHash,
|
|
1591
|
+
storeAuthToken: storeAuthToken
|
|
1592
|
+
});
|
|
1593
|
+
if (!(inBrowser && window.location && window.location.href)) {
|
|
1920
1594
|
_context18.next = 37;
|
|
1921
1595
|
break;
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
return walletClient.Authenticate({
|
|
1940
|
-
token: savedToken
|
|
1941
|
-
});
|
|
1942
|
-
|
|
1943
|
-
case 33:
|
|
1596
|
+
}
|
|
1597
|
+
url = new URL(window.location.href);
|
|
1598
|
+
if (!url.searchParams.get("elvToken")) {
|
|
1599
|
+
_context18.next = 27;
|
|
1600
|
+
break;
|
|
1601
|
+
}
|
|
1602
|
+
_context18.next = 23;
|
|
1603
|
+
return walletClient.Authenticate({
|
|
1604
|
+
token: url.searchParams.get("elvToken")
|
|
1605
|
+
});
|
|
1606
|
+
case 23:
|
|
1607
|
+
url.searchParams["delete"]("elvToken");
|
|
1608
|
+
window.history.replaceState("", "", url);
|
|
1609
|
+
_context18.next = 37;
|
|
1610
|
+
break;
|
|
1611
|
+
case 27:
|
|
1612
|
+
if (!(storeAuthToken && localStorageAvailable)) {
|
|
1944
1613
|
_context18.next = 37;
|
|
1945
1614
|
break;
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1615
|
+
}
|
|
1616
|
+
_context18.prev = 28;
|
|
1617
|
+
// Load saved auth token
|
|
1618
|
+
savedToken = localStorage.getItem("__elv-token-".concat(network));
|
|
1619
|
+
if (!savedToken) {
|
|
1620
|
+
_context18.next = 33;
|
|
1621
|
+
break;
|
|
1622
|
+
}
|
|
1623
|
+
_context18.next = 33;
|
|
1624
|
+
return walletClient.Authenticate({
|
|
1625
|
+
token: savedToken
|
|
1626
|
+
});
|
|
1627
|
+
case 33:
|
|
1628
|
+
_context18.next = 37;
|
|
1629
|
+
break;
|
|
1630
|
+
case 35:
|
|
1631
|
+
_context18.prev = 35;
|
|
1632
|
+
_context18.t0 = _context18["catch"](28);
|
|
1633
|
+
case 37:
|
|
1634
|
+
_context18.next = 39;
|
|
1635
|
+
return walletClient.LoadAvailableMarketplaces();
|
|
1636
|
+
case 39:
|
|
1637
|
+
return _context18.abrupt("return", walletClient);
|
|
1638
|
+
case 40:
|
|
1639
|
+
case "end":
|
|
1640
|
+
return _context18.stop();
|
|
1962
1641
|
}
|
|
1963
1642
|
}, _callee18, null, [[28, 35]]);
|
|
1964
1643
|
}));
|
|
1965
|
-
|
|
1966
1644
|
function Initialize(_x21) {
|
|
1967
1645
|
return _Initialize.apply(this, arguments);
|
|
1968
1646
|
}
|
|
1969
|
-
|
|
1970
1647
|
return Initialize;
|
|
1971
1648
|
}()
|
|
1972
1649
|
}]);
|
|
1973
|
-
|
|
1974
1650
|
return ElvWalletClient;
|
|
1975
1651
|
}();
|
|
1976
|
-
|
|
1977
1652
|
Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
|
|
1978
1653
|
Object.assign(ElvWalletClient.prototype, require("./Profile"));
|
|
1979
1654
|
Object.assign(ElvWalletClient.prototype, require("./Notifications"));
|