From 131e58a96c5eebd4919c11fb1acfdece99a96677 Mon Sep 17 00:00:00 2001 From: caballoninja Date: Mon, 28 Oct 2024 10:33:34 -0300 Subject: [PATCH 1/2] added ListAccounts intent support added intent call, bp support, intent and response data. --- .../AC_SequencePawn_Component.uasset | 4 +- .../Private/Sequence/SequenceAPI.cpp | 8 +++ .../Private/Sequence/SequenceSendIntent.h | 25 ++++++++ .../Private/Sequence/SequenceWalletBP.cpp | 28 +++++++++ .../Private/SequenceRPCManager.cpp | 34 +++++++++++ .../Private/SequenceRPCManager.h | 2 + .../Public/Sequence/SequenceAPI.h | 1 + .../Public/Sequence/SequenceResponseIntent.h | 60 ++++++++++++++++++- .../Public/Sequence/SequenceWalletBP.h | 8 +++ .../Public/Sequence/SequenceWalletBPTypes.h | 1 + 10 files changed, 168 insertions(+), 3 deletions(-) diff --git a/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset b/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset index 0657bb90d..1e24eccce 100644 --- a/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset +++ b/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9084a40f7f42570693bdb509e0434dcc50d5168d348203c7c5947f6344f2cbc1 -size 2347415 +oid sha256:302ed79846bfceb18d24b4b894fadadaab5b197ee231c9d86e5cd0bf9af424f1 +size 2371483 diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceAPI.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceAPI.cpp index 69b1a25a1..5076066fd 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceAPI.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceAPI.cpp @@ -195,6 +195,14 @@ void USequenceWallet::ListSessions(const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure) const +{ + if (this->SequenceRPCManager) + { + this->SequenceRPCManager->ListAccounts(this->Credentials, OnSuccess, OnFailure); + } +} + void USequenceWallet::SignOut() const { const USequenceAuthenticator * Auth = NewObject(); diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceSendIntent.h b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceSendIntent.h index 94e1f312d..093c5abbf 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceSendIntent.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceSendIntent.h @@ -16,6 +16,7 @@ static const FString CloseSessionOP = "closeSession"; static const FString SendTransactionOP = "sendTransaction"; static const FString FeeOptionsOP = "feeOptions"; static const FString ListSessionsOP = "listSessions"; +static const FString ListAccountsOP = "listAccounts"; static const FString SignMessageOP = "signMessage"; static const FString FederateSessionOP = "federateAccount"; @@ -401,6 +402,30 @@ struct SEQUENCEPLUGIN_API FListSessionsData : public FGenericData } }; +USTRUCT() +struct SEQUENCEPLUGIN_API FListAccountsData : public FGenericData +{ + GENERATED_USTRUCT_BODY() + UPROPERTY() + FString wallet = ""; + + FListAccountsData() + { + Operation = ListAccountsOP; + } + + FListAccountsData(const FString& WalletIn) + { + Operation = ListAccountsOP; + wallet = WalletIn; + } + + virtual FString GetJson() const override + { + return ""; + } +}; + USTRUCT() struct SEQUENCEPLUGIN_API FSignMessageData : public FGenericData { diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceWalletBP.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceWalletBP.cpp index a5741733e..b8cb68eb6 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceWalletBP.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/Sequence/SequenceWalletBP.cpp @@ -55,6 +55,14 @@ void USequenceWalletBP::CallOnApiListSessions(const FSequenceResponseStatus& Sta UE_LOG(LogTemp, Error, TEXT("[Nothing bound to: OnApiListSessions]")); } +void USequenceWalletBP::CallOnApiListAccounts(const FSequenceResponseStatus& Status, const FSeqListAccountsResponse_Data& Response) const +{ + if (this->OnApiListAccounts.IsBound()) + this->OnApiListAccounts.Broadcast(Status, Response); + else + UE_LOG(LogTemp, Error, TEXT("[Nothing bound to: OnApiListAccounts]")); +} + void USequenceWalletBP::CallOnApiGetSupportedTransakCountries(const FSequenceResponseStatus& Status, const TArray& SupportedCountries) const { if (this->OnApiGetSupportedTransakCountries.IsBound()) @@ -389,6 +397,26 @@ void USequenceWalletBP::ApiListSessions() } } +void USequenceWalletBP::ApiListAccounts() +{ + const TFunction OnSuccess = [this](const FSeqListAccountsResponse_Data& Response) + { + this->CallOnApiListAccounts(FSequenceResponseStatus(true, ListAccountsTrt), Response); + }; + + const TFunction OnFailure = [this](const FSequenceError& Err) + { + this->CallOnApiListAccounts(FSequenceResponseStatus(false, Err.Message, ListAccountsTrt), {}); + }; + + const TOptional WalletOptional = USequenceWallet::Get(); + if (WalletOptional.IsSet() && WalletOptional.GetValue()) + { + const USequenceWallet* Wallet = WalletOptional.GetValue(); + Wallet->ListAccounts(OnSuccess, OnFailure); + } +} + void USequenceWalletBP::ApiGetSupportedTransakCountries() { const TFunction)> OnSuccess = [this](const TArray& SupportedCountries) diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceRPCManager.cpp b/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceRPCManager.cpp index 4932f9277..a655b00d1 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceRPCManager.cpp +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceRPCManager.cpp @@ -112,6 +112,13 @@ FString USequenceRPCManager::BuildListSessionIntent(const FCredentials_BE& Crede return Intent; } +FString USequenceRPCManager::BuildListAccountsIntent(const FCredentials_BE& Credentials) const +{ + const FListAccountsData ListAccountsData(Credentials.GetWalletAddress()); + const FString Intent = this->GenerateIntent(ListAccountsData); + return Intent; +} + FString USequenceRPCManager::BuildCloseSessionIntent() const { const FCloseSessionData CloseSessionData(this->SessionWallet->GetSessionId()); @@ -350,6 +357,33 @@ void USequenceRPCManager::ListSessions(const FCredentials_BE& Credentials, const } } +void USequenceRPCManager::ListAccounts(const FCredentials_BE& Credentials, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure) const +{ + const TSuccessCallback OnResponse = [OnSuccess, OnFailure](const FString& Response) + { + const FSeqListAccountsResponse ParsedResponse = USequenceSupport::JSONStringToStruct(Response); + + UE_LOG(LogTemp, Log, TEXT("%s"), *Response); + if (ParsedResponse.IsValid()) + { + OnSuccess(ParsedResponse.Response.Data); + } + else + { + OnFailure(FSequenceError(RequestFail, "Error Parsing Response: " + Response)); + } + }; + + if (Credentials.RegisteredValid()) + { + this->SequenceRPC(this->BuildUrl(), this->BuildListAccountsIntent(Credentials), OnResponse, OnFailure); + } + else + { + OnFailure(FSequenceError(RequestFail, "[Session Not Registered Please Register Session First]")); + } +} + void USequenceRPCManager::CloseSession(const FCredentials_BE& Credentials, const TFunction& OnSuccess, const FFailureCallback& OnFailure) const { const TSuccessCallback OnResponse = [this,OnSuccess,OnFailure](const FString& Response) diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceRPCManager.h b/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceRPCManager.h index b9c4de580..3ffac8fd1 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceRPCManager.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Private/SequenceRPCManager.h @@ -63,6 +63,7 @@ class SEQUENCEPLUGIN_API USequenceRPCManager : public UObject FString BuildSendTransactionIntent(const FCredentials_BE& Credentials, const TArray& Transactions) const; FString BuildSendTransactionWithFeeIntent(const FCredentials_BE& Credentials, const TArray& Transactions,const FString& FeeQuote) const; FString BuildListSessionIntent(const FCredentials_BE& Credentials) const; + FString BuildListAccountsIntent(const FCredentials_BE& Credentials) const; FString BuildCloseSessionIntent() const; FString BuildSessionValidationIntent() const; FString BuildFederateAccountIntent(const FFederateAccountData& FederateAccountIntent) const; @@ -174,6 +175,7 @@ class SEQUENCEPLUGIN_API USequenceRPCManager : public UObject */ void ListSessions(const FCredentials_BE& Credentials, const TSuccessCallback>& OnSuccess, const FFailureCallback& OnFailure) const; + void ListAccounts(const FCredentials_BE& Credentials, const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure) const; /** * Used to close the Current Session * @param Credentials Credentials used to build Intent diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceAPI.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceAPI.h index 375f612b0..ddd1351be 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceAPI.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceAPI.h @@ -193,6 +193,7 @@ class SEQUENCEPLUGIN_API USequenceWallet : public UGameInstanceSubsystem */ void ListSessions(const TSuccessCallback>& OnSuccess, const FFailureCallback& OnFailure) const; + void ListAccounts(const TSuccessCallback& OnSuccess, const FFailureCallback& OnFailure) const; /** * Used to close the current Session with Sequence & clears all locally stored credentials */ diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceResponseIntent.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceResponseIntent.h index 8db3fa0f3..f7b57d35e 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceResponseIntent.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceResponseIntent.h @@ -553,4 +553,62 @@ struct SEQUENCEPLUGIN_API FSeqListSessionsResponse } }; -//ListSessions// \ No newline at end of file +USTRUCT(Blueprintable) +struct SEQUENCEPLUGIN_API FSeqAccount +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default") + FString Id = ""; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default") + FString Type = ""; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default") + FString Issuer = ""; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default") + FString Email = ""; + + +}; + +USTRUCT(Blueprintable) +struct SEQUENCEPLUGIN_API FSeqListAccountsResponse_Data +{ + GENERATED_BODY() + + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Default") + TArray Accounts; + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Default") + FString CurrentAccountId = ""; +}; + + + +USTRUCT() +struct SEQUENCEPLUGIN_API FSeqListAccountsResponse_Response +{ + GENERATED_BODY() + UPROPERTY() + FString Code = ""; + UPROPERTY() + FSeqListAccountsResponse_Data Data; + + bool IsValid() const + { + return Code.Equals(TEXT("accountList"), ESearchCase::IgnoreCase); + } +}; + +USTRUCT() +struct SEQUENCEPLUGIN_API FSeqListAccountsResponse +{ + GENERATED_BODY() + + UPROPERTY() + FSeqListAccountsResponse_Response Response; + + bool IsValid() const + { + return Response.IsValid(); + } +}; + diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceWalletBP.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceWalletBP.h index 9c3f8b75e..f250a0469 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceWalletBP.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceWalletBP.h @@ -20,6 +20,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnIApiGetUnFilteredFeeOptions, FSe DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnIApiSendTransactionWtihFeeOption, FSequenceResponseStatus, ResponseStatus, FSeqTransactionResponse_Data, Response); DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnIApiSendTransaction, FSequenceResponseStatus, ResponseStatus, FSeqTransactionResponse_Data, Response); DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnIApiListSessions, FSequenceResponseStatus, ResponseStatus, const TArray&, Sessions); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnIApiListAccounts, FSequenceResponseStatus, ResponseStatus, const FSeqListAccountsResponse_Data&, Data); DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnIApiGetSupportedTransakCountries, FSequenceResponseStatus, ResponseStatus, const TArray&, SupportedCountries); //Api// @@ -75,6 +76,9 @@ class SEQUENCEPLUGIN_API USequenceWalletBP : public UObject UPROPERTY(BlueprintAssignable, Category="ASYNC_RESPONSE") FOnIApiListSessions OnApiListSessions; + UPROPERTY(BlueprintAssignable, Category = "ASYNC_RESPONSE") + FOnIApiListAccounts OnApiListAccounts; + UPROPERTY(BlueprintAssignable, Category="ASYNC_RESPONSE") FOnIApiGetSupportedTransakCountries OnApiGetSupportedTransakCountries; @@ -124,6 +128,7 @@ class SEQUENCEPLUGIN_API USequenceWalletBP : public UObject void CallOnApiSendTransactionWithFee(const FSequenceResponseStatus& Status, const FSeqTransactionResponse_Data& Response) const; void CallOnApiSendTransaction(const FSequenceResponseStatus& Status, const FSeqTransactionResponse_Data& Response) const; void CallOnApiListSessions(const FSequenceResponseStatus& Status, const TArray& Sessions) const; + void CallOnApiListAccounts(const FSequenceResponseStatus& Status, const FSeqListAccountsResponse_Data& Response) const; void CallOnApiGetSupportedTransakCountries(const FSequenceResponseStatus& Status, const TArray& SupportedCountries) const; //Api// @@ -242,6 +247,9 @@ class SEQUENCEPLUGIN_API USequenceWalletBP : public UObject UFUNCTION(BlueprintCallable, Category="ASync Api") void ApiListSessions(); + UFUNCTION(BlueprintCallable, Category = "ASync Api") + void ApiListAccounts(); + UFUNCTION(BlueprintCallable, Category="ASync Api") void ApiGetSupportedTransakCountries(); diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceWalletBPTypes.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceWalletBPTypes.h index 21e00cbe5..4fe4f7d1f 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceWalletBPTypes.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Sequence/SequenceWalletBPTypes.h @@ -39,6 +39,7 @@ enum ETransactionResponseType SendTransactionWithFeeTrt UMETA(DisplayName = "SendTransactionWithFee"), SendTransactionTrt UMETA(DisplayName = "SendTransaction"), ListSessionsTrt UMETA(DisplayName = "ListSessions"), + ListAccountsTrt UMETA(DisplayName = "ListAccounts"), GetSupportedTransakCountriesTrt UMETA(DisplayName = "GetSupportedTransakCountries"), PingTrt UMETA(DisplayName = "Ping"), VersionTrt UMETA(DisplayName = "Version"), From 9f7287218eeb1e2c1ffb9c5fe7e5e6480863dda2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andy=20Gru=CC=88ning?= Date: Wed, 30 Oct 2024 16:01:03 +0100 Subject: [PATCH 2/2] Fixed SequenceWalletBP ref in AC_SequencePawn, missing header include --- .../Core/Pawn_Components/AC_SequencePawn_Component.uasset | 4 ++-- .../Public/Marketplace/Structs/SeqMarketplaceSortBy.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset b/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset index 9387239e9..aaf867316 100644 --- a/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset +++ b/Plugins/SequencePlugin/Content/Core/Pawn_Components/AC_SequencePawn_Component.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c9e98f46668233166316278e81da225edcc5b5dec838547eff17f2473d3fb020 -size 2374223 +oid sha256:8b791c47c7cc0be72b4be832085448682755097fd1e8733b5cc0f42882fe84ff +size 2377660 diff --git a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqMarketplaceSortBy.h b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqMarketplaceSortBy.h index 6e2463b8c..74dfde91b 100644 --- a/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqMarketplaceSortBy.h +++ b/Plugins/SequencePlugin/Source/SequencePlugin/Public/Marketplace/Structs/SeqMarketplaceSortBy.h @@ -2,6 +2,7 @@ #include "CoreMinimal.h" #include "Marketplace/Marketplace_Enums.h" +#include "Dom/JsonObject.h" #include "SeqMarketplaceSortBy.generated.h" USTRUCT(BlueprintType)