-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added zk evm sign typed data method (#146)
* feat: added zk evm sign typed data method * feat: added blueprint sample for sign typed data method
- Loading branch information
Showing
7 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
Binary file modified
BIN
+23.6 KB
(100%)
Content/BlueprintSampleContent/ImtblAuthenticatedWidget4_26.uasset
Binary file not shown.
Binary file added
BIN
+91.8 KB
Content/BlueprintSampleContent/ImtblEvmSignTypedDataWidget4_27.uasset
Binary file not shown.
53 changes: 53 additions & 0 deletions
53
Source/Immutable/Private/Immutable/Actions/ImtblPassportZkEvmSignTypedDataV4AsyncAction.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "Immutable/Actions/ImtblPassportZkEvmSignTypedDataV4AsyncAction.h" | ||
|
||
#include "Immutable/ImmutablePassport.h" | ||
#include "Immutable/ImmutableSubsystem.h" | ||
#include "Immutable/Misc/ImtblLogging.h" | ||
|
||
|
||
UImtblPassportZkEvmSignTypedDataV4AsyncAction* UImtblPassportZkEvmSignTypedDataV4AsyncAction::ZkEvmSignTypedDataV4(UObject* WorldContextObject, const FString& JsonStringRequest) | ||
{ | ||
UImtblPassportZkEvmSignTypedDataV4AsyncAction* PassportZkEvmSignTypedDataV4BlueprintNode = NewObject<UImtblPassportZkEvmSignTypedDataV4AsyncAction>(); | ||
|
||
PassportZkEvmSignTypedDataV4BlueprintNode->WorldContextObject = WorldContextObject; | ||
PassportZkEvmSignTypedDataV4BlueprintNode->JsonStringSignRequest = JsonStringRequest; | ||
|
||
return PassportZkEvmSignTypedDataV4BlueprintNode; | ||
} | ||
|
||
void UImtblPassportZkEvmSignTypedDataV4AsyncAction::Activate() | ||
{ | ||
if (!WorldContextObject || !WorldContextObject->GetWorld()) | ||
{ | ||
FString Err = "zkEVM Sign Typed Data V4 failed due to missing world or world " "context object."; | ||
IMTBL_WARN("%s", *Err) | ||
Failed.Broadcast(Err, TEXT("")); | ||
return; | ||
} | ||
|
||
GetSubsystem()->WhenReady(this, &UImtblPassportZkEvmSignTypedDataV4AsyncAction::DoZkEvmSignTypedDataV4); | ||
} | ||
|
||
void UImtblPassportZkEvmSignTypedDataV4AsyncAction::DoZkEvmSignTypedDataV4(TWeakObjectPtr<UImtblJSConnector> JSConnector) | ||
{ | ||
auto Passport = GetSubsystem()->GetPassport(); | ||
|
||
if (Passport.IsValid()) | ||
{ | ||
Passport->ZkEvmSignTypedDataV4(JsonStringSignRequest, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmSignTypedDataV4AsyncAction::OnZkEvmSignTypedDataV4Response)); | ||
} | ||
} | ||
|
||
void UImtblPassportZkEvmSignTypedDataV4AsyncAction::OnZkEvmSignTypedDataV4Response(FImmutablePassportResult Result) | ||
{ | ||
if (Result.Success) | ||
{ | ||
IMTBL_LOG("zkEVM Sign Typed Data V4 success") | ||
MessageSigned.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsString(Result.Response)); | ||
} | ||
else | ||
{ | ||
IMTBL_LOG("zkEVM Sign Typed Data V4 failed") | ||
Failed.Broadcast(Result.Error, TEXT("")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Source/Immutable/Public/Immutable/Actions/ImtblPassportZkEvmSignTypedDataV4AsyncAction.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
|
||
#include "Immutable/ImmutablePassport.h" | ||
#include "ImtblBlueprintAsyncAction.h" | ||
|
||
#include "ImtblPassportZkEvmSignTypedDataV4AsyncAction.generated.h" | ||
|
||
/** | ||
* Async action blueprint node for zkEVM SignTypedDataV4 | ||
*/ | ||
UCLASS() | ||
class IMMUTABLE_API UImtblPassportZkEvmSignTypedDataV4AsyncAction : public UImtblBlueprintAsyncAction | ||
{ | ||
GENERATED_BODY() | ||
|
||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportZkEvmSignTypedDataV4OutputPin, FString, ErrorMessage, FString, Signature); | ||
|
||
public: | ||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") | ||
static UImtblPassportZkEvmSignTypedDataV4AsyncAction* ZkEvmSignTypedDataV4(UObject* WorldContextObject, const FString& JsonStringRequest); | ||
|
||
virtual void Activate() override; | ||
|
||
private: | ||
FString JsonStringSignRequest; | ||
|
||
UPROPERTY(BlueprintAssignable) | ||
FPassportZkEvmSignTypedDataV4OutputPin MessageSigned; | ||
UPROPERTY(BlueprintAssignable) | ||
FPassportZkEvmSignTypedDataV4OutputPin Failed; | ||
|
||
void DoZkEvmSignTypedDataV4(TWeakObjectPtr<class UImtblJSConnector> JSGetConnector); | ||
void OnZkEvmSignTypedDataV4Response(FImmutablePassportResult Result); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters