From 05996305a86716167adf06fc1ad888bd18427624 Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Tue, 17 Dec 2024 12:27:54 +1000 Subject: [PATCH 1/4] fix: update submodule (#3501) --- Plugins/unreal-immutable-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/unreal-immutable-sdk b/Plugins/unreal-immutable-sdk index 62ac863..43db9c1 160000 --- a/Plugins/unreal-immutable-sdk +++ b/Plugins/unreal-immutable-sdk @@ -1 +1 @@ -Subproject commit 62ac8638c38c289cb655567b1ac3f9f98773ffbc +Subproject commit 43db9c1fc0d329b79746afd6b35c5539115f5290 From 37cf1f5f580ac3a3df6b93aa10e3e402e683927c Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Tue, 17 Dec 2024 12:28:28 +1000 Subject: [PATCH 2/4] fix: compile errors (#3501) --- .../Private/UI/Marketplace/SearchStacksListingWidget.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListingWidget.cpp b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListingWidget.cpp index 08927e8..3b68023 100644 --- a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListingWidget.cpp +++ b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListingWidget.cpp @@ -81,9 +81,14 @@ void USearchStacksListingWidget::ProcessModel(const ImmutablezkEVMAPI::Model& Da { for (auto Attribute : StackBundle.Stack.Attributes.GetValue()) { - TSharedPtr Value; + FString JsonBody; - AddMetadataAttribute(Attribute.TraitType, Attribute.Value); + ImmutablezkEVMAPI::JsonWriter JsonWriter = TJsonWriterFactory<>::Create(&JsonBody); + + Attribute.Value.WriteJson(JsonWriter); + JsonWriter->Close(); + + AddMetadataAttribute(Attribute.TraitType, JsonBody); } } From b3e2896f33245e6cf55f7248919cf6cd72a84f2a Mon Sep 17 00:00:00 2001 From: ImmutableJeffrey Date: Tue, 14 Jan 2025 14:12:39 +1000 Subject: [PATCH 3/4] chore: update sample game to use oneOf functionality (#3521) --- .../UI/Marketplace/SearchStacksItemWidget.cpp | 23 ++++++-- .../Marketplace/SearchStacksListingWidget.cpp | 14 ++--- .../SearchStacksListing_ListingsWidget.cpp | 56 ++++++++++--------- 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksItemWidget.cpp b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksItemWidget.cpp index 32b5fec..a7fdf96 100644 --- a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksItemWidget.cpp +++ b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksItemWidget.cpp @@ -85,13 +85,28 @@ void USearchStacksItemWidget::SetName(const FString& Name) void USearchStacksItemWidget::SetPrice(const ImmutablezkEVMAPI::APIMarketPriceDetails& PriceDetails) { - if (NFTLowestPrice && PriceDetails.Token.Decimals.IsSet()) + if (!NFTLowestPrice) { - FString Price = FMathUtility::ConvertWeiStringToFloatValueString(PriceDetails.Token.Decimals.GetValue(), PriceDetails.Amount); + return; + } + + if (const ImmutablezkEVMAPI::APIMarketPriceERC20Token* APIMarketPriceERC20Token = PriceDetails.Token.OneOf.TryGet()) + { + const TOptional& Decimals = APIMarketPriceERC20Token->Decimals; + + if (Decimals.IsSet()) + { + FString Price = FMathUtility::ConvertWeiStringToFloatValueString(Decimals.GetValue(), PriceDetails.Amount); + + NFTLowestPrice->SetText(FText::FromString(Price)); + } - NFTLowestPrice->SetText(FText::FromString(Price)); + const TOptional& Symbol = APIMarketPriceERC20Token->Symbol; - SetPriceTokenName(PriceDetails.Token.Symbol.GetValue()); + if (Symbol.IsSet()) + { + SetPriceTokenName(Symbol.GetValue()); + } } } diff --git a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListingWidget.cpp b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListingWidget.cpp index 3b68023..2eb2443 100644 --- a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListingWidget.cpp +++ b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListingWidget.cpp @@ -79,16 +79,14 @@ void USearchStacksListingWidget::ProcessModel(const ImmutablezkEVMAPI::Model& Da if (StackBundle.Stack.Attributes.IsSet()) { - for (auto Attribute : StackBundle.Stack.Attributes.GetValue()) + for (const ImmutablezkEVMAPI::APINFTMetadataAttribute& Attribute : StackBundle.Stack.Attributes.GetValue()) { - FString JsonBody; + const FString* AttributeValue = Attribute.Value.OneOf.TryGet(); - ImmutablezkEVMAPI::JsonWriter JsonWriter = TJsonWriterFactory<>::Create(&JsonBody); - - Attribute.Value.WriteJson(JsonWriter); - JsonWriter->Close(); - - AddMetadataAttribute(Attribute.TraitType, JsonBody); + if (ensureAlways(AttributeValue)) + { + AddMetadataAttribute(Attribute.TraitType, *AttributeValue); + } } } diff --git a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListing_ListingsWidget.cpp b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListing_ListingsWidget.cpp index 5607acc..1c6e186 100644 --- a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListing_ListingsWidget.cpp +++ b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksListing_ListingsWidget.cpp @@ -7,7 +7,6 @@ #include "ImmutablezkEVMAPI/Public/APIFee.h" #include "UI/Utility/MathUtility.h" - void USearchStacksListing_ListingsWidget::AddItem(const ImmutablezkEVMAPI::APIListing& Listing, bool IsIdEven, const UItemWidget::FOnSelectionChange& InOnSelectionChangeDelegate) { if (ScrollBoxListings) @@ -17,38 +16,41 @@ void USearchStacksListing_ListingsWidget::AddItem(const ImmutablezkEVMAPI::APILi if (ScrollBoxSlot) { - auto Decimals = Listing.PriceDetails.Token.Decimals; - - if (Decimals.IsSet()) + if (const ImmutablezkEVMAPI::APIMarketPriceERC20Token* APIMarketPriceERC20Token = Listing.PriceDetails.Token.OneOf.TryGet()) { - FString Price = FMathUtility::ConvertWeiStringToFloatValueString(Decimals.GetValue(), Listing.PriceDetails.Amount); - FString FeeProtocol, FeeRoyalty; + const TOptional& Decimals = APIMarketPriceERC20Token->Decimals; - for (const auto& Fee : Listing.PriceDetails.Fees) + if (Decimals.IsSet()) { - switch(static_cast(Fee.Type)) + FString Price = FMathUtility::ConvertWeiStringToFloatValueString(Decimals.GetValue(), Listing.PriceDetails.Amount); + FString FeeProtocol, FeeRoyalty; + + for (const auto& Fee : Listing.PriceDetails.Fees) { - case ImmutablezkEVMAPI::APIFee::TypeEnum::Protocol: - FeeProtocol = FMathUtility::ConvertWeiStringToFloatValueString(Decimals.GetValue(), Fee.Amount); - break; - case ImmutablezkEVMAPI::APIFee::TypeEnum::Royalty: - FeeRoyalty = FMathUtility::ConvertWeiStringToFloatValueString(Decimals.GetValue(), Fee.Amount); - break; - default:; + switch (static_cast(Fee.Type)) + { + case ImmutablezkEVMAPI::APIFee::TypeEnum::Protocol: + FeeProtocol = FMathUtility::ConvertWeiStringToFloatValueString(Decimals.GetValue(), Fee.Amount); + break; + case ImmutablezkEVMAPI::APIFee::TypeEnum::Royalty: + FeeRoyalty = FMathUtility::ConvertWeiStringToFloatValueString(Decimals.GetValue(), Fee.Amount); + break; + default: ; + } } - } - ListingsItemWidget->RegisterOnSelectionChange(InOnSelectionChangeDelegate); - ListingsItemWidget->SetIsOwned(Listing.Creator.Equals(GetOwningCustomLocalPLayer()->GetPassportWalletAddress())); - ListingsItemWidget->SetListingId(Listing.ListingId); - ListingsItemWidget->SetData(Listing.TokenId, - Listing.Amount, - FeeProtocol, - FeeRoyalty, - Price, - Listing.PriceDetails.Token.Symbol.GetValue(), - IsIdEven); - ListingsItemWidget->Show(); + ListingsItemWidget->RegisterOnSelectionChange(InOnSelectionChangeDelegate); + ListingsItemWidget->SetIsOwned(Listing.Creator.Equals(GetOwningCustomLocalPLayer()->GetPassportWalletAddress())); + ListingsItemWidget->SetListingId(Listing.ListingId); + + const TOptional& Symbol = APIMarketPriceERC20Token->Symbol; + if (Symbol.IsSet()) + { + ListingsItemWidget->SetData(Listing.TokenId, Listing.Amount, FeeProtocol, FeeRoyalty, Price, Symbol.GetValue(), IsIdEven); + } + + ListingsItemWidget->Show(); + } } } } From 7ba93de7b2b9f61210f1723c97efbf9c33a7f9f7 Mon Sep 17 00:00:00 2001 From: Yermek Garifullanov Date: Thu, 9 Jan 2025 10:28:49 +1300 Subject: [PATCH 4/4] fix: removed incorrect filter --- .../SampleGame426/Private/UI/Marketplace/SearchStacksWidget.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksWidget.cpp b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksWidget.cpp index 80638bb..151d96d 100644 --- a/Source/SampleGame426/Private/UI/Marketplace/SearchStacksWidget.cpp +++ b/Source/SampleGame426/Private/UI/Marketplace/SearchStacksWidget.cpp @@ -53,7 +53,6 @@ void USearchStacksWidget::RefreshItemList(TOptional PageCursor) * * @param SearchStacksRequest The request object to be passed to SearchStacks method of the Immutable zkEVM API. * Must-be parameters: - * - AccountAddress: The wallet address of the owning custom local player. * - ContractAddress: The contract address of NFT we are searching for, retrieved from the policy. * - ChainName: The name of the blockchain chain . * Optional parameters: @@ -70,7 +69,6 @@ void USearchStacksWidget::RefreshItemList(TOptional PageCursor) SearchStacksRequest.PageSize = ListPanel->GetNumberOfColumns() * ListPanel->GetNumberOfRows(); SearchStacksRequest.PageCursor = PageCursor; - SearchStacksRequest.AccountAddress = GetOwningCustomLocalPLayer()->GetPassportWalletAddress(); SearchStacksRequest.ContractAddress = Policy->GetContracts(); SearchStacksRequest.ChainName = Policy->GetChainName(); SearchStacksRequest.OnlyIfHasActiveListings = true;