diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblBlueprintAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblBlueprintAsyncAction.cpp index 89214a5..81ebfe9 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblBlueprintAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblBlueprintAsyncAction.cpp @@ -2,10 +2,11 @@ #include "Immutable/Actions/ImtblBlueprintAsyncAction.h" -UImmutableSubsystem *UImtblBlueprintAsyncAction::GetSubsystem() const { - if (!WorldContextObject || !WorldContextObject->GetWorld()) - return nullptr; - return WorldContextObject->GetWorld() - ->GetGameInstance() - ->GetSubsystem(); +UImmutableSubsystem* UImtblBlueprintAsyncAction::GetSubsystem() const +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + return nullptr; + } + return WorldContextObject->GetWorld()->GetGameInstance()->GetSubsystem(); } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblConnectImxAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblConnectImxAsyncAction.cpp index 4e70576..fe796c9 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblConnectImxAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblConnectImxAsyncAction.cpp @@ -32,22 +32,22 @@ UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::ConnectImx(UObject* UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::LoginPKCE(UObject* WorldContextObject) { UImtblConnectionAsyncActions* PassportInitBlueprintNode = NewObject(); - + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; PassportInitBlueprintNode->bIsConnectImx = false; PassportInitBlueprintNode->bIsPKCE = true; - + return PassportInitBlueprintNode; } UImtblConnectionAsyncActions* UImtblConnectionAsyncActions::ConnectImxPKCE(UObject* WorldContextObject) { UImtblConnectionAsyncActions* PassportInitBlueprintNode = NewObject(); - + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; PassportInitBlueprintNode->bIsConnectImx = true; PassportInitBlueprintNode->bIsPKCE = true; - + return PassportInitBlueprintNode; } @@ -58,7 +58,7 @@ void UImtblConnectionAsyncActions::Activate() FString Error = "Connect failed due to missing world or world context object."; IMTBL_WARN("%s", *Error) Failed.Broadcast(Error); - + return; } @@ -74,14 +74,12 @@ void UImtblConnectionAsyncActions::DoConnect(TWeakObjectPtr J if (bIsPKCE) { #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC - Passport->ConnectPKCE(bIsConnectImx, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject - (this, &UImtblConnectionAsyncActions::OnConnect)); + Passport->ConnectPKCE(bIsConnectImx, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblConnectionAsyncActions::OnConnect)); #endif } else { - Passport->Connect(bIsConnectImx, bUseCachedSession, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject - (this, &UImtblConnectionAsyncActions::OnConnect)); + Passport->Connect(bIsConnectImx, bUseCachedSession, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblConnectionAsyncActions::OnConnect)); } } else diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportConnectEvmAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportConnectEvmAsyncAction.cpp index 5e2232d..ac54cbb 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportConnectEvmAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportConnectEvmAsyncAction.cpp @@ -6,42 +6,42 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImtblPassportConnectEvmAsyncAction * -UImtblPassportConnectEvmAsyncAction::ConnectEvm(UObject *WorldContextObject) { - UImtblPassportConnectEvmAsyncAction *PassportInitBlueprintNode = - NewObject(); - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - return PassportInitBlueprintNode; +UImtblPassportConnectEvmAsyncAction* UImtblPassportConnectEvmAsyncAction::ConnectEvm(UObject* WorldContextObject) +{ + UImtblPassportConnectEvmAsyncAction* PassportInitBlueprintNode = NewObject(); + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; + return PassportInitBlueprintNode; } -void UImtblPassportConnectEvmAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - FString Err = - "ConnectEvm failed due to missing world or world context object."; - IMTBL_WARN("%s", *Err) - Failed.Broadcast(Err); - return; - } +void UImtblPassportConnectEvmAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + FString Err = "ConnectEvm failed due to missing world or world context object."; + IMTBL_WARN("%s", *Err) + Failed.Broadcast(Err); + return; + } - GetSubsystem()->WhenReady(this, - &UImtblPassportConnectEvmAsyncAction::DoConnectEvm); + GetSubsystem()->WhenReady(this, &UImtblPassportConnectEvmAsyncAction::DoConnectEvm); } -void UImtblPassportConnectEvmAsyncAction::DoConnectEvm( - TWeakObjectPtr JSConnector) { - // Get Passport - auto Passport = GetSubsystem()->GetPassport(); - // Run ConnectEvm - Passport->ConnectEvm( - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImtblPassportConnectEvmAsyncAction::OnConnectEvm)); +void UImtblPassportConnectEvmAsyncAction::DoConnectEvm(TWeakObjectPtr JSConnector) +{ + // Get Passport + auto Passport = GetSubsystem()->GetPassport(); + // Run ConnectEvm + Passport->ConnectEvm(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportConnectEvmAsyncAction::OnConnectEvm)); } -void UImtblPassportConnectEvmAsyncAction::OnConnectEvm( - FImmutablePassportResult Result) { - if (Result.Success) { - Success.Broadcast(Result.Message); - } else { - Failed.Broadcast(Result.Message); - } +void UImtblPassportConnectEvmAsyncAction::OnConnectEvm(FImmutablePassportResult Result) +{ + if (Result.Success) + { + Success.Broadcast(Result.Message); + } + else + { + Failed.Broadcast(Result.Message); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.cpp index 197cf33..7d5699e 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.cpp @@ -6,44 +6,42 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImtblPassportGetAccessTokenAsyncAction * -UImtblPassportGetAccessTokenAsyncAction::GetAccessToken( - UObject *WorldContextObject) { - UImtblPassportGetAccessTokenAsyncAction *PassportInitBlueprintNode = - NewObject(); - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - return PassportInitBlueprintNode; +UImtblPassportGetAccessTokenAsyncAction* UImtblPassportGetAccessTokenAsyncAction::GetAccessToken(UObject* WorldContextObject) +{ + UImtblPassportGetAccessTokenAsyncAction* PassportInitBlueprintNode = NewObject(); + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; + return PassportInitBlueprintNode; } -void UImtblPassportGetAccessTokenAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - FString Err = - "GetAccessToken failed due to missing world or world context object."; - IMTBL_WARN("%s", *Err) - Failed.Broadcast(Err, TEXT("")); - return; - } +void UImtblPassportGetAccessTokenAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + FString Err = "GetAccessToken failed due to missing world or world context object."; + IMTBL_WARN("%s", *Err) + Failed.Broadcast(Err, TEXT("")); + return; + } - GetSubsystem()->WhenReady( - this, &UImtblPassportGetAccessTokenAsyncAction::DoGetAccessToken); + GetSubsystem()->WhenReady(this, &UImtblPassportGetAccessTokenAsyncAction::DoGetAccessToken); } -void UImtblPassportGetAccessTokenAsyncAction::DoGetAccessToken( - TWeakObjectPtr JSConnector) { - // Get Passport - auto Passport = GetSubsystem()->GetPassport(); - // Run GetAccessToken - Passport->GetAccessToken( - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, - &UImtblPassportGetAccessTokenAsyncAction::OnGetAccessTokenResponse)); +void UImtblPassportGetAccessTokenAsyncAction::DoGetAccessToken(TWeakObjectPtr JSConnector) +{ + // Get Passport + auto Passport = GetSubsystem()->GetPassport(); + // Run GetAccessToken + Passport->GetAccessToken(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportGetAccessTokenAsyncAction::OnGetAccessTokenResponse)); } -void UImtblPassportGetAccessTokenAsyncAction::OnGetAccessTokenResponse( - FImmutablePassportResult Result) { - if (Result.Success) { - GotAccessToken.Broadcast(TEXT(""), Result.Message); - } else { - Failed.Broadcast(Result.Message, TEXT("")); - } +void UImtblPassportGetAccessTokenAsyncAction::OnGetAccessTokenResponse(FImmutablePassportResult Result) +{ + if (Result.Success) + { + GotAccessToken.Broadcast(TEXT(""), Result.Message); + } + else + { + Failed.Broadcast(Result.Message, TEXT("")); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAddressAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAddressAsyncAction.cpp index 6ba38ef..dd884a1 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAddressAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAddressAsyncAction.cpp @@ -6,44 +6,43 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImtblPassportGetAddressAsyncAction * -UImtblPassportGetAddressAsyncAction::GetAddress(UObject *WorldContextObject) { - UImtblPassportGetAddressAsyncAction *PassportInitBlueprintNode = - NewObject(); - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - return PassportInitBlueprintNode; +UImtblPassportGetAddressAsyncAction* UImtblPassportGetAddressAsyncAction::GetAddress(UObject* WorldContextObject) +{ + UImtblPassportGetAddressAsyncAction* PassportInitBlueprintNode = NewObject(); + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; + return PassportInitBlueprintNode; } -void UImtblPassportGetAddressAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - FString Err = - "GetAddress failed due to missing world or world context object."; - IMTBL_WARN("%s", *Err) - Failed.Broadcast(Err, TEXT("")); - return; - } +void UImtblPassportGetAddressAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + FString Err = "GetAddress failed due to missing world or world context object."; + IMTBL_WARN("%s", *Err) + Failed.Broadcast(Err, TEXT("")); + return; + } - GetSubsystem()->WhenReady( - this, - &UImtblPassportGetAddressAsyncAction::DoGetAddress); //, /* timoutSec - //*/ 15.0f); + GetSubsystem()->WhenReady(this, &UImtblPassportGetAddressAsyncAction::DoGetAddress); //, /* timoutSec + //*/ 15.0f); } -void UImtblPassportGetAddressAsyncAction::DoGetAddress( - TWeakObjectPtr JSConnector) { - // Get Passport - auto Passport = GetSubsystem()->GetPassport(); - // Run GetAddress - Passport->GetAddress( - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImtblPassportGetAddressAsyncAction::OnGetAddressResponse)); +void UImtblPassportGetAddressAsyncAction::DoGetAddress(TWeakObjectPtr JSConnector) +{ + // Get Passport + auto Passport = GetSubsystem()->GetPassport(); + // Run GetAddress + Passport->GetAddress(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportGetAddressAsyncAction::OnGetAddressResponse)); } -void UImtblPassportGetAddressAsyncAction::OnGetAddressResponse( - FImmutablePassportResult Result) { - if (Result.Success) { - GotAddress.Broadcast(TEXT(""), Result.Message); - } else { - Failed.Broadcast(Result.Message, TEXT("")); - } +void UImtblPassportGetAddressAsyncAction::OnGetAddressResponse(FImmutablePassportResult Result) +{ + if (Result.Success) + { + GotAddress.Broadcast(TEXT(""), Result.Message); + } + else + { + Failed.Broadcast(Result.Message, TEXT("")); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetEmailAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetEmailAsyncAction.cpp index ab7a28a..5a9e0da 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetEmailAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetEmailAsyncAction.cpp @@ -6,43 +6,43 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImtblPassportGetEmailAsyncAction * -UImtblPassportGetEmailAsyncAction::GetEmail(UObject *WorldContextObject) { - UImtblPassportGetEmailAsyncAction *PassportInitBlueprintNode = - NewObject(); - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - return PassportInitBlueprintNode; +UImtblPassportGetEmailAsyncAction* UImtblPassportGetEmailAsyncAction::GetEmail(UObject* WorldContextObject) +{ + UImtblPassportGetEmailAsyncAction* PassportInitBlueprintNode = NewObject(); + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; + return PassportInitBlueprintNode; } -void UImtblPassportGetEmailAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - FString Err = - "GetEmail failed due to missing world or world context object."; - IMTBL_WARN("%s", *Err) - Failed.Broadcast(Err, TEXT("")); - return; - } +void UImtblPassportGetEmailAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + FString Err = "GetEmail failed due to missing world or world context object."; + IMTBL_WARN("%s", *Err) + Failed.Broadcast(Err, TEXT("")); + return; + } - GetSubsystem()->WhenReady( - this, &UImtblPassportGetEmailAsyncAction::DoGetEmail); //, /* timoutSec - //*/ 15.0f); + GetSubsystem()->WhenReady(this, &UImtblPassportGetEmailAsyncAction::DoGetEmail); //, /* timoutSec + //*/ 15.0f); } -void UImtblPassportGetEmailAsyncAction::DoGetEmail( - TWeakObjectPtr JSConnector) { - // Get Passport - auto Passport = GetSubsystem()->GetPassport(); - // Run GetEmail - Passport->GetEmail( - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImtblPassportGetEmailAsyncAction::OnGetEmailResponse)); +void UImtblPassportGetEmailAsyncAction::DoGetEmail(TWeakObjectPtr JSConnector) +{ + // Get Passport + auto Passport = GetSubsystem()->GetPassport(); + // Run GetEmail + Passport->GetEmail(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportGetEmailAsyncAction::OnGetEmailResponse)); } -void UImtblPassportGetEmailAsyncAction::OnGetEmailResponse( - FImmutablePassportResult Result) { - if (Result.Success) { - GotEmail.Broadcast(TEXT(""), Result.Message); - } else { - Failed.Broadcast(Result.Message, TEXT("")); - } +void UImtblPassportGetEmailAsyncAction::OnGetEmailResponse(FImmutablePassportResult Result) +{ + if (Result.Success) + { + GotEmail.Broadcast(TEXT(""), Result.Message); + } + else + { + Failed.Broadcast(Result.Message, TEXT("")); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.cpp index efa8c36..323a630 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.cpp @@ -6,42 +6,42 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImtblPassportGetIdTokenAsyncAction * -UImtblPassportGetIdTokenAsyncAction::GetIdToken(UObject *WorldContextObject) { - UImtblPassportGetIdTokenAsyncAction *PassportInitBlueprintNode = - NewObject(); - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - return PassportInitBlueprintNode; +UImtblPassportGetIdTokenAsyncAction* UImtblPassportGetIdTokenAsyncAction::GetIdToken(UObject* WorldContextObject) +{ + UImtblPassportGetIdTokenAsyncAction* PassportInitBlueprintNode = NewObject(); + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; + return PassportInitBlueprintNode; } -void UImtblPassportGetIdTokenAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - FString Err = - "GetIdToken failed due to missing world or world context object."; - IMTBL_WARN("%s", *Err) - Failed.Broadcast(Err, TEXT("")); - return; - } +void UImtblPassportGetIdTokenAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + FString Err = "GetIdToken failed due to missing world or world context object."; + IMTBL_WARN("%s", *Err) + Failed.Broadcast(Err, TEXT("")); + return; + } - GetSubsystem()->WhenReady(this, - &UImtblPassportGetIdTokenAsyncAction::DoGetIdToken); + GetSubsystem()->WhenReady(this, &UImtblPassportGetIdTokenAsyncAction::DoGetIdToken); } -void UImtblPassportGetIdTokenAsyncAction::DoGetIdToken( - TWeakObjectPtr JSConnector) { - // Get Passport - auto Passport = GetSubsystem()->GetPassport(); - // Run GetIdToken - Passport->GetIdToken( - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImtblPassportGetIdTokenAsyncAction::OnGetIdTokenResponse)); +void UImtblPassportGetIdTokenAsyncAction::DoGetIdToken(TWeakObjectPtr JSConnector) +{ + // Get Passport + auto Passport = GetSubsystem()->GetPassport(); + // Run GetIdToken + Passport->GetIdToken(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportGetIdTokenAsyncAction::OnGetIdTokenResponse)); } -void UImtblPassportGetIdTokenAsyncAction::OnGetIdTokenResponse( - FImmutablePassportResult Result) { - if (Result.Success) { - GotIdToken.Broadcast(TEXT(""), Result.Message); - } else { - Failed.Broadcast(Result.Message, TEXT("")); - } +void UImtblPassportGetIdTokenAsyncAction::OnGetIdTokenResponse(FImmutablePassportResult Result) +{ + if (Result.Success) + { + GotIdToken.Broadcast(TEXT(""), Result.Message); + } + else + { + Failed.Broadcast(Result.Message, TEXT("")); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportHasStoredCredentialsAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportHasStoredCredentialsAsyncAction.cpp index 73147f9..eb431b9 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportHasStoredCredentialsAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportHasStoredCredentialsAsyncAction.cpp @@ -33,7 +33,7 @@ void UImtblPassportHasStoredCredentialsAsyncAction::DoHasStoredCredentials(TWeak if (Passport.IsValid()) { - Passport->HasStoredCredentials(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportHasStoredCredentialsAsyncAction::OnHasStoredCredentialsResponse)); + Passport->HasStoredCredentials(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportHasStoredCredentialsAsyncAction::OnHasStoredCredentialsResponse)); } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxBatchNftTransferAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxBatchNftTransferAsyncAction.cpp index 0661357..1fac37e 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxBatchNftTransferAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxBatchNftTransferAsyncAction.cpp @@ -7,58 +7,54 @@ #include "Immutable/ImmutableResponses.h" #include "Immutable/Misc/ImtblLogging.h" -UImmutablePassportImxBatchNftTransferAsyncAction * -UImmutablePassportImxBatchNftTransferAsyncAction::ImxBatchNftTransfer( - UObject *WorldContextObject, - const TArray &NftTransferDetails) { - UImmutablePassportImxBatchNftTransferAsyncAction *BlueprintNode = - NewObject(); - BlueprintNode->WorldContextObject = WorldContextObject; - BlueprintNode->NftTransferDetails = NftTransferDetails; - return BlueprintNode; +UImmutablePassportImxBatchNftTransferAsyncAction* UImmutablePassportImxBatchNftTransferAsyncAction::ImxBatchNftTransfer(UObject* WorldContextObject, const TArray& NftTransferDetails) +{ + UImmutablePassportImxBatchNftTransferAsyncAction* BlueprintNode = NewObject(); + BlueprintNode->WorldContextObject = WorldContextObject; + BlueprintNode->NftTransferDetails = NftTransferDetails; + return BlueprintNode; } -void UImmutablePassportImxBatchNftTransferAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - const FString Err = - "BatchNftTransfer failed due to missing world or world context object."; - IMTBL_WARN("Error: %s", *Err) - TArray TransferIds; - Failed.Broadcast(Err, TransferIds); - return; - } - - GetSubsystem()->WhenReady( - this, &UImmutablePassportImxBatchNftTransferAsyncAction::DoTransfer); +void UImmutablePassportImxBatchNftTransferAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + const FString Err = "BatchNftTransfer failed due to missing world or world context object."; + IMTBL_WARN("Error: %s", *Err) + TArray TransferIds; + Failed.Broadcast(Err, TransferIds); + return; + } + + GetSubsystem()->WhenReady(this, &UImmutablePassportImxBatchNftTransferAsyncAction::DoTransfer); } -void UImmutablePassportImxBatchNftTransferAsyncAction::DoTransfer( - TWeakObjectPtr JSConnector) { - // Get Passport - FImxBatchNftTransferRequest Request; - Request.nftTransferDetails = NftTransferDetails; +void UImmutablePassportImxBatchNftTransferAsyncAction::DoTransfer(TWeakObjectPtr JSConnector) +{ + // Get Passport + FImxBatchNftTransferRequest Request; + Request.nftTransferDetails = NftTransferDetails; - // Run Transfer - GetSubsystem()->GetPassport()->ImxBatchNftTransfer( - Request, - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImmutablePassportImxBatchNftTransferAsyncAction:: - OnTransferResponse)); + // Run Transfer + GetSubsystem()->GetPassport()->ImxBatchNftTransfer(Request, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImmutablePassportImxBatchNftTransferAsyncAction::OnTransferResponse)); } -void UImmutablePassportImxBatchNftTransferAsyncAction::OnTransferResponse( - FImmutablePassportResult Result) { - TArray TransferIds; - if (Result.Success) { - if (auto BatchNftTransferResponse = - JsonObjectToUStruct( - Result.Response.JsonObject)) { - for (auto Id : BatchNftTransferResponse->transferIds) { - TransferIds.Add(FString::Printf(TEXT("%u,"), Id)); - } - } - Success.Broadcast(TEXT(""), TransferIds); - } else { - Failed.Broadcast(Result.Message, TransferIds); - } +void UImmutablePassportImxBatchNftTransferAsyncAction::OnTransferResponse(FImmutablePassportResult Result) +{ + TArray TransferIds; + if (Result.Success) + { + if (auto BatchNftTransferResponse = JsonObjectToUStruct(Result.Response.JsonObject)) + { + for (auto Id : BatchNftTransferResponse->transferIds) + { + TransferIds.Add(FString::Printf(TEXT("%u,"), Id)); + } + } + Success.Broadcast(TEXT(""), TransferIds); + } + else + { + Failed.Broadcast(Result.Message, TransferIds); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxIsRegisteredOffchainAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxIsRegisteredOffchainAsyncAction.cpp index 189f9fd..ae162d6 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxIsRegisteredOffchainAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxIsRegisteredOffchainAsyncAction.cpp @@ -10,7 +10,7 @@ UImtblPassportImxIsRegisteredOffchainAsyncAction* UImtblPassportImxIsRegisteredO UImtblPassportImxIsRegisteredOffchainAsyncAction* PassportInitBlueprintNode = NewObject(); PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - + return PassportInitBlueprintNode; } @@ -24,21 +24,20 @@ void UImtblPassportImxIsRegisteredOffchainAsyncAction::Activate() return; } - GetSubsystem()->WhenReady(this, &UImtblPassportImxIsRegisteredOffchainAsyncAction::DoImxIsRegisteredOffchain);//, /* timoutSec */ 15.0f); + GetSubsystem()->WhenReady(this, &UImtblPassportImxIsRegisteredOffchainAsyncAction::DoImxIsRegisteredOffchain); //, /* timoutSec */ 15.0f); } void UImtblPassportImxIsRegisteredOffchainAsyncAction::DoImxIsRegisteredOffchain(TWeakObjectPtr JSConnector) { const auto Passport = GetSubsystem()->GetPassport(); - + if (Passport.IsValid()) { - Passport->ImxIsRegisteredOffchain(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportImxIsRegisteredOffchainAsyncAction::OnImxIsRegisteredOffchainResponse)); + Passport->ImxIsRegisteredOffchain(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportImxIsRegisteredOffchainAsyncAction::OnImxIsRegisteredOffchainResponse)); } } void UImtblPassportImxIsRegisteredOffchainAsyncAction::OnImxIsRegisteredOffchainResponse(FImmutablePassportResult Result) { - OnComplete.Broadcast(Result.Success); + OnComplete.Broadcast(Result.Success); } - diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxRegisterOffchainAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxRegisterOffchainAsyncAction.cpp index 3dcb3c0..61ba876 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxRegisterOffchainAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxRegisterOffchainAsyncAction.cpp @@ -11,7 +11,7 @@ UImtblPassportImxRegisterOffchainAsyncAction* UImtblPassportImxRegisterOffchainA UImtblPassportImxRegisterOffchainAsyncAction* PassportInitBlueprintNode = NewObject(); PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - + return PassportInitBlueprintNode; } @@ -31,10 +31,10 @@ void UImtblPassportImxRegisterOffchainAsyncAction::Activate() void UImtblPassportImxRegisterOffchainAsyncAction::DoImxRegisterOffchain(TWeakObjectPtr JSConnector) { const auto Passport = GetSubsystem()->GetPassport(); - + if (Passport.IsValid()) { - Passport->ImxRegisterOffchain(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportImxRegisterOffchainAsyncAction::OnImxRegisterOffchainResponse)); + Passport->ImxRegisterOffchain(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportImxRegisterOffchainAsyncAction::OnImxRegisterOffchainResponse)); } } @@ -47,8 +47,7 @@ void UImtblPassportImxRegisterOffchainAsyncAction::OnImxRegisterOffchainResponse OnSuccess.Broadcast(ResponseData->tx_hash, TEXT("")); return; } - } + } OnFailure.Broadcast(TEXT(""), Result.Message); } - diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxTransferAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxTransferAsyncAction.cpp index 11806ee..eaed70a 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxTransferAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportImxTransferAsyncAction.cpp @@ -6,61 +6,57 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImmutablePassportImxTransferAsyncAction * -UImmutablePassportImxTransferAsyncAction::ImxTransfer( - UObject *WorldContextObject, const FString &Receiver, const FString &Type, - const FString &Amount, const FString &TokenId, - const FString &TokenAddress) { - UImmutablePassportImxTransferAsyncAction *BlueprintNode = - NewObject(); - BlueprintNode->WorldContextObject = WorldContextObject; - BlueprintNode->Receiver = Receiver; - BlueprintNode->Type = Type; - BlueprintNode->Amount = Amount; - BlueprintNode->TokenId = TokenId; - BlueprintNode->TokenAddress = TokenAddress; - return BlueprintNode; +UImmutablePassportImxTransferAsyncAction* UImmutablePassportImxTransferAsyncAction::ImxTransfer(UObject* WorldContextObject, const FString& Receiver, const FString& Type, const FString& Amount, const FString& TokenId, const FString& TokenAddress) +{ + UImmutablePassportImxTransferAsyncAction* BlueprintNode = NewObject(); + BlueprintNode->WorldContextObject = WorldContextObject; + BlueprintNode->Receiver = Receiver; + BlueprintNode->Type = Type; + BlueprintNode->Amount = Amount; + BlueprintNode->TokenId = TokenId; + BlueprintNode->TokenAddress = TokenAddress; + return BlueprintNode; } -void UImmutablePassportImxTransferAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - const FString Err = - "Transfer failed due to missing world or world context object."; - IMTBL_WARN("Error: %s", *Err) - Failed.Broadcast(Err, TEXT("")); - return; - } +void UImmutablePassportImxTransferAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + const FString Err = "Transfer failed due to missing world or world context object."; + IMTBL_WARN("Error: %s", *Err) + Failed.Broadcast(Err, TEXT("")); + return; + } - GetSubsystem()->WhenReady( - this, &UImmutablePassportImxTransferAsyncAction::DoTransfer); + GetSubsystem()->WhenReady(this, &UImmutablePassportImxTransferAsyncAction::DoTransfer); } -void UImmutablePassportImxTransferAsyncAction::DoTransfer( - TWeakObjectPtr JSConnector) { - // Get Passport - FImxTransferRequest Request; - Request.receiver = Receiver; - Request.type = Type; - Request.amount = Amount; - Request.tokenId = TokenId; - Request.tokenAddress = TokenAddress; - // Run Transfer - GetSubsystem()->GetPassport()->ImxTransfer( - Request, - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImmutablePassportImxTransferAsyncAction::OnTransferResponse)); +void UImmutablePassportImxTransferAsyncAction::DoTransfer(TWeakObjectPtr JSConnector) +{ + // Get Passport + FImxTransferRequest Request; + Request.receiver = Receiver; + Request.type = Type; + Request.amount = Amount; + Request.tokenId = TokenId; + Request.tokenAddress = TokenAddress; + // Run Transfer + GetSubsystem()->GetPassport()->ImxTransfer(Request, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImmutablePassportImxTransferAsyncAction::OnTransferResponse)); } -void UImmutablePassportImxTransferAsyncAction::OnTransferResponse( - FImmutablePassportResult Result) { - if (Result.Success) { - FString TransferId; - if (auto TransferResponse = JsonObjectToUStruct( - Result.Response.JsonObject)) { - TransferId = FString::Printf(TEXT("%u"), TransferResponse->transferId); - } - Success.Broadcast(TEXT(""), TransferId); - } else { - Failed.Broadcast(Result.Message, TEXT("")); - } +void UImmutablePassportImxTransferAsyncAction::OnTransferResponse(FImmutablePassportResult Result) +{ + if (Result.Success) + { + FString TransferId; + if (auto TransferResponse = JsonObjectToUStruct(Result.Response.JsonObject)) + { + TransferId = FString::Printf(TEXT("%u"), TransferResponse->transferId); + } + Success.Broadcast(TEXT(""), TransferId); + } + else + { + Failed.Broadcast(Result.Message, TEXT("")); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportInitializationAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportInitializationAsyncAction.cpp index 3f07dc7..1bec1ba 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportInitializationAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportInitializationAsyncAction.cpp @@ -6,17 +6,16 @@ #include "Immutable/ImmutableSubsystem.h" -UImtblPassportInitializationAsyncAction* UImtblPassportInitializationAsyncAction::InitializePassport(UObject* WorldContextObject, const FString& ClientID, const FString& RedirectUri, - const FString& LogoutUri, const FString& Environment) +UImtblPassportInitializationAsyncAction* UImtblPassportInitializationAsyncAction::InitializePassport(UObject* WorldContextObject, const FString& ClientID, const FString& RedirectUri, const FString& LogoutUri, const FString& Environment) { UImtblPassportInitializationAsyncAction* PassportInitBlueprintNode = NewObject(); - + PassportInitBlueprintNode->ClientId = ClientID; PassportInitBlueprintNode->RedirectUri = RedirectUri; PassportInitBlueprintNode->LogoutUri = LogoutUri; PassportInitBlueprintNode->Environment = Environment; PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - + return PassportInitBlueprintNode; } @@ -36,8 +35,7 @@ void UImtblPassportInitializationAsyncAction::DoInit(TWeakObjectPtrGetPassport(); // Run Initialize - Passport->Initialize(FImmutablePassportInitData{ ClientId, RedirectUri, LogoutUri, Environment }, - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportInitializationAsyncAction::OnInitialized)); + Passport->Initialize(FImmutablePassportInitData{ClientId, RedirectUri, LogoutUri, Environment}, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportInitializationAsyncAction::OnInitialized)); } void UImtblPassportInitializationAsyncAction::OnInitialized(FImmutablePassportResult Result) diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmGetBalanceAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmGetBalanceAsyncAction.cpp index cf9deb0..2c0e158 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmGetBalanceAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmGetBalanceAsyncAction.cpp @@ -6,50 +6,46 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImtblPassportZkEvmGetBalanceAsyncAction * -UImtblPassportZkEvmGetBalanceAsyncAction::ZkEvmGetBalance( - UObject *WorldContextObject, const FString &Address, - const FString &BlockNumberOrTag) { - UImtblPassportZkEvmGetBalanceAsyncAction *PassportInitBlueprintNode = - NewObject(); - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - PassportInitBlueprintNode->Address = Address; - PassportInitBlueprintNode->BlockNumberOrTag = BlockNumberOrTag; - return PassportInitBlueprintNode; +UImtblPassportZkEvmGetBalanceAsyncAction* UImtblPassportZkEvmGetBalanceAsyncAction::ZkEvmGetBalance(UObject* WorldContextObject, const FString& Address, const FString& BlockNumberOrTag) +{ + UImtblPassportZkEvmGetBalanceAsyncAction* PassportInitBlueprintNode = NewObject(); + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; + PassportInitBlueprintNode->Address = Address; + PassportInitBlueprintNode->BlockNumberOrTag = BlockNumberOrTag; + return PassportInitBlueprintNode; } -void UImtblPassportZkEvmGetBalanceAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - FString Err = - "ZkEvmGetBalance failed due to missing world or world context object."; - IMTBL_WARN("%s", *Err) - Failed.Broadcast(Err, TEXT("")); - return; - } +void UImtblPassportZkEvmGetBalanceAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + FString Err = "ZkEvmGetBalance failed due to missing world or world context object."; + IMTBL_WARN("%s", *Err) + Failed.Broadcast(Err, TEXT("")); + return; + } - GetSubsystem()->WhenReady( - this, &UImtblPassportZkEvmGetBalanceAsyncAction::DoZkEvmGetBalance); + GetSubsystem()->WhenReady(this, &UImtblPassportZkEvmGetBalanceAsyncAction::DoZkEvmGetBalance); } -void UImtblPassportZkEvmGetBalanceAsyncAction::DoZkEvmGetBalance( - TWeakObjectPtr JSConnector) { - // Get Passport - auto Passport = GetSubsystem()->GetPassport(); - // Run ZkEvmGetBalance - Passport->ZkEvmGetBalance( - FImmutablePassportZkEvmGetBalanceData{Address, BlockNumberOrTag}, - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImtblPassportZkEvmGetBalanceAsyncAction:: - OnZkEvmGetBalanceResponse)); +void UImtblPassportZkEvmGetBalanceAsyncAction::DoZkEvmGetBalance(TWeakObjectPtr JSConnector) +{ + // Get Passport + auto Passport = GetSubsystem()->GetPassport(); + // Run ZkEvmGetBalance + Passport->ZkEvmGetBalance(FImmutablePassportZkEvmGetBalanceData{Address, BlockNumberOrTag}, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmGetBalanceAsyncAction::OnZkEvmGetBalanceResponse)); } -void UImtblPassportZkEvmGetBalanceAsyncAction::OnZkEvmGetBalanceResponse( - FImmutablePassportResult Result) { - if (Result.Success) { - IMTBL_LOG("ZkEvmGetBalance success") - GotBalance.Broadcast(TEXT(""), Result.Message); - } else { - IMTBL_LOG("ZkEvmGetBalance failed") - Failed.Broadcast(Result.Message, TEXT("")); - } +void UImtblPassportZkEvmGetBalanceAsyncAction::OnZkEvmGetBalanceResponse(FImmutablePassportResult Result) +{ + if (Result.Success) + { + IMTBL_LOG("ZkEvmGetBalance success") + GotBalance.Broadcast(TEXT(""), Result.Message); + } + else + { + IMTBL_LOG("ZkEvmGetBalance failed") + Failed.Broadcast(Result.Message, TEXT("")); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmRequestAccountsAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmRequestAccountsAsyncAction.cpp index d19a676..cef062f 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmRequestAccountsAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmRequestAccountsAsyncAction.cpp @@ -6,47 +6,45 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImtblPassportZkEvmRequestAccountsAsyncAction * -UImtblPassportZkEvmRequestAccountsAsyncAction::RequestAccounts( - UObject *WorldContextObject) { - UImtblPassportZkEvmRequestAccountsAsyncAction *PassportInitBlueprintNode = - NewObject(); - PassportInitBlueprintNode->WorldContextObject = WorldContextObject; - return PassportInitBlueprintNode; +UImtblPassportZkEvmRequestAccountsAsyncAction* UImtblPassportZkEvmRequestAccountsAsyncAction::RequestAccounts(UObject* WorldContextObject) +{ + UImtblPassportZkEvmRequestAccountsAsyncAction* PassportInitBlueprintNode = NewObject(); + PassportInitBlueprintNode->WorldContextObject = WorldContextObject; + return PassportInitBlueprintNode; } -void UImtblPassportZkEvmRequestAccountsAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - FString Err = "ZkEvmRequestAccounts failed due to missing world or world " - "context object."; - IMTBL_WARN("%s", *Err) - TArray StrArr; - Failed.Broadcast(Err, StrArr); - return; - } +void UImtblPassportZkEvmRequestAccountsAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + FString Err = "ZkEvmRequestAccounts failed due to missing world or world " "context object."; + IMTBL_WARN("%s", *Err) + TArray StrArr; + Failed.Broadcast(Err, StrArr); + return; + } - GetSubsystem()->WhenReady( - this, &UImtblPassportZkEvmRequestAccountsAsyncAction::DoRequestAccounts); + GetSubsystem()->WhenReady(this, &UImtblPassportZkEvmRequestAccountsAsyncAction::DoRequestAccounts); } -void UImtblPassportZkEvmRequestAccountsAsyncAction::DoRequestAccounts( - TWeakObjectPtr JSConnector) { - // Get Passport - auto Passport = GetSubsystem()->GetPassport(); - // Run ZkEvmRequestAccounts - Passport->ZkEvmRequestAccounts( - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImtblPassportZkEvmRequestAccountsAsyncAction:: - OnRequestAccountsResponse)); +void UImtblPassportZkEvmRequestAccountsAsyncAction::DoRequestAccounts(TWeakObjectPtr JSConnector) +{ + // Get Passport + auto Passport = GetSubsystem()->GetPassport(); + // Run ZkEvmRequestAccounts + Passport->ZkEvmRequestAccounts(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmRequestAccountsAsyncAction::OnRequestAccountsResponse)); } -void UImtblPassportZkEvmRequestAccountsAsyncAction::OnRequestAccountsResponse( - FImmutablePassportResult Result) { - TArray StrArr; - if (Result.Success) { - Result.Message.ParseIntoArray(StrArr, TEXT(",")); - GotAccounts.Broadcast(TEXT(""), StrArr); - } else { - Failed.Broadcast(Result.Message, StrArr); - } +void UImtblPassportZkEvmRequestAccountsAsyncAction::OnRequestAccountsResponse(FImmutablePassportResult Result) +{ + TArray StrArr; + if (Result.Success) + { + Result.Message.ParseIntoArray(StrArr, TEXT(",")); + GotAccounts.Broadcast(TEXT(""), StrArr); + } + else + { + Failed.Broadcast(Result.Message, StrArr); + } } diff --git a/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmSendTransactionAsyncAction.cpp b/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmSendTransactionAsyncAction.cpp index 02361be..f64fff3 100644 --- a/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmSendTransactionAsyncAction.cpp +++ b/Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmSendTransactionAsyncAction.cpp @@ -6,51 +6,45 @@ #include "Immutable/ImmutableSubsystem.h" #include "Immutable/Misc/ImtblLogging.h" -UImtblPassportZkEvmSendTransactionAsyncAction * -UImtblPassportZkEvmSendTransactionAsyncAction::ZkEvmSendTransaction( - UObject *WorldContextObject, const FImtblTransactionRequest &Request) { - UImtblPassportZkEvmSendTransactionAsyncAction - *PassportZkEvmSendTransactionBlueprintNode = - NewObject(); - PassportZkEvmSendTransactionBlueprintNode->WorldContextObject = - WorldContextObject; - PassportZkEvmSendTransactionBlueprintNode->TransactionRequest = Request; - return PassportZkEvmSendTransactionBlueprintNode; +UImtblPassportZkEvmSendTransactionAsyncAction* UImtblPassportZkEvmSendTransactionAsyncAction::ZkEvmSendTransaction(UObject* WorldContextObject, const FImtblTransactionRequest& Request) +{ + UImtblPassportZkEvmSendTransactionAsyncAction* PassportZkEvmSendTransactionBlueprintNode = NewObject(); + PassportZkEvmSendTransactionBlueprintNode->WorldContextObject = WorldContextObject; + PassportZkEvmSendTransactionBlueprintNode->TransactionRequest = Request; + return PassportZkEvmSendTransactionBlueprintNode; } -void UImtblPassportZkEvmSendTransactionAsyncAction::Activate() { - if (!WorldContextObject || !WorldContextObject->GetWorld()) { - FString Err = "ZkEvmSendTransaction failed due to missing world or world " - "context object."; - IMTBL_WARN("%s", *Err) - Failed.Broadcast(Err, TEXT("")); - return; - } +void UImtblPassportZkEvmSendTransactionAsyncAction::Activate() +{ + if (!WorldContextObject || !WorldContextObject->GetWorld()) + { + FString Err = "ZkEvmSendTransaction failed due to missing world or world " "context object."; + IMTBL_WARN("%s", *Err) + Failed.Broadcast(Err, TEXT("")); + return; + } - GetSubsystem()->WhenReady( - this, - &UImtblPassportZkEvmSendTransactionAsyncAction::DoZkEvmSendTransaction); + GetSubsystem()->WhenReady(this, &UImtblPassportZkEvmSendTransactionAsyncAction::DoZkEvmSendTransaction); } -void UImtblPassportZkEvmSendTransactionAsyncAction::DoZkEvmSendTransaction( - TWeakObjectPtr JSConnector) { - // Get Passport - auto Passport = GetSubsystem()->GetPassport(); - // Run ZkEvmSendTransaction - Passport->ZkEvmSendTransaction( - TransactionRequest, - UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject( - this, &UImtblPassportZkEvmSendTransactionAsyncAction:: - OnZkEvmSendTransactionResponse)); +void UImtblPassportZkEvmSendTransactionAsyncAction::DoZkEvmSendTransaction(TWeakObjectPtr JSConnector) +{ + // Get Passport + auto Passport = GetSubsystem()->GetPassport(); + // Run ZkEvmSendTransaction + Passport->ZkEvmSendTransaction(TransactionRequest, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmSendTransactionAsyncAction::OnZkEvmSendTransactionResponse)); } -void UImtblPassportZkEvmSendTransactionAsyncAction:: - OnZkEvmSendTransactionResponse(FImmutablePassportResult Result) { - if (Result.Success) { - IMTBL_LOG("ZkEvmSendTransaction success") - TransactionSent.Broadcast(TEXT(""), Result.Message); - } else { - IMTBL_LOG("ZkEvmSendTransaction failed") - Failed.Broadcast(Result.Message, TEXT("")); - } +void UImtblPassportZkEvmSendTransactionAsyncAction::OnZkEvmSendTransactionResponse(FImmutablePassportResult Result) +{ + if (Result.Success) + { + IMTBL_LOG("ZkEvmSendTransaction success") + TransactionSent.Broadcast(TEXT(""), Result.Message); + } + else + { + IMTBL_LOG("ZkEvmSendTransaction failed") + Failed.Broadcast(Result.Message, TEXT("")); + } } diff --git a/Source/Immutable/Private/Immutable/ImmutablePassport.cpp b/Source/Immutable/Private/Immutable/ImmutablePassport.cpp index 6a7ac24..4f81d11 100644 --- a/Source/Immutable/Private/Immutable/ImmutablePassport.cpp +++ b/Source/Immutable/Private/Immutable/ImmutablePassport.cpp @@ -92,21 +92,18 @@ FString FImmutablePassportZkEvmRequestAccountsData::ToJsonString() const return OutString; } -TOptional FImmutablePassportZkEvmRequestAccountsData::FromJsonString( - const FString& JsonObjectString) +TOptional FImmutablePassportZkEvmRequestAccountsData::FromJsonString(const FString& JsonObjectString) { FImmutablePassportZkEvmRequestAccountsData RequestAccounts; if (!FJsonObjectConverter::JsonObjectStringToUStruct(JsonObjectString, &RequestAccounts, 0, 0)) { - IMTBL_WARN("Could not parse response from JavaScript into the expected " - "Passport ZkEvm request accounts format") + IMTBL_WARN("Could not parse response from JavaScript into the expected " "Passport ZkEvm request accounts format") return TOptional(); } return RequestAccounts; } -TOptional FImmutablePassportZkEvmRequestAccountsData::FromJsonObject( - const TSharedPtr& JsonObject) +TOptional FImmutablePassportZkEvmRequestAccountsData::FromJsonObject(const TSharedPtr& JsonObject) { if (!JsonObject.IsValid()) { return TOptional(); } @@ -114,8 +111,7 @@ TOptional FImmutablePassportZkEvmReq FImmutablePassportZkEvmRequestAccountsData RequestAccounts; if (!FJsonObjectConverter::JsonObjectToUStruct(JsonObject.ToSharedRef(), &RequestAccounts, 0, 0)) { - IMTBL_ERR("Could not parse response from JavaScript into the expected " - "Passport ZkEvm request accounts format") + IMTBL_ERR("Could not parse response from JavaScript into the expected " "Passport ZkEvm request accounts format") return TOptional(); } return RequestAccounts; @@ -139,15 +135,13 @@ FString FImmutablePassportZkEvmGetBalanceData::ToJsonString() const return OutString; } -void UImmutablePassport::Initialize(const FImmutablePassportInitData& Data, - const FImtblPassportResponseDelegate& ResponseDelegate) +void UImmutablePassport::Initialize(const FImmutablePassportInitData& Data, const FImtblPassportResponseDelegate& ResponseDelegate) { check(JSConnector.IsValid()); InitData = Data; - CallJS(ImmutablePassportAction::INIT, InitData.ToJsonString(), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitializeResponse), false); + CallJS(ImmutablePassportAction::INIT, InitData.ToJsonString(), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitializeResponse), false); } void UImmutablePassport::Connect(bool IsConnectImx, bool TryToRelogin, const FImtblPassportResponseDelegate& ResponseDelegate) @@ -159,27 +153,24 @@ void UImmutablePassport::Connect(bool IsConnectImx, bool TryToRelogin, const FIm } if (TryToRelogin) { - CallJS(IsConnectImx ? ImmutablePassportAction::RECONNECT : ImmutablePassportAction::RELOGIN, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::ReinstateConnection)); + CallJS(IsConnectImx ? ImmutablePassportAction::RECONNECT : ImmutablePassportAction::RELOGIN, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::ReinstateConnection)); } else { - CallJS(ImmutablePassportAction::INIT_DEVICE_FLOW, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitDeviceFlowResponse)); + CallJS(ImmutablePassportAction::INIT_DEVICE_FLOW, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitDeviceFlowResponse)); } } #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC -void UImmutablePassport::ConnectPKCE(bool IsConnectImx, const FImtblPassportResponseDelegate &ResponseDelegate) +void UImmutablePassport::ConnectPKCE(bool IsConnectImx, const FImtblPassportResponseDelegate& ResponseDelegate) { - SetStateFlags(IPS_CONNECTING|IPS_PKCE); + SetStateFlags(IPS_CONNECTING | IPS_PKCE); if (IsConnectImx) { SetStateFlags(IPS_IMX); } PKCEResponseDelegate = ResponseDelegate; - CallJS(ImmutablePassportAction::GetPKCEAuthUrl, TEXT(""), PKCEResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetPKCEAuthUrlResponse)); + CallJS(ImmutablePassportAction::GetPKCEAuthUrl, TEXT(""), PKCEResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetPKCEAuthUrlResponse)); } #endif @@ -193,8 +184,7 @@ void UImmutablePassport::Logout(const FImtblPassportResponseDelegate& ResponseDe #endif if (IsStateFlagsSet(IPS_CONNECTED)) { - CallJS(ImmutablePassportAction::Logout, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnLogoutResponse)); + CallJS(ImmutablePassportAction::Logout, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnLogoutResponse)); } else { @@ -204,138 +194,105 @@ void UImmutablePassport::Logout(const FImtblPassportResponseDelegate& ResponseDe void UImmutablePassport::ConnectEvm(const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::ConnectEvm, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnConnectEvmResponse)); + CallJS(ImmutablePassportAction::ConnectEvm, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnConnectEvmResponse)); } void UImmutablePassport::ZkEvmRequestAccounts(const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::ZkEvmRequestAccounts, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnZkEvmRequestAccountsResponse)); + CallJS(ImmutablePassportAction::ZkEvmRequestAccounts, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnZkEvmRequestAccountsResponse)); } -void UImmutablePassport::ZkEvmGetBalance(const FImmutablePassportZkEvmGetBalanceData& Data, - const FImtblPassportResponseDelegate& ResponseDelegate) +void UImmutablePassport::ZkEvmGetBalance(const FImmutablePassportZkEvmGetBalanceData& Data, const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::ZkEvmGetBalance, Data.ToJsonString(), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnZkEvmGetBalanceResponse)); + CallJS(ImmutablePassportAction::ZkEvmGetBalance, Data.ToJsonString(), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnZkEvmGetBalanceResponse)); } -void UImmutablePassport::ZkEvmSendTransaction(const FImtblTransactionRequest& Request, - const FImtblPassportResponseDelegate& ResponseDelegate) +void UImmutablePassport::ZkEvmSendTransaction(const FImtblTransactionRequest& Request, const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::ZkEvmSendTransaction, UStructToJsonString(Request), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnZkEvmSendTransactionResponse)); + CallJS(ImmutablePassportAction::ZkEvmSendTransaction, UStructToJsonString(Request), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnZkEvmSendTransactionResponse)); } -void UImmutablePassport::ConfirmCode(const FString& DeviceCode, const float Interval, - const FImtblPassportResponseDelegate& ResponseDelegate) +void UImmutablePassport::ConfirmCode(const FString& DeviceCode, const float Interval, const FImtblPassportResponseDelegate& ResponseDelegate) { - FImmutablePassportCodeConfirmRequestData Data { DeviceCode, Interval }; + FImmutablePassportCodeConfirmRequestData Data{DeviceCode, Interval}; FString Action = IsStateFlagsSet(IPS_IMX) ? ImmutablePassportAction::CONNECT_CONFIRM_CODE : ImmutablePassportAction::LOGIN_CONFIRM_CODE; - + CallJS(Action, UStructToJsonString(Data), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnConfirmCodeResponse)); } void UImmutablePassport::GetIdToken(const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::GetIdToken, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetIdTokenResponse)); + CallJS(ImmutablePassportAction::GetIdToken, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetIdTokenResponse)); } void UImmutablePassport::GetAccessToken(const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::GetAccessToken, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetAccessTokenResponse)); + CallJS(ImmutablePassportAction::GetAccessToken, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetAccessTokenResponse)); } void UImmutablePassport::GetAddress(const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::GetAddress, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetAddressResponse)); + CallJS(ImmutablePassportAction::GetAddress, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetAddressResponse)); } void UImmutablePassport::GetEmail(const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::GetEmail, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetEmailResponse)); + CallJS(ImmutablePassportAction::GetEmail, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetEmailResponse)); } -void UImmutablePassport::ImxTransfer(const FImxTransferRequest& RequestData, - const FImtblPassportResponseDelegate& ResponseDelegate) +void UImmutablePassport::ImxTransfer(const FImxTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate) { IMTBL_LOG("Tranfer Request: %s", *UStructToJsonString(RequestData)) - CallJS(ImmutablePassportAction::ImxTransfer, UStructToJsonString(RequestData), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnTransferResponse)); + CallJS(ImmutablePassportAction::ImxTransfer, UStructToJsonString(RequestData), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnTransferResponse)); } -void UImmutablePassport::ImxBatchNftTransfer(const FImxBatchNftTransferRequest& RequestData, - const FImtblPassportResponseDelegate& ResponseDelegate) +void UImmutablePassport::ImxBatchNftTransfer(const FImxBatchNftTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::ImxBatchNftTransfer, RequestData.ToJsonString(), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnBatchNftTransferResponse)); + CallJS(ImmutablePassportAction::ImxBatchNftTransfer, RequestData.ToJsonString(), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnBatchNftTransferResponse)); } void UImmutablePassport::ImxIsRegisteredOffchain(const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::ImxIsRegisteredOffchain, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnImxIsRegisteredOffchain)); + CallJS(ImmutablePassportAction::ImxIsRegisteredOffchain, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnImxIsRegisteredOffchain)); } void UImmutablePassport::ImxRegisterOffchain(const FImtblPassportResponseDelegate& ResponseDelegate) { - CallJS(ImmutablePassportAction::ImxRegisterOffchain, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnImxRegisterOffchain)); + CallJS(ImmutablePassportAction::ImxRegisterOffchain, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnImxRegisterOffchain)); } void UImmutablePassport::HasStoredCredentials(const FImtblPassportResponseDelegate& ResponseDelegate) { // we do check credentials into two steps, we check accessToken and then IdToken // check access token - CallJS(ImmutablePassportAction::GetAccessToken, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateLambda( - [=](FImtblJSResponse Response) - { - FString AccessToken; - - Response.JsonObject->TryGetStringField(TEXT("result"), AccessToken); - if (!Response.success || AccessToken.IsEmpty()) - { - ResponseDelegate.ExecuteIfBound(FImmutablePassportResult{ - false, - Response.JsonObject->HasField(TEXT("error")) - ? Response.JsonObject->GetStringField(TEXT("error")) - : "Failed to retrieve Access Token.", - Response - }); - } - else - { - // check for id token - CallJS(ImmutablePassportAction::GetIdToken, TEXT(""), ResponseDelegate, - FImtblJSResponseDelegate::CreateLambda([ResponseDelegate](FImtblJSResponse Response) - { - FString IdToken; - - Response.JsonObject->TryGetStringField(TEXT("result"), IdToken); - if (!Response.success || IdToken.IsEmpty()) - { - ResponseDelegate.ExecuteIfBound(FImmutablePassportResult{ - false, - Response.JsonObject->HasField(TEXT("error")) - ? Response.JsonObject->GetStringField(TEXT("error")) - : "Failed to retrieve Id Token.", - Response - }); - } - else - { - ResponseDelegate.ExecuteIfBound(FImmutablePassportResult{ - Response.success, "", Response - }); - } - })); - } - })); + CallJS(ImmutablePassportAction::GetAccessToken, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateLambda([=](FImtblJSResponse Response) + { + FString AccessToken; + + Response.JsonObject->TryGetStringField(TEXT("result"), AccessToken); + if (!Response.success || AccessToken.IsEmpty()) + { + ResponseDelegate.ExecuteIfBound(FImmutablePassportResult{false, Response.JsonObject->HasField(TEXT("error")) ? Response.JsonObject->GetStringField(TEXT("error")) : "Failed to retrieve Access Token.", Response}); + } + else + { + // check for id token + CallJS(ImmutablePassportAction::GetIdToken, TEXT(""), ResponseDelegate, FImtblJSResponseDelegate::CreateLambda([ResponseDelegate](FImtblJSResponse Response) + { + FString IdToken; + + Response.JsonObject->TryGetStringField(TEXT("result"), IdToken); + if (!Response.success || IdToken.IsEmpty()) + { + ResponseDelegate.ExecuteIfBound(FImmutablePassportResult{false, Response.JsonObject->HasField(TEXT("error")) ? Response.JsonObject->GetStringField(TEXT("error")) : "Failed to retrieve Id Token.", Response}); + } + else + { + ResponseDelegate.ExecuteIfBound(FImmutablePassportResult{Response.success, "", Response}); + } + })); + } + })); } void UImmutablePassport::Setup(const TWeakObjectPtr Connector) @@ -363,7 +320,7 @@ void UImmutablePassport::ReinstateConnection(FImtblJSResponse Response) if (Response.JsonObject->GetBoolField(TEXT("result"))) { SetStateFlags(IPS_CONNECTED); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ true, "", Response }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{true, "", Response}); } else { @@ -372,14 +329,12 @@ void UImmutablePassport::ReinstateConnection(FImtblJSResponse Response) { SetStateFlags(IPS_PKCE); PKCEResponseDelegate = ResponseDelegate.GetValue(); - CallJS(ImmutablePassportAction::GetPKCEAuthUrl, TEXT(""), PKCEResponseDelegate, - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetPKCEAuthUrlResponse)); + CallJS(ImmutablePassportAction::GetPKCEAuthUrl, TEXT(""), PKCEResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnGetPKCEAuthUrlResponse)); } else #endif { - CallJS(ImmutablePassportAction::INIT_DEVICE_FLOW, TEXT(""), ResponseDelegate.GetValue(), - FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitDeviceFlowResponse)); + CallJS(ImmutablePassportAction::INIT_DEVICE_FLOW, TEXT(""), ResponseDelegate.GetValue(), FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnInitDeviceFlowResponse)); } } } @@ -388,20 +343,17 @@ void UImmutablePassport::ReinstateConnection(FImtblJSResponse Response) bool UImmutablePassport::CheckIsInitialized(const FString& Action, const FImtblPassportResponseDelegate& ResponseDelegate) const { const bool IsInitialized = IsStateFlagsSet(IPS_INITIALIZED); - + if (!IsInitialized) { IMTBL_WARN("Attempting action '%s' before Passport is initialized", *Action) ResponseDelegate.ExecuteIfBound(FImmutablePassportResult{false, "Passport is not initialized"}); } - + return IsInitialized; } -void UImmutablePassport::CallJS(const FString& Action, const FString& Data, - const FImtblPassportResponseDelegate& ClientResponseDelegate, - const FImtblJSResponseDelegate& HandleJSResponse, - const bool bCheckInitialized /*= true*/) +void UImmutablePassport::CallJS(const FString& Action, const FString& Data, const FImtblPassportResponseDelegate& ClientResponseDelegate, const FImtblJSResponseDelegate& HandleJSResponse, const bool bCheckInitialized /*= true*/) { if (bCheckInitialized && !CheckIsInitialized(Action, ClientResponseDelegate)) { return; } @@ -410,8 +362,7 @@ void UImmutablePassport::CallJS(const FString& Action, const FString& Data, ResponseDelegates.Add(Guid, ClientResponseDelegate); } -TOptional UImmutablePassport::GetResponseDelegate( - const FImtblJSResponse& Response) +TOptional UImmutablePassport::GetResponseDelegate(const FImtblJSResponse& Response) { FImtblPassportResponseDelegate ResponseDelegate; if (!ResponseDelegates.RemoveAndCopyValue(Response.requestId, ResponseDelegate)) @@ -437,12 +388,10 @@ void UImmutablePassport::OnInitializeResponse(FImtblJSResponse Response) else { IMTBL_ERR("Passport initialization failed.") - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); } - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ Response.success, Msg, Response }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{Response.success, Msg, Response}); } } @@ -455,11 +404,11 @@ void UImmutablePassport::OnInitDeviceFlowResponse(FImtblJSResponse Response) if (!Response.success || !InitDeviceFlowData || !InitDeviceFlowData->code.Len()) { FString Msg; - + IMTBL_WARN("Login device flow initialization attempt failed."); Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ false, Msg, Response }); - + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{false, Msg, Response}); + return; } FString Err; @@ -468,9 +417,9 @@ void UImmutablePassport::OnInitDeviceFlowResponse(FImtblJSResponse Response) if (Err.Len()) { FString Msg = "Failed to connect to Browser: " + Err; - + IMTBL_ERR("%s", *Msg); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ false, Msg, Response }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{false, Msg, Response}); return; } ConfirmCode(InitDeviceFlowData->deviceCode, InitDeviceFlowData->interval, ResponseDelegate.GetValue()); @@ -485,7 +434,7 @@ void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response) { FString Url; FString Err; - + Response.JsonObject->TryGetStringField(TEXT("result"), Url); if (!Url.IsEmpty()) { @@ -509,18 +458,18 @@ void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response) { FString Msg = "Failed to connect to Browser: " + Err; IMTBL_ERR("%s", *Msg); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ false, Msg, Response }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{false, Msg, Response}); return; } IMTBL_LOG("Logged out.") - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ Response.success, "Logged out" }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{Response.success, "Logged out"}); #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC } #endif } else { - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ false, "Logout Url is empty", Response }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{false, "Logout Url is empty", Response}); } ResetStateFlags(IPS_CONNECTED); } @@ -528,7 +477,7 @@ void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response) { FString Msg = Response.Error.IsSet() ? Response.Error->ToString() : Response.JsonObject->GetStringField(TEXT("error")); - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ Response.success, Msg, Response }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{Response.success, Msg, Response}); IMTBL_ERR("Error logging out.") } @@ -551,7 +500,7 @@ void UImmutablePassport::OnConnectSilentResponse(FImtblJSResponse Response) Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); } - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ Response.success, Msg, Response }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{Response.success, Msg, Response}); } } @@ -567,9 +516,7 @@ void UImmutablePassport::OnConnectEvmResponse(FImtblJSResponse Response) else { IMTBL_WARN("Error connecting to Evm.") - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); } ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{Response.success, Msg}); } @@ -582,7 +529,7 @@ void UImmutablePassport::OnGetPKCEAuthUrlResponse(FImtblJSResponse Response) { FString Msg; bool bSuccess = true; - + if (!Response.success || !Response.JsonObject->HasTypedField(TEXT("result"))) { IMTBL_LOG("Could not get PKCE auth URL from Passport."); @@ -654,9 +601,7 @@ void UImmutablePassport::OnGetIdTokenResponse(FImtblJSResponse Response) { IMTBL_LOG("Failed to retrieve Id Token."); - const FString Msg = Response.JsonObject->HasField(TEXT("error")) - ? Response.JsonObject->GetStringField(TEXT("error")) - : "Failed to retrieve Id Token."; + const FString Msg = Response.JsonObject->HasField(TEXT("error")) ? Response.JsonObject->GetStringField(TEXT("error")) : "Failed to retrieve Id Token."; ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{false, Msg, Response}); } @@ -680,9 +625,7 @@ void UImmutablePassport::OnGetAccessTokenResponse(FImtblJSResponse Response) { IMTBL_LOG("Failed to retrieve Access Token"); - const FString Msg = Response.JsonObject->HasField(TEXT("error")) - ? Response.JsonObject->GetStringField(TEXT("error")) - : "Failed to retrieve Access Token."; + const FString Msg = Response.JsonObject->HasField(TEXT("error")) ? Response.JsonObject->GetStringField(TEXT("error")) : "Failed to retrieve Access Token."; ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{false, Msg, Response}); } @@ -700,13 +643,11 @@ void UImmutablePassport::OnGetAddressResponse(FImtblJSResponse Response) { FString Msg; bool bSuccess = true; - + if (!Response.success || !Response.JsonObject->HasTypedField(TEXT("result"))) { IMTBL_WARN("Could not fetch address from Passport."); - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); bSuccess = false; } else @@ -721,16 +662,13 @@ void UImmutablePassport::OnZkEvmRequestAccountsResponse(FImtblJSResponse Respons { if (auto ResponseDelegate = GetResponseDelegate(Response)) { - const auto RequestAccountstData = FImmutablePassportZkEvmRequestAccountsData::FromJsonObject( - Response.JsonObject); + const auto RequestAccountstData = FImmutablePassportZkEvmRequestAccountsData::FromJsonObject(Response.JsonObject); FString Msg; bool bSuccess = true; if (!Response.success || !Response.JsonObject->HasTypedField(TEXT("accounts"))) { IMTBL_WARN("Error requesting zkevm accounts.") - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); bSuccess = false; } else @@ -758,9 +696,7 @@ void UImmutablePassport::OnZkEvmGetBalanceResponse(FImtblJSResponse Response) if (!Response.success || !Response.JsonObject->HasTypedField(TEXT("result"))) { IMTBL_WARN("Could not get balance."); - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); bSuccess = false; } else @@ -780,9 +716,7 @@ void UImmutablePassport::OnZkEvmSendTransactionResponse(FImtblJSResponse Respons if (!Response.success || !Response.JsonObject->HasTypedField(TEXT("result"))) { IMTBL_WARN("Could not fetch send transaction."); - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); bSuccess = false; } else @@ -811,7 +745,7 @@ void UImmutablePassport::OnConfirmCodeResponse(FImtblJSResponse Response) IMTBL_LOG("%s code not confirmed.", *TypeOfConnection) Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); } - ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{ Response.success, Msg, Response }); + ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{Response.success, Msg, Response}); } } @@ -821,13 +755,11 @@ void UImmutablePassport::OnGetEmailResponse(FImtblJSResponse Response) { FString Msg; bool bSuccess = true; - + if (!Response.success || !Response.JsonObject->HasTypedField(TEXT("result"))) { IMTBL_WARN("Connect attempt failed."); - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); bSuccess = false; } else @@ -847,9 +779,7 @@ void UImmutablePassport::OnTransferResponse(FImtblJSResponse Response) if (!Response.success) { IMTBL_WARN("ImxTransfer failed."); - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); bSuccess = false; } else @@ -871,9 +801,7 @@ void UImmutablePassport::OnBatchNftTransferResponse(FImtblJSResponse Response) if (!Response.success || !Response.JsonObject->HasTypedField(TEXT("result"))) { IMTBL_WARN("ImxBatchNftTransfer failed."); - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); bSuccess = false; } else @@ -894,9 +822,7 @@ void UImmutablePassport::OnImxIsRegisteredOffchain(FImtblJSResponse Response) if (!Response.success) { IMTBL_WARN("ImxIsRegisteredOffchain failed."); - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); } else { @@ -915,9 +841,7 @@ void UImmutablePassport::OnImxRegisterOffchain(FImtblJSResponse Response) if (!Response.success) { IMTBL_WARN("ImxRegisterOffchain failed."); - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); } ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{Response.success, Msg, Response}); @@ -933,9 +857,7 @@ void UImmutablePassport::LogAndIgnoreResponse(FImtblJSResponse Response) else { FString Msg; - Response.Error.IsSet() - ? Msg = Response.Error->ToString() - : Msg = Response.JsonObject->GetStringField(TEXT("error")); + Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error")); IMTBL_WARN("Received error response from Passport for action %s -- %s", *Response.responseFor, *Msg); } } @@ -959,15 +881,15 @@ void UImmutablePassport::SavePassportSettings() { UImmutableSaveGame* SaveGameInstance = Cast(UGameplayStatics::CreateSaveGameObject(UImmutableSaveGame::StaticClass())); - SaveGameInstance->bWasConnectedViaPKCEFlow = IsStateFlagsSet(IPS_PKCE|IPS_CONNECTED); - + SaveGameInstance->bWasConnectedViaPKCEFlow = IsStateFlagsSet(IPS_PKCE | IPS_CONNECTED); + UGameplayStatics::SaveGameToSlot(SaveGameInstance, PASSPORT_SAVE_GAME_SLOT_NAME, 0); } void UImmutablePassport::LoadPassportSettings() { UImmutableSaveGame* SaveGameInstance = Cast(UGameplayStatics::CreateSaveGameObject(UImmutableSaveGame::StaticClass())); - + SaveGameInstance = Cast(UGameplayStatics::LoadGameFromSlot(PASSPORT_SAVE_GAME_SLOT_NAME, 0)); if (!SaveGameInstance) @@ -986,14 +908,14 @@ void UImmutablePassport::OnDeepLinkActivated(FString DeepLink) OnHandleDeepLink = nullptr; if (DeepLink.StartsWith(InitData.logoutRedirectUri)) { - // execute on game thread to prevent call to Passport instance from another thread + // execute on game thread to prevent call to Passport instance from another thread if (FTaskGraphInterface::IsRunning()) { FGraphEventRef GameThreadTask = FFunctionGraphTask::CreateAndDispatchWhenReady([this]() { - PKCELogoutResponseDelegate.ExecuteIfBound(FImmutablePassportResult{ true, "Logged out" }); + PKCELogoutResponseDelegate.ExecuteIfBound(FImmutablePassportResult{true, "Logged out"}); PKCELogoutResponseDelegate = nullptr; - ResetStateFlags(IPS_CONNECTED|IPS_PKCE|IPS_IMX); + ResetStateFlags(IPS_CONNECTED | IPS_PKCE | IPS_IMX); SavePassportSettings(); }, TStatId(), nullptr, ENamedThreads::GameThread); } @@ -1036,19 +958,19 @@ void UImmutablePassport::CompleteLoginPKCEFlow(FString Url) if (!Code.IsSet() || !State.IsSet()) { const FString ErrorMsg = "Uri was missing state and/or code. Please call ConnectPKCE() again"; - + IMTBL_ERR("%s", *ErrorMsg); PKCEResponseDelegate.ExecuteIfBound(FImmutablePassportResult{false, ErrorMsg}); PKCEResponseDelegate = nullptr; - ResetStateFlags(IPS_PKCE|IPS_CONNECTING|IPS_COMPLETING_PKCE); + ResetStateFlags(IPS_PKCE | IPS_CONNECTING | IPS_COMPLETING_PKCE); SavePassportSettings(); } else { FImmutablePassportConnectPKCEData Data = FImmutablePassportConnectPKCEData{Code.GetValue(), State.GetValue()}; - CallJS(IsStateFlagsSet(IPS_IMX)? ImmutablePassportAction::CONNECT_PKCE : ImmutablePassportAction::LOGIN_PKCE, - UStructToJsonString(Data), PKCEResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnConnectPKCEResponse)); + CallJS(IsStateFlagsSet(IPS_IMX) ? ImmutablePassportAction::CONNECT_PKCE : ImmutablePassportAction::LOGIN_PKCE, UStructToJsonString(Data), PKCEResponseDelegate, + FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnConnectPKCEResponse)); } } @@ -1061,7 +983,7 @@ void UImmutablePassport::HandleDeepLink(FString DeepLink) const { #elif PLATFORM_IOS | PLATFORM_MAC // Called from iOS Objective C -void UImmutablePassport::HandleDeepLink(NSString *sDeepLink) const +void UImmutablePassport::HandleDeepLink(NSString* sDeepLink) const { FString DeepLink = FString(UTF8_TO_TCHAR([sDeepLink UTF8String])); IMTBL_LOG("Handle Deep Link: %s", *DeepLink); diff --git a/Source/Immutable/Private/Immutable/ImmutableSaveGame.cpp b/Source/Immutable/Private/Immutable/ImmutableSaveGame.cpp index c2eceb0..9d8bdf5 100644 --- a/Source/Immutable/Private/Immutable/ImmutableSaveGame.cpp +++ b/Source/Immutable/Private/Immutable/ImmutableSaveGame.cpp @@ -4,4 +4,4 @@ UImmutableSaveGame::UImmutableSaveGame(const FObjectInitializer& ObjectInitializer) { bWasConnectedViaPKCEFlow = false; -} \ No newline at end of file +} diff --git a/Source/Immutable/Private/Immutable/ImmutableSubsystem.cpp b/Source/Immutable/Private/Immutable/ImmutableSubsystem.cpp index 89db674..43b1097 100644 --- a/Source/Immutable/Private/Immutable/ImmutableSubsystem.cpp +++ b/Source/Immutable/Private/Immutable/ImmutableSubsystem.cpp @@ -11,9 +11,10 @@ UImmutableSubsystem::UImmutableSubsystem() { IMTBL_LOG_FUNCSIG } -void UImmutableSubsystem::Initialize(FSubsystemCollectionBase &Collection) { - IMTBL_LOG_FUNCSIG - Super::Initialize(Collection); +void UImmutableSubsystem::Initialize(FSubsystemCollectionBase& Collection) +{ + IMTBL_LOG_FUNCSIG + Super::Initialize(Collection); #if PLATFORM_ANDROID // Enable DOM storage so we can use localStorage in the Android webview @@ -27,11 +28,9 @@ void UImmutableSubsystem::Initialize(FSubsystemCollectionBase &Collection) { FCoreDelegates::OnFEngineLoopInitComplete.AddUObject( this, &UImmutableSubsystem::OnViewportCreated); #else - ViewportCreatedHandle = UGameViewportClient::OnViewportCreated().AddUObject( - this, &UImmutableSubsystem::OnViewportCreated); + ViewportCreatedHandle = UGameViewportClient::OnViewportCreated().AddUObject(this, &UImmutableSubsystem::OnViewportCreated); #endif - WorldTickHandle = FWorldDelegates::OnWorldTickStart.AddUObject( - this, &UImmutableSubsystem::WorldTickStart); + WorldTickHandle = FWorldDelegates::OnWorldTickStart.AddUObject(this, &UImmutableSubsystem::WorldTickStart); } void UImmutableSubsystem::Deinitialize() @@ -47,11 +46,11 @@ void UImmutableSubsystem::Deinitialize() #if PLATFORM_ANDROID | PLATFORM_IOS UGameViewportClient::OnViewportCreated().Remove(EngineInitCompleteHandle); #else - UGameViewportClient::OnViewportCreated().Remove(ViewportCreatedHandle); + UGameViewportClient::OnViewportCreated().Remove(ViewportCreatedHandle); #endif - FWorldDelegates::OnWorldTickStart.Remove(WorldTickHandle); + FWorldDelegates::OnWorldTickStart.Remove(WorldTickHandle); - Super::Deinitialize(); + Super::Deinitialize(); } template @@ -61,32 +60,38 @@ void UImmutableSubsystem::WhenReady(UserClass* Object, typename FImmutableSubsys void UImmutableSubsystem::WhenReady(UserClass* Object, typename FImmutableSubsystemReadyDelegate::FDelegate::TUObjectMethodDelegate::FMethodPtr Func) #endif { - OnReady.AddUObject(Object, Func); + OnReady.AddUObject(Object, Func); } -void UImmutableSubsystem::OnBridgeReady() { - // When the bridge is ready our subsystem is ready to be used by game code. - // Set the bIsReady flag and broadcast the OnReady event for any waiting - // delegates. - bIsReady = true; - ManageBridgeDelegateQueue(); +void UImmutableSubsystem::OnBridgeReady() +{ + // When the bridge is ready our subsystem is ready to be used by game code. + // Set the bIsReady flag and broadcast the OnReady event for any waiting + // delegates. + bIsReady = true; + ManageBridgeDelegateQueue(); } -void UImmutableSubsystem::ManageBridgeDelegateQueue() { - if (bIsReady) { +void UImmutableSubsystem::ManageBridgeDelegateQueue() +{ + if (bIsReady) + { #if USING_BLUI_CEF OnReady.Broadcast(ImtblBlui->GetJSConnector()); #else - OnReady.Broadcast(BrowserWidget->GetJSConnector()); + OnReady.Broadcast(BrowserWidget->GetJSConnector()); #endif - OnReady.Clear(); - } + OnReady.Clear(); + } } -void UImmutableSubsystem::SetupGameBridge() { - if (bHasSetupGameBridge) - return; - bHasSetupGameBridge = true; +void UImmutableSubsystem::SetupGameBridge() +{ + if (bHasSetupGameBridge) + { + return; + } + bHasSetupGameBridge = true; #if USING_BLUI_CEF // Create the Blui @@ -119,46 +124,52 @@ void UImmutableSubsystem::SetupGameBridge() { } #else - // Create the browser widget - if (!BrowserWidget) { - BrowserWidget = CreateWidget(GetWorld()); - } - if (!BrowserWidget) { - IMTBL_ERR("Failed to create up BrowserWidget") - return; - } - // Launch browser - if (!BrowserWidget->IsInViewport()) { - IMTBL_LOG("Adding BrowserWidget to viewport") - BrowserWidget->AddToViewport(); - } - if (!BrowserWidget->GetJSConnector().IsValid()) { - IMTBL_ERR( - "JSConnector not available, can't set up subsystem-ready event chain") - return; - } - // Set up ready event chain - if (!IsReady()) { - BrowserWidget->GetJSConnector()->AddCallbackWhenBridgeReady( - UImtblJSConnector::FOnBridgeReadyDelegate::FDelegate::CreateUObject( - this, &UImmutableSubsystem::OnBridgeReady)); - } - - // Prepare Passport - if (!Passport) { - Passport = NewObject(this); - if (Passport) - Passport->Setup(BrowserWidget->GetJSConnector()); - } + // Create the browser widget + if (!BrowserWidget) + { + BrowserWidget = CreateWidget(GetWorld()); + } + if (!BrowserWidget) + { + IMTBL_ERR("Failed to create up BrowserWidget") + return; + } + // Launch browser + if (!BrowserWidget->IsInViewport()) + { + IMTBL_LOG("Adding BrowserWidget to viewport") + BrowserWidget->AddToViewport(); + } + if (!BrowserWidget->GetJSConnector().IsValid()) + { + IMTBL_ERR("JSConnector not available, can't set up subsystem-ready event chain") + return; + } + // Set up ready event chain + if (!IsReady()) + { + BrowserWidget->GetJSConnector()->AddCallbackWhenBridgeReady(UImtblJSConnector::FOnBridgeReadyDelegate::FDelegate::CreateUObject(this, &UImmutableSubsystem::OnBridgeReady)); + } + + // Prepare Passport + if (!Passport) + { + Passport = NewObject(this); + if (Passport) + { + Passport->Setup(BrowserWidget->GetJSConnector()); + } + } #endif } -void UImmutableSubsystem::OnViewportCreated() { - IMTBL_LOG_FUNCSIG - SetupGameBridge(); +void UImmutableSubsystem::OnViewportCreated() +{ + IMTBL_LOG_FUNCSIG + SetupGameBridge(); } -void UImmutableSubsystem::WorldTickStart(UWorld *World, ELevelTick TickType, - float DeltaSeconds) { - ManageBridgeDelegateQueue(); +void UImmutableSubsystem::WorldTickStart(UWorld* World, ELevelTick TickType, float DeltaSeconds) +{ + ManageBridgeDelegateQueue(); } diff --git a/Source/Immutable/Private/Immutable/ImtblBlui.cpp b/Source/Immutable/Private/Immutable/ImtblBlui.cpp index b479428..cd6ceb6 100644 --- a/Source/Immutable/Private/Immutable/ImtblBlui.cpp +++ b/Source/Immutable/Private/Immutable/ImtblBlui.cpp @@ -10,8 +10,9 @@ #include "BluEye.h" #endif -UImtblBlui::UImtblBlui() { - IMTBL_LOG_FUNCSIG +UImtblBlui::UImtblBlui() +{ + IMTBL_LOG_FUNCSIG #if USING_BLUI_CEF if (!BluEyePtr) { IMTBL_LOG("Creating BluEye") @@ -19,21 +20,21 @@ UImtblBlui::UImtblBlui() { } #endif - JSConnector = NewObject(this, "JSConnector"); - JSConnector->ExecuteJs = - UImtblJSConnector::FOnExecuteJsDelegate::CreateUObject( - this, &UImtblBlui::ExecuteJS); + JSConnector = NewObject(this, "JSConnector"); + JSConnector->ExecuteJs = UImtblJSConnector::FOnExecuteJsDelegate::CreateUObject(this, &UImtblBlui::ExecuteJS); } #if USING_BLUI_CEF UBluEye *UImtblBlui::GetBluEye() const { return Cast(BluEyePtr); } #endif -void UImtblBlui::OnLogEvent(const FString &LogText) { - IMTBL_LOG_FUNC("LogEvent: %s", *LogText); +void UImtblBlui::OnLogEvent(const FString& LogText) +{ + IMTBL_LOG_FUNC("LogEvent: %s", *LogText); } -void UImtblBlui::WorldTickStart(UWorld *World, ELevelTick LevelTick, float X) { +void UImtblBlui::WorldTickStart(UWorld* World, ELevelTick LevelTick, float X) +{ #if USING_BLUI_CEF if (GetBluEye()->IsBrowserLoading()) { IMTBL_LOG("Waiting for Browser to load..."); @@ -56,28 +57,31 @@ void UImtblBlui::WorldTickStart(UWorld *World, ELevelTick LevelTick, float X) { #endif } -void UImtblBlui::BeginDestroy() { - IMTBL_LOG_FUNCSIG +void UImtblBlui::BeginDestroy() +{ + IMTBL_LOG_FUNCSIG #if USING_BLUI_CEF if (GetBluEye()) { GetBluEye()->CloseBrowser(); } BluEyePtr = nullptr; #endif - Super::BeginDestroy(); + Super::BeginDestroy(); } -void UImtblBlui::OnScriptEvent(const FString &EventName, - const FString &EventMessage) { - IMTBL_LOG_FUNC("EventName: %s, EventMessage: %s", *EventName, *EventMessage); - JSConnector->SendToGame(EventMessage); +void UImtblBlui::OnScriptEvent(const FString& EventName, const FString& EventMessage) +{ + IMTBL_LOG_FUNC("EventName: %s, EventMessage: %s", *EventName, *EventMessage); + JSConnector->SendToGame(EventMessage); } -TWeakObjectPtr UImtblBlui::GetJSConnector() const { - return JSConnector; +TWeakObjectPtr UImtblBlui::GetJSConnector() const +{ + return JSConnector; } -void UImtblBlui::ExecuteJS(const FString &ScriptText) const { +void UImtblBlui::ExecuteJS(const FString& ScriptText) const +{ #if USING_BLUI_CEF if (GetBluEye()) { GetBluEye()->ExecuteJS(ScriptText); @@ -85,8 +89,9 @@ void UImtblBlui::ExecuteJS(const FString &ScriptText) const { #endif } -void UImtblBlui::Init() { - IMTBL_LOG_FUNCSIG +void UImtblBlui::Init() +{ + IMTBL_LOG_FUNCSIG #if USING_BLUI_CEF // Todo: Add comment here why GetBluEye diff --git a/Source/Immutable/Private/Immutable/ImtblBlui.h b/Source/Immutable/Private/Immutable/ImtblBlui.h index 47a1ee6..cb68b00 100644 --- a/Source/Immutable/Private/Immutable/ImtblBlui.h +++ b/Source/Immutable/Private/Immutable/ImtblBlui.h @@ -12,38 +12,39 @@ * */ UCLASS() -class IMMUTABLE_API UImtblBlui : public UObject { - GENERATED_BODY() +class IMMUTABLE_API UImtblBlui : public UObject +{ + GENERATED_BODY() public: - UImtblBlui(); + UImtblBlui(); - UFUNCTION() - void OnScriptEvent(const FString &EventName, const FString &EventMessage); - TWeakObjectPtr GetJSConnector() const; + UFUNCTION() + void OnScriptEvent(const FString& EventName, const FString& EventMessage); + TWeakObjectPtr GetJSConnector() const; - UFUNCTION() - void OnLogEvent(const FString &LogText); + UFUNCTION() + void OnLogEvent(const FString& LogText); - void BeginDestroy() override; - void Init(); + virtual void BeginDestroy() override; + void Init(); #if USING_BLUI_CEF void StopBluiEventLoop(); #endif private: - UPROPERTY() - UObject *BluEyePtr = nullptr; + UPROPERTY() + UObject* BluEyePtr = nullptr; - bool bLoadedIndexJS = false; - void WorldTickStart(UWorld *World, ELevelTick LevelTick, float X); + bool bLoadedIndexJS = false; + void WorldTickStart(UWorld* World, ELevelTick LevelTick, float X); - UPROPERTY() - class UImtblJSConnector *JSConnector = nullptr; - FDelegateHandle WorldTickHandle; + UPROPERTY() + class UImtblJSConnector* JSConnector = nullptr; + FDelegateHandle WorldTickHandle; - void ExecuteJS(const FString &ScriptText) const; + void ExecuteJS(const FString& ScriptText) const; #if USING_BLUI_CEF class UBluEye *GetBluEye() const; diff --git a/Source/Immutable/Private/Immutable/ImtblBrowserUserWidget.cpp b/Source/Immutable/Private/Immutable/ImtblBrowserUserWidget.cpp index 150b6c0..16cc8ef 100644 --- a/Source/Immutable/Private/Immutable/ImtblBrowserUserWidget.cpp +++ b/Source/Immutable/Private/Immutable/ImtblBrowserUserWidget.cpp @@ -12,80 +12,86 @@ #include "ImtblBrowserWidget.h" #include "ImtblJSConnector.h" -TSharedRef UImtblBrowserUserWidget::RebuildWidget() { - // RebuildWidget is not called until the widget is first added to the - // viewport. +TSharedRef UImtblBrowserUserWidget::RebuildWidget() +{ + // RebuildWidget is not called until the widget is first added to the + // viewport. - UPanelWidget *RootWidget = Cast(GetRootWidget()); + UPanelWidget* RootWidget = Cast(GetRootWidget()); - if (!RootWidget) { - RootWidget = WidgetTree->ConstructWidget( - UCanvasPanel::StaticClass(), TEXT("RootWidget")); - if (UCanvasPanelSlot *RootWidgetSlot = - Cast(RootWidget->Slot)) { - // Format root widget - } - WidgetTree->RootWidget = RootWidget; - } + if (!RootWidget) + { + RootWidget = WidgetTree->ConstructWidget(UCanvasPanel::StaticClass(), TEXT("RootWidget")); + if (UCanvasPanelSlot* RootWidgetSlot = Cast(RootWidget->Slot)) + { + // Format root widget + } + WidgetTree->RootWidget = RootWidget; + } - if (RootWidget) { - UScaleBox *ScaleBox = WidgetTree->ConstructWidget( - UScaleBox::StaticClass(), TEXT("ScaleBox")); - RootWidget->AddChild(ScaleBox); - if (ScaleBox) { - Browser = WidgetTree->ConstructWidget( - UImtblBrowserWidget::StaticClass(), TEXT("ImmutableBrowserWidget")); - ScaleBox->AddChild(Browser); - if (UCanvasPanelSlot *RootWidgetSlot = - Cast(ScaleBox->Slot)) { + if (RootWidget) + { + UScaleBox* ScaleBox = WidgetTree->ConstructWidget(UScaleBox::StaticClass(), TEXT("ScaleBox")); + RootWidget->AddChild(ScaleBox); + if (ScaleBox) + { + Browser = WidgetTree->ConstructWidget(UImtblBrowserWidget::StaticClass(), TEXT("ImmutableBrowserWidget")); + ScaleBox->AddChild(Browser); + if (UCanvasPanelSlot* RootWidgetSlot = Cast(ScaleBox->Slot)) + { #if PLATFORM_ANDROID | PLATFORM_IOS // Android webview needs to be at least 1px to 1px big to work // but it can be off screen RootWidgetSlot->SetAnchors(FAnchors(0, 0, 0, 0)); RootWidgetSlot->SetOffsets(FMargin(-1, -1, 1, 1)); #else - RootWidgetSlot->SetAnchors(FAnchors(0, 0, 1, 1)); - RootWidgetSlot->SetOffsets(DefaultOffsets); + RootWidgetSlot->SetAnchors(FAnchors(0, 0, 1, 1)); + RootWidgetSlot->SetOffsets(DefaultOffsets); #endif - } - if (UScaleBoxSlot *ScaleBoxSlot = Cast(Browser->Slot)) { - ScaleBoxSlot->SetHorizontalAlignment(HAlign_Fill); - ScaleBoxSlot->SetVerticalAlignment(VAlign_Fill); - } - } - } + } + if (UScaleBoxSlot* ScaleBoxSlot = Cast(Browser->Slot)) + { + ScaleBoxSlot->SetHorizontalAlignment(HAlign_Fill); + ScaleBoxSlot->SetVerticalAlignment(VAlign_Fill); + } + } + } - return Super::RebuildWidget(); + return Super::RebuildWidget(); } void UImtblBrowserUserWidget::BeginDestroy() { Super::BeginDestroy(); } -void UImtblBrowserUserWidget::RemoveFromParent() { +void UImtblBrowserUserWidget::RemoveFromParent() +{ #if !PLATFORM_ANDROID - // This is all that is needed to persist the widget state outside throughout - // level/world changes. Super::RemoveFromParent(); + // This is all that is needed to persist the widget state outside throughout + // level/world changes. Super::RemoveFromParent(); - if (UPanelWidget *CurrentParent = GetParent()) { - CurrentParent->RemoveChild(this); - } + if (UPanelWidget* CurrentParent = GetParent()) + { + CurrentParent->RemoveChild(this); + } #endif } -void UImtblBrowserUserWidget::OnWidgetRebuilt() { +void UImtblBrowserUserWidget::OnWidgetRebuilt() +{ #if PLATFORM_ANDROID | PLATFORM_IOS - // Mobile webview needs to be visible to work + // Mobile webview needs to be visible to work #else - SetVisibility(ESlateVisibility::Collapsed); + SetVisibility(ESlateVisibility::Collapsed); #endif - Super::OnWidgetRebuilt(); + Super::OnWidgetRebuilt(); } -TWeakObjectPtr -UImtblBrowserUserWidget::GetJSConnector() const { - if (!Browser) { - IMTBL_WARN("JSConnector requested before Browser was initialized"); - return nullptr; - } +TWeakObjectPtr UImtblBrowserUserWidget::GetJSConnector() const +{ + if (!Browser) + { + IMTBL_WARN("JSConnector requested before Browser was initialized"); + return nullptr; + } - return Browser->GetJSConnector(); + return Browser->GetJSConnector(); } diff --git a/Source/Immutable/Private/Immutable/ImtblBrowserUserWidget.h b/Source/Immutable/Private/Immutable/ImtblBrowserUserWidget.h index 43e02a2..6857606 100644 --- a/Source/Immutable/Private/Immutable/ImtblBrowserUserWidget.h +++ b/Source/Immutable/Private/Immutable/ImtblBrowserUserWidget.h @@ -7,23 +7,25 @@ #include "ImtblBrowserUserWidget.generated.h" UCLASS() -class IMMUTABLE_API UImtblBrowserUserWidget : public UUserWidget { - GENERATED_BODY() +class IMMUTABLE_API UImtblBrowserUserWidget : public UUserWidget +{ + GENERATED_BODY() + public: - TSharedRef RebuildWidget() override; - void BeginDestroy() override; - void RemoveFromParent() override; - void OnWidgetRebuilt() override; + virtual TSharedRef RebuildWidget() override; + virtual void BeginDestroy() override; + virtual void RemoveFromParent() override; + virtual void OnWidgetRebuilt() override; - TWeakObjectPtr GetJSConnector() const; + TWeakObjectPtr GetJSConnector() const; private: - UPROPERTY() - class UImtblBrowserWidget *Browser = nullptr; + UPROPERTY() + class UImtblBrowserWidget* Browser = nullptr; - bool bIsBrowserAppInitialized = false; + bool bIsBrowserAppInitialized = false; - FTimerHandle Timer; + FTimerHandle Timer; - FMargin DefaultOffsets = FMargin(150, 150, 150, 150); + FMargin DefaultOffsets = FMargin(150, 150, 150, 150); }; diff --git a/Source/Immutable/Private/Immutable/ImtblBrowserWidget.cpp b/Source/Immutable/Private/Immutable/ImtblBrowserWidget.cpp index 7e6bde3..4569913 100644 --- a/Source/Immutable/Private/Immutable/ImtblBrowserWidget.cpp +++ b/Source/Immutable/Private/Immutable/ImtblBrowserWidget.cpp @@ -11,140 +11,138 @@ #include "Immutable/ImmutableSubsystem.h" #include "Interfaces/IPluginManager.h" -UImtblBrowserWidget::UImtblBrowserWidget() { - IMTBL_LOG_FUNCSIG - - JSConnector = NewObject(this, "JSConnector"); - JSConnector->ExecuteJs = - UImtblJSConnector::FOnExecuteJsDelegate::CreateUObject( - this, &UImtblBrowserWidget::ExecuteJS); - - // WebBrowserWidget->LoadString("Test

