From d4c9ee267a9567ca1fbf742d69eb281f4d2bd3a3 Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso Date: Mon, 15 Jul 2024 17:05:45 -0300 Subject: [PATCH 1/7] renamed tpw param --- .../WearablesCatalogService/LambdasWearablesCatalogService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity-renderer/Assets/DCLServices/WearablesCatalogService/LambdasWearablesCatalogService.cs b/unity-renderer/Assets/DCLServices/WearablesCatalogService/LambdasWearablesCatalogService.cs index 68481810ab..d58c204db2 100644 --- a/unity-renderer/Assets/DCLServices/WearablesCatalogService/LambdasWearablesCatalogService.cs +++ b/unity-renderer/Assets/DCLServices/WearablesCatalogService/LambdasWearablesCatalogService.cs @@ -132,7 +132,7 @@ public void Dispose() queryParams.Add(("collectionType", "on-chain")); if ((collectionTypeMask & NftCollectionType.ThirdParty) != 0) - queryParams.Add(("collectionType", "third-party")); + queryParams.Add(("collectionType", "linked-wearable")); if (thirdPartyCollectionIds != null) foreach (string collectionId in thirdPartyCollectionIds) From 651497d33fa84dc43b3f5ddac03e6e02d1866056 Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso Date: Wed, 17 Jul 2024 12:33:19 -0300 Subject: [PATCH 2/7] dont consider extended urns for collections-linked-wearables --- .../WearablesCatalogService/ExtendedUrnParser.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs index 53262e9d8d..d70bd7b2b8 100644 --- a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs +++ b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs @@ -3,7 +3,8 @@ public static class ExtendedUrnParser { private const int QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN = 6; - private const string COLLECTIONS_THIRDPARTY = "collections-thirdparty"; + private const string COLLECTIONS_THIRD_PARTY = "collections-thirdparty"; + private const string COLLECTIONS_LINKED_WEARABLES = "collections-linked-wearables"; public static string GetShortenedUrn(string urnReceived) { @@ -15,7 +16,8 @@ public static string GetShortenedUrn(string urnReceived) } public static bool IsExtendedUrn(string urn) => - urn.Split(':').Length > QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN && !urn.Contains(COLLECTIONS_THIRDPARTY); + urn.Split(':').Length > QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN + && !urn.Contains(COLLECTIONS_THIRD_PARTY) + && !urn.Contains(COLLECTIONS_LINKED_WEARABLES); } - } From fa559e4ce9f1b518400cf6a1e071e689f0189549 Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso Date: Wed, 17 Jul 2024 12:42:55 -0300 Subject: [PATCH 3/7] Revert "dont consider extended urns for collections-linked-wearables" This reverts commit 651497d33fa84dc43b3f5ddac03e6e02d1866056. --- .../WearablesCatalogService/ExtendedUrnParser.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs index d70bd7b2b8..53262e9d8d 100644 --- a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs +++ b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs @@ -3,8 +3,7 @@ public static class ExtendedUrnParser { private const int QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN = 6; - private const string COLLECTIONS_THIRD_PARTY = "collections-thirdparty"; - private const string COLLECTIONS_LINKED_WEARABLES = "collections-linked-wearables"; + private const string COLLECTIONS_THIRDPARTY = "collections-thirdparty"; public static string GetShortenedUrn(string urnReceived) { @@ -16,8 +15,7 @@ public static string GetShortenedUrn(string urnReceived) } public static bool IsExtendedUrn(string urn) => - urn.Split(':').Length > QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN - && !urn.Contains(COLLECTIONS_THIRD_PARTY) - && !urn.Contains(COLLECTIONS_LINKED_WEARABLES); + urn.Split(':').Length > QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN && !urn.Contains(COLLECTIONS_THIRDPARTY); } + } From 7e941ef1ef77ec056a7e933bb98dffbb126a83fc Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso Date: Wed, 17 Jul 2024 16:01:46 -0300 Subject: [PATCH 4/7] allocation improvements on urn checking & added collections-linked-wearables rule --- .../ExtendedUrnParser.cs | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs index 53262e9d8d..eec611ae18 100644 --- a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs +++ b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs @@ -2,20 +2,45 @@ { 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 LINKED_NFTS_SHORT_PARTS = 8; + private const string COLLECTIONS_THIRD_PARTY = "collections-thirdparty"; + private const string COLLECTIONS_LINKED_WEARABLES = "collections-linked-wearables"; public static string GetShortenedUrn(string urnReceived) { + if (!IsExtendedUrn(urnReceived)) return urnReceived; + int lastIndex = urnReceived.LastIndexOf(':'); - return lastIndex != -1 && IsExtendedUrn(urnReceived) - ? urnReceived.Substring(0, lastIndex) + return lastIndex != -1 + ? urnReceived[..lastIndex] : urnReceived; } - public static bool IsExtendedUrn(string urn) => - urn.Split(':').Length > QUANTITY_OF_PARTS_ON_SHORTENED_ITEMS_URN && !urn.Contains(COLLECTIONS_THIRDPARTY); - } + public static bool IsExtendedUrn(string urn) + { + if (urn.Contains(COLLECTIONS_THIRD_PARTY)) + return false; + + if (urn.Contains(COLLECTIONS_LINKED_WEARABLES)) + return CountParts(urn) > LINKED_NFTS_SHORT_PARTS; + + return CountParts(urn) > REGULAR_NFTS_SHORT_PARTS; + } + private static int CountParts(string urn) + { + int count = 1; + int index = urn.IndexOf(':'); + + while (index != -1) + { + count++; + index = urn.IndexOf(':', index + 1); + } + + return count; + } + } } From ebc38416659c16be6c9f9961d032404338b69e34 Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso Date: Tue, 6 Aug 2024 12:40:18 -0300 Subject: [PATCH 5/7] removed collections-linked-wearables urn checks --- .../DCLServices/WearablesCatalogService/ExtendedUrnParser.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs index eec611ae18..2ec0a61cd0 100644 --- a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs +++ b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs @@ -3,9 +3,7 @@ public static class ExtendedUrnParser { private const int REGULAR_NFTS_SHORT_PARTS = 6; - private const int LINKED_NFTS_SHORT_PARTS = 8; private const string COLLECTIONS_THIRD_PARTY = "collections-thirdparty"; - private const string COLLECTIONS_LINKED_WEARABLES = "collections-linked-wearables"; public static string GetShortenedUrn(string urnReceived) { @@ -23,9 +21,6 @@ public static bool IsExtendedUrn(string urn) if (urn.Contains(COLLECTIONS_THIRD_PARTY)) return false; - if (urn.Contains(COLLECTIONS_LINKED_WEARABLES)) - return CountParts(urn) > LINKED_NFTS_SHORT_PARTS; - return CountParts(urn) > REGULAR_NFTS_SHORT_PARTS; } From 8d5d8c7fc6123ec3415053a0095042de79e841de Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso Date: Tue, 6 Aug 2024 16:05:46 -0300 Subject: [PATCH 6/7] reverted collectionType param to third-party --- .../WearablesCatalogService/LambdasWearablesCatalogService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity-renderer/Assets/DCLServices/WearablesCatalogService/LambdasWearablesCatalogService.cs b/unity-renderer/Assets/DCLServices/WearablesCatalogService/LambdasWearablesCatalogService.cs index d58c204db2..68481810ab 100644 --- a/unity-renderer/Assets/DCLServices/WearablesCatalogService/LambdasWearablesCatalogService.cs +++ b/unity-renderer/Assets/DCLServices/WearablesCatalogService/LambdasWearablesCatalogService.cs @@ -132,7 +132,7 @@ public void Dispose() queryParams.Add(("collectionType", "on-chain")); if ((collectionTypeMask & NftCollectionType.ThirdParty) != 0) - queryParams.Add(("collectionType", "linked-wearable")); + queryParams.Add(("collectionType", "third-party")); if (thirdPartyCollectionIds != null) foreach (string collectionId in thirdPartyCollectionIds) From a79b8a4e3dfd7517e539694f3763d0a691f0a9a6 Mon Sep 17 00:00:00 2001 From: Nicolas Lorusso Date: Thu, 15 Aug 2024 15:37:58 -0300 Subject: [PATCH 7/7] fix on urn processing for tpw v2 --- .../ExtendedUrnParser.cs | 36 +++++++++++++------ .../BackpackEditorHUDController.cs | 4 +-- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs index 2ec0a61cd0..94d6f820cc 100644 --- a/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs +++ b/unity-renderer/Assets/DCLServices/WearablesCatalogService/ExtendedUrnParser.cs @@ -3,25 +3,36 @@ public static class ExtendedUrnParser { 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) { - if (!IsExtendedUrn(urnReceived)) return urnReceived; + if (string.IsNullOrEmpty(urnReceived)) return urnReceived; + if (CountParts(urnReceived) <= REGULAR_NFTS_SHORT_PARTS) return urnReceived; - int lastIndex = urnReceived.LastIndexOf(':'); + int index; - return lastIndex != -1 - ? urnReceived[..lastIndex] - : urnReceived; - } + 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; + } - public static bool IsExtendedUrn(string urn) - { - if (urn.Contains(COLLECTIONS_THIRD_PARTY)) - return false; + // TokenId is always placed in the last part for regular nfts + index = urnReceived.LastIndexOf(':'); - return CountParts(urn) > REGULAR_NFTS_SHORT_PARTS; + return index != -1 ? urnReceived[..index] : urnReceived; } private static int CountParts(string urn) @@ -37,5 +48,8 @@ private static int CountParts(string urn) return count; } + + private static bool IsThirdPartyCollection(string urn) => + !string.IsNullOrEmpty(urn) && urn.Contains(COLLECTIONS_THIRD_PARTY); } } diff --git a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs index 10ad64ec7f..6390b6868a 100644 --- a/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs +++ b/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BackpackEditorHUDV2/BackpackEditorHUDController.cs @@ -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) {