Skip to content

DX-2226: Added Imx Transfer section to readme #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file modified Content/BlueprintSampleContent/ImtblImxTransferWidget.uasset
Binary file not shown.
Binary file added ImxBatchNftTransfer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ImxTransferFlow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ Once the gamer is connected to Passport, the SDK will store your credentials (ac

See this Blueprint showing how to logout from passport ![Passport Logout Blueprint](PassportLogoutFlow.jpg)

#### Imx Transfer

> Note: The transfers feature require pre-approval from Immutable. Please [contact us](https://docs.immutable.com/docs/x/contact/) before making use of it.

To transfer tokens of type ETH, ERC20 or ERC721 use UImmutablePassport::ImxTransfer method. See this Blueprint example showing how to use Imx Transfer

![Imx Transfer](ImxTransferFlow.png)

To transfer multiple NFTs in a single transaction use UImmutablePassport::ImxBatchNftTransfer method. See this Blueprint example showing how to use Imx Batch Nft Transfer

![Imx Batch Nft Transfer](ImxBatchNftTransfer.png)


### Android and iOS PKCE login (Unreal Engine 5.0+ only)

For Android and iOS, you can use the [Authorization Code Flow with Proof Key for Code Exchange (PKCE)](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-proof-key-for-code-exchange-pkce) login flow instead of [Device Code Authorisation](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow#:~:text=Your%20Auth0%20Authorization%20Server%20redirects,authorized%20to%20access%20the%20API.). This means the gamer has one less step to complete and will be redirected back to the game after successfully authenticating.
Expand All @@ -108,7 +121,7 @@ To use this flow you will need to:

#### Unreal Editor Android setup

1. In Unreal Editor go to **Project Settings** -> **Android** -> **Advanced APK Packaging**
1. In Unreal Editor go to **Project Settings** -> **Android** -> **Advanced APK Packaging**
2. Add the following code inside the **Extra Settings for \<activity> section (\n to separate lines)** field:

```XML
Expand All @@ -119,7 +132,7 @@ The application will now open when the device processes any link that starts wit

#### Unreal Editor iOS setup

1. In Unreal Editor go to **Project Settings** -> **iOS** -> **Extra PList Data**
1. In Unreal Editor go to **Project Settings** -> **iOS** -> **Extra PList Data**
2. Add the following code inside the **Additional Plist Data** field:

```
Expand All @@ -135,12 +148,15 @@ See the [sample game](https://github.com/immutable/sample-unreal-game) for an ex

| Method | Description |
|--- |:---|
| GetAddress | Gets Wallet Address |
| GetEmail | Get Email Address associated with the Wallet Address |
| CheckStoredCredentials | Checks if there are stored credits from previous login |
| Connect | Log into Passport using [Device Code Authorisation](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow#:~:text=Your%20Auth0%20Authorization%20Server%20redirects,authorized%20to%20access%20the%20API.) |
| ConnectSilent | Attempts to login using stored credentials |
| ConnectPKCE | (Android and iOS on Unreal Engine 5.0+ only) Log into Passport using [Authorization Code Flow with Proof Key for Code Exchange (PKCE)](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-proof-key-for-code-exchange-pkce) |
| CheckStoredCredentials | Checks if there are stored credits from previous login |
| GetAddress | Gets Wallet Address |
| GetEmail | Get Email Address associated with the Wallet Address |
| ImxTransfer | ImxTransfer used to send tokens of type ETH, ERC20, ERC721 to reciever's address|
| ImxBatchNftTransfer | ImxBatchNftTransfer used to send multiple Nft tokens in a single transaction to reciever's address|



See the [ImmutablePassport.h](https://github.com/immutable/unreal-immutable-sdk/blob/dc39324db204f2ba30e9c9f0ca25c070987785cb/Source/Immutable/Public/Immutable/ImmutablePassport.h#L115C8-L115C8) header for the full API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "Immutable/Misc/ImtblLogging.h"


UImmutablePassportImxBatchNftTransferAsyncAction* UImmutablePassportImxBatchNftTransferAsyncAction::BatchNftTransfer(UObject* WorldContextObject,
UImmutablePassportImxBatchNftTransferAsyncAction* UImmutablePassportImxBatchNftTransferAsyncAction::ImxBatchNftTransfer(UObject* WorldContextObject,
const TArray<FNftTransferDetails>& NftTransferDetails)
{
UImmutablePassportImxBatchNftTransferAsyncAction* BlueprintNode = NewObject<UImmutablePassportImxBatchNftTransferAsyncAction>();
Expand Down Expand Up @@ -40,7 +40,7 @@ void UImmutablePassportImxBatchNftTransferAsyncAction::DoTransfer(TWeakObjectPtr
Request.nftTransferDetails = NftTransferDetails;

// Run Transfer
GetSubsystem()->GetPassport()->BatchNftTransfer(Request, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImmutablePassportImxBatchNftTransferAsyncAction::OnTransferResponse));
GetSubsystem()->GetPassport()->ImxBatchNftTransfer(Request, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImmutablePassportImxBatchNftTransferAsyncAction::OnTransferResponse));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "Immutable/Misc/ImtblLogging.h"


UImmutablePassportImxTransferAsyncAction* UImmutablePassportImxTransferAsyncAction::Transfer(UObject* WorldContextObject,
UImmutablePassportImxTransferAsyncAction* UImmutablePassportImxTransferAsyncAction::ImxTransfer(UObject* WorldContextObject,
const FString& Receiver, const FString& Type, const FString& Amount, const FString& TokenId,
const FString& TokenAddress)
{
Expand Down Expand Up @@ -47,7 +47,7 @@ void UImmutablePassportImxTransferAsyncAction::DoTransfer(TWeakObjectPtr<UImtblJ
Request.tokenId = TokenId;
Request.tokenAddress = TokenAddress;
// Run Transfer
GetSubsystem()->GetPassport()->Transfer(Request, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImmutablePassportImxTransferAsyncAction::OnTransferResponse));
GetSubsystem()->GetPassport()->ImxTransfer(Request, UImmutablePassport::FImtblPassportResponseDelegate::CreateUObject(this, &UImmutablePassportImxTransferAsyncAction::OnTransferResponse));
}


Expand Down
12 changes: 6 additions & 6 deletions Source/Immutable/Private/Immutable/ImmutablePassport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,21 @@ void UImmutablePassport::GetEmail(const FImtblPassportResponseDelegate& Response
);
}

void UImmutablePassport::Transfer(const FImxTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate)
void UImmutablePassport::ImxTransfer(const FImxTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate)
{
IMTBL_LOG("Tranfer Request: %s", *UStructToJsonString(RequestData))
CallJS(
ImmutablePassportAction::Transfer,
ImmutablePassportAction::ImxTransfer,
UStructToJsonString(RequestData),
ResponseDelegate,
FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnTransferResponse)
);
}

void UImmutablePassport::BatchNftTransfer(const FImxBatchNftTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate)
void UImmutablePassport::ImxBatchNftTransfer(const FImxBatchNftTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate)
{
CallJS(
ImmutablePassportAction::BatchNftTransfer,
ImmutablePassportAction::ImxBatchNftTransfer,
RequestData.ToJsonString(),
ResponseDelegate,
FImtblJSResponseDelegate::CreateUObject(this, &UImmutablePassport::OnBatchNftTransferResponse)
Expand Down Expand Up @@ -772,7 +772,7 @@ void UImmutablePassport::OnTransferResponse(FImtblJSResponse Response)
bool bSuccess = true;
if (!Response.success)
{
IMTBL_LOG("Transfer failed.");
IMTBL_LOG("ImxTransfer failed.");
if (Response.Error.IsSet())
{
Msg = Response.Error->ToString();
Expand All @@ -798,7 +798,7 @@ void UImmutablePassport::OnBatchNftTransferResponse(FImtblJSResponse Response)
bool bSuccess = true;
if (!Response.success || !Response.JsonObject->HasTypedField<EJson::Object>(TEXT("result")))
{
IMTBL_LOG("Transfer failed.");
IMTBL_LOG("ImxBatchNftTransfer failed.");
if (Response.Error.IsSet())
{
Msg = Response.Error->ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class IMMUTABLE_API UImmutablePassportImxBatchNftTransferAsyncAction : public UI

public:
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable")
static UImmutablePassportImxBatchNftTransferAsyncAction* BatchNftTransfer(UObject* WorldContextObject,
static UImmutablePassportImxBatchNftTransferAsyncAction* ImxBatchNftTransfer(UObject* WorldContextObject,
const TArray<FNftTransferDetails>& NftTransferDetails);

virtual void Activate() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class IMMUTABLE_API UImmutablePassportImxTransferAsyncAction : public UImtblBlue

public:
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject", BlueprintInternalUseOnly = "true"), Category = "Immutable")
static UImmutablePassportImxTransferAsyncAction* Transfer(UObject* WorldContextObject,
static UImmutablePassportImxTransferAsyncAction* ImxTransfer(UObject* WorldContextObject,
const FString& Receiver, const FString& Type, const FString& Amount, const FString& TokenId,
const FString& TokenAddress);

Expand Down
12 changes: 6 additions & 6 deletions Source/Immutable/Public/Immutable/ImmutablePassport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace ImmutablePassportAction
#endif
const FString GetAddress = TEXT("getAddress");
const FString GetEmail = TEXT("getEmail");
const FString Transfer = TEXT("imxTransfer");
const FString BatchNftTransfer = TEXT("imxBatchNftTransfer");
const FString ImxTransfer = TEXT("imxTransfer");
const FString ImxBatchNftTransfer = TEXT("imxBatchNftTransfer");
const FString EnvSandbox = TEXT("sandbox");
const FString EnvProduction = TEXT("production");
}
Expand Down Expand Up @@ -461,18 +461,18 @@ class IMMUTABLE_API UImmutablePassport : public UObject
void GetEmail(const FImtblPassportResponseDelegate& ResponseDelegate);

/**
* Create a new transfer request.
* Create a new imx transfer request.
* @param RequestData The transfer details structure of type FImxTransferRequest
* @param ResponseDelegate The response delegate of type FImtblPassportResponseDelegate to call on response from JS.
*/
void Transfer(const FImxTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate);
void ImxTransfer(const FImxTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate);

/**
* Creates a new batch nft transfer request with the given transfer details.
* Creates a new imx batch nft transfer request with the given transfer details.
* @param RequestData The transfer details structure of type FImxBatchNftTransferRequest
* @param ResponseDelegate The response delegate of type FImtblPassportResponseDelegate to call on response from JS.
*/
void BatchNftTransfer(const FImxBatchNftTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate);
void ImxBatchNftTransfer(const FImxBatchNftTransferRequest& RequestData, const FImtblPassportResponseDelegate& ResponseDelegate);

protected:
void Setup(TWeakObjectPtr<class UImtblJSConnector> Connector);
Expand Down