From 54b3097e649ba510e066a6945bac26117e6dcd03 Mon Sep 17 00:00:00 2001 From: Jan Dohring Date: Tue, 3 Dec 2024 13:28:44 -0500 Subject: [PATCH 1/4] Structure start --- .../Private/Marketplace/Marketplace.cpp | 10 +- .../Public/Marketplace/Marketplace.h | 92 +++++++++++++++++++ .../Public/Marketplace/Structs/SeqCurrency.h | 21 +++++ ...lectibleListingsWithLowestPriceFirstArgs.h | 10 ++ ...istingsWithLowestPriceListingsFirstArgs.h} | 4 +- ...gsReturn.h => SeqListCollectiblesReturn.h} | 4 +- .../Structs/SeqListCurrenciesResponse.h | 16 ++++ .../Public/Marketplace/Structs/Struct_Data.h | 4 +- 8 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Marketplace.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCurrency.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListAllCollectibleListingsWithLowestPriceFirstArgs.h rename Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/{SeqGetCollectiblesWithLowestListingsArgs.h => SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h} (89%) rename Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/{SeqGetCollectiblesWithLowestListingsReturn.h => SeqListCollectiblesReturn.h} (94%) create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesResponse.h diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp index 364ecc6ee..9a01c5501 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp @@ -90,13 +90,19 @@ void UMarketplace::GetCollectiblesWithLowestListings(const int64 ChainID, const { const FString Endpoint = "ListCollectiblesWithLowestListing"; - HTTPPost(ChainID, Endpoint, BuildArgs(Args), [this, OnSuccess](const FString& Content) + HTTPPost(ChainID, Endpoint, BuildArgs(Args), [this, OnSuccess](const FString& Content) { - const FSeqGetCollectiblesWithLowestListingsReturn Response = this->BuildResponse(Content); + const FSeqListCollectiblesReturn Response = this->BuildResponse(Content); OnSuccess(Response); }, OnFailure); } +void UMarketplace::ListCurrencies(const int64 ChainID, TSuccessCallback OnSuccess, + const FFailureCallback& OnFailure) +{ + +} + template < typename T> FString UMarketplace::BuildArgs(T StructIn) { FString Result = "[FAILED TO PARSE]"; diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Marketplace.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Marketplace.h new file mode 100644 index 000000000..10ba2f5fb --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Marketplace.h @@ -0,0 +1,92 @@ +// Copyright 2024 Horizon Blockchain Games Inc. All rights reserved. + +#pragma once + +#include "CoreMinimal.h" +#include "Util/Async.h" +#include "Marketplace/Structs/Struct_Data.h" +#include "Structs/SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h" +#include "Structs/SeqListCurrenciesResponse.h" +#include "Marketplace.generated.h" + +UCLASS() +class SEQUENCEPLUGIN_API UMarketplace : public UObject +{ + GENERATED_BODY() + +private: + + const FString PATH = "/rpc/Marketplace/"; + + //private functions + + /* + Creates the URL from a given chainID and endpoint + */ + FString Url(const int64& ChainID, const FString& EndPoint) const; + + /* + Returns the host name + */ + static FString HostName(int64 ChainID); + +public: + /* + Used to send an HTTPPost req to a the sequence app + @return the content of the post response + */ + void HTTPPost(const int64& ChainID, const FString& Endpoint, const FString& Args, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure) const; + + + //public functions + + /* + Here we take in text and convert it to a Struct of type T if possible + @return a Struct of type T + + NOTE: Because unreal doesn't support nested TArrays and TMaps I had to use special implementations + for some data structures inorder for them to parse properly + */ + template < typename T > T BuildResponse(FString Text); + + /* + Here we take in a struct and convert it straight into a json object String + @Param (T) Struct_in the struct we are converting to a json object string + @Return the JSON Object String + */ + template < typename T> FString BuildArgs(T StructIn); + + UMarketplace(); + + // Nothing + void ListCurrencies(const int64 ChainID, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); + // Takes address, filter, page + void ListCollectibleListingsWithLowestPriceListingsFirst(const int64 ChainID, const FSeqListCollectiblesArgs& Args, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); + // Takes address, filter + void ListAllCollectibleListingsWithLowestPriceListingsFirst(const int64 ChainID, FString ContractAddress, FSeqCollectiblesFilter Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure); + // Takes address, filter, page + void ListCollectibleOffersWithHighestPricedOfferFirst(const int64 ChainID, const FSeqListCollectiblesArgs& Args, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); + // Takes address, filter + void ListAllCollectibleOffersWithHighestPricedOfferFirst(const int64 ChainID, FString ContractAddress, FSeqCollectiblesFilter Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure); + // Takes address, tokenId, filter + void GetLowestPriceOfferForCollectible(const int64 ChainID); + // Takes endpoint, address, tokenid + void GetCollectibleOrder(const int64 ChainID); + // Takes address, tokenId, filter + void GetHighestPriceOfferForCollectible(const int64 ChainID); + // Takes address, tokenId, filter + void GetLowestPriceListingForCollectible(const int64 ChainID); + // Takes address, tokenId, filter + void GetHighestPriceListingForCollectible(const int64 ChainID); + // Takes address, tokenId, filter, page + void ListListingsForCollectible(const int64 ChainID); + // Takes address, tokenId, filter + void ListAllListingsForCollectible(const int64 ChainID); + // Takes address, tokenId, filter, page + void ListOffersForCollectible(const int64 ChainID); + // Takes address, tokenId, filter + void ListAllOffersForCollectible(const int64 ChainID); + // takes address, filter + void GetFloorOrder(const int64 ChainID); +}; + diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCurrency.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCurrency.h new file mode 100644 index 000000000..07c24031f --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCurrency.h @@ -0,0 +1,21 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCurrency.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqCurrency +{ + GENERATED_USTRUCT_BODY() + +public: + // Properties + UPROPERTY(EditAnywhere, BlueprintReadWrite) + int ID; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + int ChainID; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + FString ContractAddress; +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListAllCollectibleListingsWithLowestPriceFirstArgs.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListAllCollectibleListingsWithLowestPriceFirstArgs.h new file mode 100644 index 000000000..a311185b7 --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListAllCollectibleListingsWithLowestPriceFirstArgs.h @@ -0,0 +1,10 @@ +#pragma once + +USTRUCT(BlueprintType) +class SEQUENCEPLUGIN_API FSeqListAllCollectibleListingsWithLowestPriceFirstArgs +{ + GENERATED_USTRUCT_BODY() + +public: + +}; diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectiblesWithLowestListingsArgs.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h similarity index 89% rename from Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectiblesWithLowestListingsArgs.h rename to Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h index de4c11894..dde292748 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectiblesWithLowestListingsArgs.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h @@ -3,10 +3,10 @@ #include "CoreMinimal.h" #include "SeqCollectiblesFilter.h" #include "SeqMarketplacePage.h" -#include "SeqGetCollectiblesWithLowestListingsArgs.generated.h" +#include "SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.generated.h" USTRUCT(BlueprintType) -struct SEQUENCEPLUGIN_API FSeqGetCollectiblesWithLowestListingsArgs +struct SEQUENCEPLUGIN_API FSeqListCollectiblesArgs { GENERATED_USTRUCT_BODY() diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectiblesWithLowestListingsReturn.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectiblesReturn.h similarity index 94% rename from Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectiblesWithLowestListingsReturn.h rename to Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectiblesReturn.h index 19863ef3c..f00c01457 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectiblesWithLowestListingsReturn.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectiblesReturn.h @@ -3,10 +3,10 @@ #include "CoreMinimal.h" #include "SeqCollectibleOrder.h" #include "SeqMarketplacePage.h" -#include "SeqGetCollectiblesWithLowestListingsReturn.generated.h" +#include "SeqListCollectiblesReturn.generated.h" USTRUCT(BlueprintType) -struct SEQUENCEPLUGIN_API FSeqGetCollectiblesWithLowestListingsReturn +struct SEQUENCEPLUGIN_API FSeqListCollectiblesReturn { GENERATED_USTRUCT_BODY() diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesResponse.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesResponse.h new file mode 100644 index 000000000..0b8b157d5 --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesResponse.h @@ -0,0 +1,16 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCurrency.h" +#include "SeqListCurrenciesResponse.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqListCurrenciesResponse +{ + GENERATED_USTRUCT_BODY() + +public: + // Properties + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Page") + TArray Currencies; +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/Struct_Data.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/Struct_Data.h index e3dab820b..fd98e19c7 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/Struct_Data.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/Struct_Data.h @@ -1,8 +1,8 @@ #pragma once #include "Marketplace/Marketplace_Enums.h" -#include "SeqGetCollectiblesWithLowestListingsArgs.h" -#include "SeqGetCollectiblesWithLowestListingsReturn.h" +#include "SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h" +#include "SeqListCollectiblesReturn.h" #include "SeqCollectiblesFilter.h" #include "SeqPropertyFilter.h" #include "SeqMarketplaceSortBy.h" From d3ca54a599fb1aa69d1bfd6ef103b46b9e500c17 Mon Sep 17 00:00:00 2001 From: Jan Dohring Date: Tue, 10 Dec 2024 17:16:13 -0500 Subject: [PATCH 2/4] api implemented --- .../Core/Testing/BP_GeneralTesting.uasset | 4 +- .../SequencePlugin/Private/GeneralTesting.cpp | 45 +++ .../SequencePlugin/Private/GeneralTesting.h | 9 + .../Integrators/SequenceMarketplaceBP.cpp | 10 +- .../Private/Marketplace/Marketplace.cpp | 322 +++++++++++++++++- .../Private/Marketplace/Marketplace.h | 64 ---- .../Private/Tests/TestSequenceAPI.cpp | 65 ++++ .../Private/Tests/TestSequenceAPI.h | 5 + .../Private/Util/JsonBuilder.cpp | 1 - .../Public/Indexer/Structs/SeqTokenMetaData.h | 5 + .../Integrators/SequenceMarketplaceBP.h | 7 +- .../Public/Marketplace/Marketplace.h | 45 ++- .../Marketplace/Structs/SeqCollectibleOrder.h | 5 +- .../Structs/SeqCollectiblesFilter.h | 5 + .../Structs/SeqGetCollectibleOrderArgs.h | 39 +++ .../Structs/SeqGetCollectibleOrderReturn.h | 21 ++ .../Structs/SeqGetFloorOrderArgs.h | 46 +++ .../Marketplace/Structs/SeqGetOrderReturn.h | 21 ++ ...lectibleListingsWithLowestPriceFirstArgs.h | 10 - .../Structs/SeqListCollectibleListingsArgs.h | 50 +++ .../SeqListCollectibleListingsReturn.h | 74 ++++ .../Structs/SeqListCollectibleOffersReturn.h | 74 ++++ ...sFirstArgs.h => SeqListCollectiblesArgs.h} | 21 +- .../Structs/SeqListCurrenciesResponse.h | 16 - .../Structs/SeqListCurrenciesReturn.h | 20 ++ .../Marketplace/Structs/SeqMarketplacePage.h | 5 + .../Public/Marketplace/Structs/SeqOrder.h | 8 +- .../Public/Marketplace/Structs/Struct_Data.h | 2 +- 28 files changed, 847 insertions(+), 152 deletions(-) delete mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectibleOrderArgs.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectibleOrderReturn.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetFloorOrderArgs.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetOrderReturn.h delete mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListAllCollectibleListingsWithLowestPriceFirstArgs.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsArgs.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsReturn.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleOffersReturn.h rename Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/{SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h => SeqListCollectiblesArgs.h} (63%) delete mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesResponse.h create mode 100644 Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesReturn.h diff --git a/Plugins/SequencePlugin/Content/Core/Testing/BP_GeneralTesting.uasset b/Plugins/SequencePlugin/Content/Core/Testing/BP_GeneralTesting.uasset index bafd3d6d4..89164e7be 100644 --- a/Plugins/SequencePlugin/Content/Core/Testing/BP_GeneralTesting.uasset +++ b/Plugins/SequencePlugin/Content/Core/Testing/BP_GeneralTesting.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3183b6879d17efddc01e76bcdea24fffaa9c6468f54851ac4a3b47b3f1b6c87d -size 251442 +oid sha256:e23b117e8a88476e640a69d95a2efe9dec578b4dedcf78915eec504762386258 +size 259135 diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.cpp index 8a96bbbdf..705657be9 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.cpp @@ -220,6 +220,51 @@ void AGeneralTesting::TestGuestLogin() Auth->GuestLogin(false); } +void AGeneralTesting::TestListCurrencies() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::ListCurrencies(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestListCollectibleListingsWithLowestPriceListingsFirst() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::ListCollectibleListingsWithLowestPricedListingsFirst(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestListAllCollectibleListingsWithLowestPriceListingsFirst() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::ListAllCollectibleListingsWithLowestPriceListingsFirst(OnSuccess, OnFailure); +} + void AGeneralTesting::TestIndexer() { TFunction OnSuccess = [this](FString State) diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.h b/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.h index 48e5a977f..9fcba171a 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.h @@ -77,6 +77,15 @@ class SEQUENCEPLUGIN_API AGeneralTesting : public AActor UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") void TestGuestLogin(); + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestListCurrencies() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestListCollectibleListingsWithLowestPriceListingsFirst() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestListAllCollectibleListingsWithLowestPriceListingsFirst() const; /* * Called by frontend to test the indexer diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Integrators/SequenceMarketplaceBP.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Integrators/SequenceMarketplaceBP.cpp index b46302f41..e8d80ebe1 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Integrators/SequenceMarketplaceBP.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Integrators/SequenceMarketplaceBP.cpp @@ -9,9 +9,9 @@ USequenceMarketplaceBP::USequenceMarketplaceBP() } -void USequenceMarketplaceBP::GetGetCollectiblesWithLowestListingsAsync(const int64 ChainId, const FSeqGetCollectiblesWithLowestListingsArgs& Args) +void USequenceMarketplaceBP::GetGetCollectiblesWithLowestListingsAsync(const int64 ChainId, const FSeqListCollectiblesArgs& Args) { - const TSuccessCallback OnSuccess = [this, ChainId, Args](const FSeqGetCollectiblesWithLowestListingsReturn& CollectiblesWithLowestListings) + const TSuccessCallback OnSuccess = [this, ChainId, Args](const FSeqListCollectiblesReturn& CollectiblesWithLowestListings) { this->CallCollectiblesWithLowestListingsReceived(true, ChainId, CollectiblesWithLowestListings); }; @@ -19,15 +19,15 @@ void USequenceMarketplaceBP::GetGetCollectiblesWithLowestListingsAsync(const int const FFailureCallback OnFailure = [this, ChainId, Args](const FSequenceError& Error) { SEQ_LOG(Error, TEXT("Error getting Collectibles with Lowest Listings: %s"), *Error.Message); - FSeqGetCollectiblesWithLowestListingsReturn CollectiblesWithLowestListings; + FSeqListCollectiblesReturn CollectiblesWithLowestListings; this->CallCollectiblesWithLowestListingsReceived(false, ChainId, CollectiblesWithLowestListings); }; - this->Marketplace->GetCollectiblesWithLowestListings(ChainId, Args, OnSuccess, OnFailure); + this->Marketplace->ListCollectibleListingsWithLowestPriceListingsFirst(ChainId, Args.ContractAddress, Args.Filter, Args.Page, OnSuccess, OnFailure); } -void USequenceMarketplaceBP::CallCollectiblesWithLowestListingsReceived(const bool Status, const int64 ChainId, const FSeqGetCollectiblesWithLowestListingsReturn& Response) +void USequenceMarketplaceBP::CallCollectiblesWithLowestListingsReceived(const bool Status, const int64 ChainId, const FSeqListCollectiblesReturn& Response) { if (this->CollectiblesWithLowestListingsResponse.IsBound()) this->CollectiblesWithLowestListingsResponse.Broadcast(Status, ChainId, Response); diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp index 9a01c5501..65af27cec 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp @@ -7,6 +7,13 @@ #include "Util/SequenceSupport.h" #include "ConfigFetcher.h" #include "HttpManager.h" +#include "Marketplace/Structs/SeqGetCollectibleOrderArgs.h" +#include "Marketplace/Structs/SeqGetCollectibleOrderReturn.h" +#include "Marketplace/Structs/SeqGetFloorOrderArgs.h" +#include "Marketplace/Structs/SeqGetOrderReturn.h" +#include "Marketplace/Structs/SeqListCollectibleListingsArgs.h" +#include "Marketplace/Structs/SeqListCollectibleOffersReturn.h" +#include "Marketplace/Structs/SeqListCurrenciesReturn.h" UMarketplace::UMarketplace(){} @@ -31,6 +38,8 @@ FString UMarketplace::HostName(const int64 ChainID) return Hostname; } + + void UMarketplace::HTTPPost(const int64& ChainID, const FString& Endpoint, const FString& Args, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure) const { const FString RequestURL = this->Url(ChainID, Endpoint); @@ -86,23 +95,6 @@ void UMarketplace::HTTPPost(const int64& ChainID, const FString& Endpoint, const HTTP_Post_Req->ProcessRequest(); } -void UMarketplace::GetCollectiblesWithLowestListings(const int64 ChainID, const FSeqGetCollectiblesWithLowestListingsArgs& Args, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure) -{ - const FString Endpoint = "ListCollectiblesWithLowestListing"; - - HTTPPost(ChainID, Endpoint, BuildArgs(Args), [this, OnSuccess](const FString& Content) - { - const FSeqListCollectiblesReturn Response = this->BuildResponse(Content); - OnSuccess(Response); - }, OnFailure); -} - -void UMarketplace::ListCurrencies(const int64 ChainID, TSuccessCallback OnSuccess, - const FFailureCallback& OnFailure) -{ - -} - template < typename T> FString UMarketplace::BuildArgs(T StructIn) { FString Result = "[FAILED TO PARSE]"; @@ -148,4 +140,298 @@ template T UMarketplace::BuildResponse(const FString Text) } Ret_Struct.Setup(*JSON_Step.Get());//now for the edge cases we will manually inject the data where it needs to be! return Ret_Struct; -} \ No newline at end of file +} + +void UMarketplace::ListCurrencies(const int64 ChainID, TSuccessCallback OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Endpoint = "ListCurrencies"; + const FString Args = ""; + HTTPPost(ChainID, Endpoint, Args, [this, OnSuccess](const FString& Content) + { + const FSeqListCurrenciesReturn Response = this->BuildResponse(Content); + OnSuccess(Response); + }, OnFailure); +} + +void UMarketplace::ListCollectibleListingsWithLowestPriceListingsFirst(const int64 ChainID, const FString& ContractAddress, + const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TSuccessCallback OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Endpoint = "ListCollectiblesWithLowestListing"; + const FString Args = BuildArgs(FSeqListCollectiblesArgs{LISTING, ContractAddress, Filter, Page}); + HTTPPost(ChainID, Endpoint, Args, [this, OnSuccess](const FString& Content) + { + const FSeqListCollectiblesReturn Response = this->BuildResponse(Content); + OnSuccess(Response); + }, OnFailure); +} + +void UMarketplace::ListAllCollectibleListingsWithLowestPriceListingsFirst(const int64 ChainID, + const FString& ContractAddress, const FSeqCollectiblesFilter& Filter, + TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure) +{ + const FString Args = BuildArgs(FSeqListCollectiblesArgs{LISTING, ContractAddress, Filter, FSeqMarketplacePage::Empty()}); + OrderArray.Empty(); + + return ListAllCollectibleListingsWithLowestPriceListingsFirstHelper(ChainID, ContractAddress, Filter, FSeqMarketplacePage::Empty(), [this, OnSuccess](const TArray& Orders, const bool IsDone) + { + OrderArray.Append(Orders); + + if(IsDone) + { + OnSuccess(OrderArray); + } + }, OnFailure); +} + +void UMarketplace::ListCollectibleOffersWithHighestPricedOfferFirst( + const int64 ChainID, + const FString& ContractAddress, + const FSeqCollectiblesFilter& Filter, + const FSeqMarketplacePage& Page, + TSuccessCallback OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Endpoint = "ListCollectibleOffersWithHighestPricedOfferFirst"; + const FString Args = BuildArgs(FSeqListCollectiblesArgs{OFFER, ContractAddress, Filter, Page}); + HTTPPost(ChainID, Endpoint, Args, [this, OnSuccess](const FString& Content) + { + const FSeqListCollectiblesReturn Response = this->BuildResponse(Content); + OnSuccess(Response); + }, OnFailure); +} + +void UMarketplace::ListAllCollectibleOffersWithHighestPricedOfferFirst( + const int64 ChainID, + const FString& ContractAddress, + const FSeqCollectiblesFilter& Filter, + TSuccessCallback> OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Args = BuildArgs(FSeqListCollectiblesArgs{LISTING, ContractAddress, Filter, FSeqMarketplacePage::Empty()}); + OrderArray.Empty(); + + return ListAllCollectibleListingsWithLowestPriceListingsFirstHelper(ChainID, ContractAddress, Filter, FSeqMarketplacePage::Empty(), [this, OnSuccess](const TArray& Orders, const bool IsDone) + { + OrderArray.Append(Orders); + + if(IsDone) + { + OnSuccess(OrderArray); + } + }, OnFailure); +} + +void UMarketplace::GetLowestPriceOfferForCollectible( + const int64 ChainID, + const FString& ContractAddress, + const FString& TokenID, + const FSeqCollectiblesFilter& Filter, + const TSuccessCallback& OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Endpoint = "GetLowestPriceOfferForCollectible"; + const FSeqGetCollectibleOrderArgs Args = FSeqGetCollectibleOrderArgs{ ContractAddress, TokenID, Filter}; + GetCollectibleOrder(ChainID, Endpoint, Args, OnSuccess, OnFailure); +} + +void UMarketplace::GetHighestPriceOfferForCollectible(const int64 ChainID, const FString& ContractAddress, + const FString& TokenID, const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Endpoint = "GetHighestPriceOfferForCollectible"; + const FSeqGetCollectibleOrderArgs Args = FSeqGetCollectibleOrderArgs{ContractAddress, TokenID, Filter}; + GetCollectibleOrder(ChainID, Endpoint, Args, OnSuccess, OnFailure); +} + +void UMarketplace::GetLowestPriceListingForCollectible(const int64 ChainID, const FString& ContractAddress, + const FString& TokenID, const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Endpoint = "GetLowestPriceListingForCollectible"; + const FSeqGetCollectibleOrderArgs Args = FSeqGetCollectibleOrderArgs{ContractAddress, TokenID, Filter}; + GetCollectibleOrder(ChainID, Endpoint, Args, OnSuccess, OnFailure); +} + +void UMarketplace::GetHighestPriceListingForCollectible(const int64 ChainID, const FString& ContractAddress, + const FString& TokenID, const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Endpoint = "GetHighestPriceListingForCollectible"; + const FSeqGetCollectibleOrderArgs Args = FSeqGetCollectibleOrderArgs{ContractAddress, TokenID, Filter}; + GetCollectibleOrder(ChainID, Endpoint, Args, OnSuccess, OnFailure); +} + +void UMarketplace::ListListingsForCollectible(const int64 ChainID, const FString& ContractAddress, + const FString& TokenID, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, + TSuccessCallback OnSuccess, const FFailureCallback& OnFailure) +{ + const FString Endpoint = "ListListingsForCollectible"; + const FSeqListCollectibleListingsArgs Args = FSeqListCollectibleListingsArgs{ContractAddress, TokenID, Filter, Page}; + HTTPPost(ChainID, Endpoint, BuildArgs(Args), [this, OnSuccess](const FString& Content) + { + const FSeqListCollectibleListingsReturn Response = this->BuildResponse(Content); + OnSuccess(Response); + }, OnFailure); +} + +void UMarketplace::ListAllListingsForCollectible(const int64 ChainID, + const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, + TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure) +{ + const FString Args = BuildArgs(FSeqListCollectibleListingsArgs{ ContractAddress, TokenID, Filter, FSeqMarketplacePage::Empty()}); + OrderArray.Empty(); + + return ListAllCollectibleListingsWithLowestPriceListingsFirstHelper(ChainID, ContractAddress, Filter, FSeqMarketplacePage::Empty(), [this, OnSuccess](const TArray& Orders, const bool IsDone) + { + OrderArray.Append(Orders); + + if(IsDone) + { + OnSuccess(OrderArray); + } + }, OnFailure); +} + +void UMarketplace::ListOffersForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, + const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, + TSuccessCallback OnSuccess, const FFailureCallback& OnFailure) +{ + const FString Endpoint = "ListOffersForCollectible"; + const FSeqListCollectibleListingsArgs Args = FSeqListCollectibleListingsArgs{ContractAddress, TokenID, Filter, Page}; + HTTPPost(ChainID, Endpoint, BuildArgs(Args), [this, OnSuccess](const FString& Content) + { + const FSeqListCollectibleOffersReturn Response = this->BuildResponse(Content); + OnSuccess(Response); + }, OnFailure); +} + +void UMarketplace::ListAllOffersForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure) +{ + const FString Args = BuildArgs(FSeqListCollectibleListingsArgs{ ContractAddress, TokenID, Filter, FSeqMarketplacePage::Empty()}); + OrderArray.Empty(); + + return ListAllOffersForCollectibleHelper(ChainID, ContractAddress, TokenID, Filter, FSeqMarketplacePage::Empty(), [this, OnSuccess](const TArray& Orders, bool IsDone) + { + OrderArray.Append(Orders); + + if(IsDone) + { + OnSuccess(OrderArray); + } + }, OnFailure); +} + +void UMarketplace::GetFloorOrder(const int64 ChainID, const FString& ContractAddress, + const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, + const FFailureCallback& OnFailure) +{ + const FString Endpoint = "GetFloorOrder"; + const FSeqGetFloorOrderArgs Args = FSeqGetFloorOrderArgs{ContractAddress, Filter, FSeqMarketplacePage::Empty()}; + HTTPPost(ChainID, Endpoint, BuildArgs(Args), [this, OnSuccess](const FString& Content) + { + const FSeqGetOrderReturn Response = this->BuildResponse(Content); + OnSuccess(Response.Collectible); + }, OnFailure); + +} + + +// HELPER FUNCTIONS +void UMarketplace::ListAllCollectibleListingsWithLowestPriceListingsFirstHelper( + const int64 ChainID, + const FString& ContractAddress, + const FSeqCollectiblesFilter& Filter, + const FSeqMarketplacePage& Page, + TFunction, bool)> OnSuccess, + const FFailureCallback& OnFailure) +{ + ListCollectibleListingsWithLowestPriceListingsFirst(ChainID, ContractAddress, Filter, Page, [ChainID, ContractAddress, Filter, this, OnSuccess, OnFailure](const FSeqListCollectiblesReturn& CollectiblesReturn) + { + if (CollectiblesReturn.Page.More) + { + // Call the next page + ListAllCollectibleListingsWithLowestPriceListingsFirstHelper(ChainID, ContractAddress, Filter, CollectiblesReturn.Page, OnSuccess, OnFailure); + OnSuccess(CollectiblesReturn.CollectibleOrders, false); + } + else + { + OnSuccess(CollectiblesReturn.CollectibleOrders, true); + } + }, OnFailure); +} + +void UMarketplace::ListAllCollectibleOffersWithHighestPricedOfferFirstHelper( + const int64 ChainID, + const FString& ContractAddress, + const FSeqCollectiblesFilter& Filter, + const FSeqMarketplacePage& Page, + TFunction, bool)> OnSuccess, + const FFailureCallback& OnFailure) +{ + ListCollectibleOffersWithHighestPricedOfferFirst(ChainID, ContractAddress, Filter, Page, [ChainID, ContractAddress, Filter, this, OnSuccess, OnFailure](const FSeqListCollectiblesReturn& CollectiblesReturn) + { + + if (CollectiblesReturn.Page.More) + { + // Call the next page + ListAllCollectibleOffersWithHighestPricedOfferFirstHelper(ChainID, ContractAddress, Filter, CollectiblesReturn.Page, OnSuccess, OnFailure); + OnSuccess(CollectiblesReturn.CollectibleOrders, false); + } + else + { + OnSuccess(CollectiblesReturn.CollectibleOrders, true); + } + }, OnFailure); +} + +void UMarketplace::GetCollectibleOrder(const int64 ChainID, const FString& Endpoint, const FSeqGetCollectibleOrderArgs& Args, TSuccessCallback OnSuccess, + const FFailureCallback& OnFailure) +{ + HTTPPost(ChainID, Endpoint, BuildArgs(Args), [this, OnSuccess](const FString& Content) + { + const FSeqGetCollectibleOrderReturn Response = this->BuildResponse(Content); + OnSuccess(Response.Order); + }, OnFailure); +} + +void UMarketplace::ListAllListingsForCollectibleHelper(const int64 ChainID, const FString& ContractAddress, + const FString& TokenID, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, + TFunction, bool)> OnSuccess, const FFailureCallback& OnFailure) +{ + ListListingsForCollectible(ChainID, ContractAddress, TokenID, Filter, Page, [ChainID, ContractAddress, Filter, TokenID, this, OnSuccess, OnFailure](const FSeqListCollectibleListingsReturn& CollectiblesReturn) + { + + if (CollectiblesReturn.Page.More) + { + // Call the next page + ListAllListingsForCollectibleHelper(ChainID, ContractAddress, TokenID, Filter, CollectiblesReturn.Page, OnSuccess, OnFailure); + OnSuccess(CollectiblesReturn.Listings, false); + } + else + { + OnSuccess(CollectiblesReturn.Listings, true); + } + }, OnFailure); +} + +void UMarketplace::ListAllOffersForCollectibleHelper(const int64 ChainID, const FString& ContractAddress, + const FString& TokenID, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, + TFunction, bool)> OnSuccess, const FFailureCallback& OnFailure) +{ + ListOffersForCollectible(ChainID, ContractAddress, TokenID, Filter, Page, [ChainID, ContractAddress, Filter, TokenID, this, OnSuccess, OnFailure](const FSeqListCollectibleOffersReturn& CollectiblesReturn) + { + + if (CollectiblesReturn.Page.More) + { + // Call the next page + ListAllOffersForCollectibleHelper(ChainID, ContractAddress, TokenID, Filter, CollectiblesReturn.Page, OnSuccess, OnFailure); + OnSuccess(CollectiblesReturn.Offers, false); + } + else + { + OnSuccess(CollectiblesReturn.Offers, true); + } + }, OnFailure); +} diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.h b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.h deleted file mode 100644 index 9db028253..000000000 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2024 Horizon Blockchain Games Inc. All rights reserved. - -#pragma once - -#include "CoreMinimal.h" -#include "Util/Async.h" -#include "Marketplace/Structs/Struct_Data.h" -#include "Marketplace.generated.h" - -UCLASS() -class SEQUENCEPLUGIN_API UMarketplace : public UObject -{ - GENERATED_BODY() - -private: - - const FString PATH = "/rpc/Marketplace/"; - - //private functions - - /* - Creates the URL from a given chainID and endpoint - */ - FString Url(const int64& ChainID, const FString& EndPoint) const; - - /* - Returns the host name - */ - static FString HostName(int64 ChainID); - -public: - /* - Used to send an HTTPPost req to a the sequence app - @return the content of the post response - */ - void HTTPPost(const int64& ChainID, const FString& Endpoint, const FString& Args, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure) const; - - - //public functions - - /* - Here we take in text and convert it to a Struct of type T if possible - @return a Struct of type T - - NOTE: Because unreal doesn't support nested TArrays and TMaps I had to use special implementations - for some data structures inorder for them to parse properly - */ - template < typename T > T BuildResponse(FString Text); - - /* - Here we take in a struct and convert it straight into a json object String - @Param (T) Struct_in the struct we are converting to a json object string - @Return the JSON Object String - */ - template < typename T> FString BuildArgs(T StructIn); - - UMarketplace(); - - void GetCollectiblesWithLowestListings(const int64 ChainID, const FSeqGetCollectiblesWithLowestListingsArgs& Args, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); - - - -}; - diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp index d410a5371..e1be92485 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp @@ -4,8 +4,12 @@ #include "Sequence/SequenceAPI.h" #include "SequenceAuthenticator.h" #include "ABI/ABI.h" +#include "Marketplace/Marketplace.h" +#include "Marketplace/Structs/SeqCollectibleOrder.h" +#include "Marketplace/Structs/SeqCollectiblesFilter.h" #include "Native/NativeOAuth.h" + /* * testing stack based implementation for memory faults */ @@ -462,3 +466,64 @@ void SequenceAPITest::TestLoadTransakUrl() Api->OpenTransakLink(); } } + +void SequenceAPITest::ListCurrencies(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->ListCurrencies(Support->GetNetworkId(PolygonChain), [OnSuccess](FSeqListCurrenciesReturn Response) + { + FString Currencies = "Currencies: \n"; + + for(FSeqCurrency Currency : Response.Currencies) + { + Currencies += USequenceSupport::StructToString(Currency) + "\n"; + } + + OnSuccess(Currencies); + }, [OnFailure](FSequenceError Error) + { + OnFailure("Error: " + Error.Message, Error); + }); +} + +void SequenceAPITest::ListCollectibleListingsWithLowestPricedListingsFirst(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->ListCollectibleListingsWithLowestPriceListingsFirst( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", + FSeqCollectiblesFilter::Empty(), + FSeqMarketplacePage::Empty(), + [OnSuccess](FSeqListCollectiblesReturn Orders) { + OnSuccess("Orders: " + FString::FromInt(Orders.CollectibleOrders.Num())); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} + +void SequenceAPITest::ListAllCollectibleListingsWithLowestPriceListingsFirst(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->ListAllCollectibleListingsWithLowestPriceListingsFirst( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", + FSeqCollectiblesFilter::Empty(), + [OnSuccess](TArray Orders) { + OnSuccess("Orders: " + FString::FromInt(Orders.Num())); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.h b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.h index 7c390d63f..ae253c7a5 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.h @@ -21,4 +21,9 @@ class SequenceAPITest static void GetUnfilteredFeeOptions(TFunction OnSuccess, TFunction OnFailure); static void GetSupportedCountries(const TSuccessCallback>& OnSuccess, const FFailureCallback& OnFailure); static void TestLoadTransakUrl(); + + // Market + static void ListCurrencies(TFunction OnSuccess, TFunction OnFailure); + static void ListCollectibleListingsWithLowestPricedListingsFirst(TFunction OnSuccess, TFunction OnFailure); + static void ListAllCollectibleListingsWithLowestPriceListingsFirst(TFunction OnSuccess, TFunction OnFailure); }; diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Util/JsonBuilder.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Util/JsonBuilder.cpp index 8f2892282..e3c0481e4 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Util/JsonBuilder.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Util/JsonBuilder.cpp @@ -52,7 +52,6 @@ FJsonArray FJsonBuilder::AddArray(FString Name) FString FJsonBuilder::ToString() const { - auto x = 3; return FString("{") + StringValue + FString("}"); } diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Indexer/Structs/SeqTokenMetaData.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Indexer/Structs/SeqTokenMetaData.h index 319d8c194..97200b5cd 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Indexer/Structs/SeqTokenMetaData.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Indexer/Structs/SeqTokenMetaData.h @@ -98,6 +98,8 @@ struct SEQUENCEPLUGIN_API FSeqTokenMetaData void Setup(FJsonObject json_in) {//the json object we expect here will be a mirror of what is above EXCEPT we will be snipping out what we need! + UE_LOG(LogTemp, Warning, TEXT("seq token meta data setup start")); + FString tokenIdString; if (json_in.TryGetStringField(TEXT("tokenId"), tokenIdString)) { @@ -144,5 +146,8 @@ struct SEQUENCEPLUGIN_API FSeqTokenMetaData } } } + + + UE_LOG(LogTemp, Warning, TEXT("seq token meta data setup done")); } }; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Integrators/SequenceMarketplaceBP.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Integrators/SequenceMarketplaceBP.h index 494aab26a..9aeee6943 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Integrators/SequenceMarketplaceBP.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Integrators/SequenceMarketplaceBP.h @@ -5,7 +5,7 @@ #include "Subsystems/GameInstanceSubsystem.h" #include "SequenceMarketplaceBP.generated.h" -DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnGetCollectiblesWithLowestListings, bool, Status, const int64, ChainId, FSeqGetCollectiblesWithLowestListingsReturn, Response); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnGetCollectiblesWithLowestListings, bool, Status, const int64, ChainId, FSeqListCollectiblesReturn, Response); UCLASS(Blueprintable) class SEQUENCEPLUGIN_API USequenceMarketplaceBP : public UGameInstanceSubsystem @@ -15,16 +15,17 @@ class SEQUENCEPLUGIN_API USequenceMarketplaceBP : public UGameInstanceSubsystem public: USequenceMarketplaceBP(); + UPROPERTY(BlueprintAssignable, Category = "0xSequence SDK - Events") FOnGetCollectiblesWithLowestListings CollectiblesWithLowestListingsResponse; UFUNCTION(BlueprintCallable, Category = "0xSequence SDK - Functions") - void GetGetCollectiblesWithLowestListingsAsync(const int64 ChainId, const FSeqGetCollectiblesWithLowestListingsArgs& Args); + void GetGetCollectiblesWithLowestListingsAsync(const int64 ChainId, const FSeqListCollectiblesArgs& Args); private: UMarketplace* Marketplace; - void CallCollectiblesWithLowestListingsReceived(const bool Status, const int64 ChainId, const FSeqGetCollectiblesWithLowestListingsReturn& Response); + void CallCollectiblesWithLowestListingsReceived(const bool Status, const int64 ChainId, const FSeqListCollectiblesReturn& Response); }; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Marketplace.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Marketplace.h index 10ba2f5fb..33838fe90 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Marketplace.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Marketplace.h @@ -5,8 +5,10 @@ #include "CoreMinimal.h" #include "Util/Async.h" #include "Marketplace/Structs/Struct_Data.h" -#include "Structs/SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h" -#include "Structs/SeqListCurrenciesResponse.h" +#include "Structs/SeqGetCollectibleOrderArgs.h" +#include "Structs/SeqListCollectibleListingsReturn.h" +#include "Structs/SeqListCollectibleOffersReturn.h" +#include "Structs/SeqListCurrenciesReturn.h" #include "Marketplace.generated.h" UCLASS() @@ -18,6 +20,8 @@ class SEQUENCEPLUGIN_API UMarketplace : public UObject const FString PATH = "/rpc/Marketplace/"; + TArray OrderArray; + //private functions /* @@ -30,6 +34,13 @@ class SEQUENCEPLUGIN_API UMarketplace : public UObject */ static FString HostName(int64 ChainID); + // HELPERS + void ListAllCollectibleListingsWithLowestPriceListingsFirstHelper(const int64 ChainID, const FString& ContractAddress, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TFunction, bool)> OnSuccess, const FFailureCallback& OnFailure); + void ListAllCollectibleOffersWithHighestPricedOfferFirstHelper(const int64 ChainID, const FString& ContractAddress, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TFunction, bool)> OnSuccess, const FFailureCallback& OnFailure); + void GetCollectibleOrder(int64 ChainID, const FString& Endpoint, const FSeqGetCollectibleOrderArgs& Args, + TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); + void ListAllListingsForCollectibleHelper(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TFunction, bool)> OnSuccess, const FFailureCallback& OnFailure); + void ListAllOffersForCollectibleHelper(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TFunction, bool)> OnSuccess, const FFailureCallback& OnFailure); public: /* Used to send an HTTPPost req to a the sequence app @@ -59,34 +70,32 @@ class SEQUENCEPLUGIN_API UMarketplace : public UObject UMarketplace(); // Nothing - void ListCurrencies(const int64 ChainID, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); + void ListCurrencies(const int64 ChainID, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); // Takes address, filter, page - void ListCollectibleListingsWithLowestPriceListingsFirst(const int64 ChainID, const FSeqListCollectiblesArgs& Args, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); + void ListCollectibleListingsWithLowestPriceListingsFirst(const int64 ChainID, const FString& ContractAddress, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); // Takes address, filter - void ListAllCollectibleListingsWithLowestPriceListingsFirst(const int64 ChainID, FString ContractAddress, FSeqCollectiblesFilter Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure); + void ListAllCollectibleListingsWithLowestPriceListingsFirst(const int64 ChainID, const FString& ContractAddress, const FSeqCollectiblesFilter& Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure); // Takes address, filter, page - void ListCollectibleOffersWithHighestPricedOfferFirst(const int64 ChainID, const FSeqListCollectiblesArgs& Args, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); + void ListCollectibleOffersWithHighestPricedOfferFirst(const int64 ChainID, const FString& ContractAddress, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); // Takes address, filter - void ListAllCollectibleOffersWithHighestPricedOfferFirst(const int64 ChainID, FString ContractAddress, FSeqCollectiblesFilter Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure); + void ListAllCollectibleOffersWithHighestPricedOfferFirst(const int64 ChainID, const FString& ContractAddress, const FSeqCollectiblesFilter& Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure); // Takes address, tokenId, filter - void GetLowestPriceOfferForCollectible(const int64 ChainID); - // Takes endpoint, address, tokenid - void GetCollectibleOrder(const int64 ChainID); + void GetLowestPriceOfferForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure); // Takes address, tokenId, filter - void GetHighestPriceOfferForCollectible(const int64 ChainID); + void GetHighestPriceOfferForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure); // Takes address, tokenId, filter - void GetLowestPriceListingForCollectible(const int64 ChainID); + void GetLowestPriceListingForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure); // Takes address, tokenId, filter - void GetHighestPriceListingForCollectible(const int64 ChainID); + void GetHighestPriceListingForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure); // Takes address, tokenId, filter, page - void ListListingsForCollectible(const int64 ChainID); + void ListListingsForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); // Takes address, tokenId, filter - void ListAllListingsForCollectible(const int64 ChainID); + void ListAllListingsForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure); // Takes address, tokenId, filter, page - void ListOffersForCollectible(const int64 ChainID); + void ListOffersForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, const FSeqMarketplacePage& Page, TSuccessCallback OnSuccess, const FFailureCallback& OnFailure); // Takes address, tokenId, filter - void ListAllOffersForCollectible(const int64 ChainID); + void ListAllOffersForCollectible(const int64 ChainID, const FString& ContractAddress, const FString& TokenID, const FSeqCollectiblesFilter& Filter, TSuccessCallback> OnSuccess, const FFailureCallback& OnFailure); // takes address, filter - void GetFloorOrder(const int64 ChainID); + void GetFloorOrder(const int64 ChainID, const FString& ContractAddress, const FSeqCollectiblesFilter& Filter, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure); }; diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCollectibleOrder.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCollectibleOrder.h index e8344bb80..e39a7bdb9 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCollectibleOrder.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCollectibleOrder.h @@ -12,7 +12,6 @@ struct SEQUENCEPLUGIN_API FSeqCollectibleOrder GENERATED_USTRUCT_BODY() public: - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Order") FSeqTokenMetaData TokenMetadata; @@ -32,6 +31,8 @@ struct SEQUENCEPLUGIN_API FSeqCollectibleOrder void Setup(FJsonObject json_in) { + UE_LOG(LogTemp, Warning, TEXT("seq collectible setup start")); + const TSharedPtr* item; if (json_in.TryGetObjectField(TEXT("metadata"), item)) { @@ -43,5 +44,7 @@ struct SEQUENCEPLUGIN_API FSeqCollectibleOrder { Order.Setup(*orderItem->Get()); } + + UE_LOG(LogTemp, Warning, TEXT("seq collectible setup done")); } }; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCollectiblesFilter.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCollectiblesFilter.h index fbef9f125..2f0eb9e8e 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCollectiblesFilter.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqCollectiblesFilter.h @@ -37,6 +37,11 @@ struct SEQUENCEPLUGIN_API FSeqCollectiblesFilter UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") TArray OrdersNotCreatedBy; + static FSeqCollectiblesFilter Empty() + { + return FSeqCollectiblesFilter{}; + } + bool ContainsData() { // Check for valid data in the properties diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectibleOrderArgs.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectibleOrderArgs.h new file mode 100644 index 000000000..8734491d4 --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectibleOrderArgs.h @@ -0,0 +1,39 @@ +#pragma once + +#include "Util/JsonBuilder.h" +#include "SeqCollectiblesFilter.h" +#include "SeqGetCollectibleOrderArgs.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqGetCollectibleOrderArgs +{ + GENERATED_USTRUCT_BODY() + + public: + // Properties + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FString ContractAddress; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FString TokenID; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FSeqCollectiblesFilter Filter; + + bool customGetter = true; + + FString GetArgs() + { + FJsonBuilder Builder; + + Builder.AddString("contractAddress", ContractAddress); + Builder.AddString("tokenID", TokenID); + + if (Filter.ContainsData()) + {// Check if the Filter has data and append its args if it does + Builder.AddField("filter", Filter.GetArgs()); + } + + return Builder.ToString(); + } +}; diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectibleOrderReturn.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectibleOrderReturn.h new file mode 100644 index 000000000..4216bbb27 --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetCollectibleOrderReturn.h @@ -0,0 +1,21 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCollectibleOrder.h" +#include "SeqCurrency.h" +#include "SeqGetCollectibleOrderReturn.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqGetCollectibleOrderReturn +{ + GENERATED_USTRUCT_BODY() + +public: + bool customConstructor = false;//used to tell buildresponse whether or not to use a custom constructor OR the unreal one! + void construct(FJsonObject json_in) {};//dummy construct for templating + void Setup(FJsonObject json_in) {};//dummy method to allow for templating in build response! + + // Properties + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Order") + FSeqCollectibleOrder Order; +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetFloorOrderArgs.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetFloorOrderArgs.h new file mode 100644 index 000000000..e88efd84c --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetFloorOrderArgs.h @@ -0,0 +1,46 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCollectiblesFilter.h" +#include "SeqMarketplacePage.h" +#include "Util/JsonBuilder.h" +#include "SeqGetFloorOrderArgs.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqGetFloorOrderArgs +{ + GENERATED_USTRUCT_BODY() + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FString ContractAddress; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FSeqCollectiblesFilter Filter; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FSeqMarketplacePage Page; + + bool customGetter = true; + + FString GetArgs() + { + FJsonBuilder Builder; + + Builder.AddString("contractAddress", ContractAddress); + + if (Filter.ContainsData()) + {// Check if the Filter has data and append its args if it does + Builder.AddField("filter", Filter.GetArgs()); + } + + // Check if the Page has data and append its args if it does + if (Page.ContainsData()) + { + Builder.AddString("page", Page.GetArgs()); + } + + return Builder.ToString(); + } + +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetOrderReturn.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetOrderReturn.h new file mode 100644 index 000000000..a072b42c2 --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqGetOrderReturn.h @@ -0,0 +1,21 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCollectibleOrder.h" +#include "Util/JsonBuilder.h" +#include "SeqMarketplacePage.h" +#include "SeqGetOrderReturn.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqGetOrderReturn +{ + GENERATED_USTRUCT_BODY() + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FSeqCollectibleOrder Collectible; + + bool customConstructor = false;//used to tell buildresponse whether or not to use a custom constructor OR the unreal one! + void construct(FJsonObject json_in) {};//dummy construct for templating + void Setup(FJsonObject json_in) {};//dummy method to allow for templating in build response! +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListAllCollectibleListingsWithLowestPriceFirstArgs.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListAllCollectibleListingsWithLowestPriceFirstArgs.h deleted file mode 100644 index a311185b7..000000000 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListAllCollectibleListingsWithLowestPriceFirstArgs.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -USTRUCT(BlueprintType) -class SEQUENCEPLUGIN_API FSeqListAllCollectibleListingsWithLowestPriceFirstArgs -{ - GENERATED_USTRUCT_BODY() - -public: - -}; diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsArgs.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsArgs.h new file mode 100644 index 000000000..6937e8d90 --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsArgs.h @@ -0,0 +1,50 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCollectiblesFilter.h" +#include "SeqMarketplacePage.h" +#include "Util/JsonBuilder.h" +#include "SeqListCollectibleListingsArgs.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqListCollectibleListingsArgs +{ + GENERATED_USTRUCT_BODY() + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FString ContractAddress; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FString TokenID; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FSeqCollectiblesFilter Filter; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FSeqMarketplacePage Page; + + bool customGetter = true; + + FString GetArgs() + { + FJsonBuilder Builder; + + Builder.AddString("contractAddress", ContractAddress); + Builder.AddString("tokenID", TokenID); + + if (Filter.ContainsData()) + {// Check if the Filter has data and append its args if it does + Builder.AddField("filter", Filter.GetArgs()); + } + + // Check if the Page has data and append its args if it does + if (Page.ContainsData()) + { + Builder.AddString("page", Page.GetArgs()); + } + + return Builder.ToString(); + } + +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsReturn.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsReturn.h new file mode 100644 index 000000000..9bf8ae57e --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsReturn.h @@ -0,0 +1,74 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCollectibleOrder.h" +#include "SeqMarketplacePage.h" +#include "SeqListCollectibleListingsReturn.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqListCollectibleListingsReturn +{ + GENERATED_USTRUCT_BODY() + +public: + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + TArray Listings; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FSeqMarketplacePage Page; + + bool customConstructor = false; // Flag to determine the constructor used + + // Dummy constructor method to maintain consistency + void construct(FJsonObject json_in) {} + + /* + * Returns a JSON Object for arguments / testing purposes + */ + TSharedPtr GetJson() + { + TSharedPtr ret = MakeShareable(new FJsonObject); + + // Convert Page object to JSON + ret->SetObjectField("page", Page.GetJson()); + + // Convert CollectibleOrders array to JSON + TArray> collectibleOrdersList; + for (FSeqCollectibleOrder order : Listings) + { + collectibleOrdersList.Add(order.GetJson()); + } + + // Set the collectible orders as a simple string array in JSON + ret->SetStringField("listings", USequenceSupport::JsonObjListToSimpleString(collectibleOrdersList)); + return ret; + } + + /* + * Handles edge cases with Unreal's JSON parsing + //*/ + void Setup(FJsonObject json_in) + { + const TArray>* lst; + if (json_in.TryGetArrayField(TEXT("listings"), lst)) + { + Listings.SetNum(lst->Num()); + + for (int32 i = 0; i < lst->Num(); i++) + { + TSharedPtr item = (*lst)[i]; + + if (item.IsValid()) + { + TSharedPtr itemObj = item->AsObject(); + Listings[i].Setup(*itemObj); + } + } + } + else + { + UE_LOG(LogTemp, Warning, TEXT("No collectibles field found in the GetCollectiblesWithLowestListings response.")); + } + } +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleOffersReturn.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleOffersReturn.h new file mode 100644 index 000000000..ea00762a4 --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleOffersReturn.h @@ -0,0 +1,74 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCollectibleOrder.h" +#include "SeqMarketplacePage.h" +#include "SeqListCollectibleOffersReturn.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqListCollectibleOffersReturn +{ + GENERATED_USTRUCT_BODY() + +public: + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + TArray Offers; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + FSeqMarketplacePage Page; + + bool customConstructor = false; // Flag to determine the constructor used + + // Dummy constructor method to maintain consistency + void construct(FJsonObject json_in) {} + + /* + * Returns a JSON Object for arguments / testing purposes + */ + TSharedPtr GetJson() + { + TSharedPtr ret = MakeShareable(new FJsonObject); + + // Convert Page object to JSON + ret->SetObjectField("page", Page.GetJson()); + + // Convert CollectibleOrders array to JSON + TArray> collectibleOrdersList; + for (FSeqCollectibleOrder order : Offers) + { + collectibleOrdersList.Add(order.GetJson()); + } + + // Set the collectible orders as a simple string array in JSON + ret->SetStringField("listings", USequenceSupport::JsonObjListToSimpleString(collectibleOrdersList)); + return ret; + } + + /* + * Handles edge cases with Unreal's JSON parsing + //*/ + void Setup(FJsonObject json_in) + { + const TArray>* lst; + if (json_in.TryGetArrayField(TEXT("offers"), lst)) + { + Offers.SetNum(lst->Num()); + + for (int32 i = 0; i < lst->Num(); i++) + { + TSharedPtr item = (*lst)[i]; + + if (item.IsValid()) + { + TSharedPtr itemObj = item->AsObject(); + Offers[i].Setup(*itemObj); + } + } + } + else + { + UE_LOG(LogTemp, Warning, TEXT("No collectibles field found in the GetCollectibleOffers response.")); + } + } +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectiblesArgs.h similarity index 63% rename from Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h rename to Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectiblesArgs.h index dde292748..d2ff72808 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCollectiblesArgs.h @@ -3,7 +3,8 @@ #include "CoreMinimal.h" #include "SeqCollectiblesFilter.h" #include "SeqMarketplacePage.h" -#include "SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.generated.h" +#include "Util/JsonBuilder.h" +#include "SeqListCollectiblesArgs.generated.h" USTRUCT(BlueprintType) struct SEQUENCEPLUGIN_API FSeqListCollectiblesArgs @@ -12,6 +13,9 @@ struct SEQUENCEPLUGIN_API FSeqListCollectiblesArgs public: // Properties + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") + TEnumAsByte Side; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Collectibles") FString ContractAddress; @@ -25,26 +29,23 @@ struct SEQUENCEPLUGIN_API FSeqListCollectiblesArgs FString GetArgs() { - FString ret = "{"; + FJsonBuilder Builder; - ret += "\"contractAddress\":\"" + ContractAddress + "\""; + Builder.AddString("side", UEnum::GetValueAsString(Side).ToLower()); + Builder.AddString("contractAddress", ContractAddress); if (Filter.ContainsData()) {// Check if the Filter has data and append its args if it does - ret.Append(",\"filter\":"); - ret.Append(Filter.GetArgs()); + Builder.AddField("filter", Filter.GetArgs()); } // Check if the Page has data and append its args if it does if (Page.ContainsData()) { - ret.Append(",\"page\":"); - ret.Append(Page.GetArgs()); + Builder.AddString("page", Page.GetArgs()); } - ret.Append("}"); // Close the JSON object - return ret; - + return Builder.ToString(); } }; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesResponse.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesResponse.h deleted file mode 100644 index 0b8b157d5..000000000 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesResponse.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "SeqCurrency.h" -#include "SeqListCurrenciesResponse.generated.h" - -USTRUCT(BlueprintType) -struct SEQUENCEPLUGIN_API FSeqListCurrenciesResponse -{ - GENERATED_USTRUCT_BODY() - -public: - // Properties - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Page") - TArray Currencies; -}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesReturn.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesReturn.h new file mode 100644 index 000000000..06f5e1ede --- /dev/null +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqListCurrenciesReturn.h @@ -0,0 +1,20 @@ +#pragma once + +#include "CoreMinimal.h" +#include "SeqCurrency.h" +#include "SeqListCurrenciesReturn.generated.h" + +USTRUCT(BlueprintType) +struct SEQUENCEPLUGIN_API FSeqListCurrenciesReturn +{ + GENERATED_USTRUCT_BODY() + +public: + bool customConstructor = false;//used to tell buildresponse whether or not to use a custom constructor OR the unreal one! + void construct(FJsonObject json_in) {};//dummy construct for templating + void Setup(FJsonObject json_in) {};//dummy method to allow for templating in build response! + + // Properties + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Page") + TArray Currencies; +}; \ No newline at end of file diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqMarketplacePage.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqMarketplacePage.h index b4894ca4f..9c65c493e 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqMarketplacePage.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqMarketplacePage.h @@ -33,6 +33,11 @@ struct SEQUENCEPLUGIN_API FSeqMarketplacePage UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Page") bool More; + static FSeqMarketplacePage Empty() + { + return FSeqMarketplacePage{}; + } + bool ContainsData() { bool ret = false;//assume nothing & look for true states! diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqOrder.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqOrder.h index b99c9bde8..aa59065e0 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqOrder.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqOrder.h @@ -197,9 +197,11 @@ struct SEQUENCEPLUGIN_API FSeqOrder if (feeValue->Type == EJson::Object) { FSeqFeeBreakdown fee; - TSharedPtr feeJsonObject = USequenceSupport::JsonStringToObject(feeValue->AsString()); - fee.Setup(*feeJsonObject); - FeeBreakdown.Add(fee); + //TSharedPtr feeJsonObject = USequenceSupport::JsonStringToObject(feeValue->AsString()); + fee.Setup(*feeValue->AsObject()); + FeeBreakdown.Add(fee); + + UE_LOG(LogTemp, Warning, TEXT("fee setup")); } } } diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/Struct_Data.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/Struct_Data.h index fd98e19c7..4d0536e73 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/Struct_Data.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/Struct_Data.h @@ -1,7 +1,7 @@ #pragma once #include "Marketplace/Marketplace_Enums.h" -#include "SeqListCollectibleListingsWithLowestPriceListingsFirstArgs.h" +#include "SeqListCollectiblesArgs.h" #include "SeqListCollectiblesReturn.h" #include "SeqCollectiblesFilter.h" #include "SeqPropertyFilter.h" From c0f269fe9e7f61449719a6a3c5b4fc8d09c81c08 Mon Sep 17 00:00:00 2001 From: Jan Dohring Date: Mon, 16 Dec 2024 15:14:48 -0500 Subject: [PATCH 3/4] marketplace api test functions --- .../Core/Testing/BP_GeneralTesting.uasset | 4 +- .../SequencePlugin/Private/GeneralTesting.cpp | 113 ++++++++++++- .../SequencePlugin/Private/GeneralTesting.h | 26 ++- .../Private/Marketplace/Marketplace.cpp | 1 - .../Private/Tests/TestSequenceAPI.cpp | 155 +++++++++++++++++- .../Private/Tests/TestSequenceAPI.h | 10 +- 6 files changed, 291 insertions(+), 18 deletions(-) diff --git a/Plugins/SequencePlugin/Content/Core/Testing/BP_GeneralTesting.uasset b/Plugins/SequencePlugin/Content/Core/Testing/BP_GeneralTesting.uasset index 89164e7be..56d097664 100644 --- a/Plugins/SequencePlugin/Content/Core/Testing/BP_GeneralTesting.uasset +++ b/Plugins/SequencePlugin/Content/Core/Testing/BP_GeneralTesting.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e23b117e8a88476e640a69d95a2efe9dec578b4dedcf78915eec504762386258 -size 259135 +oid sha256:9592f0930baf48dea1577e9c91dcd95ae6db3168743bf52c6081ab3e5fa0995a +size 285841 diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.cpp index 705657be9..c99ff8414 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.cpp @@ -235,7 +235,7 @@ void AGeneralTesting::TestListCurrencies() const SequenceAPITest::ListCurrencies(OnSuccess, OnFailure); } -void AGeneralTesting::TestListCollectibleListingsWithLowestPriceListingsFirst() const +void AGeneralTesting::TestListAllCollectibleListingsWithLowestPriceListingsFirst() const { const TFunction OnSuccess = [this](FString State) { @@ -247,10 +247,10 @@ void AGeneralTesting::TestListCollectibleListingsWithLowestPriceListingsFirst() CallbackFailed(Data, Err); }; - SequenceAPITest::ListCollectibleListingsWithLowestPricedListingsFirst(OnSuccess, OnFailure); + SequenceAPITest::ListAllCollectibleListingsWithLowestPriceListingsFirst(OnSuccess, OnFailure); } -void AGeneralTesting::TestListAllCollectibleListingsWithLowestPriceListingsFirst() const +void AGeneralTesting::TestListAllCollectibleOffersWithHighestPricedOfferFirst() const { const TFunction OnSuccess = [this](FString State) { @@ -262,7 +262,112 @@ void AGeneralTesting::TestListAllCollectibleListingsWithLowestPriceListingsFirst CallbackFailed(Data, Err); }; - SequenceAPITest::ListAllCollectibleListingsWithLowestPriceListingsFirst(OnSuccess, OnFailure); + SequenceAPITest::ListAllCollectibleOffersWithHighestPricedOfferFirst(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestGetLowestPriceOfferForCollectible() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::GetLowestPriceOfferForCollectible(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestGetHighestPriceOfferForCollectible() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::GetHighestPriceOfferForCollectible(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestGetLowestPriceListingForCollectible() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::GetLowestPriceListingForCollectible(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestGetHighestPriceListingForCollectible() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::GetHighestPriceListingForCollectible(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestListAllListingsForCollectible() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::ListAllListingsForCollectible(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestListAllOffersForCollectible() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::ListAllOffersForCollectible(OnSuccess, OnFailure); +} + +void AGeneralTesting::TestGetFloorOrder() const +{ + const TFunction OnSuccess = [this](FString State) + { + CallbackPassed(State); + }; + + const TFunction OnFailure = [this](FString Data, FSequenceError Err) + { + CallbackFailed(Data, Err); + }; + + SequenceAPITest::GetFloorOrder(OnSuccess, OnFailure); } void AGeneralTesting::TestIndexer() diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.h b/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.h index 9fcba171a..99e34d1bd 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/GeneralTesting.h @@ -82,10 +82,32 @@ class SEQUENCEPLUGIN_API AGeneralTesting : public AActor void TestListCurrencies() const; UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") - void TestListCollectibleListingsWithLowestPriceListingsFirst() const; + void TestListAllCollectibleListingsWithLowestPriceListingsFirst() const; UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") - void TestListAllCollectibleListingsWithLowestPriceListingsFirst() const; + void TestListAllCollectibleOffersWithHighestPricedOfferFirst() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestGetLowestPriceOfferForCollectible() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestGetHighestPriceOfferForCollectible() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestGetLowestPriceListingForCollectible() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestGetHighestPriceListingForCollectible() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestListAllListingsForCollectible() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestListAllOffersForCollectible() const; + + UFUNCTION(BlueprintCallable, CATEGORY = "Test_API") + void TestGetFloorOrder() const; + /* * Called by frontend to test the indexer diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp index 65af27cec..c8f70adb7 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Marketplace/Marketplace.cpp @@ -334,7 +334,6 @@ void UMarketplace::GetFloorOrder(const int64 ChainID, const FString& ContractAdd const FSeqGetOrderReturn Response = this->BuildResponse(Content); OnSuccess(Response.Collectible); }, OnFailure); - } diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp index e1be92485..dbb855b40 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp @@ -489,19 +489,18 @@ void SequenceAPITest::ListCurrencies(TFunction OnSuccess, }); } -void SequenceAPITest::ListCollectibleListingsWithLowestPricedListingsFirst(TFunction OnSuccess, - TFunction OnFailure) +void SequenceAPITest::ListAllCollectibleListingsWithLowestPriceListingsFirst(TFunction OnSuccess, + TFunction OnFailure) { UMarketplace* Marketplace = NewObject(); USequenceSupport* Support = NewObject(); - Marketplace->ListCollectibleListingsWithLowestPriceListingsFirst( + Marketplace->ListAllCollectibleListingsWithLowestPriceListingsFirst( Support->GetNetworkId(ENetwork::PolygonChain), "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", FSeqCollectiblesFilter::Empty(), - FSeqMarketplacePage::Empty(), - [OnSuccess](FSeqListCollectiblesReturn Orders) { - OnSuccess("Orders: " + FString::FromInt(Orders.CollectibleOrders.Num())); + [OnSuccess](TArray Orders) { + OnSuccess("Orders: " + FString::FromInt(Orders.Num())); }, [OnFailure](FSequenceError Error) { OnFailure("Error: " + Error.Message, Error); @@ -509,15 +508,115 @@ void SequenceAPITest::ListCollectibleListingsWithLowestPricedListingsFirst(TFunc ); } -void SequenceAPITest::ListAllCollectibleListingsWithLowestPriceListingsFirst(TFunction OnSuccess, - TFunction OnFailure) +void SequenceAPITest::ListAllCollectibleOffersWithHighestPricedOfferFirst(TFunction OnSuccess, + TFunction OnFailure) { UMarketplace* Marketplace = NewObject(); USequenceSupport* Support = NewObject(); Marketplace->ListAllCollectibleListingsWithLowestPriceListingsFirst( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x5e4bfd71236a21299d43f508dbb76cb7d0fd4e50", + FSeqCollectiblesFilter::Empty(), + [OnSuccess](TArray Orders) { + OnSuccess("Orders: " + FString::FromInt(Orders.Num())); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} + +void SequenceAPITest::GetLowestPriceOfferForCollectible(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->GetLowestPriceOfferForCollectible( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x5e4bfd71236a21299d43f508dbb76cb7d0fd4e50", + "1", + FSeqCollectiblesFilter::Empty(), + [OnSuccess](FSeqCollectibleOrder Order) { + OnSuccess("Order: " + Order.Order.OrderId); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} + +void SequenceAPITest::GetHighestPriceOfferForCollectible(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->GetHighestPriceOfferForCollectible( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x5e4bfd71236a21299d43f508dbb76cb7d0fd4e50", + "1", + FSeqCollectiblesFilter::Empty(), + [OnSuccess](FSeqCollectibleOrder Order) { + OnSuccess("Order: " + Order.Order.OrderId); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} + +void SequenceAPITest::GetLowestPriceListingForCollectible(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->GetLowestPriceListingForCollectible( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", + "130", + FSeqCollectiblesFilter::Empty(), + [OnSuccess](FSeqCollectibleOrder Order) { + OnSuccess("Order: " + Order.Order.OrderId); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} + +void SequenceAPITest::GetHighestPriceListingForCollectible(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->GetLowestPriceListingForCollectible( Support->GetNetworkId(ENetwork::PolygonChain), "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", + "130", + FSeqCollectiblesFilter::Empty(), + [OnSuccess](FSeqCollectibleOrder Order) { + OnSuccess("Order: " + Order.Order.OrderId); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} + +void SequenceAPITest::ListAllListingsForCollectible(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->ListAllListingsForCollectible( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", + "130", FSeqCollectiblesFilter::Empty(), [OnSuccess](TArray Orders) { OnSuccess("Orders: " + FString::FromInt(Orders.Num())); @@ -527,3 +626,43 @@ void SequenceAPITest::ListAllCollectibleListingsWithLowestPriceListingsFirst(TFu } ); } + +void SequenceAPITest::ListAllOffersForCollectible(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->ListAllOffersForCollectible( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x5e4bfd71236a21299d43f508dbb76cb7d0fd4e50", + "1", + FSeqCollectiblesFilter::Empty(), + [OnSuccess](TArray Orders) { + OnSuccess("Orders: " + FString::FromInt(Orders.Num())); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} + +void SequenceAPITest::GetFloorOrder(TFunction OnSuccess, + TFunction OnFailure) +{ + UMarketplace* Marketplace = NewObject(); + USequenceSupport* Support = NewObject(); + + Marketplace->GetFloorOrder( + Support->GetNetworkId(ENetwork::PolygonChain), + "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", + FSeqCollectiblesFilter::Empty(), + [OnSuccess](FSeqCollectibleOrder Order) { + OnSuccess("Order: %s" + Order.Order.OrderId); + }, + [OnFailure](FSequenceError Error) { + OnFailure("Error: " + Error.Message, Error); + } + ); +} + diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.h b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.h index ae253c7a5..566e38b4d 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.h @@ -24,6 +24,14 @@ class SequenceAPITest // Market static void ListCurrencies(TFunction OnSuccess, TFunction OnFailure); - static void ListCollectibleListingsWithLowestPricedListingsFirst(TFunction OnSuccess, TFunction OnFailure); static void ListAllCollectibleListingsWithLowestPriceListingsFirst(TFunction OnSuccess, TFunction OnFailure); + static void ListAllCollectibleOffersWithHighestPricedOfferFirst(TFunction OnSuccess, TFunction OnFailure); + static void GetLowestPriceOfferForCollectible(TFunction OnSuccess, TFunction OnFailure); + static void GetHighestPriceOfferForCollectible(TFunction OnSuccess, TFunction OnFailure); + static void GetLowestPriceListingForCollectible(TFunction OnSuccess, TFunction OnFailure); + static void GetHighestPriceListingForCollectible(TFunction OnSuccess, TFunction OnFailure); + static void ListAllListingsForCollectible(TFunction OnSuccess, TFunction OnFailure); + static void ListAllOffersForCollectible(TFunction OnSuccess, TFunction OnFailure); + static void GetFloorOrder(TFunction OnSuccess, TFunction OnFailure); + }; From bd6b8e9cd99174fd49c603a7ebffaecb542606f4 Mon Sep 17 00:00:00 2001 From: Jan Dohring Date: Tue, 17 Dec 2024 09:47:34 -0500 Subject: [PATCH 4/4] new sequence builder project --- Config/SequenceConfig.ini | 4 ++-- .../Private/Tests/TestSequenceAPI.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Config/SequenceConfig.ini b/Config/SequenceConfig.ini index 14f8e8436..a50f50219 100644 --- a/Config/SequenceConfig.ini +++ b/Config/SequenceConfig.ini @@ -1,7 +1,7 @@ [/Script/Sequence.Config] FallbackEncryptionKey = "aaaabbbbccccddddaaaabbbbccccdddd" -WaaSConfigKey = "eyJwcm9qZWN0SWQiOjM3MDY2LCJycGNTZXJ2ZXIiOiJodHRwczovL3dhYXMuc2VxdWVuY2UuYXBwIn0=" -ProjectAccessKey = "AQAAAAAAAJDKR9cs25gJSSKzszRT9STo9hk" +WaaSConfigKey = "eyJwcm9qZWN0SWQiOjQxMDg3LCJycGNTZXJ2ZXIiOiJodHRwczovL3dhYXMuc2VxdWVuY2UuYXBwIn0=" +ProjectAccessKey = "AQAAAAAAAKB_eaItDuiSDnsDrg1TM5Izj_k" GoogleClientID = "970987756660-35a6tc48hvi8cev9cnknp0iugv9poa23.apps.googleusercontent.com" AppleClientID = "com.horizon.sequence.waas" FacebookClientID = "" diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp index dbb855b40..44bf9902b 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Tests/TestSequenceAPI.cpp @@ -535,7 +535,7 @@ void SequenceAPITest::GetLowestPriceOfferForCollectible(TFunction Marketplace->GetLowestPriceOfferForCollectible( Support->GetNetworkId(ENetwork::PolygonChain), - "0x5e4bfd71236a21299d43f508dbb76cb7d0fd4e50", + "0x079294e6ffec16234578c672fa3fbfd4b6c48640", "1", FSeqCollectiblesFilter::Empty(), [OnSuccess](FSeqCollectibleOrder Order) { @@ -555,7 +555,7 @@ void SequenceAPITest::GetHighestPriceOfferForCollectible(TFunctionGetHighestPriceOfferForCollectible( Support->GetNetworkId(ENetwork::PolygonChain), - "0x5e4bfd71236a21299d43f508dbb76cb7d0fd4e50", + "0x079294e6ffec16234578c672fa3fbfd4b6c48640", "1", FSeqCollectiblesFilter::Empty(), [OnSuccess](FSeqCollectibleOrder Order) { @@ -575,8 +575,8 @@ void SequenceAPITest::GetLowestPriceListingForCollectible(TFunctionGetLowestPriceListingForCollectible( Support->GetNetworkId(ENetwork::PolygonChain), - "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", - "130", + "0x079294e6ffec16234578c672fa3fbfd4b6c48640", + "1", FSeqCollectiblesFilter::Empty(), [OnSuccess](FSeqCollectibleOrder Order) { OnSuccess("Order: " + Order.Order.OrderId); @@ -595,8 +595,8 @@ void SequenceAPITest::GetHighestPriceListingForCollectible(TFunctionGetLowestPriceListingForCollectible( Support->GetNetworkId(ENetwork::PolygonChain), - "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", - "130", + "0x079294e6ffec16234578c672fa3fbfd4b6c48640", + "1", FSeqCollectiblesFilter::Empty(), [OnSuccess](FSeqCollectibleOrder Order) { OnSuccess("Order: " + Order.Order.OrderId); @@ -615,8 +615,8 @@ void SequenceAPITest::ListAllListingsForCollectible(TFunction OnS Marketplace->ListAllListingsForCollectible( Support->GetNetworkId(ENetwork::PolygonChain), - "0x44b3f42e2BF34F62868Ff9e9dAb7C2F807ba97Cb", - "130", + "0x079294e6ffec16234578c672fa3fbfd4b6c48640", + "1", FSeqCollectiblesFilter::Empty(), [OnSuccess](TArray Orders) { OnSuccess("Orders: " + FString::FromInt(Orders.Num())); @@ -635,7 +635,7 @@ void SequenceAPITest::ListAllOffersForCollectible(TFunction OnSuc Marketplace->ListAllOffersForCollectible( Support->GetNetworkId(ENetwork::PolygonChain), - "0x5e4bfd71236a21299d43f508dbb76cb7d0fd4e50", + "0x079294e6ffec16234578c672fa3fbfd4b6c48640", "1", FSeqCollectiblesFilter::Empty(), [OnSuccess](TArray Orders) {