@eluvio/elv-client-js 4.0.4 → 4.0.6
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 -17
- package/dist/ElvFrameClient-min.js +12 -11
- package/dist/ElvPermissionsClient-min.js +10 -9
- package/dist/ElvWalletClient-min.js +11 -10
- package/dist/ElvWalletClient-node-min.js +12 -17
- 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 +1412 -1551
- 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 +1169 -1493
- package/package.json +3 -2
- package/src/Crypto.js +1 -1
- package/src/ElvClient.js +1 -3
- package/src/Utils.js +1 -1
- package/src/walletClient/ClientMethods.js +133 -11
- package/src/walletClient/index.js +1 -0
- 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;
|
|
@@ -80,22 +61,22 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
80
61
|
this.availableMarketplaces = {};
|
|
81
62
|
this.availableMarketplacesById = {};
|
|
82
63
|
this.marketplaceHashes = {};
|
|
64
|
+
this.tenantConfigs = {};
|
|
83
65
|
this.stateStoreUrls = Configuration[network].stateStoreUrls;
|
|
84
66
|
this.stateStoreClient = new HTTPClient({
|
|
85
67
|
uris: this.stateStoreUrls
|
|
86
|
-
});
|
|
68
|
+
});
|
|
87
69
|
|
|
70
|
+
// Caches
|
|
88
71
|
this.cachedMarketplaces = {};
|
|
89
72
|
this.cachedCSS = {};
|
|
90
73
|
this.utils = client.utils;
|
|
91
74
|
}
|
|
92
|
-
|
|
93
75
|
_createClass(ElvWalletClient, [{
|
|
94
76
|
key: "Log",
|
|
95
77
|
value: function Log(message) {
|
|
96
78
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
97
79
|
var errorObject = arguments.length > 2 ? arguments[2] : undefined;
|
|
98
|
-
|
|
99
80
|
if (error) {
|
|
100
81
|
// eslint-disable-next-line no-console
|
|
101
82
|
console.error("Eluvio Wallet Client:", message);
|
|
@@ -103,12 +84,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
103
84
|
// eslint-disable-next-line no-console
|
|
104
85
|
console.log("Eluvio Wallet Client:", message);
|
|
105
86
|
}
|
|
106
|
-
|
|
107
87
|
if (errorObject) {
|
|
108
88
|
// eslint-disable-next-line no-console
|
|
109
89
|
console.error(errorObject);
|
|
110
90
|
}
|
|
111
91
|
}
|
|
92
|
+
|
|
112
93
|
/**
|
|
113
94
|
* Initialize the wallet client.
|
|
114
95
|
*
|
|
@@ -126,11 +107,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
126
107
|
*
|
|
127
108
|
* @returns {Promise<ElvWalletClient>}
|
|
128
109
|
*/
|
|
129
|
-
|
|
130
110
|
}, {
|
|
131
111
|
key: "CanSign",
|
|
132
|
-
value:
|
|
133
|
-
/* Login and authorization */
|
|
112
|
+
value: /* Login and authorization */
|
|
134
113
|
|
|
135
114
|
/**
|
|
136
115
|
* Check if this client can sign without opening a popup.
|
|
@@ -144,9 +123,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
144
123
|
if (!this.loggedIn) {
|
|
145
124
|
return false;
|
|
146
125
|
}
|
|
147
|
-
|
|
148
126
|
return !!this.__authorization.clusterToken || inBrowser && !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
|
|
149
127
|
}
|
|
128
|
+
|
|
150
129
|
/**
|
|
151
130
|
* <b><i>Requires login</i></b>
|
|
152
131
|
*
|
|
@@ -164,169 +143,136 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
164
143
|
*
|
|
165
144
|
* @returns {Promise<string>} - The signature of the message
|
|
166
145
|
*/
|
|
167
|
-
|
|
168
146
|
}, {
|
|
169
147
|
key: "PersonalSign",
|
|
170
148
|
value: function () {
|
|
171
149
|
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
|
|
172
150
|
var message, parameters, url;
|
|
173
151
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
174
|
-
while (1) {
|
|
175
|
-
|
|
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
|
-
case 16:
|
|
218
|
-
throw Error("ElvWalletClient: Unable to sign");
|
|
219
|
-
|
|
220
|
-
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) {
|
|
221
193
|
_context3.next = 21;
|
|
222
194
|
break;
|
|
223
|
-
|
|
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
|
-
onCancel: function onCancel() {
|
|
262
|
-
return reject("User cancelled sign");
|
|
263
|
-
},
|
|
264
|
-
onMessage: function () {
|
|
265
|
-
var _onMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, Close) {
|
|
266
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
267
|
-
while (1) {
|
|
268
|
-
switch (_context.prev = _context.next) {
|
|
269
|
-
case 0:
|
|
270
|
-
if (!(!event || !event.data || event.data.type !== "FlowResponse")) {
|
|
271
|
-
_context.next = 2;
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
return _context.abrupt("return");
|
|
276
|
-
|
|
277
|
-
case 2:
|
|
278
|
-
try {
|
|
279
|
-
resolve(event.data.response);
|
|
280
|
-
} catch (error) {
|
|
281
|
-
reject(error);
|
|
282
|
-
} finally {
|
|
283
|
-
Close();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
case 3:
|
|
287
|
-
case "end":
|
|
288
|
-
return _context.stop();
|
|
289
|
-
}
|
|
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;
|
|
290
233
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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();
|
|
296
246
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return _context3.stop();
|
|
321
|
-
}
|
|
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();
|
|
322
270
|
}
|
|
323
271
|
}, _callee3, this);
|
|
324
272
|
}));
|
|
325
|
-
|
|
326
273
|
function PersonalSign(_x) {
|
|
327
274
|
return _PersonalSign.apply(this, arguments);
|
|
328
275
|
}
|
|
329
|
-
|
|
330
276
|
return PersonalSign;
|
|
331
277
|
}()
|
|
332
278
|
/**
|
|
@@ -350,181 +296,143 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
350
296
|
*
|
|
351
297
|
* @throws - If using the popup flow and the user closes the popup, this method will throw an error.
|
|
352
298
|
*/
|
|
353
|
-
|
|
354
299
|
}, {
|
|
355
300
|
key: "LogIn",
|
|
356
301
|
value: function () {
|
|
357
302
|
var _LogIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref4) {
|
|
358
303
|
var _this = this;
|
|
359
|
-
|
|
360
304
|
var _ref4$method, method, provider, _ref4$mode, mode, callbackUrl, marketplaceParams, _ref4$clearLogin, clearLogin, callback, loginUrl;
|
|
361
|
-
|
|
362
305
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
363
|
-
while (1) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if (!marketplaceParams) {
|
|
381
|
-
_context6.next = 15;
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
_context6.t0 = loginUrl.searchParams;
|
|
386
|
-
_context6.next = 11;
|
|
387
|
-
return this.MarketplaceInfo({
|
|
388
|
-
marketplaceParams: marketplaceParams
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
case 11:
|
|
392
|
-
_context6.t1 = _context6.sent.marketplaceHash;
|
|
393
|
-
|
|
394
|
-
_context6.t0.set.call(_context6.t0, "mid", _context6.t1);
|
|
395
|
-
|
|
396
|
-
_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;
|
|
397
321
|
break;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
loginUrl.searchParams.set("
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
_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;
|
|
419
343
|
break;
|
|
420
|
-
|
|
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
|
-
case 2:
|
|
452
|
-
_context4.prev = 2;
|
|
453
|
-
|
|
454
|
-
if (!callback) {
|
|
455
|
-
_context4.next = 8;
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
_context4.next = 6;
|
|
460
|
-
return callback(event.data.params);
|
|
461
|
-
|
|
462
|
-
case 6:
|
|
463
|
-
_context4.next = 10;
|
|
464
|
-
break;
|
|
465
|
-
|
|
466
|
-
case 8:
|
|
467
|
-
_context4.next = 10;
|
|
468
|
-
return _this.Authenticate({
|
|
469
|
-
token: event.data.params.clientSigningToken || event.data.params.clientAuthToken
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
case 10:
|
|
473
|
-
resolve();
|
|
474
|
-
_context4.next = 16;
|
|
475
|
-
break;
|
|
476
|
-
|
|
477
|
-
case 13:
|
|
478
|
-
_context4.prev = 13;
|
|
479
|
-
_context4.t0 = _context4["catch"](2);
|
|
480
|
-
reject(_context4.t0);
|
|
481
|
-
|
|
482
|
-
case 16:
|
|
483
|
-
_context4.prev = 16;
|
|
484
|
-
Close();
|
|
485
|
-
return _context4.finish(16);
|
|
486
|
-
|
|
487
|
-
case 19:
|
|
488
|
-
case "end":
|
|
489
|
-
return _context4.stop();
|
|
490
|
-
}
|
|
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;
|
|
491
375
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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();
|
|
497
408
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
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();
|
|
520
430
|
}
|
|
521
431
|
}, _callee6, this);
|
|
522
432
|
}));
|
|
523
|
-
|
|
524
433
|
function LogIn(_x6) {
|
|
525
434
|
return _LogIn.apply(this, arguments);
|
|
526
435
|
}
|
|
527
|
-
|
|
528
436
|
return LogIn;
|
|
529
437
|
}()
|
|
530
438
|
/**
|
|
@@ -532,20 +440,22 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
532
440
|
*
|
|
533
441
|
* @methodGroup Login
|
|
534
442
|
*/
|
|
535
|
-
|
|
536
443
|
}, {
|
|
537
444
|
key: "LogOut",
|
|
538
445
|
value: function LogOut() {
|
|
539
446
|
this.__authorization = {};
|
|
540
447
|
this.loggedIn = false;
|
|
541
|
-
this.cachedMarketplaces = {};
|
|
448
|
+
this.cachedMarketplaces = {};
|
|
542
449
|
|
|
450
|
+
// Delete saved auth token
|
|
543
451
|
if (localStorageAvailable) {
|
|
544
452
|
try {
|
|
545
|
-
localStorage.removeItem("__elv-token-".concat(this.network));
|
|
453
|
+
localStorage.removeItem("__elv-token-".concat(this.network));
|
|
454
|
+
// eslint-disable-next-line no-empty
|
|
546
455
|
} catch (error) {}
|
|
547
456
|
}
|
|
548
457
|
}
|
|
458
|
+
|
|
549
459
|
/**
|
|
550
460
|
* Authenticate with an ElvWalletClient authorization token
|
|
551
461
|
*
|
|
@@ -553,65 +463,53 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
553
463
|
* @namedParams
|
|
554
464
|
* @param {string} token - A previously generated ElvWalletClient authorization token;
|
|
555
465
|
*/
|
|
556
|
-
|
|
557
466
|
}, {
|
|
558
467
|
key: "Authenticate",
|
|
559
468
|
value: function () {
|
|
560
469
|
var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref6) {
|
|
561
470
|
var token, decodedToken;
|
|
562
471
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
563
|
-
while (1) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
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;
|
|
570
486
|
break;
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
throw new Error("Invalid authorization token " + token);
|
|
576
|
-
|
|
577
|
-
case 8:
|
|
578
|
-
if (!(!decodedToken.expiresAt || Date.now() > decodedToken.expiresAt)) {
|
|
579
|
-
_context7.next = 10;
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
throw Error("ElvWalletClient: Provided authorization token has expired");
|
|
584
|
-
|
|
585
|
-
case 10:
|
|
586
|
-
if (!decodedToken.clusterToken) {
|
|
587
|
-
_context7.next = 13;
|
|
588
|
-
break;
|
|
589
|
-
}
|
|
590
|
-
|
|
487
|
+
}
|
|
488
|
+
throw Error("ElvWalletClient: Provided authorization token has expired");
|
|
489
|
+
case 10:
|
|
490
|
+
if (!decodedToken.clusterToken) {
|
|
591
491
|
_context7.next = 13;
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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();
|
|
607
507
|
}
|
|
608
508
|
}, _callee7, this, [[1, 5]]);
|
|
609
509
|
}));
|
|
610
|
-
|
|
611
510
|
function Authenticate(_x11) {
|
|
612
511
|
return _Authenticate.apply(this, arguments);
|
|
613
512
|
}
|
|
614
|
-
|
|
615
513
|
return Authenticate;
|
|
616
514
|
}()
|
|
617
515
|
/**
|
|
@@ -633,111 +531,94 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
633
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
|
|
634
532
|
* shared with third parties.
|
|
635
533
|
*/
|
|
636
|
-
|
|
637
534
|
}, {
|
|
638
535
|
key: "AuthenticateOAuth",
|
|
639
536
|
value: function () {
|
|
640
537
|
var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref7) {
|
|
641
538
|
var idToken, tenantId, email, signerURIs, _ref7$shareEmail, shareEmail, tokenDuration, expiresAt, fabricToken, address, decodedToken;
|
|
642
|
-
|
|
643
539
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
644
|
-
while (1) {
|
|
645
|
-
|
|
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
|
-
duration: tokenDuration * 60 * 60 * 1000
|
|
678
|
-
});
|
|
679
|
-
|
|
680
|
-
case 11:
|
|
681
|
-
fabricToken = _context8.sent;
|
|
682
|
-
address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
|
|
683
|
-
|
|
684
|
-
if (email) {
|
|
685
|
-
_context8.next = 22;
|
|
686
|
-
break;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
_context8.prev = 14;
|
|
690
|
-
decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
|
|
691
|
-
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) {
|
|
692
573
|
_context8.next = 22;
|
|
693
574
|
break;
|
|
694
|
-
|
|
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
|
-
|
|
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();
|
|
733
616
|
}
|
|
734
617
|
}, _callee8, this, [[14, 19]]);
|
|
735
618
|
}));
|
|
736
|
-
|
|
737
619
|
function AuthenticateOAuth(_x12) {
|
|
738
620
|
return _AuthenticateOAuth.apply(this, arguments);
|
|
739
621
|
}
|
|
740
|
-
|
|
741
622
|
return AuthenticateOAuth;
|
|
742
623
|
}()
|
|
743
624
|
/**
|
|
@@ -753,85 +634,68 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
753
634
|
* @returns {Promise<string>} - Returns an authorization token that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
754
635
|
* Save this token to avoid having to reauthenticate. This token expires after 24 hours.
|
|
755
636
|
*/
|
|
756
|
-
|
|
757
637
|
}, {
|
|
758
638
|
key: "AuthenticateExternalWallet",
|
|
759
639
|
value: function () {
|
|
760
640
|
var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref8) {
|
|
761
641
|
var _this2 = this;
|
|
762
|
-
|
|
763
642
|
var address, _ref8$tokenDuration, tokenDuration, _ref8$walletName, walletName, Sign, expiresAt, fabricToken;
|
|
764
|
-
|
|
765
643
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
766
|
-
while (1) {
|
|
767
|
-
|
|
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
|
-
fabricToken: fabricToken,
|
|
816
|
-
address: address,
|
|
817
|
-
expiresAt: expiresAt,
|
|
818
|
-
walletType: "External",
|
|
819
|
-
walletName: walletName,
|
|
820
|
-
register: true
|
|
821
|
-
}));
|
|
822
|
-
|
|
823
|
-
case 9:
|
|
824
|
-
case "end":
|
|
825
|
-
return _context10.stop();
|
|
826
|
-
}
|
|
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();
|
|
827
693
|
}
|
|
828
694
|
}, _callee10, this);
|
|
829
695
|
}));
|
|
830
|
-
|
|
831
696
|
function AuthenticateExternalWallet(_x13) {
|
|
832
697
|
return _AuthenticateExternalWallet.apply(this, arguments);
|
|
833
698
|
}
|
|
834
|
-
|
|
835
699
|
return AuthenticateExternalWallet;
|
|
836
700
|
}()
|
|
837
701
|
/**
|
|
@@ -841,14 +705,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
841
705
|
*
|
|
842
706
|
* @returns {string} - The client auth token
|
|
843
707
|
*/
|
|
844
|
-
|
|
845
708
|
}, {
|
|
846
709
|
key: "ClientAuthToken",
|
|
847
710
|
value: function ClientAuthToken() {
|
|
848
711
|
if (!this.loggedIn) {
|
|
849
712
|
return "";
|
|
850
713
|
}
|
|
851
|
-
|
|
852
714
|
return this.utils.B58(JSON.stringify(this.__authorization));
|
|
853
715
|
}
|
|
854
716
|
}, {
|
|
@@ -857,25 +719,23 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
857
719
|
if (!this.loggedIn) {
|
|
858
720
|
return this.publicStaticToken;
|
|
859
721
|
}
|
|
860
|
-
|
|
861
722
|
return this.__authorization.fabricToken;
|
|
862
723
|
}
|
|
863
724
|
}, {
|
|
864
725
|
key: "SetAuthorization",
|
|
865
726
|
value: function SetAuthorization(_ref10) {
|
|
866
727
|
var _this3 = this;
|
|
867
|
-
|
|
868
728
|
var clusterToken = _ref10.clusterToken,
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
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;
|
|
879
739
|
address = this.client.utils.FormatAddress(address);
|
|
880
740
|
this.__authorization = {
|
|
881
741
|
fabricToken: fabricToken,
|
|
@@ -886,25 +746,21 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
886
746
|
walletType: walletType,
|
|
887
747
|
walletName: walletName
|
|
888
748
|
};
|
|
889
|
-
|
|
890
749
|
if (clusterToken) {
|
|
891
750
|
this.__authorization.clusterToken = clusterToken;
|
|
892
|
-
|
|
893
751
|
if (signerURIs) {
|
|
894
752
|
this.__authorization.signerURIs = signerURIs;
|
|
895
753
|
}
|
|
896
754
|
}
|
|
897
|
-
|
|
898
755
|
this.loggedIn = true;
|
|
899
756
|
this.cachedMarketplaces = {};
|
|
900
757
|
var token = this.ClientAuthToken();
|
|
901
|
-
|
|
902
758
|
if (this.storeAuthToken && localStorageAvailable) {
|
|
903
759
|
try {
|
|
904
|
-
localStorage.setItem("__elv-token-".concat(this.network), token);
|
|
760
|
+
localStorage.setItem("__elv-token-".concat(this.network), token);
|
|
761
|
+
// eslint-disable-next-line no-empty
|
|
905
762
|
} catch (error) {}
|
|
906
763
|
}
|
|
907
|
-
|
|
908
764
|
if (register) {
|
|
909
765
|
this.client.authClient.MakeAuthServiceRequest({
|
|
910
766
|
path: "/as/wlt/register",
|
|
@@ -916,7 +772,6 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
916
772
|
_this3.Log("Failed to register account: ", true, error);
|
|
917
773
|
});
|
|
918
774
|
}
|
|
919
|
-
|
|
920
775
|
return token;
|
|
921
776
|
}
|
|
922
777
|
}, {
|
|
@@ -925,289 +780,244 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
925
780
|
var _SignMetamask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref11) {
|
|
926
781
|
var message, address, accounts;
|
|
927
782
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
928
|
-
while (1) {
|
|
929
|
-
|
|
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
|
-
method: "personal_sign",
|
|
961
|
-
params: [message, address, ""]
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
case 11:
|
|
965
|
-
return _context11.abrupt("return", _context11.sent);
|
|
966
|
-
|
|
967
|
-
case 12:
|
|
968
|
-
case "end":
|
|
969
|
-
return _context11.stop();
|
|
970
|
-
}
|
|
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();
|
|
971
815
|
}
|
|
972
816
|
}, _callee11, this);
|
|
973
817
|
}));
|
|
974
|
-
|
|
975
818
|
function SignMetamask(_x15) {
|
|
976
819
|
return _SignMetamask.apply(this, arguments);
|
|
977
820
|
}
|
|
978
|
-
|
|
979
821
|
return SignMetamask;
|
|
980
822
|
}() // Internal loading methods
|
|
981
|
-
|
|
982
823
|
}, {
|
|
983
824
|
key: "LoadAvailableMarketplaces",
|
|
984
825
|
value: function () {
|
|
985
826
|
var _LoadAvailableMarketplaces = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
986
827
|
var _this4 = this;
|
|
987
|
-
|
|
988
828
|
var forceReload,
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
829
|
+
mainSiteHash,
|
|
830
|
+
metadata,
|
|
831
|
+
previewTenantSlug,
|
|
832
|
+
previewMarketplaceSlug,
|
|
833
|
+
previewMarketplaceMetadata,
|
|
834
|
+
availableMarketplaces,
|
|
835
|
+
availableMarketplacesById,
|
|
836
|
+
_args12 = arguments;
|
|
997
837
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
998
|
-
while (1) {
|
|
999
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
1031
888
|
});
|
|
889
|
+
});
|
|
1032
890
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
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;
|
|
1052
948
|
|
|
1053
|
-
|
|
1054
|
-
|
|
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
|
+
}
|
|
1055
954
|
}
|
|
955
|
+
} catch (error) {
|
|
956
|
+
_this4.Log("Eluvio Wallet Client: Unable to load info for marketplace ".concat(tenantSlug, "/").concat(marketplaceSlug), true);
|
|
1056
957
|
}
|
|
1057
958
|
});
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
if (previewMarketplaceMetadata) {
|
|
1061
|
-
_context12.next = 17;
|
|
1062
|
-
break;
|
|
959
|
+
} catch (error) {
|
|
960
|
+
_this4.Log("Eluvio Wallet Client: Failed to load tenant info ".concat(tenantSlug), true, error);
|
|
1063
961
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
authorizationToken: this.publicStaticToken,
|
|
1071
|
-
noAuth: true,
|
|
1072
|
-
select: ["slug", "info/tenant_id", "info/tenant_name", "info/branding"],
|
|
1073
|
-
remove: ["info/branding/custom_css"]
|
|
1074
|
-
});
|
|
1075
|
-
|
|
1076
|
-
case 15:
|
|
1077
|
-
previewMarketplaceMetadata = _context12.sent;
|
|
1078
|
-
|
|
1079
|
-
if (!previewMarketplaceSlug) {
|
|
1080
|
-
previewMarketplaceSlug = previewMarketplaceMetadata.slug;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
case 17:
|
|
1084
|
-
previewMarketplaceMetadata["."] = {
|
|
1085
|
-
source: this.previewMarketplaceHash
|
|
1086
|
-
};
|
|
1087
|
-
previewMarketplaceMetadata.info["."] = {
|
|
1088
|
-
source: this.previewMarketplaceHash
|
|
1089
|
-
};
|
|
1090
|
-
previewMarketplaceMetadata.info.branding.preview = true;
|
|
1091
|
-
previewMarketplaceMetadata.info.branding.show = true;
|
|
1092
|
-
metadata[previewTenantSlug] = metadata[previewTenantSlug] || {};
|
|
1093
|
-
metadata[previewTenantSlug].marketplaces = metadata[previewTenantSlug].marketplaces || {};
|
|
1094
|
-
metadata[previewTenantSlug].marketplaces[previewMarketplaceSlug] = previewMarketplaceMetadata;
|
|
1095
|
-
|
|
1096
|
-
case 24:
|
|
1097
|
-
availableMarketplaces = _objectSpread({}, this.availableMarketplaces || {});
|
|
1098
|
-
availableMarketplacesById = _objectSpread({}, this.availableMarketplacesById || {});
|
|
1099
|
-
Object.keys(metadata || {}).forEach(function (tenantSlug) {
|
|
1100
|
-
try {
|
|
1101
|
-
availableMarketplaces[tenantSlug] = metadata[tenantSlug]["."] ? {
|
|
1102
|
-
versionHash: metadata[tenantSlug]["."].source
|
|
1103
|
-
} : {};
|
|
1104
|
-
Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
|
|
1105
|
-
try {
|
|
1106
|
-
var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
|
|
1107
|
-
|
|
1108
|
-
var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
|
|
1109
|
-
|
|
1110
|
-
availableMarketplaces[tenantSlug][marketplaceSlug] = _objectSpread(_objectSpread({}, metadata[tenantSlug].marketplaces[marketplaceSlug].info || {}), {}, {
|
|
1111
|
-
tenantName: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_name,
|
|
1112
|
-
tenantId: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_id,
|
|
1113
|
-
tenantSlug: tenantSlug,
|
|
1114
|
-
marketplaceSlug: marketplaceSlug,
|
|
1115
|
-
marketplaceId: objectId,
|
|
1116
|
-
marketplaceHash: versionHash,
|
|
1117
|
-
order: Configuration.__MARKETPLACE_ORDER.findIndex(function (slug) {
|
|
1118
|
-
return slug === marketplaceSlug;
|
|
1119
|
-
})
|
|
1120
|
-
});
|
|
1121
|
-
availableMarketplacesById[objectId] = availableMarketplaces[tenantSlug][marketplaceSlug];
|
|
1122
|
-
_this4.marketplaceHashes[objectId] = versionHash; // Fill out selected marketplace info
|
|
1123
|
-
|
|
1124
|
-
if (_this4.selectedMarketplaceInfo) {
|
|
1125
|
-
if (_this4.selectedMarketplaceInfo.tenantSlug === tenantSlug && _this4.selectedMarketplaceInfo.marketplaceSlug === marketplaceSlug || _this4.selectedMarketplaceInfo.marketplaceId === objectId) {
|
|
1126
|
-
_this4.selectedMarketplaceInfo = availableMarketplaces[tenantSlug][marketplaceSlug];
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
} catch (error) {
|
|
1130
|
-
_this4.Log("Eluvio Wallet Client: Unable to load info for marketplace ".concat(tenantSlug, "/").concat(marketplaceSlug), true);
|
|
1131
|
-
}
|
|
1132
|
-
});
|
|
1133
|
-
} catch (error) {
|
|
1134
|
-
_this4.Log("Eluvio Wallet Client: Failed to load tenant info ".concat(tenantSlug), true, error);
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
this.availableMarketplaces = availableMarketplaces;
|
|
1138
|
-
this.availableMarketplacesById = availableMarketplacesById;
|
|
1139
|
-
|
|
1140
|
-
case 29:
|
|
1141
|
-
case "end":
|
|
1142
|
-
return _context12.stop();
|
|
1143
|
-
}
|
|
962
|
+
});
|
|
963
|
+
this.availableMarketplaces = availableMarketplaces;
|
|
964
|
+
this.availableMarketplacesById = availableMarketplacesById;
|
|
965
|
+
case 29:
|
|
966
|
+
case "end":
|
|
967
|
+
return _context12.stop();
|
|
1144
968
|
}
|
|
1145
969
|
}, _callee12, this);
|
|
1146
970
|
}));
|
|
1147
|
-
|
|
1148
971
|
function LoadAvailableMarketplaces() {
|
|
1149
972
|
return _LoadAvailableMarketplaces.apply(this, arguments);
|
|
1150
973
|
}
|
|
1151
|
-
|
|
1152
974
|
return LoadAvailableMarketplaces;
|
|
1153
975
|
}() // Get the hash of the currently linked marketplace
|
|
1154
|
-
|
|
1155
976
|
}, {
|
|
1156
977
|
key: "LatestMarketplaceHash",
|
|
1157
978
|
value: function () {
|
|
1158
979
|
var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref12) {
|
|
1159
980
|
var marketplaceParams, marketplaceInfo, mainSiteHash, marketplaceLink;
|
|
1160
981
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1161
|
-
while (1) {
|
|
1162
|
-
|
|
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
|
-
case 11:
|
|
1196
|
-
marketplaceLink = _context13.sent;
|
|
1197
|
-
return _context13.abrupt("return", LinkTargetHash(marketplaceLink));
|
|
1198
|
-
|
|
1199
|
-
case 13:
|
|
1200
|
-
case "end":
|
|
1201
|
-
return _context13.stop();
|
|
1202
|
-
}
|
|
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();
|
|
1203
1015
|
}
|
|
1204
1016
|
}, _callee13, this);
|
|
1205
1017
|
}));
|
|
1206
|
-
|
|
1207
1018
|
function LatestMarketplaceHash(_x16) {
|
|
1208
1019
|
return _LatestMarketplaceHash.apply(this, arguments);
|
|
1209
1020
|
}
|
|
1210
|
-
|
|
1211
1021
|
return LatestMarketplaceHash;
|
|
1212
1022
|
}()
|
|
1213
1023
|
}, {
|
|
@@ -1215,164 +1025,137 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1215
1025
|
value: function () {
|
|
1216
1026
|
var _LoadMarketplace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(marketplaceParams) {
|
|
1217
1027
|
var _this5 = this;
|
|
1218
|
-
|
|
1219
1028
|
var marketplaceInfo, marketplaceId, marketplaceHash, marketplace;
|
|
1220
1029
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1221
|
-
while (1) {
|
|
1222
|
-
|
|
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
|
-
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1264
|
-
while (1) {
|
|
1265
|
-
switch (_context14.prev = _context14.next) {
|
|
1266
|
-
case 0:
|
|
1267
|
-
if (!item.requires_permissions) {
|
|
1268
|
-
_context14.next = 14;
|
|
1269
|
-
break;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
if (_this5.loggedIn) {
|
|
1273
|
-
_context14.next = 5;
|
|
1274
|
-
break;
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
_context14.next = 4;
|
|
1278
|
-
return _this5.client.CreateFabricToken({});
|
|
1279
|
-
|
|
1280
|
-
case 4:
|
|
1281
|
-
authorizationToken = _context14.sent;
|
|
1282
|
-
|
|
1283
|
-
case 5:
|
|
1284
|
-
_context14.prev = 5;
|
|
1285
|
-
_context14.next = 8;
|
|
1286
|
-
return _this5.client.ContentObjectMetadata({
|
|
1287
|
-
versionHash: LinkTargetHash(item.nft_template),
|
|
1288
|
-
metadataSubtree: "permissioned",
|
|
1289
|
-
authorizationToken: authorizationToken
|
|
1290
|
-
});
|
|
1291
|
-
|
|
1292
|
-
case 8:
|
|
1293
|
-
item.authorized = true;
|
|
1294
|
-
_context14.next = 14;
|
|
1295
|
-
break;
|
|
1296
|
-
|
|
1297
|
-
case 11:
|
|
1298
|
-
_context14.prev = 11;
|
|
1299
|
-
_context14.t0 = _context14["catch"](5);
|
|
1300
|
-
item.authorized = false;
|
|
1301
|
-
|
|
1302
|
-
case 14:
|
|
1303
|
-
item.nftTemplateMetadata = (item.nft_template || {}).nft || {};
|
|
1304
|
-
item.nftTemplateHash = ((item.nft_template || {})["."] || {}).source;
|
|
1305
|
-
item.itemIndex = index;
|
|
1306
|
-
return _context14.abrupt("return", item);
|
|
1307
|
-
|
|
1308
|
-
case 18:
|
|
1309
|
-
case "end":
|
|
1310
|
-
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;
|
|
1311
1072
|
}
|
|
1312
|
-
|
|
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
|
-
} 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
|
|
1358
1117
|
});
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
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();
|
|
1368
1153
|
}
|
|
1369
1154
|
}, _callee15, this);
|
|
1370
1155
|
}));
|
|
1371
|
-
|
|
1372
1156
|
function LoadMarketplace(_x17) {
|
|
1373
1157
|
return _LoadMarketplace.apply(this, arguments);
|
|
1374
1158
|
}
|
|
1375
|
-
|
|
1376
1159
|
return LoadMarketplace;
|
|
1377
1160
|
}()
|
|
1378
1161
|
}, {
|
|
@@ -1380,344 +1163,286 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1380
1163
|
value: function () {
|
|
1381
1164
|
var _FilteredQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
1382
1165
|
var _this6 = this;
|
|
1383
|
-
|
|
1384
1166
|
var _ref14,
|
|
1385
|
-
|
|
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
|
-
|
|
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;
|
|
1423
1204
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1424
|
-
while (1) {
|
|
1425
|
-
|
|
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
|
-
if (sellerAddress) {
|
|
1480
|
-
filters.push("seller:eq:".concat(this.client.utils.FormatAddress(sellerAddress)));
|
|
1481
|
-
} else if (userAddress && mode !== "owned") {
|
|
1482
|
-
filters.push("addr:eq:".concat(this.client.utils.FormatAddress(userAddress)));
|
|
1483
|
-
}
|
|
1484
|
-
|
|
1485
|
-
if (marketplace && collectionIndexes.length >= 0) {
|
|
1486
|
-
collectionIndexes.forEach(function (collectionIndex) {
|
|
1487
|
-
var collection = marketplace.collections[collectionIndex];
|
|
1488
|
-
collection.items.forEach(function (sku) {
|
|
1489
|
-
if (!sku) {
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
var item = marketplace.items.find(function (item) {
|
|
1494
|
-
return item.sku === sku;
|
|
1495
|
-
});
|
|
1496
|
-
|
|
1497
|
-
if (!item) {
|
|
1498
|
-
return;
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
var address = Utils.SafeTraverse(item, "nft_template", "nft", "address");
|
|
1502
|
-
|
|
1503
|
-
if (address) {
|
|
1504
|
-
filters.push("".concat(mode === "owned" ? "contract_addr" : "contract", ":eq:").concat(Utils.FormatAddress(address)));
|
|
1505
|
-
}
|
|
1506
|
-
});
|
|
1507
|
-
});
|
|
1508
|
-
} else if (marketplaceInfo || tenantId) {
|
|
1509
|
-
filters.push("tenant:eq:".concat(marketplaceInfo ? marketplaceInfo.tenantId : tenantId));
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
if (contractAddress) {
|
|
1513
|
-
if (mode === "owned") {
|
|
1514
|
-
filters.push("contract_addr:eq:".concat(Utils.FormatAddress(contractAddress)));
|
|
1515
|
-
} else {
|
|
1516
|
-
filters.push("contract:eq:".concat(Utils.FormatAddress(contractAddress)));
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
if (tokenId) {
|
|
1520
|
-
filters.push("token:eq:".concat(tokenId));
|
|
1521
|
-
}
|
|
1522
|
-
} else if (filter) {
|
|
1523
|
-
if (mode.includes("listing")) {
|
|
1524
|
-
filters.push("nft/display_name:eq:".concat(filter));
|
|
1525
|
-
} else if (mode === "owned") {
|
|
1526
|
-
filters.push("meta/display_name:eq:".concat(filter));
|
|
1527
|
-
} else {
|
|
1528
|
-
filters.push("name:eq:".concat(filter));
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
if (editionFilters) {
|
|
1533
|
-
editionFilters.forEach(function (editionFilter) {
|
|
1534
|
-
if (mode.includes("listing")) {
|
|
1535
|
-
filters.push("nft/edition_name:eq:".concat(editionFilter));
|
|
1536
|
-
} else if (mode === "owned") {
|
|
1537
|
-
filters.push("meta:@>:{\"edition_name\":\"".concat(editionFilter, "\"}"));
|
|
1538
|
-
params.exact = false;
|
|
1539
|
-
} else {
|
|
1540
|
-
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;
|
|
1541
1259
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
attributeFilters.map(function (_ref15) {
|
|
1547
|
-
var name = _ref15.name,
|
|
1548
|
-
value = _ref15.value;
|
|
1549
|
-
|
|
1550
|
-
if (!name || !value) {
|
|
1260
|
+
var item = marketplace.items.find(function (item) {
|
|
1261
|
+
return item.sku === sku;
|
|
1262
|
+
});
|
|
1263
|
+
if (!item) {
|
|
1551
1264
|
return;
|
|
1552
1265
|
}
|
|
1553
|
-
|
|
1554
|
-
|
|
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
|
+
}
|
|
1555
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)));
|
|
1556
1280
|
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
filters.push("link_type:eq:sol");
|
|
1281
|
+
if (tokenId) {
|
|
1282
|
+
filters.push("token:eq:".concat(tokenId));
|
|
1560
1283
|
}
|
|
1561
|
-
|
|
1562
|
-
if (
|
|
1563
|
-
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));
|
|
1564
1291
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
if (tokenIdRange) {
|
|
1577
|
-
if (tokenIdRange.min) {
|
|
1578
|
-
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));
|
|
1579
1302
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
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;
|
|
1583
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)));
|
|
1584
1324
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
filters.push("info/cap:le:".concat(parseInt(capLimit)));
|
|
1325
|
+
if (priceRange.max) {
|
|
1326
|
+
filters.push("price:le:".concat(parseFloat(priceRange.max)));
|
|
1588
1327
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
case 29:
|
|
1595
|
-
path = UrlJoin("as", "wlt", userAddress || this.UserAddress());
|
|
1596
|
-
return _context16.abrupt("break", 48);
|
|
1597
|
-
|
|
1598
|
-
case 31:
|
|
1599
|
-
path = UrlJoin("as", "mkt", "f");
|
|
1600
|
-
return _context16.abrupt("break", 48);
|
|
1601
|
-
|
|
1602
|
-
case 33:
|
|
1603
|
-
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1604
|
-
filters.push("action:eq:TRANSFERRED");
|
|
1605
|
-
filters.push("action:eq:SOLD");
|
|
1606
|
-
return _context16.abrupt("break", 48);
|
|
1607
|
-
|
|
1608
|
-
case 37:
|
|
1609
|
-
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1610
|
-
filters.push("action:eq:SOLD");
|
|
1611
|
-
filters.push("seller:co:0x");
|
|
1612
|
-
return _context16.abrupt("break", 48);
|
|
1613
|
-
|
|
1614
|
-
case 41:
|
|
1615
|
-
path = UrlJoin("as", "mkt", "stats", "listed");
|
|
1616
|
-
return _context16.abrupt("break", 48);
|
|
1617
|
-
|
|
1618
|
-
case 43:
|
|
1619
|
-
path = UrlJoin("as", "mkt", "stats", "sold");
|
|
1620
|
-
filters.push("seller:co:0x");
|
|
1621
|
-
return _context16.abrupt("break", 48);
|
|
1622
|
-
|
|
1623
|
-
case 46:
|
|
1624
|
-
path = UrlJoin("as", "wlt", "leaders");
|
|
1625
|
-
return _context16.abrupt("break", 48);
|
|
1626
|
-
|
|
1627
|
-
case 48:
|
|
1628
|
-
if (filters.length > 0) {
|
|
1629
|
-
params.filter = filters;
|
|
1328
|
+
}
|
|
1329
|
+
if (tokenIdRange) {
|
|
1330
|
+
if (tokenIdRange.min) {
|
|
1331
|
+
filters.push("info/token_id:ge:".concat(parseInt(tokenIdRange.min)));
|
|
1630
1332
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
_context16.next = 53;
|
|
1634
|
-
break;
|
|
1333
|
+
if (tokenIdRange.max) {
|
|
1334
|
+
filters.push("info/token_id:le:".concat(parseInt(tokenIdRange.max)));
|
|
1635
1335
|
}
|
|
1636
|
-
|
|
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
|
-
|
|
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();
|
|
1713
1440
|
}
|
|
1714
1441
|
}, _callee16, this, [[14, 68]]);
|
|
1715
1442
|
}));
|
|
1716
|
-
|
|
1717
1443
|
function FilteredQuery() {
|
|
1718
1444
|
return _FilteredQuery.apply(this, arguments);
|
|
1719
1445
|
}
|
|
1720
|
-
|
|
1721
1446
|
return FilteredQuery;
|
|
1722
1447
|
}()
|
|
1723
1448
|
}, {
|
|
@@ -1726,99 +1451,83 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1726
1451
|
var _MintingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref17) {
|
|
1727
1452
|
var marketplaceParams, tenantId, marketplaceInfo, response;
|
|
1728
1453
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1729
|
-
while (1) {
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
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())
|
|
1737
1476
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
}));
|
|
1758
|
-
|
|
1759
|
-
case 9:
|
|
1760
|
-
response = _context17.sent;
|
|
1761
|
-
return _context17.abrupt("return", response.map(function (status) {
|
|
1762
|
-
var _status$op$split = status.op.split(":"),
|
|
1763
|
-
_status$op$split2 = _slicedToArray(_status$op$split, 3),
|
|
1764
|
-
op = _status$op$split2[0],
|
|
1765
|
-
address = _status$op$split2[1],
|
|
1766
|
-
id = _status$op$split2[2];
|
|
1767
|
-
|
|
1768
|
-
address = address.startsWith("0x") ? Utils.FormatAddress(address) : address;
|
|
1769
|
-
var confirmationId, tokenId;
|
|
1770
|
-
|
|
1771
|
-
if (op === "nft-buy") {
|
|
1772
|
-
confirmationId = id;
|
|
1773
|
-
} else if (op === "nft-claim") {
|
|
1774
|
-
confirmationId = id;
|
|
1775
|
-
status.marketplaceId = address;
|
|
1776
|
-
|
|
1777
|
-
if (status.extra && status.extra["0"]) {
|
|
1778
|
-
address = status.extra.token_addr;
|
|
1779
|
-
tokenId = status.extra.token_id_str;
|
|
1780
|
-
}
|
|
1781
|
-
} else if (op === "nft-redeem") {
|
|
1782
|
-
confirmationId = status.op.split(":").slice(-1)[0];
|
|
1783
|
-
} else {
|
|
1784
|
-
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;
|
|
1785
1496
|
}
|
|
1786
|
-
|
|
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
|
-
|
|
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();
|
|
1814
1525
|
}
|
|
1815
1526
|
}, _callee17, this, [[6, 13]]);
|
|
1816
1527
|
}));
|
|
1817
|
-
|
|
1818
1528
|
function MintingStatus(_x20) {
|
|
1819
1529
|
return _MintingStatus.apply(this, arguments);
|
|
1820
1530
|
}
|
|
1821
|
-
|
|
1822
1531
|
return MintingStatus;
|
|
1823
1532
|
}()
|
|
1824
1533
|
}], [{
|
|
@@ -1826,153 +1535,120 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1826
1535
|
value: function () {
|
|
1827
1536
|
var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
|
|
1828
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;
|
|
1829
|
-
|
|
1830
1538
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1831
|
-
while (1) {
|
|
1832
|
-
|
|
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
|
-
client: client,
|
|
1887
|
-
network: network,
|
|
1888
|
-
mode: mode,
|
|
1889
|
-
marketplaceInfo: {
|
|
1890
|
-
tenantSlug: tenantSlug,
|
|
1891
|
-
marketplaceSlug: marketplaceSlug,
|
|
1892
|
-
marketplaceId: marketplaceHash ? client.utils.DecodeVersionHash(marketplaceHash).objectId : marketplaceId,
|
|
1893
|
-
marketplaceHash: marketplaceHash
|
|
1894
|
-
},
|
|
1895
|
-
previewMarketplaceHash: previewMarketplaceHash,
|
|
1896
|
-
storeAuthToken: storeAuthToken
|
|
1897
|
-
});
|
|
1898
|
-
|
|
1899
|
-
if (!(inBrowser && window.location && window.location.href)) {
|
|
1900
|
-
_context18.next = 37;
|
|
1901
|
-
break;
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
url = new URL(window.location.href);
|
|
1905
|
-
|
|
1906
|
-
if (!url.searchParams.get("elvToken")) {
|
|
1907
|
-
_context18.next = 27;
|
|
1908
|
-
break;
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
_context18.next = 23;
|
|
1912
|
-
return walletClient.Authenticate({
|
|
1913
|
-
token: url.searchParams.get("elvToken")
|
|
1914
|
-
});
|
|
1915
|
-
|
|
1916
|
-
case 23:
|
|
1917
|
-
url.searchParams["delete"]("elvToken");
|
|
1918
|
-
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)) {
|
|
1919
1594
|
_context18.next = 37;
|
|
1920
1595
|
break;
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
return walletClient.Authenticate({
|
|
1939
|
-
token: savedToken
|
|
1940
|
-
});
|
|
1941
|
-
|
|
1942
|
-
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)) {
|
|
1943
1613
|
_context18.next = 37;
|
|
1944
1614
|
break;
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
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();
|
|
1961
1641
|
}
|
|
1962
1642
|
}, _callee18, null, [[28, 35]]);
|
|
1963
1643
|
}));
|
|
1964
|
-
|
|
1965
1644
|
function Initialize(_x21) {
|
|
1966
1645
|
return _Initialize.apply(this, arguments);
|
|
1967
1646
|
}
|
|
1968
|
-
|
|
1969
1647
|
return Initialize;
|
|
1970
1648
|
}()
|
|
1971
1649
|
}]);
|
|
1972
|
-
|
|
1973
1650
|
return ElvWalletClient;
|
|
1974
1651
|
}();
|
|
1975
|
-
|
|
1976
1652
|
Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
|
|
1977
1653
|
Object.assign(ElvWalletClient.prototype, require("./Profile"));
|
|
1978
1654
|
Object.assign(ElvWalletClient.prototype, require("./Notifications"));
|