Skip to content

Commit a9f4b0f

Browse files
v1.7.0 (#14)
* Mask sensitive strings in logging * Reduce inputs on CreateSessionKey * Fix Formatting string on Read Contract * Add JSI-bound custom tabs to fix android external auth * Migrate ParterID to global configuration, removing from all nodes * Add Get Transaction Status and Get Transaction Receipt nodes * Add Blueprint Screenshot Debug Functionality to Editor Toolbar as Button
1 parent b628e31 commit a9f4b0f

File tree

77 files changed

+2691
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2691
-729
lines changed

Resources/ScreenshotIcon.svg

Lines changed: 11 additions & 0 deletions
Loading
File renamed without changes.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) 2024 Thirdweb. All Rights Reserved.
2+
3+
#include "AsyncTasks/Engine/AsyncTaskThirdwebEngineGetTransactionReceipt.h"
4+
5+
#include "HttpModule.h"
6+
#include "ThirdwebLog.h"
7+
#include "ThirdwebRuntimeSettings.h"
8+
#include "ThirdwebUtils.h"
9+
10+
#include "Dom/JsonObject.h"
11+
12+
#include "Engine/ThirdwebEngineTransactionReceipt.h"
13+
14+
#include "Interfaces/IHttpResponse.h"
15+
16+
#include "Kismet/KismetStringLibrary.h"
17+
18+
#include "Serialization/JsonReader.h"
19+
#include "Serialization/JsonSerializer.h"
20+
21+
UAsyncTaskThirdwebEngineGetTransactionReceipt* UAsyncTaskThirdwebEngineGetTransactionReceipt::GetTransactionReceipt(UObject* WorldContextObject, const FString& TxHash, const int64 ChainID)
22+
{
23+
if (!WorldContextObject)
24+
{
25+
return nullptr;
26+
}
27+
NEW_TASK
28+
Task->TransactionHash = TxHash;
29+
Task->ChainId = ChainID;
30+
RR_TASK
31+
}
32+
33+
void UAsyncTaskThirdwebEngineGetTransactionReceipt::Activate()
34+
{
35+
const TSharedRef<IHttpRequest> Request = ThirdwebUtils::Internal::CreateEngineRequest();
36+
Request->SetURL(FString::Printf(TEXT("%s/transaction/%lld/tx-hash/%s"), *UThirdwebRuntimeSettings::GetEngineBaseUrl(), ChainId, *TransactionHash));
37+
ThirdwebUtils::Internal::LogRequest(Request, {UThirdwebRuntimeSettings::GetEngineAccessToken()});
38+
Request->OnProcessRequestComplete().BindUObject(this, &ThisClass::HandleResponse);
39+
Request->ProcessRequest();
40+
}
41+
42+
void UAsyncTaskThirdwebEngineGetTransactionReceipt::HandleResponse(FHttpRequestPtr, FHttpResponsePtr Response, bool bConnectedSuccessfully)
43+
{
44+
if (bConnectedSuccessfully)
45+
{
46+
FString Content = Response->GetContentAsString();
47+
TW_LOG(Verbose, TEXT("UAsyncTaskThirdwebEngineGetTransactionReceipt::HandleResponse::Content=%s"), *Content)
48+
FString Error;
49+
if (TSharedPtr<FJsonObject> JsonObject; ThirdwebUtils::Json::ParseEngineResponse(Content, JsonObject, Error))
50+
{
51+
Success.Broadcast(FThirdwebEngineTransactionReceipt::FromJson(JsonObject), TEXT(""));
52+
SetReadyToDestroy();
53+
}
54+
else return HandleFailed(Error);
55+
}
56+
else return HandleFailed(TEXT("Network connection failed"));
57+
}
58+
59+
void UAsyncTaskThirdwebEngineGetTransactionReceipt::HandleFailed(const FString& Error)
60+
{
61+
Failed.Broadcast(FThirdwebEngineTransactionReceipt(), Error);
62+
SetReadyToDestroy();
63+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright (c) 2024 Thirdweb. All Rights Reserved.
2+
3+
#include "AsyncTasks/Engine/AsyncTaskThirdwebEngineGetTransactionStatus.h"
4+
5+
#include "HttpModule.h"
6+
#include "ThirdwebLog.h"
7+
#include "ThirdwebRuntimeSettings.h"
8+
#include "ThirdwebUtils.h"
9+
10+
#include "Dom/JsonObject.h"
11+
12+
#include "Engine/ThirdwebEngineTransactionStatusResult.h"
13+
14+
#include "Interfaces/IHttpResponse.h"
15+
16+
#include "Kismet/KismetStringLibrary.h"
17+
18+
#include "Serialization/JsonReader.h"
19+
#include "Serialization/JsonSerializer.h"
20+
21+
UAsyncTaskThirdwebEngineGetTransactionStatus* UAsyncTaskThirdwebEngineGetTransactionStatus::GetTransactionStatus(UObject* WorldContextObject, const FString& QueueID)
22+
{
23+
if (!WorldContextObject)
24+
{
25+
return nullptr;
26+
}
27+
NEW_TASK
28+
Task->QueueId = QueueID;
29+
RR_TASK
30+
}
31+
32+
void UAsyncTaskThirdwebEngineGetTransactionStatus::Activate()
33+
{
34+
const TSharedRef<IHttpRequest> Request = ThirdwebUtils::Internal::CreateEngineRequest();
35+
Request->SetURL(FString::Printf(TEXT("%s/transaction/status/%s"), *UThirdwebRuntimeSettings::GetEngineBaseUrl(), *QueueId));
36+
ThirdwebUtils::Internal::LogRequest(Request, {UThirdwebRuntimeSettings::GetEngineAccessToken()});
37+
Request->OnProcessRequestComplete().BindUObject(this, &ThisClass::HandleResponse);
38+
Request->ProcessRequest();
39+
}
40+
41+
void UAsyncTaskThirdwebEngineGetTransactionStatus::HandleResponse(FHttpRequestPtr, FHttpResponsePtr Response, bool bConnectedSuccessfully)
42+
{
43+
if (bConnectedSuccessfully)
44+
{
45+
FString Content = Response->GetContentAsString();
46+
TW_LOG(Verbose, TEXT("UAsyncTaskThirdwebEngineGetTransactionStatus::HandleResponse::Content=%s"), *Content)
47+
FString Error;
48+
if (TSharedPtr<FJsonObject> JsonObject; ThirdwebUtils::Json::ParseEngineResponse(Content, JsonObject, Error))
49+
{
50+
Success.Broadcast(FThirdwebEngineTransactionStatusResult::FromJson(JsonObject), TEXT(""));
51+
SetReadyToDestroy();
52+
}
53+
else return HandleFailed(Error);
54+
}
55+
else return HandleFailed(TEXT("Network connection failed"));
56+
}
57+
58+
void UAsyncTaskThirdwebEngineGetTransactionStatus::HandleFailed(const FString& Error)
59+
{
60+
Failed.Broadcast(FThirdwebEngineTransactionStatusResult(), Error);
61+
SetReadyToDestroy();
62+
}

Source/Thirdweb/Private/AsyncTasks/Engine/AsyncTaskThirdwebEngineReadContract.cpp

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@
77
#include "ThirdwebRuntimeSettings.h"
88
#include "ThirdwebUtils.h"
99

10-
#include "Dom/JsonObject.h"
11-
1210
#include "Interfaces/IHttpResponse.h"
1311

1412
#include "Kismet/KismetStringLibrary.h"
1513

16-
#include "Serialization/JsonReader.h"
17-
#include "Serialization/JsonSerializer.h"
18-
1914
UAsyncTaskThirdwebEngineReadContract* UAsyncTaskThirdwebEngineReadContract::ReadContract(
2015
UObject* WorldContextObject,
2116
const int64 ChainId,
@@ -39,11 +34,7 @@ UAsyncTaskThirdwebEngineReadContract* UAsyncTaskThirdwebEngineReadContract::Read
3934

4035
void UAsyncTaskThirdwebEngineReadContract::Activate()
4136
{
42-
FHttpModule& HttpModule = FHttpModule::Get();
43-
const TSharedRef<IHttpRequest> Request = HttpModule.CreateRequest();
44-
Request->SetVerb(TEXT("GET"));
45-
Request->SetHeader("Content-Type", TEXT("application/json"));
46-
Request->SetHeader("authorization", TEXT("Bearer ") + UThirdwebRuntimeSettings::GetEngineAccessToken());
37+
const TSharedRef<IHttpRequest> Request = ThirdwebUtils::Internal::CreateEngineRequest();
4738
Request->SetURL(
4839
FString::Format(
4940
TEXT("{0}/contract/{1}/{2}/read?functionName={3}{4}"),
@@ -52,12 +43,11 @@ void UAsyncTaskThirdwebEngineReadContract::Activate()
5243
FString::Printf(TEXT("%lld"), ChainId),
5344
ContractAddress,
5445
FunctionName,
55-
Args.Num() > 0 ? TEXT("&args={0}") + UKismetStringLibrary::JoinStringArray(Args, TEXT(",")) : TEXT("")
46+
Args.Num() > 0 ? TEXT("&args=") + UKismetStringLibrary::JoinStringArray(Args, TEXT(",")) : TEXT("")
5647
}
5748
)
5849
);
5950
ThirdwebUtils::Internal::LogRequest(Request, {UThirdwebRuntimeSettings::GetEngineAccessToken()});
60-
Request->SetTimeout(30.0f);
6151
Request->OnProcessRequestComplete().BindUObject(this, &ThisClass::HandleResponse);
6252
Request->ProcessRequest();
6353
}
@@ -68,24 +58,13 @@ void UAsyncTaskThirdwebEngineReadContract::HandleResponse(FHttpRequestPtr, FHttp
6858
{
6959
FString Content = Response->GetContentAsString();
7060
TW_LOG(Verbose, TEXT("UAsyncTaskThirdwebEngineReadContract::HandleResponse::Content=%s"), *Content)
71-
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject);
72-
const TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Content);
73-
FJsonSerializer::Deserialize(Reader, JsonObject);
74-
if (JsonObject.IsValid())
61+
FString Error;
62+
if (TSharedPtr<FJsonObject> JsonObject; ThirdwebUtils::Json::ParseEngineResponse(Content, JsonObject, Error))
7563
{
76-
if (JsonObject->HasTypedField<EJson::String>(TEXT("error")))
77-
{
78-
FString Error = TEXT("Unknown Error");
79-
if (JsonObject->HasTypedField<EJson::String>(TEXT("message")))
80-
{
81-
Error = JsonObject->GetStringField(TEXT("message"));
82-
}
83-
return HandleFailed(Error);
84-
}
8564
Success.Broadcast(Content, TEXT(""));
8665
SetReadyToDestroy();
8766
}
88-
else return HandleFailed(TEXT("Invalid Response"));
67+
else return HandleFailed(Error);
8968
}
9069
else return HandleFailed(TEXT("Network connection failed"));
9170
}

