@eluvio/elv-client-js 3.2.14 → 3.2.18
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/ElvWalletClient-min.js +9 -9
- package/dist/ElvWalletClient-node-min.js +10 -10
- package/dist/src/walletClient/ClientMethods.js +793 -481
- package/dist/src/walletClient/Configuration.js +2 -0
- package/dist/src/walletClient/Profile.js +368 -0
- package/dist/src/walletClient/Utils.js +33 -29
- package/dist/src/walletClient/index.js +90 -63
- package/package.json +1 -1
- package/src/walletClient/ClientMethods.js +151 -13
- package/src/walletClient/Configuration.js +2 -0
- package/src/walletClient/Profile.js +182 -0
- package/src/walletClient/Utils.js +29 -24
- package/src/walletClient/index.js +42 -19
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const {ElvClient} = require("../ElvClient");
|
|
2
2
|
const Configuration = require("./Configuration");
|
|
3
3
|
const {LinkTargetHash, FormatNFT, ActionPopup} = require("./Utils");
|
|
4
|
+
const HTTPClient = require("../HttpClient");
|
|
4
5
|
const UrlJoin = require("url-join");
|
|
5
6
|
const Utils = require("../Utils");
|
|
6
7
|
const Ethers = require("ethers");
|
|
@@ -15,7 +16,9 @@ const embedded = inBrowser && window.top !== window.self;
|
|
|
15
16
|
* See the Modules section on the sidebar for all client methods unrelated to login and authorization
|
|
16
17
|
*/
|
|
17
18
|
class ElvWalletClient {
|
|
18
|
-
constructor({client, network, mode, marketplaceInfo, storeAuthToken}) {
|
|
19
|
+
constructor({appId, client, network, mode, marketplaceInfo, storeAuthToken}) {
|
|
20
|
+
this.appId = appId;
|
|
21
|
+
|
|
19
22
|
this.client = client;
|
|
20
23
|
this.loggedIn = false;
|
|
21
24
|
|
|
@@ -33,6 +36,9 @@ class ElvWalletClient {
|
|
|
33
36
|
this.availableMarketplacesById = {};
|
|
34
37
|
this.marketplaceHashes = {};
|
|
35
38
|
|
|
39
|
+
this.stateStoreUrls = Configuration[network].stateStoreUrls;
|
|
40
|
+
this.stateStoreClient = new HTTPClient({uris: this.stateStoreUrls});
|
|
41
|
+
|
|
36
42
|
// Caches
|
|
37
43
|
this.cachedMarketplaces = {};
|
|
38
44
|
this.cachedCSS = {};
|
|
@@ -60,8 +66,10 @@ class ElvWalletClient {
|
|
|
60
66
|
*
|
|
61
67
|
* Specify tenantSlug and marketplaceSlug to automatically associate this tenant with a particular marketplace.
|
|
62
68
|
*
|
|
69
|
+
*
|
|
63
70
|
* @methodGroup Initialization
|
|
64
71
|
* @namedParams
|
|
72
|
+
* @param {string} appId - A string identifying your app. This is used for namespacing user profile data.
|
|
65
73
|
* @param {string} network=main - Name of the Fabric network to use (`main`, `demo`)
|
|
66
74
|
* @param {string} mode=production - Environment to use (`production`, `staging`)
|
|
67
75
|
* @param {Object=} marketplaceParams - Marketplace parameters
|
|
@@ -70,6 +78,7 @@ class ElvWalletClient {
|
|
|
70
78
|
* @returns {Promise<ElvWalletClient>}
|
|
71
79
|
*/
|
|
72
80
|
static async Initialize({
|
|
81
|
+
appId="general",
|
|
73
82
|
network="main",
|
|
74
83
|
mode="production",
|
|
75
84
|
marketplaceParams,
|
|
@@ -86,6 +95,7 @@ class ElvWalletClient {
|
|
|
86
95
|
const client = await ElvClient.FromNetworkName({networkName: network, assumeV3: true});
|
|
87
96
|
|
|
88
97
|
const walletClient = new ElvWalletClient({
|
|
98
|
+
appId,
|
|
89
99
|
client,
|
|
90
100
|
network,
|
|
91
101
|
mode,
|
|
@@ -217,6 +227,9 @@ class ElvWalletClient {
|
|
|
217
227
|
/**
|
|
218
228
|
* Direct the user to the Eluvio Media Wallet login page.
|
|
219
229
|
*
|
|
230
|
+
* For redirect login, the authorization token will be included in the URL parameters of the callbackUrl. Simply re-initialize the wallet client and it will authorize with this token,
|
|
231
|
+
* or you can retrieve the parameter (`elvToken`) yourself and use it in the <a href="#Authenticate">Authenticate</a> method.
|
|
232
|
+
*
|
|
220
233
|
* <b>NOTE:</b> The domain of the opening window (popup flow) or domain of the `callbackUrl` (redirect flow) MUST be allowed in the metadata of the specified marketplace.
|
|
221
234
|
*
|
|
222
235
|
* @methodGroup Login
|
|
@@ -682,6 +695,7 @@ class ElvWalletClient {
|
|
|
682
695
|
}
|
|
683
696
|
|
|
684
697
|
item.nftTemplateMetadata = ((item.nft_template || {}).nft || {});
|
|
698
|
+
item.nftTemplateHash = ((item.nft_template || {})["."] || {}).source;
|
|
685
699
|
item.itemIndex = index;
|
|
686
700
|
|
|
687
701
|
return item;
|
|
@@ -743,20 +757,29 @@ class ElvWalletClient {
|
|
|
743
757
|
priceRange,
|
|
744
758
|
tokenIdRange,
|
|
745
759
|
capLimit,
|
|
760
|
+
userAddress,
|
|
746
761
|
sellerAddress,
|
|
747
762
|
lastNDays=-1,
|
|
763
|
+
includeCheckoutLocked=false,
|
|
748
764
|
start=0,
|
|
749
765
|
limit=50
|
|
750
766
|
}={}) {
|
|
751
767
|
collectionIndexes = (collectionIndexes || []).map(i => parseInt(i));
|
|
752
768
|
|
|
753
769
|
let params = {
|
|
754
|
-
sort_by: sortBy,
|
|
755
|
-
sort_descending: sortDesc,
|
|
756
770
|
start,
|
|
757
|
-
limit
|
|
771
|
+
limit,
|
|
772
|
+
sort_descending: sortDesc
|
|
758
773
|
};
|
|
759
774
|
|
|
775
|
+
if(mode !== "leaderboard") {
|
|
776
|
+
params.sort_by = sortBy;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
if(mode.includes("listings") && includeCheckoutLocked) {
|
|
780
|
+
params.checkout = true;
|
|
781
|
+
}
|
|
782
|
+
|
|
760
783
|
let marketplaceInfo, marketplace;
|
|
761
784
|
if(marketplaceParams) {
|
|
762
785
|
marketplaceInfo = await this.MarketplaceInfo({marketplaceParams});
|
|
@@ -771,6 +794,8 @@ class ElvWalletClient {
|
|
|
771
794
|
|
|
772
795
|
if(sellerAddress) {
|
|
773
796
|
filters.push(`seller:eq:${this.client.utils.FormatAddress(sellerAddress)}`);
|
|
797
|
+
} else if(userAddress && mode !== "owned") {
|
|
798
|
+
filters.push(`addr:eq:${this.client.utils.FormatAddress(userAddress)}`);
|
|
774
799
|
}
|
|
775
800
|
|
|
776
801
|
if(marketplace && collectionIndexes.length >= 0) {
|
|
@@ -797,7 +822,7 @@ class ElvWalletClient {
|
|
|
797
822
|
}
|
|
798
823
|
});
|
|
799
824
|
});
|
|
800
|
-
} else if(
|
|
825
|
+
} else if(marketplaceInfo || tenantId) {
|
|
801
826
|
filters.push(`tenant:eq:${marketplaceInfo ? marketplaceInfo.tenantId : tenantId}`);
|
|
802
827
|
}
|
|
803
828
|
|
|
@@ -812,11 +837,10 @@ class ElvWalletClient {
|
|
|
812
837
|
filters.push(`token:eq:${tokenId}`);
|
|
813
838
|
}
|
|
814
839
|
} else if(filter) {
|
|
815
|
-
if(mode
|
|
840
|
+
if(mode === "listing") {
|
|
816
841
|
filters.push(`nft/display_name:eq:${filter}`);
|
|
817
842
|
} else if(mode === "owned") {
|
|
818
|
-
filters.push(`meta
|
|
819
|
-
params.exact = false;
|
|
843
|
+
filters.push(`meta/display_name:eq:${filter}`);
|
|
820
844
|
} else {
|
|
821
845
|
filters.push(`name:eq:${filter}`);
|
|
822
846
|
}
|
|
@@ -879,12 +903,7 @@ class ElvWalletClient {
|
|
|
879
903
|
let path;
|
|
880
904
|
switch(mode) {
|
|
881
905
|
case "owned":
|
|
882
|
-
path = UrlJoin("as", "wlt",
|
|
883
|
-
|
|
884
|
-
if(marketplaceInfo) {
|
|
885
|
-
path = UrlJoin("as", "wlt", "nfts", marketplaceInfo.tenantId);
|
|
886
|
-
}
|
|
887
|
-
|
|
906
|
+
path = UrlJoin("as", "wlt", userAddress || this.UserAddress());
|
|
888
907
|
break;
|
|
889
908
|
|
|
890
909
|
case "listings":
|
|
@@ -900,6 +919,7 @@ class ElvWalletClient {
|
|
|
900
919
|
case "sales":
|
|
901
920
|
path = UrlJoin("as", "mkt", "hst", "f");
|
|
902
921
|
filters.push("action:eq:SOLD");
|
|
922
|
+
filters.push("seller:co:0x");
|
|
903
923
|
break;
|
|
904
924
|
|
|
905
925
|
case "listing-stats":
|
|
@@ -908,6 +928,11 @@ class ElvWalletClient {
|
|
|
908
928
|
|
|
909
929
|
case "sales-stats":
|
|
910
930
|
path = UrlJoin("as", "mkt", "stats", "sold");
|
|
931
|
+
filters.push("seller:co:0x");
|
|
932
|
+
break;
|
|
933
|
+
|
|
934
|
+
case "leaderboard":
|
|
935
|
+
path = UrlJoin("as", "wlt", "leaders");
|
|
911
936
|
break;
|
|
912
937
|
}
|
|
913
938
|
|
|
@@ -929,10 +954,7 @@ class ElvWalletClient {
|
|
|
929
954
|
await this.client.authClient.MakeAuthServiceRequest({
|
|
930
955
|
path,
|
|
931
956
|
method: "GET",
|
|
932
|
-
queryParams: params
|
|
933
|
-
headers: mode === "owned" ?
|
|
934
|
-
{ Authorization: `Bearer ${this.AuthToken()}` } :
|
|
935
|
-
{}
|
|
957
|
+
queryParams: params
|
|
936
958
|
})
|
|
937
959
|
) || [];
|
|
938
960
|
|
|
@@ -943,7 +965,7 @@ class ElvWalletClient {
|
|
|
943
965
|
total: paging.total,
|
|
944
966
|
more: paging.total > start + limit
|
|
945
967
|
},
|
|
946
|
-
results: (contents || []).map(item => ["owned", "listings"].includes(mode) ? FormatNFT(item) : item)
|
|
968
|
+
results: (contents || []).map(item => ["owned", "listings"].includes(mode) ? FormatNFT(this, item) : item)
|
|
947
969
|
};
|
|
948
970
|
} catch(error) {
|
|
949
971
|
if(error.status && error.status.toString() === "404") {
|
|
@@ -1026,5 +1048,6 @@ class ElvWalletClient {
|
|
|
1026
1048
|
}
|
|
1027
1049
|
|
|
1028
1050
|
Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
|
|
1051
|
+
Object.assign(ElvWalletClient.prototype, require("./Profile"));
|
|
1029
1052
|
|
|
1030
1053
|
exports.ElvWalletClient = ElvWalletClient;
|