Skip to content

Commit

Permalink
Merge pull request #6259 from decentraland/release/release20241203
Browse files Browse the repository at this point in the history
Release: 20241203
  • Loading branch information
Ludmilafantaniella authored Dec 3, 2024
2 parents 9b4bdea + eebd86e commit 474ae12
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 31 deletions.
3 changes: 2 additions & 1 deletion browser-interface/packages/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ export type KernelConfigForRenderer = {
kernelVersion: string
rendererVersion: string
avatarTextureAPIBaseUrl: string
urlParamsForWearablesDebug: boolean // temporal field until the whole the wearables catalog sagas flow is migrated to Unity
urlParamsForWearablesDebug: boolean, // temporal field until the whole the wearables catalog sagas flow is migrated to Unity
builderUrl: string
}

export type RealmsInfoForRenderer = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
PREVIEW,
DEBUG,
getTLD,
ETHEREUM_NETWORK
ETHEREUM_NETWORK, BUILDER_SERVER_URL
} from 'config'
import { nameValidCharacterRegex, nameValidRegex } from 'lib/decentraland/profiles/names'
import { getWorld } from '@dcl/schemas'
Expand All @@ -31,6 +31,7 @@ export function kernelConfigForRenderer(): KernelConfigForRenderer {
PREVIEW || ((DEBUG || getTLD() !== 'org') && network !== ETHEREUM_NETWORK.MAINNET)

const urlParamsForWearablesDebug = !!(WITH_FIXED_ITEMS || WITH_FIXED_COLLECTIONS || COLLECTIONS_OR_ITEMS_ALLOWED)
const builderUrl = BUILDER_SERVER_URL;

return {
...globalState.meta.config.world,
Expand All @@ -54,6 +55,7 @@ export function kernelConfigForRenderer(): KernelConfigForRenderer {
/** @deprecated */
rendererVersion: explorerVersion,
avatarTextureAPIBaseUrl: getAvatarTextureAPIBaseUrl(getSelectedNetwork(globalState)),
urlParamsForWearablesDebug: urlParamsForWearablesDebug
urlParamsForWearablesDebug: urlParamsForWearablesDebug,
builderUrl: builderUrl
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private class EmoteCollectionResponse
private readonly ICatalyst catalyst;
private readonly ILambdasService lambdasService;
private readonly DataStore dataStore;
private readonly KernelConfig kernelConfig;
private readonly Dictionary<string, string> ownedUrns = new (new Dictionary<string, string>(), StringIgnoreCaseEqualityComparer.Default);

private EmbeddedEmotesSO embeddedEmotesSo;
Expand All @@ -49,13 +50,15 @@ public LambdasEmotesCatalogService(IEmotesRequestSource emoteSource,
IAddressableResourceProvider addressableResourceProvider,
ICatalyst catalyst,
ILambdasService lambdasService,
DataStore dataStore)
DataStore dataStore,
KernelConfig kernelConfig)
{
this.emoteSource = emoteSource;
this.addressableResourceProvider = addressableResourceProvider;
this.catalyst = catalyst;
this.lambdasService = lambdasService;
this.dataStore = dataStore;
this.kernelConfig = kernelConfig;
}

private async UniTaskVoid InitializeAsyncEmbeddedEmotes()
Expand Down Expand Up @@ -108,21 +111,22 @@ public bool TryGetLoadedEmote(string id, out WearableItem emote)

public async UniTask<WearableItem> RequestEmoteFromBuilderAsync(string emoteId, CancellationToken cancellationToken)
{
const string TEMPLATE_URL = "https://builder-api.decentraland.org/v1/items/:emoteId/";
string url = TEMPLATE_URL.Replace(":emoteId", emoteId);
string domain = GetBuilderDomainUrl();
string url = $"{domain}/items/{emoteId}/";
string templateUrl = $"{domain}/items/{emoteId}/";

try
{
(WearableItemResponseFromBuilder response, bool success) = await lambdasService.GetFromSpecificUrl<WearableItemResponseFromBuilder>(
TEMPLATE_URL, url,
templateUrl, url,
isSigned: true,
cancellationToken: cancellationToken);

if (!success)
throw new Exception($"The request of wearables from builder '{emoteId}' failed!");

WearableItem wearable = response.data.ToWearableItem(
"https://builder-api.decentraland.org/v1/storage/contents/",
$"{domain}/storage/contents/",
assetBundlesUrl);

if (!wearable.IsEmote()) return null;
Expand Down Expand Up @@ -348,8 +352,7 @@ public async UniTask<EmbeddedEmotesSO> GetEmbeddedEmotes()
public async UniTask<IReadOnlyList<WearableItem>> RequestEmoteCollectionInBuilderAsync(IEnumerable<string> collectionIds,
CancellationToken cancellationToken, List<WearableItem> emoteBuffer = null)
{
const string TEMPLATE_URL = "https://builder-api.decentraland.org/v1/collections/:collectionId/items/";

string domain = GetBuilderDomainUrl();
var emotes = emoteBuffer ?? new List<WearableItem>();

var queryParams = new[]
Expand All @@ -360,10 +363,11 @@ public async UniTask<IReadOnlyList<WearableItem>> RequestEmoteCollectionInBuilde

foreach (string collectionId in collectionIds)
{
string url = TEMPLATE_URL.Replace(":collectionId", collectionId);
var url = $"{domain}/collections/{collectionId}";
var templateUrl = $"{domain}/collections/:collectionId/items/";

(WearableCollectionResponseFromBuilder response, bool success) = await lambdasService.GetFromSpecificUrl<WearableCollectionResponseFromBuilder>(
TEMPLATE_URL, url,
templateUrl, url,
cancellationToken: cancellationToken,
isSigned: true,
urlEncodedParams: queryParams);
Expand All @@ -373,7 +377,7 @@ public async UniTask<IReadOnlyList<WearableItem>> RequestEmoteCollectionInBuilde

foreach (BuilderWearable bw in response.data.results)
{
var wearable = bw.ToWearableItem("https://builder-api.decentraland.org/v1/storage/contents/",
var wearable = bw.ToWearableItem($"{domain}/storage/contents/",
assetBundlesUrl);
if (!wearable.IsEmote()) continue;
emotes.Add(wearable);
Expand Down Expand Up @@ -460,4 +464,13 @@ private void EmbedEmotes()
emotesOnUse[embeddedEmote.id] = 5000;
}
}

private string GetBuilderDomainUrl()
{
string domain = kernelConfig.Get().builderUrl;

if (string.IsNullOrEmpty(domain))
domain = "https://builder-api.decentraland.org/v1";
return domain;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void SetUp()
IAddressableResourceProvider addressableResourceProvider = Substitute.For<IAddressableResourceProvider>();
addressableResourceProvider.GetAddressable<EmbeddedEmotesSO>(Arg.Any<string>(), Arg.Any<CancellationToken>()).Returns(GetEmbeddedEmotesSO());
catalog = new LambdasEmotesCatalogService(emotesRequestSource, addressableResourceProvider, Substitute.For<ICatalyst>(),
Substitute.For<ILambdasService>(), new DataStore());
Substitute.For<ILambdasService>(), new DataStore(), KernelConfig.i);
catalog.Initialize();
}

Expand Down Expand Up @@ -342,7 +342,7 @@ public void EmbedEmotes()
IAddressableResourceProvider addressableResourceProvider = Substitute.For<IAddressableResourceProvider>();
addressableResourceProvider.GetAddressable<EmbeddedEmotesSO>(Arg.Any<string>(), Arg.Any<CancellationToken>()).Returns(GetExampleEmbeddedEmotesSO());
catalog = new LambdasEmotesCatalogService(Substitute.For<IEmotesRequestSource>(), addressableResourceProvider,
Substitute.For<ICatalyst>(), Substitute.For<ILambdasService>(), new DataStore());
Substitute.For<ICatalyst>(), Substitute.For<ILambdasService>(), new DataStore(), KernelConfig.i);
catalog.Initialize();

Assert.AreEqual(catalog.emotes["id1"], embededEmotes[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"GUID:68069f49d86442cd9618861b4d74b1aa",
"GUID:dffbb581f2650ea4990781f603ac258a",
"GUID:a4bf61c057a098f4ca05b539a6d8c0fe",
"GUID:28f74c468a54948bfa9f625c5d428f56"
"GUID:28f74c468a54948bfa9f625c5d428f56",
"GUID:c44f6fd10d3d94432a107d581e0096b5"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public WearableCollectionResponse(EntityDto[] entities)
private readonly List<string> pendingWearablesToRequest = new ();
private readonly BaseVariable<FeatureFlag> featureFlags;
private readonly DataStore dataStore;
private readonly KernelConfig kernelConfig;
private readonly ICatalyst catalyst;

private string assetBundlesUrl => featureFlags.Get().IsFeatureEnabled("ab-new-cdn") ? "https://ab-cdn.decentraland.org/" : "https://content-assets-as-bundle.decentraland.org/";
Expand All @@ -64,10 +65,12 @@ public LambdasWearablesCatalogService(BaseDictionary<string, WearableItem> weara
ILambdasService lambdasService,
IServiceProviders serviceProviders,
BaseVariable<FeatureFlag> featureFlags,
DataStore dataStore)
DataStore dataStore,
KernelConfig kernelConfig)
{
this.featureFlags = featureFlags;
this.dataStore = dataStore;
this.kernelConfig = kernelConfig;
this.lambdasService = lambdasService;
WearablesCatalog = wearablesCatalog;
catalyst = serviceProviders.catalyst;
Expand Down Expand Up @@ -285,11 +288,11 @@ public async UniTask<WearableItem> RequestWearableFromBuilderAsync(string wearab
return wearable;
}

const string TEMPLATE_URL = "https://builder-api.decentraland.org/v1/items/:wearableId/";
string url = TEMPLATE_URL.Replace(":wearableId", wearableId);
string domain = GetBuilderDomainUrl();
var url = $"{domain}/items/{wearableId}";

(WearableItemResponseFromBuilder response, bool success) = await lambdasService.GetFromSpecificUrl<WearableItemResponseFromBuilder>(
TEMPLATE_URL, url,
domain, url,
isSigned: true,
cancellationToken: ct);

Expand All @@ -299,7 +302,7 @@ public async UniTask<WearableItem> RequestWearableFromBuilderAsync(string wearab
List<WearableItem> ws = new List<WearableItem>
{
response.data.ToWearableItem(
"https://builder-api.decentraland.org/v1/storage/contents/",
$"{domain}/storage/contents/",
assetBundlesUrl),
};

Expand Down Expand Up @@ -346,8 +349,7 @@ public async UniTask<IReadOnlyList<WearableItem>> RequestWearableCollection(IEnu
public async UniTask<IReadOnlyList<WearableItem>> RequestWearableCollectionInBuilder(IEnumerable<string> collectionIds,
CancellationToken cancellationToken, List<WearableItem> collectionBuffer = null)
{
const string TEMPLATE_URL = "https://builder-api.decentraland.org/v1/collections/:collectionId/items/";

string domain = GetBuilderDomainUrl();
var wearables = collectionBuffer ?? new List<WearableItem>();

var queryParams = new[]
Expand All @@ -358,10 +360,11 @@ public async UniTask<IReadOnlyList<WearableItem>> RequestWearableCollectionInBui

foreach (string collectionId in collectionIds)
{
string url = TEMPLATE_URL.Replace(":collectionId", collectionId);
var url = $"{domain}/collections/{collectionId}/items/";
var templateUrl = $"{domain}/collections/:collectionId/items/";

(WearableCollectionResponseFromBuilder response, bool success) = await lambdasService.GetFromSpecificUrl<WearableCollectionResponseFromBuilder>(
TEMPLATE_URL, url,
templateUrl, url,
isSigned: true,
urlEncodedParams: queryParams,
cancellationToken: cancellationToken);
Expand All @@ -371,7 +374,7 @@ public async UniTask<IReadOnlyList<WearableItem>> RequestWearableCollectionInBui

List<WearableItem> ws = response.data.results
.Select(bw => bw.ToWearableItem(
"https://builder-api.decentraland.org/v1/storage/contents/",
$"{domain}/storage/contents/",
assetBundlesUrl))
.Where(bw => !bw.IsEmote())
.ToList();
Expand Down Expand Up @@ -701,5 +704,14 @@ private bool IsInvalidWearable(EntityDto.MetadataDto metadata)

private bool IsLocalPreview() =>
dataStore.realm.playerRealm.Get()?.serverName?.Equals("LocalPreview", StringComparison.OrdinalIgnoreCase) ?? false;

private string GetBuilderDomainUrl()
{
string domain = kernelConfig.Get().builderUrl;

if (string.IsNullOrEmpty(domain))
domain = "https://builder-api.decentraland.org/v1";
return domain;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void SetUp()

BaseVariable<FeatureFlag> featureFlags = new BaseVariable<FeatureFlag>();
featureFlags.Set(new FeatureFlag());
service = new LambdasWearablesCatalogService(initialCatalog, lambdasService, serviceProviders, featureFlags, new DataStore());
service = new LambdasWearablesCatalogService(initialCatalog, lambdasService, serviceProviders, featureFlags, new DataStore(), KernelConfig.i);
service.Initialize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"CatalystInterfaces",
"FeatureFlagData",
"Utils",
"DataStore"
"DataStore",
"KernelConfiguration"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static ServiceLocator CreateDefault()
featureFlagsDataStore);

var lambdasEmotesCatalogService = new LambdasEmotesCatalogService(emotesRequest, addressableResourceProvider,
result.Get<IServiceProviders>().catalyst, result.Get<ILambdasService>(), DataStore.i);
result.Get<IServiceProviders>().catalyst, result.Get<ILambdasService>(), DataStore.i, KernelConfig.i);
var webInterfaceEmotesCatalogService = new WebInterfaceEmotesCatalogService(EmotesCatalogBridge.GetOrCreate(), addressableResourceProvider);
return new EmotesCatalogServiceProxy(lambdasEmotesCatalogService, webInterfaceEmotesCatalogService, featureFlagsDataStore, KernelConfig.i);
});
Expand All @@ -149,7 +149,8 @@ public static ServiceLocator CreateDefault()
result.Get<ILambdasService>(),
result.Get<IServiceProviders>(),
featureFlagsDataStore,
DataStore.i),
DataStore.i,
KernelConfig.i),
WebInterfaceWearablesCatalogService.Instance,
DataStore.i.common.wearables,
KernelConfig.i,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class KernelConfigModel
public ProceduralSkybox proceduralSkyboxConfig = new ProceduralSkybox();
public string avatarTextureAPIBaseUrl = string.Empty;
public bool urlParamsForWearablesDebug = false;
public string builderUrl = string.Empty;

public override bool Equals(object obj) { return obj is KernelConfigModel other && Equals(other); }

Expand Down Expand Up @@ -48,7 +49,8 @@ public bool Equals(KernelConfigModel other)
&& debugConfig.Equals(other.debugConfig)
&& proceduralSkyboxConfig.Equals(other.proceduralSkyboxConfig)
&& avatarTextureAPIBaseUrl == other.avatarTextureAPIBaseUrl
&& urlParamsForWearablesDebug == other.urlParamsForWearablesDebug;
&& urlParamsForWearablesDebug == other.urlParamsForWearablesDebug
&& builderUrl == other.builderUrl;
}

public string GetTld() =>
Expand All @@ -70,6 +72,7 @@ public KernelConfigModel Clone()
clone.proceduralSkyboxConfig = proceduralSkyboxConfig.Clone();
clone.avatarTextureAPIBaseUrl = avatarTextureAPIBaseUrl;
clone.urlParamsForWearablesDebug = urlParamsForWearablesDebug;
clone.builderUrl = builderUrl;
return clone;
}
}

0 comments on commit 474ae12

Please sign in to comment.