@eluvio/elv-client-js 4.0.139 → 4.0.140
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.json +1 -1
- package/src/walletClient/index.js +47 -48
package/package.json
CHANGED
|
@@ -185,28 +185,8 @@ class ElvWalletClient {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
walletClient.
|
|
190
|
-
client.utils.ResponseToJson(
|
|
191
|
-
client.MakeAuthServiceRequest({
|
|
192
|
-
path: "/as/mw/toplevel",
|
|
193
|
-
queryParams: {env: mode}
|
|
194
|
-
})
|
|
195
|
-
)
|
|
196
|
-
.then(info => {
|
|
197
|
-
walletClient.topLevelInfo = info;
|
|
198
|
-
resolve();
|
|
199
|
-
|
|
200
|
-
if(!skipMarketplaceLoad) {
|
|
201
|
-
walletClient.LoadAvailableMarketplaces();
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
);
|
|
205
|
-
} catch(error) {
|
|
206
|
-
// eslint-disable-next-line no-console
|
|
207
|
-
console.error("Unable to load top level info:");
|
|
208
|
-
// eslint-disable-next-line no-console
|
|
209
|
-
console.error(error);
|
|
188
|
+
if(!skipMarketplaceLoad) {
|
|
189
|
+
walletClient.LoadAvailableMarketplaces();
|
|
210
190
|
}
|
|
211
191
|
|
|
212
192
|
return walletClient;
|
|
@@ -774,39 +754,57 @@ class ElvWalletClient {
|
|
|
774
754
|
|
|
775
755
|
// Internal loading methods
|
|
776
756
|
|
|
777
|
-
async
|
|
778
|
-
if(!
|
|
779
|
-
|
|
757
|
+
async TopLevelInfo(forceReload=false) {
|
|
758
|
+
if(!this.topLevelInfoPromise || forceReload) {
|
|
759
|
+
this.topLevelInfoPromise = this.client.utils.ResponseToJson(
|
|
760
|
+
this.client.MakeAuthServiceRequest({
|
|
761
|
+
path: "/as/mw/toplevel",
|
|
762
|
+
queryParams: {env: this.mode}
|
|
763
|
+
})
|
|
764
|
+
);
|
|
780
765
|
}
|
|
781
766
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
let availableMarketplaces = { ...(this.availableMarketplaces || {}) };
|
|
785
|
-
let availableMarketplacesById = { ...(this.availableMarketplacesById || {}) };
|
|
767
|
+
return await this.topLevelInfoPromise;
|
|
768
|
+
}
|
|
786
769
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
770
|
+
async LoadAvailableMarketplaces(forceReload=false) {
|
|
771
|
+
if(!this.availableMarketplacesPromise || forceReload) {
|
|
772
|
+
this.availableMarketplacesPromise = new Promise(async resolve => {
|
|
773
|
+
const topLevelInfo = await this.TopLevelInfo();
|
|
774
|
+
const marketplaces = topLevelInfo.marketplaces;
|
|
775
|
+
|
|
776
|
+
let availableMarketplaces = {...(this.availableMarketplaces || {})};
|
|
777
|
+
let availableMarketplacesById = {...(this.availableMarketplacesById || {})};
|
|
778
|
+
|
|
779
|
+
marketplaces.map(marketplaceInfo => {
|
|
780
|
+
const marketplaceId = Utils.DecodeVersionHash(marketplaceInfo.source_hash).objectId;
|
|
781
|
+
const marketplaceSlug = marketplaceInfo.slug || marketplaceInfo.name;
|
|
782
|
+
|
|
783
|
+
availableMarketplaces[marketplaceInfo.tenant_slug] = availableMarketplaces[marketplaceInfo.tenant_slug] || {};
|
|
784
|
+
|
|
785
|
+
availableMarketplaces[marketplaceInfo.tenant_slug][marketplaceSlug] = {
|
|
786
|
+
...marketplaceInfo,
|
|
787
|
+
tenantName: marketplaceInfo.tenant_slug,
|
|
788
|
+
tenantSlug: marketplaceInfo.tenant_slug,
|
|
789
|
+
tenantId: marketplaceInfo.tenant_id,
|
|
790
|
+
marketplaceSlug: marketplaceSlug,
|
|
791
|
+
marketplaceId,
|
|
792
|
+
marketplaceHash: marketplaceInfo.source_hash
|
|
793
|
+
};
|
|
790
794
|
|
|
791
|
-
|
|
795
|
+
availableMarketplacesById[marketplaceId] = availableMarketplaces[marketplaceInfo.tenant_slug][marketplaceSlug];
|
|
792
796
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
tenantName: marketplaceInfo.tenant_slug,
|
|
796
|
-
tenantSlug: marketplaceInfo.tenant_slug,
|
|
797
|
-
tenantId: marketplaceInfo.tenant_id,
|
|
798
|
-
marketplaceSlug: marketplaceSlug,
|
|
799
|
-
marketplaceId,
|
|
800
|
-
marketplaceHash: marketplaceInfo.source_hash
|
|
801
|
-
};
|
|
797
|
+
this.marketplaceHashes[marketplaceId] = marketplaceInfo.source_hash;
|
|
798
|
+
});
|
|
802
799
|
|
|
803
|
-
|
|
800
|
+
this.availableMarketplaces = availableMarketplaces;
|
|
801
|
+
this.availableMarketplacesById = availableMarketplacesById;
|
|
804
802
|
|
|
805
|
-
|
|
806
|
-
|
|
803
|
+
resolve();
|
|
804
|
+
});
|
|
805
|
+
}
|
|
807
806
|
|
|
808
|
-
this.
|
|
809
|
-
this.availableMarketplacesById = availableMarketplacesById;
|
|
807
|
+
await this.availableMarketplacesPromise;
|
|
810
808
|
}
|
|
811
809
|
|
|
812
810
|
// Get the hash of the currently linked marketplace
|
|
@@ -829,7 +827,8 @@ class ElvWalletClient {
|
|
|
829
827
|
}
|
|
830
828
|
|
|
831
829
|
async LoadMarketplace(marketplaceParams) {
|
|
832
|
-
await this.
|
|
830
|
+
await this.LoadAvailableMarketplaces();
|
|
831
|
+
|
|
833
832
|
const marketplaceInfo = this.MarketplaceInfo({marketplaceParams});
|
|
834
833
|
|
|
835
834
|
const marketplaceId = marketplaceInfo.marketplaceId;
|