Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Social login and migration to ecosystem wallets #12

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ Plugins/*/Intermediate/*
# Cache files for the editor to use
DerivedDataCache/*
LocalDerivedDataCache/*

#Thirdweb Plugin
Plugins/Thirdweb/*
4 changes: 4 additions & 0 deletions Config/DefaultEditor.ini

Large diffs are not rendered by default.

32 changes: 27 additions & 5 deletions Config/DefaultEngine.ini
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,36 @@ bUseManualIPAddress=False
ManualIPAddress=

[/Script/TDKCommon.TDKRuntimeSettings]
Env=DEV
CartridgeTag=harness
CartridgeName=TDK Harness
ProdApiUrl="https://tdk-api.treasure.lol"
DevApiUrl="https://tdk-api.spellcaster.lol"
ClientId=d5abed6dd83664090303541ae02a4542
EcosystemId=ecosystem.treasure-dev
EcosystemPartnerId=0e5db500-9317-4c9b-a49e-2cd5ea48af7e
DevApiKey=
ProdApiKey=
FactoryAddress=0x463effb51873c7720c810ac7fb2e145ec2f8cc60
DevChainId=421614
ProdChainId=42161
SessionDurationSec=86400
SessionMinDurationLeftSec=3600
ChainIdentifier=arbitrum-sepolia
BackendWallet=0xae093efa5651ba216feb2082a2d4bb8da5f425f2
+CallTargets=0x55d0cf68a1afe0932aff6f36c87efa703508191c
+CallTargets=0xa8654a8097b78daf740c1e2ada8a6bf3cd60da50
+CallTargets=0xfe592736200d7545981397ca7a8e896ac0c166d4
+CallTargets=0xe647b2c46365741e85268ced243113d08f7e00b8
NativeTokenLimitPerTransaction=1
DevAnalyticsApiUrl="https://darkmatter.spellcaster.lol/ingress"
ProdAnalyticsApiUrl="https://darkmatter.treasure.lol/ingress"
DevClientId=e521f021ac8ac00473cc1a41001dc4a8
ProdClientId=3098f205cbb932cb31d8cf63fb482a0e
ApiKey=83H5QJcrjrYkzT62DStgp5
LauncherApiUrl="http://localhost:16001"

[/Script/Thirdweb.ThirdwebRuntimeSettings]
ClientID=7e7c070be896e27ffd5352e264df9bcc
BundleID=com.thirdweb.unitysdk
ClientId=d5abed6dd83664090303541ae02a4542
BundleId=com.treasure.tdkunity
EcosystemId=
PartnerId=
bSendAnalytics=False

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Plugins/TDK/Content/TDK/UMG/WB_TDK.uasset
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Plugins/TDK/Source/TDK/Private/TDKAnalyticsAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void UTDKAnalyticsAPI::Activate()

if (bUseApiKey)
{
FString AuthValue = CallAuthenticationContext != nullptr ? CallAuthenticationContext->GetApiKey() : GetDefault<UTDKRuntimeSettings>()->ApiKey;
FString AuthValue = CallAuthenticationContext != nullptr ? CallAuthenticationContext->GetApiKey() : GetDefault<UTDKRuntimeSettings>()->GetApiKey();
if (!AuthValue.IsEmpty())
{
HttpRequest->SetHeader(TEXT("x-api-key"), AuthValue);
Expand Down
14 changes: 14 additions & 0 deletions Plugins/TDK/Source/TDK/Private/TDKWidgetConnectModal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "TDKWidgetConnectModal.h"

bool UTDKWidgetConnectModal::IsWalletConnect_Implementation()
{
return IsConnected;
}

void UTDKWidgetConnectModal::Disconnect_Implementation()
{
IsConnected = false;
}
27 changes: 27 additions & 0 deletions Plugins/TDK/Source/TDK/Public/TDKWidgetConnectModal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "TDKWidgetConnectModal.generated.h"

/**
*
*/
UCLASS()
class TDK_API UTDKWidgetConnectModal : public UUserWidget
{
GENERATED_BODY()

protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Status")
bool IsConnected;

public:
UFUNCTION(BlueprintNativeEvent, BlueprintPure, Category = "Status")
bool IsWalletConnect();

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Status")
void Disconnect();
};
3 changes: 2 additions & 1 deletion Plugins/TDK/Source/TDK/TDK.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public TDK(ReadOnlyTargetRules Target) : base(Target)
"Json",
"JsonUtilities",
"TDKCommon",
"TDKCpp"
"TDKCpp",
"UMG"
}
);
}
Expand Down
54 changes: 54 additions & 0 deletions Plugins/TDK/Source/TDKCommon/Private/TDKBlueprintUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Fill out your copyright notice in the Description page of Project Settings.


#include "TDKBlueprintUtils.h"

#include "Runtime/ApplicationCore/Public/HAL/PlatformApplicationMisc.h"

#include <regex>

#include "TDKRuntimeSettings.h"

bool UTDKBlueprintUtils::IsEmailValid(const FString& email)
{
// define a regular expression
const std::regex pattern
("(\\w+)(\\.|_)?(\\w*)@(\\w+)(\\.(\\w+))+");
// try to match the string with the regular expression
return std::regex_match(TCHAR_TO_UTF8(*email), pattern);
}

void UTDKBlueprintUtils::CopyText(const FString& text)
{
FPlatformApplicationMisc::ClipboardCopy(*text);
}

FString UTDKBlueprintUtils::GetCartridgeName()
{
UTDKRuntimeSettings* Settings = GetMutableDefault<UTDKRuntimeSettings>();
return Settings->CartridgeName;
}

FString UTDKBlueprintUtils::GetEcosystemPartnerId()
{
UTDKRuntimeSettings* Settings = GetMutableDefault<UTDKRuntimeSettings>();
return Settings->EcosystemPartnerId;
}

UTexture2D* UTDKBlueprintUtils::GetCartridgeIcon()
{
UTDKRuntimeSettings* Settings = GetMutableDefault<UTDKRuntimeSettings>();
return Settings->CartridgeIcon;
}

FString UTDKBlueprintUtils::GetFactoryAddress()
{
UTDKRuntimeSettings* Settings = GetMutableDefault<UTDKRuntimeSettings>();
return Settings->FactoryAddress;
}

int64 UTDKBlueprintUtils::GetChainId()
{
UTDKRuntimeSettings* Settings = GetMutableDefault<UTDKRuntimeSettings>();
return Settings->GetChainId();
}
33 changes: 28 additions & 5 deletions Plugins/TDK/Source/TDKCommon/Private/TDKRuntimeSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@
#include "TDKRuntimeSettings.h"

UTDKRuntimeSettings::UTDKRuntimeSettings() :
CartridgeTag(TEXT("")),
DevAnalyticsApiUrl(TEXT("")),
ProdAnalyticsApiUrl(TEXT("")),
ApiKey(TEXT("")),
CartridgeTag(TEXT("harness")),
CartridgeName(TEXT("TDK Harness")),
ProdApiUrl(TEXT("https://tdk-api.treasure.lol")),
DevApiUrl(TEXT("https://tdk-api.spellcaster.lol")),
EcosystemId(TEXT("ecosystem.treasure")),
DevChainId(421614),
ProdChainId(42161),
SessionDurationSec(86400),
SessionMinDurationLeftSec(3600),
DevAnalyticsApiUrl(TEXT("https://darkmatter.spellcaster.lol/ingress")),
ProdAnalyticsApiUrl(TEXT("https://darkmatter.treasure.lol/ingress")),
LauncherApiUrl(TEXT("http://localhost:16001"))
{

CartridgeIcon = LoadObject<UTexture2D>(nullptr, TEXT("Texture2D'/TDK/TDK/Texture/Icon/T_Icon_Profile_Logo.T_Icon_Profile_Logo'"));
}

FString UTDKRuntimeSettings::GetAnalyticsApiUrl() const
Expand All @@ -21,7 +28,23 @@ FString UTDKRuntimeSettings::GetAnalyticsApiUrl() const
return ProdAnalyticsApiUrl;
}

FString UTDKRuntimeSettings::GetApiKey() const
{
if (Env == EEnv::DEV)
return DevApiKey;
else
return ProdApiKey;
}

FString UTDKRuntimeSettings::GetLauncherApiUrl() const
{
return LauncherApiUrl;
}

int64 UTDKRuntimeSettings::GetChainId() const
{
if (Env == EEnv::DEV)
return DevChainId;
else
return ProdChainId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TDKCOMMON_API UTDKAuthenticationContext : public UObject
public:
UTDKAuthenticationContext()
{
ApiKey = GetDefault<UTDKRuntimeSettings>()->ApiKey;
ApiKey = GetDefault<UTDKRuntimeSettings>()->GetApiKey();
}

// Get the API key. These keys can be used in request authentication.
Expand Down
38 changes: 38 additions & 0 deletions Plugins/TDK/Source/TDKCommon/Public/TDKBlueprintUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "TDKBlueprintUtils.generated.h"

/**
*
*/
UCLASS()
class TDKCOMMON_API UTDKBlueprintUtils : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

public:
UFUNCTION(BlueprintPure)
static bool IsEmailValid(const FString& email);

UFUNCTION(BlueprintCallable)
static void CopyText(const FString& text);

UFUNCTION(BlueprintPure)
static FString GetCartridgeName();

UFUNCTION(BlueprintPure)
static FString GetEcosystemPartnerId();

UFUNCTION(BlueprintPure)
static UTexture2D* GetCartridgeIcon();

UFUNCTION(BlueprintPure)
static FString GetFactoryAddress();

UFUNCTION(BlueprintPure)
static int64 GetChainId();
};
90 changes: 74 additions & 16 deletions Plugins/TDK/Source/TDKCommon/Public/TDKRuntimeSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,92 @@ class TDKCOMMON_API UTDKRuntimeSettings : public UObject
public:
UTDKRuntimeSettings();

// ---------- TDK Config
UPROPERTY(EditAnywhere, config, Category = TDK)
// ---------------- General ----------------- //

