@eluvio/elv-client-js 3.2.19 → 3.2.22
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/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eluvio/elv-client-js",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.22",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@eluvio/elv-client-js",
|
|
9
|
-
"version": "3.2.
|
|
9
|
+
"version": "3.2.21",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@babel/runtime": "^7.8.4",
|
package/package.json
CHANGED
package/src/ElvClient.js
CHANGED
|
@@ -708,6 +708,22 @@ class ElvClient {
|
|
|
708
708
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
709
709
|
*/
|
|
710
710
|
|
|
711
|
+
async PersonalSign({
|
|
712
|
+
message,
|
|
713
|
+
addEthereumPrefix,
|
|
714
|
+
Sign
|
|
715
|
+
}) {
|
|
716
|
+
if(!Sign) {
|
|
717
|
+
Sign = async message => this.authClient.Sign(message);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if(addEthereumPrefix) {
|
|
721
|
+
message = Ethers.utils.keccak256(Buffer.from(`\x19Ethereum Signed Message:\n${message.length}${message}`, "utf-8"));
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return await Sign(message);
|
|
725
|
+
}
|
|
726
|
+
|
|
711
727
|
/**
|
|
712
728
|
* Create a signed authorization token that can be used to authorize against the fabric
|
|
713
729
|
*
|
|
@@ -737,17 +753,9 @@ class ElvClient {
|
|
|
737
753
|
exp: Date.now() + duration,
|
|
738
754
|
};
|
|
739
755
|
|
|
740
|
-
if(!Sign) {
|
|
741
|
-
Sign = async message => this.authClient.Sign(message);
|
|
742
|
-
}
|
|
743
|
-
|
|
744
756
|
let message = `Eluvio Content Fabric Access Token 1.0\n${JSON.stringify(token)}`;
|
|
745
757
|
|
|
746
|
-
|
|
747
|
-
message = Ethers.utils.keccak256(Buffer.from(`\x19Ethereum Signed Message:\n${message.length}${message}`, "utf-8"));
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
const signature = await Sign(message);
|
|
758
|
+
const signature = await this.PersonalSign({message, addEthereumPrefix, Sign});
|
|
751
759
|
|
|
752
760
|
const compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
753
761
|
return `acspjc${this.utils.B58(
|
|
@@ -23,9 +23,12 @@ let WalletConfiguration = {
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
__MARKETPLACE_ORDER: [
|
|
26
|
+
"PREVIEW",
|
|
27
|
+
"wwe-marketplace-main",
|
|
28
|
+
"maskverse-marketplace",
|
|
26
29
|
"dolly-marketplace",
|
|
27
30
|
"oc-marketplace",
|
|
28
|
-
"
|
|
31
|
+
"cirkay-marketplace",
|
|
29
32
|
"emp-marketplace",
|
|
30
33
|
"microsoft",
|
|
31
34
|
"indieflix-marketplace",
|
|
@@ -56,6 +56,7 @@ const FormatNFTDetails = function(entry) {
|
|
|
56
56
|
ContractId: `ictr${Utils.AddressToHash(info.contract_addr)}`,
|
|
57
57
|
ContractName: info.contract_name,
|
|
58
58
|
Cap: info.cap,
|
|
59
|
+
Offers: info.offers || [],
|
|
59
60
|
TokenIdStr: info.token_id_str,
|
|
60
61
|
TokenUri: info.token_uri,
|
|
61
62
|
TokenOrdinal: info.ordinal,
|
|
@@ -16,7 +16,7 @@ const embedded = inBrowser && window.top !== window.self;
|
|
|
16
16
|
* See the Modules section on the sidebar for all client methods unrelated to login and authorization
|
|
17
17
|
*/
|
|
18
18
|
class ElvWalletClient {
|
|
19
|
-
constructor({appId, client, network, mode, marketplaceInfo, storeAuthToken}) {
|
|
19
|
+
constructor({appId, client, network, mode, marketplaceInfo, previewMarketplaceHash, storeAuthToken}) {
|
|
20
20
|
this.appId = appId;
|
|
21
21
|
|
|
22
22
|
this.client = client;
|
|
@@ -31,6 +31,8 @@ class ElvWalletClient {
|
|
|
31
31
|
this.storeAuthToken = storeAuthToken;
|
|
32
32
|
|
|
33
33
|
this.selectedMarketplaceInfo = marketplaceInfo;
|
|
34
|
+
this.previewMarketplaceId = previewMarketplaceHash ? Utils.DecodeVersionHash(previewMarketplaceHash).objectId : undefined;
|
|
35
|
+
this.previewMarketplaceHash = previewMarketplaceHash;
|
|
34
36
|
|
|
35
37
|
this.availableMarketplaces = {};
|
|
36
38
|
this.availableMarketplacesById = {};
|
|
@@ -82,6 +84,7 @@ class ElvWalletClient {
|
|
|
82
84
|
network="main",
|
|
83
85
|
mode="production",
|
|
84
86
|
marketplaceParams,
|
|
87
|
+
previewMarketplaceId,
|
|
85
88
|
storeAuthToken=true
|
|
86
89
|
}) {
|
|
87
90
|
let { tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash } = (marketplaceParams || {});
|
|
@@ -94,6 +97,11 @@ class ElvWalletClient {
|
|
|
94
97
|
|
|
95
98
|
const client = await ElvClient.FromNetworkName({networkName: network, assumeV3: true});
|
|
96
99
|
|
|
100
|
+
let previewMarketplaceHash = previewMarketplaceId;
|
|
101
|
+
if(previewMarketplaceHash && !previewMarketplaceHash.startsWith("hq__")) {
|
|
102
|
+
previewMarketplaceHash = await client.LatestVersionHash({objectId: previewMarketplaceId});
|
|
103
|
+
}
|
|
104
|
+
|
|
97
105
|
const walletClient = new ElvWalletClient({
|
|
98
106
|
appId,
|
|
99
107
|
client,
|
|
@@ -105,6 +113,7 @@ class ElvWalletClient {
|
|
|
105
113
|
marketplaceId: marketplaceHash ? client.utils.DecodeVersionHash(marketplaceHash).objectId : marketplaceId,
|
|
106
114
|
marketplaceHash
|
|
107
115
|
},
|
|
116
|
+
previewMarketplaceHash,
|
|
108
117
|
storeAuthToken
|
|
109
118
|
});
|
|
110
119
|
|
|
@@ -565,14 +574,13 @@ class ElvWalletClient {
|
|
|
565
574
|
|
|
566
575
|
|
|
567
576
|
|
|
568
|
-
// If marketplace slug is specified, load only that marketplace. Otherwise load all
|
|
569
577
|
async LoadAvailableMarketplaces(forceReload=false) {
|
|
570
578
|
if(!forceReload && Object.keys(this.availableMarketplaces) > 0) {
|
|
571
579
|
return;
|
|
572
580
|
}
|
|
573
581
|
|
|
574
582
|
const mainSiteHash = await this.client.LatestVersionHash({objectId: this.mainSiteId});
|
|
575
|
-
|
|
583
|
+
let metadata = await this.client.ContentObjectMetadata({
|
|
576
584
|
versionHash: mainSiteHash,
|
|
577
585
|
metadataSubtree: "public/asset_metadata/tenants",
|
|
578
586
|
resolveLinks: true,
|
|
@@ -594,13 +602,74 @@ class ElvWalletClient {
|
|
|
594
602
|
]
|
|
595
603
|
});
|
|
596
604
|
|
|
605
|
+
// If preview marketplace is specified, load it appropriately
|
|
606
|
+
if(this.previewMarketplaceId) {
|
|
607
|
+
let previewTenantSlug = "PREVIEW";
|
|
608
|
+
let previewMarketplaceSlug, previewMarketplaceMetadata;
|
|
609
|
+
Object.keys(metadata || {}).forEach(tenantSlug =>
|
|
610
|
+
Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(marketplaceSlug => {
|
|
611
|
+
const versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
|
|
612
|
+
const objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
613
|
+
|
|
614
|
+
if(objectId === this.previewMarketplaceId) {
|
|
615
|
+
// Marketplace exists in site meta
|
|
616
|
+
previewTenantSlug = tenantSlug;
|
|
617
|
+
previewMarketplaceSlug = marketplaceSlug;
|
|
618
|
+
|
|
619
|
+
// Deployed marketplace is same as preview marketplace
|
|
620
|
+
if(versionHash === this.previewMarketplaceHash) {
|
|
621
|
+
previewMarketplaceMetadata = metadata[tenantSlug].marketplaces[marketplaceSlug];
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
})
|
|
625
|
+
);
|
|
626
|
+
|
|
627
|
+
// Marketplace not present in branch, or preview version is different - Load metadata directly
|
|
628
|
+
if(!previewMarketplaceMetadata) {
|
|
629
|
+
previewMarketplaceMetadata = await this.client.ContentObjectMetadata({
|
|
630
|
+
versionHash: this.previewMarketplaceHash,
|
|
631
|
+
metadataSubtree: "public/asset_metadata",
|
|
632
|
+
produceLinkUrls: true,
|
|
633
|
+
authorizationToken: this.publicStaticToken,
|
|
634
|
+
noAuth: true,
|
|
635
|
+
select: [
|
|
636
|
+
"slug",
|
|
637
|
+
"info/tenant_id",
|
|
638
|
+
"info/tenant_name",
|
|
639
|
+
"info/branding",
|
|
640
|
+
],
|
|
641
|
+
remove: [
|
|
642
|
+
"info/branding/custom_css"
|
|
643
|
+
]
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
if(!previewMarketplaceSlug) {
|
|
647
|
+
previewMarketplaceSlug = previewMarketplaceMetadata.slug;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
previewMarketplaceMetadata["."] = {
|
|
652
|
+
source: this.previewMarketplaceHash
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
previewMarketplaceMetadata.info["."] = {
|
|
656
|
+
source: this.previewMarketplaceHash
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
previewMarketplaceMetadata.info.branding.preview = true;
|
|
660
|
+
previewMarketplaceMetadata.info.branding.show = true;
|
|
661
|
+
|
|
662
|
+
metadata[previewTenantSlug] = metadata[previewTenantSlug] || {};
|
|
663
|
+
metadata[previewTenantSlug].marketplaces = metadata[previewTenantSlug].marketplaces || {};
|
|
664
|
+
metadata[previewTenantSlug].marketplaces[previewMarketplaceSlug] = previewMarketplaceMetadata;
|
|
665
|
+
}
|
|
666
|
+
|
|
597
667
|
let availableMarketplaces = { ...(this.availableMarketplaces || {}) };
|
|
598
668
|
let availableMarketplacesById = { ...(this.availableMarketplacesById || {}) };
|
|
599
669
|
Object.keys(metadata || {}).forEach(tenantSlug => {
|
|
600
670
|
try {
|
|
601
|
-
availableMarketplaces[tenantSlug] =
|
|
602
|
-
versionHash: metadata[tenantSlug]["."].source
|
|
603
|
-
};
|
|
671
|
+
availableMarketplaces[tenantSlug] = metadata[tenantSlug]["."] ?
|
|
672
|
+
{ versionHash: metadata[tenantSlug]["."].source } : { };
|
|
604
673
|
|
|
605
674
|
Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(marketplaceSlug => {
|
|
606
675
|
try {
|
|
@@ -642,11 +711,17 @@ class ElvWalletClient {
|
|
|
642
711
|
}
|
|
643
712
|
|
|
644
713
|
// Get the hash of the currently linked marketplace
|
|
645
|
-
async LatestMarketplaceHash({
|
|
714
|
+
async LatestMarketplaceHash({marketplaceParams}) {
|
|
715
|
+
const marketplaceInfo = await this.MarketplaceInfo({marketplaceParams});
|
|
716
|
+
|
|
717
|
+
if(this.previewMarketplaceId && this.previewMarketplaceId === marketplaceInfo.marketplaceId) {
|
|
718
|
+
return this.availableMarketplaces[marketplaceInfo.tenantSlug][marketplaceInfo.marketplaceSlug]["."].source;
|
|
719
|
+
}
|
|
720
|
+
|
|
646
721
|
const mainSiteHash = await this.client.LatestVersionHash({objectId: this.mainSiteId});
|
|
647
722
|
const marketplaceLink = await this.client.ContentObjectMetadata({
|
|
648
723
|
versionHash: mainSiteHash,
|
|
649
|
-
metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", tenantSlug, "marketplaces", marketplaceSlug),
|
|
724
|
+
metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "marketplaces", marketplaceInfo.marketplaceSlug),
|
|
650
725
|
resolveLinks: false
|
|
651
726
|
});
|
|
652
727
|
|
|
@@ -657,7 +732,7 @@ class ElvWalletClient {
|
|
|
657
732
|
const marketplaceInfo = this.MarketplaceInfo({marketplaceParams});
|
|
658
733
|
|
|
659
734
|
const marketplaceId = marketplaceInfo.marketplaceId;
|
|
660
|
-
const marketplaceHash = await this.LatestMarketplaceHash({
|
|
735
|
+
const marketplaceHash = await this.LatestMarketplaceHash({marketplaceParams});
|
|
661
736
|
|
|
662
737
|
if(this.cachedMarketplaces[marketplaceId] && this.cachedMarketplaces[marketplaceId].versionHash !== marketplaceHash) {
|
|
663
738
|
delete this.cachedMarketplaces[marketplaceId];
|
|
@@ -711,6 +786,10 @@ class ElvWalletClient {
|
|
|
711
786
|
marketplace.marketplaceId = marketplaceId;
|
|
712
787
|
marketplace.versionHash = marketplaceHash;
|
|
713
788
|
|
|
789
|
+
if(this.previewMarketplaceId && marketplaceId === this.previewMarketplaceId) {
|
|
790
|
+
marketplace.branding.preview = true;
|
|
791
|
+
}
|
|
792
|
+
|
|
714
793
|
// Generate embed URLs for pack opening animations
|
|
715
794
|
["purchase_animation", "purchase_animation__mobile", "reveal_animation", "reveal_animation_mobile"].forEach(key => {
|
|
716
795
|
try {
|