@eluvio/elv-client-js 3.2.10 → 3.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +8 -8
- package/dist/ElvClient-node-min.js +2 -2
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +2 -2
- package/dist/src/ElvClient.js +5 -4
- package/dist/src/RemoteSigner.js +2 -2
- package/dist/src/index.js +2 -2
- package/dist/src/walletClient/ClientMethods.js +15 -14
- package/dist/src/walletClient/Configuration.js +1 -1
- package/dist/src/walletClient/index.js +202 -149
- package/package.json +1 -1
- package/src/ElvClient.js +3 -2
- package/src/RemoteSigner.js +2 -2
- package/src/index.js +2 -2
- package/src/walletClient/ClientMethods.js +14 -13
- package/src/walletClient/index.js +111 -60
- package/testScripts/Test.js +33 -0
- package/testScripts/TestMarketplaceClient.js +0 -25
|
@@ -31,6 +31,9 @@ var UrlJoin = require("url-join");
|
|
|
31
31
|
var Utils = require("../Utils");
|
|
32
32
|
|
|
33
33
|
var Ethers = require("ethers");
|
|
34
|
+
|
|
35
|
+
var inBrowser = typeof window !== "undefined";
|
|
36
|
+
var embedded = inBrowser && window.top !== window.self;
|
|
34
37
|
/**
|
|
35
38
|
* Use the <a href="#.Initialize">Initialize</a> method to initialize a new client.
|
|
36
39
|
*
|
|
@@ -38,7 +41,6 @@ var Ethers = require("ethers");
|
|
|
38
41
|
* See the Modules section on the sidebar for all client methods unrelated to login and authorization
|
|
39
42
|
*/
|
|
40
43
|
|
|
41
|
-
|
|
42
44
|
var ElvWalletClient = /*#__PURE__*/function () {
|
|
43
45
|
"use strict";
|
|
44
46
|
|
|
@@ -74,6 +76,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
74
76
|
key: "Log",
|
|
75
77
|
value: function Log(message) {
|
|
76
78
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
79
|
+
var errorObject = arguments.length > 2 ? arguments[2] : undefined;
|
|
77
80
|
|
|
78
81
|
if (error) {
|
|
79
82
|
// eslint-disable-next-line no-console
|
|
@@ -82,6 +85,11 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
82
85
|
// eslint-disable-next-line no-console
|
|
83
86
|
console.log("Eluvio Wallet Client:", message);
|
|
84
87
|
}
|
|
88
|
+
|
|
89
|
+
if (errorObject) {
|
|
90
|
+
// eslint-disable-next-line no-console
|
|
91
|
+
console.error(errorObject);
|
|
92
|
+
}
|
|
85
93
|
}
|
|
86
94
|
/**
|
|
87
95
|
* Initialize the wallet client.
|
|
@@ -116,7 +124,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
116
124
|
return false;
|
|
117
125
|
}
|
|
118
126
|
|
|
119
|
-
return !!this.__authorization.clusterToken || !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
|
|
127
|
+
return !!this.__authorization.clusterToken || inBrowser && !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
|
|
120
128
|
}
|
|
121
129
|
/**
|
|
122
130
|
* <b><i>Requires login</i></b>
|
|
@@ -156,7 +164,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
156
164
|
|
|
157
165
|
case 3:
|
|
158
166
|
if (!this.CanSign()) {
|
|
159
|
-
_context3.next =
|
|
167
|
+
_context3.next = 19;
|
|
160
168
|
break;
|
|
161
169
|
}
|
|
162
170
|
|
|
@@ -189,6 +197,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
189
197
|
throw Error("ElvWalletClient: Unable to sign");
|
|
190
198
|
|
|
191
199
|
case 17:
|
|
200
|
+
_context3.next = 21;
|
|
201
|
+
break;
|
|
202
|
+
|
|
203
|
+
case 19:
|
|
204
|
+
if (inBrowser) {
|
|
205
|
+
_context3.next = 21;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
throw Error("ElvWalletClient: Unable to sign");
|
|
210
|
+
|
|
211
|
+
case 21:
|
|
192
212
|
parameters = {
|
|
193
213
|
action: "personal-sign",
|
|
194
214
|
message: message,
|
|
@@ -197,7 +217,16 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
197
217
|
url = new URL(this.appUrl);
|
|
198
218
|
url.hash = UrlJoin("/action", "sign", Utils.B58(JSON.stringify(parameters)));
|
|
199
219
|
url.searchParams.set("origin", window.location.origin);
|
|
200
|
-
|
|
220
|
+
|
|
221
|
+
if (!(!embedded && window.location.origin === url.origin)) {
|
|
222
|
+
_context3.next = 27;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
throw Error("ElvWalletClient: Unable to sign");
|
|
227
|
+
|
|
228
|
+
case 27:
|
|
229
|
+
_context3.next = 29;
|
|
201
230
|
return new Promise( /*#__PURE__*/function () {
|
|
202
231
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
|
|
203
232
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -262,10 +291,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
262
291
|
};
|
|
263
292
|
}());
|
|
264
293
|
|
|
265
|
-
case
|
|
294
|
+
case 29:
|
|
266
295
|
return _context3.abrupt("return", _context3.sent);
|
|
267
296
|
|
|
268
|
-
case
|
|
297
|
+
case 30:
|
|
269
298
|
case "end":
|
|
270
299
|
return _context3.stop();
|
|
271
300
|
}
|
|
@@ -537,14 +566,15 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
537
566
|
|
|
538
567
|
_context7.next = 13;
|
|
539
568
|
return this.client.SetRemoteSigner({
|
|
540
|
-
authToken: decodedToken.clusterToken
|
|
569
|
+
authToken: decodedToken.clusterToken,
|
|
570
|
+
signerURIs: decodedToken.signerURIs
|
|
541
571
|
});
|
|
542
572
|
|
|
543
573
|
case 13:
|
|
544
574
|
this.client.SetStaticToken({
|
|
545
575
|
token: decodedToken.fabricToken
|
|
546
576
|
});
|
|
547
|
-
return _context7.abrupt("return", this.SetAuthorization(decodedToken));
|
|
577
|
+
return _context7.abrupt("return", this.SetAuthorization(_objectSpread({}, decodedToken)));
|
|
548
578
|
|
|
549
579
|
case 15:
|
|
550
580
|
case "end":
|
|
@@ -568,8 +598,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
568
598
|
* @param {string} idToken - An OAuth ID token
|
|
569
599
|
* @param {string=} tenantId - ID of tenant with which to associate the user. If marketplace info was set upon initialization, this will be determined automatically.
|
|
570
600
|
* @param {string=} email - Email address of the user. If not specified, this method will attempt to extract the email from the ID token.
|
|
601
|
+
* @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
|
|
571
602
|
* @param {boolean=} shareEmail=false - Whether or not the user consents to sharing their email
|
|
572
|
-
* @param {number=} tokenDuration=24 - Number of hours the generated authorization token will last before expiring
|
|
573
603
|
*
|
|
574
604
|
* @returns {Promise<Object>} - Returns an authorization tokens that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
575
605
|
* Save this token to avoid having to reauthenticate with OAuth. This token expires after 24 hours.
|
|
@@ -584,64 +614,66 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
584
614
|
key: "AuthenticateOAuth",
|
|
585
615
|
value: function () {
|
|
586
616
|
var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref7) {
|
|
587
|
-
var idToken, tenantId, email, _ref7$shareEmail, shareEmail,
|
|
617
|
+
var idToken, tenantId, email, signerURIs, _ref7$shareEmail, shareEmail, tokenDuration, expiresAt, fabricToken, address, decodedToken;
|
|
588
618
|
|
|
589
619
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
590
620
|
while (1) {
|
|
591
621
|
switch (_context8.prev = _context8.next) {
|
|
592
622
|
case 0:
|
|
593
|
-
idToken = _ref7.idToken, tenantId = _ref7.tenantId, email = _ref7.email,
|
|
623
|
+
idToken = _ref7.idToken, tenantId = _ref7.tenantId, email = _ref7.email, signerURIs = _ref7.signerURIs, _ref7$shareEmail = _ref7.shareEmail, shareEmail = _ref7$shareEmail === void 0 ? false : _ref7$shareEmail;
|
|
624
|
+
tokenDuration = 24;
|
|
594
625
|
|
|
595
626
|
if (!(!tenantId && this.selectedMarketplaceInfo)) {
|
|
596
|
-
_context8.next =
|
|
627
|
+
_context8.next = 6;
|
|
597
628
|
break;
|
|
598
629
|
}
|
|
599
630
|
|
|
600
|
-
_context8.next =
|
|
631
|
+
_context8.next = 5;
|
|
601
632
|
return this.AvailableMarketplaces();
|
|
602
633
|
|
|
603
|
-
case
|
|
634
|
+
case 5:
|
|
604
635
|
tenantId = this.selectedMarketplaceInfo.tenantId;
|
|
605
636
|
|
|
606
|
-
case
|
|
607
|
-
_context8.next =
|
|
637
|
+
case 6:
|
|
638
|
+
_context8.next = 8;
|
|
608
639
|
return this.client.SetRemoteSigner({
|
|
609
640
|
idToken: idToken,
|
|
610
641
|
tenantId: tenantId,
|
|
642
|
+
signerURIs: signerURIs,
|
|
611
643
|
extraData: {
|
|
612
644
|
share_email: shareEmail
|
|
613
645
|
},
|
|
614
646
|
unsignedPublicAuth: true
|
|
615
647
|
});
|
|
616
648
|
|
|
617
|
-
case
|
|
649
|
+
case 8:
|
|
618
650
|
expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
619
|
-
_context8.next =
|
|
651
|
+
_context8.next = 11;
|
|
620
652
|
return this.client.CreateFabricToken({
|
|
621
653
|
duration: tokenDuration * 60 * 60 * 1000
|
|
622
654
|
});
|
|
623
655
|
|
|
624
|
-
case
|
|
656
|
+
case 11:
|
|
625
657
|
fabricToken = _context8.sent;
|
|
626
658
|
address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
|
|
627
659
|
|
|
628
660
|
if (email) {
|
|
629
|
-
_context8.next =
|
|
661
|
+
_context8.next = 22;
|
|
630
662
|
break;
|
|
631
663
|
}
|
|
632
664
|
|
|
633
|
-
_context8.prev =
|
|
665
|
+
_context8.prev = 14;
|
|
634
666
|
decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
|
|
635
667
|
email = decodedToken.email;
|
|
636
|
-
_context8.next =
|
|
668
|
+
_context8.next = 22;
|
|
637
669
|
break;
|
|
638
670
|
|
|
639
|
-
case
|
|
640
|
-
_context8.prev =
|
|
641
|
-
_context8.t0 = _context8["catch"](
|
|
671
|
+
case 19:
|
|
672
|
+
_context8.prev = 19;
|
|
673
|
+
_context8.t0 = _context8["catch"](14);
|
|
642
674
|
throw Error("Failed to decode ID token");
|
|
643
675
|
|
|
644
|
-
case
|
|
676
|
+
case 22:
|
|
645
677
|
this.client.SetStaticToken({
|
|
646
678
|
token: fabricToken
|
|
647
679
|
});
|
|
@@ -652,8 +684,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
652
684
|
address: address,
|
|
653
685
|
email: email,
|
|
654
686
|
expiresAt: expiresAt,
|
|
687
|
+
signerURIs: signerURIs,
|
|
655
688
|
walletType: "Custodial",
|
|
656
|
-
walletName: "Eluvio"
|
|
689
|
+
walletName: "Eluvio",
|
|
690
|
+
register: true
|
|
657
691
|
}),
|
|
658
692
|
signingToken: this.SetAuthorization({
|
|
659
693
|
clusterToken: this.client.signer.authToken,
|
|
@@ -662,17 +696,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
662
696
|
address: address,
|
|
663
697
|
email: email,
|
|
664
698
|
expiresAt: expiresAt,
|
|
699
|
+
signerURIs: signerURIs,
|
|
665
700
|
walletType: "Custodial",
|
|
666
701
|
walletName: "Eluvio"
|
|
667
702
|
})
|
|
668
703
|
});
|
|
669
704
|
|
|
670
|
-
case
|
|
705
|
+
case 24:
|
|
671
706
|
case "end":
|
|
672
707
|
return _context8.stop();
|
|
673
708
|
}
|
|
674
709
|
}
|
|
675
|
-
}, _callee8, this, [[
|
|
710
|
+
}, _callee8, this, [[14, 19]]);
|
|
676
711
|
}));
|
|
677
712
|
|
|
678
713
|
function AuthenticateOAuth(_x12) {
|
|
@@ -757,7 +792,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
757
792
|
address: address,
|
|
758
793
|
expiresAt: expiresAt,
|
|
759
794
|
walletType: "External",
|
|
760
|
-
walletName: walletName
|
|
795
|
+
walletName: walletName,
|
|
796
|
+
register: true
|
|
761
797
|
}));
|
|
762
798
|
|
|
763
799
|
case 9:
|
|
@@ -803,14 +839,19 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
803
839
|
}, {
|
|
804
840
|
key: "SetAuthorization",
|
|
805
841
|
value: function SetAuthorization(_ref10) {
|
|
842
|
+
var _this3 = this;
|
|
843
|
+
|
|
806
844
|
var clusterToken = _ref10.clusterToken,
|
|
807
845
|
fabricToken = _ref10.fabricToken,
|
|
808
846
|
tenantId = _ref10.tenantId,
|
|
809
847
|
address = _ref10.address,
|
|
810
848
|
email = _ref10.email,
|
|
811
849
|
expiresAt = _ref10.expiresAt,
|
|
850
|
+
signerURIs = _ref10.signerURIs,
|
|
812
851
|
walletType = _ref10.walletType,
|
|
813
|
-
walletName = _ref10.walletName
|
|
852
|
+
walletName = _ref10.walletName,
|
|
853
|
+
_ref10$register = _ref10.register,
|
|
854
|
+
register = _ref10$register === void 0 ? false : _ref10$register;
|
|
814
855
|
address = this.client.utils.FormatAddress(address);
|
|
815
856
|
this.__authorization = {
|
|
816
857
|
fabricToken: fabricToken,
|
|
@@ -824,6 +865,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
824
865
|
|
|
825
866
|
if (clusterToken) {
|
|
826
867
|
this.__authorization.clusterToken = clusterToken;
|
|
868
|
+
|
|
869
|
+
if (signerURIs) {
|
|
870
|
+
this.__authorization.signerURIs = signerURIs;
|
|
871
|
+
}
|
|
827
872
|
}
|
|
828
873
|
|
|
829
874
|
this.loggedIn = true;
|
|
@@ -836,6 +881,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
836
881
|
} catch (error) {}
|
|
837
882
|
}
|
|
838
883
|
|
|
884
|
+
if (register) {
|
|
885
|
+
this.client.authClient.MakeAuthServiceRequest({
|
|
886
|
+
path: "/as/wlt/register",
|
|
887
|
+
method: "POST",
|
|
888
|
+
headers: {
|
|
889
|
+
Authorization: "Bearer ".concat(this.AuthToken())
|
|
890
|
+
}
|
|
891
|
+
})["catch"](function (error) {
|
|
892
|
+
_this3.Log("Failed to register account: ", true, error);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
|
|
839
896
|
return token;
|
|
840
897
|
}
|
|
841
898
|
}, {
|
|
@@ -849,7 +906,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
849
906
|
case 0:
|
|
850
907
|
message = _ref11.message, address = _ref11.address;
|
|
851
908
|
|
|
852
|
-
if (window.ethereum) {
|
|
909
|
+
if (!(!inBrowser || !window.ethereum)) {
|
|
853
910
|
_context11.next = 3;
|
|
854
911
|
break;
|
|
855
912
|
}
|
|
@@ -903,7 +960,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
903
960
|
key: "LoadAvailableMarketplaces",
|
|
904
961
|
value: function () {
|
|
905
962
|
var _LoadAvailableMarketplaces = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
906
|
-
var
|
|
963
|
+
var _this4 = this;
|
|
907
964
|
|
|
908
965
|
var forceReload,
|
|
909
966
|
mainSiteHash,
|
|
@@ -960,7 +1017,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
960
1017
|
try {
|
|
961
1018
|
var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
|
|
962
1019
|
|
|
963
|
-
var objectId =
|
|
1020
|
+
var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
|
|
964
1021
|
|
|
965
1022
|
availableMarketplaces[tenantSlug][marketplaceSlug] = _objectSpread(_objectSpread({}, metadata[tenantSlug].marketplaces[marketplaceSlug].info || {}), {}, {
|
|
966
1023
|
tenantName: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_name,
|
|
@@ -974,21 +1031,19 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
974
1031
|
})
|
|
975
1032
|
});
|
|
976
1033
|
availableMarketplacesById[objectId] = availableMarketplaces[tenantSlug][marketplaceSlug];
|
|
977
|
-
|
|
1034
|
+
_this4.marketplaceHashes[objectId] = versionHash; // Fill out selected marketplace info
|
|
978
1035
|
|
|
979
|
-
if (
|
|
980
|
-
if (
|
|
981
|
-
|
|
1036
|
+
if (_this4.selectedMarketplaceInfo) {
|
|
1037
|
+
if (_this4.selectedMarketplaceInfo.tenantSlug === tenantSlug && _this4.selectedMarketplaceInfo.marketplaceSlug === marketplaceSlug || _this4.selectedMarketplaceInfo.marketplaceId === objectId) {
|
|
1038
|
+
_this4.selectedMarketplaceInfo = availableMarketplaces[tenantSlug][marketplaceSlug];
|
|
982
1039
|
}
|
|
983
1040
|
}
|
|
984
1041
|
} catch (error) {
|
|
985
|
-
|
|
1042
|
+
_this4.Log("Eluvio Wallet Client: Unable to load info for marketplace ".concat(tenantSlug, "/").concat(marketplaceSlug), true);
|
|
986
1043
|
}
|
|
987
1044
|
});
|
|
988
1045
|
} catch (error) {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
_this3.Log(error, true);
|
|
1046
|
+
_this4.Log("Eluvio Wallet Client: Failed to load tenant info ".concat(tenantSlug), true, error);
|
|
992
1047
|
}
|
|
993
1048
|
});
|
|
994
1049
|
this.availableMarketplaces = availableMarketplaces;
|
|
@@ -1055,7 +1110,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1055
1110
|
key: "LoadMarketplace",
|
|
1056
1111
|
value: function () {
|
|
1057
1112
|
var _LoadMarketplace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(marketplaceParams) {
|
|
1058
|
-
var
|
|
1113
|
+
var _this5 = this;
|
|
1059
1114
|
|
|
1060
1115
|
var marketplaceInfo, marketplaceId, marketplaceHash, marketplace;
|
|
1061
1116
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
@@ -1110,7 +1165,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1110
1165
|
break;
|
|
1111
1166
|
}
|
|
1112
1167
|
|
|
1113
|
-
if (
|
|
1168
|
+
if (_this5.loggedIn) {
|
|
1114
1169
|
_context14.next = 5;
|
|
1115
1170
|
break;
|
|
1116
1171
|
}
|
|
@@ -1122,7 +1177,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1122
1177
|
case 5:
|
|
1123
1178
|
_context14.prev = 5;
|
|
1124
1179
|
_context14.next = 8;
|
|
1125
|
-
return
|
|
1180
|
+
return _this5.client.ContentObjectMetadata({
|
|
1126
1181
|
versionHash: LinkTargetHash(item.nft_template),
|
|
1127
1182
|
metadataSubtree: "permissioned"
|
|
1128
1183
|
});
|
|
@@ -1172,8 +1227,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1172
1227
|
var embedUrl = new URL("https://embed.v3.contentfabric.io");
|
|
1173
1228
|
var targetHash = LinkTargetHash(marketplace.storefront[key]);
|
|
1174
1229
|
embedUrl.searchParams.set("p", "");
|
|
1175
|
-
embedUrl.searchParams.set("net",
|
|
1176
|
-
embedUrl.searchParams.set("ath", (
|
|
1230
|
+
embedUrl.searchParams.set("net", _this5.network === "main" ? "main" : "demo");
|
|
1231
|
+
embedUrl.searchParams.set("ath", (_this5.__authorization || {}).authToken || _this5.publicStaticToken);
|
|
1177
1232
|
embedUrl.searchParams.set("vid", targetHash);
|
|
1178
1233
|
embedUrl.searchParams.set("ap", "");
|
|
1179
1234
|
|
|
@@ -1218,15 +1273,17 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1218
1273
|
_ref14$sortDesc,
|
|
1219
1274
|
sortDesc,
|
|
1220
1275
|
filter,
|
|
1221
|
-
|
|
1276
|
+
editionFilters,
|
|
1222
1277
|
attributeFilters,
|
|
1223
1278
|
contractAddress,
|
|
1224
1279
|
tokenId,
|
|
1225
1280
|
currency,
|
|
1226
1281
|
marketplaceParams,
|
|
1227
1282
|
tenantId,
|
|
1228
|
-
|
|
1229
|
-
|
|
1283
|
+
collectionIndexes,
|
|
1284
|
+
priceRange,
|
|
1285
|
+
tokenIdRange,
|
|
1286
|
+
capLimit,
|
|
1230
1287
|
sellerAddress,
|
|
1231
1288
|
_ref14$lastNDays,
|
|
1232
1289
|
lastNDays,
|
|
@@ -1238,7 +1295,6 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1238
1295
|
marketplaceInfo,
|
|
1239
1296
|
marketplace,
|
|
1240
1297
|
filters,
|
|
1241
|
-
collection,
|
|
1242
1298
|
path,
|
|
1243
1299
|
_ref16,
|
|
1244
1300
|
contents,
|
|
@@ -1249,8 +1305,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1249
1305
|
while (1) {
|
|
1250
1306
|
switch (_context16.prev = _context16.next) {
|
|
1251
1307
|
case 0:
|
|
1252
|
-
_ref14 = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {}, _ref14$mode = _ref14.mode, mode = _ref14$mode === void 0 ? "listings" : _ref14$mode, _ref14$sortBy = _ref14.sortBy, sortBy = _ref14$sortBy === void 0 ? "created" : _ref14$sortBy, _ref14$sortDesc = _ref14.sortDesc, sortDesc = _ref14$sortDesc === void 0 ? false : _ref14$sortDesc, filter = _ref14.filter,
|
|
1253
|
-
|
|
1308
|
+
_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, sellerAddress = _ref14.sellerAddress, _ref14$lastNDays = _ref14.lastNDays, lastNDays = _ref14$lastNDays === void 0 ? -1 : _ref14$lastNDays, _ref14$start = _ref14.start, start = _ref14$start === void 0 ? 0 : _ref14$start, _ref14$limit = _ref14.limit, limit = _ref14$limit === void 0 ? 50 : _ref14$limit;
|
|
1309
|
+
collectionIndexes = (collectionIndexes || []).map(function (i) {
|
|
1310
|
+
return parseInt(i);
|
|
1311
|
+
});
|
|
1254
1312
|
params = {
|
|
1255
1313
|
sort_by: sortBy,
|
|
1256
1314
|
sort_descending: sortDesc,
|
|
@@ -1271,7 +1329,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1271
1329
|
case 6:
|
|
1272
1330
|
marketplaceInfo = _context16.sent;
|
|
1273
1331
|
|
|
1274
|
-
if (!(
|
|
1332
|
+
if (!(collectionIndexes.length > 0)) {
|
|
1275
1333
|
_context16.next = 11;
|
|
1276
1334
|
break;
|
|
1277
1335
|
}
|
|
@@ -1292,65 +1350,33 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1292
1350
|
filters.push("seller:eq:".concat(this.client.utils.FormatAddress(sellerAddress)));
|
|
1293
1351
|
}
|
|
1294
1352
|
|
|
1295
|
-
if (
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
if (!sku) {
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
var item = marketplace.items.find(function (item) {
|
|
1307
|
-
return item.sku === sku;
|
|
1308
|
-
});
|
|
1309
|
-
|
|
1310
|
-
if (!item) {
|
|
1311
|
-
return;
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
var address = Utils.SafeTraverse(item, "nft_template", "nft", "address");
|
|
1315
|
-
|
|
1316
|
-
if (address) {
|
|
1317
|
-
filters.push("".concat(mode === "owned" ? "contract_addr" : "contract", ":eq:").concat(Utils.FormatAddress(address)));
|
|
1318
|
-
}
|
|
1319
|
-
}); // No valid items, so there must not be anything relevant in the collection
|
|
1320
|
-
|
|
1321
|
-
if (!(filters.length === 0)) {
|
|
1322
|
-
_context16.next = 23;
|
|
1323
|
-
break;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
if (!mode.includes("stats")) {
|
|
1327
|
-
_context16.next = 22;
|
|
1328
|
-
break;
|
|
1329
|
-
}
|
|
1353
|
+
if (marketplace && collectionIndexes.length >= 0) {
|
|
1354
|
+
collectionIndexes.forEach(function (collectionIndex) {
|
|
1355
|
+
var collection = marketplace.collections[collectionIndex];
|
|
1356
|
+
collection.items.forEach(function (sku) {
|
|
1357
|
+
if (!sku) {
|
|
1358
|
+
return;
|
|
1359
|
+
}
|
|
1330
1360
|
|
|
1331
|
-
|
|
1361
|
+
var item = marketplace.items.find(function (item) {
|
|
1362
|
+
return item.sku === sku;
|
|
1363
|
+
});
|
|
1332
1364
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
start: params.start,
|
|
1337
|
-
limit: params.limit,
|
|
1338
|
-
total: 0,
|
|
1339
|
-
more: false
|
|
1340
|
-
},
|
|
1341
|
-
results: []
|
|
1342
|
-
});
|
|
1365
|
+
if (!item) {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1343
1368
|
|
|
1344
|
-
|
|
1345
|
-
_context16.next = 26;
|
|
1346
|
-
break;
|
|
1369
|
+
var address = Utils.SafeTraverse(item, "nft_template", "nft", "address");
|
|
1347
1370
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1371
|
+
if (address) {
|
|
1372
|
+
filters.push("".concat(mode === "owned" ? "contract_addr" : "contract", ":eq:").concat(Utils.FormatAddress(address)));
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
});
|
|
1376
|
+
} else if (mode !== "owned" && marketplaceInfo || tenantId) {
|
|
1350
1377
|
filters.push("tenant:eq:".concat(marketplaceInfo ? marketplaceInfo.tenantId : tenantId));
|
|
1351
1378
|
}
|
|
1352
1379
|
|
|
1353
|
-
case 26:
|
|
1354
1380
|
if (contractAddress) {
|
|
1355
1381
|
if (mode === "owned") {
|
|
1356
1382
|
filters.push("contract_addr:eq:".concat(Utils.FormatAddress(contractAddress)));
|
|
@@ -1372,15 +1398,17 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1372
1398
|
}
|
|
1373
1399
|
}
|
|
1374
1400
|
|
|
1375
|
-
if (
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1401
|
+
if (editionFilters) {
|
|
1402
|
+
editionFilters.forEach(function (editionFilter) {
|
|
1403
|
+
if (mode.includes("listing")) {
|
|
1404
|
+
filters.push("nft/edition_name:eq:".concat(editionFilter));
|
|
1405
|
+
} else if (mode === "owned") {
|
|
1406
|
+
filters.push("meta:@>:{\"edition_name\":\"".concat(editionFilter, "\"}"));
|
|
1407
|
+
params.exact = false;
|
|
1408
|
+
} else {
|
|
1409
|
+
filters.push("edition:eq:".concat(editionFilter));
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1384
1412
|
}
|
|
1385
1413
|
|
|
1386
1414
|
if (attributeFilters) {
|
|
@@ -1404,63 +1432,89 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1404
1432
|
filters.push("created:gt:".concat((Date.now() / 1000 - lastNDays * 24 * 60 * 60).toFixed(0)));
|
|
1405
1433
|
}
|
|
1406
1434
|
|
|
1435
|
+
if (priceRange) {
|
|
1436
|
+
if (priceRange.min) {
|
|
1437
|
+
filters.push("price:gte:".concat(parseFloat(priceRange.min)));
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
if (priceRange.max) {
|
|
1441
|
+
filters.push("price:lte:".concat(parseFloat(priceRange.max)));
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
if (tokenIdRange) {
|
|
1446
|
+
if (tokenIdRange.min) {
|
|
1447
|
+
filters.push("info/token_id:gte:".concat(parseInt(tokenIdRange.min)));
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
if (tokenIdRange.max) {
|
|
1451
|
+
filters.push("info/token_id:lte:".concat(parseInt(tokenIdRange.max)));
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
if (capLimit) {
|
|
1456
|
+
filters.push("info/cap:lte:".concat(parseInt(capLimit)));
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1407
1459
|
_context16.t0 = mode;
|
|
1408
|
-
_context16.next = _context16.t0 === "owned" ?
|
|
1460
|
+
_context16.next = _context16.t0 === "owned" ? 26 : _context16.t0 === "listings" ? 29 : _context16.t0 === "transfers" ? 31 : _context16.t0 === "sales" ? 35 : _context16.t0 === "listing-stats" ? 38 : _context16.t0 === "sales-stats" ? 40 : 42;
|
|
1409
1461
|
break;
|
|
1410
1462
|
|
|
1411
|
-
case
|
|
1463
|
+
case 26:
|
|
1412
1464
|
path = UrlJoin("as", "wlt", "nfts");
|
|
1413
1465
|
|
|
1414
1466
|
if (marketplaceInfo) {
|
|
1415
1467
|
path = UrlJoin("as", "wlt", "nfts", marketplaceInfo.tenantId);
|
|
1416
1468
|
}
|
|
1417
1469
|
|
|
1418
|
-
return _context16.abrupt("break",
|
|
1470
|
+
return _context16.abrupt("break", 42);
|
|
1419
1471
|
|
|
1420
|
-
case
|
|
1472
|
+
case 29:
|
|
1421
1473
|
path = UrlJoin("as", "mkt", "f");
|
|
1422
|
-
return _context16.abrupt("break",
|
|
1474
|
+
return _context16.abrupt("break", 42);
|
|
1423
1475
|
|
|
1424
|
-
case
|
|
1476
|
+
case 31:
|
|
1425
1477
|
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1426
|
-
|
|
1478
|
+
filters.push("action:eq:TRANSFERRED");
|
|
1479
|
+
filters.push("action:eq:SOLD");
|
|
1480
|
+
return _context16.abrupt("break", 42);
|
|
1427
1481
|
|
|
1428
|
-
case
|
|
1482
|
+
case 35:
|
|
1429
1483
|
path = UrlJoin("as", "mkt", "hst", "f");
|
|
1430
1484
|
filters.push("action:eq:SOLD");
|
|
1431
|
-
return _context16.abrupt("break",
|
|
1485
|
+
return _context16.abrupt("break", 42);
|
|
1432
1486
|
|
|
1433
|
-
case
|
|
1487
|
+
case 38:
|
|
1434
1488
|
path = UrlJoin("as", "mkt", "stats", "listed");
|
|
1435
|
-
return _context16.abrupt("break",
|
|
1489
|
+
return _context16.abrupt("break", 42);
|
|
1436
1490
|
|
|
1437
|
-
case
|
|
1491
|
+
case 40:
|
|
1438
1492
|
path = UrlJoin("as", "mkt", "stats", "sold");
|
|
1439
|
-
return _context16.abrupt("break",
|
|
1493
|
+
return _context16.abrupt("break", 42);
|
|
1440
1494
|
|
|
1441
|
-
case
|
|
1495
|
+
case 42:
|
|
1442
1496
|
if (filters.length > 0) {
|
|
1443
1497
|
params.filter = filters;
|
|
1444
1498
|
}
|
|
1445
1499
|
|
|
1446
1500
|
if (!mode.includes("stats")) {
|
|
1447
|
-
_context16.next =
|
|
1501
|
+
_context16.next = 47;
|
|
1448
1502
|
break;
|
|
1449
1503
|
}
|
|
1450
1504
|
|
|
1451
|
-
_context16.next =
|
|
1505
|
+
_context16.next = 46;
|
|
1452
1506
|
return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
|
|
1453
1507
|
path: path,
|
|
1454
1508
|
method: "GET",
|
|
1455
1509
|
queryParams: params
|
|
1456
1510
|
}));
|
|
1457
1511
|
|
|
1458
|
-
case
|
|
1512
|
+
case 46:
|
|
1459
1513
|
return _context16.abrupt("return", _context16.sent);
|
|
1460
1514
|
|
|
1461
|
-
case
|
|
1515
|
+
case 47:
|
|
1462
1516
|
_context16.t2 = Utils;
|
|
1463
|
-
_context16.next =
|
|
1517
|
+
_context16.next = 50;
|
|
1464
1518
|
return this.client.authClient.MakeAuthServiceRequest({
|
|
1465
1519
|
path: path,
|
|
1466
1520
|
method: "GET",
|
|
@@ -1470,22 +1524,22 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1470
1524
|
} : {}
|
|
1471
1525
|
});
|
|
1472
1526
|
|
|
1473
|
-
case
|
|
1527
|
+
case 50:
|
|
1474
1528
|
_context16.t3 = _context16.sent;
|
|
1475
|
-
_context16.next =
|
|
1529
|
+
_context16.next = 53;
|
|
1476
1530
|
return _context16.t2.ResponseToJson.call(_context16.t2, _context16.t3);
|
|
1477
1531
|
|
|
1478
|
-
case
|
|
1532
|
+
case 53:
|
|
1479
1533
|
_context16.t1 = _context16.sent;
|
|
1480
1534
|
|
|
1481
1535
|
if (_context16.t1) {
|
|
1482
|
-
_context16.next =
|
|
1536
|
+
_context16.next = 56;
|
|
1483
1537
|
break;
|
|
1484
1538
|
}
|
|
1485
1539
|
|
|
1486
1540
|
_context16.t1 = [];
|
|
1487
1541
|
|
|
1488
|
-
case
|
|
1542
|
+
case 56:
|
|
1489
1543
|
_ref16 = _context16.t1;
|
|
1490
1544
|
contents = _ref16.contents;
|
|
1491
1545
|
paging = _ref16.paging;
|
|
@@ -1501,12 +1555,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1501
1555
|
})
|
|
1502
1556
|
});
|
|
1503
1557
|
|
|
1504
|
-
case
|
|
1505
|
-
_context16.prev =
|
|
1558
|
+
case 62:
|
|
1559
|
+
_context16.prev = 62;
|
|
1506
1560
|
_context16.t4 = _context16["catch"](11);
|
|
1507
1561
|
|
|
1508
1562
|
if (!(_context16.t4.status && _context16.t4.status.toString() === "404")) {
|
|
1509
|
-
_context16.next =
|
|
1563
|
+
_context16.next = 66;
|
|
1510
1564
|
break;
|
|
1511
1565
|
}
|
|
1512
1566
|
|
|
@@ -1520,15 +1574,15 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1520
1574
|
results: []
|
|
1521
1575
|
});
|
|
1522
1576
|
|
|
1523
|
-
case
|
|
1577
|
+
case 66:
|
|
1524
1578
|
throw _context16.t4;
|
|
1525
1579
|
|
|
1526
|
-
case
|
|
1580
|
+
case 67:
|
|
1527
1581
|
case "end":
|
|
1528
1582
|
return _context16.stop();
|
|
1529
1583
|
}
|
|
1530
1584
|
}
|
|
1531
|
-
}, _callee16, this, [[11,
|
|
1585
|
+
}, _callee16, this, [[11, 62]]);
|
|
1532
1586
|
}));
|
|
1533
1587
|
|
|
1534
1588
|
function FilteredQuery() {
|
|
@@ -1621,11 +1675,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1621
1675
|
case 13:
|
|
1622
1676
|
_context17.prev = 13;
|
|
1623
1677
|
_context17.t0 = _context17["catch"](6);
|
|
1624
|
-
this.Log("Failed to retrieve minting status", true);
|
|
1625
|
-
this.Log(_context17.t0);
|
|
1678
|
+
this.Log("Failed to retrieve minting status", true, _context17.t0);
|
|
1626
1679
|
return _context17.abrupt("return", []);
|
|
1627
1680
|
|
|
1628
|
-
case
|
|
1681
|
+
case 17:
|
|
1629
1682
|
case "end":
|
|
1630
1683
|
return _context17.stop();
|
|
1631
1684
|
}
|
|
@@ -1689,7 +1742,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1689
1742
|
storeAuthToken: storeAuthToken
|
|
1690
1743
|
});
|
|
1691
1744
|
|
|
1692
|
-
if (!(
|
|
1745
|
+
if (!(inBrowser && window.location && window.location.href)) {
|
|
1693
1746
|
_context18.next = 31;
|
|
1694
1747
|
break;
|
|
1695
1748
|
}
|