From b43822cfd8dd9db8ecc0841b9c86ca0e27e0538d Mon Sep 17 00:00:00 2001 From: Yermek Garifullanov Date: Wed, 11 Dec 2024 09:56:06 +1300 Subject: [PATCH 1/6] feat: added transak config --- .../Private/Immutable/ImmutableUtilities.cpp | 16 ++ .../Immutable/ImmutablePluginSettings.h | 4 + .../Public/Immutable/ImmutableUtilities.h | 2 + .../Public/Immutable/TransakConfig.h | 139 ++++++++++++++++++ 4 files changed, 161 insertions(+) create mode 100644 Source/Immutable/Public/Immutable/TransakConfig.h diff --git a/Source/Immutable/Private/Immutable/ImmutableUtilities.cpp b/Source/Immutable/Private/Immutable/ImmutableUtilities.cpp index a81db18..dad2f90 100644 --- a/Source/Immutable/Private/Immutable/ImmutableUtilities.cpp +++ b/Source/Immutable/Private/Immutable/ImmutableUtilities.cpp @@ -27,8 +27,24 @@ UApplicationConfig* FImmutableUtilities::GetDefaultApplicationConfig() if (!Settings) { + IMTBL_ERR("Failed to retrieve default Immutable application configuration") + return nullptr; } return Settings->DefaultApplicationConfig.GetDefaultObject(); } + +UTransakConfig* FImmutableUtilities::GetDefaultTransakConfig() +{ + auto Settings = GetDefault(); + + if (!Settings) + { + IMTBL_ERR("Failed to retrieve default Immutable Transak configuration") + + return nullptr; + } + + return Settings->DefaultTransakConfig.GetDefaultObject(); +} diff --git a/Source/Immutable/Public/Immutable/ImmutablePluginSettings.h b/Source/Immutable/Public/Immutable/ImmutablePluginSettings.h index fd87515..fa1acff 100644 --- a/Source/Immutable/Public/Immutable/ImmutablePluginSettings.h +++ b/Source/Immutable/Public/Immutable/ImmutablePluginSettings.h @@ -2,6 +2,7 @@ #include "Engine/DeveloperSettings.h" #include "ApplicationConfig.h" +#include "TransakConfig.h" #include "ImmutablePluginSettings.generated.h" @@ -22,4 +23,7 @@ class IMMUTABLE_API UImmutablePluginSettings : public UDeveloperSettings /// which will be used as the default configuration for the application. UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "General") TSubclassOf DefaultApplicationConfig; + + UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Transak") + TSubclassOf DefaultTransakConfig; }; diff --git a/Source/Immutable/Public/Immutable/ImmutableUtilities.h b/Source/Immutable/Public/Immutable/ImmutableUtilities.h index 45af345..6c788d2 100644 --- a/Source/Immutable/Public/Immutable/ImmutableUtilities.h +++ b/Source/Immutable/Public/Immutable/ImmutableUtilities.h @@ -1,5 +1,6 @@ #pragma once #include "ApplicationConfig.h" +#include "TransakConfig.h" /** A wrapper struct around various Immutable namespace utility and support methods. */ @@ -15,4 +16,5 @@ struct IMMUTABLE_API FImmutableUtilities static bool LoadGameBridge(FString& GameBridge); static UApplicationConfig* GetDefaultApplicationConfig(); + static UTransakConfig* GetDefaultTransakConfig(); }; diff --git a/Source/Immutable/Public/Immutable/TransakConfig.h b/Source/Immutable/Public/Immutable/TransakConfig.h new file mode 100644 index 0000000..b998970 --- /dev/null +++ b/Source/Immutable/Public/Immutable/TransakConfig.h @@ -0,0 +1,139 @@ +#pragma once +#include "ImmutableEnums.h" + +#include "TransakConfig.generated.h" + + +UENUM() +enum class ETransakEnvironment : uint8 +{ + Sandbox, + Production, +}; + +/** + * @class UTransakConfig + * @brief Configuration settings for Passport and various APIs. + * @details This class stores configuration settings such as URLs, chain names, contract addresses, + * client IDs, and environment settings for the zkEVM API, Orderbook API, and Passport. + */ +UCLASS(Abstract, Blueprintable, ClassGroup = Immutable) +class UTransakConfig : public UObject +{ + GENERATED_BODY() + +public: + FString GetURL() const + { + switch (Environment) + { + case ETransakEnvironment::Production: + return TEXT("https://global.transak.com/"); + default: + case ETransakEnvironment::Sandbox: + return TEXT("https://global-stg.transak.com/"); + } + } + + FString GetAPIKey() const + { + switch (Environment) + { + case ETransakEnvironment::Production: + return TEXT("ad1bca70-d917-4628-bb0f-5609537498bc"); + default: + case ETransakEnvironment::Sandbox: + return TEXT("d14b44fb-0f84-4db5-affb-e044040d724b"); + } + } + + const FString& GetNetwork() + { + return Network; + } + + const FString& GetDefaultFiatCurrency() + { + return DefaultFiatCurrency; + } + + const FString& GetDefaultFiatAmount() + { + return DefaultFiatAmount; + } + + const FString& GetDefaultCryptoCurrency() + { + return DefaultCryptoCurrency; + } + + const FString& GetDefaultPaymentMethod() + { + return DefaultPaymentMethod; + } + + const TArray& GetDisablePaymentMethods() + { + return DisablePaymentMethods; + } + + bool IsAutoFillUserData() + { + return bIsAutoFillUserData; + } + + bool DisableWalletAddressForm() + { + return bDisableWalletAddressForm; + } + + const TArray& GetCryptoCurrencyList() + { + return CryptoCurrencyList; + } + + const FLinearColor& GetThemeColor() + { + return ThemeColor; + } + +protected: + // UPROPERTY(EditDefaultsOnly, Category = "Transak") + // FString URL; + // + // UPROPERTY(EditDefaultsOnly, Category = "Transak") + // FString APIKey; + + UPROPERTY(EditDefaultsOnly, Category = "General") + ETransakEnvironment Environment = ETransakEnvironment::Sandbox; + + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + FString DefaultPaymentMethod; + + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + FString DefaultFiatCurrency; + + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + FString DefaultFiatAmount; + + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + FString DefaultCryptoCurrency; + + UPROPERTY(EditDefaultsOnly, Category = "Transak") + FString Network; + + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + TArray DisablePaymentMethods; + + UPROPERTY(EditDefaultsOnly, Category = "User") + bool bIsAutoFillUserData = true; + + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + bool bDisableWalletAddressForm = true; + + UPROPERTY(EditDefaultsOnly, Category = "Fiat") + TArray CryptoCurrencyList; + + UPROPERTY(EditDefaultsOnly, Category = "Theme") + FLinearColor ThemeColor; +}; From 03bc8bf37f60b006394abec828d4aa6e8b4a3f30 Mon Sep 17 00:00:00 2001 From: Yermek Garifullanov Date: Thu, 12 Dec 2024 11:28:04 +1300 Subject: [PATCH 2/6] feat: added transak web widget and environment enum --- .../Immutable/Transak/TransakWebBrowser.cpp | 149 ++++++++++++++++++ .../Public/Immutable/ImmutableEnums.h | 10 ++ .../Immutable/Transak/TransakWebBrowser.h | 41 +++++ 3 files changed, 200 insertions(+) create mode 100644 Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp create mode 100644 Source/Immutable/Public/Immutable/ImmutableEnums.h create mode 100644 Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h diff --git a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp new file mode 100644 index 0000000..d6efcd3 --- /dev/null +++ b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp @@ -0,0 +1,149 @@ +#include "Immutable/Transak/TransakWebBrowser.h" + +#include "SWebBrowser.h" +#include "PlatformHttp.h" +#include "Immutable/ImmutableUtilities.h" +#include "Immutable/TransakConfig.h" + + +#define LOCTEXT_NAMESPACE "Immutable" + +FDelegateHandle UTransakWebBrowser::CallAndRegister_OnWhenReady(FOnWhenReady::FDelegate Delegate) +{ + if (bIsReady) + { + Delegate.ExecuteIfBound(); + } + + return OnWhenReady.Add(Delegate); +} + +TSharedRef UTransakWebBrowser::RebuildWidget() +{ + if ( IsDesignTime() ) + { + return SNew(SBox) + .HAlign(HAlign_Center) + .VAlign(VAlign_Center) + [ + SNew(STextBlock) + .Text(LOCTEXT("Transak Web Browser", "Transak Web Browser")) + ]; + } + else + { + WebBrowserWidget = SNew(SWebBrowser) + .InitialURL(TEXT("about:blank")) + .ShowControls(false) + .SupportsTransparency(bSupportsTransparency) + .OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, OnUrlChanged)) + .OnBeforePopup(BIND_UOBJECT_DELEGATE(FOnBeforePopupDelegate, HandleOnBeforePopup)) + .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, HandleOnConsoleMessage)); + + return WebBrowserWidget.ToSharedRef(); + } +} + +void UTransakWebBrowser::OnUrlChanged(const FText& Text) +{ + HandleOnUrlChanged(Text); + + if (Text.EqualToCaseIgnored(FText::FromString(TEXT("about:blank")))) + { + bIsReady = true; + OnWhenReady.Broadcast(); + } +} + +void UTransakWebBrowser::Load(const FString& WalletAddress, const FString& Email, const FString& ProductsAvailed, const FString& ScreenTitle) +{ + if (!WebBrowserWidget.IsValid()) + { + return; + } + + FString UrlToLoad = ComputePath(WalletAddress, Email, ProductsAvailed, ScreenTitle); + + if (bIsReady) + { + WebBrowserWidget->LoadURL(UrlToLoad); + } + else + { + FDelegateHandle OnWhenReadyHandle = CallAndRegister_OnWhenReady(UTransakWebBrowser::FOnWhenReady::FDelegate::CreateWeakLambda(this, [this, UrlToLoad, OnWhenReadyHandle]() + { + WebBrowserWidget->LoadURL(UrlToLoad); + OnWhenReady.Remove(OnWhenReadyHandle); + })); + } +} + +FString UTransakWebBrowser::ComputePath(const FString& WalletAddress, const FString& Email, const FString& ProductsAvailed, const FString& ScreenTitle) +{ + UTransakConfig* TransakConfig = FImmutableUtilities::GetDefaultTransakConfig(); + + if (!TransakConfig) + { + return ""; + } + + FString Path = TransakConfig->GetURL(); + TArray QueryParams; + + QueryParams.Add(FString(TEXT("apiKey=")) + FPlatformHttp::UrlEncode(TransakConfig->GetAPIKey())); + QueryParams.Add(FString(TEXT("email=")) + FPlatformHttp::UrlEncode(Email)); + QueryParams.Add(FString(TEXT("walletAddress=")) + FPlatformHttp::UrlEncode(WalletAddress)); + QueryParams.Add(FString(TEXT("themeColor=")) + FPlatformHttp::UrlEncode(TransakConfig->GetThemeColor().ToString())); + QueryParams.Add(FString(TEXT("isAutoFillUserData=")) + FPlatformHttp::UrlEncode(TransakConfig->IsAutoFillUserData() ? TEXT("true") : TEXT("false"))); + QueryParams.Add(FString(TEXT("disableWalletAddressForm=")) + FPlatformHttp::UrlEncode(TransakConfig->DisableWalletAddressForm() ? TEXT("true") : TEXT("false"))); + + if (!TransakConfig->GetNetwork().IsEmpty()) + { + QueryParams.Add(FString(TEXT("network=")) + FPlatformHttp::UrlEncode(TransakConfig->GetNetwork())); + } + + if (!ProductsAvailed.IsEmpty()) + { + QueryParams.Add(FString(TEXT("productsAvailed=")) + FPlatformHttp::UrlEncode(ProductsAvailed)); + } + + if (!ScreenTitle.IsEmpty()) + { + QueryParams.Add(FString(TEXT("exchangeScreenTitle=")) + FPlatformHttp::UrlEncode(ScreenTitle)); + } + + if (!TransakConfig->GetDefaultCryptoCurrency().IsEmpty()) + { + QueryParams.Add(FString(TEXT("defaultCryptoCurrency=")) + FPlatformHttp::UrlEncode(TransakConfig->GetDefaultCryptoCurrency())); + } + + if (!TransakConfig->GetDefaultFiatAmount().IsEmpty()) + { + QueryParams.Add(FString(TEXT("defaultFiatAmount=")) + FPlatformHttp::UrlEncode(TransakConfig->GetDefaultFiatAmount())); + } + + if (!TransakConfig->GetDefaultFiatCurrency().IsEmpty()) + { + QueryParams.Add(FString(TEXT("defaultFiatCurrency=")) + FPlatformHttp::UrlEncode(TransakConfig->GetDefaultFiatCurrency())); + } + + if (!TransakConfig->GetDefaultPaymentMethod().IsEmpty()) + { + QueryParams.Add(FString(TEXT("defaultPaymentMethod=")) + FPlatformHttp::UrlEncode(TransakConfig->GetDefaultPaymentMethod())); + } + + if (TransakConfig->GetCryptoCurrencyList().Num() > 0) + { + QueryParams.Add(FString(TEXT("cryptoCurrencyList=")) + FPlatformHttp::UrlEncode(FString::Join(TransakConfig->GetCryptoCurrencyList(), TEXT(",")))); + } + + if (TransakConfig->GetDisablePaymentMethods().Num() > 0) + { + QueryParams.Add(FString(TEXT("disablePaymentMethods=")) + FPlatformHttp::UrlEncode(FString::Join(TransakConfig->GetDisablePaymentMethods(), TEXT(",")))); + } + + Path += TEXT("?"); + Path += FString::Join(QueryParams, TEXT("&")); + + return Path; +} diff --git a/Source/Immutable/Public/Immutable/ImmutableEnums.h b/Source/Immutable/Public/Immutable/ImmutableEnums.h new file mode 100644 index 0000000..ebe3fb3 --- /dev/null +++ b/Source/Immutable/Public/Immutable/ImmutableEnums.h @@ -0,0 +1,10 @@ +#pragma once + +UENUM() +enum class EPassportEnvironment : uint8 +{ + Development, + Sandbox, + Production, +}; + diff --git a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h new file mode 100644 index 0000000..3972d81 --- /dev/null +++ b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h @@ -0,0 +1,41 @@ +#pragma once + +#include "CoreMinimal.h" +#include "WebBrowser.h" + +#include "TransakWebBrowser.generated.h" + +/** + * + */ +UCLASS() +class IMMUTABLE_API UTransakWebBrowser : public UWebBrowser +{ + GENERATED_BODY() + +public: + DECLARE_MULTICAST_DELEGATE(FOnWhenReady); + + UFUNCTION(BlueprintCallable) + void Load(const FString& WalletAddress, const FString& Email, const FString& ProductsAvailed, const FString& ScreenTitle); + + bool IsReady() const { return bIsReady; }; + + FDelegateHandle CallAndRegister_OnWhenReady(FOnWhenReady::FDelegate Delegate); + +protected: + // UWidget interface + virtual TSharedRef RebuildWidget() override; + // End of UWidget interface + +private: + FString ComputePath(const FString& WalletAddress, const FString& Email, const FString& ProductsAvailed, const FString& ScreenTitle); + void OnUrlChanged(const FText& Text); + +protected: + FOnWhenReady OnWhenReady; + +private: + bool bIsReady = false; + +}; From efc18e53eb386422b8bdff5725f8b5c79b048f38 Mon Sep 17 00:00:00 2001 From: Yermek Garifullanov Date: Thu, 12 Dec 2024 11:28:24 +1300 Subject: [PATCH 3/6] feat: added missing module --- Source/Immutable/Immutable.Build.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Immutable/Immutable.Build.cs b/Source/Immutable/Immutable.Build.cs index 953881b..3c2bd23 100644 --- a/Source/Immutable/Immutable.Build.cs +++ b/Source/Immutable/Immutable.Build.cs @@ -34,6 +34,7 @@ public Immutable(ReadOnlyTargetRules Target) : base(Target) "UMG", "Projects", "DeveloperSettings", + "HTTP", } ); From a04a6b9f8fe44256acefcb220a1d372ff3dffbb7 Mon Sep 17 00:00:00 2001 From: Yermek Garifullanov Date: Thu, 12 Dec 2024 20:44:50 +1300 Subject: [PATCH 4/6] fix: resolved compile issue with ue4 --- Source/Immutable/Immutable.Build.cs | 4 +++- .../Private/Immutable/Transak/TransakWebBrowser.cpp | 6 ++++-- .../Immutable/Public/Immutable/Transak/TransakWebBrowser.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/Immutable/Immutable.Build.cs b/Source/Immutable/Immutable.Build.cs index 3c2bd23..ded64fd 100644 --- a/Source/Immutable/Immutable.Build.cs +++ b/Source/Immutable/Immutable.Build.cs @@ -19,7 +19,9 @@ public Immutable(ReadOnlyTargetRules Target) : base(Target) new string[] { "Core", - "JsonUtilities", + "JsonUtilities", + "WebBrowser", + "WebBrowserWidget", } ); diff --git a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp index d6efcd3..ecf8b46 100644 --- a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp +++ b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp @@ -38,8 +38,10 @@ TSharedRef UTransakWebBrowser::RebuildWidget() .SupportsTransparency(bSupportsTransparency) .OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, OnUrlChanged)) .OnBeforePopup(BIND_UOBJECT_DELEGATE(FOnBeforePopupDelegate, HandleOnBeforePopup)) - .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, HandleOnConsoleMessage)); - +#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) + .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, HandleOnConsoleMessage)) +#endif + ; return WebBrowserWidget.ToSharedRef(); } } diff --git a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h index 3972d81..e1bdcf9 100644 --- a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h +++ b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h @@ -2,6 +2,7 @@ #include "CoreMinimal.h" #include "WebBrowser.h" +#include "WebBrowser.h" #include "TransakWebBrowser.generated.h" From 560900864d8f2a54558835f481c039c207869019 Mon Sep 17 00:00:00 2001 From: Yermek Garifullanov Date: Fri, 13 Dec 2024 14:06:38 +1300 Subject: [PATCH 5/6] fix: compiler issue with ue4 --- Source/Immutable/Immutable.Build.cs | 2 ++ .../Immutable/Transak/TransakWebBrowser.cpp | 16 +++++++++------- .../Public/Immutable/Transak/TransakWebBrowser.h | 15 +++++++++++---- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Source/Immutable/Immutable.Build.cs b/Source/Immutable/Immutable.Build.cs index ded64fd..a9079a6 100644 --- a/Source/Immutable/Immutable.Build.cs +++ b/Source/Immutable/Immutable.Build.cs @@ -20,8 +20,10 @@ public Immutable(ReadOnlyTargetRules Target) : base(Target) { "Core", "JsonUtilities", +#if UE_5_1_OR_LATER "WebBrowser", "WebBrowserWidget", +#endif } ); diff --git a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp index ecf8b46..7d6d64d 100644 --- a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp +++ b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp @@ -1,6 +1,5 @@ #include "Immutable/Transak/TransakWebBrowser.h" -#include "SWebBrowser.h" #include "PlatformHttp.h" #include "Immutable/ImmutableUtilities.h" #include "Immutable/TransakConfig.h" @@ -32,24 +31,23 @@ TSharedRef UTransakWebBrowser::RebuildWidget() } else { +#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) WebBrowserWidget = SNew(SWebBrowser) .InitialURL(TEXT("about:blank")) .ShowControls(false) .SupportsTransparency(bSupportsTransparency) .OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, OnUrlChanged)) .OnBeforePopup(BIND_UOBJECT_DELEGATE(FOnBeforePopupDelegate, HandleOnBeforePopup)) -#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) - .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, HandleOnConsoleMessage)) -#endif - ; + .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, HandleOnConsoleMessage)); return WebBrowserWidget.ToSharedRef(); +#else + return SNullWidget::NullWidget; +#endif } } void UTransakWebBrowser::OnUrlChanged(const FText& Text) { - HandleOnUrlChanged(Text); - if (Text.EqualToCaseIgnored(FText::FromString(TEXT("about:blank")))) { bIsReady = true; @@ -68,13 +66,17 @@ void UTransakWebBrowser::Load(const FString& WalletAddress, const FString& Email if (bIsReady) { +#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) WebBrowserWidget->LoadURL(UrlToLoad); +#endif } else { FDelegateHandle OnWhenReadyHandle = CallAndRegister_OnWhenReady(UTransakWebBrowser::FOnWhenReady::FDelegate::CreateWeakLambda(this, [this, UrlToLoad, OnWhenReadyHandle]() { +#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) WebBrowserWidget->LoadURL(UrlToLoad); +#endif OnWhenReady.Remove(OnWhenReadyHandle); })); } diff --git a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h index e1bdcf9..c4dbedc 100644 --- a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h +++ b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h @@ -1,8 +1,10 @@ #pragma once -#include "CoreMinimal.h" -#include "WebBrowser.h" -#include "WebBrowser.h" +#include "Components/Widget.h" + +#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) +#include "SWebBrowser.h" +#endif #include "TransakWebBrowser.generated.h" @@ -10,7 +12,7 @@ * */ UCLASS() -class IMMUTABLE_API UTransakWebBrowser : public UWebBrowser +class IMMUTABLE_API UTransakWebBrowser : public UWidget { GENERATED_BODY() @@ -34,6 +36,11 @@ class IMMUTABLE_API UTransakWebBrowser : public UWebBrowser void OnUrlChanged(const FText& Text); protected: +#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) + TSharedPtr WebBrowserWidget; +#else + TSharedPtr WebBrowserWidget; +#endif FOnWhenReady OnWhenReady; private: From 5d92e40d9ae4ef0048c8f82ebbd925142bb551b1 Mon Sep 17 00:00:00 2001 From: Yermek Garifullanov Date: Fri, 13 Dec 2024 15:20:23 +1300 Subject: [PATCH 6/6] chore: isolated source code for ue5 --- .../Immutable/Transak/TransakWebBrowser.cpp | 19 ++++++++++++++++--- .../Immutable/Transak/TransakWebBrowser.h | 7 ++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp index 7d6d64d..3f417d8 100644 --- a/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp +++ b/Source/Immutable/Private/Immutable/Transak/TransakWebBrowser.cpp @@ -3,6 +3,7 @@ #include "PlatformHttp.h" #include "Immutable/ImmutableUtilities.h" #include "Immutable/TransakConfig.h" +#include "Immutable/Misc/ImtblLogging.h" #define LOCTEXT_NAMESPACE "Immutable" @@ -35,8 +36,8 @@ TSharedRef UTransakWebBrowser::RebuildWidget() WebBrowserWidget = SNew(SWebBrowser) .InitialURL(TEXT("about:blank")) .ShowControls(false) - .SupportsTransparency(bSupportsTransparency) - .OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, OnUrlChanged)) + .SupportsTransparency(false) + .OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnUrlChanged)) .OnBeforePopup(BIND_UOBJECT_DELEGATE(FOnBeforePopupDelegate, HandleOnBeforePopup)) .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, HandleOnConsoleMessage)); return WebBrowserWidget.ToSharedRef(); @@ -46,7 +47,8 @@ TSharedRef UTransakWebBrowser::RebuildWidget() } } -void UTransakWebBrowser::OnUrlChanged(const FText& Text) +#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) +void UTransakWebBrowser::HandleOnUrlChanged(const FText& Text) { if (Text.EqualToCaseIgnored(FText::FromString(TEXT("about:blank")))) { @@ -55,6 +57,17 @@ void UTransakWebBrowser::OnUrlChanged(const FText& Text) } } +void UTransakWebBrowser::HandleOnConsoleMessage(const FString& Message, const FString& Source, int32 Line, EWebBrowserConsoleLogSeverity Severity) +{ + IMTBL_LOG("Transak Web Browser console message: %s, Source: %s, Line: %d", *Message, *Source, Line); +} + +bool UTransakWebBrowser::HandleOnBeforePopup(FString URL, FString Frame) +{ + return false; +} +#endif + void UTransakWebBrowser::Load(const FString& WalletAddress, const FString& Email, const FString& ProductsAvailed, const FString& ScreenTitle) { if (!WebBrowserWidget.IsValid()) diff --git a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h index c4dbedc..7dcdb30 100644 --- a/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h +++ b/Source/Immutable/Public/Immutable/Transak/TransakWebBrowser.h @@ -33,7 +33,12 @@ class IMMUTABLE_API UTransakWebBrowser : public UWidget private: FString ComputePath(const FString& WalletAddress, const FString& Email, const FString& ProductsAvailed, const FString& ScreenTitle); - void OnUrlChanged(const FText& Text); + +#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1) + void HandleOnConsoleMessage(const FString& Message, const FString& Source, int32 Line, EWebBrowserConsoleLogSeverity Severity); + void HandleOnUrlChanged(const FText& Text); + bool HandleOnBeforePopup(FString URL, FString Frame); +#endif protected: #if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1)