Skip to content

Commit

Permalink
[DX-2956, DX-2965] refactor: updated passport delegate handling due t…
Browse files Browse the repository at this point in the history
…o changes in the game bridge (#92)

* chore: update game bridge(tag 1.44.3)

* refactor: updated passport to match bridge changes for consistent callback result structure
  • Loading branch information
YermekG authored Jul 7, 2024
1 parent a9d29cf commit f9b32f4
Show file tree
Hide file tree
Showing 22 changed files with 150 additions and 432 deletions.
Binary file modified Content/PackagedResources/index.uasset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ void UImtblConnectionAsyncActions::OnConnect(FImmutablePassportResult Result)
}
else
{
Failed.Broadcast(Result.Message);
Failed.Broadcast(Result.Error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ void UImtblPassportConnectEvmAsyncAction::OnConnectEvm(FImmutablePassportResult
{
if (Result.Success)
{
Success.Broadcast(Result.Message);
Success.Broadcast("");
}
else
{
Failed.Broadcast(Result.Message);
Failed.Broadcast(Result.Error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ void UImtblPassportGetAccessTokenAsyncAction::OnGetAccessTokenResponse(FImmutabl
{
if (Result.Success)
{
GotAccessToken.Broadcast(TEXT(""), Result.Message);
GotAccessToken.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsString(Result.Response));
}
else
{
Failed.Broadcast(Result.Message, TEXT(""));
Failed.Broadcast(Result.Error, TEXT(""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ void UImtblPassportGetAddressAsyncAction::OnGetAddressResponse(FImmutablePasspor
{
if (Result.Success)
{
GotAddress.Broadcast(TEXT(""), Result.Message);
GotAddress.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsString(Result.Response));
}
else
{
Failed.Broadcast(Result.Message, TEXT(""));
Failed.Broadcast(Result.Error, TEXT(""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ void UImtblPassportGetEmailAsyncAction::OnGetEmailResponse(FImmutablePassportRes
{
if (Result.Success)
{
GotEmail.Broadcast(TEXT(""), Result.Message);
GotEmail.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsString(Result.Response));
}
else
{
Failed.Broadcast(Result.Message, TEXT(""));
Failed.Broadcast(Result.Error, TEXT(""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ void UImtblPassportGetIdTokenAsyncAction::OnGetIdTokenResponse(FImmutablePasspor
{
if (Result.Success)
{
GotIdToken.Broadcast(TEXT(""), Result.Message);
GotIdToken.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsString(Result.Response));
}
else
{
Failed.Broadcast(Result.Message, TEXT(""));
Failed.Broadcast(Result.Error, TEXT(""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ void UImtblPassportHasStoredCredentialsAsyncAction::OnHasStoredCredentialsRespon
}
else
{
OnFalse.Broadcast(Result.Message);
OnFalse.Broadcast(Result.Error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ void UImmutablePassportImxBatchNftTransferAsyncAction::OnTransferResponse(FImmut
}
else
{
Failed.Broadcast(Result.Message, TransferIds);
Failed.Broadcast(Result.Error, TransferIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ void UImtblPassportImxIsRegisteredOffchainAsyncAction::DoImxIsRegisteredOffchain

void UImtblPassportImxIsRegisteredOffchainAsyncAction::OnImxIsRegisteredOffchainResponse(FImmutablePassportResult Result)
{
OnComplete.Broadcast(Result.Success);
OnComplete.Broadcast(UImmutablePassport::GetResponseResultAsBool(Result.Response));
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ void UImtblPassportImxRegisterOffchainAsyncAction::OnImxRegisterOffchainResponse
}
}

OnFailure.Broadcast(TEXT(""), Result.Message);
OnFailure.Broadcast(TEXT(""), Result.Error);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Immutable/Actions/ImtblPassportImxTransferAsyncAction.h"

#include "Immutable/ImmutablePassport.h"
#include "Immutable/ImmutableResponses.h"
#include "Immutable/ImmutableSubsystem.h"
#include "Immutable/Misc/ImtblLogging.h"

Expand Down Expand Up @@ -57,6 +58,6 @@ void UImmutablePassportImxTransferAsyncAction::OnTransferResponse(FImmutablePass
}
else
{
Failed.Broadcast(Result.Message, TEXT(""));
Failed.Broadcast(Result.Error, TEXT(""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ void UImtblPassportInitializationAsyncAction::OnInitialized(FImmutablePassportRe
{
if (Result.Success)
{
Initialized.Broadcast(Result.Message);
Initialized.Broadcast("");
}
else
{
Failed.Broadcast(Result.Message);
Failed.Broadcast(Result.Error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ void UImtblPassportLogoutAsyncAction::OnLogoutResponse(FImmutablePassportResult
{
if (Result.Success)
{
OnSuccess.Broadcast(Result.Message);
OnSuccess.Broadcast("");
}
else
{
OnFailure.Broadcast(Result.Message);
OnFailure.Broadcast(Result.Error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ void UImtblPassportZkEvmGetBalanceAsyncAction::Activate()

void UImtblPassportZkEvmGetBalanceAsyncAction::DoZkEvmGetBalance(TWeakObjectPtr<UImtblJSConnector> JSConnector)
{
// Get Passport
auto Passport = GetSubsystem()->GetPassport();
// Run ZkEvmGetBalance
Passport->ZkEvmGetBalance(FImmutablePassportZkEvmGetBalanceData{Address, BlockNumberOrTag}, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmGetBalanceAsyncAction::OnZkEvmGetBalanceResponse));

if (Passport.IsValid())
{
Passport->ZkEvmGetBalance(FImmutablePassportZkEvmGetBalanceData{Address, BlockNumberOrTag}, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmGetBalanceAsyncAction::OnZkEvmGetBalanceResponse));
}
}

void UImtblPassportZkEvmGetBalanceAsyncAction::OnZkEvmGetBalanceResponse(FImmutablePassportResult Result)
{
if (Result.Success)
{
IMTBL_LOG("ZkEvmGetBalance success")
GotBalance.Broadcast(TEXT(""), Result.Message);
GotBalance.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsString(Result.Response));
}
else
{
IMTBL_LOG("ZkEvmGetBalance failed")
Failed.Broadcast(Result.Message, TEXT(""));
Failed.Broadcast(Result.Error, TEXT(""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ void UImtblPassportZkEvmGetTransactionReceiptAA::OnZkEvmGetTransactionReceiptRes
else
{
IMTBL_LOG("zkEVM Transaction Receipt retrival failed")
Failed.Broadcast(Result.Message, FZkEvmTransactionReceipt());
Failed.Broadcast(Result.Error, FZkEvmTransactionReceipt());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,24 @@ void UImtblPassportZkEvmRequestAccountsAsyncAction::Activate()

void UImtblPassportZkEvmRequestAccountsAsyncAction::DoRequestAccounts(TWeakObjectPtr<UImtblJSConnector> JSConnector)
{
// Get Passport
auto Passport = GetSubsystem()->GetPassport();
// Run ZkEvmRequestAccounts
Passport->ZkEvmRequestAccounts(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmRequestAccountsAsyncAction::OnRequestAccountsResponse));

if (Passport.IsValid())
{
Passport->ZkEvmRequestAccounts(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmRequestAccountsAsyncAction::OnRequestAccountsResponse));
}
}

void UImtblPassportZkEvmRequestAccountsAsyncAction::OnRequestAccountsResponse(FImmutablePassportResult Result)
{
TArray<FString> StrArr;
if (Result.Success)
{
Result.Message.ParseIntoArray(StrArr, TEXT(","));
GotAccounts.Broadcast(TEXT(""), StrArr);
const auto RequestAccountsData = FImmutablePassportZkEvmRequestAccountsData::FromJsonObject(Result.Response.JsonObject);

GotAccounts.Broadcast(TEXT(""), RequestAccountsData->accounts);
}
else
{
Failed.Broadcast(Result.Message, StrArr);
Failed.Broadcast(Result.Error, TArray<FString>());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ void UImtblPassportZkEvmSendTransactionAsyncAction::Activate()

void UImtblPassportZkEvmSendTransactionAsyncAction::DoZkEvmSendTransaction(TWeakObjectPtr<UImtblJSConnector> JSConnector)
{
// Get Passport
auto Passport = GetSubsystem()->GetPassport();
// Run ZkEvmSendTransaction
Passport->ZkEvmSendTransaction(TransactionRequest, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmSendTransactionAsyncAction::OnZkEvmSendTransactionResponse));

if (Passport.IsValid())
{
Passport->ZkEvmSendTransaction(TransactionRequest, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportZkEvmSendTransactionAsyncAction::OnZkEvmSendTransactionResponse));
}
}

void UImtblPassportZkEvmSendTransactionAsyncAction::OnZkEvmSendTransactionResponse(FImmutablePassportResult Result)
{
if (Result.Success)
{
IMTBL_LOG("zkEVM Send Transaction success")
TransactionSent.Broadcast(TEXT(""), Result.Message);
TransactionSent.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsString(Result.Response));
}
else
{
IMTBL_LOG("zkEVM Send Transaction failed")
Failed.Broadcast(Result.Message, TEXT(""));
Failed.Broadcast(Result.Error, TEXT(""));
}
}

Expand Down Expand Up @@ -105,6 +107,6 @@ void UImtblPassportZkEvmSendTransactionWithConfirmationAA::OnZkEvmSendTransactio
else
{
IMTBL_LOG("zkEVM Send Transaction with confirmation failed")
Failed.Broadcast(Result.Message, FZkEvmTransactionReceipt());
Failed.Broadcast(Result.Error, FZkEvmTransactionReceipt());
}
}
Loading

0 comments on commit f9b32f4

Please sign in to comment.