Source/Thirdweb/Private/AsyncTasks/Engine/AsyncTaskThirdwebEngineWriteContract.cpp

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,6 @@
1313

1414
#include "Kismet/KismetStringLibrary.h"
1515

16-
TSharedPtr<FJsonObject> FThirdwebTransactionOverrides::ToJson() const
17-
{
18-
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject);
19-
if (Gas > 0)
20-
{
21-
JsonObject->SetStringField(TEXT("gas"), FString::Printf(TEXT("%lld"), Gas));
22-
}
23-
if (MaxFeePerGas > 0)
24-
{
25-
JsonObject->SetStringField(TEXT("maxFeePerGas"), FString::Printf(TEXT("%lld"), MaxFeePerGas));
26-
}
27-
if (MaxPriorityFeePerGas > 0)
28-
{
29-
JsonObject->SetStringField(TEXT("maxPriorityFeePerGas"), FString::Printf(TEXT("%lld"), MaxPriorityFeePerGas));
30-
}
31-
if (Value > 0)
32-
{
33-
JsonObject->SetStringField(TEXT("value"), FString::Printf(TEXT("%lld"), Value));
34-
}
35-
return JsonObject;
36-
}
37-
3816
UAsyncTaskThirdwebEngineWriteContract* UAsyncTaskThirdwebEngineWriteContract::WriteContract(
3917
UObject* WorldContextObject,
4018
const int64 ChainId,
@@ -45,7 +23,7 @@ UAsyncTaskThirdwebEngineWriteContract* UAsyncTaskThirdwebEngineWriteContract::Wr
4523
const FString& IdempotencyKey,
4624
const FString& FunctionName,
4725
const TArray<FString>& Args,
48-
const FThirdwebTransactionOverrides& TxOverrides,
26+
const FThirdwebEngineTransactionOverrides& TxOverrides,
4927
const FString& Abi,
5028
const bool bSimulateTx)
5129
{
@@ -71,11 +49,7 @@ UAsyncTaskThirdwebEngineWriteContract* UAsyncTaskThirdwebEngineWriteContract::Wr
7149

7250
void UAsyncTaskThirdwebEngineWriteContract::Activate()
7351
{
74-
FHttpModule& HttpModule = FHttpModule::Get();
75-
const TSharedRef<IHttpRequest> Request = HttpModule.CreateRequest();
76-
Request->SetVerb(TEXT("POST"));
77-
Request->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
78-
Request->SetHeader(TEXT("authorization"), TEXT("Bearer ") + UThirdwebRuntimeSettings::GetEngineAccessToken());
52+
const TSharedRef<IHttpRequest> Request = ThirdwebUtils::Internal::CreateEngineRequest(TEXT("POST"));
7953
Request->SetHeader(TEXT("x-backend-wallet-address"), BackendWalletAddress);
8054
if (!IdempotencyKey.IsEmpty())
8155
{
@@ -120,7 +94,6 @@ void UAsyncTaskThirdwebEngineWriteContract::Activate()
12094
)
12195
);
12296
ThirdwebUtils::Internal::LogRequest(Request, {UThirdwebRuntimeSettings::GetEngineAccessToken()});
123-
Request->SetTimeout(30.0f);
12497
Request->OnProcessRequestComplete().BindUObject(this, &ThisClass::HandleResponse);
12598
Request->ProcessRequest();
12699
}
@@ -130,18 +103,10 @@ void UAsyncTaskThirdwebEngineWriteContract::HandleResponse(FHttpRequestPtr, FHtt
130103
if (bConnectedSuccessfully)
131104
{
132105
const FString Content = Response->GetContentAsString();
133-
if (TSharedPtr<FJsonObject> JsonObject = ThirdwebUtils::Json::ToJson(Content); JsonObject.IsValid())
106+
TW_LOG(Verbose, TEXT("UAsyncTaskThirdwebEngineWriteContract::HandleResponse::Content=%s"), *Content)
107+
FString Error;
108+
if (TSharedPtr<FJsonObject> JsonObject; ThirdwebUtils::Json::ParseEngineResponse(Content, JsonObject, Error))
134109
{
135-
TW_LOG(Verbose, TEXT("UAsyncTaskThirdwebEngineWriteContract::HandleResponse::Content=%s"), *Content)
136-
if (JsonObject->HasTypedField<EJson::String>(TEXT("error")))
137-
{
138-
FString Error = TEXT("Unknown Error");
139-
if (JsonObject->HasTypedField<EJson::String>(TEXT("message")))
140-
{
141-
Error = JsonObject->GetStringField(TEXT("message"));
142-
}
143-
return HandleFailed(Error);
144-
}
145110
FString QueueId = TEXT("Unknown");
146111
if (JsonObject->HasTypedField<EJson::String>(TEXT("queueId")))
147112
{
@@ -150,7 +115,7 @@ void UAsyncTaskThirdwebEngineWriteContract::HandleResponse(FHttpRequestPtr, FHtt
150115
Success.Broadcast(QueueId, TEXT(""));
151116
SetReadyToDestroy();
152117
}
153-
else return HandleFailed(TEXT("Invalid Response"));
118+
else return HandleFailed(Error);
154119
}
155120
else return HandleFailed(TEXT("Network connection failed"));
156121
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
// Copyright (c) 2024 Thirdweb. All Rights Reserved.
22

33
#include "AsyncTasks/Wallets/InApp/Create/AsyncTaskThirdwebCreateAuthEndpointWallet.h"
4-
5-
#include "ThirdwebRuntimeSettings.h"
6-
74
#include "Wallets/ThirdwebInAppWalletHandle.h"
85

96
void UAsyncTaskThirdwebCreateAuthEndpointWallet::Activate()
107
{
11-
if (UThirdwebRuntimeSettings::IsEcosystem())
12-
{
13-
return FInAppWalletHandle::CreateEcosystemAuthEndpointWallet(EcosystemPartnerId, BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
14-
}
158
FInAppWalletHandle::CreateAuthEndpointWallet(BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
169
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
// Copyright (c) 2024 Thirdweb. All Rights Reserved.
22

33
#include "AsyncTasks/Wallets/InApp/Create/AsyncTaskThirdwebCreateEmailWallet.h"
4-
5-
#include "ThirdwebRuntimeSettings.h"
6-
74
#include "Wallets/ThirdwebInAppWalletHandle.h"
85

96
void UAsyncTaskThirdwebCreateEmailWallet::Activate()
107
{
11-
if (UThirdwebRuntimeSettings::IsEcosystem())
12-
{
13-
return FInAppWalletHandle::CreateEcosystemEmailWallet(EcosystemPartnerId, AuthInput, BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
14-
}
158
FInAppWalletHandle::CreateEmailWallet(AuthInput,BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
169
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
// Copyright (c) 2024 Thirdweb. All Rights Reserved.
22

33
#include "AsyncTasks/Wallets/InApp/Create/AsyncTaskThirdwebCreateGuestWallet.h"
4-
5-
#include "ThirdwebRuntimeSettings.h"
6-
74
#include "Wallets/ThirdwebInAppWalletHandle.h"
85

96
void UAsyncTaskThirdwebCreateGuestWallet::Activate()
107
{
11-
if (UThirdwebRuntimeSettings::IsEcosystem())
12-
{
13-
return FInAppWalletHandle::CreateEcosystemGuestWallet(EcosystemPartnerId, BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
14-
}
158
FInAppWalletHandle::CreateGuestWallet(BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
169
}

Source/Thirdweb/Private/AsyncTasks/Wallets/InApp/Create/AsyncTaskThirdwebCreateJwtWallet.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
#include "AsyncTasks/Wallets/InApp/Create/AsyncTaskThirdwebCreateJwtWallet.h"
44

5-
#include "ThirdwebRuntimeSettings.h"
6-
75
#include "Wallets/ThirdwebInAppWalletHandle.h"
86

97
void UAsyncTaskThirdwebCreateJwtWallet::Activate()
108
{
11-
if (UThirdwebRuntimeSettings::IsEcosystem())
12-
{
13-
return FInAppWalletHandle::CreateEcosystemJwtWallet(EcosystemPartnerId, BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
14-
}
159
FInAppWalletHandle::CreateJwtWallet(BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
1610
}

Source/Thirdweb/Private/AsyncTasks/Wallets/InApp/Create/AsyncTaskThirdwebCreateOAuthWallet.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@
66

77
#include "Wallets/ThirdwebInAppWalletHandle.h"
88

9-
UAsyncTaskThirdwebCreateOAuthWallet* UAsyncTaskThirdwebCreateOAuthWallet::CreateOAuthWallet(UObject* WorldContextObject, const EThirdwebOAuthProvider Provider, const FString& PartnerId)
9+
UAsyncTaskThirdwebCreateOAuthWallet* UAsyncTaskThirdwebCreateOAuthWallet::CreateOAuthWallet(UObject* WorldContextObject, const EThirdwebOAuthProvider Provider)
1010
{
1111
if (!WorldContextObject)
1212
{
1313
return nullptr;
1414
}
1515
ThisClass* Task = NewObject<ThisClass>(WorldContextObject);
16-
Task->EcosystemPartnerId = PartnerId;
1716
Task->Provider = Provider;
1817
Task->RegisterWithGameInstance(WorldContextObject);
1918
return Task;
2019
}
2120

2221
void UAsyncTaskThirdwebCreateOAuthWallet::Activate()
2322
{
24-
if (UThirdwebRuntimeSettings::IsEcosystem())
25-
{
26-
return FInAppWalletHandle::CreateEcosystemOAuthWallet(EcosystemPartnerId, Provider,BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
27-
}
2823
FInAppWalletHandle::CreateOAuthWallet(Provider,BIND_CREATE_WALLET_SUCCESS_DELEGATE, BIND_CREATE_WALLET_ERROR_DELEGATE);
2924
}

0 commit comments

Comments
 (0)