@@ -132,11 +132,11 @@ FString FImmutablePassportZkEvmGetBalanceData::ToJsonString() const
132
132
FString FImtblTransactionRequest::ToJsonString () const
133
133
{
134
134
FString OutString;
135
-
135
+
136
136
FJsonObjectWrapper Wrapper;
137
137
Wrapper.JsonObject = MakeShared<FJsonObject>();
138
138
FJsonObjectConverter::UStructToJsonObject (FImtblTransactionRequest::StaticStruct (), this , Wrapper.JsonObject .ToSharedRef (), 0 , 0 );
139
-
139
+
140
140
if (!Wrapper.JsonObject .IsValid ())
141
141
{
142
142
IMTBL_ERR (" Could not convert FImtblTransactionRequest to JSON" )
@@ -150,10 +150,10 @@ FString FImtblTransactionRequest::ToJsonString() const
150
150
CustomDataArray.Add (MakeShared<FJsonValueObject>(FJsonValueObject (CustomData.ToJsonObject ())));
151
151
}
152
152
Wrapper.JsonObject ->SetArrayField (" customData" , CustomDataArray);
153
-
153
+
154
154
Wrapper.JsonObjectToString (OutString);
155
155
156
-
156
+
157
157
return OutString;
158
158
}
159
159
@@ -244,7 +244,7 @@ void UImmutablePassport::ZkEvmGetBalance(const FImmutablePassportZkEvmGetBalance
244
244
}
245
245
246
246
void UImmutablePassport::ZkEvmSendTransaction (const FImtblTransactionRequest& Request, const FImtblPassportResponseDelegate& ResponseDelegate)
247
- {
247
+ {
248
248
CallJS (
249
249
ImmutablePassportAction::ZkEvmSendTransaction,
250
250
Request.ToJsonString (),
@@ -382,11 +382,8 @@ void UImmutablePassport::OnInitializeResponse(FImtblJSResponse Response)
382
382
}
383
383
else
384
384
{
385
- IMTBL_LOG (" Passport initialization failed." )
386
- if (Response.Error .IsSet ())
387
- {
388
- Msg = Response.Error ->ToString ();
389
- }
385
+ IMTBL_ERR (" Passport initialization failed." )
386
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
390
387
}
391
388
392
389
ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{Response.success , Msg, Response});
@@ -405,8 +402,7 @@ void UImmutablePassport::OnCheckStoredCredentialsResponse(FImtblJSResponse Respo
405
402
{
406
403
IMTBL_LOG (" No stored credentials found." );
407
404
FString Msg;
408
- if (Response.Error .IsSet ())
409
- Msg = Response.Error ->ToString ();
405
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
410
406
ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{false , Msg, Response});
411
407
}
412
408
else
@@ -429,8 +425,7 @@ void UImmutablePassport::OnConnectSilentResponse(FImtblJSResponse Response)
429
425
{
430
426
IMTBL_LOG (" No stored credentials found." );
431
427
FString Msg;
432
- if (Response.Error .IsSet ())
433
- Msg = Response.Error ->ToString ();
428
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
434
429
ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{false , Msg, Response});
435
430
return ;
436
431
}
@@ -460,8 +455,7 @@ void UImmutablePassport::OnConnectWithCredentialsResponse(FImtblJSResponse Respo
460
455
else
461
456
{
462
457
IMTBL_LOG (" Connect with credentials failed." );
463
- if (Response.Error .IsSet ())
464
- Msg = Response.Error ->ToString ();
458
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
465
459
// Send log out action to Passport and move on, logging and ignoring the response
466
460
JSConnector->CallJS (ImmutablePassportAction::Logout, TEXT (" " ), FImtblJSResponseDelegate::CreateUObject (this , &UImmutablePassport::LogAndIgnoreResponse));
467
461
}
@@ -482,9 +476,8 @@ void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response)
482
476
}
483
477
else
484
478
{
485
- IMTBL_LOG (" Error logging out." )
486
- if (Response.Error .IsSet ())
487
- Msg = Response.Error ->ToString ();
479
+ IMTBL_ERR (" Error logging out." )
480
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
488
481
}
489
482
ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{Response.success , Msg, Response});
490
483
}
@@ -499,11 +492,8 @@ void UImmutablePassport::OnConnectResponse(FImtblJSResponse Response)
499
492
if (!Response.success || !ConnectData || !ConnectData->code .Len ())
500
493
{
501
494
FString Msg;
502
- IMTBL_LOG (" Connect attempt failed." );
503
- if (Response.Error .IsSet ())
504
- {
505
- Msg = Response.Error ->ToString ();
506
- }
495
+ IMTBL_WARN (" Connect attempt failed." );
496
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
507
497
ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{false , Msg, Response});
508
498
return ;
509
499
}
@@ -531,9 +521,8 @@ void UImmutablePassport::OnConnectEvmResponse(FImtblJSResponse Response)
531
521
}
532
522
else
533
523
{
534
- IMTBL_LOG (" Error connecting to Evm." )
535
- if (Response.Error .IsSet ())
536
- Msg = Response.Error ->ToString ();
524
+ IMTBL_WARN (" Error connecting to Evm." )
525
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
537
526
}
538
527
ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{Response.success , Msg});
539
528
}
@@ -601,9 +590,8 @@ void UImmutablePassport::OnConnectPKCEResponse(FImtblJSResponse Response)
601
590
}
602
591
else
603
592
{
604
- IMTBL_LOG (" Connect PKCE attempt failed." );
605
- if (Response.Error .IsSet ())
606
- Msg = Response.Error ->ToString ();
593
+ IMTBL_WARN (" Connect PKCE attempt failed." );
594
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
607
595
}
608
596
PKCEResponseDelegate.ExecuteIfBound (FImmutablePassportResult{Response.success , Msg});
609
597
PKCEResponseDelegate = nullptr ;
@@ -626,9 +614,8 @@ void UImmutablePassport::OnGetAddressResponse(FImtblJSResponse Response)
626
614
bool bSuccess = true ;
627
615
if (!Response.success || !Response.JsonObject ->HasTypedField <EJson::String>(TEXT (" result" )))
628
616
{
629
- IMTBL_LOG (" Could not fetch address from Passport." );
630
- if (Response.Error .IsSet ())
631
- Msg = Response.Error ->ToString ();
617
+ IMTBL_WARN (" Could not fetch address from Passport." );
618
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
632
619
bSuccess = false ;
633
620
}
634
621
else
@@ -649,9 +636,8 @@ void UImmutablePassport::OnZkEvmRequestAccountsResponse(FImtblJSResponse Respons
649
636
bool bSuccess = true ;
650
637
if (!Response.success || !Response.JsonObject ->HasTypedField <EJson::Array>(TEXT (" accounts" )))
651
638
{
652
- IMTBL_LOG (" Error requesting zkevm accounts." )
653
- if (Response.Error .IsSet ())
654
- Msg = Response.Error ->ToString ();
639
+ IMTBL_WARN (" Error requesting zkevm accounts." )
640
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
655
641
bSuccess = false ;
656
642
}
657
643
else
@@ -679,9 +665,8 @@ void UImmutablePassport::OnZkEvmGetBalanceResponse(FImtblJSResponse Response)
679
665
bool bSuccess = true ;
680
666
if (!Response.success || !Response.JsonObject ->HasTypedField <EJson::String>(TEXT (" result" )))
681
667
{
682
- IMTBL_LOG (" Could not get balance." );
683
- if (Response.Error .IsSet ())
684
- Msg = Response.Error ->ToString ();
668
+ IMTBL_WARN (" Could not get balance." );
669
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
685
670
bSuccess = false ;
686
671
}
687
672
else
@@ -700,9 +685,8 @@ void UImmutablePassport::OnZkEvmSendTransactionResponse(FImtblJSResponse Respons
700
685
bool bSuccess = true ;
701
686
if (!Response.success || !Response.JsonObject ->HasTypedField <EJson::String>(TEXT (" result" )))
702
687
{
703
- IMTBL_LOG (" Could not fetch send transaction." );
704
- if (Response.Error .IsSet ())
705
- Msg = Response.Error ->ToString ();
688
+ IMTBL_WARN (" Could not fetch send transaction." );
689
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
706
690
bSuccess = false ;
707
691
}
708
692
else
@@ -725,9 +709,8 @@ void UImmutablePassport::OnConfirmCodeResponse(FImtblJSResponse Response)
725
709
}
726
710
else
727
711
{
728
- IMTBL_LOG (" Login code not confirmed." )
729
- if (Response.Error .IsSet ())
730
- Msg = Response.Error ->ToString ();
712
+ IMTBL_WARN (" Login code not confirmed." )
713
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
731
714
}
732
715
ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{Response.success , Msg, Response});
733
716
}
@@ -744,9 +727,8 @@ void UImmutablePassport::OnGetEmailResponse(FImtblJSResponse Response)
744
727
bool bSuccess = true ;
745
728
if (!Response.success || !Response.JsonObject ->HasTypedField <EJson::String>(TEXT (" result" )))
746
729
{
747
- IMTBL_LOG (" Connect attempt failed." );
748
- if (Response.Error .IsSet ())
749
- Msg = Response.Error ->ToString ();
730
+ IMTBL_WARN (" Connect attempt failed." );
731
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
750
732
bSuccess = false ;
751
733
}
752
734
else
@@ -767,17 +749,13 @@ void UImmutablePassport::OnTransferResponse(FImtblJSResponse Response)
767
749
bool bSuccess = true ;
768
750
if (!Response.success )
769
751
{
770
- IMTBL_LOG (" ImxTransfer failed." );
771
- if (Response.Error .IsSet ())
772
- {
773
- Msg = Response.Error ->ToString ();
774
- }
775
-
752
+ IMTBL_WARN (" ImxTransfer failed." );
753
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
776
754
bSuccess = false ;
777
755
}
778
756
else
779
757
{
780
- Msg = Response.JsonObject ->GetStringField (TEXT (" result " ));
758
+ Msg = Response.JsonObject ->GetStringField (TEXT (" status " ));
781
759
}
782
760
ResponseDelegate->ExecuteIfBound (FImmutablePassportResult{bSuccess, Msg, Response});
783
761
}
@@ -793,11 +771,8 @@ void UImmutablePassport::OnBatchNftTransferResponse(FImtblJSResponse Response)
793
771
bool bSuccess = true ;
794
772
if (!Response.success || !Response.JsonObject ->HasTypedField <EJson::Object>(TEXT (" result" )))
795
773
{
796
- IMTBL_LOG (" ImxBatchNftTransfer failed." );
797
- if (Response.Error .IsSet ())
798
- {
799
- Msg = Response.Error ->ToString ();
800
- }
774
+ IMTBL_WARN (" ImxBatchNftTransfer failed." );
775
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
801
776
bSuccess = false ;
802
777
}
803
778
else
@@ -817,7 +792,9 @@ void UImmutablePassport::LogAndIgnoreResponse(FImtblJSResponse Response)
817
792
}
818
793
else
819
794
{
820
- IMTBL_WARN (" Received error response from Passport for action %s -- %s" , *Response.responseFor , *Response.Error ->ToString ());
795
+ FString Msg;
796
+ Response.Error .IsSet () ? Msg = Response.Error ->ToString () : Msg = Response.JsonObject ->GetStringField (TEXT (" error" ));
797
+ IMTBL_WARN (" Received error response from Passport for action %s -- %s" , *Response.responseFor , *Msg);
821
798
}
822
799
}
823
800
0 commit comments