Test

", - // TEXT("http://www.google.com")); InitialURL = TEXT("http://www.google.com"); - // InitialURL = TEXT("chrome://version"); - // IPluginManager& PluginManager = IPluginManager::Get(); - // if (const TSharedPtr Plugin = - // PluginManager.FindPlugin("Immutable")) - // { - // InitialURL = FString::Printf(TEXT("%s%s"), TEXT("file:///"), - // *FPaths::ConvertRelativePathToFull(FPaths::Combine(Plugin->GetContentDir(), - // TEXT("index.html")))); IMTBL_LOG("Loading initial url: %s", - // *InitialURL) - // } - InitialURL = TEXT("about:blank"); +UImtblBrowserWidget::UImtblBrowserWidget() +{ + IMTBL_LOG_FUNCSIG + + JSConnector = NewObject(this, "JSConnector"); + JSConnector->ExecuteJs = UImtblJSConnector::FOnExecuteJsDelegate::CreateUObject(this, &UImtblBrowserWidget::ExecuteJS); + + // WebBrowserWidget->LoadString("Test

Test

", + // TEXT("http://www.google.com")); InitialURL = TEXT("http://www.google.com"); + // InitialURL = TEXT("chrome://version"); + // IPluginManager& PluginManager = IPluginManager::Get(); + // if (const TSharedPtr Plugin = + // PluginManager.FindPlugin("Immutable")) + // { + // InitialURL = FString::Printf(TEXT("%s%s"), TEXT("file:///"), + // *FPaths::ConvertRelativePathToFull(FPaths::Combine(Plugin->GetContentDir(), + // TEXT("index.html")))); IMTBL_LOG("Loading initial url: %s", + // *InitialURL) + // } + InitialURL = TEXT("about:blank"); } -void UImtblBrowserWidget::BindConnector() { - if (JSConnector && JSConnector->IsBound()) - return; - - IMTBL_LOG("Setting up %s...", *UImtblJSConnector::StaticClass()->GetName()) - - if (JSConnector) { - if (BindUObject(UImtblJSConnector::JSObjectName(), JSConnector)) { - JSConnector->Init(IsPageLoaded()); - } - } +void UImtblBrowserWidget::BindConnector() +{ + if (JSConnector && JSConnector->IsBound()) + { + return; + } + + IMTBL_LOG("Setting up %s...", *UImtblJSConnector::StaticClass()->GetName()) + + if (JSConnector) + { + if (BindUObject(UImtblJSConnector::JSObjectName(), JSConnector)) + { + JSConnector->Init(IsPageLoaded()); + } + } } -TWeakObjectPtr UImtblBrowserWidget::GetJSConnector() const { - return JSConnector; +TWeakObjectPtr UImtblBrowserWidget::GetJSConnector() const +{ + return JSConnector; } -bool UImtblBrowserWidget::IsPageLoaded() const { +bool UImtblBrowserWidget::IsPageLoaded() const +{ #if USING_BUNDLED_CEF - return WebBrowserWidget.IsValid() && WebBrowserWidget->IsLoaded(); + return WebBrowserWidget.IsValid() && WebBrowserWidget->IsLoaded(); #endif - return false; + return false; } -void UImtblBrowserWidget::ExecuteJS(const FString &ScriptText) const { +void UImtblBrowserWidget::ExecuteJS(const FString& ScriptText) const +{ #if USING_BUNDLED_CEF - if (WebBrowserWidget.IsValid()) { - WebBrowserWidget->ExecuteJavascript(ScriptText); - } + if (WebBrowserWidget.IsValid()) + { + WebBrowserWidget->ExecuteJavascript(ScriptText); + } #endif } -void UImtblBrowserWidget::SetBrowserContent() { +void UImtblBrowserWidget::SetBrowserContent() +{ #if USING_BUNDLED_CEF - FSoftObjectPath AssetRef(TEXT("/Script/Immutable.ImtblSDKResource'/Immutable/" - "PackagedResources/index.index'")); - if (UObject *LoadedAsset = AssetRef.TryLoad()) { - if (auto Resource = Cast(LoadedAsset)) { - if (!WebBrowserWidget.IsValid()) { - IMTBL_ERR("no browser") - return; - } - - const FString IndexHtml = - FString("GameSDK Bridge

