Skip to content

Commit 73c457b

Browse files
authored
[DX-2787] feat: added zkevm transaction receipt acquirement method (#85)
* feat: added get transaction receipt functionality * chore: game bridge update, tag 1.35.5 * fix: removed unnecessary code, edited comments * feat: updated widget blueprints with new method
1 parent bd08d56 commit 73c457b

13 files changed

+289
-2
lines changed
Binary file not shown.
-7.34 KB
Binary file not shown.
Binary file not shown.
-372 KB
Binary file not shown.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Fill out your copyright notice in the Description page of Project Settings.
2+
3+
#include "Immutable/Actions/ImtblPassportZkEvmGetTransactionReceiptAA.h"
4+
5+
#include "Immutable/ImmutablePassport.h"
6+
#include "Immutable/ImmutableSubsystem.h"
7+
#include "Immutable/Misc/ImtblLogging.h"
8+
9+
UImtblPassportZkEvmGetTransactionReceiptAA* UImtblPassportZkEvmGetTransactionReceiptAA::ZkEvmGetTransactionReceipt(UObject* WorldContextObject, const FString& Hash)
10+
{
11+
UImtblPassportZkEvmGetTransactionReceiptAA* PassportZkEvmSendTransactionBlueprintNode = NewObject<UImtblPassportZkEvmGetTransactionReceiptAA>();
12+
13+
PassportZkEvmSendTransactionBlueprintNode->WorldContextObject = WorldContextObject;
14+
PassportZkEvmSendTransactionBlueprintNode->Hash = Hash;
15+
16+
return PassportZkEvmSendTransactionBlueprintNode;
17+
}
18+
19+
void UImtblPassportZkEvmGetTransactionReceiptAA::Activate()
20+
{
21+
if (!WorldContextObject || !WorldContextObject->GetWorld())
22+
{
23+
const FString ErrorMessage = "ZkEvmSendTransaction failed due to missing world or world " "context object.";
24+
IMTBL_WARN("%s", *ErrorMessage)
25+
Failed.Broadcast(ErrorMessage, FZkEvmTransactionReceipt());
26+
return;
27+
}
28+
29+
GetSubsystem()->WhenReady(this, &UImtblPassportZkEvmGetTransactionReceiptAA::DoZkEvmGetTransactionReceipt);
30+
}
31+
32+
void UImtblPassportZkEvmGetTransactionReceiptAA::DoZkEvmGetTransactionReceipt(TWeakObjectPtr<UImtblJSConnector> JSConnector)
33+
{
34+
auto Passport = GetSubsystem()->GetPassport();
35+
36+
if (Passport.IsValid())
37+
{
38+
Passport->ZkEvmGetTransactionReceipt({ Hash }, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmGetTransactionReceiptAA::OnZkEvmGetTransactionReceiptResponse));
39+
}
40+
}
41+
42+
void UImtblPassportZkEvmGetTransactionReceiptAA::OnZkEvmGetTransactionReceiptResponse(FImmutablePassportResult Result)
43+
{
44+
if (Result.Success)
45+
{
46+
auto Receipt = JsonObjectToUStruct<FZkEvmTransactionReceipt>(Result.Response.JsonObject);
47+
48+
if (Receipt.IsSet())
49+
{
50+
IMTBL_LOG("ZkEvmGetTransactionReceipt success")
51+
Success.Broadcast(TEXT(""), Receipt.GetValue());
52+
}
53+
else
54+
{
55+
IMTBL_LOG("ZkEvm Transaction Receipt is not provided")
56+
Success.Broadcast(TEXT(""), FZkEvmTransactionReceipt());
57+
}
58+
}
59+
else
60+
{
61+
IMTBL_LOG("ZkEvmGetTransactionReceipt failed")
62+
Failed.Broadcast(Result.Message, FZkEvmTransactionReceipt());
63+
}
64+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include "Immutable/ImmutableBlueprintLibrary.h"
2+
3+
4+
void UImmutableBlueprintLibrary::BreakFZkEvmTransactionReceiptLog(FZkEvmTransactionReceiptLog Log, FString& Address, FString& Data,
5+
FString& BlockNumber, FString& TransactionHash, FString& TransactionIndex, FString& BlockHash, FString& LogIndex, bool& Removed,
6+
TArray<FString>& Topics)
7+
{
8+
Address = Log.address;
9+
Data = Log.data;
10+
BlockNumber = Log.blockNumber;
11+
TransactionHash = Log.transactionHash;
12+
TransactionIndex = Log.transactionIndex;
13+
BlockHash = Log.blockHash;
14+
LogIndex = Log.logIndex;
15+
Removed = Log.removed;
16+
Topics = Log.topics;
17+
}
18+
19+
void UImmutableBlueprintLibrary::BreakZkEvmTransactionReceipt(FZkEvmTransactionReceipt Receipt, FString& BlockHash, FString& BlockNumber,
20+
FString& ContractAddress, FString& CumulativeGasUsed, FString& EffectiveGasPrice, FString& From, FString& GasUsed, FString& LogsBloom,
21+
FString& Status, FString& To, FString& TransactionHash, FString& TransactionIndex, FString& Type, TArray<FZkEvmTransactionReceiptLog>& Logs)
22+
{
23+
BlockHash = Receipt.blockHash;
24+
BlockNumber = Receipt.blockNumber;
25+
ContractAddress = Receipt.contractAddress;
26+
CumulativeGasUsed = Receipt.cumulativeGasUsed;
27+
EffectiveGasPrice = Receipt.effectiveGasPrice;
28+
From = Receipt.from;
29+
GasUsed = Receipt.gasUsed;
30+
LogsBloom = Receipt.logsBloom;
31+
Status = Receipt.status;
32+
To = Receipt.to;
33+
TransactionHash = Receipt.transactionHash;
34+
TransactionIndex = Receipt.transactionIndex;
35+
Type = Receipt.type;
36+
Logs = Receipt.logs;
37+
}

Source/Immutable/Private/Immutable/ImmutablePassport.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ void UImmutablePassport::ZkEvmSendTransaction(const FImtblTransactionRequest& Re
116116
CallJS(ImmutablePassportAction::ZkEvmSendTransaction, UStructToJsonString(Request), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnZkEvmSendTransactionResponse));
117117
}
118118