UPROPERTY(EditAnywhere, config, Category = General)
TEnumAsByte<EEnv> Env;

UPROPERTY(EditAnywhere, config, Category = TDK)
UPROPERTY(EditAnywhere, config, Category = General)
FString CartridgeTag;

UPROPERTY(EditAnywhere, config, Category = TDK)

UPROPERTY(EditAnywhere, config, Category = General)
FString CartridgeName;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = General)
UTexture2D* CartridgeIcon;

UPROPERTY(EditAnywhere, config, Category = General)
FString ProdApiUrl;

UPROPERTY(EditAnywhere, config, Category = General)
FString DevApiUrl;

UPROPERTY(EditAnywhere, config, Category = General)
FString ClientId;

UPROPERTY(EditAnywhere, config, Category = General)
FString EcosystemId;

UPROPERTY(EditAnywhere, config, Category = General)
FString EcosystemPartnerId;

UPROPERTY(EditAnywhere, config, Category = General)
FString DevApiKey;

UPROPERTY(EditAnywhere, config, Category = General)
FString ProdApiKey;


// ----------------- Connect ------------------- //

UPROPERTY(EditAnywhere, config, Category = Connect)
FString FactoryAddress;

UPROPERTY(EditAnywhere, config, Category = Connect)
int64 DevChainId;

UPROPERTY(EditAnywhere, config, Category = Connect)
int64 ProdChainId;

UPROPERTY(EditAnywhere, config, Category = Connect)
int32 SessionDurationSec;

UPROPERTY(EditAnywhere, config, Category = Connect)
int32 SessionMinDurationLeftSec;

UPROPERTY(EditAnywhere, config, Category = "Connect|SessionOptions")
FString ChainIdentifier;

UPROPERTY(EditAnywhere, config, Category = "Connect|SessionOptions")
FString BackendWallet;

UPROPERTY(EditAnywhere, config, Category = "Connect|SessionOptions")
TArray<FString> CallTargets;

UPROPERTY(EditAnywhere, config, Category = "Connect|SessionOptions")
FString NativeTokenLimitPerTransaction;


// ---------------- Analytics ------------------- //

UPROPERTY(EditAnywhere, config, Category = Analytics)
FString DevAnalyticsApiUrl;

UPROPERTY(EditAnywhere, config, Category = TDK)
UPROPERTY(EditAnywhere, config, Category = Analytics)
FString ProdAnalyticsApiUrl;

UPROPERTY(EditAnywhere, config, Category = TDK)
FString ApiKey;

UPROPERTY(EditAnywhere, config, Category = TDK)
FString LauncherApiUrl;

// ---------- Third-Web Config
UPROPERTY(EditAnywhere, config, Category = ThirdWeb)
FString DevClientId;
// ---------------- Launcher ------------------- //

UPROPERTY(EditAnywhere, config, Category = ThirdWeb)
FString ProdClientId;
UPROPERTY(EditAnywhere, config, Category = Launcher)
FString LauncherApiUrl;

public:
FString GetAnalyticsApiUrl() const;

FString GetApiKey() const;

FString GetLauncherApiUrl() const;

int64 GetChainId() const;
};
1 change: 1 addition & 0 deletions Plugins/TDK/Source/TDKCommon/TDKCommon.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public TDKCommon(ReadOnlyTargetRules Target) : base(Target)
"HTTP",
"Json",
"JsonUtilities",
"ApplicationCore"
}
);

Expand Down
4 changes: 2 additions & 2 deletions Plugins/TDK/Source/TDKCpp/Private/Core/TDKAnalyticsAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool UTDKAnalyticsAPI::TrackCustom(FString EvtName, TMap<FString, FString> EvtPr

bool UTDKAnalyticsAPI::SendEvent(AnalyticsModels::FSendEventRequest Request, const FSendEventBatchDelegate& SuccessDelegate, const FTDKErrorDelegate& ErrorDelegate)
{
FString AuthValue = Request.AuthenticationContext.IsValid() ? Request.AuthenticationContext->GetApiKey() : GetDefault<UTDKRuntimeSettings>()->ApiKey;
FString AuthValue = Request.AuthenticationContext.IsValid() ? Request.AuthenticationContext->GetApiKey() : GetDefault<UTDKRuntimeSettings>()->GetApiKey();

FString Payload = Request.toJSONString();
if (Payload.StartsWith(TEXT("{")))
Expand Down Expand Up @@ -84,7 +84,7 @@ void UTDKAnalyticsAPI::OnSendEventBatchResult(FHttpRequestPtr HttpRequest, FHttp
UE_LOG(LogTDKCpp, Warning, TEXT("Header Request: %s"), *Header);
}*/

UE_LOG(LogTDKCpp, Warning, TEXT("Response: %s %d"), *HttpResponse->GetContentAsString(), HttpResponse->GetResponseCode());
//UE_LOG(LogTDKCpp, Warning, TEXT("Response: %s %d"), *HttpResponse->GetContentAsString(), HttpResponse->GetResponseCode());

AnalyticsModels::FSendEventResponse OutResult;
FTDKCppError ErrorResult;
Expand Down
Loading