Bridge Running

"); - - // IMTBL_LOG("Loaded resource: %s", *Resource->GetName()) - WebBrowserWidget->LoadString(IndexHtml, - TEXT("file://immutable/index.html")); - // WebBrowserWidget->LoadURL(FString::Printf(TEXT("%s%s"), - // TEXT("file:///"), - // *FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::ProjectContentDir(), - // TEXT("html"), TEXT("index.html"))))); - } - } + FSoftObjectPath AssetRef(TEXT("/Script/Immutable.ImtblSDKResource'/Immutable/" "PackagedResources/index.index'")); + if (UObject* LoadedAsset = AssetRef.TryLoad()) + { + if (auto Resource = Cast(LoadedAsset)) + { + if (!WebBrowserWidget.IsValid()) + { + IMTBL_ERR("no browser") + return; + } + + const FString IndexHtml = FString("GameSDK Bridge

Bridge Running

"); + + // IMTBL_LOG("Loaded resource: %s", *Resource->GetName()) + WebBrowserWidget->LoadString(IndexHtml, TEXT("file://immutable/index.html")); + // WebBrowserWidget->LoadURL(FString::Printf(TEXT("%s%s"), + // TEXT("file:///"), + // *FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::ProjectContentDir(), + // TEXT("html"), TEXT("index.html"))))); + } + } #endif } -bool UImtblBrowserWidget::BindUObject(const FString &Name, UObject *Object, - const bool bIsPermanent) const { +bool UImtblBrowserWidget::BindUObject(const FString& Name, UObject* Object, const bool bIsPermanent) const +{ #if USING_BUNDLED_CEF - if (!WebBrowserWidget) { - IMTBL_WARN_FUNC( - "Could not bind UObject '%s' to browser, WebBrowserWidget is null", - *Object->GetName()) - return false; - } + if (!WebBrowserWidget) + { + IMTBL_WARN_FUNC("Could not bind UObject '%s' to browser, WebBrowserWidget is null", *Object->GetName()) + return false; + } - WebBrowserWidget->BindUObject(Name, Object, bIsPermanent); + WebBrowserWidget->BindUObject(Name, Object, bIsPermanent); #endif - return true; + return true; } -void UImtblBrowserWidget::ReleaseSlateResources(bool bReleaseChildren) { - Super::ReleaseSlateResources(bReleaseChildren); +void UImtblBrowserWidget::ReleaseSlateResources(bool bReleaseChildren) +{ + Super::ReleaseSlateResources(bReleaseChildren); #if USING_BUNDLED_CEF - WebBrowserWidget.Reset(); + WebBrowserWidget.Reset(); #endif } -TSharedRef UImtblBrowserWidget::RebuildWidget() { - if (IsDesignTime()) { - return SNew(SBox) - .HAlign(HAlign_Center) - .VAlign(VAlign_Center)[SNew(STextBlock) - .Text(NSLOCTEXT("Immutable", - "Immutable Web Browser", - "Immutable Web Browser"))]; - } else { +TSharedRef UImtblBrowserWidget::RebuildWidget() +{ + if (IsDesignTime()) + { + return SNew(SBox).HAlign(HAlign_Center).VAlign(VAlign_Center)[SNew(STextBlock).Text(NSLOCTEXT("Immutable", "Immutable Web Browser", "Immutable Web Browser"))]; + } + else + { #if USING_BUNDLED_CEF - WebBrowserWidget = - SNew(SWebBrowser) - .InitialURL(InitialURL) - .ShowControls(false) - .SupportsTransparency(bSupportsTransparency) - .ShowInitialThrobber(bShowInitialThrobber) + WebBrowserWidget = SNew(SWebBrowser).InitialURL(InitialURL).ShowControls(false).SupportsTransparency(bSupportsTransparency).ShowInitialThrobber(bShowInitialThrobber) #if PLATFORM_ANDROID | PLATFORM_IOS .OnLoadCompleted( BIND_UOBJECT_DELEGATE(FSimpleDelegate, HandleOnLoadCompleted)) #endif #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 - .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, - HandleOnConsoleMessage)) + .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, HandleOnConsoleMessage)) #endif - ; + ; - return WebBrowserWidget.ToSharedRef(); + return WebBrowserWidget.ToSharedRef(); #else return SNew(SBox) .HAlign(HAlign_Center) @@ -153,7 +151,7 @@ TSharedRef UImtblBrowserWidget::RebuildWidget() { "Immutable Web Browser", "Immutable Web Browser"))]; #endif - } + } } #if PLATFORM_ANDROID | PLATFORM_IOS @@ -172,19 +170,18 @@ void UImtblBrowserWidget::HandleOnLoadCompleted() { } #endif -void UImtblBrowserWidget::OnWidgetRebuilt() { - Super::OnWidgetRebuilt(); - BindConnector(); - SetBrowserContent(); +void UImtblBrowserWidget::OnWidgetRebuilt() +{ + Super::OnWidgetRebuilt(); + BindConnector(); + SetBrowserContent(); } #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 -void UImtblBrowserWidget::HandleOnConsoleMessage( - const FString &Message, const FString &Source, int32 Line, - EWebBrowserConsoleLogSeverity Severity) { - // TODO: add severity to log and callback - IMTBL_LOG("Browser console message: %s, Source: %s, Line: %d", *Message, - *Source, Line); - OnConsoleMessage.Broadcast(Message, Source, Line); +void UImtblBrowserWidget::HandleOnConsoleMessage(const FString& Message, const FString& Source, int32 Line, EWebBrowserConsoleLogSeverity Severity) +{ + // TODO: add severity to log and callback + IMTBL_LOG("Browser console message: %s, Source: %s, Line: %d", *Message, *Source, Line); + OnConsoleMessage.Broadcast(Message, Source, Line); } #endif diff --git a/Source/Immutable/Private/Immutable/ImtblBrowserWidget.h b/Source/Immutable/Private/Immutable/ImtblBrowserWidget.h index 10446d1..bc70d4b 100644 --- a/Source/Immutable/Private/Immutable/ImtblBrowserWidget.h +++ b/Source/Immutable/Private/Immutable/ImtblBrowserWidget.h @@ -10,67 +10,63 @@ #include "ImtblBrowserWidget.generated.h" UCLASS() -class IMMUTABLE_API UImtblBrowserWidget : public UWidget { - GENERATED_BODY() +class IMMUTABLE_API UImtblBrowserWidget : public UWidget +{ + GENERATED_BODY() - friend class UImtblJSConnector; + friend class UImtblJSConnector; public: - // Sets default values for this actor's properties - UImtblBrowserWidget(); + // Sets default values for this actor's properties + UImtblBrowserWidget(); - // Get a pointer to the JSConnector - TWeakObjectPtr GetJSConnector() const; + // Get a pointer to the JSConnector + TWeakObjectPtr GetJSConnector() const; - bool IsPageLoaded() const; + bool IsPageLoaded() const; protected: - void ExecuteJS(const FString &ScriptText) const; + void ExecuteJS(const FString& ScriptText) const; private: - DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnConsoleMessage, - const FString &, Message, - const FString &, Source, int32, - Line); - FOnConsoleMessage OnConsoleMessage; + DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnConsoleMessage, const FString &, Message, const FString &, Source, int32, Line); + + FOnConsoleMessage OnConsoleMessage; #if USING_BUNDLED_CEF - TSharedPtr WebBrowserWidget; + TSharedPtr WebBrowserWidget; #endif - /** URL that the browser will initially navigate to. The URL should include - * the protocol, eg http:// */ - FString InitialURL; - /** Should the browser window support transparency. */ - bool bSupportsTransparency = true; - bool bShowInitialThrobber = false; + /** URL that the browser will initially navigate to. The URL should include + * the protocol, eg http:// */ + FString InitialURL; + /** Should the browser window support transparency. */ + bool bSupportsTransparency = true; + bool bShowInitialThrobber = false; - UPROPERTY() - class UImtblJSConnector *JSConnector = nullptr; + UPROPERTY() + class UImtblJSConnector* JSConnector = nullptr; - void SetBrowserContent(); + void SetBrowserContent(); - bool BindUObject(const FString &Name, UObject *Object, - bool bIsPermanent = true) const; - // Bind the JSConnector to the browser window - void BindConnector(); + bool BindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true) const; + // Bind the JSConnector to the browser window + void BindConnector(); #if PLATFORM_ANDROID | PLATFORM_IOS void HandleOnLoadCompleted(); #endif #if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1 - void HandleOnConsoleMessage(const FString &Message, const FString &Source, - int32 Line, - EWebBrowserConsoleLogSeverity Severity); + void HandleOnConsoleMessage(const FString& Message, const FString& Source, int32 Line, EWebBrowserConsoleLogSeverity Severity); #endif - /** - * UWidget interface - */ + /** + * UWidget interface + */ public: - void ReleaseSlateResources(bool bReleaseChildren) override; + virtual void ReleaseSlateResources(bool bReleaseChildren) override; protected: - TSharedRef RebuildWidget() override; - void OnWidgetRebuilt() override; + virtual TSharedRef RebuildWidget() override; + virtual void OnWidgetRebuilt() override; }; diff --git a/Source/Immutable/Private/Immutable/ImtblJSConnector.cpp b/Source/Immutable/Private/Immutable/ImtblJSConnector.cpp index 8ff5ff5..434f3db 100644 --- a/Source/Immutable/Private/Immutable/ImtblJSConnector.cpp +++ b/Source/Immutable/Private/Immutable/ImtblJSConnector.cpp @@ -8,23 +8,24 @@ UImtblJSConnector::UImtblJSConnector() { IMTBL_LOG_FUNCSIG } -void UImtblJSConnector::Init(bool bPageLoaded) { - IMTBL_LOG("JSConnect::Init called, bPageloaded %d", bPageLoaded); - if (bPageLoaded) { - IMTBL_LOG("Browser finished loading the bridge document before the " - "Immutable JSConnector was created & bound") - FImtblJSResponse InitResponse{}; - InitResponse.responseFor = "init"; - InitResponse.requestId = "1"; - InitResponse.success = true; - HandleInitResponse(InitResponse); - } else { - // Add init function to "waiting for response" queue to handle the init - // message - RequestResponseDelegates.Add( - "1", FImtblJSResponseDelegate::CreateUObject( - this, &UImtblJSConnector::HandleInitResponse)); - } +void UImtblJSConnector::Init(bool bPageLoaded) +{ + IMTBL_LOG("JSConnect::Init called, bPageloaded %d", bPageLoaded); + if (bPageLoaded) + { + IMTBL_LOG("Browser finished loading the bridge document before the " "Immutable JSConnector was created & bound") + FImtblJSResponse InitResponse{}; + InitResponse.responseFor = "init"; + InitResponse.requestId = "1"; + InitResponse.success = true; + HandleInitResponse(InitResponse); + } + else + { + // Add init function to "waiting for response" queue to handle the init + // message + RequestResponseDelegates.Add("1", FImtblJSResponseDelegate::CreateUObject(this, &UImtblJSConnector::HandleInitResponse)); + } } void UImtblJSConnector::PostInitProperties() { UObject::PostInitProperties(); } @@ -33,93 +34,94 @@ bool UImtblJSConnector::IsBound() const { return bIsBound; } bool UImtblJSConnector::IsBridgeReady() const { return bIsBridgeReady; } -void UImtblJSConnector::AddCallbackWhenBridgeReady( - const FOnBridgeReadyDelegate::FDelegate &Delegate) { - if (IsBridgeReady()) { - Delegate.Execute(); - } else { - OnBridgeReady.Add(Delegate); - } +void UImtblJSConnector::AddCallbackWhenBridgeReady(const FOnBridgeReadyDelegate::FDelegate& Delegate) +{ + if (IsBridgeReady()) + { + Delegate.Execute(); + } + else + { + OnBridgeReady.Add(Delegate); + } } -FString -UImtblJSConnector::CallJS(const FString &Function, const FString &Data, - const FImtblJSResponseDelegate &HandleResponse, - const float ResponseTimeout) { - const FString Guid = FGuid::NewGuid().ToString(); - CallJS(FImtblJSRequest{Function, Data, Guid}, HandleResponse, - ResponseTimeout); - return Guid; +FString UImtblJSConnector::CallJS(const FString& Function, const FString& Data, const FImtblJSResponseDelegate& HandleResponse, const float ResponseTimeout) +{ + const FString Guid = FGuid::NewGuid().ToString(); + CallJS(FImtblJSRequest{Function, Data, Guid}, HandleResponse, ResponseTimeout); + return Guid; } -void UImtblJSConnector::CallJS(const FImtblJSRequest &Request, - FImtblJSResponseDelegate HandleResponse, - float ResponseTimeout) { - if (!IsBridgeReady()) { - // IMTBL_WARN("Attempt to call Immutable JS bridge before bridge ready") - AddCallbackWhenBridgeReady(FOnBridgeReadyDelegate::FDelegate::CreateLambda( - [Request, HandleResponse, ResponseTimeout, this]() { - CallJS(Request, HandleResponse, ResponseTimeout); - })); - return; - } - - // First, add response callback to map - RequestResponseDelegates.Add(Request.requestId, HandleResponse); - - // Convert the request to a string - FString RequestString = Request.ToJsonString(); - RequestString.ReplaceInline(TEXT("\\"), TEXT("\\\\")); - RequestString.ReplaceInline(TEXT("\""), TEXT("\\\"")); - const FString JS = - FString::Printf(TEXT("callFunction(\"%s\");"), *RequestString); - // const FString JS = FString::Printf(TEXT("callFunction(%s);"), - // *RequestString); - - // Execute - IMTBL_LOG("Executing JS: %s", *JS) - const bool Result = ExecuteJs.ExecuteIfBound(JS); - if (!Result) { - IMTBL_WARN("ExecuteJS delegate was not called"); - } - - // TODO: add timeout callback +void UImtblJSConnector::CallJS(const FImtblJSRequest& Request, FImtblJSResponseDelegate HandleResponse, float ResponseTimeout) +{ + if (!IsBridgeReady()) + { + // IMTBL_WARN("Attempt to call Immutable JS bridge before bridge ready") + AddCallbackWhenBridgeReady(FOnBridgeReadyDelegate::FDelegate::CreateLambda([Request, HandleResponse, ResponseTimeout, this]() + { + CallJS(Request, HandleResponse, ResponseTimeout); + })); + return; + } + + // First, add response callback to map + RequestResponseDelegates.Add(Request.requestId, HandleResponse); + + // Convert the request to a string + FString RequestString = Request.ToJsonString(); + RequestString.ReplaceInline(TEXT("\\"), TEXT("\\\\")); + RequestString.ReplaceInline(TEXT("\""), TEXT("\\\"")); + const FString JS = FString::Printf(TEXT("callFunction(\"%s\");"), *RequestString); + // const FString JS = FString::Printf(TEXT("callFunction(%s);"), + // *RequestString); + + // Execute + IMTBL_LOG("Executing JS: %s", *JS) + const bool Result = ExecuteJs.ExecuteIfBound(JS); + if (!Result) + { + IMTBL_WARN("ExecuteJS delegate was not called"); + } + + // TODO: add timeout callback } -void UImtblJSConnector::HandleInitResponse(FImtblJSResponse Response) { - IMTBL_LOG_FUNCSIG - bIsBridgeReady = true; - OnBridgeReady.Broadcast(); - OnBridgeReady.Clear(); +void UImtblJSConnector::HandleInitResponse(FImtblJSResponse Response) +{ + IMTBL_LOG_FUNCSIG + bIsBridgeReady = true; + OnBridgeReady.Broadcast(); + OnBridgeReady.Clear(); } -void UImtblJSConnector::SendToGame(FString Message) { - IMTBL_LOG_FUNC("Received message from JS: %s", *Message); +void UImtblJSConnector::SendToGame(FString Message) +{ + IMTBL_LOG_FUNC("Received message from JS: %s", *Message); - // Parse response + // Parse response - const TOptional Response = - FImtblJSResponse::FromJsonString(Message); - if (!Response.IsSet()) { - IMTBL_WARN("Received unexpected response from browser: %s", *Message); - return; - } + const TOptional Response = FImtblJSResponse::FromJsonString(Message); + if (!Response.IsSet()) + { + IMTBL_WARN("Received unexpected response from browser: %s", *Message); + return; + } - // Handle response + // Handle response - if (!RequestResponseDelegates.Contains(Response->requestId)) { - IMTBL_WARN("No delegate found for response with id %s", - *Response->requestId); - return; - } + if (!RequestResponseDelegates.Contains(Response->requestId)) + { + IMTBL_WARN("No delegate found for response with id %s", *Response->requestId); + return; + } - if (!RequestResponseDelegates[Response->requestId].ExecuteIfBound( - Response.GetValue())) { - IMTBL_WARN("Delegate for response with id %s failed to execute", - *Response->requestId); - } + if (!RequestResponseDelegates[Response->requestId].ExecuteIfBound(Response.GetValue())) + { + IMTBL_WARN("Delegate for response with id %s failed to execute", *Response->requestId); + } - RequestResponseDelegates.Remove(Response->requestId); + RequestResponseDelegates.Remove(Response->requestId); } #if PLATFORM_ANDROID | PLATFORM_IOS @@ -129,4 +131,4 @@ void UImtblJSConnector::SetMobileBridgeReady() { OnBridgeReady.Broadcast(); OnBridgeReady.Clear(); } -#endif \ No newline at end of file +#endif diff --git a/Source/Immutable/Private/Immutable/ImtblJSConnector.h b/Source/Immutable/Private/Immutable/ImtblJSConnector.h index 34c852d..c941522 100644 --- a/Source/Immutable/Private/Immutable/ImtblJSConnector.h +++ b/Source/Immutable/Private/Immutable/ImtblJSConnector.h @@ -22,57 +22,53 @@ DECLARE_DELEGATE_OneParam(FImtblJSResponseDelegate, struct FImtblJSResponse); * sure that the only UFUNCTIONs exposed to the browser are defined here. */ UCLASS() -class IMMUTABLE_API UImtblJSConnector : public UObject { - GENERATED_BODY() +class IMMUTABLE_API UImtblJSConnector : public UObject +{ + GENERATED_BODY() - friend class UImmutablePassport; + friend class UImmutablePassport; public: - DECLARE_MULTICAST_DELEGATE(FOnBridgeReadyDelegate); - DECLARE_DELEGATE_OneParam(FOnExecuteJsDelegate, const FString &); + DECLARE_MULTICAST_DELEGATE(FOnBridgeReadyDelegate); + DECLARE_DELEGATE_OneParam(FOnExecuteJsDelegate, const FString &); - UImtblJSConnector(); - void Init(bool bPageLoaded); + UImtblJSConnector(); + void Init(bool bPageLoaded); - void PostInitProperties() override; - bool IsBound() const; + virtual void PostInitProperties() override; + bool IsBound() const; - // The object name used to access the object in JavaScript (i.e.: - // window.ue.myjsobjectname). Will be converted to lowercase automatically. - static FString JSObjectName() { return "JSConnector"; } + // The object name used to access the object in JavaScript (i.e.: + // window.ue.myjsobjectname). Will be converted to lowercase automatically. + static FString JSObjectName() { return "JSConnector"; } - bool IsBridgeReady() const; - void - AddCallbackWhenBridgeReady(const FOnBridgeReadyDelegate::FDelegate &Delegate); + bool IsBridgeReady() const; + void AddCallbackWhenBridgeReady(const FOnBridgeReadyDelegate::FDelegate& Delegate); - // Callback for JavaScript to send responses back to Unreal - UFUNCTION() - void SendToGame(FString Message); + // Callback for JavaScript to send responses back to Unreal + UFUNCTION() + void SendToGame(FString Message); - // Bind the func to be called for executing JS. Typically by the BrowserWidget - // (UE5) or Blui for UE4 - FOnExecuteJsDelegate ExecuteJs; + // Bind the func to be called for executing JS. Typically by the BrowserWidget + // (UE5) or Blui for UE4 + FOnExecuteJsDelegate ExecuteJs; #if PLATFORM_ANDROID | PLATFORM_IOS void SetMobileBridgeReady(); #endif protected: - // Call a JavaScript function in the connected browser - FString CallJS(const FString &Function, const FString &Data, - const FImtblJSResponseDelegate &HandleResponse, - float ResponseTimeout = 0.0f); + // Call a JavaScript function in the connected browser + FString CallJS(const FString& Function, const FString& Data, const FImtblJSResponseDelegate& HandleResponse, float ResponseTimeout = 0.0f); private: - FOnBridgeReadyDelegate OnBridgeReady; - TMap RequestResponseDelegates; + FOnBridgeReadyDelegate OnBridgeReady; + TMap RequestResponseDelegates; - bool bIsBound = false; - bool bIsBridgeReady = false; - void HandleInitResponse(struct FImtblJSResponse Response); + bool bIsBound = false; + bool bIsBridgeReady = false; + void HandleInitResponse(struct FImtblJSResponse Response); - // Call a JavaScript function in the connected browser - void CallJS(const FImtblJSRequest &Request, - FImtblJSResponseDelegate HandleResponse, - float ResponseTimeout = 0.0f); + // Call a JavaScript function in the connected browser + void CallJS(const FImtblJSRequest& Request, FImtblJSResponseDelegate HandleResponse, float ResponseTimeout = 0.0f); }; diff --git a/Source/Immutable/Private/Immutable/ImtblJSMessages.h b/Source/Immutable/Private/Immutable/ImtblJSMessages.h index 046fade..bd5cc0f 100644 --- a/Source/Immutable/Private/Immutable/ImtblJSMessages.h +++ b/Source/Immutable/Private/Immutable/ImtblJSMessages.h @@ -8,110 +8,114 @@ // clang-format on UENUM() -enum class EImtblPassportError : int8 { - AuthenticationError, - WalletConnectionError, - UserRegistrationError, - RefreshTokenError, - TransferError, - CreateOrderError, - CancelOrderError, - CreateTradeError, - BatchTransferError, - ExchangeTransferError, - OperationNotSupportedError - // unknown, timeout? +enum class EImtblPassportError : int8 +{ + AuthenticationError, + WalletConnectionError, + UserRegistrationError, + RefreshTokenError, + TransferError, + CreateOrderError, + CancelOrderError, + CreateTradeError, + BatchTransferError, + ExchangeTransferError, + OperationNotSupportedError + // unknown, timeout? }; USTRUCT() -struct FImtblResponseError { - GENERATED_BODY() +struct FImtblResponseError +{ + GENERATED_BODY() - UPROPERTY() - EImtblPassportError errorType = static_cast(-1); + UPROPERTY() + EImtblPassportError errorType = static_cast(-1); - UPROPERTY() - FString errorMessage; + UPROPERTY() + FString errorMessage; - FString ToString() { - const FString ErrType = - StaticEnum()->GetNameStringByValue( - static_cast(errorType)); - return ErrType == "" ? errorMessage : ErrType + ": " + errorMessage; - } + FString ToString() + { + const FString ErrType = StaticEnum()->GetNameStringByValue(static_cast(errorType)); + return ErrType == "" ? errorMessage : ErrType + ": " + errorMessage; + } }; USTRUCT() -struct FImtblJSRequest { - GENERATED_BODY() +struct FImtblJSRequest +{ + GENERATED_BODY() - UPROPERTY() - FString fxName; + UPROPERTY() + FString fxName; - UPROPERTY() - FString data; + UPROPERTY() + FString data; - UPROPERTY() - FString requestId; + UPROPERTY() + FString requestId; - FString ToJsonString() const { - FString OutString; - FJsonObjectConverter::UStructToJsonObjectString( - *this, OutString, 0, 0, 0, nullptr, false); - return OutString; - } + FString ToJsonString() const + { + FString OutString; + FJsonObjectConverter::UStructToJsonObjectString(*this, OutString, 0, 0, 0, nullptr, false); + return OutString; + } }; USTRUCT() -struct IMMUTABLE_API FImtblJSResponse { - GENERATED_BODY() - - UPROPERTY() - FString responseFor; - - UPROPERTY() - FString requestId; - - UPROPERTY() - bool success = false; - - TOptional Error; - - // Store the parsed response object for later in case we need to access more - // data from it (tokens, addresses, user email, etc) - TSharedPtr JsonObject; - - static TOptional FromJsonString(const FString &JsonString) { - TOptional Response; - FImtblJSResponse JSResponse; - - // Parse the JSON - const TSharedRef> JsonReader = - TJsonReaderFactory<>::Create(JsonString); - if (!FJsonSerializer::Deserialize(JsonReader, JSResponse.JsonObject) || - !JSResponse.JsonObject.IsValid()) { - IMTBL_ERR("Could not parse response from JavaScript -- invalid JSON: %s", - *JsonString) - } else if (!FJsonObjectConverter::JsonObjectToUStruct( - JSResponse.JsonObject.ToSharedRef(), &JSResponse, 0, 0)) { - IMTBL_ERR("Could not parse response from JavaScript into the expected " - "response object format: %s", - *JsonString) - } else { - Response = JSResponse; - } - - if (!JSResponse.success) { - double ErrType = -1; - FString Error; - if (JSResponse.JsonObject.IsValid()) { - JSResponse.JsonObject->TryGetNumberField("errorType", ErrType); - JSResponse.JsonObject->TryGetStringField("error", Error); - } - JSResponse.Error = - FImtblResponseError{static_cast(ErrType), Error}; - } - - return Response; - } +struct IMMUTABLE_API FImtblJSResponse +{ + GENERATED_BODY() + + UPROPERTY() + FString responseFor; + + UPROPERTY() + FString requestId; + + UPROPERTY() + bool success = false; + + TOptional Error; + + // Store the parsed response object for later in case we need to access more + // data from it (tokens, addresses, user email, etc) + TSharedPtr JsonObject; + + static TOptional FromJsonString(const FString& JsonString) + { + TOptional Response; + FImtblJSResponse JSResponse; + + // Parse the JSON + const TSharedRef> JsonReader = TJsonReaderFactory<>::Create(JsonString); + if (!FJsonSerializer::Deserialize(JsonReader, JSResponse.JsonObject) || !JSResponse.JsonObject.IsValid()) + { + IMTBL_ERR("Could not parse response from JavaScript -- invalid JSON: %s", *JsonString) + } + else if (!FJsonObjectConverter::JsonObjectToUStruct(JSResponse.JsonObject.ToSharedRef(), &JSResponse, 0, 0)) + { + IMTBL_ERR("Could not parse response from JavaScript into the expected " "response object format: %s", *JsonString) + } + else + { + Response = JSResponse; + } + + if (!JSResponse.success) + { + double ErrType = -1; + FString Error; + if (JSResponse.JsonObject.IsValid()) + { + JSResponse.JsonObject->TryGetNumberField("errorType", ErrType); + JSResponse.JsonObject->TryGetStringField("error", Error); + } + JSResponse.Error = FImtblResponseError{static_cast(ErrType), Error}; + } + + return Response; + } }; diff --git a/Source/Immutable/Private/Immutable/Tests/ImtblMessagesTest.cpp b/Source/Immutable/Private/Immutable/Tests/ImtblMessagesTest.cpp index 3405229..8d91005 100644 --- a/Source/Immutable/Private/Immutable/Tests/ImtblMessagesTest.cpp +++ b/Source/Immutable/Private/Immutable/Tests/ImtblMessagesTest.cpp @@ -1,4 +1,3 @@ - // Fill out your copyright notice in the Description page of Project Settings. #include "Containers/UnrealString.h" @@ -16,10 +15,8 @@ #if WITH_DEV_AUTOMATION_TESTS -IMPLEMENT_SIMPLE_AUTOMATION_TEST(FImtblMessagesTest, "Immutable.JSMessages", - EAutomationTestFlags::ApplicationContextMask | - EAutomationTestFlags::ServerContext | - EAutomationTestFlags::ProductFilter) +IMPLEMENT_SIMPLE_AUTOMATION_TEST(FImtblMessagesTest, "Immutable.JSMessages", EAutomationTestFlags::ApplicationContextMask | EAutomationTestFlags::ServerContext | EAutomationTestFlags::ProductFilter) + // EAutomationTestFlags::SmokeFilter -- note that SmokeFilter will run // automatically during cooking @@ -29,70 +26,46 @@ IMPLEMENT_SIMPLE_AUTOMATION_TEST(FImtblMessagesTest, "Immutable.JSMessages", * * NB - must compile using "Development Editor" to recompile these tests. */ -bool FImtblMessagesTest::RunTest(const FString &Parameters) { - const FString ClientId = "MyExampleClientId"; +bool FImtblMessagesTest::RunTest(const FString& Parameters) +{ + const FString ClientId = "MyExampleClientId"; - // an FImmutablePassportInitData should convert into an appropriate json - // string - { - const FString RedirectUri = "https://example.com"; - const FImmutablePassportInitData InitData{ - ClientId, RedirectUri, ImmutablePassportAction::EnvSandbox}; - FString ExpectedJson = - "{\"clientId\":\"MyExampleClientId\",\"redirectUri\":\"https://" - "example.com\",\"environment\":\"sandbox\""; - ExpectedJson += ",\"engineVersion\":{"; - ExpectedJson += "\"engine\":\"unreal\""; - // example: - // engineVersion":"5.2.1-26001984+++UE5+Release-5.2","platform":"Mac","platformVersion":"13.5.2" - ExpectedJson += - ",\"engineVersion\":\"" + - FEngineVersion::Current().ToString().Replace(TEXT(" "), TEXT("_")) + - "\""; - ExpectedJson += FString(",\"platform\":\"") + - FString(FPlatformProperties::IniPlatformName()) - .Replace(TEXT(" "), TEXT("_")) + - "\""; - ExpectedJson += - FString(",\"platformVersion\":\"") + - FPlatformMisc::GetOSVersion().Replace(TEXT(" "), TEXT("_")) + "\""; - ExpectedJson += "}}"; - const FString Result = InitData.ToJsonString(); - TestEqual("toJsonString() on FPassportInitData with clientId and " - "redirectUri should produce valid JSON output", - Result, ExpectedJson); - } + // an FImmutablePassportInitData should convert into an appropriate json + // string + { + const FString RedirectUri = "https://example.com"; + const FImmutablePassportInitData InitData{ClientId, RedirectUri, ImmutablePassportAction::EnvSandbox}; + FString ExpectedJson = "{\"clientId\":\"MyExampleClientId\",\"redirectUri\":\"https://" "example.com\",\"environment\":\"sandbox\""; + ExpectedJson += ",\"engineVersion\":{"; + ExpectedJson += "\"engine\":\"unreal\""; + // example: + // engineVersion":"5.2.1-26001984+++UE5+Release-5.2","platform":"Mac","platformVersion":"13.5.2" + ExpectedJson += ",\"engineVersion\":\"" + FEngineVersion::Current().ToString().Replace(TEXT(" "), TEXT("_")) + "\""; + ExpectedJson += FString(",\"platform\":\"") + FString(FPlatformProperties::IniPlatformName()).Replace(TEXT(" "), TEXT("_")) + "\""; + ExpectedJson += FString(",\"platformVersion\":\"") + FPlatformMisc::GetOSVersion().Replace(TEXT(" "), TEXT("_")) + "\""; + ExpectedJson += "}}"; + const FString Result = InitData.ToJsonString(); + TestEqual("toJsonString() on FPassportInitData with clientId and " "redirectUri should produce valid JSON output", Result, ExpectedJson); + } - // an FImmutablePassportInitData with an empty redirectUri should leave the - // redirectUri field out of the json string when converted - { - const FImmutablePassportInitData InitData{ - ClientId, "", ImmutablePassportAction::EnvSandbox}; - FString ExpectedJson = - "{\"clientId\":\"MyExampleClientId\",\"environment\":\"sandbox\""; - ExpectedJson += ",\"engineVersion\":{"; - ExpectedJson += "\"engine\":\"unreal\""; - // example: - // engineVersion":"5.2.1-26001984+++UE5+Release-5.2","platform":"Mac","platformVersion":"13.5.2" - ExpectedJson += - ",\"engineVersion\":\"" + - FEngineVersion::Current().ToString().Replace(TEXT(" "), TEXT("_")) + - "\""; - ExpectedJson += FString(",\"platform\":\"") + - FString(FPlatformProperties::IniPlatformName()) - .Replace(TEXT(" "), TEXT("_")) + - "\""; - ExpectedJson += - FString(",\"platformVersion\":\"") + - FPlatformMisc::GetOSVersion().Replace(TEXT(" "), TEXT("_")) + "\""; - ExpectedJson += "}}"; - const FString Result = InitData.ToJsonString(); - TestEqual("toJsonString() on FPassportInitData with an empty redirectUri " - "should produce a valid JSON string with no redirectUri field", - Result, ExpectedJson); - } + // an FImmutablePassportInitData with an empty redirectUri should leave the + // redirectUri field out of the json string when converted + { + const FImmutablePassportInitData InitData{ClientId, "", ImmutablePassportAction::EnvSandbox}; + FString ExpectedJson = "{\"clientId\":\"MyExampleClientId\",\"environment\":\"sandbox\""; + ExpectedJson += ",\"engineVersion\":{"; + ExpectedJson += "\"engine\":\"unreal\""; + // example: + // engineVersion":"5.2.1-26001984+++UE5+Release-5.2","platform":"Mac","platformVersion":"13.5.2" + ExpectedJson += ",\"engineVersion\":\"" + FEngineVersion::Current().ToString().Replace(TEXT(" "), TEXT("_")) + "\""; + ExpectedJson += FString(",\"platform\":\"") + FString(FPlatformProperties::IniPlatformName()).Replace(TEXT(" "), TEXT("_")) + "\""; + ExpectedJson += FString(",\"platformVersion\":\"") + FPlatformMisc::GetOSVersion().Replace(TEXT(" "), TEXT("_")) + "\""; + ExpectedJson += "}}"; + const FString Result = InitData.ToJsonString(); + TestEqual("toJsonString() on FPassportInitData with an empty redirectUri " "should produce a valid JSON string with no redirectUri field", Result, ExpectedJson); + } - return true; + return true; } #endif // WITH_DEV_AUTOMATION_TESTS diff --git a/Source/Immutable/Private/ImmutableModule.cpp b/Source/Immutable/Private/ImmutableModule.cpp index aed6b79..53647bc 100644 --- a/Source/Immutable/Private/ImmutableModule.cpp +++ b/Source/Immutable/Private/ImmutableModule.cpp @@ -13,9 +13,10 @@ #define LOCTEXT_NAMESPACE "FImmutableModule" -void FImmutableModule::StartupModule() { - // This code will execute after your module is loaded into memory; the exact - // timing is specified in the .uplugin file per-module +void FImmutableModule::StartupModule() +{ + // This code will execute after your module is loaded into memory; the exact + // timing is specified in the .uplugin file per-module #if USING_BLUI_CEF if (IPluginManager::Get().FindPlugin("WebBrowserWidget") != nullptr && diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblConnectImxAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblConnectImxAsyncAction.h index d0bb5e7..5298bd9 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblConnectImxAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblConnectImxAsyncAction.h @@ -18,7 +18,6 @@ class IMMUTABLE_API UImtblConnectionAsyncActions : public UImtblBlueprintAsyncAc DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPassportConnectOutputPin, FString, ErrorMessage); public: - /** * Log into Passport using Device Code Authorisation. * @@ -62,10 +61,9 @@ class IMMUTABLE_API UImtblConnectionAsyncActions : public UImtblBlueprintAsyncAc static UImtblConnectionAsyncActions* ConnectImxPKCE(UObject* WorldContextObject); - void Activate() override; + virtual void Activate() override; private: - FImmutablePassportInitDeviceFlowData InitDeviceFlowData; void DoConnect(TWeakObjectPtr JSConnector); diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportConnectEvmAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportConnectEvmAsyncAction.h index 4ad0ef1..968132d 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportConnectEvmAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportConnectEvmAsyncAction.h @@ -11,29 +11,24 @@ * */ UCLASS() -class IMMUTABLE_API UImtblPassportConnectEvmAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportConnectEvmAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPassportConnectEvmOutputPin, - FString, ErrorMessage); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPassportConnectEvmOutputPin, FString, ErrorMessage); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportConnectEvmAsyncAction * - ConnectEvm(UObject *WorldContextObject); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportConnectEvmAsyncAction* ConnectEvm(UObject* WorldContextObject); - void Activate() override; + virtual void Activate() override; private: - void DoConnectEvm(TWeakObjectPtr JSConnector); - void OnConnectEvm(FImmutablePassportResult Result); + void DoConnectEvm(TWeakObjectPtr JSConnector); + void OnConnectEvm(FImmutablePassportResult Result); - UPROPERTY(BlueprintAssignable) - FPassportConnectEvmOutputPin Success; - UPROPERTY(BlueprintAssignable) - FPassportConnectEvmOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportConnectEvmOutputPin Success; + UPROPERTY(BlueprintAssignable) + FPassportConnectEvmOutputPin Failed; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.h index 0a6f5a7..ce75dd7 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.h @@ -11,30 +11,24 @@ * */ UCLASS() -class IMMUTABLE_API UImtblPassportGetAccessTokenAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportGetAccessTokenAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetAccessTokenOutputPin, - FString, ErrorMessage, FString, - AccessToken); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetAccessTokenOutputPin, FString, ErrorMessage, FString, AccessToken); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportGetAccessTokenAsyncAction * - GetAccessToken(UObject *WorldContextObject); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportGetAccessTokenAsyncAction* GetAccessToken(UObject* WorldContextObject); - void Activate() override; + virtual void Activate() override; private: - void DoGetAccessToken(TWeakObjectPtr JSGetConnector); - void OnGetAccessTokenResponse(FImmutablePassportResult Result); + void DoGetAccessToken(TWeakObjectPtr JSGetConnector); + void OnGetAccessTokenResponse(FImmutablePassportResult Result); - UPROPERTY(BlueprintAssignable) - FPassportGetAccessTokenOutputPin GotAccessToken; - UPROPERTY(BlueprintAssignable) - FPassportGetAccessTokenOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportGetAccessTokenOutputPin GotAccessToken; + UPROPERTY(BlueprintAssignable) + FPassportGetAccessTokenOutputPin Failed; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAddressAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAddressAsyncAction.h index fb6d99a..bb3718c 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAddressAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAddressAsyncAction.h @@ -11,30 +11,24 @@ * */ UCLASS() -class IMMUTABLE_API UImtblPassportGetAddressAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportGetAddressAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetAddressOutputPin, - FString, ErrorMessage, FString, - Address); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetAddressOutputPin, FString, ErrorMessage, FString, Address); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportGetAddressAsyncAction * - GetAddress(UObject *WorldContextObject); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportGetAddressAsyncAction* GetAddress(UObject* WorldContextObject); - void Activate() override; + virtual void Activate() override; private: - void DoGetAddress(TWeakObjectPtr JSGetConnector); - void OnGetAddressResponse(FImmutablePassportResult Result); + void DoGetAddress(TWeakObjectPtr JSGetConnector); + void OnGetAddressResponse(FImmutablePassportResult Result); - UPROPERTY(BlueprintAssignable) - FPassportGetAddressOutputPin GotAddress; - UPROPERTY(BlueprintAssignable) - FPassportGetAddressOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportGetAddressOutputPin GotAddress; + UPROPERTY(BlueprintAssignable) + FPassportGetAddressOutputPin Failed; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetEmailAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetEmailAsyncAction.h index 076de06..788f2a9 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetEmailAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetEmailAsyncAction.h @@ -11,30 +11,24 @@ * */ UCLASS() -class IMMUTABLE_API UImtblPassportGetEmailAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportGetEmailAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetEmailOutputPin, - FString, ErrorMessage, FString, - Email); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetEmailOutputPin, FString, ErrorMessage, FString, Email); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportGetEmailAsyncAction * - GetEmail(UObject *WorldContextObject); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportGetEmailAsyncAction* GetEmail(UObject* WorldContextObject); - void Activate() override; + virtual void Activate() override; private: - void DoGetEmail(TWeakObjectPtr JSGetConnector); - void OnGetEmailResponse(FImmutablePassportResult Result); + void DoGetEmail(TWeakObjectPtr JSGetConnector); + void OnGetEmailResponse(FImmutablePassportResult Result); - UPROPERTY(BlueprintAssignable) - FPassportGetEmailOutputPin GotEmail; - UPROPERTY(BlueprintAssignable) - FPassportGetEmailOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportGetEmailOutputPin GotEmail; + UPROPERTY(BlueprintAssignable) + FPassportGetEmailOutputPin Failed; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.h index d7b789d..0fc19f2 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.h @@ -11,30 +11,24 @@ * */ UCLASS() -class IMMUTABLE_API UImtblPassportGetIdTokenAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportGetIdTokenAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetIdTokenOutputPin, - FString, ErrorMessage, FString, - IdToken); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetIdTokenOutputPin, FString, ErrorMessage, FString, IdToken); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportGetIdTokenAsyncAction * - GetIdToken(UObject *WorldContextObject); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportGetIdTokenAsyncAction* GetIdToken(UObject* WorldContextObject); - void Activate() override; + virtual void Activate() override; private: - void DoGetIdToken(TWeakObjectPtr JSGetConnector); - void OnGetIdTokenResponse(FImmutablePassportResult Result); + void DoGetIdToken(TWeakObjectPtr JSGetConnector); + void OnGetIdTokenResponse(FImmutablePassportResult Result); - UPROPERTY(BlueprintAssignable) - FPassportGetIdTokenOutputPin GotIdToken; - UPROPERTY(BlueprintAssignable) - FPassportGetIdTokenOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportGetIdTokenOutputPin GotIdToken; + UPROPERTY(BlueprintAssignable) + FPassportGetIdTokenOutputPin Failed; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportHasStoredCredentialsAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportHasStoredCredentialsAsyncAction.h index 019573b..5485979 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportHasStoredCredentialsAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportHasStoredCredentialsAsyncAction.h @@ -16,14 +16,12 @@ class IMMUTABLE_API UImtblPassportHasStoredCredentialsAsyncAction : public UImtb DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPassportHasStoredCredentialsOutputPin, FString, ErrorMessage); public: - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") static UImtblPassportHasStoredCredentialsAsyncAction* HasStoredCredentials(UObject* WorldContextObject); - void Activate() override; + virtual void Activate() override; private: - void DoHasStoredCredentials(TWeakObjectPtr JSGetConnector); void OnHasStoredCredentialsResponse(struct FImmutablePassportResult Result); diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxBatchNftTransferAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxBatchNftTransferAsyncAction.h index 6e02492..9c4b145 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxBatchNftTransferAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxBatchNftTransferAsyncAction.h @@ -11,33 +11,26 @@ * */ UCLASS() -class IMMUTABLE_API UImmutablePassportImxBatchNftTransferAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImmutablePassportImxBatchNftTransferAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( - FPassportImxBatchNftTransferIdOutputPin, FString, ErrorMessageString, - const TArray &, TransferIds); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportImxBatchNftTransferIdOutputPin, FString, ErrorMessageString, const TArray &, TransferIds); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImmutablePassportImxBatchNftTransferAsyncAction * - ImxBatchNftTransfer(UObject *WorldContextObject, - const TArray &NftTransferDetails); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImmutablePassportImxBatchNftTransferAsyncAction* ImxBatchNftTransfer(UObject* WorldContextObject, const TArray& NftTransferDetails); - void Activate() override; + virtual void Activate() override; private: - void DoTransfer(TWeakObjectPtr JSGetConnector); - void OnTransferResponse(FImmutablePassportResult Result); + void DoTransfer(TWeakObjectPtr JSGetConnector); + void OnTransferResponse(FImmutablePassportResult Result); - TArray NftTransferDetails; + TArray NftTransferDetails; - UPROPERTY(BlueprintAssignable) - FPassportImxBatchNftTransferIdOutputPin Success; - UPROPERTY(BlueprintAssignable) - FPassportImxBatchNftTransferIdOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportImxBatchNftTransferIdOutputPin Success; + UPROPERTY(BlueprintAssignable) + FPassportImxBatchNftTransferIdOutputPin Failed; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxIsRegisteredOffchainAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxIsRegisteredOffchainAsyncAction.h index 5a530b3..848b189 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxIsRegisteredOffchainAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxIsRegisteredOffchainAsyncAction.h @@ -15,18 +15,15 @@ class IMMUTABLE_API UImtblPassportImxIsRegisteredOffchainAsyncAction : public UI DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnCompleteOutputPin, bool, IsRegistered); public: - - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") - static UImtblPassportImxIsRegisteredOffchainAsyncAction* IsRegisteredOffchain(UObject* WorldContextObject); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportImxIsRegisteredOffchainAsyncAction* IsRegisteredOffchain(UObject* WorldContextObject); - virtual void Activate() override; + virtual void Activate() override; private: - - void DoImxIsRegisteredOffchain(TWeakObjectPtr JSGetConnector); - void OnImxIsRegisteredOffchainResponse(struct FImmutablePassportResult Result); - - UPROPERTY(BlueprintAssignable) - FOnCompleteOutputPin OnComplete; + void DoImxIsRegisteredOffchain(TWeakObjectPtr JSGetConnector); + void OnImxIsRegisteredOffchainResponse(struct FImmutablePassportResult Result); + UPROPERTY(BlueprintAssignable) + FOnCompleteOutputPin OnComplete; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxRegisterOffchainAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxRegisterOffchainAsyncAction.h index 93f2804..8e03fcf 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxRegisterOffchainAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxRegisterOffchainAsyncAction.h @@ -15,20 +15,17 @@ class IMMUTABLE_API UImtblPassportImxRegisterOffchainAsyncAction : public UImtbl DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOutputPin, FString, TxHash, FString, ErrorMessage); public: - - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") - static UImtblPassportImxRegisterOffchainAsyncAction* RegisterOffchain(UObject* WorldContextObject); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportImxRegisterOffchainAsyncAction* RegisterOffchain(UObject* WorldContextObject); - virtual void Activate() override; + virtual void Activate() override; private: - - void DoImxRegisterOffchain(TWeakObjectPtr JSGetConnector); - void OnImxRegisterOffchainResponse(struct FImmutablePassportResult Result); + void DoImxRegisterOffchain(TWeakObjectPtr JSGetConnector); + void OnImxRegisterOffchainResponse(struct FImmutablePassportResult Result); UPROPERTY(BlueprintAssignable) FOutputPin OnSuccess; UPROPERTY(BlueprintAssignable) FOutputPin OnFailure; - }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxTransferAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxTransferAsyncAction.h index 68d0e8c..9848de3 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxTransferAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportImxTransferAsyncAction.h @@ -11,38 +11,30 @@ * */ UCLASS() -class IMMUTABLE_API UImmutablePassportImxTransferAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImmutablePassportImxTransferAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportImxTransferIdOutputPin, - FString, ErrorMessageString, - FString, TransferId); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportImxTransferIdOutputPin, FString, ErrorMessageString, FString, TransferId); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImmutablePassportImxTransferAsyncAction * - ImxTransfer(UObject *WorldContextObject, const FString &Receiver, - const FString &Type, const FString &Amount, - const FString &TokenId, const FString &TokenAddress); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImmutablePassportImxTransferAsyncAction* ImxTransfer(UObject* WorldContextObject, const FString& Receiver, const FString& Type, const FString& Amount, const FString& TokenId, const FString& TokenAddress); - void Activate() override; + virtual void Activate() override; private: - void DoTransfer(TWeakObjectPtr JSGetConnector); - void OnTransferResponse(FImmutablePassportResult Result); - - FString Receiver; - FString Type; - FString Amount; - FString TokenId; - FString TokenAddress; - - UPROPERTY(BlueprintAssignable) - FPassportImxTransferIdOutputPin Success; - UPROPERTY(BlueprintAssignable) - FPassportImxTransferIdOutputPin Failed; + void DoTransfer(TWeakObjectPtr JSGetConnector); + void OnTransferResponse(FImmutablePassportResult Result); + + FString Receiver; + FString Type; + FString Amount; + FString TokenId; + FString TokenAddress; + + UPROPERTY(BlueprintAssignable) + FPassportImxTransferIdOutputPin Success; + UPROPERTY(BlueprintAssignable) + FPassportImxTransferIdOutputPin Failed; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportLogoutAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportLogoutAsyncAction.h index fe24f7b..cf2525a 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportLogoutAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportLogoutAsyncAction.h @@ -17,22 +17,18 @@ class IMMUTABLE_API UImtblPassportLogoutAsyncAction : public UImtblBlueprintAsyn DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPassportLogoutOutPin, FString, Message); public: - UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") static UImtblPassportLogoutAsyncAction* Logout(UObject* WorldContextObject); virtual void Activate() override; private: - void DoLogout(TWeakObjectPtr JSConnector); void OnLogoutResponse(FImmutablePassportResult Result) const; private: - UPROPERTY(BlueprintAssignable) FPassportLogoutOutPin OnSuccess; UPROPERTY(BlueprintAssignable) FPassportLogoutOutPin OnFailure; - }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmGetBalanceAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmGetBalanceAsyncAction.h index b93cabf..654fc14 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmGetBalanceAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmGetBalanceAsyncAction.h @@ -11,35 +11,27 @@ * */ UCLASS() -class IMMUTABLE_API UImtblPassportZkEvmGetBalanceAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportZkEvmGetBalanceAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( - FPassportZkEvmGetBalanceOutputPin, FString, ErrorMessage, FString, - Balance); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportZkEvmGetBalanceOutputPin, FString, ErrorMessage, FString, Balance); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportZkEvmGetBalanceAsyncAction * - ZkEvmGetBalance(UObject *WorldContextObject, const FString &Address, - const FString &BlockNumberOrTag); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportZkEvmGetBalanceAsyncAction* ZkEvmGetBalance(UObject* WorldContextObject, const FString& Address, const FString& BlockNumberOrTag); - void Activate() override; + virtual void Activate() override; private: - FString Address; - FString BlockNumberOrTag; + FString Address; + FString BlockNumberOrTag; - UPROPERTY(BlueprintAssignable) - FPassportZkEvmGetBalanceOutputPin GotBalance; - UPROPERTY(BlueprintAssignable) - FPassportZkEvmGetBalanceOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportZkEvmGetBalanceOutputPin GotBalance; + UPROPERTY(BlueprintAssignable) + FPassportZkEvmGetBalanceOutputPin Failed; - void - DoZkEvmGetBalance(TWeakObjectPtr JSGetConnector); - void OnZkEvmGetBalanceResponse(FImmutablePassportResult Result); + void DoZkEvmGetBalance(TWeakObjectPtr JSGetConnector); + void OnZkEvmGetBalanceResponse(FImmutablePassportResult Result); }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmRequestAccountsAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmRequestAccountsAsyncAction.h index 8840800..905cd07 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmRequestAccountsAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmRequestAccountsAsyncAction.h @@ -11,33 +11,26 @@ * */ UCLASS() -class IMMUTABLE_API UImtblPassportZkEvmRequestAccountsAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportZkEvmRequestAccountsAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( - FPassportZkEvmRequestAccountsOutputPin, FString, ErrorMessage, - const TArray &, Accounts); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportZkEvmRequestAccountsOutputPin, FString, ErrorMessage, const TArray &, Accounts); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportZkEvmRequestAccountsAsyncAction * - RequestAccounts(UObject *WorldContextObject); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportZkEvmRequestAccountsAsyncAction* RequestAccounts(UObject* WorldContextObject); - void Activate() override; + virtual void Activate() override; private: - FImmutablePassportZkEvmRequestAccountsData RequestAccountsData; + FImmutablePassportZkEvmRequestAccountsData RequestAccountsData; - void - DoRequestAccounts(TWeakObjectPtr JSGetConnector); - void OnRequestAccountsResponse(FImmutablePassportResult Result); + void DoRequestAccounts(TWeakObjectPtr JSGetConnector); + void OnRequestAccountsResponse(FImmutablePassportResult Result); - UPROPERTY(BlueprintAssignable) - FPassportZkEvmRequestAccountsOutputPin Failed; - UPROPERTY(BlueprintAssignable) - FPassportZkEvmRequestAccountsOutputPin GotAccounts; + UPROPERTY(BlueprintAssignable) + FPassportZkEvmRequestAccountsOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportZkEvmRequestAccountsOutputPin GotAccounts; }; diff --git a/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmSendTransactionAsyncAction.h b/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmSendTransactionAsyncAction.h index 2654609..ddfae85 100644 --- a/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmSendTransactionAsyncAction.h +++ b/Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmSendTransactionAsyncAction.h @@ -11,34 +11,26 @@ * */ UCLASS() -class IMMUTABLE_API UImtblPassportZkEvmSendTransactionAsyncAction - : public UImtblBlueprintAsyncAction { - GENERATED_BODY() +class IMMUTABLE_API UImtblPassportZkEvmSendTransactionAsyncAction : public UImtblBlueprintAsyncAction +{ + GENERATED_BODY() - DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( - FPassportZkEvmSendTransactionOutputPin, FString, ErrorMessage, FString, - Transaction); + DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportZkEvmSendTransactionOutputPin, FString, ErrorMessage, FString, Transaction); public: - UFUNCTION(BlueprintCallable, - meta = (WorldContext = "WorldContextObject", - BlueprintInternalUseOnly = "true"), - Category = "Immutable") - static UImtblPassportZkEvmSendTransactionAsyncAction * - ZkEvmSendTransaction(UObject *WorldContextObject, - const FImtblTransactionRequest &Request); + UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") + static UImtblPassportZkEvmSendTransactionAsyncAction* ZkEvmSendTransaction(UObject* WorldContextObject, const FImtblTransactionRequest& Request); - void Activate() override; + virtual void Activate() override; private: - FImtblTransactionRequest TransactionRequest; + FImtblTransactionRequest TransactionRequest; - UPROPERTY(BlueprintAssignable) - FPassportZkEvmSendTransactionOutputPin TransactionSent; - UPROPERTY(BlueprintAssignable) - FPassportZkEvmSendTransactionOutputPin Failed; + UPROPERTY(BlueprintAssignable) + FPassportZkEvmSendTransactionOutputPin TransactionSent; + UPROPERTY(BlueprintAssignable) + FPassportZkEvmSendTransactionOutputPin Failed; - void DoZkEvmSendTransaction( - TWeakObjectPtr JSGetConnector); - void OnZkEvmSendTransactionResponse(FImmutablePassportResult Result); -}; \ No newline at end of file + void DoZkEvmSendTransaction(TWeakObjectPtr JSGetConnector); + void OnZkEvmSendTransactionResponse(FImmutablePassportResult Result); +}; diff --git a/Source/Immutable/Public/Immutable/Assets/ImtblSDKResource.h b/Source/Immutable/Public/Immutable/Assets/ImtblSDKResource.h index a0e96d6..d9e1375 100644 --- a/Source/Immutable/Public/Immutable/Assets/ImtblSDKResource.h +++ b/Source/Immutable/Public/Immutable/Assets/ImtblSDKResource.h @@ -9,10 +9,11 @@ * */ UCLASS() -class IMMUTABLE_API UImtblSDKResource : public UObject { - GENERATED_BODY() +class IMMUTABLE_API UImtblSDKResource : public UObject +{ + GENERATED_BODY() public: - UPROPERTY() - FString Js; + UPROPERTY() + FString Js; }; diff --git a/Source/Immutable/Public/Immutable/ImmutableDataTypes.h b/Source/Immutable/Public/Immutable/ImmutableDataTypes.h index 527f651..0cb96c8 100644 --- a/Source/Immutable/Public/Immutable/ImmutableDataTypes.h +++ b/Source/Immutable/Public/Immutable/ImmutableDataTypes.h @@ -82,7 +82,6 @@ struct FImtblUserProfile FString nickname; UPROPERTY() FString sub; - }; USTRUCT() @@ -95,8 +94,7 @@ struct FImmutablePassportZkEvmRequestAccountsData FString ToJsonString() const; static TOptional FromJsonString(const FString& JsonObjectString); - static TOptional FromJsonObject( - const TSharedPtr& JsonObject); + static TOptional FromJsonObject(const TSharedPtr& JsonObject); }; USTRUCT() diff --git a/Source/Immutable/Public/Immutable/ImmutableNames.h b/Source/Immutable/Public/Immutable/ImmutableNames.h index 69a9fce..bc52a4f 100644 --- a/Source/Immutable/Public/Immutable/ImmutableNames.h +++ b/Source/Immutable/Public/Immutable/ImmutableNames.h @@ -31,4 +31,4 @@ namespace ImmutablePassportAction const FString EnvProduction = TEXT("production"); const FString ImxIsRegisteredOffchain = TEXT("isRegisteredOffchain"); const FString ImxRegisterOffchain = TEXT("registerOffchain"); -} // namespace ImmutablePassportAction \ No newline at end of file +} // namespace ImmutablePassportAction diff --git a/Source/Immutable/Public/Immutable/ImmutablePassport.h b/Source/Immutable/Public/Immutable/ImmutablePassport.h index 9f3605f..717809d 100644 --- a/Source/Immutable/Public/Immutable/ImmutablePassport.h +++ b/Source/Immutable/Public/Immutable/ImmutablePassport.h @@ -15,14 +15,16 @@ #include "ImmutablePassport.generated.h" -template FString UStructToJsonString(const UStructType& InStruct) +template +FString UStructToJsonString(const UStructType& InStruct) { FString OutString; FJsonObjectConverter::UStructToJsonObjectString(InStruct, OutString, 0, 0, 0, nullptr, false); return OutString; } -template TOptional JsonObjectToUStruct(const TSharedPtr& JsonObject) +template +TOptional JsonObjectToUStruct(const TSharedPtr& JsonObject) { if (!JsonObject.IsValid()) { @@ -101,8 +103,7 @@ class IMMUTABLE_API UImmutablePassport : public UObject * @param ResponseDelegate The response delegate of type * FImtblPassportResponseDelegate to call on response from JS. */ - void ZkEvmSendTransaction(const FImtblTransactionRequest& Request, - const FImtblPassportResponseDelegate& ResponseDelegate); + void ZkEvmSendTransaction(const FImtblTransactionRequest& Request, const FImtblPassportResponseDelegate& ResponseDelegate); void GetIdToken(const FImtblPassportResponseDelegate& ResponseDelegate); void GetAccessToken(const FImtblPassportResponseDelegate& ResponseDelegate); void GetAddress(const FImtblPassportResponseDelegate& ResponseDelegate); @@ -125,8 +126,7 @@ class IMMUTABLE_API UImmutablePassport : public UObject * @param ResponseDelegate The response delegate of type * FImtblPassportResponseDelegate to call on response from JS. */ - void ImxBatchNftTransfer(const FImxBatchNftTransferRequest& RequestData, - const FImtblPassportResponseDelegate& ResponseDelegate); + void ImxBatchNftTransfer(const FImxBatchNftTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate); /** * @@ -151,7 +151,6 @@ class IMMUTABLE_API UImmutablePassport : public UObject void HasStoredCredentials(const FImtblPassportResponseDelegate& ResponseDelegate); protected: - void Setup(TWeakObjectPtr Connector); void ReinstateConnection(FImtblJSResponse Response); @@ -167,7 +166,7 @@ class IMMUTABLE_API UImmutablePassport : public UObject TMap ResponseDelegates; #if PLATFORM_ANDROID | PLATFORM_IOS | PLATFORM_MAC DECLARE_DELEGATE_OneParam(FImtblPassportHandleDeepLinkDelegate, FString); - + FImtblPassportHandleDeepLinkDelegate OnHandleDeepLink; // Since the second part of PKCE is triggered by deep links, saving the // response delegate here so it's easier to get @@ -180,18 +179,15 @@ class IMMUTABLE_API UImmutablePassport : public UObject bool CheckIsInitialized(const FString& Action, const FImtblPassportResponseDelegate& ResponseDelegate) const; // Calls JS with the given Action and Data, and registers the given // ResponseDelegate to be called when JS responds - void CallJS(const FString& Action, const FString& Data, - const FImtblPassportResponseDelegate& ClientResponseDelegate, - const FImtblJSResponseDelegate& HandleJSResponse, const bool bCheckInitialized = true); + void CallJS(const FString& Action, const FString& Data, const FImtblPassportResponseDelegate& ClientResponseDelegate, const FImtblJSResponseDelegate& HandleJSResponse, const bool bCheckInitialized = true); // Pulls the ResponseDelegate from the ResponseDelegates map and returns it TOptional GetResponseDelegate(const FImtblJSResponse& Response); - void ConfirmCode(const FString& DeviceCode, const float Interval, - const FImtblPassportResponseDelegate& ResponseDelegate); + void ConfirmCode(const FString& DeviceCode, const float Interval, const FImtblPassportResponseDelegate& ResponseDelegate); void OnInitializeResponse(FImtblJSResponse Response); void OnInitDeviceFlowResponse(FImtblJSResponse Response); - + void OnLogoutResponse(FImtblJSResponse Response); void OnConnectResponse(FImtblJSResponse Response); void OnConnectSilentResponse(FImtblJSResponse Response); @@ -231,24 +227,21 @@ class IMMUTABLE_API UImmutablePassport : public UObject bool IsStateFlagsSet(uint8 StateIn) const; private: - void SavePassportSettings(); void LoadPassportSettings(); - -private: +private: enum EImmutablePassportStateFlags : uint8 { - IPS_NONE = 0, - IPS_CONNECTING = 1 << 0, - IPS_CONNECTED = 1 << 1, - IPS_IMX = 1 << 2, - IPS_PKCE = 1 << 3, - IPS_COMPLETING_PKCE = 1 << 4, - IPS_INITIALIZED = 1 << 5 + IPS_NONE = 0, + IPS_CONNECTING = 1 << 0, + IPS_CONNECTED = 1 << 1, + IPS_IMX = 1 << 2, + IPS_PKCE = 1 << 3, + IPS_COMPLETING_PKCE = 1 << 4, + IPS_INITIALIZED = 1 << 5 }; uint8 StateFlags = IPS_NONE; bool bIsPrevConnectedViaPKCEFlow = false; - }; diff --git a/Source/Immutable/Public/Immutable/ImmutableRequests.h b/Source/Immutable/Public/Immutable/ImmutableRequests.h index ce912fe..9ee27b3 100644 --- a/Source/Immutable/Public/Immutable/ImmutableRequests.h +++ b/Source/Immutable/Public/Immutable/ImmutableRequests.h @@ -51,4 +51,4 @@ struct FImxBatchNftTransferRequest TArray nftTransferDetails; FString ToJsonString() const; -}; \ No newline at end of file +}; diff --git a/Source/Immutable/Public/Immutable/ImmutableResponses.h b/Source/Immutable/Public/Immutable/ImmutableResponses.h index 5007bcb..70e65fd 100644 --- a/Source/Immutable/Public/Immutable/ImmutableResponses.h +++ b/Source/Immutable/Public/Immutable/ImmutableResponses.h @@ -37,4 +37,4 @@ struct FImxRegisterOffchainResponse UPROPERTY() FString tx_hash; -}; \ No newline at end of file +}; diff --git a/Source/Immutable/Public/Immutable/ImmutableSaveGame.h b/Source/Immutable/Public/Immutable/ImmutableSaveGame.h index a49097a..cdb90a3 100644 --- a/Source/Immutable/Public/Immutable/ImmutableSaveGame.h +++ b/Source/Immutable/Public/Immutable/ImmutableSaveGame.h @@ -15,9 +15,7 @@ class IMMUTABLE_API UImmutableSaveGame : public USaveGame GENERATED_UCLASS_BODY() public: - /** check if player logged in/connected with PKCE flow previously */ UPROPERTY(VisibleAnywhere, Category = "Immutable") bool bWasConnectedViaPKCEFlow; - -}; \ No newline at end of file +}; diff --git a/Source/Immutable/Public/Immutable/ImmutableSubsystem.h b/Source/Immutable/Public/Immutable/ImmutableSubsystem.h index 8bd8df3..9f7d88c 100644 --- a/Source/Immutable/Public/Immutable/ImmutableSubsystem.h +++ b/Source/Immutable/Public/Immutable/ImmutableSubsystem.h @@ -8,62 +8,63 @@ #include "ImmutableSubsystem.generated.h" // clang-format on -DECLARE_MULTICAST_DELEGATE_OneParam(FImmutableSubsystemReadyDelegate, - TWeakObjectPtr); +DECLARE_MULTICAST_DELEGATE_OneParam(FImmutableSubsystemReadyDelegate, TWeakObjectPtr); /** * */ UCLASS() -class IMMUTABLE_API UImmutableSubsystem : public UGameInstanceSubsystem { - GENERATED_BODY() +class IMMUTABLE_API UImmutableSubsystem : public UGameInstanceSubsystem +{ + GENERATED_BODY() public: - UImmutableSubsystem(); + UImmutableSubsystem(); - void Initialize(FSubsystemCollectionBase &Collection) override; - void Deinitialize() override; + virtual void Initialize(FSubsystemCollectionBase& Collection) override; + virtual void Deinitialize() override; - TWeakObjectPtr GetPassport() const { - return MakeWeakObjectPtr(Passport); - } + TWeakObjectPtr GetPassport() const + { + return MakeWeakObjectPtr(Passport); + } - bool IsReady() const { return bIsReady; } + bool IsReady() const { return bIsReady; } - // FOnGameViewportTick& OnGameViewportTick() { return GameViewportTickEvent; } + // FOnGameViewportTick& OnGameViewportTick() { return GameViewportTickEvent; } - // Execute a delegate when the subsystem is ready (i.e.: when the browser is - // running and the Immutable SDK game bridge has loaded). - template + // Execute a delegate when the subsystem is ready (i.e.: when the browser is + // running and the Immutable SDK game bridge has loaded). + template #if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) - void WhenReady(UserClass* Object, typename FImmutableSubsystemReadyDelegate::FDelegate::TMethodPtr Func); + void WhenReady(UserClass* Object, typename FImmutableSubsystemReadyDelegate::FDelegate::TMethodPtr Func); #else void WhenReady(UserClass* Object, typename FImmutableSubsystemReadyDelegate::FDelegate::TUObjectMethodDelegate::FMethodPtr Func); #endif private: - UPROPERTY() - class UImtblBrowserUserWidget *BrowserWidget = nullptr; + UPROPERTY() + class UImtblBrowserUserWidget* BrowserWidget = nullptr; - UPROPERTY() - class UImtblBlui *ImtblBlui = nullptr; + UPROPERTY() + class UImtblBlui* ImtblBlui = nullptr; - UPROPERTY() - class UImmutablePassport *Passport = nullptr; + UPROPERTY() + class UImmutablePassport* Passport = nullptr; - bool bHasSetupGameBridge = false; - bool bIsReady = false; - FImmutableSubsystemReadyDelegate OnReady; + bool bHasSetupGameBridge = false; + bool bIsReady = false; + FImmutableSubsystemReadyDelegate OnReady; - FDelegateHandle WorldTickHandle; - FDelegateHandle ViewportCreatedHandle; + FDelegateHandle WorldTickHandle; + FDelegateHandle ViewportCreatedHandle; #if PLATFORM_ANDROID | PLATFORM_IOS FDelegateHandle EngineInitCompleteHandle; #endif - void SetupGameBridge(); - void OnBridgeReady(); - void ManageBridgeDelegateQueue(); - void OnViewportCreated(); - void WorldTickStart(UWorld *World, ELevelTick TickType, float DeltaSeconds); + void SetupGameBridge(); + void OnBridgeReady(); + void ManageBridgeDelegateQueue(); + void OnViewportCreated(); + void WorldTickStart(UWorld* World, ELevelTick TickType, float DeltaSeconds); }; diff --git a/Source/Immutable/Public/Immutable/Misc/ImtblLogging.h b/Source/Immutable/Public/Immutable/Misc/ImtblLogging.h index 5784445..e0382ba 100644 --- a/Source/Immutable/Public/Immutable/Misc/ImtblLogging.h +++ b/Source/Immutable/Public/Immutable/Misc/ImtblLogging.h @@ -10,9 +10,11 @@ IMMUTABLE_API DECLARE_LOG_CATEGORY_EXTERN(LogImmutable, Log, All); IMMUTABLE_API DECLARE_LOG_CATEGORY_EXTERN(LogClean, Log, All); #else // Direct implementation of the DECLARE_LOG_CATEGORY_EXTERN macro -IMMUTABLE_API extern struct FLogCategoryLogClean - : public FLogCategory { - FORCEINLINE FLogCategoryLogClean() : FLogCategory(TEXT("")) {} +IMMUTABLE_API extern struct FLogCategoryLogClean : public FLogCategory +{ + FORCEINLINE FLogCategoryLogClean() : FLogCategory(TEXT("")) + { + } } LogClean; #endif diff --git a/Source/Immutable/Public/ImmutableModule.h b/Source/Immutable/Public/ImmutableModule.h index e48da53..e4c1261 100644 --- a/Source/Immutable/Public/ImmutableModule.h +++ b/Source/Immutable/Public/ImmutableModule.h @@ -5,11 +5,12 @@ #include "CoreMinimal.h" #include "Modules/ModuleManager.h" -class FImmutableModule : public IModuleInterface { +class FImmutableModule : public IModuleInterface +{ public: - /** IModuleInterface implementation */ - void StartupModule() override; - void ShutdownModule() override; + /** IModuleInterface implementation */ + virtual void StartupModule() override; + virtual void ShutdownModule() override; private: };