119+
void UImmutablePassport::ZkEvmGetTransactionReceipt(const FZkEvmTransactionReceiptRequest& Request, const FImtblPassportResponseDelegate& ResponseDelegate)
120+
{
121+
CallJS(ImmutablePassportAction::ZkEvmGetTransactionReceipt, UStructToJsonString(Request), ResponseDelegate, FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnZkEvmGetTransactionReceiptResponse));
122+
}
123+
119124
void UImmutablePassport::ConfirmCode(const FString& DeviceCode, const float Interval, const FImtblPassportResponseDelegate& ResponseDelegate)
120125
{
121126
FImmutablePassportCodeConfirmRequestData Data{DeviceCode, Interval};
@@ -647,6 +652,23 @@ void UImmutablePassport::OnZkEvmSendTransactionResponse(FImtblJSResponse Respons
647652
}
648653
}
649654

655+
void UImmutablePassport::OnZkEvmGetTransactionReceiptResponse(FImtblJSResponse Response)
656+
{
657+
if (auto ResponseDelegate = GetResponseDelegate(Response))
658+
{
659+
FString Msg;
660+
bool bSuccess = true;
661+
662+
if (!Response.success)
663+
{
664+
IMTBL_WARN("zkEVM transaction receipt retrieval failed.");
665+
Response.Error.IsSet() ? Msg = Response.Error->ToString() : Msg = Response.JsonObject->GetStringField(TEXT("error"));
666+
bSuccess = false;
667+
}
668+
ResponseDelegate->ExecuteIfBound(FImmutablePassportResult{bSuccess, Msg, Response});
669+
}
670+
}
671+
650672
void UImmutablePassport::OnConfirmCodeResponse(FImtblJSResponse Response)
651673
{
652674
if (auto ResponseDelegate = GetResponseDelegate(Response))
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Fill out your copyright notice in the Description page of Project Settings.
2+
3+
#pragma once
4+
5+
#include "CoreMinimal.h"
6+
#include "Immutable/ImmutablePassport.h"
7+
#include "ImtblBlueprintAsyncAction.h"
8+
9+
#include "ImtblPassportZkEvmGetTransactionReceiptAA.generated.h"
10+
11+
12+
/**
13+
*
14+
*/
15+
UCLASS()
16+
class IMMUTABLE_API UImtblPassportZkEvmGetTransactionReceiptAA : public UImtblBlueprintAsyncAction
17+
{
18+
GENERATED_BODY()
19+
20+
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FZkEvmGetTransactionReceiptOutputPin, FString, ErrorMessage, const struct FZkEvmTransactionReceipt&, Receipt);
21+
22+
public:
23+
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable")
24+
static UImtblPassportZkEvmGetTransactionReceiptAA* ZkEvmGetTransactionReceipt(UObject* WorldContextObject, const FString& Hash);
25+
26+
virtual void Activate() override;
27+
28+
private:
29+
FString Hash;
30+
31+
UPROPERTY(BlueprintAssignable)
32+
FZkEvmGetTransactionReceiptOutputPin Success;
33+
UPROPERTY(BlueprintAssignable)
34+
FZkEvmGetTransactionReceiptOutputPin Failed;
35+
36+
void DoZkEvmGetTransactionReceipt(TWeakObjectPtr<class UImtblJSConnector> JSGetConnector);
37+
void OnZkEvmGetTransactionReceiptResponse(FImmutablePassportResult Result);
38+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include "Kismet/BlueprintFunctionLibrary.h"
4+
#include "Immutable/ImmutableDataTypes.h"
5+
6+
#include "ImmutableBlueprintLibrary.generated.h"
7+
8+
9+
UCLASS()
10+
class IMMUTABLE_API UImmutableBlueprintLibrary : public UBlueprintFunctionLibrary
11+
{
12+
GENERATED_BODY()
13+
14+
public:
15+
16+
UFUNCTION(BlueprintPure, Category = "Immutable", meta = (NativeBreakFunc))
17+
static void BreakFZkEvmTransactionReceiptLog(FZkEvmTransactionReceiptLog Log, FString& Address, FString& Data, FString& BlockNumber, FString& TransactionHash, FString& TransactionIndex, FString& BlockHash, FString& LogIndex, bool& Removed, TArray<FString>& Topics);
18+
19+
UFUNCTION(BlueprintPure, Category = "Immutable", meta = (NativeBreakFunc))
20+
static void BreakZkEvmTransactionReceipt(FZkEvmTransactionReceipt Receipt, FString& BlockHash, FString& BlockNumber, FString& ContractAddress, FString& CumulativeGasUsed, FString& EffectiveGasPrice, FString& From, FString& GasUsed, FString& LogsBloom, FString& Status, FString& To, FString& TransactionHash, FString& TransactionIndex, FString& Type, TArray<FZkEvmTransactionReceiptLog>& Logs);
21+
22+
};

Source/Immutable/Public/Immutable/ImmutableDataTypes.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,86 @@ struct FNftTransferDetails
184184
UPROPERTY(BlueprintReadWrite)
185185
FString tokenAddress;
186186
};
187+
188+
189+
USTRUCT(BlueprintType, meta = (HasNativeBreak = "/Script/Immutable.ImmutableBlueprintLibrary.BreakFZkEvmTransactionReceiptLog"))
190+
struct IMMUTABLE_API FZkEvmTransactionReceiptLog
191+
{
192+
GENERATED_BODY()
193+
194+
UPROPERTY()
195+
FString address;
196+
197+
UPROPERTY()
198+
TArray<FString> topics;
199+
200+
UPROPERTY()
201+
FString data;
202+
203+
UPROPERTY()
204+
FString blockNumber;
205+
206+
UPROPERTY()
207+
FString transactionHash;
208+
209+
UPROPERTY()
210+
FString transactionIndex;
211+
212+
UPROPERTY()
213+
FString blockHash;
214+
215+
UPROPERTY()
216+
FString logIndex;
217+
218+
UPROPERTY()
219+
bool removed;
220+
};
221+
222+
USTRUCT(BlueprintType, meta = (HasNativeBreak = "/Script/Immutable.ImmutableBlueprintLibrary.BreakZkEvmTransactionReceipt"))
223+
struct IMMUTABLE_API FZkEvmTransactionReceipt
224+
{
225+
GENERATED_BODY()
226+
227+
UPROPERTY()
228+
FString blockHash;
229+
230+
UPROPERTY()
231+
FString blockNumber;
232+
233+
UPROPERTY()
234+
FString contractAddress;
235+
236+
UPROPERTY()
237+
FString cumulativeGasUsed;
238+
239+
UPROPERTY()
240+
FString effectiveGasPrice;
241+
242+
UPROPERTY()
243+
FString from;
244+
245+
UPROPERTY()
246+
FString gasUsed;
247+
248+
UPROPERTY(BlueprintReadOnly)
249+
TArray<FZkEvmTransactionReceiptLog> logs;
250+
251+
UPROPERTY()
252+
FString logsBloom;
253+
254+
// Either 1 (success) or 0 (failure) encoded as a hexadecimal.
255+
UPROPERTY()
256+
FString status;
257+
258+
UPROPERTY()
259+
FString to;
260+
261+
UPROPERTY()
262+
FString transactionHash;
263+
264+
UPROPERTY()
265+
FString transactionIndex;
266+
267+
UPROPERTY()
268+
FString type;
269+
};

0 commit comments

Comments
 (0)