-
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.
[DX-2975] feat: get linked addresses (#93)
* feat: added get linked addresses method * feat: added get linked addresses node to sample blueprints * refactor: joined token blueprint node implementations * fix: updated get token nodes in sample blueprints
- Loading branch information
Showing
12 changed files
with
230 additions
and
163 deletions.
There are no files selected for viewing
Binary file modified
BIN
+30.1 KB
(110%)
Content/BlueprintSampleContent/ImtblAuthenticatedWidget4_26.uasset
Binary file not shown.
47 changes: 0 additions & 47 deletions
47
Source/Immutable/Private/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.cpp
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
Source/Immutable/Private/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.cpp
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
Source/Immutable/Private/Immutable/Actions/ImtblPassportGetLinkedAddressesAsyncAction.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 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
#include "Immutable/Actions/ImtblPassportGetLinkedAddressesAsyncAction.h" | ||
|
||
#include "Immutable/ImmutablePassport.h" | ||
#include "Immutable/ImmutableSubsystem.h" | ||
#include "Immutable/Misc/ImtblLogging.h" | ||
|
||
UImtblPassportGetLinkedAddressesAsyncAction* UImtblPassportGetLinkedAddressesAsyncAction::GetLinkedAddresses(UObject* WorldContextObject) | ||
{ | ||
UImtblPassportGetLinkedAddressesAsyncAction* Node = NewObject<UImtblPassportGetLinkedAddressesAsyncAction>(); | ||
|
||
Node->WorldContextObject = WorldContextObject; | ||
|
||
return Node; | ||
} | ||
|
||
void UImtblPassportGetLinkedAddressesAsyncAction::Activate() | ||
{ | ||
if (!WorldContextObject || !WorldContextObject->GetWorld()) | ||
{ | ||
FString Err = "GetLinkedAddresses failed due to missing world or world context object."; | ||
|
||
IMTBL_WARN("%s", *Err) | ||
Failed.Broadcast(Err, TArray<FString>()); | ||
|
||
return; | ||
} | ||
|
||
GetSubsystem()->WhenReady(this, &UImtblPassportGetLinkedAddressesAsyncAction::DoGetLinkedAddresses); | ||
} | ||
|
||
void UImtblPassportGetLinkedAddressesAsyncAction::DoGetLinkedAddresses(TWeakObjectPtr<UImtblJSConnector> JSConnector) | ||
{ | ||
auto Passport = GetSubsystem()->GetPassport(); | ||
|
||
if (Passport.IsValid()) | ||
{ | ||
Passport->GetLinkedAddresses(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportGetLinkedAddressesAsyncAction::OnGetLinkedAddressesResponse)); | ||
} | ||
} | ||
|
||
void UImtblPassportGetLinkedAddressesAsyncAction::OnGetLinkedAddressesResponse(FImmutablePassportResult Result) | ||
{ | ||
if (Result.Success) | ||
{ | ||
Success.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsStringArray(Result.Response)); | ||
} | ||
else | ||
{ | ||
Failed.Broadcast(Result.Error, TArray<FString>()); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
Source/Immutable/Private/Immutable/Actions/ImtblPassportGetTokenAsyncAction.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,71 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
#include "Immutable/Actions/ImtblPassportGetTokenAsyncAction.h" | ||
|
||
#include "Immutable/ImmutablePassport.h" | ||
#include "Immutable/ImmutableSubsystem.h" | ||
#include "Immutable/Misc/ImtblLogging.h" | ||
|
||
UImtblPassportGetTokenAsyncAction* UImtblPassportGetTokenAsyncAction::GetAccessToken(UObject* WorldContextObject) | ||
{ | ||
UImtblPassportGetTokenAsyncAction* Node = NewObject<UImtblPassportGetTokenAsyncAction>(); | ||
|
||
Node->WorldContextObject = WorldContextObject; | ||
Node->Type = ACCESS; | ||
|
||
return Node; | ||
} | ||
|
||
UImtblPassportGetTokenAsyncAction* UImtblPassportGetTokenAsyncAction::GetIdToken(UObject* WorldContextObject) | ||
{ | ||
UImtblPassportGetTokenAsyncAction* Node = NewObject<UImtblPassportGetTokenAsyncAction>(); | ||
|
||
Node->WorldContextObject = WorldContextObject; | ||
Node->Type = ID; | ||
|
||
return Node; | ||
} | ||
|
||
void UImtblPassportGetTokenAsyncAction::Activate() | ||
{ | ||
if (!WorldContextObject || !WorldContextObject->GetWorld()) | ||
{ | ||
FString Err = "Get Token failed due to missing world or world context object."; | ||
IMTBL_WARN("%s", *Err) | ||
Failed.Broadcast(Err, TEXT("")); | ||
return; | ||
} | ||
|
||
|
||
GetSubsystem()->WhenReady(this, &UImtblPassportGetTokenAsyncAction::DoGetToken); | ||
} | ||
|
||
void UImtblPassportGetTokenAsyncAction::DoGetToken(TWeakObjectPtr<UImtblJSConnector> JSConnector) | ||
{ | ||
auto Passport = GetSubsystem()->GetPassport(); | ||
|
||
if (Passport.IsValid()) | ||
{ | ||
switch(Type) | ||
{ | ||
case ID: | ||
Passport->GetIdToken(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportGetTokenAsyncAction::OnGetTokenResponse)); | ||
break; | ||
case ACCESS: | ||
Passport->GetAccessToken(UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImtblPassportGetTokenAsyncAction::OnGetTokenResponse)); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
void UImtblPassportGetTokenAsyncAction::OnGetTokenResponse(FImmutablePassportResult Result) | ||
{ | ||
if (Result.Success) | ||
{ | ||
Success.Broadcast(TEXT(""), UImmutablePassport::GetResponseResultAsString(Result.Response)); | ||
} | ||
else | ||
{ | ||
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
34 changes: 0 additions & 34 deletions
34
Source/Immutable/Public/Immutable/Actions/ImtblPassportGetAccessTokenAsyncAction.h
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
Source/Immutable/Public/Immutable/Actions/ImtblPassportGetIdTokenAsyncAction.h
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
Source/Immutable/Public/Immutable/Actions/ImtblPassportGetLinkedAddressesAsyncAction.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,33 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
#pragma once | ||
|
||
#include "ImtblBlueprintAsyncAction.h" | ||
|
||
#include "ImtblPassportGetLinkedAddressesAsyncAction.generated.h" | ||
|
||
/** | ||
* The Blueprint node retrieves a list of wallet addresses linked to the passport wallet. | ||
*/ | ||
UCLASS() | ||
class IMMUTABLE_API UImtblPassportGetLinkedAddressesAsyncAction : public UImtblBlueprintAsyncAction | ||
{ | ||
GENERATED_BODY() | ||
|
||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPassportGetLinkedAddressesOutputPin, FString, ErrorMessage, const TArray<FString> &, Addresses); | ||
|
||
public: | ||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable") | ||
static UImtblPassportGetLinkedAddressesAsyncAction* GetLinkedAddresses(UObject* WorldContextObject); | ||
|
||
virtual void Activate() override; | ||
|
||
private: | ||
void DoGetLinkedAddresses(TWeakObjectPtr<class UImtblJSConnector> JSGetConnector); | ||
void OnGetLinkedAddressesResponse(struct FImmutablePassportResult Result); | ||
|
||
UPROPERTY(BlueprintAssignable) | ||
FPassportGetLinkedAddressesOutputPin Success; | ||
UPROPERTY(BlueprintAssignable) | ||
FPassportGetLinkedAddressesOutputPin Failed; | ||
}; |
Oops, something went wrong.