Skip to content

Commit

Permalink
Merge pull request #6247 from decentraland/release/release20240826
Browse files Browse the repository at this point in the history
Release: 20240826
  • Loading branch information
Ludmilafantaniella committed Aug 26, 2024
2 parents fb95b9b + 5092dfe commit bf6738c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,54 @@
{
public static class ExtendedUrnParser
{
private const int QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN = 6;
private const string COLLECTIONS_THIRDPARTY = "collections-thirdparty";
private const int REGULAR_NFTS_SHORT_PARTS = 6;
private const int THIRD_PARTY_V2_SHORTEN_URN_PARTS = 7;
private const string COLLECTIONS_THIRD_PARTY = "collections-thirdparty";

public static string GetShortenedUrn(string urnReceived)
{
int lastIndex = urnReceived.LastIndexOf(':');
if (string.IsNullOrEmpty(urnReceived)) return urnReceived;
if (CountParts(urnReceived) <= REGULAR_NFTS_SHORT_PARTS) return urnReceived;

return lastIndex != -1 && IsExtendedUrn(urnReceived)
? urnReceived.Substring(0, lastIndex)
: urnReceived;
int index;

if (IsThirdPartyCollection(urnReceived))
{
index = -1;

// Third party v2 contains 10 parts, on which 3 are reserved for the tokenId
// "id": urn:decentraland:amoy:collections-thirdparty:back-to-the-future:amoy-eb54:tuxedo-6751:amoy:0x1d9fb685c257e74f869ba302e260c0b68f5ebb37:12
// "tokenId": amoy:0x1d9fb685c257e74f869ba302e260c0b68f5ebb37:12
for (var i = 0; i < THIRD_PARTY_V2_SHORTEN_URN_PARTS; i++)
{
index = urnReceived.IndexOf(':', index + 1);
if (index == -1) break;
}

return index != -1 ? urnReceived[..index] : urnReceived;
}

// TokenId is always placed in the last part for regular nfts
index = urnReceived.LastIndexOf(':');

return index != -1 ? urnReceived[..index] : urnReceived;
}

public static bool IsExtendedUrn(string urn) =>
urn.Split(':').Length > QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN && !urn.Contains(COLLECTIONS_THIRDPARTY);
}
private static int CountParts(string urn)
{
int count = 1;
int index = urn.IndexOf(':');

while (index != -1)
{
count++;
index = urn.IndexOf(':', index + 1);
}

return count;
}

private static bool IsThirdPartyCollection(string urn) =>
!string.IsNullOrEmpty(urn) && urn.Contains(COLLECTIONS_THIRD_PARTY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public GltFastDownloadProvider(string baseUrl, IWebRequestController webRequestC
this.texturePromiseKeeper = texturePromiseKeeper;
}

public async Task<IDownload> Request(Uri uri)
public async Task<IDownload> RequestAsync(Uri uri)
{
if (isDisposed)
return null;
Expand Down Expand Up @@ -75,7 +75,7 @@ private string GetFinalUrl(Uri uri, bool isTexture)
return uri.OriginalString;
}

public async Task<ITextureDownload> RequestTexture(Uri uri, bool nonReadable, bool forceLinear)
public async Task<ITextureDownload> RequestTextureAsync(Uri uri, bool nonReadable, bool forceLinear)
{
if (isDisposed)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,7 @@ private void EquipWearable(
bool resetOverride = true)
{
string shortenWearableId = ExtendedUrnParser.GetShortenedUrn(wearable.id);

if (ExtendedUrnParser.IsExtendedUrn(extendedWearableId))
extendedWearableUrns[shortenWearableId] = extendedWearableId;
extendedWearableUrns[shortenWearableId] = extendedWearableId;

if (wearable.data.category == WearableLiterals.Categories.BODY_SHAPE)
{
Expand Down
2 changes: 1 addition & 1 deletion unity-renderer/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"com.unity.ai.navigation": "1.1.4",
"com.unity.build-report-inspector": "https://github.com/needle-mirror/com.unity.build-report-inspector.git",
"com.unity.cinemachine": "2.9.5",
"com.unity.ide.rider": "3.0.27",
"com.unity.ide.rider": "3.0.31",
"com.unity.ide.visualstudio": "2.0.18",
"com.unity.ide.vscode": "1.2.5",
"com.unity.memoryprofiler": "1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions unity-renderer/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"com.unity.mathematics": "1.2.6",
"com.unity.burst": "1.6.6"
},
"hash": "af15ee7336fa1759dc24953a21e253944180dfc7"
"hash": "3d0abc3b482b0b6c2ab7a0ccbf57647dc05f9811"
},
"com.brunomikoski.animationsequencer": {
"version": "0.3.8",
Expand Down Expand Up @@ -155,7 +155,7 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "3.0.27",
"version": "3.0.31",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down

0 comments on commit bf6738c

Please sign in to comment.