From aff6f6e2b86f3d827278be32c4de6a2a129493b1 Mon Sep 17 00:00:00 2001 From: Natalie Bunduwongse Date: Thu, 5 Oct 2023 07:11:32 +1300 Subject: [PATCH] docs: update readme for zkevm functions and update sample app labels --- README.md | 94 ++++++++++++------- sample/Assets/Scenes/AuthenticatedScene.unity | 38 ++++---- sample/Assets/Scripts/AuthenticatedScript.cs | 12 +-- 3 files changed, 84 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 01117163..48de29fa 100644 --- a/README.md +++ b/README.md @@ -105,41 +105,6 @@ catch (Exception) await passport.Logout(); ``` -### Immutable X Transfer - -> Note: The transfers feature require pre-approval from Immutable. Please reach out to us before making use of it. - -An unsigned transfer request for ETH, ERC20 or ERC721 is expected for the ImxTransfer method. - -```csharp -UnsignedTransferRequest request = UnsignedTransferRequest.ERC721( - receiver, - tokenId, - tokenAddress -); - -CreateTransferResponseV1 response = await passport.ImxTransfer(request); -``` - -Batch NFT transfers are also supported: - -```csharp -NftTransferDetails[] details = { - new NftTransferDetails( - receiver1, - tokenId1, - tokenAddress1 - ), - new NftTransferDetails( - receiver2, - tokenId2, - tokenAddress2 - ) -}; - -CreateBatchTransferResponse response = await passport.ImxBatchNftTransfer(details); -``` - ### Android, iOS and macOS PKCE login For Android and iOS you can use the PKCE login flow instead of Device Code. This means the gamer has one less step to complete and will be redirected back to the game after successfully authenticating. @@ -188,6 +153,62 @@ After this set-up, your game can log in using PKCE. After this set-up, your game can log in using PKCE. +### Immutable X Transfer + +> Note: The transfers features require pre-approval from Immutable. Please reach out to us before making use of it. + +An unsigned transfer request for ETH, ERC20 or ERC721 is expected for the ImxTransfer method. + +```csharp +UnsignedTransferRequest request = UnsignedTransferRequest.ERC721( + receiver, + tokenId, + tokenAddress +); + +CreateTransferResponseV1 response = await passport.ImxTransfer(request); +``` + +Batch NFT transfers are also supported: + +```csharp +NftTransferDetails[] details = { + new NftTransferDetails( + receiver1, + tokenId1, + tokenAddress1 + ), + new NftTransferDetails( + receiver2, + tokenId2, + tokenAddress2 + ) +}; + +CreateBatchTransferResponse response = await passport.ImxBatchNftTransfer(details); +``` + +### zkEVM Send Transaction + +> Note: The zkEVM send transaction feature requires pre-approval from Immutable. Please reach out to us before making use of it. + +- `To`: The destination address +- `Value`: The value to transfer for the transaction in wei +- `Data`: Byte string containing the associated data of the message + +```csharp +TransactionRequest request = new TransactionRequest() +{ + To = address, + Value = amount, + Data = data +} + +string? transactionHash = await passport.ZkEvmSendTransaction(request); +``` + +See [here](https://docs.immutable.com/docs/zkEVM/products/passport/wallet/rpc-methods/eth_sendTransaction) for more details. + ## Supported Functions - Get wallet address @@ -197,6 +218,9 @@ After this set-up, your game can log in using PKCE. - Checks if there are any credentials saved - Immutable X Transfer (ERC20, ETH and ERC721) - Immutable X NFT Batch Transfer +- zkEVM Request Accounts +- zkEVM Get balance +- zkEVM Send transaction ## Examples diff --git a/sample/Assets/Scenes/AuthenticatedScene.unity b/sample/Assets/Scenes/AuthenticatedScene.unity index 04d032e3..db4e2a3a 100644 --- a/sample/Assets/Scenes/AuthenticatedScene.unity +++ b/sample/Assets/Scenes/AuthenticatedScene.unity @@ -1981,7 +1981,7 @@ GameObject: - component: {fileID: 455311494} - component: {fileID: 455311493} m_Layer: 5 - m_Name: Amount + m_Name: Value m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -2004,8 +2004,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 116, y: -123} - m_SizeDelta: {x: 200, y: 30} + m_AnchoredPosition: {x: 66, y: -123} + m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &455311493 MonoBehaviour: @@ -2418,7 +2418,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Amount... + m_Text: Value... --- !u!222 &548681578 CanvasRenderer: m_ObjectHideFlags: 0 @@ -2622,8 +2622,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 116, y: -77} - m_SizeDelta: {x: 200, y: 30} + m_AnchoredPosition: {x: 66, y: -77} + m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &563057549 MonoBehaviour: @@ -2919,7 +2919,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 332, y: -77} + m_AnchoredPosition: {x: 232, y: -77} m_SizeDelta: {x: 200, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &649013319 @@ -6331,8 +6331,8 @@ MonoBehaviour: zkGetBalanceAccount: {fileID: 885231615} zkSendTransactionCanvas: {fileID: 1343113126} zkSendTransactionTo: {fileID: 649013321} - zkSendTransactionAmount: {fileID: 1901422923} - zkSendTransactionFunctionSignature: {fileID: 1391622483} + zkSendTransactionValue: {fileID: 1901422923} + zkSendTransactionData: {fileID: 1391622483} --- !u!1 &1216631573 GameObject: m_ObjectHideFlags: 0 @@ -6345,7 +6345,7 @@ GameObject: - component: {fileID: 1216631576} - component: {fileID: 1216631575} m_Layer: 5 - m_Name: Function signature + m_Name: Data m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -6368,8 +6368,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 116, y: -169} - m_SizeDelta: {x: 200, y: 30} + m_AnchoredPosition: {x: 66, y: -169} + m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1216631575 MonoBehaviour: @@ -6404,7 +6404,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 'Function signature:' + m_Text: 'Data:' --- !u!222 &1216631576 CanvasRenderer: m_ObjectHideFlags: 0 @@ -7071,7 +7071,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 0x... + m_Text: Data... --- !u!222 &1349875448 CanvasRenderer: m_ObjectHideFlags: 0 @@ -7280,7 +7280,7 @@ GameObject: - component: {fileID: 1391622485} - component: {fileID: 1391622483} m_Layer: 5 - m_Name: Function signature Input + m_Name: Data Input m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -7373,7 +7373,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 332, y: -168.10004} + m_AnchoredPosition: {x: 232, y: -168.10004} m_SizeDelta: {x: 200, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1391622485 @@ -9717,7 +9717,7 @@ GameObject: - component: {fileID: 1901422921} - component: {fileID: 1901422923} m_Layer: 5 - m_Name: Amount Input + m_Name: Value Input m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -9742,7 +9742,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 332, y: -123} + m_AnchoredPosition: {x: 232, y: -123} m_SizeDelta: {x: 200, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1901422921 @@ -11203,7 +11203,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1335469792} m_HandleRect: {fileID: 1335469791} m_Direction: 2 - m_Value: 0 + m_Value: 1 m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: diff --git a/sample/Assets/Scripts/AuthenticatedScript.cs b/sample/Assets/Scripts/AuthenticatedScript.cs index 1c8eb158..6f023f9d 100644 --- a/sample/Assets/Scripts/AuthenticatedScript.cs +++ b/sample/Assets/Scripts/AuthenticatedScript.cs @@ -51,8 +51,8 @@ public class AuthenticatedScript : MonoBehaviour // ZkEVM Send Transaction [SerializeField] private Canvas zkSendTransactionCanvas; [SerializeField] private InputField zkSendTransactionTo; - [SerializeField] private InputField zkSendTransactionAmount; - [SerializeField] private InputField zkSendTransactionFunctionSignature; + [SerializeField] private InputField zkSendTransactionValue; + [SerializeField] private InputField zkSendTransactionData; private Passport passport; #pragma warning restore CS8618 @@ -227,8 +227,8 @@ public async void SendZkTransaction() string? response = await passport.ZkEvmSendTransaction(new TransactionRequest() { To = zkSendTransactionTo.text, - Value = zkSendTransactionAmount.text, - Data = zkSendTransactionFunctionSignature.text + Value = zkSendTransactionValue.text, + Data = zkSendTransactionData.text }); ShowOutput($"Transaction hash: {response}"); @@ -244,8 +244,8 @@ public void ShowZkSendTransaction() authenticatedCanvas.gameObject.SetActive(false); zkSendTransactionCanvas.gameObject.SetActive(true); zkSendTransactionTo.text = ""; - zkSendTransactionAmount.text = ""; - zkSendTransactionFunctionSignature.text = ""; + zkSendTransactionValue.text = ""; + zkSendTransactionData.text = ""; } public void CancelZkSendTransaction()