From 5dbcbf24304797cad5727db4d758a3cb7b28db5a Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Mon, 19 May 2025 10:57:15 +1000 Subject: [PATCH 01/18] chore: rename PassportInit script file name --- ...InitializationScript.cs => PassportInitialisationScript.cs} | 0 ...tionScript.cs.meta => PassportInitialisationScript.cs.meta} | 0 sample/Assets/Scripts/Passport/features.json | 3 ++- 3 files changed, 2 insertions(+), 1 deletion(-) rename sample/Assets/Scripts/Passport/PassportInitialisation/{PassportInitializationScript.cs => PassportInitialisationScript.cs} (100%) rename sample/Assets/Scripts/Passport/PassportInitialisation/{PassportInitializationScript.cs.meta => PassportInitialisationScript.cs.meta} (100%) diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitializationScript.cs b/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs similarity index 100% rename from sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitializationScript.cs rename to sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitializationScript.cs.meta b/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs.meta similarity index 100% rename from sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitializationScript.cs.meta rename to sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs.meta diff --git a/sample/Assets/Scripts/Passport/features.json b/sample/Assets/Scripts/Passport/features.json index 63133284..1c9d4926 100644 --- a/sample/Assets/Scripts/Passport/features.json +++ b/sample/Assets/Scripts/Passport/features.json @@ -17,6 +17,7 @@ { "SetCallTimeout": "SetCallTimeoutScript.cs" }, { "ClearStorageAndCache": "ClearStorageAndCacheScript.cs" }, { "ImxIsRegisteredOffchain": "ImxIsRegisteredOffchainScript.cs" }, - { "ZkEvmRequestAccounts": "ZkEvmRequestAccountsScript.cs" } + { "ZkEvmRequestAccounts": "ZkEvmRequestAccountsScript.cs" }, + { "PassportInitialisation": "PassportInitializationScript.cs" } ] } \ No newline at end of file From 46e96e8d59c71fe6558d9dba2bfbc28549cefcad Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Mon, 19 May 2025 12:49:04 +1000 Subject: [PATCH 02/18] feat: generated tutorial walkthroughs for all passport features --- .../Passport/Other/SetCallTimeout.unity | 73 +------ .../Passport/ZkEvm/ZkEvmGetBalance.unity | 67 +----- .../ZkEvm/ZkEvmGetTransactionReceipt.unity | 67 +----- .../Passport/ZkEvm/ZkEvmSendTransaction.unity | 69 +------ .../Passport/ZkEvm/ZkEvmSignTypedData.unity | 73 +------ .../ClearStorageAndCache/metadata.json | 8 + .../ClearStorageAndCache/metadata.json.meta | 7 + .../Passport/ClearStorageAndCache/tutorial.md | 81 ++++++++ .../ClearStorageAndCache/tutorial.md.meta | 7 + .../Passport/GetUserInfo/metadata.json | 8 + .../Passport/GetUserInfo/metadata.json.meta | 7 + .../Scripts/Passport/GetUserInfo/tutorial.md | 195 ++++++++++++++++++ .../Passport/GetUserInfo/tutorial.md.meta | 7 + .../Scripts/Passport/ImxConnect/metadata.json | 8 + .../Passport/ImxConnect/metadata.json.meta | 7 + .../Scripts/Passport/ImxConnect/tutorial.md | 82 ++++++++ .../Passport/ImxConnect/tutorial.md.meta | 7 + .../Passport/ImxGetAddress/metadata.json | 8 + .../Passport/ImxGetAddress/metadata.json.meta | 7 + .../Passport/ImxGetAddress/tutorial.md | 72 +++++++ .../Passport/ImxGetAddress/tutorial.md.meta | 7 + .../ImxIsRegisteredOffchain/metadata.json | 8 + .../metadata.json.meta | 7 + .../ImxIsRegisteredOffchain/tutorial.md | 84 ++++++++ .../ImxIsRegisteredOffchain/tutorial.md.meta | 7 + .../Passport/ImxNftTransfer/metadata.json | 8 + .../ImxNftTransfer/metadata.json.meta | 7 + .../Passport/ImxNftTransfer/tutorial.md | 86 ++++++++ .../Passport/ImxNftTransfer/tutorial.md.meta | 7 + .../Passport/ImxRegister/metadata.json | 8 + .../Passport/ImxRegister/metadata.json.meta | 7 + .../Scripts/Passport/ImxRegister/tutorial.md | 69 +++++++ .../Passport/ImxRegister/tutorial.md.meta | 7 + .../Scripts/Passport/Login/metadata.json | 8 + .../Scripts/Passport/Login/metadata.json.meta | 7 + .../Assets/Scripts/Passport/Login/tutorial.md | 79 +++++++ .../Scripts/Passport/Login/tutorial.md.meta | 7 + .../Scripts/Passport/Logout/metadata.json | 8 + .../Passport/Logout/metadata.json.meta | 7 + .../Scripts/Passport/Logout/tutorial.md | 80 +++++++ .../Scripts/Passport/Logout/tutorial.md.meta | 7 + .../Other/SetCallTimeout/metadata.json | 8 + .../Other/SetCallTimeout/metadata.json.meta | 7 + .../Passport/Other/SetCallTimeout/tutorial.md | 66 ++++++ .../Other/SetCallTimeout/tutorial.md.meta | 7 + .../PassportInitialisation/metadata.json | 8 + .../PassportInitialisation/metadata.json.meta | 7 + .../PassportInitialisation/tutorial.md | 130 ++++++++++++ .../PassportInitialisation/tutorial.md.meta | 7 + .../Scripts/Passport/Reconnect/metadata.json | 8 + .../Passport/Reconnect/metadata.json.meta | 7 + .../Scripts/Passport/Reconnect/tutorial.md | 88 ++++++++ .../Passport/Reconnect/tutorial.md.meta | 7 + .../Scripts/Passport/Relogin/metadata.json | 8 + .../Passport/Relogin/metadata.json.meta | 7 + .../Scripts/Passport/Relogin/tutorial.md | 73 +++++++ .../Scripts/Passport/Relogin/tutorial.md.meta | 7 + .../Passport/ZkEvm/ZkEvmConnect/metadata.json | 8 + .../ZkEvm/ZkEvmConnect/metadata.json.meta | 7 + .../Passport/ZkEvm/ZkEvmConnect/tutorial.md | 82 ++++++++ .../ZkEvm/ZkEvmConnect/tutorial.md.meta | 7 + .../ZkEvm/ZkEvmGetBalance/metadata.json | 8 + .../ZkEvm/ZkEvmGetBalance/metadata.json.meta | 7 + .../ZkEvm/ZkEvmGetBalance/tutorial.md | 85 ++++++++ .../ZkEvm/ZkEvmGetBalance/tutorial.md.meta | 7 + .../ZkEvmGetTransactionReceipt/metadata.json | 8 + .../metadata.json.meta | 7 + .../ZkEvmGetTransactionReceipt/tutorial.md | 100 +++++++++ .../tutorial.md.meta | 7 + .../ZkEvm/ZkEvmRequestAccounts/metadata.json | 8 + .../ZkEvmRequestAccounts/metadata.json.meta | 7 + .../ZkEvm/ZkEvmRequestAccounts/tutorial.md | 76 +++++++ .../ZkEvmRequestAccounts/tutorial.md.meta | 7 + .../ZkEvm/ZkEvmSendTransaction/metadata.json | 8 + .../ZkEvmSendTransaction/metadata.json.meta | 7 + .../ZkEvm/ZkEvmSendTransaction/tutorial.md | 79 +++++++ .../ZkEvmSendTransaction/tutorial.md.meta | 7 + .../ZkEvm/ZkEvmSignTypedData/metadata.json | 8 + .../ZkEvmSignTypedData/metadata.json.meta | 7 + .../ZkEvm/ZkEvmSignTypedData/tutorial.md | 80 +++++++ .../ZkEvm/ZkEvmSignTypedData/tutorial.md.meta | 7 + 81 files changed, 2137 insertions(+), 317 deletions(-) create mode 100644 sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/GetUserInfo/metadata.json create mode 100644 sample/Assets/Scripts/Passport/GetUserInfo/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ImxConnect/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ImxConnect/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ImxConnect/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ImxConnect/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ImxRegister/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ImxRegister/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ImxRegister/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ImxRegister/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/Login/metadata.json create mode 100644 sample/Assets/Scripts/Passport/Login/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/Login/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/Login/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/Logout/metadata.json create mode 100644 sample/Assets/Scripts/Passport/Logout/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/Logout/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/Logout/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json create mode 100644 sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json create mode 100644 sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/Reconnect/metadata.json create mode 100644 sample/Assets/Scripts/Passport/Reconnect/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/Reconnect/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/Reconnect/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/Relogin/metadata.json create mode 100644 sample/Assets/Scripts/Passport/Relogin/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/Relogin/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/Relogin/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json.meta create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md.meta diff --git a/sample/Assets/Scenes/Passport/Other/SetCallTimeout.unity b/sample/Assets/Scenes/Passport/Other/SetCallTimeout.unity index 2ec701b6..e05ca010 100644 --- a/sample/Assets/Scenes/Passport/Other/SetCallTimeout.unity +++ b/sample/Assets/Scenes/Passport/Other/SetCallTimeout.unity @@ -557,8 +557,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 66309839} m_HandleRect: {fileID: 66309838} m_Direction: 0 - m_Value: 0 - m_Size: 1 + m_Value: 1 + m_Size: 0.99999994 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -739,8 +739,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 777.4961, y: 0} - m_SizeDelta: {x: 1554.9922, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &410008536 MonoBehaviour: @@ -1052,8 +1052,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 777.4961, y: 0} - m_SizeDelta: {x: 1554.9922, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &783923066 MonoBehaviour: @@ -1112,63 +1112,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 783923064} m_CullTransparentMesh: 1 ---- !u!1001 &844900173 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_RootOrder - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3857838456431626832, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_Name - value: AltTesterPrefab - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} --- !u!1 &872295794 GameObject: m_ObjectHideFlags: 0 @@ -1252,8 +1195,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1741513414} m_HandleRect: {fileID: 1741513413} m_Direction: 2 - m_Value: 0 - m_Size: 1 + m_Value: 1 + m_Size: 0.99999994 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: diff --git a/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmGetBalance.unity b/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmGetBalance.unity index 0070f890..fb465c1c 100644 --- a/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmGetBalance.unity +++ b/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmGetBalance.unity @@ -739,8 +739,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 895.1311, y: 0} - m_SizeDelta: {x: 1790.2622, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &410008536 MonoBehaviour: @@ -1098,8 +1098,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 895.1311, y: 0} - m_SizeDelta: {x: 1790.2622, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &783923066 MonoBehaviour: @@ -1241,7 +1241,7 @@ MonoBehaviour: m_HandleRect: {fileID: 1741513413} m_Direction: 2 m_Value: 1 - m_Size: 1 + m_Size: 0.99999994 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -2670,63 +2670,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: -20, y: -20} m_Pivot: {x: 0.5, y: 0.5} ---- !u!1001 &1929884916 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_RootOrder - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3857838456431626832, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_Name - value: AltTesterPrefab - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} --- !u!1 &1957825742 GameObject: m_ObjectHideFlags: 0 diff --git a/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmGetTransactionReceipt.unity b/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmGetTransactionReceipt.unity index fdd81964..b5965588 100644 --- a/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmGetTransactionReceipt.unity +++ b/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmGetTransactionReceipt.unity @@ -808,8 +808,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 895.1311, y: 0} - m_SizeDelta: {x: 1790.2622, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &406311237 MonoBehaviour: @@ -867,63 +867,6 @@ MonoBehaviour: m_EditorClassIdentifier: m_HorizontalFit: 0 m_VerticalFit: 2 ---- !u!1001 &500226718 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_RootOrder - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3857838456431626832, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_Name - value: AltTesterPrefab - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} --- !u!1 &519420028 GameObject: m_ObjectHideFlags: 0 @@ -1271,7 +1214,7 @@ MonoBehaviour: m_HandleRect: {fileID: 1741513413} m_Direction: 2 m_Value: 1 - m_Size: 1 + m_Size: 0.99999994 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -1688,8 +1631,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 895.1311, y: 0} - m_SizeDelta: {x: 1790.2622, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1181031973 MonoBehaviour: diff --git a/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSendTransaction.unity b/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSendTransaction.unity index 35cd130a..503610a7 100644 --- a/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSendTransaction.unity +++ b/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSendTransaction.unity @@ -1339,7 +1339,7 @@ MonoBehaviour: m_HandleRect: {fileID: 1741513413} m_Direction: 2 m_Value: 1 - m_Size: 1 + m_Size: 0.99999994 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -1418,7 +1418,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 420.14243, y: 0} + m_AnchoredPosition: {x: 443.46127, y: 0} m_SizeDelta: {x: 0, y: 60} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &885137217 @@ -3485,8 +3485,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 895.1311, y: 0} - m_SizeDelta: {x: 1790.2622, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1833965463 MonoBehaviour: @@ -3852,63 +3852,6 @@ MonoBehaviour: m_ChildScaleWidth: 0 m_ChildScaleHeight: 0 m_ReverseArrangement: 0 ---- !u!1001 &1891777080 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_RootOrder - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3857838456431626832, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_Name - value: AltTesterPrefab - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} --- !u!1 &1901422919 GameObject: m_ObjectHideFlags: 0 @@ -4477,8 +4420,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 895.1311, y: 0} - m_SizeDelta: {x: 1790.2622, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2131064088 MonoBehaviour: diff --git a/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSignTypedData.unity b/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSignTypedData.unity index b232285e..f5bacc74 100644 --- a/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSignTypedData.unity +++ b/sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSignTypedData.unity @@ -477,8 +477,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 66309839} m_HandleRect: {fileID: 66309838} m_Direction: 0 - m_Value: 0 - m_Size: 1 + m_Value: 1 + m_Size: 0.99999994 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -808,8 +808,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 835.7824, y: 0} - m_SizeDelta: {x: 1671.5648, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &406311237 MonoBehaviour: @@ -987,8 +987,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 835.7824, y: 0} - m_SizeDelta: {x: 1671.5648, y: 0} + m_AnchoredPosition: {x: 821.85657, y: 0} + m_SizeDelta: {x: 1643.7131, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &546010066 MonoBehaviour: @@ -1307,8 +1307,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1741513414} m_HandleRect: {fileID: 1741513413} m_Direction: 2 - m_Value: 0 - m_Size: 1 + m_Value: 1 + m_Size: 0.99999994 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -1687,63 +1687,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1086281026} m_CullTransparentMesh: 1 ---- !u!1001 &1189100477 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_RootOrder - value: 6 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 1289509568734035852, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 3857838456431626832, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} - propertyPath: m_Name - value: AltTesterPrefab - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: b513e9e94967f45dbbf2c4e1f36dd77e, type: 3} --- !u!1 &1192763471 GameObject: m_ObjectHideFlags: 0 diff --git a/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json b/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json new file mode 100644 index 00000000..fa08197c --- /dev/null +++ b/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Clear Storage and Cache", + "description": "Clears the WebView storage and cache on mobile platforms, removing any locally stored data and credentials", + "keywords": ["Immutable", "SDK", "Passport", "Storage", "Cache", "Mobile", "Android", "iOS"], + "tech_stack": ["Unity", "C#", "WebView"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json.meta b/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json.meta new file mode 100644 index 00000000..2d8f0654 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7447d28a5df46421a8c4a9cc5c272579 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md b/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md new file mode 100644 index 00000000..5a32b7cf --- /dev/null +++ b/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md @@ -0,0 +1,81 @@ + + +The Clear Storage and Cache feature allows you to clear the underlying WebView storage and cache on mobile devices. This is particularly useful for resetting saved credentials and other locally stored data during development or when implementing logout functionality. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ClearStorageAndCache) + +
+ +## Feature Overview + +This atomic feature demonstrates how to use the Immutable Passport SDK to clear the WebView's storage and cache on mobile platforms (Android and iOS). + +## SDK Integration Details + +The Clear Storage and Cache feature allows developers to clear all locally stored data in the WebView used by the Passport SDK. This includes: +- Local storage data +- Session storage +- WebSQL databases +- Indexed databases +- Memory and disk caches + +```csharp title="ClearStorageAndCache" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ClearStorageAndCache/ClearStorageAndCacheScript.cs" +public void ClearStorageAndCache() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null. Initialize Passport first."); + return; + } + +#if UNITY_ANDROID && !UNITY_EDITOR + ShowOutput("Clearing storage and cache..."); + Passport.Instance.ClearStorage(); + Passport.Instance.ClearCache(true); + ShowOutput("Storage and cache cleared (on Android)."); +#elif UNITY_IPHONE && !UNITY_EDITOR + ShowOutput("Clearing storage and cache..."); + Passport.Instance.ClearStorage(); + Passport.Instance.ClearCache(true); + ShowOutput("Storage and cache cleared (on iOS)."); +#else + ShowOutput("ClearStorageAndCache is only available on Android and iOS devices."); +#endif +} +``` + +The function first checks if the Passport instance is initialized. If it is, it calls two methods: + +1. `Passport.Instance.ClearStorage()` - Clears all data stored using JavaScript storage APIs, including local storage, session storage, WebSQL databases, and IndexedDB. +2. `Passport.Instance.ClearCache(true)` - Clears the WebView's resource cache, including both memory and disk cache when the `includeDiskFiles` parameter is set to `true`. + +These methods are only available on Android and iOS platforms, and will not work in the Unity Editor or on desktop platforms. + +## Running the Feature Example + +### Prerequisites +- Set up your Immutable Passport application on [Immutable Hub](https://hub.immutable.com/) +- Configure your Unity project with the Immutable Passport SDK + +### Steps to Run +1. Open the sample project in Unity +2. Navigate to the Authenticated/Unauthenticated scene +3. Build and run the application on an Android or iOS device +4. Press the "Clear Storage and Cache" button to execute the feature +5. Observe the output message confirming that storage and cache have been cleared + +## Summary + +The Clear Storage and Cache feature provides a simple way to clear all locally stored data in the WebView used by the Passport SDK. This can be useful for: +- Debugging authentication issues +- Implementing complete logout functionality +- Resetting the application state +- Clearing saved credentials + +Remember that this feature only works on actual Android and iOS devices, not in the Unity Editor or on desktop platforms. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md.meta b/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md.meta new file mode 100644 index 00000000..b423f110 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2440bdd2896ba4df3b67acaaf73b2b27 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json b/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json new file mode 100644 index 00000000..582f8e53 --- /dev/null +++ b/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Get User Information", + "description": "Retrieve user data such as email, Passport ID, access token, ID token, and linked wallet addresses from the Immutable Passport", + "keywords": ["Immutable", "SDK", "Passport", "User Info", "Authentication", "Identity"], + "tech_stack": ["Unity", "C#", "Cysharp UniTask"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json.meta b/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json.meta new file mode 100644 index 00000000..96c42d34 --- /dev/null +++ b/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 036063d5fe09740dc9e6024546daa93f +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md b/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md new file mode 100644 index 00000000..0d8b6697 --- /dev/null +++ b/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md @@ -0,0 +1,195 @@ + + +The Get User Info feature allows you to retrieve various pieces of information about the currently logged-in user through the Immutable Passport SDK. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/GetUserInfo) + +
+ +## Feature Overview + +The Get User Info feature provides easy access to user data from the Immutable Passport. This includes: + +- User email +- Passport ID +- Access token +- ID token +- Linked addresses (external wallets connected to the Passport account) + +## SDK Integration Details + +The Get User Info feature utilizes five key methods from the Passport SDK to retrieve different types of user information. Each method returns specific data related to the authenticated user. + +### Retrieving User Email + +```csharp title="GetEmail" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" +public void GetEmail() +{ + GetEmailAsync(); +} + +private async UniTaskVoid GetEmailAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + try + { + string email = await Passport.Instance.GetEmail(); + ShowOutput(email); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to get email: {ex.Message}"); + } +} +``` + +This code retrieves the email address of the currently authenticated user. It first checks if the Passport instance is available, then calls the `GetEmail()` method which returns the email as a string. The method is asynchronous and uses UniTask to handle the async operation without blocking the main thread. + +### Retrieving Passport ID + +```csharp title="GetPassportId" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" +public void GetPassportId() +{ + GetPassportIdAsync(); +} + +private async UniTaskVoid GetPassportIdAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + try + { + string passportId = await Passport.Instance.GetPassportId(); + ShowOutput(passportId); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to get Passport ID: {ex.Message}"); + } +} +``` + +The `GetPassportId()` method retrieves the unique identifier for the user's Passport account. This ID can be used to identify the user across different Immutable services. The method performs a null check on the Passport instance before making the async call and handles any exceptions that might occur during the process. + +### Retrieving Access Token + +```csharp title="GetAccessToken" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" +public void GetAccessToken() +{ + GetAccessTokenAsync(); +} + +private async UniTaskVoid GetAccessTokenAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + try + { + string accessToken = await Passport.Instance.GetAccessToken(); + ShowOutput(accessToken); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to get access token: {ex.Message}"); + } +} +``` + +The `GetAccessToken()` method retrieves the current OAuth access token for the authenticated user. This token is used for authenticating API calls to Immutable services. The method follows the same pattern of checking for a valid Passport instance, making the async call, and handling any exceptions. + +### Retrieving ID Token + +```csharp title="GetIdToken" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" +public void GetIdToken() +{ + GetIdTokenAsync(); +} + +private async UniTaskVoid GetIdTokenAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + try + { + string idToken = await Passport.Instance.GetIdToken(); + ShowOutput(idToken); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to get ID token: {ex.Message}"); + } +} +``` + +The `GetIdToken()` method retrieves the ID token, which contains claims about the identity of the authenticated user. This token follows the OpenID Connect standard and can be used to verify the user's identity. Like the other methods, it performs proper error handling and operates asynchronously. + +### Retrieving Linked Addresses + +```csharp title="GetLinkedAddresses" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" +public void GetLinkedAddresses() +{ + GetLinkedAddressesAsync(); +} + +private async UniTaskVoid GetLinkedAddressesAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + try + { + List addresses = await Passport.Instance.GetLinkedAddresses(); + string outputMessage = addresses.Count > 0 ? string.Join(", ", addresses) : "No linked addresses"; + ShowOutput(outputMessage); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to get linked addresses: {ex.Message}"); + } +} +``` + +The `GetLinkedAddresses()` method retrieves a list of external wallet addresses that the user has linked to their Passport account through the Passport dashboard. This is particularly useful for games that need to know which external wallets a user has connected. The method returns a List of strings containing the wallet addresses, and formats them for display. + +## Running the Feature Example + +### Prerequisites + +- Set up your development environment as described in the [Immutable Hub](https://hub.immutable.com/docs/overview) +- Have Unity installed (version 2021.3 LTS or newer) +- Clone the Immutable Unity SDK repository + +### Step-by-step Instructions + +1. Open the sample project in Unity Editor +2. Navigate to the Passport initialization scene +3. Play the scene to initialize Passport +4. Log in using your Immutable Passport credentials +5. Navigate to the "Get User Info" example in the sample app +6. Click on any of the buttons ("Get Email", "Get Passport ID", "Get Access Token", "Get ID Token", or "Get Linked Addresses") to retrieve the corresponding user information +7. The retrieved information will be displayed in the output text area + +## Summary + +The Get User Info feature provides simple but powerful methods to access user information from the Immutable Passport. By implementing these methods, games can easily retrieve user email, Passport ID, tokens, and linked wallet addresses. This information can be used for user identification, authentication of API calls, and connecting to the user's blockchain assets. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md.meta b/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md.meta new file mode 100644 index 00000000..8b79316b --- /dev/null +++ b/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3004807f5a2bc4b8091effcca48f62cd +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxConnect/metadata.json b/sample/Assets/Scripts/Passport/ImxConnect/metadata.json new file mode 100644 index 00000000..5a2b92cb --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxConnect/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "IMX Connect", + "description": "Connect to Immutable X, initializing the user's wallet and setting up the Immutable X provider", + "keywords": ["Immutable", "SDK", "Passport", "IMX", "Connect", "Authentication"], + "tech_stack": ["Unity", "C#", "Immutable X"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxConnect/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxConnect/metadata.json.meta new file mode 100644 index 00000000..abc2673e --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxConnect/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1a87a10906bbd4e78947b7898657bd56 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md b/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md new file mode 100644 index 00000000..a47c0365 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md @@ -0,0 +1,82 @@ + + +The IMX Connect feature allows your application to connect to Immutable X, initializing the user's wallet and setting up the Immutable X provider. This is a crucial step required before performing any Immutable X-specific operations like token transfers or NFT interactions. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/imxconnect) + +
+ +## Feature Overview + +This atomic feature demonstrates how to connect to Immutable X using the Passport SDK. + +## SDK Integration Details + +The IMX Connect feature establishes a connection to Immutable X using the user's Passport credentials. It sets up the Immutable X provider, allowing your application to interact with the Immutable X blockchain. + +```csharp title="IMXConnect" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/imxconnect/ImxConnectScript.cs" +public void ConnectImx() +{ + ConnectImxAsync(); +} + +private async UniTaskVoid ConnectImxAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + // Set the static property for global access + SampleAppManager.PassportInstance = Passport.Instance; + ShowOutput("Connecting to Passport using saved credentials..."); + try + { + await Passport.Instance.ConnectImx(); + + SampleAppManager.IsConnectedToImx = true; + ShowOutput("Connected to IMX"); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to connect to IMX: {ex.Message}"); + } +} +``` + +The code works by: + +1. When `ConnectImx()` is called, it triggers the asynchronous function `ConnectImxAsync()` +2. The function first checks if a valid Passport instance exists +3. It then calls `Passport.Instance.ConnectImx()`, which: + - Uses saved credentials if available (access token or refresh token) + - If credentials don't exist or are invalid, it opens the user's browser for authentication via device code flow + - Sets up the Immutable X provider after successful authentication +4. Upon successful connection, it updates the application state to reflect that the user is connected to Immutable X + +## Running the Feature Example + +### Prerequisites + +- Set up your environment following the [Immutable Hub documentation](https://docs.immutable.com/docs/hub/setup) +- Unity Editor (2021.3 LTS or later) +- Immutable Unity SDK installed and configured + +### Steps to Run the Example + +1. Open the sample project in Unity Editor +2. Navigate to the Passport scene that contains the IMXConnect feature +3. Enter Play mode in the Unity Editor +4. Click the "Connect IMX" button in the sample UI +5. If you're not already logged in, a browser window will open for authentication +6. After successful authentication, you will see "Connected to IMX" in the output text + +## Summary + +The IMX Connect feature is essential for any application that needs to interact with the Immutable X blockchain. It handles the authentication flow and sets up the Immutable X provider, allowing your game to perform operations like token transfers and NFT interactions. This feature provides a seamless way to connect users to Immutable X while managing the complexities of authentication and provider initialization behind the scenes. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md.meta new file mode 100644 index 00000000..8a476816 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: da4f08cf1356d40f7a41ec014f800ec0 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json b/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json new file mode 100644 index 00000000..f8b3e459 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "IMX Get Address", + "description": "Retrieve the Immutable wallet address of the currently logged-in user", + "keywords": ["Immutable", "SDK", "Passport", "Wallet", "Address", "IMX"], + "tech_stack": ["Unity", "C#"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json.meta new file mode 100644 index 00000000..ea2ee371 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7f635745bd4424a4a9f6ef74e8ee8ed8 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md b/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md new file mode 100644 index 00000000..1017f321 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md @@ -0,0 +1,72 @@ + + +Get the connected Immutable Wallet address quickly and easily. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ImxGetAddress) + +
+ +## Feature Overview + +The IMX Get Address feature allows developers to retrieve the Immutable wallet address of the currently logged-in user. This is a fundamental operation for many blockchain applications that need to identify the user's wallet address to perform transactions, display balances, or interact with smart contracts. + +## SDK Integration Details + +This feature provides a simple way to retrieve the user's wallet address through the Passport SDK. The implementation is straightforward: simply call `GetAddress()` on the Passport instance. + +```csharp title="ImxGetAddressScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ImxGetAddress/ImxGetAddressScript.cs" +/// +/// Gets the wallet address of the currently logged-in user. +/// +public async void GetAddress() +{ + ShowOutput("Retrieving wallet address..."); + try + { + string address = await Passport.GetAddress(); + ShowOutput(string.IsNullOrEmpty(address) ? "No address found" : address); + } + catch (PassportException e) + { + ShowOutput($"Unable to retrieve address: {e.Message} ({e.Type})"); + } + catch (Exception) + { + ShowOutput("Unable to retrieve address"); + } +} +``` + +### How it works + +The code performs these steps: +1. Calls the asynchronous `GetAddress()` method from the Passport SDK +2. Awaits the response which returns the wallet address as a string +3. Handles potential exceptions that might occur during the request +4. Displays the address (or an error message) to the user + +This method requires the user to be authenticated with Passport first, so make sure your application handles login before calling this method. + +## Running the Feature Example + +### Prerequisites +- Unity Editor 2022.3 or later +- [Immutable Hub](https://hub.immutable.com/) account for environment setup + +### Step-by-step instructions +1. Clone the Unity Immutable SDK repository +2. Open the sample project in Unity Editor +3. Navigate to SelectAuthMethod and login using Immutable Passport +4. In the UnauthenticatedScene, first click "Connect" to authenticate with Passport and connect to the IMX Provider +5. Once logged in, locate and click the "Get IMX Address" button +6. The wallet address will be displayed in the output area + +## Summary + +The IMX Get Address feature provides a simple way to retrieve a user's Immutable wallet address. This functionality is essential for applications that need to identify users, initiate transactions, or interact with blockchain data. By integrating this feature, developers can seamlessly connect their Unity applications with users' Immutable wallets. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md.meta new file mode 100644 index 00000000..1487ec24 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2b588afd0cb204681a9a83a19796ca3e +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json new file mode 100644 index 00000000..3be4c591 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Check Immutable X off-chain Registration Status", + "description": "Check if a user's wallet is registered off-chain with Immutable X using Passport SDK", + "keywords": ["Immutable", "SDK", "Passport", "Immutable X", "Off-chain", "Registration"], + "tech_stack": ["Unity", "C#", "Immutable Passport"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json.meta new file mode 100644 index 00000000..c4345a91 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8270c9f4ffcb447f7b3eda8c43dc7572 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md new file mode 100644 index 00000000..897c2f6f --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md @@ -0,0 +1,84 @@ + + +The IsRegisteredOffchain feature allows developers to check if a user's wallet has been registered off-chain with Immutable X. This off-chain registration is required for certain operations on Immutable X, such as trading or minting NFTs. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/imxisregisteredoffchain) + +
+ +## Feature Overview + +The ImxIsRegisteredOffchain feature demonstrates how to check if a user's wallet is registered off-chain with Immutable X protocol using the Passport SDK. + +## SDK Integration Details + +This feature utilizes the `IsRegisteredOffchain()` method from the Passport SDK to determine if the current wallet is registered with Immutable X's off-chain system. + +Off-chain registration is a one-time process that's required before users can perform operations like trading assets on Immutable X. This check helps applications determine if a user needs to complete the registration process before attempting certain operations. + +```csharp title="ImxIsRegisteredOffchainScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/imxisregisteredoffchain/ImxIsRegisteredOffchainScript.cs" +private async UniTaskVoid CheckIsRegisteredOffchainAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport not initialized."); + return; + } + + if (!SampleAppManager.IsConnectedToImx) + { + ShowOutput("Please connect to Immutable X first."); + return; + } + + ShowOutput("Checking if registered offchain..."); + try + { + bool isRegistered = await SampleAppManager.PassportInstance.IsRegisteredOffchain(); + + if (isRegistered) + { + ShowOutput("Registered"); + } + else + { + ShowOutput("User is NOT registered offchain."); + } + } + catch (System.Exception ex) + { + ShowOutput($"Failed to check registration: {ex.Message}"); + } +} +``` + +The implementation follows these steps: +1. First, it verifies that the Passport instance is initialized +2. It checks if the user is connected to Immutable X (a prerequisite for checking registration status) +3. It calls the `IsRegisteredOffchain()` method which returns a boolean indicating whether the user is registered +4. Based on the result, it displays the appropriate message to the user + +## Running the Feature Example + +### Prerequisites +- Unity Editor (2022.3 LTS or later recommended) +- Immutable Passport SDK imported into your project +- An Immutable Hub account (you can create one at [Immutable Hub](https://hub.immutable.com/)) + +### Steps to Run +1. Open the Passport sample scene in the Unity Editor +2. Connect to Passport by clicking the "Login" button +3. Connect to Immutable X by clicking the "Connect to IMX" button +4. Navigate to the ImxIsRegisteredOffchain feature section +5. Click the "Check Registration" button to verify if the wallet is registered off-chain +6. The result will be displayed in the UI showing either "Registered" or "User is NOT registered offchain" + +## Summary + +The ImxIsRegisteredOffchain feature provides developers with an easy way to check if a user's wallet is registered with Immutable X's off-chain system. This verification is important before attempting operations that require off-chain registration, helping to provide a smoother user experience by guiding users to complete registration when necessary. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md.meta new file mode 100644 index 00000000..5a88e561 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e403aa657f30742339e17451852893e0 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json b/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json new file mode 100644 index 00000000..14efbbbe --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "IMX NFT Transfer", + "description": "Transfer NFTs on Immutable X to other addresses with single and batch operations", + "keywords": ["Immutable", "SDK", "NFT", "Transfer", "Immutable X", "Passport", "ERC721", "Batch Transfer"], + "tech_stack": ["Unity", "C#", "Immutable X"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json.meta new file mode 100644 index 00000000..cd9ad3a1 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b0b736963ea804cd6bef81a7f8e54c18 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md b/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md new file mode 100644 index 00000000..30f78eb1 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md @@ -0,0 +1,86 @@ + + +The IMX NFT Transfer feature allows developers to transfer NFTs to other accounts using the Immutable X protocol. This feature provides both single and batch transfer capabilities, enabling efficient management of digital assets within your Unity application. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ImxNftTransfer) + +
+ +## Feature Overview +This example demonstrates how to use the Passport SDK to transfer NFTs on Immutable X, including: +- Single NFT transfers using `ImxTransfer` +- Batch transfers of multiple NFTs using `ImxBatchNftTransfer` + +## SDK Integration Details +### Single NFT Transfer +To transfer a single NFT to another address: + +```csharp title="Single NFT Transfer" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ImxNftTransfer/ImxNftTransferScript.cs" +NftTransferDetails nftTransferDetail = new NftTransferDetails( + receiverAddress, // Ethereum address of the receiver + tokenId, // ID of the NFT to transfer + tokenAddress // Contract address of the NFT +); + +UnsignedTransferRequest transferRequest = UnsignedTransferRequest.ERC721( + nftTransferDetail.receiver, + nftTransferDetail.tokenId, + nftTransferDetail.tokenAddress +); + +CreateTransferResponseV1 response = await Passport.Instance.ImxTransfer(transferRequest); +``` + +The code creates an `UnsignedTransferRequest` specifically for ERC721 tokens (NFTs) with the helper method `ERC721()`, then calls the Passport SDK's `ImxTransfer` method to execute the transfer. The response contains the transfer ID and status information. + +### Batch NFT Transfer +For transferring multiple NFTs in a single operation: + +```csharp title="Batch NFT Transfer" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ImxNftTransfer/ImxNftTransferScript.cs" +List transferDetails = new List(); + +// Add first NFT transfer details +transferDetails.Add(new NftTransferDetails( + receiver1, // First receiver address + tokenId1, // First NFT token ID + tokenAddress1 // First NFT contract address +)); + +// Add second NFT transfer details +transferDetails.Add(new NftTransferDetails( + receiver2, // Second receiver address + tokenId2, // Second NFT token ID + tokenAddress2 // Second NFT contract address +)); + +// Execute batch transfer +CreateBatchTransferResponse response = await Passport.Instance.ImxBatchNftTransfer(transferDetails.ToArray()); +``` + +The batch transfer method allows you to transfer multiple NFTs in a single call, which is more efficient than making individual transfer calls. The response contains an array of transfer IDs for each successfully transferred NFT. + +## Running the Feature Example +### Prerequisites +- Unity Editor 2021.3 or higher +- [Immutable Hub](https://hub.immutable.com/) account for environment setup +- Passport SDK integrated into your Unity project + +### Steps to Run the Example +1. Open the sample project in Unity Editor +2. Navigate to the `sample/Assets/Scenes/Passport/Imx/ImxNftTransfer.unity` scene +3. Ensure you have already logged in to Passport (you can use the Login feature example first) +4. Enter the required information for at least one NFT transfer: + - Token ID: The unique identifier of the NFT + - Token Address: The smart contract address for the NFT collection + - Receiver: The Ethereum address of the recipient +5. Click the "Transfer" button to execute the transfer +6. Check the output message to confirm successful transfer or identify any errors + +## Summary +The IMX NFT Transfer feature provides a straightforward way to transfer NFTs on Immutable X directly from your Unity application. It handles both single NFT transfers and batch operations, giving developers flexibility when building NFT-enabled games and applications. The implementation abstracts away the complexity of blockchain transactions, allowing you to focus on creating engaging user experiences. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md.meta new file mode 100644 index 00000000..a48a1a0e --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1f8494e14a9024243953bddd4c806384 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxRegister/metadata.json b/sample/Assets/Scripts/Passport/ImxRegister/metadata.json new file mode 100644 index 00000000..7c078e24 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxRegister/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "IMX Register", + "description": "Register users with Immutable X to enable interaction with the IMX blockchain", + "keywords": ["Immutable", "SDK", "Passport", "IMX", "Register", "Blockchain", "Layer2"], + "tech_stack": ["Unity", "C#", "Immutable Passport"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxRegister/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxRegister/metadata.json.meta new file mode 100644 index 00000000..71965af8 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxRegister/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f17fc50f6837b483c9fa1f78b9835a5b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md b/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md new file mode 100644 index 00000000..450fa908 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md @@ -0,0 +1,69 @@ + + +Register users with Immutable X to enable them to interact with the IMX blockchain. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/imxregister) + +
+ +## Feature Overview + +The IMX Register feature enables users to register with Immutable X's Layer 2 solution, which is required before they can perform transactions on the IMX blockchain. + +## SDK Integration Details + +The Immutable Passport SDK provides a simple method to register users with Immutable X. This registration is required before users can perform transactions such as transferring NFTs or tokens on the IMX blockchain. + +```csharp title="IMX Register" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/imxregister/ImxRegisterScript.cs" +public async void RegisterOffchain() +{ + ShowOutput("Registering off-chain..."); + try + { + RegisterUserResponse response = await Passport.RegisterOffchain(); + if (response != null) + { + ShowOutput($"Successfully registered"); + } + else + { + ShowOutput("Registration failed"); + } + } + catch (PassportException e) + { + ShowOutput($"Unable to register off-chain: {e.Message} ({e.Type})"); + } + catch (Exception e) + { + ShowOutput($"Unable to register off-chain {e.Message}"); + } +} +``` + +The `RegisterOffchain()` method handles the registration process with Immutable X. Upon successful registration, users can interact with the IMX blockchain. The method returns a `RegisterUserResponse` object which confirms successful registration. + +## Running the Feature Example + +### Prerequisites +- Set up your development environment with [Immutable Hub](https://hub.immutable.com/) +- Unity Editor (2022.2 or newer recommended) +- The Immutable Passport SDK installed in your Unity project + +### Step-by-step Instructions +1. Open your Unity project with the Immutable Passport SDK properly initialized +2. Navigate to the IMX Register sample scene in the project +3. Ensure you've logged in to Passport first using the login feature +4. Connect to Immutable X via the IMX Connect feature +5. Click the "Register Offchain" button to initiate the registration +6. View the output message confirming successful registration + +## Summary + +The IMX Register feature allows users to register with Immutable X's Layer 2 solution, which is a necessary step before they can perform any transactions on the IMX blockchain. This simple implementation enables quick and easy registration for your users, enhancing their experience with blockchain functionality in your game. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md.meta new file mode 100644 index 00000000..42529eca --- /dev/null +++ b/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 190c0c040bee2443d9b5c6b334555957 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Login/metadata.json b/sample/Assets/Scripts/Passport/Login/metadata.json new file mode 100644 index 00000000..6d9fdb6d --- /dev/null +++ b/sample/Assets/Scripts/Passport/Login/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Passport Authentication", + "description": "Demonstrates how to implement user authentication with Immutable Passport using PKCE and Device Code Auth methods", + "keywords": ["Immutable", "SDK", "Login", "Authentication", "PKCE", "Device Code Auth", "Passport"], + "tech_stack": ["Unity", "C#", "Passport SDK"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Login/metadata.json.meta b/sample/Assets/Scripts/Passport/Login/metadata.json.meta new file mode 100644 index 00000000..c37848f8 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Login/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 79e835cb3144a48a39b2cfab74807f4f +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md b/sample/Assets/Scripts/Passport/Login/tutorial.md new file mode 100644 index 00000000..ff4895d6 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Login/tutorial.md @@ -0,0 +1,79 @@ + + +Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Login) + +
+ +## Feature Overview +This example demonstrates how to implement user authentication using the Immutable Passport SDK. It covers two authentication methods: +1. **PKCE (Proof Key for Code Exchange)** - A more secure OAuth flow for native and mobile applications +2. **Device Code Auth** - An authentication flow designed for devices with limited input capabilities + +## SDK Integration Details + +### PKCE Login +PKCE login is recommended for platforms with a web browser, including mobile devices and desktop applications. It provides a secure authentication flow without exposing sensitive data. + +```csharp title="PKCE Login" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/Login/LoginScript.cs" +// First, initialize Passport with the appropriate redirect URIs for PKCE +SampleAppManager.UsePKCE = true; +InitialisePassport(redirectUri: "immutablerunner://callback", logoutRedirectUri: "immutablerunner://logout"); + +// Then, to perform the login: +await Passport.LoginPKCE(); +``` + +The PKCE login flow works as follows: +1. The SDK generates a code verifier and code challenge +2. The user is redirected to the Immutable Passport login page in a browser +3. After successful authentication, the browser redirects back to your application with an authorization code +4. The SDK exchanges this code for access and refresh tokens using the code verifier +5. The user is now authenticated and can interact with Immutable services + +### Device Code Auth Login +Device Code Auth is useful for devices with limited input capabilities or where opening a browser is not optimal. The user authenticates on a separate device by visiting a URL and entering a code. + +```csharp title="Device Code Auth Login" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/Login/LoginScript.cs" +// First, initialize Passport for Device Code Auth +SampleAppManager.UsePKCE = false; +InitialisePassport(logoutRedirectUri: "https://www.immutable.com"); + +// Then, to perform the login with an optional timeout: +var timeoutMs = GetDeviceCodeTimeoutMs(); // Optional timeout in milliseconds +await Passport.Login(timeoutMs: timeoutMs); +``` + +The Device Code Auth flow works as follows: +1. The SDK requests a device code from the authorization server +2. A URL and user code are presented to the user +3. The user must visit the URL on another device and enter the code +4. The SDK polls the server until the user completes authentication +5. Upon successful authentication, the user is logged in +6. An optional timeout can be specified to limit how long the SDK will wait for authentication + +## Running the Feature Example + +### Prerequisites +- Set up your development environment by following the instructions on [Immutable Hub](https://hub.immutable.com) +- Ensure you have the Immutable Passport SDK installed in your Unity project + +### Steps to Run the Login Feature +1. Open the sample project in Unity Editor +2. Navigate to the SelectAuthMethod scene +3. Enter Play mode +4. Choose either "Use PKCE" or "Use Device Code Auth" based on your preferred authentication method +5. After initialization completes, you'll be taken to the login screen +6. Click "Login" to start the authentication process + - For PKCE: A browser window will open where you can enter your credentials + - For Device Code Auth: A URL and code will be displayed; visit the URL on another device and enter the code + +## Summary +The Login feature demonstrates how to implement user authentication in your Unity game using the Immutable Passport SDK. It provides two authentication methods: PKCE for browser-capable devices and Device Code Auth for devices with limited input capabilities. By authenticating users, you enable them to access Immutable's blockchain services securely. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md.meta b/sample/Assets/Scripts/Passport/Login/tutorial.md.meta new file mode 100644 index 00000000..e911ec94 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Login/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6326f3aa908a842608e7205e8ae49ef2 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Logout/metadata.json b/sample/Assets/Scripts/Passport/Logout/metadata.json new file mode 100644 index 00000000..e1a70df4 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Logout/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Passport Logout", + "description": "Demonstrates how to implement user logout functionality in the Immutable Passport SDK", + "keywords": ["Immutable", "SDK", "Passport", "Logout", "Authentication"], + "tech_stack": ["Unity", "C#", "Immutable SDK"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Logout/metadata.json.meta b/sample/Assets/Scripts/Passport/Logout/metadata.json.meta new file mode 100644 index 00000000..780766d2 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Logout/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e3940bc6fd9f845e3bff289738a8c498 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Logout/tutorial.md b/sample/Assets/Scripts/Passport/Logout/tutorial.md new file mode 100644 index 00000000..e676039a --- /dev/null +++ b/sample/Assets/Scripts/Passport/Logout/tutorial.md @@ -0,0 +1,80 @@ + + +The Passport SDK provides a simple way to log out users from their authenticated session. This feature demonstrates how to properly implement the logout functionality in your Unity application. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/logout) + +
+ +## Feature Overview + +This atomic example demonstrates how to implement the logout functionality in the Immutable Passport SDK, allowing users to securely end their authenticated session. + +## SDK Integration Details + +The logout feature provides a clean way to end a user's authenticated session. It handles both standard logout and PKCE (Proof Key for Code Exchange) authentication methods. + +```csharp title="Logout Implementation" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/logout/LogoutScript.cs" +private async UniTaskVoid LogoutAsync() +{ + if (Passport.Instance == null) + { + Debug.LogError("Passport instance is null"); + return; + } + try + { + if (SampleAppManager.UsePKCE) + { + await Passport.Instance.LogoutPKCE(); + } + else + { + await Passport.Instance.Logout(); + } + SampleAppManager.IsConnectedToImx = false; + SampleAppManager.IsConnectedToZkEvm = false; + AuthenticatedSceneManager.NavigateToUnauthenticatedScene(); + } + catch (System.Exception ex) + { + Debug.LogError($"Failed to logout: {ex.Message}"); + } +} +``` + +The implementation works as follows: + +1. First, it checks if the Passport instance is available +2. Based on the authentication method used (standard or PKCE), it calls the appropriate logout method: + - `Passport.Instance.Logout()` for standard authentication + - `Passport.Instance.LogoutPKCE()` for PKCE authentication +3. After successful logout, it updates the application state to reflect the disconnected status +4. Finally, it navigates the user back to the unauthenticated scene +5. Error handling is implemented to catch and log any issues that occur during the logout process + +## Running the Feature Example + +### Prerequisites + +- Unity Editor 2022.3 or later +- Immutable Unity SDK installed +- Properly configured Passport environment (see [Immutable Hub](https://hub.immutable.com/) for setup instructions) + +### Steps + +1. Open the sample project in Unity Editor +2. Login using your Immutable Passport in the Unauthenticated Scene. +3. In the "AuthenticatedScene" scene, enter Play mode in the Unity Editor +5. Click the "Logout" button +6. Observe that the user is successfully logged out and redirected to the unauthenticated scene + +## Summary + +The logout feature provides a straightforward way to end a user's authenticated session in your application. By supporting both standard and PKCE authentication methods, it ensures compatibility with different authentication flows. Properly handling the logout process is crucial for maintaining security and providing a seamless user experience in your application. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Logout/tutorial.md.meta b/sample/Assets/Scripts/Passport/Logout/tutorial.md.meta new file mode 100644 index 00000000..a6703ef9 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Logout/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 26245d6155dd44b6799b47bf717f2d80 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json new file mode 100644 index 00000000..19e7885e --- /dev/null +++ b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Set Call Timeout", + "description": "Configure the timeout duration for API calls made through the Passport SDK", + "keywords": ["Immutable", "SDK", "Passport", "Timeout", "Network", "Configuration"], + "tech_stack": ["Unity", "C#"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json.meta b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json.meta new file mode 100644 index 00000000..5627a2d5 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d1c60aa7d8cd34225a4afd2271b5cd7b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md new file mode 100644 index 00000000..737693f4 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md @@ -0,0 +1,66 @@ + + +The Set Call Timeout feature allows developers to configure the timeout duration for calls made through the Passport SDK's browser communications manager. This provides greater control over network operations and improves user experience by allowing customized timeout handling. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Other/SetCallTimeout) + +
+ +## Feature Overview + +This feature demonstrates how to use the `SetCallTimeout` method from the Passport SDK to customize the timeout period for API calls. The timeout is specified in milliseconds and applies to all subsequent calls that use the browser communications manager. + +## SDK Integration Details + +The SetCallTimeout feature is implemented with a simple UI that allows users to input a custom timeout value in milliseconds. When the user enters a value and confirms the action, the timeout is set using the Passport SDK. + +```csharp title="SetCallTimeoutScript" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/Other/SetCallTimeout/SetCallTimeoutScript.cs" +public void SetTimeout() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + if (!int.TryParse(TimeoutInput.text, out int timeout)) + { + ShowOutput("Invalid timeout value"); + return; + } + Passport.Instance.SetCallTimeout(timeout); + ShowOutput($"Set call timeout to: {timeout}ms"); +} +``` + +The code works as follows: +1. It validates that the Passport SDK is properly initialized +2. It parses the user input to get the timeout value in milliseconds +3. It calls `Passport.Instance.SetCallTimeout(timeout)` to set the timeout +4. It displays a confirmation message to the user + +This timeout value affects how long the SDK will wait for responses from the Passport service before timing out. Setting an appropriate timeout can improve user experience by ensuring that operations don't hang indefinitely when network issues occur. + +## Running the Feature Example + +### Prerequisites +- Unity Editor (2021.3 LTS or later recommended) +- Immutable SDK installed and configured +- Environment variables set up in [Immutable Hub](https://hub.immutable.com) + +### Steps to Run the Example +1. Open the Unity project containing the Immutable SDK +2. Ensure you're logged in to Passport (use the Login feature first) +3. Navigate to the "SetCallTimeout" scene in the Passport/Other directory +4. Enter a timeout value in milliseconds in the input field +5. Click the "Set Timeout" button to apply the setting +6. The confirmation message will display the newly set timeout value + +## Summary + +The SetCallTimeout feature provides a simple way to control how long API calls wait for a response before timing out. By setting an appropriate timeout, developers can enhance their application's resilience to network issues and provide better feedback to users when operations take longer than expected. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md.meta b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md.meta new file mode 100644 index 00000000..dbcbc34a --- /dev/null +++ b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5be11a350b38f425f88f3fb88911eef7 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json b/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json new file mode 100644 index 00000000..af164e46 --- /dev/null +++ b/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Passport Initialisation", + "description": "Initialize the Immutable Passport SDK with the appropriate configuration settings for both Device Code Auth and PKCE authentication methods", + "keywords": ["Immutable", "SDK", "Passport", "Initialisation", "Authentication", "PKCE", "Device Code Auth"], + "tech_stack": ["Unity", "C#", "Immutable SDK"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json.meta b/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json.meta new file mode 100644 index 00000000..81791629 --- /dev/null +++ b/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 68535d953d9d5454db46456ed83aa959 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md b/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md new file mode 100644 index 00000000..84656f2a --- /dev/null +++ b/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md @@ -0,0 +1,130 @@ + + +Learn how to properly initialize the Immutable Passport SDK in your Unity game. This foundational step is required before utilizing any other Passport features. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/PassportInitialisation) + +
+ +## Feature Overview + +This example demonstrates how to initialize the Immutable Passport SDK with the appropriate configuration settings for both Device Code Auth and PKCE (Proof Key for Code Exchange) authentication methods. + +## SDK Integration Details + +### Initializing Passport with Device Code Auth + +Device Code Auth is suitable for most desktop platforms, especially Windows. This method opens the player's default browser for authentication. + +```csharp title="PassportInitialisationScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs" +public void UseDeviceCodeAuth() +{ + SampleAppManager.UsePKCE = false; + InitialisePassport(logoutRedirectUri: "https://www.immutable.com"); +} + +private async void InitialisePassport(string? redirectUri = null, string? logoutRedirectUri = null) +{ + try { + // Set the log level for the SDK + Passport.LogLevel = LogLevel.Info; + + // Don't redact token values from logs + Passport.RedactTokensInLogs = false; + + // Initialise Passport + string environment = Immutable.Passport.Model.Environment.SANDBOX; + string clientId = "mp6rxfMDwwZDogcdgNrAaHnG0qMlXuMK"; + Passport passport = await Passport.Init(clientId, environment, redirectUri, logoutRedirectUri); + SampleAppManager.PassportInstance = passport; + + // Navigate to the unauthenticated scene after initialising Passport + SceneManager.LoadScene("UnauthenticatedScene"); + } + catch (Exception ex) { + Debug.LogException(ex, this); + ShowOutput($"Initialise Passport error: {ex.Message}"); + } +} +``` + +### Initializing Passport with PKCE Auth + +PKCE (Proof Key for Code Exchange) is recommended for mobile platforms (Android, iOS) and macOS. It provides a more seamless experience with in-app browsers or pop-up windows. + +```csharp title="PassportInitialisationScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs" +public void UsePKCE() +{ + SampleAppManager.UsePKCE = true; +#if UNITY_WEBGL + string url = Application.absoluteURL; + Uri uri = new Uri(url); + string scheme = uri.Scheme; + string hostWithPort = uri.IsDefaultPort ? uri.Host : $"{uri.Host}:{uri.Port}"; + string fullPath = uri.AbsolutePath.EndsWith("/") ? uri.AbsolutePath : uri.AbsolutePath.Substring(0, uri.AbsolutePath.LastIndexOf('/') + 1); + + string redirectUri = $"{scheme}://{hostWithPort}{fullPath}callback.html"; + string logoutRedirectUri = $"{scheme}://{hostWithPort}{fullPath}logout.html"; + + InitialisePassport(redirectUri: redirectUri, logoutRedirectUri: logoutRedirectUri); +#else + InitialisePassport(redirectUri: "immutablerunner://callback", logoutRedirectUri: "immutablerunner://logout"); +#endif +} +``` + +### How It Works + +1. **Configure Authentication Method**: + - The sample allows selecting between Device Code Auth and PKCE + - WebGL builds automatically default to PKCE + +2. **Setting Up Passport**: + - Set log level for appropriate debugging feedback + - Configure token redaction behavior for security + - Specify the environment (SANDBOX or PRODUCTION) + - Provide your client ID obtained from Immutable Hub + - Pass the appropriate redirect URIs based on authentication method + +3. **Handling Platform-Specific Requirements**: + - WebGL builds need special handling to dynamically determine callback URIs + - Other platforms use custom URI schemes (e.g., "immutablerunner://callback") + +4. **Managing Errors**: + - Initialization errors are properly caught and logged + +## Running the Feature Example + +### Prerequisites + +- Unity 2021.3 or newer +- Basic understanding of Unity concepts +- Immutable Hub account (set up at [Immutable Hub](https://hub.immutable.com/)) + +### Steps + +1. **Import the SDK**: + - Install the Immutable Unity SDK via the Unity Package Manager + - Add the package from https://github.com/immutable/unity-immutable-sdk.git?path=/src/Packages/Passport + +2. **Configure Your Client**: + - Register your game as an OAuth 2.0 Native client in Immutable Hub + - Take note of your client ID + - Configure appropriate redirect URIs in your Hub settings + +3. **Run the Example**: + - Open the "SelectAuthScene" scene in Unity Editor + - Enter Play mode + - Click either the "Use Device Code Auth" or "Use PKCE" button to initialize Passport + - For Device Code Auth, your browser will open for authentication + - For PKCE on platforms that support it, a pop-up or in-app browser will appear + +## Summary + +The Passport Initialisation feature demonstrates how to properly set up and configure the Immutable Passport SDK in your Unity application. This is a critical first step before using any other Passport features like login, wallet operations, or blockchain interactions. The sample shows how to handle both authentication methods and platform-specific requirements, ensuring your game can work across desktop, mobile, and web platforms. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md.meta b/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md.meta new file mode 100644 index 00000000..e89f7dbe --- /dev/null +++ b/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9c42b115adf2340a7a93c5883f458637 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Reconnect/metadata.json b/sample/Assets/Scripts/Passport/Reconnect/metadata.json new file mode 100644 index 00000000..0fcf1d19 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Reconnect/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Passport Reconnect", + "description": "Demonstrates how to reconnect users to Passport using previously saved credentials without requiring re-authentication", + "keywords": ["Immutable", "SDK", "Passport", "Reconnect", "Authentication"], + "tech_stack": ["Unity", "C#", "Immutable SDK"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Reconnect/metadata.json.meta b/sample/Assets/Scripts/Passport/Reconnect/metadata.json.meta new file mode 100644 index 00000000..5a6d298d --- /dev/null +++ b/sample/Assets/Scripts/Passport/Reconnect/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bb3f8dd4de9aa4db6b7a2afb3f77c082 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Reconnect/tutorial.md b/sample/Assets/Scripts/Passport/Reconnect/tutorial.md new file mode 100644 index 00000000..770287f4 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Reconnect/tutorial.md @@ -0,0 +1,88 @@ + + +Easily reconnect to Passport using saved credentials for a seamless user experience without requiring users to log in again. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Reconnect) + +
+ +## Feature Overview +The Reconnect feature allows you to reconnect a user to Passport by utilizing previously saved credentials, eliminating the need for users to authenticate again when they return to your application. This enhances user experience by providing a seamless, frictionless re-entry into your application. + +## SDK Integration Details +The Passport SDK provides a straightforward way to reconnect users with their saved credentials through the `ConnectImx` method with the `useCachedSession` parameter set to `true`. + +```csharp title="Reconnect" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/Reconnect/ReconnectScript.cs" +public void Reconnect() +{ + ReconnectAsync(); +} + +private async UniTaskVoid ReconnectAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport Instance is null"); + return; + } + ShowOutput("Reconnecting to Passport using saved credentials..."); + try + { + bool connected = await Passport.Instance.ConnectImx(useCachedSession: true); + if (connected) + { + // Set IMX and zkEVM state and update UI as if user clicked Connect to IMX/EVM + SampleAppManager.IsConnectedToImx = true; + SampleAppManager.IsConnectedToZkEvm = true; + SampleAppManager.PassportInstance = Passport.Instance; + var sceneManager = GameObject.FindObjectOfType(); + if (sceneManager != null) + { + sceneManager.UpdateImxButtonStates(); + sceneManager.UpdateZkEvmButtonStates(); + } + NavigateToAuthenticatedScene(); + } + else + { + ShowOutput("Could not reconnect using saved credentials"); + } + } + catch (System.Exception ex) + { + ShowOutput($"Failed to reconnect: {ex.Message}"); + } +} +``` + +The reconnect process works by: +1. Calling `ConnectImx` with `useCachedSession` set to `true`, which attempts to use saved credentials +2. If successful, updating the application state to reflect the authenticated user +3. Navigating to the authenticated scene +4. If unsuccessful, showing an appropriate error message + +Behind the scenes, the SDK checks for saved credentials and automatically refreshes the authentication tokens if necessary, without requiring any user interaction. + +## Running the Feature Example +### Prerequisites +- Unity Editor 2021.3 or later +- Immutable SDK installed in your project +- A registered application in [Immutable Hub](https://hub.immutable.com) +- Configured environment variables (Client ID, etc.) + +### Steps to Run +1. Open the sample project in Unity Editor +2. Navigate to the Passport scene +3. Ensure you have previously logged in at least once to create saved credentials +4. Click the "Reconnect" button in the Passport demo UI +5. The app will attempt to reconnect using saved credentials +6. If successful, you'll be redirected to the authenticated scene + +## Summary +The Reconnect feature provides a seamless way to improve user experience by allowing returning users to bypass the login process. By utilizing saved credentials, your application can provide a frictionless authentication experience that reduces friction and encourages user retention. This approach is particularly valuable for games and applications where maintaining engagement is critical. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Reconnect/tutorial.md.meta b/sample/Assets/Scripts/Passport/Reconnect/tutorial.md.meta new file mode 100644 index 00000000..c0e446ad --- /dev/null +++ b/sample/Assets/Scripts/Passport/Reconnect/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1a421fa9f6ff84c458b9b70cd0b18172 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Relogin/metadata.json b/sample/Assets/Scripts/Passport/Relogin/metadata.json new file mode 100644 index 00000000..d0a7fbee --- /dev/null +++ b/sample/Assets/Scripts/Passport/Relogin/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Relogin with Cached Credentials", + "description": "Demonstrates how to use cached credentials to seamlessly re-login users to Passport without requiring re-authentication", + "keywords": ["Immutable", "SDK", "Passport", "Relogin", "Authentication", "Cached Credentials"], + "tech_stack": ["Unity", "C#", "UniTask"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Relogin/metadata.json.meta b/sample/Assets/Scripts/Passport/Relogin/metadata.json.meta new file mode 100644 index 00000000..e3721d72 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Relogin/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 28beba9a714c44f85ae21fc35205efbc +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Relogin/tutorial.md b/sample/Assets/Scripts/Passport/Relogin/tutorial.md new file mode 100644 index 00000000..9b51e148 --- /dev/null +++ b/sample/Assets/Scripts/Passport/Relogin/tutorial.md @@ -0,0 +1,73 @@ + + +Use saved credentials to re-login to Passport, allowing users to seamlessly resume their session without requiring re-authentication. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Relogin) + +
+ +## Feature Overview + +The Relogin feature demonstrates how to use existing cached credentials to log back into Passport without requiring users to authenticate again. This is particularly useful for improving user experience after app restarts or temporary disconnections. + +## SDK Integration Details + +The Relogin functionality leverages the Passport SDK's ability to use cached sessions. When implemented, it allows the application to attempt logging in using previously stored credentials. + +```csharp title="ReloginScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Relogin/ReloginScript.cs" +private async UniTaskVoid ReloginAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport Instance is null"); + return; + } + ShowOutput("Re-logging into Passport using saved credentials..."); + try + { + bool loggedIn = await Passport.Instance.Login(useCachedSession: true); + if (loggedIn) + { + NavigateToAuthenticatedScene(); + } + else + { + ShowOutput("Could not re-login using saved credentials"); + } + } + catch (System.Exception ex) + { + ShowOutput($"Failed to re-login: {ex.Message}"); + } +} +``` + +The key part of this implementation is passing `useCachedSession: true` to the `Passport.Instance.Login()` method. This parameter instructs the SDK to attempt logging in using previously saved credentials instead of triggering a new authentication flow. + +When successful, the user is automatically logged in and redirected to the authenticated experience. If the cached credentials are invalid or expired, the login attempt will fail, and the application can then prompt for manual login. + +## Running the Feature Example + +### Prerequisites +- Unity Editor 2022.3 or later +- Immutable Unity SDK installed +- Environment set up using [Immutable Hub](https://hub.immutable.com) + +### Steps +1. Open the sample project in Unity Editor +2. Navigate to the Scenes folder and open the Unauthenticated scene +3. In the Hierarchy panel, locate and select the Relogin button +4. Play the scene in the Editor +5. First login normally to create cached credentials +6. Stop the playback and start it again +7. Click the "Relogin" button to test the re-login functionality + +## Summary + +The Relogin feature provides a seamless way to maintain user sessions across app restarts or reconnections by leveraging cached credentials. By using the `useCachedSession: true` parameter with the Login method, developers can create a frictionless authentication experience for returning users. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Relogin/tutorial.md.meta b/sample/Assets/Scripts/Passport/Relogin/tutorial.md.meta new file mode 100644 index 00000000..ccdf807d --- /dev/null +++ b/sample/Assets/Scripts/Passport/Relogin/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d5e8853f6b99e462abaf4a3711972afc +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json new file mode 100644 index 00000000..09f443f4 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Connect to zkEVM", + "description": "Connect your Unity game to the Immutable zkEVM network using Passport SDK", + "keywords": ["Immutable", "SDK", "Passport", "zkEVM", "Blockchain", "Web3", "Connect"], + "tech_stack": ["Unity", "C#", "Passport SDK", "zkEVM"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json.meta new file mode 100644 index 00000000..da232404 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c73921d23c00d4e15aa9962eebb099b9 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md new file mode 100644 index 00000000..fa5c8dc6 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md @@ -0,0 +1,82 @@ + + +Connect to Immutable zkEVM to enable blockchain transactions and interactions in your Unity game. This feature allows players to connect their Passport wallet to the zkEVM network, enabling a wide range of blockchain operations including sending transactions, checking balances, and signing data. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect) + +
+ +## Feature Overview + +This example demonstrates how to connect to the Immutable zkEVM network using the Passport SDK. The connection to zkEVM is a prerequisite for performing any other zkEVM operations like sending transactions or checking balances. + +## SDK Integration Details + +The ZkEvmConnect feature establishes a connection between your game and the Immutable zkEVM network through the user's Passport wallet. This connection enables subsequent blockchain operations like sending transactions, signing data, and checking balances. + +```csharp title="ZkEvmConnectScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/ZkEvmConnectScript.cs" +private async UniTaskVoid ConnectZkEvmAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport not initialized."); + return; + } + + ShowOutput("Connecting to zkEVM..."); + try + { + await Passport.Instance.ConnectEvm(); + + // Update connection state and refresh UI + SampleAppManager.IsConnectedToZkEvm = true; + var sceneManager = FindObjectOfType(); + if (sceneManager != null) + { + sceneManager.UpdateZkEvmButtonStates(); + } + + ShowOutput("Connected to EVM"); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to connect to zkEVM: {ex.Message}"); + } +} +``` + +The implementation works as follows: + +1. First, it checks if the Passport instance is initialized, which is a prerequisite for connecting to zkEVM. +2. Then it calls `Passport.Instance.ConnectEvm()`, which initiates the connection to the Immutable zkEVM network. +3. After successful connection, it updates the application state to reflect the connected status. +4. Finally, it updates the UI to enable buttons for other zkEVM operations that require an active connection. + +## Running the Feature Example + +### Prerequisites + +- Unity 2021.3 LTS or newer +- Immutable SDK package imported into your project +- Passport configured with appropriate credentials from [Immutable Hub](https://hub.immutable.com) +- User must be logged in to Passport before connecting to zkEVM + +### Steps to Run + +1. Open the sample scene in Unity Editor +2. Enter Play mode +3. Log in to Passport if not already logged in +4. Navigate to the zkEVM section in the sample app +5. Click the "Connect to zkEVM" button +6. If successful, you'll see "Connected to EVM" in the output text area +7. Other zkEVM-related buttons will become active, indicating you can now perform those operations + +## Summary + +The ZkEvmConnect feature provides a straightforward way to establish a connection to the Immutable zkEVM network, which is required for any blockchain interactions on this network. Once connected, your application can perform various blockchain operations such as sending transactions, checking balances, and signing data. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md.meta new file mode 100644 index 00000000..45cf93f7 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fac0c831a9a9142dbae170b1b8205841 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json new file mode 100644 index 00000000..eec2be11 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Get Account Balance from zkEVM", + "description": "Learn how to query Ethereum account balances on the Immutable zkEVM blockchain using the Passport SDK", + "keywords": ["Immutable", "SDK", "zkEVM", "Balance", "Ethereum", "Blockchain", "Web3"], + "tech_stack": ["Unity", "C#", "Immutable Passport SDK", "zkEVM"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json.meta new file mode 100644 index 00000000..03f31e06 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 72b2111e863a846de99a42fc6aafd4c0 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md new file mode 100644 index 00000000..debcc2c3 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md @@ -0,0 +1,85 @@ + + +This feature demonstrates how to retrieve an account's balance from the Immutable zkEVM blockchain using the Passport SDK. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance) + +
+ +## Feature Overview + +The ZkEvmGetBalance feature lets developers query the balance of any Ethereum address on the Immutable zkEVM blockchain. This is essential for games and applications that need to display user balances, check if users have sufficient funds for transactions, or monitor balance changes. + +## SDK Integration Details + +The feature utilizes the `ZkEvmGetBalance` method from the Passport SDK to retrieve the account balance in Wei (the smallest unit of Ether). + +```csharp title="ZkEvmGetBalanceScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/ZkEvmGetBalanceScript.cs" +public void GetBalance() +{ + GetBalanceAsync(); +} + +private async UniTaskVoid GetBalanceAsync() +{ + if (SampleAppManager.PassportInstance == null) + { + ShowOutput("Passport instance is null"); + return; + } + ShowOutput("Getting account balance..."); + try + { + string balanceHex = await SampleAppManager.PassportInstance.ZkEvmGetBalance(AddressInput.text); + var balanceDec = BigInteger.Parse(balanceHex.Replace("0x", ""), NumberStyles.HexNumber); + if (balanceDec < 0) + { + balanceDec = BigInteger.Parse("0" + balanceHex.Replace("0x", ""), NumberStyles.HexNumber); + } + ShowOutput($"Balance:\nHex: {balanceHex}\nDec: {balanceDec}"); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to get balance: {ex.Message}"); + } +} +``` + +The implementation works as follows: + +1. The `GetBalance` method is called when the user initiates a balance check. +2. Inside `GetBalanceAsync`, the code first verifies that the Passport instance is available. +3. It then calls `ZkEvmGetBalance` with the address input provided by the user (the account address to check). +4. The balance is returned in hexadecimal format (e.g., "0x1a2b3c4d"). +5. The code converts this hexadecimal value to a decimal representation using `BigInteger.Parse`. +6. If parsing results in a negative number (which can happen with very large hex values), the code prepends a "0" to ensure proper parsing. +7. Both the hexadecimal and decimal representations of the balance are displayed to the user. + +## Running the Feature Example + +### Prerequisites +- Unity Editor (2021.3 LTS or newer) +- An Immutable Passport account (create one at [Immutable Hub](https://hub.immutable.com)) +- The Immutable Unity SDK properly installed and configured + +### Steps to Run the Example + +1. Open the sample project in Unity Editor. +2. Make sure you have properly configured the Passport SDK with your credentials. +3. Build and run the sample app. +4. Log in to your Passport account when prompted. +5. Navigate to the authenticated screen. +6. Connect to zkEVM by clicking the "Connect zkEVM" button. +7. After connecting, click the "Get Balance" button. +8. Enter an Ethereum address in the input field. +9. Submit the request to view the account balance in both hexadecimal and decimal format. + +## Summary + +The ZkEvmGetBalance feature provides a straightforward way to query account balances on the Immutable zkEVM blockchain. By integrating this feature, developers can enable their games and applications to check user balances, which is essential for features like displaying wallet information, verifying sufficient funds before transactions, or implementing conditional logic based on user balances. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md.meta new file mode 100644 index 00000000..685704b9 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 175970d682bd74260b1767a76129a79c +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json new file mode 100644 index 00000000..54ec1dd2 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Retrieve zkEVM Transaction Receipt", + "description": "Learn how to retrieve and interpret transaction receipts from the Immutable zkEVM blockchain using the Passport SDK", + "keywords": ["Immutable", "SDK", "Passport", "zkEVM", "Transaction", "Receipt", "Blockchain"], + "tech_stack": ["Unity", "C#", "Immutable Passport"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json.meta new file mode 100644 index 00000000..80ef76b5 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a6afe94d9e17543ddbf5e3471ebcf0d7 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md new file mode 100644 index 00000000..40d3a449 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md @@ -0,0 +1,100 @@ + + +The Immutable Passport SDK provides functionality to retrieve transaction receipts from the Immutable zkEVM blockchain. This feature allows developers to check the status of a transaction to determine if it has been processed successfully, failed, or is still pending. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt) + +
+ +## Feature Overview + +The ZkEvmGetTransactionReceipt feature demonstrates how to use the Immutable Passport SDK to retrieve the receipt of a transaction on the Immutable zkEVM blockchain using a transaction hash. + +## SDK Integration Details + +This feature demonstrates how to retrieve a transaction receipt from the Immutable zkEVM blockchain using the Passport SDK. To implement this functionality, you need to: + +1. Ensure that the user is connected to zkEVM +2. Call the ZkEvmGetTransactionReceipt method with the transaction hash +3. Process the transaction receipt response + +```csharp title="ZkEvmGetTransactionReceiptScript" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/ZkEvmGetTransactionReceiptScript.cs" +private async UniTaskVoid GetZkEvmTransactionReceiptAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + ShowOutput("Getting transaction receipt..."); + try + { + await Passport.Instance.ConnectEvm(); + TransactionReceiptResponse response = await Passport.Instance.ZkEvmGetTransactionReceipt(TransactionHash.text); + string status = $"Status: {GetTransactionStatusString(response.status)}"; + ShowOutput(status); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to retrieve transaction receipt: {ex.Message}"); + } +} + +private string GetTransactionStatusString(string status) +{ + switch (status) + { + case "1": + case "0x1": + return "Success"; + case "0": + case "0x0": + return "Failed"; + case null: + return "Still processing"; + default: + return "Unknown status"; + } +} +``` + +The example above demonstrates the following steps: + +1. First, we call `ConnectEvm()` to ensure the user is connected to the zkEVM network. +2. Then, we call `ZkEvmGetTransactionReceipt(txHash)` with the transaction hash to retrieve the transaction receipt. +3. The response contains a status field that indicates whether the transaction was successful, failed, or is still processing. +4. We interpret the status code using a helper method that converts the raw status code to a human-readable string. + +The `TransactionReceiptResponse` object provides comprehensive information about the transaction, including: +- Transaction status (success, failure, or processing) +- Block information (hash, number) +- Gas usage information +- Transaction details (hash, index, etc.) +- Logs generated by the transaction + +## Running the Feature Example + +### Prerequisites + +- A Unity project with Immutable Passport SDK installed +- An Immutable Hub account and configured environment. [Sign up here](https://hub.immutable.com/) if you don't have one. +- A valid transaction hash from a previously executed transaction on Immutable zkEVM + +### Step-by-step Instructions + +1. Open the Unity Editor with the Immutable SDK sample project +2. Ensure you're logged in to Passport through the sample app +3. Navigate to the ZkEvmGetTransactionReceipt scene +4. Enter a valid transaction hash in the input field +5. Click the "Get Transaction Receipt" button +6. The status of the transaction will be displayed in the output field + +## Summary + +The ZkEvmGetTransactionReceipt feature provides a simple way to check the status of a transaction on the Immutable zkEVM blockchain. It allows developers to determine if a transaction has been successfully processed, failed, or is still pending, which is essential for providing feedback to users in applications that involve blockchain transactions. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md.meta new file mode 100644 index 00000000..df1bcaee --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5946e62ec65f44b48aa3f58908041026 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json new file mode 100644 index 00000000..ea65a0c3 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "Request Wallet Accounts", + "description": "Retrieve Ethereum addresses associated with the user's Immutable Passport account", + "keywords": ["Immutable", "SDK", "Passport", "ZkEvm", "Accounts", "Wallet", "Ethereum", "Unity"], + "tech_stack": ["Unity", "C#", "Immutable SDK", "Passport"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json.meta new file mode 100644 index 00000000..a48f9018 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a4a4f2fd3742c4a1d861bcf46930d688 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md new file mode 100644 index 00000000..8a6e9476 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md @@ -0,0 +1,76 @@ + + +Retrieve wallet addresses from the user's Immutable Passport account using the ZkEvmRequestAccounts feature. This feature allows your Unity application to access the Ethereum addresses associated with the logged-in user's Passport account. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts) + +
+ +## Feature Overview + +The ZkEvmRequestAccounts feature provides a simple way to request the list of Ethereum addresses associated with the user's Immutable Passport account. This is a crucial step for any application that needs to interact with the user's blockchain wallet or perform blockchain operations on their behalf. + +## SDK Integration Details + +The ZkEvmRequestAccounts feature allows you to retrieve the Ethereum addresses from the user's Passport account using a simple asynchronous call. + +```csharp title="ZkEvmRequestAccountsScript" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/ZkEvmRequestAccountsScript.cs" +private async UniTaskVoid RequestAccountsAsync() +{ + if (SampleAppManager.PassportInstance == null) + { + ShowOutput("Passport not initialized."); + return; + } + + ShowOutput("Requesting wallet accounts..."); + try + { + List accounts = await SampleAppManager.PassportInstance.ZkEvmRequestAccounts(); + ShowOutput(accounts.Count > 0 ? string.Join(", ", accounts) : "No accounts found."); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to request wallet accounts: {ex.Message}"); + } +} +``` + +The code works by: + +1. Checking if the Passport instance is properly initialized +2. Making an asynchronous call to `ZkEvmRequestAccounts()` method from the Passport SDK +3. Receiving a list of Ethereum addresses associated with the user's account +4. Displaying the results or handling any errors that occur during the process + +This feature should be used after a user has successfully logged in to Passport and before performing any blockchain operations that require their wallet address. + +## Running the Feature Example + +### Prerequisites + +Before running the feature example, ensure you have: + +1. Set up your Immutable Passport application on [Immutable Hub](https://hub.immutable.com) +2. Configured your Unity project with the Immutable Passport SDK +3. Successfully initialized Passport in your application +4. User must be logged in to Passport + +### Steps to Run + +1. Open the sample Unity project in the Unity Editor +2. Navigate to the Scenes folder, open the "AuthenticatedScene" scene, and click on the "Connect to EVM" button. +3. Then, click on the "Request accounts" button containing the ZkEvmRequestAccounts example +4. Log in to your Passport account if not already logged in +5. Click the "Request Accounts" button in the UI +6. The addresses associated with the user's Passport account will be displayed in the output area + +## Summary + +The ZkEvmRequestAccounts feature provides a straightforward way to retrieve Ethereum addresses associated with the user's Passport account. This feature is essential for any dApp that needs to interact with the blockchain on behalf of the user, as it provides the necessary wallet addresses for transaction signing and other operations. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md.meta new file mode 100644 index 00000000..ad84e3c9 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2298e10deedec4487b116f4db8e05488 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json new file mode 100644 index 00000000..843625ba --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "ZkEvm Send Transaction", + "description": "Send transactions to the Immutable zkEVM network from your Unity game, allowing users to interact with smart contracts and transfer assets.", + "keywords": ["Immutable", "SDK", "Passport", "zkEVM", "Transaction", "Blockchain", "Smart Contract"], + "tech_stack": ["Unity", "C#", "Immutable Passport SDK", "zkEVM"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json.meta new file mode 100644 index 00000000..d6fef291 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: abe05855192e041f69850866b26c3965 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md new file mode 100644 index 00000000..57eee612 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md @@ -0,0 +1,79 @@ + + +Send transactions to the Immutable zkEVM network from your Unity game using Passport SDK. This feature allows your users to sign and submit transactions to execute smart contract methods or transfer assets. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction) + +
+ +## Feature Overview +This Passport feature demonstrates how to send transactions to the Immutable zkEVM network using the authenticated Passport user's account. It provides two transaction modes: +- Basic transaction submission (`ZkEvmSendTransaction`) +- Transaction with confirmation (`ZkEvmSendTransactionWithConfirmation`) + +## SDK Integration Details + +### Sending a Transaction + +The Passport SDK provides a simple way to send transactions to the zkEVM network: + +```csharp title="ZkEvmSendTransactionScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/ZkEvmSendTransactionScript.cs" +// Create transaction request +TransactionRequest request = new TransactionRequest +{ + to = ToInputField.text, // Destination address + value = ValueInputField.text, // Amount of IMX to send (in wei) + data = DataInputField.text // Transaction data (for contract interactions) +}; + +// Send transaction without confirmation +string transactionHash = await SampleAppManager.PassportInstance.ZkEvmSendTransaction(request); +``` + +This method returns a transaction hash immediately after submission, allowing your application to continue while the transaction is being processed by the network. + +### Sending a Transaction with Confirmation + +For use cases where you need to know the transaction result before proceeding: + +```csharp title="ZkEvmSendTransactionScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/ZkEvmSendTransactionScript.cs" +// Send transaction with confirmation and display transaction status upon completion +TransactionReceiptResponse response = await SampleAppManager.PassportInstance.ZkEvmSendTransactionWithConfirmation(request); +``` + +This method waits for the transaction to be included in a block and returns the transaction receipt, which includes the transaction status (success or failure). + +### Checking Transaction Status + +You can also manually poll for transaction status using the transaction hash: + +```csharp title="ZkEvmSendTransactionScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/ZkEvmSendTransactionScript.cs" +// Poll for the receipt and display transaction status +TransactionReceiptResponse response = await SampleAppManager.PassportInstance.ZkEvmGetTransactionReceipt(transactionHash); +``` + +## Running the Feature Example + +### Prerequisites +- Set up your application with the Immutable SDK using [Immutable Hub](https://hub.immutable.com) +- Complete the Passport login process + +### Steps to Run in Unity Editor +1. Navigate to the ZkEvmSendTransaction scene in `sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSendTransaction.unity` +2. Run the scene in the Unity Editor +3. Enter the following in the form: + - **To**: The destination address (e.g., another wallet address) + - **Value**: Amount to send in wei (e.g., "1000000000000000" for 0.001 IMX) + - **Data**: Optional data for contract interactions +4. Select whether to wait for confirmation using the checkbox +5. Click "Send Transaction" to execute the transaction +6. View the transaction result displayed in the UI + +## Summary +The ZkEvmSendTransaction feature enables your game to interact with the Immutable zkEVM blockchain by sending transactions from the user's Passport wallet. This allows for implementing various blockchain operations like token transfers, smart contract interactions, and more. The ability to either fire-and-forget transactions or wait for confirmations gives developers flexibility to implement different user experience flows based on their game's requirements. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md.meta new file mode 100644 index 00000000..a14d39e9 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: db3db69c418874807afe5ccd8564d047 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json new file mode 100644 index 00000000..2cac72ef --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json @@ -0,0 +1,8 @@ +{ + "title": "ZkEVM Sign Typed Data", + "description": "Sign EIP-712 structured data messages using Passport SDK to enable secure and user-friendly off-chain signing for on-chain use", + "keywords": ["Immutable", "SDK", "Passport", "ZkEVM", "EIP-712", "Sign Typed Data", "Web3"], + "tech_stack": ["Unity", "C#", "Passport SDK", "ZkEVM"], + "product": "Passport", + "programming_language": "C#" +} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json.meta new file mode 100644 index 00000000..c133d51e --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 64fd359c934504a848d8e9f56ea52f33 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md new file mode 100644 index 00000000..aafb3829 --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md @@ -0,0 +1,80 @@ + + +Sign EIP-712 structured data using the Passport SDK, enabling secure and user-friendly off-chain message signing for on-chain use. + +
+ +[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData) + +
+ +## Feature Overview + +The ZkEVM Sign Typed Data feature demonstrates how to sign EIP-712 structured data messages using the Immutable Passport SDK. EIP-712 is a standard for hashing and signing of typed structured data as opposed to just byte strings, making off-chain message signing more secure and user-friendly. + +## SDK Integration Details + +The ZkEvmSignTypedDataV4 method in the Passport SDK allows developers to sign EIP-712 structured messages in JSON string format with the logged-in user's Passport account. + +```csharp title="ZkEvmSignTypedData" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/ZkEvmSignTypedDataScript.cs" +private async UniTaskVoid SignTypedDataAsync() +{ + if (Passport.Instance == null) + { + ShowOutput("Passport instance is null"); + return; + } + ShowOutput("Signing payload..."); + try + { + await Passport.Instance.ConnectEvm(); + string signature = await Passport.Instance.ZkEvmSignTypedDataV4(Payload.text); + ShowOutput(signature); + } + catch (System.Exception ex) + { + ShowOutput($"Failed to sign typed data: {ex.Message}"); + } +} +``` + +The code above demonstrates the following process: +1. First, it ensures the Passport instance is initialized +2. It connects to the EVM network using `ConnectEvm()` +3. It calls the `ZkEvmSignTypedDataV4()` method, passing in the EIP-712 formatted payload as a JSON string +4. The method returns a signature string that can be used for verification purposes + +The payload follows the EIP-712 standard JSON format, which includes: +- A `types` object defining the structure of your data +- A `domain` object with chain-specific information to prevent cross-chain replay attacks +- A `primaryType` field indicating the main struct being signed +- A `message` object containing the actual data to sign + +## Running the Feature Example + +### Prerequisites +- Unity Editor (2022.3 LTS or newer) +- Immutable Passport SDK installed +- [Immutable Hub](https://hub.immutable.com/) account for environment setup + +### Steps to Run +1. Open the sample project in Unity Editor +2. Navigate to the `/Assets/Scenes/Passport/ZkEvm/ZkEvmSignTypedData.unity` scene +3. Enter your EIP-712 formatted payload in the text field + - Ensure it's in valid JSON format following the EIP-712 standard +4. Click the "Sign Typed Data" button +5. The signature will be displayed in the output field if successful + +## Summary + +The ZkEVM Sign Typed Data feature allows developers to implement secure message signing in their games using the standardized EIP-712 format. This enables various use cases like: +- User authentication +- Proving ownership of assets +- Creating off-chain orders for on-chain execution +- Implementing gasless transactions with meta-transactions + +By using structured, typed data instead of opaque hex strings, users get a clearer understanding of what they're signing, enhancing the security and usability of your blockchain integration. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md.meta new file mode 100644 index 00000000..d29d05cf --- /dev/null +++ b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0968d6fe5d1a24e39879224eb666978b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 63dada5a4f81e1634c7f3c4f2a3a0075bec70fb5 Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Mon, 19 May 2025 13:12:36 +1000 Subject: [PATCH 03/18] feat: pipeline to push the sample app's tutorials to the docs site --- .../scripts/aggregate-passport-metadata.js | 100 ++++++ .github/scripts/process-passport-tutorials.sh | 74 +++++ .../workflows/publish-passport-tutorials.yml | 298 ++++++++++++++++++ 3 files changed, 472 insertions(+) create mode 100644 .github/scripts/aggregate-passport-metadata.js create mode 100644 .github/scripts/process-passport-tutorials.sh create mode 100644 .github/workflows/publish-passport-tutorials.yml diff --git a/.github/scripts/aggregate-passport-metadata.js b/.github/scripts/aggregate-passport-metadata.js new file mode 100644 index 00000000..775a0bc4 --- /dev/null +++ b/.github/scripts/aggregate-passport-metadata.js @@ -0,0 +1,100 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const path = require('path'); +const { execSync } = require('child_process'); + +// Configuration +const PASSPORT_ROOT = './sample/Assets/Scripts/Passport'; +const OUTPUT_DIR = './_parsed'; +const OUTPUT_FILE = path.join(OUTPUT_DIR, 'passport-features.json'); +const FEATURES_JSON_PATH = path.join(PASSPORT_ROOT, 'features.json'); + +// Ensure output directory exists +if (!fs.existsSync(OUTPUT_DIR)) { + fs.mkdirSync(OUTPUT_DIR, { recursive: true }); +} + +console.log('Processing Passport features metadata...'); + +// Load features.json to map script files to feature names +let featuresMap = {}; +try { + const featuresContent = fs.readFileSync(FEATURES_JSON_PATH, 'utf8'); + const featuresJson = JSON.parse(featuresContent); + + // Create mapping of script filename to feature name + featuresJson.features.forEach(feature => { + const [featureName, scriptFile] = Object.entries(feature)[0]; + featuresMap[scriptFile] = featureName; + }); +} catch (error) { + console.error(`Error reading features.json: ${error.message}`); + process.exit(1); +} + +// Find all metadata.json files +const findMetadataFiles = () => { + const result = execSync(`find "${PASSPORT_ROOT}" -name "metadata.json" -type f`).toString().trim(); + return result.split('\n').filter(Boolean); +}; + +// Process metadata files +const processMetadataFiles = (metadataFiles) => { + const features = []; + + metadataFiles.forEach(metadataFile => { + console.log(`Processing ${metadataFile}`); + + // Extract feature directory + const featureDir = path.dirname(metadataFile); + + // Find script file in this directory + let featureName = ''; + try { + const dirFiles = fs.readdirSync(featureDir); + const scriptFiles = dirFiles.filter(file => file.endsWith('.cs')); + + if (scriptFiles.length > 0) { + // Look up the feature name in featuresMap + const scriptFile = scriptFiles[0]; + featureName = featuresMap[scriptFile] || ''; + } + + // If not found in features.json, fallback to directory name + if (!featureName) { + console.warn(`Feature for script in ${featureDir} not found in features.json, using directory name`); + featureName = path.basename(featureDir); + } + } catch (error) { + console.warn(`Error processing directory ${featureDir}: ${error.message}`); + featureName = path.basename(featureDir); + } + + console.log(`Feature name: ${featureName}`); + + // Read and process metadata + try { + const metadataContent = fs.readFileSync(metadataFile, 'utf8'); + const metadata = JSON.parse(metadataContent); + + // Add feature name to metadata + metadata.name = featureName; + features.push(metadata); + } catch (error) { + console.error(`Error processing metadata file ${metadataFile}: ${error.message}`); + } + }); + + return features; +}; + +// Main execution +const metadataFiles = findMetadataFiles(); +const features = processMetadataFiles(metadataFiles); + +// Create the final passport-features.json +const passportFeatures = { features }; +fs.writeFileSync(OUTPUT_FILE, JSON.stringify(passportFeatures, null, 2)); + +console.log(`Created ${OUTPUT_FILE}`); \ No newline at end of file diff --git a/.github/scripts/process-passport-tutorials.sh b/.github/scripts/process-passport-tutorials.sh new file mode 100644 index 00000000..d1fb84c9 --- /dev/null +++ b/.github/scripts/process-passport-tutorials.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +set -e +set -x + +# Directory where docs repo is cloned +DOCS_REPO_DIR=${CLONE_DIR:-"./imx-docs"} + +# Root of the Passport features +PASSPORT_ROOT="./sample/Assets/Scripts/Passport" + +echo "Processing Passport tutorials..." + +# Load features.json to map script files to feature names +FEATURES_JSON="$PASSPORT_ROOT/features.json" +if [ ! -f "$FEATURES_JSON" ]; then + echo "Error: features.json not found at $FEATURES_JSON" + exit 1 +fi + +# Create _tutorials directory in docs repo +TUTORIALS_DIR="$DOCS_REPO_DIR/docs/main/example/zkEVM/passport-examples/_tutorials" +mkdir -p "$TUTORIALS_DIR" + +# Find all tutorial.md files +TUTORIAL_FILES=$(find "$PASSPORT_ROOT" -name "tutorial.md" -type f) + +for TUTORIAL_FILE in $TUTORIAL_FILES; do + echo "Processing $TUTORIAL_FILE" + + # Extract feature directory + FEATURE_DIR=$(dirname "$TUTORIAL_FILE") + + # Try to find script file in this directory + SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f | head -n 1) + if [ -z "$SCRIPT_FILE" ]; then + echo "Warning: No script file found in $FEATURE_DIR, using directory name" + FEATURE_NAME=$(basename "$FEATURE_DIR") + else + # Extract script filename + SCRIPT_FILENAME=$(basename "$SCRIPT_FILE") + + # Look up the feature name in features.json + FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON") + + # If not found in features.json, fallback to directory name + if [ -z "$FEATURE_NAME" ] || [ "$FEATURE_NAME" == "null" ]; then + echo "Warning: Feature for script $SCRIPT_FILENAME not found in features.json, using directory name" + FEATURE_NAME=$(basename "$FEATURE_DIR") + fi + fi + + echo "Feature name: $FEATURE_NAME" + + # Copy and rename tutorial file + cp "$TUTORIAL_FILE" "$TUTORIALS_DIR/${FEATURE_NAME}.md" + echo "Copied $TUTORIAL_FILE to $TUTORIALS_DIR/${FEATURE_NAME}.md" +done + +# Copy the generated JSON file +JSON_FILE="./_parsed/passport-features.json" +if [ -f "$JSON_FILE" ]; then + # Create directory for JSON file if it doesn't exist + JSON_DIR="$DOCS_REPO_DIR/docs/main/example/zkEVM/passport-examples" + mkdir -p "$JSON_DIR" + + # Copy JSON file + cp "$JSON_FILE" "$JSON_DIR/passport-features.json" + echo "Copied $JSON_FILE to $JSON_DIR/passport-features.json" +else + echo "Warning: No passport-features.json found at $JSON_FILE" +fi + +echo "Passport tutorial processing complete." \ No newline at end of file diff --git a/.github/workflows/publish-passport-tutorials.yml b/.github/workflows/publish-passport-tutorials.yml new file mode 100644 index 00000000..eb9f0141 --- /dev/null +++ b/.github/workflows/publish-passport-tutorials.yml @@ -0,0 +1,298 @@ +name: Publish Passport Tutorials + +on: + # Run when changes are pushed to Passport tutorials or metadata + push: + branches: + # - main + - chore/sample-app-tutorial + paths: + - 'sample/Assets/Scripts/Passport/**/tutorial.md' + - 'sample/Assets/Scripts/Passport/**/metadata.json' + - 'sample/Assets/Scripts/Passport/features.json' + - '.github/scripts/aggregate-passport-metadata.js' + - '.github/scripts/process-passport-tutorials.sh' + - '.github/workflows/publish-passport-tutorials.yml' + # Allow manual triggering + workflow_dispatch: + +concurrency: + group: passport-tutorials + cancel-in-progress: false + +jobs: + PublishPassportTutorials: + name: Process and Publish Passport Tutorials + runs-on: ubuntu-latest + steps: + - name: Checkout Unity SDK Repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + + - name: Create Script Directories + run: | + mkdir -p .github/scripts + mkdir -p _parsed + + - name: Create Aggregation Script + run: | + cat > .github/scripts/aggregate-passport-metadata.js << 'EOF' + #!/usr/bin/env node + + const fs = require('fs'); + const path = require('path'); + const { execSync } = require('child_process'); + + // Configuration + const PASSPORT_ROOT = './sample/Assets/Scripts/Passport'; + const OUTPUT_DIR = './_parsed'; + const OUTPUT_FILE = path.join(OUTPUT_DIR, 'passport-features.json'); + const FEATURES_JSON_PATH = path.join(PASSPORT_ROOT, 'features.json'); + + // Ensure output directory exists + if (!fs.existsSync(OUTPUT_DIR)) { + fs.mkdirSync(OUTPUT_DIR, { recursive: true }); + } + + console.log('Processing Passport features metadata...'); + + // Load features.json to map script files to feature names + let featuresMap = {}; + try { + const featuresContent = fs.readFileSync(FEATURES_JSON_PATH, 'utf8'); + const featuresJson = JSON.parse(featuresContent); + + // Create mapping of script filename to feature name + featuresJson.features.forEach(feature => { + const [featureName, scriptFile] = Object.entries(feature)[0]; + featuresMap[scriptFile] = featureName; + }); + } catch (error) { + console.error(`Error reading features.json: ${error.message}`); + process.exit(1); + } + + // Find all metadata.json files + const findMetadataFiles = () => { + const result = execSync(`find "${PASSPORT_ROOT}" -name "metadata.json" -type f`).toString().trim(); + return result.split('\n').filter(Boolean); + }; + + // Process metadata files + const processMetadataFiles = (metadataFiles) => { + const features = []; + + metadataFiles.forEach(metadataFile => { + console.log(`Processing ${metadataFile}`); + + // Extract feature directory + const featureDir = path.dirname(metadataFile); + + // Find script file in this directory + let featureName = ''; + try { + const dirFiles = fs.readdirSync(featureDir); + const scriptFiles = dirFiles.filter(file => file.endsWith('.cs')); + + if (scriptFiles.length > 0) { + // Look up the feature name in featuresMap + const scriptFile = scriptFiles[0]; + featureName = featuresMap[scriptFile] || ''; + } + + // If not found in features.json, fallback to directory name + if (!featureName) { + console.warn(`Feature for script in ${featureDir} not found in features.json, using directory name`); + featureName = path.basename(featureDir); + } + } catch (error) { + console.warn(`Error processing directory ${featureDir}: ${error.message}`); + featureName = path.basename(featureDir); + } + + console.log(`Feature name: ${featureName}`); + + // Read and process metadata + try { + const metadataContent = fs.readFileSync(metadataFile, 'utf8'); + const metadata = JSON.parse(metadataContent); + + // Add feature name to metadata + metadata.name = featureName; + features.push(metadata); + } catch (error) { + console.error(`Error processing metadata file ${metadataFile}: ${error.message}`); + } + }); + + return features; + }; + + // Main execution + const metadataFiles = findMetadataFiles(); + const features = processMetadataFiles(metadataFiles); + + // Create the final passport-features.json + const passportFeatures = { features }; + fs.writeFileSync(OUTPUT_FILE, JSON.stringify(passportFeatures, null, 2)); + + console.log(`Created ${OUTPUT_FILE}`); + EOF + chmod +x .github/scripts/aggregate-passport-metadata.js + + - name: Create Tutorial Processing Script + run: | + cat > .github/scripts/process-passport-tutorials.sh << 'EOF' + #!/bin/bash + + set -e + set -x + + # Directory where docs repo is cloned + DOCS_REPO_DIR=${CLONE_DIR:-"./imx-docs"} + + # Root of the Passport features + PASSPORT_ROOT="./sample/Assets/Scripts/Passport" + + echo "Processing Passport tutorials..." + + # Load features.json to map script files to feature names + FEATURES_JSON="$PASSPORT_ROOT/features.json" + if [ ! -f "$FEATURES_JSON" ]; then + echo "Error: features.json not found at $FEATURES_JSON" + exit 1 + fi + + # Check and create required directories in docs repo + BASE_DIR="$DOCS_REPO_DIR/docs/main/example/zkevm" + + # Create unity directory if it doesn't exist + UNITY_DIR="$BASE_DIR/unity" + if [ ! -d "$UNITY_DIR" ]; then + echo "Creating unity directory at $UNITY_DIR" + mkdir -p "$UNITY_DIR" + fi + + # Create passport directory if it doesn't exist + PASSPORT_DIR="$UNITY_DIR/passport" + if [ ! -d "$PASSPORT_DIR" ]; then + echo "Creating passport directory at $PASSPORT_DIR" + mkdir -p "$PASSPORT_DIR" + fi + + # Create _tutorials directory + TUTORIALS_DIR="$PASSPORT_DIR/_tutorials" + mkdir -p "$TUTORIALS_DIR" + + # Find all tutorial.md files + TUTORIAL_FILES=$(find "$PASSPORT_ROOT" -name "tutorial.md" -type f) + + for TUTORIAL_FILE in $TUTORIAL_FILES; do + echo "Processing $TUTORIAL_FILE" + + # Extract feature directory + FEATURE_DIR=$(dirname "$TUTORIAL_FILE") + + # Try to find script file in this directory + SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f | head -n 1) + if [ -z "$SCRIPT_FILE" ]; then + echo "Warning: No script file found in $FEATURE_DIR, using directory name" + FEATURE_NAME=$(basename "$FEATURE_DIR") + else + # Extract script filename + SCRIPT_FILENAME=$(basename "$SCRIPT_FILE") + + # Look up the feature name in features.json + FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON") + + # If not found in features.json, fallback to directory name + if [ -z "$FEATURE_NAME" ] || [ "$FEATURE_NAME" == "null" ]; then + echo "Warning: Feature for script $SCRIPT_FILENAME not found in features.json, using directory name" + FEATURE_NAME=$(basename "$FEATURE_DIR") + fi + fi + + echo "Feature name: $FEATURE_NAME" + + # Copy and rename tutorial file + cp "$TUTORIAL_FILE" "$TUTORIALS_DIR/${FEATURE_NAME}.md" + echo "Copied $TUTORIAL_FILE to $TUTORIALS_DIR/${FEATURE_NAME}.md" + done + + # Copy the generated JSON file + JSON_FILE="./_parsed/passport-features.json" + if [ -f "$JSON_FILE" ]; then + # Copy JSON file to the passport directory + cp "$JSON_FILE" "$PASSPORT_DIR/passport-features.json" + echo "Copied $JSON_FILE to $PASSPORT_DIR/passport-features.json" + else + echo "Warning: No passport-features.json found at $JSON_FILE" + fi + + echo "Passport tutorial processing complete." + EOF + chmod +x .github/scripts/process-passport-tutorials.sh + + - name: Checkout Docs Repo + uses: actions/checkout@v3 + with: + repository: immutable/imx-docs + token: ${{ secrets.DOCS_REPO_PAT }} + path: imx-docs + ref: 'DVR-425-unity-sample-app-tutorial' + + - name: Setup environment variables + run: | + echo "CLONE_DIR=./imx-docs" >> $GITHUB_ENV + + - name: Setup Github + run: | + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + + - name: Install Dependencies + run: | + sudo apt-get update + sudo apt-get install -y jq + + - name: Generate Passport Features JSON + run: | + node ./.github/scripts/aggregate-passport-metadata.js + shell: bash + + - name: Process Passport Tutorials + run: | + ./.github/scripts/process-passport-tutorials.sh + shell: bash + + - name: List Generated Files + run: | + echo "Generated passport-features.json:" + ls -la _parsed/ + + echo "Generated tutorial files:" + ls -la imx-docs/docs/main/example/zkevm/unity/passport/_tutorials/ + + echo "Content of passport-features.json:" + cat _parsed/passport-features.json | jq . + + - name: Commit and Push Changes to Docs Repo + run: | + cd "$CLONE_DIR" + # Check if there are changes to commit + if git status --porcelain | grep -q .; then + # Add all changes + git add . + + # Commit the changes + git commit -m "Update Passport tutorials from Unity SDK repo" + + # Push to the target branch (always DVR-425-unity-sample-app-tutorial for now) + git push -u origin DVR-425-unity-sample-app-tutorial + echo "Successfully pushed Passport tutorial changes to docs repo" + else + echo "No changes to commit" + fi + shell: bash \ No newline at end of file From 6323bd2c68087179f39475f45df4e0d9052aad88 Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Mon, 19 May 2025 13:35:26 +1000 Subject: [PATCH 04/18] fix: updated tutorial workflow --- .../workflows/publish-passport-tutorials.yml | 258 ++---------------- 1 file changed, 22 insertions(+), 236 deletions(-) diff --git a/.github/workflows/publish-passport-tutorials.yml b/.github/workflows/publish-passport-tutorials.yml index eb9f0141..a1abee7e 100644 --- a/.github/workflows/publish-passport-tutorials.yml +++ b/.github/workflows/publish-passport-tutorials.yml @@ -10,9 +10,7 @@ on: - 'sample/Assets/Scripts/Passport/**/tutorial.md' - 'sample/Assets/Scripts/Passport/**/metadata.json' - 'sample/Assets/Scripts/Passport/features.json' - - '.github/scripts/aggregate-passport-metadata.js' - - '.github/scripts/process-passport-tutorials.sh' - - '.github/workflows/publish-passport-tutorials.yml' + # Allow manual triggering workflow_dispatch: @@ -26,228 +24,25 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Unity SDK Repo - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: fetch-depth: 0 - ref: ${{ github.ref }} - - - name: Create Script Directories - run: | - mkdir -p .github/scripts - mkdir -p _parsed - - - name: Create Aggregation Script - run: | - cat > .github/scripts/aggregate-passport-metadata.js << 'EOF' - #!/usr/bin/env node - - const fs = require('fs'); - const path = require('path'); - const { execSync } = require('child_process'); - - // Configuration - const PASSPORT_ROOT = './sample/Assets/Scripts/Passport'; - const OUTPUT_DIR = './_parsed'; - const OUTPUT_FILE = path.join(OUTPUT_DIR, 'passport-features.json'); - const FEATURES_JSON_PATH = path.join(PASSPORT_ROOT, 'features.json'); - // Ensure output directory exists - if (!fs.existsSync(OUTPUT_DIR)) { - fs.mkdirSync(OUTPUT_DIR, { recursive: true }); - } - - console.log('Processing Passport features metadata...'); - - // Load features.json to map script files to feature names - let featuresMap = {}; - try { - const featuresContent = fs.readFileSync(FEATURES_JSON_PATH, 'utf8'); - const featuresJson = JSON.parse(featuresContent); - - // Create mapping of script filename to feature name - featuresJson.features.forEach(feature => { - const [featureName, scriptFile] = Object.entries(feature)[0]; - featuresMap[scriptFile] = featureName; - }); - } catch (error) { - console.error(`Error reading features.json: ${error.message}`); - process.exit(1); - } - - // Find all metadata.json files - const findMetadataFiles = () => { - const result = execSync(`find "${PASSPORT_ROOT}" -name "metadata.json" -type f`).toString().trim(); - return result.split('\n').filter(Boolean); - }; - - // Process metadata files - const processMetadataFiles = (metadataFiles) => { - const features = []; - - metadataFiles.forEach(metadataFile => { - console.log(`Processing ${metadataFile}`); - - // Extract feature directory - const featureDir = path.dirname(metadataFile); - - // Find script file in this directory - let featureName = ''; - try { - const dirFiles = fs.readdirSync(featureDir); - const scriptFiles = dirFiles.filter(file => file.endsWith('.cs')); - - if (scriptFiles.length > 0) { - // Look up the feature name in featuresMap - const scriptFile = scriptFiles[0]; - featureName = featuresMap[scriptFile] || ''; - } - - // If not found in features.json, fallback to directory name - if (!featureName) { - console.warn(`Feature for script in ${featureDir} not found in features.json, using directory name`); - featureName = path.basename(featureDir); - } - } catch (error) { - console.warn(`Error processing directory ${featureDir}: ${error.message}`); - featureName = path.basename(featureDir); - } - - console.log(`Feature name: ${featureName}`); - - // Read and process metadata - try { - const metadataContent = fs.readFileSync(metadataFile, 'utf8'); - const metadata = JSON.parse(metadataContent); - - // Add feature name to metadata - metadata.name = featureName; - features.push(metadata); - } catch (error) { - console.error(`Error processing metadata file ${metadataFile}: ${error.message}`); - } - }); - - return features; - }; - - // Main execution - const metadataFiles = findMetadataFiles(); - const features = processMetadataFiles(metadataFiles); - - // Create the final passport-features.json - const passportFeatures = { features }; - fs.writeFileSync(OUTPUT_FILE, JSON.stringify(passportFeatures, null, 2)); - - console.log(`Created ${OUTPUT_FILE}`); - EOF - chmod +x .github/scripts/aggregate-passport-metadata.js - - - name: Create Tutorial Processing Script - run: | - cat > .github/scripts/process-passport-tutorials.sh << 'EOF' - #!/bin/bash - - set -e - set -x - - # Directory where docs repo is cloned - DOCS_REPO_DIR=${CLONE_DIR:-"./imx-docs"} - - # Root of the Passport features - PASSPORT_ROOT="./sample/Assets/Scripts/Passport" - - echo "Processing Passport tutorials..." - - # Load features.json to map script files to feature names - FEATURES_JSON="$PASSPORT_ROOT/features.json" - if [ ! -f "$FEATURES_JSON" ]; then - echo "Error: features.json not found at $FEATURES_JSON" - exit 1 - fi - - # Check and create required directories in docs repo - BASE_DIR="$DOCS_REPO_DIR/docs/main/example/zkevm" - - # Create unity directory if it doesn't exist - UNITY_DIR="$BASE_DIR/unity" - if [ ! -d "$UNITY_DIR" ]; then - echo "Creating unity directory at $UNITY_DIR" - mkdir -p "$UNITY_DIR" - fi - - # Create passport directory if it doesn't exist - PASSPORT_DIR="$UNITY_DIR/passport" - if [ ! -d "$PASSPORT_DIR" ]; then - echo "Creating passport directory at $PASSPORT_DIR" - mkdir -p "$PASSPORT_DIR" - fi - - # Create _tutorials directory - TUTORIALS_DIR="$PASSPORT_DIR/_tutorials" - mkdir -p "$TUTORIALS_DIR" - - # Find all tutorial.md files - TUTORIAL_FILES=$(find "$PASSPORT_ROOT" -name "tutorial.md" -type f) - - for TUTORIAL_FILE in $TUTORIAL_FILES; do - echo "Processing $TUTORIAL_FILE" - - # Extract feature directory - FEATURE_DIR=$(dirname "$TUTORIAL_FILE") - - # Try to find script file in this directory - SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f | head -n 1) - if [ -z "$SCRIPT_FILE" ]; then - echo "Warning: No script file found in $FEATURE_DIR, using directory name" - FEATURE_NAME=$(basename "$FEATURE_DIR") - else - # Extract script filename - SCRIPT_FILENAME=$(basename "$SCRIPT_FILE") - - # Look up the feature name in features.json - FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON") - - # If not found in features.json, fallback to directory name - if [ -z "$FEATURE_NAME" ] || [ "$FEATURE_NAME" == "null" ]; then - echo "Warning: Feature for script $SCRIPT_FILENAME not found in features.json, using directory name" - FEATURE_NAME=$(basename "$FEATURE_DIR") - fi - fi - - echo "Feature name: $FEATURE_NAME" - - # Copy and rename tutorial file - cp "$TUTORIAL_FILE" "$TUTORIALS_DIR/${FEATURE_NAME}.md" - echo "Copied $TUTORIAL_FILE to $TUTORIALS_DIR/${FEATURE_NAME}.md" - done - - # Copy the generated JSON file - JSON_FILE="./_parsed/passport-features.json" - if [ -f "$JSON_FILE" ]; then - # Copy JSON file to the passport directory - cp "$JSON_FILE" "$PASSPORT_DIR/passport-features.json" - echo "Copied $JSON_FILE to $PASSPORT_DIR/passport-features.json" - else - echo "Warning: No passport-features.json found at $JSON_FILE" - fi - - echo "Passport tutorial processing complete." - EOF - chmod +x .github/scripts/process-passport-tutorials.sh + - name: Create Parsed Directory + run: mkdir -p _parsed - name: Checkout Docs Repo - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: - repository: immutable/imx-docs - token: ${{ secrets.DOCS_REPO_PAT }} + repository: immutable/docs + token: ${{ secrets.UNITY_IMMUTABLE_SDK_GITHUB_TOKEN }} path: imx-docs ref: 'DVR-425-unity-sample-app-tutorial' - name: Setup environment variables - run: | - echo "CLONE_DIR=./imx-docs" >> $GITHUB_ENV + run: echo "CLONE_DIR=./imx-docs" >> $GITHUB_ENV - - name: Setup Github + - name: Setup Git run: | git config --global user.name "${GITHUB_ACTOR}" git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" @@ -257,42 +52,33 @@ jobs: sudo apt-get update sudo apt-get install -y jq - - name: Generate Passport Features JSON - run: | - node ./.github/scripts/aggregate-passport-metadata.js - shell: bash - - name: Process Passport Tutorials run: | - ./.github/scripts/process-passport-tutorials.sh - shell: bash - - - name: List Generated Files - run: | - echo "Generated passport-features.json:" - ls -la _parsed/ + # Make scripts executable + chmod +x .github/scripts/aggregate-passport-metadata.js + chmod +x .github/scripts/process-passport-tutorials.sh - echo "Generated tutorial files:" - ls -la imx-docs/docs/main/example/zkevm/unity/passport/_tutorials/ + # Generate aggregated JSON file + node .github/scripts/aggregate-passport-metadata.js - echo "Content of passport-features.json:" - cat _parsed/passport-features.json | jq . + # Process tutorials and copy to docs repo + .github/scripts/process-passport-tutorials.sh + shell: bash - name: Commit and Push Changes to Docs Repo run: | cd "$CLONE_DIR" - # Check if there are changes to commit if git status --porcelain | grep -q .; then - # Add all changes git add . - # Commit the changes - git commit -m "Update Passport tutorials from Unity SDK repo" + # Commit with reference to source commit + COMMIT_MSG="docs: Update Passport tutorials from Unity SDK (Ref: ${GITHUB_SHA::8})" + git commit -m "$COMMIT_MSG" - # Push to the target branch (always DVR-425-unity-sample-app-tutorial for now) + # Push to the target branch git push -u origin DVR-425-unity-sample-app-tutorial echo "Successfully pushed Passport tutorial changes to docs repo" else echo "No changes to commit" fi - shell: bash \ No newline at end of file + shell: bash \ No newline at end of file From dc3cb9ba1782c5397e2f5fc8c535abe70b6e4212 Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Mon, 19 May 2025 13:38:26 +1000 Subject: [PATCH 05/18] chore: testing new workflow --- sample/Assets/Scripts/Passport/Login/tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md b/sample/Assets/Scripts/Passport/Login/tutorial.md index ff4895d6..e8cdb7d9 100644 --- a/sample/Assets/Scripts/Passport/Login/tutorial.md +++ b/sample/Assets/Scripts/Passport/Login/tutorial.md @@ -4,7 +4,7 @@ -Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth. +Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth
From 7014928a62c4393a12bd1ed85b4ef39ae32016df Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Tue, 20 May 2025 10:19:21 +1000 Subject: [PATCH 06/18] fix: updated scripts to ensure it produces the correct JSON format output --- .../scripts/aggregate-passport-metadata.js | 110 ++++++++++++++---- sample/Assets/Scripts/Passport/features.json | 2 +- 2 files changed, 88 insertions(+), 24 deletions(-) diff --git a/.github/scripts/aggregate-passport-metadata.js b/.github/scripts/aggregate-passport-metadata.js index 775a0bc4..624c4630 100644 --- a/.github/scripts/aggregate-passport-metadata.js +++ b/.github/scripts/aggregate-passport-metadata.js @@ -2,7 +2,6 @@ const fs = require('fs'); const path = require('path'); -const { execSync } = require('child_process'); // Configuration const PASSPORT_ROOT = './sample/Assets/Scripts/Passport'; @@ -26,22 +25,55 @@ try { // Create mapping of script filename to feature name featuresJson.features.forEach(feature => { const [featureName, scriptFile] = Object.entries(feature)[0]; + // Store both the full filename and just the filename without path featuresMap[scriptFile] = featureName; + featuresMap[path.basename(scriptFile)] = featureName; }); } catch (error) { console.error(`Error reading features.json: ${error.message}`); process.exit(1); } -// Find all metadata.json files +// Platform-independent recursive file search const findMetadataFiles = () => { - const result = execSync(`find "${PASSPORT_ROOT}" -name "metadata.json" -type f`).toString().trim(); - return result.split('\n').filter(Boolean); + const metadataFiles = []; + + const walkDir = (dir) => { + if (!fs.existsSync(dir)) { + console.warn(`Directory does not exist: ${dir}`); + return; + } + + try { + const files = fs.readdirSync(dir); + + files.forEach(file => { + const filePath = path.join(dir, file); + + try { + const stat = fs.statSync(filePath); + + if (stat.isDirectory()) { + walkDir(filePath); + } else if (file === 'metadata.json') { + metadataFiles.push(filePath); + } + } catch (err) { + console.warn(`Error accessing file ${filePath}: ${err.message}`); + } + }); + } catch (err) { + console.warn(`Error reading directory ${dir}: ${err.message}`); + } + }; + + walkDir(PASSPORT_ROOT); + return metadataFiles; }; // Process metadata files const processMetadataFiles = (metadataFiles) => { - const features = []; + const featuresObject = {}; metadataFiles.forEach(metadataFile => { console.log(`Processing ${metadataFile}`); @@ -49,44 +81,77 @@ const processMetadataFiles = (metadataFiles) => { // Extract feature directory const featureDir = path.dirname(metadataFile); - // Find script file in this directory + // Get directory name as fallback feature name + const dirName = path.basename(featureDir); + + // Try to find feature name in feature map, fallback to directory name let featureName = ''; try { + // Look for any script file in this directory const dirFiles = fs.readdirSync(featureDir); const scriptFiles = dirFiles.filter(file => file.endsWith('.cs')); - if (scriptFiles.length > 0) { - // Look up the feature name in featuresMap - const scriptFile = scriptFiles[0]; - featureName = featuresMap[scriptFile] || ''; + // Try to match any script file to our feature map + let found = false; + for (const scriptFile of scriptFiles) { + if (featuresMap[scriptFile]) { + featureName = featuresMap[scriptFile]; + found = true; + break; + } } - // If not found in features.json, fallback to directory name - if (!featureName) { - console.warn(`Feature for script in ${featureDir} not found in features.json, using directory name`); - featureName = path.basename(featureDir); + if (!found) { + console.warn(`No feature found in features.json for ${featureDir}, using directory name`); + featureName = dirName; } } catch (error) { console.warn(`Error processing directory ${featureDir}: ${error.message}`); - featureName = path.basename(featureDir); + featureName = dirName; + } + + // Create feature key (kebab-case) + const featureKey = featureName + .replace(/([a-z])([A-Z])/g, '$1-$2') + .replace(/\s+/g, '-') + .replace(/[^a-z0-9-]/gi, '') + .toLowerCase(); + + if (!featureKey) { + console.warn(`Generated empty feature key for ${featureDir}, skipping`); + return; } - console.log(`Feature name: ${featureName}`); + // Check for tutorial.md in the same directory + const tutorialPath = path.join(featureDir, 'tutorial.md'); + const tutorialExists = fs.existsSync(tutorialPath); + const tutorialFile = tutorialExists ? `${featureKey}.md` : null; + + if (!tutorialExists) { + console.warn(`No tutorial.md found for feature ${featureName} in ${featureDir}`); + } // Read and process metadata try { const metadataContent = fs.readFileSync(metadataFile, 'utf8'); const metadata = JSON.parse(metadataContent); - // Add feature name to metadata - metadata.name = featureName; - features.push(metadata); + // Add additional fields + metadata.title = metadata.title || featureName; + metadata.sidebar_order = metadata.sidebar_order || 0; + metadata.deprecated = metadata.deprecated || false; + + // Create the feature entry + featuresObject[featureKey] = { + tutorial: tutorialFile, + metadata: metadata + }; } catch (error) { console.error(`Error processing metadata file ${metadataFile}: ${error.message}`); } }); - return features; + return featuresObject; }; // Main execution @@ -94,7 +159,6 @@ const metadataFiles = findMetadataFiles(); const features = processMetadataFiles(metadataFiles); // Create the final passport-features.json -const passportFeatures = { features }; -fs.writeFileSync(OUTPUT_FILE, JSON.stringify(passportFeatures, null, 2)); +fs.writeFileSync(OUTPUT_FILE, JSON.stringify(features, null, 2)); -console.log(`Created ${OUTPUT_FILE}`); \ No newline at end of file +console.log(`Created ${OUTPUT_FILE}`); \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/features.json b/sample/Assets/Scripts/Passport/features.json index 1c9d4926..6295bfad 100644 --- a/sample/Assets/Scripts/Passport/features.json +++ b/sample/Assets/Scripts/Passport/features.json @@ -18,6 +18,6 @@ { "ClearStorageAndCache": "ClearStorageAndCacheScript.cs" }, { "ImxIsRegisteredOffchain": "ImxIsRegisteredOffchainScript.cs" }, { "ZkEvmRequestAccounts": "ZkEvmRequestAccountsScript.cs" }, - { "PassportInitialisation": "PassportInitializationScript.cs" } + { "PassportInitialisation": "PassportInitialisationScript.cs" } ] } \ No newline at end of file From 24ca072efe0ec18bdd4085af9c415cf228f3b40b Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Thu, 22 May 2025 09:55:20 +1000 Subject: [PATCH 07/18] fix: handle null delimited filenames --- .github/scripts/process-passport-tutorials.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/scripts/process-passport-tutorials.sh b/.github/scripts/process-passport-tutorials.sh index d1fb84c9..ede4d51b 100644 --- a/.github/scripts/process-passport-tutorials.sh +++ b/.github/scripts/process-passport-tutorials.sh @@ -25,14 +25,15 @@ mkdir -p "$TUTORIALS_DIR" # Find all tutorial.md files TUTORIAL_FILES=$(find "$PASSPORT_ROOT" -name "tutorial.md" -type f) -for TUTORIAL_FILE in $TUTORIAL_FILES; do + # Process null-delimited filenames + find "$PASSPORT_ROOT" -name "tutorial.md" -type f -print0 | while IFS= read -r -d '' TUTORIAL_FILE; do echo "Processing $TUTORIAL_FILE" # Extract feature directory FEATURE_DIR=$(dirname "$TUTORIAL_FILE") # Try to find script file in this directory - SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f | head -n 1) + SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f -print0 | xargs -0 -n1 echo | head -n 1) if [ -z "$SCRIPT_FILE" ]; then echo "Warning: No script file found in $FEATURE_DIR, using directory name" FEATURE_NAME=$(basename "$FEATURE_DIR") @@ -41,7 +42,11 @@ for TUTORIAL_FILE in $TUTORIAL_FILES; do SCRIPT_FILENAME=$(basename "$SCRIPT_FILE") # Look up the feature name in features.json - FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON") + # Extract feature name with error handling + if ! FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON" 2>/dev/null); then + echo "Warning: Error parsing features.json with jq, using directory name" + FEATURE_NAME=$(basename "$FEATURE_DIR") + fi # If not found in features.json, fallback to directory name if [ -z "$FEATURE_NAME" ] || [ "$FEATURE_NAME" == "null" ]; then From 46f524c633b7e3fc6d347ebf48e25865831fbeb6 Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Thu, 22 May 2025 10:30:08 +1000 Subject: [PATCH 08/18] fix: linting issues --- .../scripts/aggregate-passport-metadata.js | 44 ++++++++----- .github/scripts/process-passport-tutorials.sh | 62 +++++++++---------- .../Assets/Scripts/Passport/Login/tutorial.md | 2 +- 3 files changed, 61 insertions(+), 47 deletions(-) mode change 100644 => 100755 .github/scripts/aggregate-passport-metadata.js mode change 100644 => 100755 .github/scripts/process-passport-tutorials.sh diff --git a/.github/scripts/aggregate-passport-metadata.js b/.github/scripts/aggregate-passport-metadata.js old mode 100644 new mode 100755 index 624c4630..1c562ab7 --- a/.github/scripts/aggregate-passport-metadata.js +++ b/.github/scripts/aggregate-passport-metadata.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const fs = require('fs'); const path = require('path'); @@ -10,20 +12,25 @@ const OUTPUT_FILE = path.join(OUTPUT_DIR, 'passport-features.json'); const FEATURES_JSON_PATH = path.join(PASSPORT_ROOT, 'features.json'); // Ensure output directory exists -if (!fs.existsSync(OUTPUT_DIR)) { - fs.mkdirSync(OUTPUT_DIR, { recursive: true }); +try { + if (!fs.existsSync(OUTPUT_DIR)) { + fs.mkdirSync(OUTPUT_DIR, { recursive: true }); + } +} catch (error) { + console.error(`Error creating output directory: ${error.message}`); + process.exit(1); } console.log('Processing Passport features metadata...'); // Load features.json to map script files to feature names -let featuresMap = {}; +const featuresMap = {}; try { const featuresContent = fs.readFileSync(FEATURES_JSON_PATH, 'utf8'); const featuresJson = JSON.parse(featuresContent); // Create mapping of script filename to feature name - featuresJson.features.forEach(feature => { + featuresJson.features.forEach((feature) => { const [featureName, scriptFile] = Object.entries(feature)[0]; // Store both the full filename and just the filename without path featuresMap[scriptFile] = featureName; @@ -47,7 +54,7 @@ const findMetadataFiles = () => { try { const files = fs.readdirSync(dir); - files.forEach(file => { + files.forEach((file) => { const filePath = path.join(dir, file); try { @@ -75,7 +82,7 @@ const findMetadataFiles = () => { const processMetadataFiles = (metadataFiles) => { const featuresObject = {}; - metadataFiles.forEach(metadataFile => { + metadataFiles.forEach((metadataFile) => { console.log(`Processing ${metadataFile}`); // Extract feature directory @@ -89,7 +96,7 @@ const processMetadataFiles = (metadataFiles) => { try { // Look for any script file in this directory const dirFiles = fs.readdirSync(featureDir); - const scriptFiles = dirFiles.filter(file => file.endsWith('.cs')); + const scriptFiles = dirFiles.filter((file) => file.endsWith('.cs')); // Try to match any script file to our feature map let found = false; @@ -154,11 +161,20 @@ const processMetadataFiles = (metadataFiles) => { return featuresObject; }; -// Main execution -const metadataFiles = findMetadataFiles(); -const features = processMetadataFiles(metadataFiles); - -// Create the final passport-features.json -fs.writeFileSync(OUTPUT_FILE, JSON.stringify(features, null, 2)); +try { + // Main execution + const metadataFiles = findMetadataFiles(); + + if (metadataFiles.length === 0) { + console.warn('No metadata files found. Output file will be empty.'); + } + + const features = processMetadataFiles(metadataFiles); -console.log(`Created ${OUTPUT_FILE}`); \ No newline at end of file + // Create the final passport-features.json + fs.writeFileSync(OUTPUT_FILE, JSON.stringify(features, null, 2)); + console.log(`Created ${OUTPUT_FILE}`); +} catch (error) { + console.error(`Fatal error: ${error.message}`); + process.exit(1); +} \ No newline at end of file diff --git a/.github/scripts/process-passport-tutorials.sh b/.github/scripts/process-passport-tutorials.sh old mode 100644 new mode 100755 index ede4d51b..b7796fc2 --- a/.github/scripts/process-passport-tutorials.sh +++ b/.github/scripts/process-passport-tutorials.sh @@ -4,7 +4,7 @@ set -e set -x # Directory where docs repo is cloned -DOCS_REPO_DIR=${CLONE_DIR:-"./imx-docs"} +DOCS_REPO_DIR="${CLONE_DIR:-"./imx-docs"}" # Root of the Passport features PASSPORT_ROOT="./sample/Assets/Scripts/Passport" @@ -12,68 +12,66 @@ PASSPORT_ROOT="./sample/Assets/Scripts/Passport" echo "Processing Passport tutorials..." # Load features.json to map script files to feature names -FEATURES_JSON="$PASSPORT_ROOT/features.json" -if [ ! -f "$FEATURES_JSON" ]; then - echo "Error: features.json not found at $FEATURES_JSON" +FEATURES_JSON="${PASSPORT_ROOT}/features.json" +if [ ! -f "${FEATURES_JSON}" ]; then + echo "Error: features.json not found at ${FEATURES_JSON}" exit 1 fi # Create _tutorials directory in docs repo -TUTORIALS_DIR="$DOCS_REPO_DIR/docs/main/example/zkEVM/passport-examples/_tutorials" -mkdir -p "$TUTORIALS_DIR" +TUTORIALS_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/passport-examples/_tutorials" +mkdir -p "${TUTORIALS_DIR}" -# Find all tutorial.md files -TUTORIAL_FILES=$(find "$PASSPORT_ROOT" -name "tutorial.md" -type f) - - # Process null-delimited filenames - find "$PASSPORT_ROOT" -name "tutorial.md" -type f -print0 | while IFS= read -r -d '' TUTORIAL_FILE; do - echo "Processing $TUTORIAL_FILE" +# Process null-delimited filenames +find "${PASSPORT_ROOT}" -name "tutorial.md" -type f -print0 | while IFS= read -r -d '' TUTORIAL_FILE; do + echo "Processing ${TUTORIAL_FILE}" # Extract feature directory - FEATURE_DIR=$(dirname "$TUTORIAL_FILE") + FEATURE_DIR=$(dirname "${TUTORIAL_FILE}") # Try to find script file in this directory - SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f -print0 | xargs -0 -n1 echo | head -n 1) - if [ -z "$SCRIPT_FILE" ]; then - echo "Warning: No script file found in $FEATURE_DIR, using directory name" - FEATURE_NAME=$(basename "$FEATURE_DIR") + SCRIPT_FILE=$(find "${FEATURE_DIR}" -name "*.cs" -type f -print0 | xargs -0 -n1 echo | head -n 1) + + if [ -z "${SCRIPT_FILE}" ]; then + echo "Warning: No script file found in ${FEATURE_DIR}, using directory name" + FEATURE_NAME=$(basename "${FEATURE_DIR}") else # Extract script filename - SCRIPT_FILENAME=$(basename "$SCRIPT_FILE") + SCRIPT_FILENAME=$(basename "${SCRIPT_FILE}") # Look up the feature name in features.json # Extract feature name with error handling - if ! FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON" 2>/dev/null); then + if ! FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"${SCRIPT_FILENAME}\") | .key" "${FEATURES_JSON}" 2>/dev/null); then echo "Warning: Error parsing features.json with jq, using directory name" - FEATURE_NAME=$(basename "$FEATURE_DIR") + FEATURE_NAME=$(basename "${FEATURE_DIR}") fi # If not found in features.json, fallback to directory name - if [ -z "$FEATURE_NAME" ] || [ "$FEATURE_NAME" == "null" ]; then - echo "Warning: Feature for script $SCRIPT_FILENAME not found in features.json, using directory name" - FEATURE_NAME=$(basename "$FEATURE_DIR") + if [ -z "${FEATURE_NAME}" ] || [ "${FEATURE_NAME}" == "null" ]; then + echo "Warning: Feature for script ${SCRIPT_FILENAME} not found in features.json, using directory name" + FEATURE_NAME=$(basename "${FEATURE_DIR}") fi fi - echo "Feature name: $FEATURE_NAME" + echo "Feature name: ${FEATURE_NAME}" # Copy and rename tutorial file - cp "$TUTORIAL_FILE" "$TUTORIALS_DIR/${FEATURE_NAME}.md" - echo "Copied $TUTORIAL_FILE to $TUTORIALS_DIR/${FEATURE_NAME}.md" + cp "${TUTORIAL_FILE}" "${TUTORIALS_DIR}/${FEATURE_NAME}.md" + echo "Copied ${TUTORIAL_FILE} to ${TUTORIALS_DIR}/${FEATURE_NAME}.md" done # Copy the generated JSON file JSON_FILE="./_parsed/passport-features.json" -if [ -f "$JSON_FILE" ]; then +if [ -f "${JSON_FILE}" ]; then # Create directory for JSON file if it doesn't exist - JSON_DIR="$DOCS_REPO_DIR/docs/main/example/zkEVM/passport-examples" - mkdir -p "$JSON_DIR" + JSON_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/passport-examples" + mkdir -p "${JSON_DIR}" # Copy JSON file - cp "$JSON_FILE" "$JSON_DIR/passport-features.json" - echo "Copied $JSON_FILE to $JSON_DIR/passport-features.json" + cp "${JSON_FILE}" "${JSON_DIR}/passport-features.json" + echo "Copied ${JSON_FILE} to ${JSON_DIR}/passport-features.json" else - echo "Warning: No passport-features.json found at $JSON_FILE" + echo "Warning: No passport-features.json found at ${JSON_FILE}" fi echo "Passport tutorial processing complete." \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md b/sample/Assets/Scripts/Passport/Login/tutorial.md index e8cdb7d9..ff4895d6 100644 --- a/sample/Assets/Scripts/Passport/Login/tutorial.md +++ b/sample/Assets/Scripts/Passport/Login/tutorial.md @@ -4,7 +4,7 @@
-Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth +Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth.
From 361497f248584d77345485c730ba2fe45c66b0be Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Thu, 22 May 2025 11:53:20 +1000 Subject: [PATCH 09/18] chore: changed workflow secret --- .github/workflows/publish-passport-tutorials.yml | 2 +- sample/Assets/Scripts/Passport/Login/tutorial.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-passport-tutorials.yml b/.github/workflows/publish-passport-tutorials.yml index a1abee7e..f5d22457 100644 --- a/.github/workflows/publish-passport-tutorials.yml +++ b/.github/workflows/publish-passport-tutorials.yml @@ -35,7 +35,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with: repository: immutable/docs - token: ${{ secrets.UNITY_IMMUTABLE_SDK_GITHUB_TOKEN }} + token: ${{ secrets.UNITY_SDK_DOCS_WORKFLOW }} path: imx-docs ref: 'DVR-425-unity-sample-app-tutorial' diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md b/sample/Assets/Scripts/Passport/Login/tutorial.md index ff4895d6..e8cdb7d9 100644 --- a/sample/Assets/Scripts/Passport/Login/tutorial.md +++ b/sample/Assets/Scripts/Passport/Login/tutorial.md @@ -4,7 +4,7 @@
-Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth. +Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth
From 87e1071dbf69f37e8c4c39731e5e497b39e3c4e2 Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Thu, 22 May 2025 12:02:27 +1000 Subject: [PATCH 10/18] fix: changed directory and target branch for more testing --- .github/scripts/process-passport-tutorials.sh | 4 ++-- .github/workflows/publish-passport-tutorials.yml | 4 ++-- sample/Assets/Scripts/Passport/Login/tutorial.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/scripts/process-passport-tutorials.sh b/.github/scripts/process-passport-tutorials.sh index b7796fc2..7b70a6eb 100755 --- a/.github/scripts/process-passport-tutorials.sh +++ b/.github/scripts/process-passport-tutorials.sh @@ -19,7 +19,7 @@ if [ ! -f "${FEATURES_JSON}" ]; then fi # Create _tutorials directory in docs repo -TUTORIALS_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/passport-examples/_tutorials" +TUTORIALS_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/unity/passport-examples/_tutorials" mkdir -p "${TUTORIALS_DIR}" # Process null-delimited filenames @@ -64,7 +64,7 @@ done JSON_FILE="./_parsed/passport-features.json" if [ -f "${JSON_FILE}" ]; then # Create directory for JSON file if it doesn't exist - JSON_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/passport-examples" + JSON_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/unity/passport-examples" mkdir -p "${JSON_DIR}" # Copy JSON file diff --git a/.github/workflows/publish-passport-tutorials.yml b/.github/workflows/publish-passport-tutorials.yml index f5d22457..28301ac1 100644 --- a/.github/workflows/publish-passport-tutorials.yml +++ b/.github/workflows/publish-passport-tutorials.yml @@ -37,7 +37,7 @@ jobs: repository: immutable/docs token: ${{ secrets.UNITY_SDK_DOCS_WORKFLOW }} path: imx-docs - ref: 'DVR-425-unity-sample-app-tutorial' + ref: 'DVR-425-unity-sample-app-tutorial-v2' - name: Setup environment variables run: echo "CLONE_DIR=./imx-docs" >> $GITHUB_ENV @@ -76,7 +76,7 @@ jobs: git commit -m "$COMMIT_MSG" # Push to the target branch - git push -u origin DVR-425-unity-sample-app-tutorial + git push -u origin DVR-425-unity-sample-app-tutorial-v2 echo "Successfully pushed Passport tutorial changes to docs repo" else echo "No changes to commit" diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md b/sample/Assets/Scripts/Passport/Login/tutorial.md index e8cdb7d9..ff4895d6 100644 --- a/sample/Assets/Scripts/Passport/Login/tutorial.md +++ b/sample/Assets/Scripts/Passport/Login/tutorial.md @@ -4,7 +4,7 @@
-Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth +Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth.
From 32bfc3ebe7ce32bc22d527d7f26760e4d3bece4e Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Thu, 22 May 2025 12:34:39 +1000 Subject: [PATCH 11/18] test: workflow test on new docs dir structure --- sample/Assets/Scripts/Passport/Login/tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md b/sample/Assets/Scripts/Passport/Login/tutorial.md index ff4895d6..e8cdb7d9 100644 --- a/sample/Assets/Scripts/Passport/Login/tutorial.md +++ b/sample/Assets/Scripts/Passport/Login/tutorial.md @@ -4,7 +4,7 @@
-Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth. +Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth
From d1943226d2850117cbeb1c139f5cd9ffeaa23bcd Mon Sep 17 00:00:00 2001 From: darrenmelvison1 Date: Thu, 22 May 2025 16:24:59 +1000 Subject: [PATCH 12/18] chore: revamped tutorial structure to be under feature groups --- .../scripts/aggregate-passport-metadata.js | 144 ++++----- .github/scripts/process-passport-tutorials.sh | 66 ++-- .../workflows/publish-passport-tutorials.yml | 3 +- .../ClearStorageAndCache/metadata.json | 8 - .../ClearStorageAndCache/metadata.json.meta | 7 - .../Passport/ClearStorageAndCache/tutorial.md | 81 ----- .../ClearStorageAndCache/tutorial.md.meta | 7 - .../Passport/GetUserInfo/metadata.json | 8 - .../Passport/GetUserInfo/metadata.json.meta | 7 - .../Scripts/Passport/GetUserInfo/tutorial.md | 195 ----------- .../Passport/GetUserInfo/tutorial.md.meta | 7 - .../Scripts/Passport/ImxConnect/metadata.json | 8 - .../Passport/ImxConnect/metadata.json.meta | 7 - .../Scripts/Passport/ImxConnect/tutorial.md | 82 ----- .../Passport/ImxConnect/tutorial.md.meta | 7 - .../Passport/ImxGetAddress/metadata.json | 8 - .../Passport/ImxGetAddress/metadata.json.meta | 7 - .../Passport/ImxGetAddress/tutorial.md | 72 ----- .../Passport/ImxGetAddress/tutorial.md.meta | 7 - .../ImxIsRegisteredOffchain/metadata.json | 8 - .../metadata.json.meta | 7 - .../ImxIsRegisteredOffchain/tutorial.md | 84 ----- .../ImxIsRegisteredOffchain/tutorial.md.meta | 7 - .../Passport/ImxNftTransfer/metadata.json | 8 - .../ImxNftTransfer/metadata.json.meta | 7 - .../Passport/ImxNftTransfer/tutorial.md | 86 ----- .../Passport/ImxNftTransfer/tutorial.md.meta | 7 - .../Passport/ImxRegister/metadata.json | 8 - .../Passport/ImxRegister/metadata.json.meta | 7 - .../Scripts/Passport/ImxRegister/tutorial.md | 69 ---- .../Passport/ImxRegister/tutorial.md.meta | 7 - .../Scripts/Passport/Login/metadata.json | 8 - .../Scripts/Passport/Login/metadata.json.meta | 7 - .../Assets/Scripts/Passport/Login/tutorial.md | 79 ----- .../Scripts/Passport/Login/tutorial.md.meta | 7 - .../Scripts/Passport/Logout/metadata.json | 8 - .../Passport/Logout/metadata.json.meta | 7 - .../Scripts/Passport/Logout/tutorial.md | 80 ----- .../Scripts/Passport/Logout/tutorial.md.meta | 7 - .../Other/SetCallTimeout/metadata.json | 8 - .../Other/SetCallTimeout/metadata.json.meta | 7 - .../Passport/Other/SetCallTimeout/tutorial.md | 66 ---- .../Other/SetCallTimeout/tutorial.md.meta | 7 - .../PassportInitialisation/metadata.json | 8 - .../PassportInitialisation/metadata.json.meta | 7 - .../PassportInitialisation/tutorial.md | 130 -------- .../PassportInitialisation/tutorial.md.meta | 7 - .../Scripts/Passport/Reconnect/metadata.json | 8 - .../Passport/Reconnect/metadata.json.meta | 7 - .../Scripts/Passport/Reconnect/tutorial.md | 88 ----- .../Passport/Reconnect/tutorial.md.meta | 7 - .../Scripts/Passport/Relogin/metadata.json | 8 - .../Passport/Relogin/metadata.json.meta | 7 - .../Scripts/Passport/Relogin/tutorial.md | 73 ----- .../Scripts/Passport/Relogin/tutorial.md.meta | 7 - .../Passport/ZkEvm/ZkEvmConnect/metadata.json | 8 - .../ZkEvm/ZkEvmConnect/metadata.json.meta | 7 - .../Passport/ZkEvm/ZkEvmConnect/tutorial.md | 82 ----- .../ZkEvm/ZkEvmConnect/tutorial.md.meta | 7 - .../ZkEvm/ZkEvmGetBalance/metadata.json | 8 - .../ZkEvm/ZkEvmGetBalance/metadata.json.meta | 7 - .../ZkEvm/ZkEvmGetBalance/tutorial.md | 85 ----- .../ZkEvm/ZkEvmGetBalance/tutorial.md.meta | 7 - .../ZkEvmGetTransactionReceipt/metadata.json | 8 - .../metadata.json.meta | 7 - .../ZkEvmGetTransactionReceipt/tutorial.md | 100 ------ .../tutorial.md.meta | 7 - .../ZkEvm/ZkEvmRequestAccounts/metadata.json | 8 - .../ZkEvmRequestAccounts/metadata.json.meta | 7 - .../ZkEvm/ZkEvmRequestAccounts/tutorial.md | 76 ----- .../ZkEvmRequestAccounts/tutorial.md.meta | 7 - .../ZkEvm/ZkEvmSendTransaction/metadata.json | 8 - .../ZkEvmSendTransaction/metadata.json.meta | 7 - .../ZkEvm/ZkEvmSendTransaction/tutorial.md | 79 ----- .../ZkEvmSendTransaction/tutorial.md.meta | 7 - .../ZkEvm/ZkEvmSignTypedData/metadata.json | 8 - .../ZkEvmSignTypedData/metadata.json.meta | 7 - .../ZkEvm/ZkEvmSignTypedData/tutorial.md | 80 ----- .../ZkEvm/ZkEvmSignTypedData/tutorial.md.meta | 7 - .../_prompts/tutorial-generation-prompt.txt | 147 ++++++--- .../_tutorials/Authentication/metadata.json | 8 + .../_tutorials/Authentication/tutorial.md | 220 +++++++++++++ .../ClearStorageAndCache/metadata.json | 8 + .../ClearStorageAndCache/tutorial.md | 86 +++++ .../_tutorials/GetUserInfo/metadata.json | 8 + .../_tutorials/GetUserInfo/tutorial.md | 103 ++++++ .../Passport/_tutorials/Imx/metadata.json | 8 + .../Passport/_tutorials/Imx/tutorial.md | 297 +++++++++++++++++ .../PassportInitialisation/metadata.json | 8 + .../PassportInitialisation/tutorial.md | 97 ++++++ .../_tutorials/SetCallTimeout/metadata.json | 8 + .../_tutorials/SetCallTimeout/tutorial.md | 93 ++++++ .../Passport/_tutorials/ZkEvm/metadata.json | 8 + .../Passport/_tutorials/ZkEvm/tutorial.md | 305 ++++++++++++++++++ sample/Assets/Scripts/Passport/features.json | 58 ++-- 95 files changed, 1481 insertions(+), 2299 deletions(-) delete mode 100644 sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/GetUserInfo/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/GetUserInfo/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxConnect/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ImxConnect/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxConnect/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ImxConnect/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxRegister/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ImxRegister/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ImxRegister/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ImxRegister/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/Login/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/Login/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/Login/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/Login/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/Logout/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/Logout/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/Logout/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/Logout/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/Reconnect/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/Reconnect/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/Reconnect/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/Reconnect/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/Relogin/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/Relogin/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/Relogin/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/Relogin/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json.meta delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md delete mode 100644 sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md.meta create mode 100644 sample/Assets/Scripts/Passport/_tutorials/Authentication/metadata.json create mode 100644 sample/Assets/Scripts/Passport/_tutorials/Authentication/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/_tutorials/ClearStorageAndCache/metadata.json create mode 100644 sample/Assets/Scripts/Passport/_tutorials/ClearStorageAndCache/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/_tutorials/GetUserInfo/metadata.json create mode 100644 sample/Assets/Scripts/Passport/_tutorials/GetUserInfo/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/_tutorials/Imx/metadata.json create mode 100644 sample/Assets/Scripts/Passport/_tutorials/Imx/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/_tutorials/PassportInitialisation/metadata.json create mode 100644 sample/Assets/Scripts/Passport/_tutorials/PassportInitialisation/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/_tutorials/SetCallTimeout/metadata.json create mode 100644 sample/Assets/Scripts/Passport/_tutorials/SetCallTimeout/tutorial.md create mode 100644 sample/Assets/Scripts/Passport/_tutorials/ZkEvm/metadata.json create mode 100644 sample/Assets/Scripts/Passport/_tutorials/ZkEvm/tutorial.md diff --git a/.github/scripts/aggregate-passport-metadata.js b/.github/scripts/aggregate-passport-metadata.js index 1c562ab7..c08e4afa 100755 --- a/.github/scripts/aggregate-passport-metadata.js +++ b/.github/scripts/aggregate-passport-metadata.js @@ -7,6 +7,7 @@ const path = require('path'); // Configuration const PASSPORT_ROOT = './sample/Assets/Scripts/Passport'; +const TUTORIALS_DIR = path.join(PASSPORT_ROOT, '_tutorials'); const OUTPUT_DIR = './_parsed'; const OUTPUT_FILE = path.join(OUTPUT_DIR, 'passport-features.json'); const FEATURES_JSON_PATH = path.join(PASSPORT_ROOT, 'features.json'); @@ -23,138 +24,105 @@ try { console.log('Processing Passport features metadata...'); -// Load features.json to map script files to feature names -const featuresMap = {}; +// Load features.json to get feature groups and their features +let featureGroups = {}; try { const featuresContent = fs.readFileSync(FEATURES_JSON_PATH, 'utf8'); const featuresJson = JSON.parse(featuresContent); - - // Create mapping of script filename to feature name - featuresJson.features.forEach((feature) => { - const [featureName, scriptFile] = Object.entries(feature)[0]; - // Store both the full filename and just the filename without path - featuresMap[scriptFile] = featureName; - featuresMap[path.basename(scriptFile)] = featureName; - }); + featureGroups = featuresJson.features || {}; } catch (error) { console.error(`Error reading features.json: ${error.message}`); process.exit(1); } -// Platform-independent recursive file search -const findMetadataFiles = () => { - const metadataFiles = []; +// Find all feature group directories in _tutorials +const findFeatureGroupDirectories = () => { + const featureGroupDirs = []; + + if (!fs.existsSync(TUTORIALS_DIR)) { + console.warn(`Tutorials directory does not exist: ${TUTORIALS_DIR}`); + return featureGroupDirs; + } - const walkDir = (dir) => { - if (!fs.existsSync(dir)) { - console.warn(`Directory does not exist: ${dir}`); - return; - } + try { + const dirs = fs.readdirSync(TUTORIALS_DIR, { withFileTypes: true }); - try { - const files = fs.readdirSync(dir); - - files.forEach((file) => { - const filePath = path.join(dir, file); - - try { - const stat = fs.statSync(filePath); - - if (stat.isDirectory()) { - walkDir(filePath); - } else if (file === 'metadata.json') { - metadataFiles.push(filePath); - } - } catch (err) { - console.warn(`Error accessing file ${filePath}: ${err.message}`); - } - }); - } catch (err) { - console.warn(`Error reading directory ${dir}: ${err.message}`); - } - }; + dirs.forEach((dirent) => { + if (dirent.isDirectory()) { + featureGroupDirs.push(path.join(TUTORIALS_DIR, dirent.name)); + } + }); + } catch (err) { + console.warn(`Error reading tutorials directory ${TUTORIALS_DIR}: ${err.message}`); + } - walkDir(PASSPORT_ROOT); - return metadataFiles; + return featureGroupDirs; }; // Process metadata files -const processMetadataFiles = (metadataFiles) => { +const processFeatureGroups = (featureGroupDirs) => { const featuresObject = {}; - metadataFiles.forEach((metadataFile) => { - console.log(`Processing ${metadataFile}`); - - // Extract feature directory - const featureDir = path.dirname(metadataFile); + featureGroupDirs.forEach((groupDir) => { + const groupName = path.basename(groupDir); + console.log(`Processing feature group: ${groupName}`); - // Get directory name as fallback feature name - const dirName = path.basename(featureDir); + // Check if this group exists in features.json + if (!featureGroups[groupName]) { + console.warn(`Feature group ${groupName} not found in features.json, skipping`); + return; + } - // Try to find feature name in feature map, fallback to directory name - let featureName = ''; - try { - // Look for any script file in this directory - const dirFiles = fs.readdirSync(featureDir); - const scriptFiles = dirFiles.filter((file) => file.endsWith('.cs')); - - // Try to match any script file to our feature map - let found = false; - for (const scriptFile of scriptFiles) { - if (featuresMap[scriptFile]) { - featureName = featuresMap[scriptFile]; - found = true; - break; - } - } - - if (!found) { - console.warn(`No feature found in features.json for ${featureDir}, using directory name`); - featureName = dirName; - } - } catch (error) { - console.warn(`Error processing directory ${featureDir}: ${error.message}`); - featureName = dirName; + // Path to metadata.json in this feature group directory + const metadataPath = path.join(groupDir, 'metadata.json'); + if (!fs.existsSync(metadataPath)) { + console.warn(`No metadata.json found for feature group ${groupName} in ${groupDir}`); + return; } - // Create feature key (kebab-case) - const featureKey = featureName + // Path to tutorial.md in this feature group directory + const tutorialPath = path.join(groupDir, 'tutorial.md'); + const tutorialExists = fs.existsSync(tutorialPath); + + // Create the feature key (kebab-case) + const featureKey = groupName .replace(/([a-z])([A-Z])/g, '$1-$2') .replace(/\s+/g, '-') .replace(/[^a-z0-9-]/gi, '') .toLowerCase(); if (!featureKey) { - console.warn(`Generated empty feature key for ${featureDir}, skipping`); + console.warn(`Generated empty feature key for ${groupName}, skipping`); return; } - // Check for tutorial.md in the same directory - const tutorialPath = path.join(featureDir, 'tutorial.md'); - const tutorialExists = fs.existsSync(tutorialPath); const tutorialFile = tutorialExists ? `${featureKey}.md` : null; if (!tutorialExists) { - console.warn(`No tutorial.md found for feature ${featureName} in ${featureDir}`); + console.warn(`No tutorial.md found for feature group ${groupName} in ${groupDir}`); } // Read and process metadata try { - const metadataContent = fs.readFileSync(metadataFile, 'utf8'); + const metadataContent = fs.readFileSync(metadataPath, 'utf8'); const metadata = JSON.parse(metadataContent); // Add additional fields - metadata.title = metadata.title || featureName; + metadata.title = metadata.title || groupName; metadata.sidebar_order = metadata.sidebar_order || 0; metadata.deprecated = metadata.deprecated || false; + // Add feature group information + metadata.feature_group = groupName; + metadata.features = Object.keys(featureGroups[groupName] || {}); + // Create the feature entry featuresObject[featureKey] = { tutorial: tutorialFile, metadata: metadata }; } catch (error) { - console.error(`Error processing metadata file ${metadataFile}: ${error.message}`); + console.error(`Error processing metadata file ${metadataPath}: ${error.message}`); } }); @@ -163,13 +131,13 @@ const processMetadataFiles = (metadataFiles) => { try { // Main execution - const metadataFiles = findMetadataFiles(); + const featureGroupDirs = findFeatureGroupDirectories(); - if (metadataFiles.length === 0) { - console.warn('No metadata files found. Output file will be empty.'); + if (featureGroupDirs.length === 0) { + console.warn('No feature group directories found. Output file will be empty.'); } - const features = processMetadataFiles(metadataFiles); + const features = processFeatureGroups(featureGroupDirs); // Create the final passport-features.json fs.writeFileSync(OUTPUT_FILE, JSON.stringify(features, null, 2)); diff --git a/.github/scripts/process-passport-tutorials.sh b/.github/scripts/process-passport-tutorials.sh index 7b70a6eb..082436b9 100755 --- a/.github/scripts/process-passport-tutorials.sh +++ b/.github/scripts/process-passport-tutorials.sh @@ -8,10 +8,11 @@ DOCS_REPO_DIR="${CLONE_DIR:-"./imx-docs"}" # Root of the Passport features PASSPORT_ROOT="./sample/Assets/Scripts/Passport" +TUTORIALS_DIR="${PASSPORT_ROOT}/_tutorials" echo "Processing Passport tutorials..." -# Load features.json to map script files to feature names +# Load features.json to get feature groups FEATURES_JSON="${PASSPORT_ROOT}/features.json" if [ ! -f "${FEATURES_JSON}" ]; then echo "Error: features.json not found at ${FEATURES_JSON}" @@ -19,46 +20,37 @@ if [ ! -f "${FEATURES_JSON}" ]; then fi # Create _tutorials directory in docs repo -TUTORIALS_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/unity/passport-examples/_tutorials" -mkdir -p "${TUTORIALS_DIR}" +DOCS_TUTORIALS_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/unity/passport-examples/_tutorials" +mkdir -p "${DOCS_TUTORIALS_DIR}" -# Process null-delimited filenames -find "${PASSPORT_ROOT}" -name "tutorial.md" -type f -print0 | while IFS= read -r -d '' TUTORIAL_FILE; do - echo "Processing ${TUTORIAL_FILE}" - - # Extract feature directory - FEATURE_DIR=$(dirname "${TUTORIAL_FILE}") - - # Try to find script file in this directory - SCRIPT_FILE=$(find "${FEATURE_DIR}" -name "*.cs" -type f -print0 | xargs -0 -n1 echo | head -n 1) - - if [ -z "${SCRIPT_FILE}" ]; then - echo "Warning: No script file found in ${FEATURE_DIR}, using directory name" - FEATURE_NAME=$(basename "${FEATURE_DIR}") - else - # Extract script filename - SCRIPT_FILENAME=$(basename "${SCRIPT_FILE}") +# Check if _tutorials directory exists +if [ ! -d "${TUTORIALS_DIR}" ]; then + echo "Warning: _tutorials directory not found at ${TUTORIALS_DIR}" +else + # Process each feature group directory in _tutorials + find "${TUTORIALS_DIR}" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d '' GROUP_DIR; do + echo "Processing feature group: ${GROUP_DIR}" - # Look up the feature name in features.json - # Extract feature name with error handling - if ! FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"${SCRIPT_FILENAME}\") | .key" "${FEATURES_JSON}" 2>/dev/null); then - echo "Warning: Error parsing features.json with jq, using directory name" - FEATURE_NAME=$(basename "${FEATURE_DIR}") - fi + # Extract feature group name from directory + GROUP_NAME=$(basename "${GROUP_DIR}") - # If not found in features.json, fallback to directory name - if [ -z "${FEATURE_NAME}" ] || [ "${FEATURE_NAME}" == "null" ]; then - echo "Warning: Feature for script ${SCRIPT_FILENAME} not found in features.json, using directory name" - FEATURE_NAME=$(basename "${FEATURE_DIR}") + # Tutorial file path + TUTORIAL_FILE="${GROUP_DIR}/tutorial.md" + + if [ -f "${TUTORIAL_FILE}" ]; then + echo "Found tutorial for ${GROUP_NAME}" + + # Convert feature group name to kebab-case for the destination filename + KEBAB_NAME=$(echo "${GROUP_NAME}" | sed -E 's/([a-z])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]') + + # Copy the tutorial file + cp "${TUTORIAL_FILE}" "${DOCS_TUTORIALS_DIR}/${KEBAB_NAME}.md" + echo "Copied ${TUTORIAL_FILE} to ${DOCS_TUTORIALS_DIR}/${KEBAB_NAME}.md" + else + echo "Warning: No tutorial.md found for feature group ${GROUP_NAME}" fi - fi - - echo "Feature name: ${FEATURE_NAME}" - - # Copy and rename tutorial file - cp "${TUTORIAL_FILE}" "${TUTORIALS_DIR}/${FEATURE_NAME}.md" - echo "Copied ${TUTORIAL_FILE} to ${TUTORIALS_DIR}/${FEATURE_NAME}.md" -done + done +fi # Copy the generated JSON file JSON_FILE="./_parsed/passport-features.json" diff --git a/.github/workflows/publish-passport-tutorials.yml b/.github/workflows/publish-passport-tutorials.yml index 28301ac1..d4de066c 100644 --- a/.github/workflows/publish-passport-tutorials.yml +++ b/.github/workflows/publish-passport-tutorials.yml @@ -7,9 +7,8 @@ on: # - main - chore/sample-app-tutorial paths: - - 'sample/Assets/Scripts/Passport/**/tutorial.md' - - 'sample/Assets/Scripts/Passport/**/metadata.json' - 'sample/Assets/Scripts/Passport/features.json' + - 'sample/Assets/Scripts/Passport/_tutorials/**/*' # Allow manual triggering workflow_dispatch: diff --git a/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json b/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json deleted file mode 100644 index fa08197c..00000000 --- a/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Clear Storage and Cache", - "description": "Clears the WebView storage and cache on mobile platforms, removing any locally stored data and credentials", - "keywords": ["Immutable", "SDK", "Passport", "Storage", "Cache", "Mobile", "Android", "iOS"], - "tech_stack": ["Unity", "C#", "WebView"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json.meta b/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json.meta deleted file mode 100644 index 2d8f0654..00000000 --- a/sample/Assets/Scripts/Passport/ClearStorageAndCache/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 7447d28a5df46421a8c4a9cc5c272579 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md b/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md deleted file mode 100644 index 5a32b7cf..00000000 --- a/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md +++ /dev/null @@ -1,81 +0,0 @@ - - -The Clear Storage and Cache feature allows you to clear the underlying WebView storage and cache on mobile devices. This is particularly useful for resetting saved credentials and other locally stored data during development or when implementing logout functionality. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ClearStorageAndCache) - -
- -## Feature Overview - -This atomic feature demonstrates how to use the Immutable Passport SDK to clear the WebView's storage and cache on mobile platforms (Android and iOS). - -## SDK Integration Details - -The Clear Storage and Cache feature allows developers to clear all locally stored data in the WebView used by the Passport SDK. This includes: -- Local storage data -- Session storage -- WebSQL databases -- Indexed databases -- Memory and disk caches - -```csharp title="ClearStorageAndCache" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ClearStorageAndCache/ClearStorageAndCacheScript.cs" -public void ClearStorageAndCache() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null. Initialize Passport first."); - return; - } - -#if UNITY_ANDROID && !UNITY_EDITOR - ShowOutput("Clearing storage and cache..."); - Passport.Instance.ClearStorage(); - Passport.Instance.ClearCache(true); - ShowOutput("Storage and cache cleared (on Android)."); -#elif UNITY_IPHONE && !UNITY_EDITOR - ShowOutput("Clearing storage and cache..."); - Passport.Instance.ClearStorage(); - Passport.Instance.ClearCache(true); - ShowOutput("Storage and cache cleared (on iOS)."); -#else - ShowOutput("ClearStorageAndCache is only available on Android and iOS devices."); -#endif -} -``` - -The function first checks if the Passport instance is initialized. If it is, it calls two methods: - -1. `Passport.Instance.ClearStorage()` - Clears all data stored using JavaScript storage APIs, including local storage, session storage, WebSQL databases, and IndexedDB. -2. `Passport.Instance.ClearCache(true)` - Clears the WebView's resource cache, including both memory and disk cache when the `includeDiskFiles` parameter is set to `true`. - -These methods are only available on Android and iOS platforms, and will not work in the Unity Editor or on desktop platforms. - -## Running the Feature Example - -### Prerequisites -- Set up your Immutable Passport application on [Immutable Hub](https://hub.immutable.com/) -- Configure your Unity project with the Immutable Passport SDK - -### Steps to Run -1. Open the sample project in Unity -2. Navigate to the Authenticated/Unauthenticated scene -3. Build and run the application on an Android or iOS device -4. Press the "Clear Storage and Cache" button to execute the feature -5. Observe the output message confirming that storage and cache have been cleared - -## Summary - -The Clear Storage and Cache feature provides a simple way to clear all locally stored data in the WebView used by the Passport SDK. This can be useful for: -- Debugging authentication issues -- Implementing complete logout functionality -- Resetting the application state -- Clearing saved credentials - -Remember that this feature only works on actual Android and iOS devices, not in the Unity Editor or on desktop platforms. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md.meta b/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md.meta deleted file mode 100644 index b423f110..00000000 --- a/sample/Assets/Scripts/Passport/ClearStorageAndCache/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 2440bdd2896ba4df3b67acaaf73b2b27 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json b/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json deleted file mode 100644 index 582f8e53..00000000 --- a/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Get User Information", - "description": "Retrieve user data such as email, Passport ID, access token, ID token, and linked wallet addresses from the Immutable Passport", - "keywords": ["Immutable", "SDK", "Passport", "User Info", "Authentication", "Identity"], - "tech_stack": ["Unity", "C#", "Cysharp UniTask"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json.meta b/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json.meta deleted file mode 100644 index 96c42d34..00000000 --- a/sample/Assets/Scripts/Passport/GetUserInfo/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 036063d5fe09740dc9e6024546daa93f -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md b/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md deleted file mode 100644 index 0d8b6697..00000000 --- a/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md +++ /dev/null @@ -1,195 +0,0 @@ - - -The Get User Info feature allows you to retrieve various pieces of information about the currently logged-in user through the Immutable Passport SDK. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/GetUserInfo) - -
- -## Feature Overview - -The Get User Info feature provides easy access to user data from the Immutable Passport. This includes: - -- User email -- Passport ID -- Access token -- ID token -- Linked addresses (external wallets connected to the Passport account) - -## SDK Integration Details - -The Get User Info feature utilizes five key methods from the Passport SDK to retrieve different types of user information. Each method returns specific data related to the authenticated user. - -### Retrieving User Email - -```csharp title="GetEmail" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" -public void GetEmail() -{ - GetEmailAsync(); -} - -private async UniTaskVoid GetEmailAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - try - { - string email = await Passport.Instance.GetEmail(); - ShowOutput(email); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to get email: {ex.Message}"); - } -} -``` - -This code retrieves the email address of the currently authenticated user. It first checks if the Passport instance is available, then calls the `GetEmail()` method which returns the email as a string. The method is asynchronous and uses UniTask to handle the async operation without blocking the main thread. - -### Retrieving Passport ID - -```csharp title="GetPassportId" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" -public void GetPassportId() -{ - GetPassportIdAsync(); -} - -private async UniTaskVoid GetPassportIdAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - try - { - string passportId = await Passport.Instance.GetPassportId(); - ShowOutput(passportId); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to get Passport ID: {ex.Message}"); - } -} -``` - -The `GetPassportId()` method retrieves the unique identifier for the user's Passport account. This ID can be used to identify the user across different Immutable services. The method performs a null check on the Passport instance before making the async call and handles any exceptions that might occur during the process. - -### Retrieving Access Token - -```csharp title="GetAccessToken" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" -public void GetAccessToken() -{ - GetAccessTokenAsync(); -} - -private async UniTaskVoid GetAccessTokenAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - try - { - string accessToken = await Passport.Instance.GetAccessToken(); - ShowOutput(accessToken); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to get access token: {ex.Message}"); - } -} -``` - -The `GetAccessToken()` method retrieves the current OAuth access token for the authenticated user. This token is used for authenticating API calls to Immutable services. The method follows the same pattern of checking for a valid Passport instance, making the async call, and handling any exceptions. - -### Retrieving ID Token - -```csharp title="GetIdToken" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" -public void GetIdToken() -{ - GetIdTokenAsync(); -} - -private async UniTaskVoid GetIdTokenAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - try - { - string idToken = await Passport.Instance.GetIdToken(); - ShowOutput(idToken); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to get ID token: {ex.Message}"); - } -} -``` - -The `GetIdToken()` method retrieves the ID token, which contains claims about the identity of the authenticated user. This token follows the OpenID Connect standard and can be used to verify the user's identity. Like the other methods, it performs proper error handling and operates asynchronously. - -### Retrieving Linked Addresses - -```csharp title="GetLinkedAddresses" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/GetUserInfo/GetUserInfoScript.cs" -public void GetLinkedAddresses() -{ - GetLinkedAddressesAsync(); -} - -private async UniTaskVoid GetLinkedAddressesAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - try - { - List addresses = await Passport.Instance.GetLinkedAddresses(); - string outputMessage = addresses.Count > 0 ? string.Join(", ", addresses) : "No linked addresses"; - ShowOutput(outputMessage); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to get linked addresses: {ex.Message}"); - } -} -``` - -The `GetLinkedAddresses()` method retrieves a list of external wallet addresses that the user has linked to their Passport account through the Passport dashboard. This is particularly useful for games that need to know which external wallets a user has connected. The method returns a List of strings containing the wallet addresses, and formats them for display. - -## Running the Feature Example - -### Prerequisites - -- Set up your development environment as described in the [Immutable Hub](https://hub.immutable.com/docs/overview) -- Have Unity installed (version 2021.3 LTS or newer) -- Clone the Immutable Unity SDK repository - -### Step-by-step Instructions - -1. Open the sample project in Unity Editor -2. Navigate to the Passport initialization scene -3. Play the scene to initialize Passport -4. Log in using your Immutable Passport credentials -5. Navigate to the "Get User Info" example in the sample app -6. Click on any of the buttons ("Get Email", "Get Passport ID", "Get Access Token", "Get ID Token", or "Get Linked Addresses") to retrieve the corresponding user information -7. The retrieved information will be displayed in the output text area - -## Summary - -The Get User Info feature provides simple but powerful methods to access user information from the Immutable Passport. By implementing these methods, games can easily retrieve user email, Passport ID, tokens, and linked wallet addresses. This information can be used for user identification, authentication of API calls, and connecting to the user's blockchain assets. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md.meta b/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md.meta deleted file mode 100644 index 8b79316b..00000000 --- a/sample/Assets/Scripts/Passport/GetUserInfo/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 3004807f5a2bc4b8091effcca48f62cd -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxConnect/metadata.json b/sample/Assets/Scripts/Passport/ImxConnect/metadata.json deleted file mode 100644 index 5a2b92cb..00000000 --- a/sample/Assets/Scripts/Passport/ImxConnect/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "IMX Connect", - "description": "Connect to Immutable X, initializing the user's wallet and setting up the Immutable X provider", - "keywords": ["Immutable", "SDK", "Passport", "IMX", "Connect", "Authentication"], - "tech_stack": ["Unity", "C#", "Immutable X"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxConnect/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxConnect/metadata.json.meta deleted file mode 100644 index abc2673e..00000000 --- a/sample/Assets/Scripts/Passport/ImxConnect/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1a87a10906bbd4e78947b7898657bd56 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md b/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md deleted file mode 100644 index a47c0365..00000000 --- a/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md +++ /dev/null @@ -1,82 +0,0 @@ - - -The IMX Connect feature allows your application to connect to Immutable X, initializing the user's wallet and setting up the Immutable X provider. This is a crucial step required before performing any Immutable X-specific operations like token transfers or NFT interactions. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/imxconnect) - -
- -## Feature Overview - -This atomic feature demonstrates how to connect to Immutable X using the Passport SDK. - -## SDK Integration Details - -The IMX Connect feature establishes a connection to Immutable X using the user's Passport credentials. It sets up the Immutable X provider, allowing your application to interact with the Immutable X blockchain. - -```csharp title="IMXConnect" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/imxconnect/ImxConnectScript.cs" -public void ConnectImx() -{ - ConnectImxAsync(); -} - -private async UniTaskVoid ConnectImxAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - // Set the static property for global access - SampleAppManager.PassportInstance = Passport.Instance; - ShowOutput("Connecting to Passport using saved credentials..."); - try - { - await Passport.Instance.ConnectImx(); - - SampleAppManager.IsConnectedToImx = true; - ShowOutput("Connected to IMX"); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to connect to IMX: {ex.Message}"); - } -} -``` - -The code works by: - -1. When `ConnectImx()` is called, it triggers the asynchronous function `ConnectImxAsync()` -2. The function first checks if a valid Passport instance exists -3. It then calls `Passport.Instance.ConnectImx()`, which: - - Uses saved credentials if available (access token or refresh token) - - If credentials don't exist or are invalid, it opens the user's browser for authentication via device code flow - - Sets up the Immutable X provider after successful authentication -4. Upon successful connection, it updates the application state to reflect that the user is connected to Immutable X - -## Running the Feature Example - -### Prerequisites - -- Set up your environment following the [Immutable Hub documentation](https://docs.immutable.com/docs/hub/setup) -- Unity Editor (2021.3 LTS or later) -- Immutable Unity SDK installed and configured - -### Steps to Run the Example - -1. Open the sample project in Unity Editor -2. Navigate to the Passport scene that contains the IMXConnect feature -3. Enter Play mode in the Unity Editor -4. Click the "Connect IMX" button in the sample UI -5. If you're not already logged in, a browser window will open for authentication -6. After successful authentication, you will see "Connected to IMX" in the output text - -## Summary - -The IMX Connect feature is essential for any application that needs to interact with the Immutable X blockchain. It handles the authentication flow and sets up the Immutable X provider, allowing your game to perform operations like token transfers and NFT interactions. This feature provides a seamless way to connect users to Immutable X while managing the complexities of authentication and provider initialization behind the scenes. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md.meta deleted file mode 100644 index 8a476816..00000000 --- a/sample/Assets/Scripts/Passport/ImxConnect/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: da4f08cf1356d40f7a41ec014f800ec0 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json b/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json deleted file mode 100644 index f8b3e459..00000000 --- a/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "IMX Get Address", - "description": "Retrieve the Immutable wallet address of the currently logged-in user", - "keywords": ["Immutable", "SDK", "Passport", "Wallet", "Address", "IMX"], - "tech_stack": ["Unity", "C#"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json.meta deleted file mode 100644 index ea2ee371..00000000 --- a/sample/Assets/Scripts/Passport/ImxGetAddress/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 7f635745bd4424a4a9f6ef74e8ee8ed8 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md b/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md deleted file mode 100644 index 1017f321..00000000 --- a/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md +++ /dev/null @@ -1,72 +0,0 @@ - - -Get the connected Immutable Wallet address quickly and easily. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ImxGetAddress) - -
- -## Feature Overview - -The IMX Get Address feature allows developers to retrieve the Immutable wallet address of the currently logged-in user. This is a fundamental operation for many blockchain applications that need to identify the user's wallet address to perform transactions, display balances, or interact with smart contracts. - -## SDK Integration Details - -This feature provides a simple way to retrieve the user's wallet address through the Passport SDK. The implementation is straightforward: simply call `GetAddress()` on the Passport instance. - -```csharp title="ImxGetAddressScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ImxGetAddress/ImxGetAddressScript.cs" -/// -/// Gets the wallet address of the currently logged-in user. -/// -public async void GetAddress() -{ - ShowOutput("Retrieving wallet address..."); - try - { - string address = await Passport.GetAddress(); - ShowOutput(string.IsNullOrEmpty(address) ? "No address found" : address); - } - catch (PassportException e) - { - ShowOutput($"Unable to retrieve address: {e.Message} ({e.Type})"); - } - catch (Exception) - { - ShowOutput("Unable to retrieve address"); - } -} -``` - -### How it works - -The code performs these steps: -1. Calls the asynchronous `GetAddress()` method from the Passport SDK -2. Awaits the response which returns the wallet address as a string -3. Handles potential exceptions that might occur during the request -4. Displays the address (or an error message) to the user - -This method requires the user to be authenticated with Passport first, so make sure your application handles login before calling this method. - -## Running the Feature Example - -### Prerequisites -- Unity Editor 2022.3 or later -- [Immutable Hub](https://hub.immutable.com/) account for environment setup - -### Step-by-step instructions -1. Clone the Unity Immutable SDK repository -2. Open the sample project in Unity Editor -3. Navigate to SelectAuthMethod and login using Immutable Passport -4. In the UnauthenticatedScene, first click "Connect" to authenticate with Passport and connect to the IMX Provider -5. Once logged in, locate and click the "Get IMX Address" button -6. The wallet address will be displayed in the output area - -## Summary - -The IMX Get Address feature provides a simple way to retrieve a user's Immutable wallet address. This functionality is essential for applications that need to identify users, initiate transactions, or interact with blockchain data. By integrating this feature, developers can seamlessly connect their Unity applications with users' Immutable wallets. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md.meta deleted file mode 100644 index 1487ec24..00000000 --- a/sample/Assets/Scripts/Passport/ImxGetAddress/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 2b588afd0cb204681a9a83a19796ca3e -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json deleted file mode 100644 index 3be4c591..00000000 --- a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Check Immutable X off-chain Registration Status", - "description": "Check if a user's wallet is registered off-chain with Immutable X using Passport SDK", - "keywords": ["Immutable", "SDK", "Passport", "Immutable X", "Off-chain", "Registration"], - "tech_stack": ["Unity", "C#", "Immutable Passport"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json.meta deleted file mode 100644 index c4345a91..00000000 --- a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 8270c9f4ffcb447f7b3eda8c43dc7572 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md deleted file mode 100644 index 897c2f6f..00000000 --- a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md +++ /dev/null @@ -1,84 +0,0 @@ - - -The IsRegisteredOffchain feature allows developers to check if a user's wallet has been registered off-chain with Immutable X. This off-chain registration is required for certain operations on Immutable X, such as trading or minting NFTs. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/imxisregisteredoffchain) - -
- -## Feature Overview - -The ImxIsRegisteredOffchain feature demonstrates how to check if a user's wallet is registered off-chain with Immutable X protocol using the Passport SDK. - -## SDK Integration Details - -This feature utilizes the `IsRegisteredOffchain()` method from the Passport SDK to determine if the current wallet is registered with Immutable X's off-chain system. - -Off-chain registration is a one-time process that's required before users can perform operations like trading assets on Immutable X. This check helps applications determine if a user needs to complete the registration process before attempting certain operations. - -```csharp title="ImxIsRegisteredOffchainScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/imxisregisteredoffchain/ImxIsRegisteredOffchainScript.cs" -private async UniTaskVoid CheckIsRegisteredOffchainAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport not initialized."); - return; - } - - if (!SampleAppManager.IsConnectedToImx) - { - ShowOutput("Please connect to Immutable X first."); - return; - } - - ShowOutput("Checking if registered offchain..."); - try - { - bool isRegistered = await SampleAppManager.PassportInstance.IsRegisteredOffchain(); - - if (isRegistered) - { - ShowOutput("Registered"); - } - else - { - ShowOutput("User is NOT registered offchain."); - } - } - catch (System.Exception ex) - { - ShowOutput($"Failed to check registration: {ex.Message}"); - } -} -``` - -The implementation follows these steps: -1. First, it verifies that the Passport instance is initialized -2. It checks if the user is connected to Immutable X (a prerequisite for checking registration status) -3. It calls the `IsRegisteredOffchain()` method which returns a boolean indicating whether the user is registered -4. Based on the result, it displays the appropriate message to the user - -## Running the Feature Example - -### Prerequisites -- Unity Editor (2022.3 LTS or later recommended) -- Immutable Passport SDK imported into your project -- An Immutable Hub account (you can create one at [Immutable Hub](https://hub.immutable.com/)) - -### Steps to Run -1. Open the Passport sample scene in the Unity Editor -2. Connect to Passport by clicking the "Login" button -3. Connect to Immutable X by clicking the "Connect to IMX" button -4. Navigate to the ImxIsRegisteredOffchain feature section -5. Click the "Check Registration" button to verify if the wallet is registered off-chain -6. The result will be displayed in the UI showing either "Registered" or "User is NOT registered offchain" - -## Summary - -The ImxIsRegisteredOffchain feature provides developers with an easy way to check if a user's wallet is registered with Immutable X's off-chain system. This verification is important before attempting operations that require off-chain registration, helping to provide a smoother user experience by guiding users to complete registration when necessary. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md.meta deleted file mode 100644 index 5a88e561..00000000 --- a/sample/Assets/Scripts/Passport/ImxIsRegisteredOffchain/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e403aa657f30742339e17451852893e0 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json b/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json deleted file mode 100644 index 14efbbbe..00000000 --- a/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "IMX NFT Transfer", - "description": "Transfer NFTs on Immutable X to other addresses with single and batch operations", - "keywords": ["Immutable", "SDK", "NFT", "Transfer", "Immutable X", "Passport", "ERC721", "Batch Transfer"], - "tech_stack": ["Unity", "C#", "Immutable X"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json.meta deleted file mode 100644 index cd9ad3a1..00000000 --- a/sample/Assets/Scripts/Passport/ImxNftTransfer/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: b0b736963ea804cd6bef81a7f8e54c18 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md b/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md deleted file mode 100644 index 30f78eb1..00000000 --- a/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md +++ /dev/null @@ -1,86 +0,0 @@ - - -The IMX NFT Transfer feature allows developers to transfer NFTs to other accounts using the Immutable X protocol. This feature provides both single and batch transfer capabilities, enabling efficient management of digital assets within your Unity application. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ImxNftTransfer) - -
- -## Feature Overview -This example demonstrates how to use the Passport SDK to transfer NFTs on Immutable X, including: -- Single NFT transfers using `ImxTransfer` -- Batch transfers of multiple NFTs using `ImxBatchNftTransfer` - -## SDK Integration Details -### Single NFT Transfer -To transfer a single NFT to another address: - -```csharp title="Single NFT Transfer" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ImxNftTransfer/ImxNftTransferScript.cs" -NftTransferDetails nftTransferDetail = new NftTransferDetails( - receiverAddress, // Ethereum address of the receiver - tokenId, // ID of the NFT to transfer - tokenAddress // Contract address of the NFT -); - -UnsignedTransferRequest transferRequest = UnsignedTransferRequest.ERC721( - nftTransferDetail.receiver, - nftTransferDetail.tokenId, - nftTransferDetail.tokenAddress -); - -CreateTransferResponseV1 response = await Passport.Instance.ImxTransfer(transferRequest); -``` - -The code creates an `UnsignedTransferRequest` specifically for ERC721 tokens (NFTs) with the helper method `ERC721()`, then calls the Passport SDK's `ImxTransfer` method to execute the transfer. The response contains the transfer ID and status information. - -### Batch NFT Transfer -For transferring multiple NFTs in a single operation: - -```csharp title="Batch NFT Transfer" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ImxNftTransfer/ImxNftTransferScript.cs" -List transferDetails = new List(); - -// Add first NFT transfer details -transferDetails.Add(new NftTransferDetails( - receiver1, // First receiver address - tokenId1, // First NFT token ID - tokenAddress1 // First NFT contract address -)); - -// Add second NFT transfer details -transferDetails.Add(new NftTransferDetails( - receiver2, // Second receiver address - tokenId2, // Second NFT token ID - tokenAddress2 // Second NFT contract address -)); - -// Execute batch transfer -CreateBatchTransferResponse response = await Passport.Instance.ImxBatchNftTransfer(transferDetails.ToArray()); -``` - -The batch transfer method allows you to transfer multiple NFTs in a single call, which is more efficient than making individual transfer calls. The response contains an array of transfer IDs for each successfully transferred NFT. - -## Running the Feature Example -### Prerequisites -- Unity Editor 2021.3 or higher -- [Immutable Hub](https://hub.immutable.com/) account for environment setup -- Passport SDK integrated into your Unity project - -### Steps to Run the Example -1. Open the sample project in Unity Editor -2. Navigate to the `sample/Assets/Scenes/Passport/Imx/ImxNftTransfer.unity` scene -3. Ensure you have already logged in to Passport (you can use the Login feature example first) -4. Enter the required information for at least one NFT transfer: - - Token ID: The unique identifier of the NFT - - Token Address: The smart contract address for the NFT collection - - Receiver: The Ethereum address of the recipient -5. Click the "Transfer" button to execute the transfer -6. Check the output message to confirm successful transfer or identify any errors - -## Summary -The IMX NFT Transfer feature provides a straightforward way to transfer NFTs on Immutable X directly from your Unity application. It handles both single NFT transfers and batch operations, giving developers flexibility when building NFT-enabled games and applications. The implementation abstracts away the complexity of blockchain transactions, allowing you to focus on creating engaging user experiences. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md.meta deleted file mode 100644 index a48a1a0e..00000000 --- a/sample/Assets/Scripts/Passport/ImxNftTransfer/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1f8494e14a9024243953bddd4c806384 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxRegister/metadata.json b/sample/Assets/Scripts/Passport/ImxRegister/metadata.json deleted file mode 100644 index 7c078e24..00000000 --- a/sample/Assets/Scripts/Passport/ImxRegister/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "IMX Register", - "description": "Register users with Immutable X to enable interaction with the IMX blockchain", - "keywords": ["Immutable", "SDK", "Passport", "IMX", "Register", "Blockchain", "Layer2"], - "tech_stack": ["Unity", "C#", "Immutable Passport"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxRegister/metadata.json.meta b/sample/Assets/Scripts/Passport/ImxRegister/metadata.json.meta deleted file mode 100644 index 71965af8..00000000 --- a/sample/Assets/Scripts/Passport/ImxRegister/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: f17fc50f6837b483c9fa1f78b9835a5b -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md b/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md deleted file mode 100644 index 450fa908..00000000 --- a/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md +++ /dev/null @@ -1,69 +0,0 @@ - - -Register users with Immutable X to enable them to interact with the IMX blockchain. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/imxregister) - -
- -## Feature Overview - -The IMX Register feature enables users to register with Immutable X's Layer 2 solution, which is required before they can perform transactions on the IMX blockchain. - -## SDK Integration Details - -The Immutable Passport SDK provides a simple method to register users with Immutable X. This registration is required before users can perform transactions such as transferring NFTs or tokens on the IMX blockchain. - -```csharp title="IMX Register" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/imxregister/ImxRegisterScript.cs" -public async void RegisterOffchain() -{ - ShowOutput("Registering off-chain..."); - try - { - RegisterUserResponse response = await Passport.RegisterOffchain(); - if (response != null) - { - ShowOutput($"Successfully registered"); - } - else - { - ShowOutput("Registration failed"); - } - } - catch (PassportException e) - { - ShowOutput($"Unable to register off-chain: {e.Message} ({e.Type})"); - } - catch (Exception e) - { - ShowOutput($"Unable to register off-chain {e.Message}"); - } -} -``` - -The `RegisterOffchain()` method handles the registration process with Immutable X. Upon successful registration, users can interact with the IMX blockchain. The method returns a `RegisterUserResponse` object which confirms successful registration. - -## Running the Feature Example - -### Prerequisites -- Set up your development environment with [Immutable Hub](https://hub.immutable.com/) -- Unity Editor (2022.2 or newer recommended) -- The Immutable Passport SDK installed in your Unity project - -### Step-by-step Instructions -1. Open your Unity project with the Immutable Passport SDK properly initialized -2. Navigate to the IMX Register sample scene in the project -3. Ensure you've logged in to Passport first using the login feature -4. Connect to Immutable X via the IMX Connect feature -5. Click the "Register Offchain" button to initiate the registration -6. View the output message confirming successful registration - -## Summary - -The IMX Register feature allows users to register with Immutable X's Layer 2 solution, which is a necessary step before they can perform any transactions on the IMX blockchain. This simple implementation enables quick and easy registration for your users, enhancing their experience with blockchain functionality in your game. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md.meta b/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md.meta deleted file mode 100644 index 42529eca..00000000 --- a/sample/Assets/Scripts/Passport/ImxRegister/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 190c0c040bee2443d9b5c6b334555957 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Login/metadata.json b/sample/Assets/Scripts/Passport/Login/metadata.json deleted file mode 100644 index 6d9fdb6d..00000000 --- a/sample/Assets/Scripts/Passport/Login/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Passport Authentication", - "description": "Demonstrates how to implement user authentication with Immutable Passport using PKCE and Device Code Auth methods", - "keywords": ["Immutable", "SDK", "Login", "Authentication", "PKCE", "Device Code Auth", "Passport"], - "tech_stack": ["Unity", "C#", "Passport SDK"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Login/metadata.json.meta b/sample/Assets/Scripts/Passport/Login/metadata.json.meta deleted file mode 100644 index c37848f8..00000000 --- a/sample/Assets/Scripts/Passport/Login/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 79e835cb3144a48a39b2cfab74807f4f -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md b/sample/Assets/Scripts/Passport/Login/tutorial.md deleted file mode 100644 index e8cdb7d9..00000000 --- a/sample/Assets/Scripts/Passport/Login/tutorial.md +++ /dev/null @@ -1,79 +0,0 @@ - - -Passport Login enables users to authenticate with the Immutable Passport service. This feature demonstrates how to implement user authentication in your Unity game using two different authentication methods: PKCE (Proof Key for Code Exchange) and Device Code Auth - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Login) - -
- -## Feature Overview -This example demonstrates how to implement user authentication using the Immutable Passport SDK. It covers two authentication methods: -1. **PKCE (Proof Key for Code Exchange)** - A more secure OAuth flow for native and mobile applications -2. **Device Code Auth** - An authentication flow designed for devices with limited input capabilities - -## SDK Integration Details - -### PKCE Login -PKCE login is recommended for platforms with a web browser, including mobile devices and desktop applications. It provides a secure authentication flow without exposing sensitive data. - -```csharp title="PKCE Login" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/Login/LoginScript.cs" -// First, initialize Passport with the appropriate redirect URIs for PKCE -SampleAppManager.UsePKCE = true; -InitialisePassport(redirectUri: "immutablerunner://callback", logoutRedirectUri: "immutablerunner://logout"); - -// Then, to perform the login: -await Passport.LoginPKCE(); -``` - -The PKCE login flow works as follows: -1. The SDK generates a code verifier and code challenge -2. The user is redirected to the Immutable Passport login page in a browser -3. After successful authentication, the browser redirects back to your application with an authorization code -4. The SDK exchanges this code for access and refresh tokens using the code verifier -5. The user is now authenticated and can interact with Immutable services - -### Device Code Auth Login -Device Code Auth is useful for devices with limited input capabilities or where opening a browser is not optimal. The user authenticates on a separate device by visiting a URL and entering a code. - -```csharp title="Device Code Auth Login" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/Login/LoginScript.cs" -// First, initialize Passport for Device Code Auth -SampleAppManager.UsePKCE = false; -InitialisePassport(logoutRedirectUri: "https://www.immutable.com"); - -// Then, to perform the login with an optional timeout: -var timeoutMs = GetDeviceCodeTimeoutMs(); // Optional timeout in milliseconds -await Passport.Login(timeoutMs: timeoutMs); -``` - -The Device Code Auth flow works as follows: -1. The SDK requests a device code from the authorization server -2. A URL and user code are presented to the user -3. The user must visit the URL on another device and enter the code -4. The SDK polls the server until the user completes authentication -5. Upon successful authentication, the user is logged in -6. An optional timeout can be specified to limit how long the SDK will wait for authentication - -## Running the Feature Example - -### Prerequisites -- Set up your development environment by following the instructions on [Immutable Hub](https://hub.immutable.com) -- Ensure you have the Immutable Passport SDK installed in your Unity project - -### Steps to Run the Login Feature -1. Open the sample project in Unity Editor -2. Navigate to the SelectAuthMethod scene -3. Enter Play mode -4. Choose either "Use PKCE" or "Use Device Code Auth" based on your preferred authentication method -5. After initialization completes, you'll be taken to the login screen -6. Click "Login" to start the authentication process - - For PKCE: A browser window will open where you can enter your credentials - - For Device Code Auth: A URL and code will be displayed; visit the URL on another device and enter the code - -## Summary -The Login feature demonstrates how to implement user authentication in your Unity game using the Immutable Passport SDK. It provides two authentication methods: PKCE for browser-capable devices and Device Code Auth for devices with limited input capabilities. By authenticating users, you enable them to access Immutable's blockchain services securely. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Login/tutorial.md.meta b/sample/Assets/Scripts/Passport/Login/tutorial.md.meta deleted file mode 100644 index e911ec94..00000000 --- a/sample/Assets/Scripts/Passport/Login/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 6326f3aa908a842608e7205e8ae49ef2 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Logout/metadata.json b/sample/Assets/Scripts/Passport/Logout/metadata.json deleted file mode 100644 index e1a70df4..00000000 --- a/sample/Assets/Scripts/Passport/Logout/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Passport Logout", - "description": "Demonstrates how to implement user logout functionality in the Immutable Passport SDK", - "keywords": ["Immutable", "SDK", "Passport", "Logout", "Authentication"], - "tech_stack": ["Unity", "C#", "Immutable SDK"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Logout/metadata.json.meta b/sample/Assets/Scripts/Passport/Logout/metadata.json.meta deleted file mode 100644 index 780766d2..00000000 --- a/sample/Assets/Scripts/Passport/Logout/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e3940bc6fd9f845e3bff289738a8c498 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Logout/tutorial.md b/sample/Assets/Scripts/Passport/Logout/tutorial.md deleted file mode 100644 index e676039a..00000000 --- a/sample/Assets/Scripts/Passport/Logout/tutorial.md +++ /dev/null @@ -1,80 +0,0 @@ - - -The Passport SDK provides a simple way to log out users from their authenticated session. This feature demonstrates how to properly implement the logout functionality in your Unity application. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/logout) - -
- -## Feature Overview - -This atomic example demonstrates how to implement the logout functionality in the Immutable Passport SDK, allowing users to securely end their authenticated session. - -## SDK Integration Details - -The logout feature provides a clean way to end a user's authenticated session. It handles both standard logout and PKCE (Proof Key for Code Exchange) authentication methods. - -```csharp title="Logout Implementation" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/logout/LogoutScript.cs" -private async UniTaskVoid LogoutAsync() -{ - if (Passport.Instance == null) - { - Debug.LogError("Passport instance is null"); - return; - } - try - { - if (SampleAppManager.UsePKCE) - { - await Passport.Instance.LogoutPKCE(); - } - else - { - await Passport.Instance.Logout(); - } - SampleAppManager.IsConnectedToImx = false; - SampleAppManager.IsConnectedToZkEvm = false; - AuthenticatedSceneManager.NavigateToUnauthenticatedScene(); - } - catch (System.Exception ex) - { - Debug.LogError($"Failed to logout: {ex.Message}"); - } -} -``` - -The implementation works as follows: - -1. First, it checks if the Passport instance is available -2. Based on the authentication method used (standard or PKCE), it calls the appropriate logout method: - - `Passport.Instance.Logout()` for standard authentication - - `Passport.Instance.LogoutPKCE()` for PKCE authentication -3. After successful logout, it updates the application state to reflect the disconnected status -4. Finally, it navigates the user back to the unauthenticated scene -5. Error handling is implemented to catch and log any issues that occur during the logout process - -## Running the Feature Example - -### Prerequisites - -- Unity Editor 2022.3 or later -- Immutable Unity SDK installed -- Properly configured Passport environment (see [Immutable Hub](https://hub.immutable.com/) for setup instructions) - -### Steps - -1. Open the sample project in Unity Editor -2. Login using your Immutable Passport in the Unauthenticated Scene. -3. In the "AuthenticatedScene" scene, enter Play mode in the Unity Editor -5. Click the "Logout" button -6. Observe that the user is successfully logged out and redirected to the unauthenticated scene - -## Summary - -The logout feature provides a straightforward way to end a user's authenticated session in your application. By supporting both standard and PKCE authentication methods, it ensures compatibility with different authentication flows. Properly handling the logout process is crucial for maintaining security and providing a seamless user experience in your application. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Logout/tutorial.md.meta b/sample/Assets/Scripts/Passport/Logout/tutorial.md.meta deleted file mode 100644 index a6703ef9..00000000 --- a/sample/Assets/Scripts/Passport/Logout/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 26245d6155dd44b6799b47bf717f2d80 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json deleted file mode 100644 index 19e7885e..00000000 --- a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Set Call Timeout", - "description": "Configure the timeout duration for API calls made through the Passport SDK", - "keywords": ["Immutable", "SDK", "Passport", "Timeout", "Network", "Configuration"], - "tech_stack": ["Unity", "C#"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json.meta b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json.meta deleted file mode 100644 index 5627a2d5..00000000 --- a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: d1c60aa7d8cd34225a4afd2271b5cd7b -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md deleted file mode 100644 index 737693f4..00000000 --- a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md +++ /dev/null @@ -1,66 +0,0 @@ - - -The Set Call Timeout feature allows developers to configure the timeout duration for calls made through the Passport SDK's browser communications manager. This provides greater control over network operations and improves user experience by allowing customized timeout handling. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Other/SetCallTimeout) - -
- -## Feature Overview - -This feature demonstrates how to use the `SetCallTimeout` method from the Passport SDK to customize the timeout period for API calls. The timeout is specified in milliseconds and applies to all subsequent calls that use the browser communications manager. - -## SDK Integration Details - -The SetCallTimeout feature is implemented with a simple UI that allows users to input a custom timeout value in milliseconds. When the user enters a value and confirms the action, the timeout is set using the Passport SDK. - -```csharp title="SetCallTimeoutScript" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/Other/SetCallTimeout/SetCallTimeoutScript.cs" -public void SetTimeout() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - if (!int.TryParse(TimeoutInput.text, out int timeout)) - { - ShowOutput("Invalid timeout value"); - return; - } - Passport.Instance.SetCallTimeout(timeout); - ShowOutput($"Set call timeout to: {timeout}ms"); -} -``` - -The code works as follows: -1. It validates that the Passport SDK is properly initialized -2. It parses the user input to get the timeout value in milliseconds -3. It calls `Passport.Instance.SetCallTimeout(timeout)` to set the timeout -4. It displays a confirmation message to the user - -This timeout value affects how long the SDK will wait for responses from the Passport service before timing out. Setting an appropriate timeout can improve user experience by ensuring that operations don't hang indefinitely when network issues occur. - -## Running the Feature Example - -### Prerequisites -- Unity Editor (2021.3 LTS or later recommended) -- Immutable SDK installed and configured -- Environment variables set up in [Immutable Hub](https://hub.immutable.com) - -### Steps to Run the Example -1. Open the Unity project containing the Immutable SDK -2. Ensure you're logged in to Passport (use the Login feature first) -3. Navigate to the "SetCallTimeout" scene in the Passport/Other directory -4. Enter a timeout value in milliseconds in the input field -5. Click the "Set Timeout" button to apply the setting -6. The confirmation message will display the newly set timeout value - -## Summary - -The SetCallTimeout feature provides a simple way to control how long API calls wait for a response before timing out. By setting an appropriate timeout, developers can enhance their application's resilience to network issues and provide better feedback to users when operations take longer than expected. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md.meta b/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md.meta deleted file mode 100644 index dbcbc34a..00000000 --- a/sample/Assets/Scripts/Passport/Other/SetCallTimeout/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 5be11a350b38f425f88f3fb88911eef7 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json b/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json deleted file mode 100644 index af164e46..00000000 --- a/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Passport Initialisation", - "description": "Initialize the Immutable Passport SDK with the appropriate configuration settings for both Device Code Auth and PKCE authentication methods", - "keywords": ["Immutable", "SDK", "Passport", "Initialisation", "Authentication", "PKCE", "Device Code Auth"], - "tech_stack": ["Unity", "C#", "Immutable SDK"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json.meta b/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json.meta deleted file mode 100644 index 81791629..00000000 --- a/sample/Assets/Scripts/Passport/PassportInitialisation/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 68535d953d9d5454db46456ed83aa959 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md b/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md deleted file mode 100644 index 84656f2a..00000000 --- a/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md +++ /dev/null @@ -1,130 +0,0 @@ - - -Learn how to properly initialize the Immutable Passport SDK in your Unity game. This foundational step is required before utilizing any other Passport features. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/PassportInitialisation) - -
- -## Feature Overview - -This example demonstrates how to initialize the Immutable Passport SDK with the appropriate configuration settings for both Device Code Auth and PKCE (Proof Key for Code Exchange) authentication methods. - -## SDK Integration Details - -### Initializing Passport with Device Code Auth - -Device Code Auth is suitable for most desktop platforms, especially Windows. This method opens the player's default browser for authentication. - -```csharp title="PassportInitialisationScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs" -public void UseDeviceCodeAuth() -{ - SampleAppManager.UsePKCE = false; - InitialisePassport(logoutRedirectUri: "https://www.immutable.com"); -} - -private async void InitialisePassport(string? redirectUri = null, string? logoutRedirectUri = null) -{ - try { - // Set the log level for the SDK - Passport.LogLevel = LogLevel.Info; - - // Don't redact token values from logs - Passport.RedactTokensInLogs = false; - - // Initialise Passport - string environment = Immutable.Passport.Model.Environment.SANDBOX; - string clientId = "mp6rxfMDwwZDogcdgNrAaHnG0qMlXuMK"; - Passport passport = await Passport.Init(clientId, environment, redirectUri, logoutRedirectUri); - SampleAppManager.PassportInstance = passport; - - // Navigate to the unauthenticated scene after initialising Passport - SceneManager.LoadScene("UnauthenticatedScene"); - } - catch (Exception ex) { - Debug.LogException(ex, this); - ShowOutput($"Initialise Passport error: {ex.Message}"); - } -} -``` - -### Initializing Passport with PKCE Auth - -PKCE (Proof Key for Code Exchange) is recommended for mobile platforms (Android, iOS) and macOS. It provides a more seamless experience with in-app browsers or pop-up windows. - -```csharp title="PassportInitialisationScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/PassportInitialisation/PassportInitialisationScript.cs" -public void UsePKCE() -{ - SampleAppManager.UsePKCE = true; -#if UNITY_WEBGL - string url = Application.absoluteURL; - Uri uri = new Uri(url); - string scheme = uri.Scheme; - string hostWithPort = uri.IsDefaultPort ? uri.Host : $"{uri.Host}:{uri.Port}"; - string fullPath = uri.AbsolutePath.EndsWith("/") ? uri.AbsolutePath : uri.AbsolutePath.Substring(0, uri.AbsolutePath.LastIndexOf('/') + 1); - - string redirectUri = $"{scheme}://{hostWithPort}{fullPath}callback.html"; - string logoutRedirectUri = $"{scheme}://{hostWithPort}{fullPath}logout.html"; - - InitialisePassport(redirectUri: redirectUri, logoutRedirectUri: logoutRedirectUri); -#else - InitialisePassport(redirectUri: "immutablerunner://callback", logoutRedirectUri: "immutablerunner://logout"); -#endif -} -``` - -### How It Works - -1. **Configure Authentication Method**: - - The sample allows selecting between Device Code Auth and PKCE - - WebGL builds automatically default to PKCE - -2. **Setting Up Passport**: - - Set log level for appropriate debugging feedback - - Configure token redaction behavior for security - - Specify the environment (SANDBOX or PRODUCTION) - - Provide your client ID obtained from Immutable Hub - - Pass the appropriate redirect URIs based on authentication method - -3. **Handling Platform-Specific Requirements**: - - WebGL builds need special handling to dynamically determine callback URIs - - Other platforms use custom URI schemes (e.g., "immutablerunner://callback") - -4. **Managing Errors**: - - Initialization errors are properly caught and logged - -## Running the Feature Example - -### Prerequisites - -- Unity 2021.3 or newer -- Basic understanding of Unity concepts -- Immutable Hub account (set up at [Immutable Hub](https://hub.immutable.com/)) - -### Steps - -1. **Import the SDK**: - - Install the Immutable Unity SDK via the Unity Package Manager - - Add the package from https://github.com/immutable/unity-immutable-sdk.git?path=/src/Packages/Passport - -2. **Configure Your Client**: - - Register your game as an OAuth 2.0 Native client in Immutable Hub - - Take note of your client ID - - Configure appropriate redirect URIs in your Hub settings - -3. **Run the Example**: - - Open the "SelectAuthScene" scene in Unity Editor - - Enter Play mode - - Click either the "Use Device Code Auth" or "Use PKCE" button to initialize Passport - - For Device Code Auth, your browser will open for authentication - - For PKCE on platforms that support it, a pop-up or in-app browser will appear - -## Summary - -The Passport Initialisation feature demonstrates how to properly set up and configure the Immutable Passport SDK in your Unity application. This is a critical first step before using any other Passport features like login, wallet operations, or blockchain interactions. The sample shows how to handle both authentication methods and platform-specific requirements, ensuring your game can work across desktop, mobile, and web platforms. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md.meta b/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md.meta deleted file mode 100644 index e89f7dbe..00000000 --- a/sample/Assets/Scripts/Passport/PassportInitialisation/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9c42b115adf2340a7a93c5883f458637 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Reconnect/metadata.json b/sample/Assets/Scripts/Passport/Reconnect/metadata.json deleted file mode 100644 index 0fcf1d19..00000000 --- a/sample/Assets/Scripts/Passport/Reconnect/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Passport Reconnect", - "description": "Demonstrates how to reconnect users to Passport using previously saved credentials without requiring re-authentication", - "keywords": ["Immutable", "SDK", "Passport", "Reconnect", "Authentication"], - "tech_stack": ["Unity", "C#", "Immutable SDK"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Reconnect/metadata.json.meta b/sample/Assets/Scripts/Passport/Reconnect/metadata.json.meta deleted file mode 100644 index 5a6d298d..00000000 --- a/sample/Assets/Scripts/Passport/Reconnect/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: bb3f8dd4de9aa4db6b7a2afb3f77c082 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Reconnect/tutorial.md b/sample/Assets/Scripts/Passport/Reconnect/tutorial.md deleted file mode 100644 index 770287f4..00000000 --- a/sample/Assets/Scripts/Passport/Reconnect/tutorial.md +++ /dev/null @@ -1,88 +0,0 @@ - - -Easily reconnect to Passport using saved credentials for a seamless user experience without requiring users to log in again. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Reconnect) - -
- -## Feature Overview -The Reconnect feature allows you to reconnect a user to Passport by utilizing previously saved credentials, eliminating the need for users to authenticate again when they return to your application. This enhances user experience by providing a seamless, frictionless re-entry into your application. - -## SDK Integration Details -The Passport SDK provides a straightforward way to reconnect users with their saved credentials through the `ConnectImx` method with the `useCachedSession` parameter set to `true`. - -```csharp title="Reconnect" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/Reconnect/ReconnectScript.cs" -public void Reconnect() -{ - ReconnectAsync(); -} - -private async UniTaskVoid ReconnectAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport Instance is null"); - return; - } - ShowOutput("Reconnecting to Passport using saved credentials..."); - try - { - bool connected = await Passport.Instance.ConnectImx(useCachedSession: true); - if (connected) - { - // Set IMX and zkEVM state and update UI as if user clicked Connect to IMX/EVM - SampleAppManager.IsConnectedToImx = true; - SampleAppManager.IsConnectedToZkEvm = true; - SampleAppManager.PassportInstance = Passport.Instance; - var sceneManager = GameObject.FindObjectOfType(); - if (sceneManager != null) - { - sceneManager.UpdateImxButtonStates(); - sceneManager.UpdateZkEvmButtonStates(); - } - NavigateToAuthenticatedScene(); - } - else - { - ShowOutput("Could not reconnect using saved credentials"); - } - } - catch (System.Exception ex) - { - ShowOutput($"Failed to reconnect: {ex.Message}"); - } -} -``` - -The reconnect process works by: -1. Calling `ConnectImx` with `useCachedSession` set to `true`, which attempts to use saved credentials -2. If successful, updating the application state to reflect the authenticated user -3. Navigating to the authenticated scene -4. If unsuccessful, showing an appropriate error message - -Behind the scenes, the SDK checks for saved credentials and automatically refreshes the authentication tokens if necessary, without requiring any user interaction. - -## Running the Feature Example -### Prerequisites -- Unity Editor 2021.3 or later -- Immutable SDK installed in your project -- A registered application in [Immutable Hub](https://hub.immutable.com) -- Configured environment variables (Client ID, etc.) - -### Steps to Run -1. Open the sample project in Unity Editor -2. Navigate to the Passport scene -3. Ensure you have previously logged in at least once to create saved credentials -4. Click the "Reconnect" button in the Passport demo UI -5. The app will attempt to reconnect using saved credentials -6. If successful, you'll be redirected to the authenticated scene - -## Summary -The Reconnect feature provides a seamless way to improve user experience by allowing returning users to bypass the login process. By utilizing saved credentials, your application can provide a frictionless authentication experience that reduces friction and encourages user retention. This approach is particularly valuable for games and applications where maintaining engagement is critical. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Reconnect/tutorial.md.meta b/sample/Assets/Scripts/Passport/Reconnect/tutorial.md.meta deleted file mode 100644 index c0e446ad..00000000 --- a/sample/Assets/Scripts/Passport/Reconnect/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1a421fa9f6ff84c458b9b70cd0b18172 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Relogin/metadata.json b/sample/Assets/Scripts/Passport/Relogin/metadata.json deleted file mode 100644 index d0a7fbee..00000000 --- a/sample/Assets/Scripts/Passport/Relogin/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Relogin with Cached Credentials", - "description": "Demonstrates how to use cached credentials to seamlessly re-login users to Passport without requiring re-authentication", - "keywords": ["Immutable", "SDK", "Passport", "Relogin", "Authentication", "Cached Credentials"], - "tech_stack": ["Unity", "C#", "UniTask"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Relogin/metadata.json.meta b/sample/Assets/Scripts/Passport/Relogin/metadata.json.meta deleted file mode 100644 index e3721d72..00000000 --- a/sample/Assets/Scripts/Passport/Relogin/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 28beba9a714c44f85ae21fc35205efbc -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/Relogin/tutorial.md b/sample/Assets/Scripts/Passport/Relogin/tutorial.md deleted file mode 100644 index 9b51e148..00000000 --- a/sample/Assets/Scripts/Passport/Relogin/tutorial.md +++ /dev/null @@ -1,73 +0,0 @@ - - -Use saved credentials to re-login to Passport, allowing users to seamlessly resume their session without requiring re-authentication. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Relogin) - -
- -## Feature Overview - -The Relogin feature demonstrates how to use existing cached credentials to log back into Passport without requiring users to authenticate again. This is particularly useful for improving user experience after app restarts or temporary disconnections. - -## SDK Integration Details - -The Relogin functionality leverages the Passport SDK's ability to use cached sessions. When implemented, it allows the application to attempt logging in using previously stored credentials. - -```csharp title="ReloginScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/Relogin/ReloginScript.cs" -private async UniTaskVoid ReloginAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport Instance is null"); - return; - } - ShowOutput("Re-logging into Passport using saved credentials..."); - try - { - bool loggedIn = await Passport.Instance.Login(useCachedSession: true); - if (loggedIn) - { - NavigateToAuthenticatedScene(); - } - else - { - ShowOutput("Could not re-login using saved credentials"); - } - } - catch (System.Exception ex) - { - ShowOutput($"Failed to re-login: {ex.Message}"); - } -} -``` - -The key part of this implementation is passing `useCachedSession: true` to the `Passport.Instance.Login()` method. This parameter instructs the SDK to attempt logging in using previously saved credentials instead of triggering a new authentication flow. - -When successful, the user is automatically logged in and redirected to the authenticated experience. If the cached credentials are invalid or expired, the login attempt will fail, and the application can then prompt for manual login. - -## Running the Feature Example - -### Prerequisites -- Unity Editor 2022.3 or later -- Immutable Unity SDK installed -- Environment set up using [Immutable Hub](https://hub.immutable.com) - -### Steps -1. Open the sample project in Unity Editor -2. Navigate to the Scenes folder and open the Unauthenticated scene -3. In the Hierarchy panel, locate and select the Relogin button -4. Play the scene in the Editor -5. First login normally to create cached credentials -6. Stop the playback and start it again -7. Click the "Relogin" button to test the re-login functionality - -## Summary - -The Relogin feature provides a seamless way to maintain user sessions across app restarts or reconnections by leveraging cached credentials. By using the `useCachedSession: true` parameter with the Login method, developers can create a frictionless authentication experience for returning users. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/Relogin/tutorial.md.meta b/sample/Assets/Scripts/Passport/Relogin/tutorial.md.meta deleted file mode 100644 index ccdf807d..00000000 --- a/sample/Assets/Scripts/Passport/Relogin/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: d5e8853f6b99e462abaf4a3711972afc -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json deleted file mode 100644 index 09f443f4..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Connect to zkEVM", - "description": "Connect your Unity game to the Immutable zkEVM network using Passport SDK", - "keywords": ["Immutable", "SDK", "Passport", "zkEVM", "Blockchain", "Web3", "Connect"], - "tech_stack": ["Unity", "C#", "Passport SDK", "zkEVM"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json.meta deleted file mode 100644 index da232404..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: c73921d23c00d4e15aa9962eebb099b9 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md deleted file mode 100644 index fa5c8dc6..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md +++ /dev/null @@ -1,82 +0,0 @@ - - -Connect to Immutable zkEVM to enable blockchain transactions and interactions in your Unity game. This feature allows players to connect their Passport wallet to the zkEVM network, enabling a wide range of blockchain operations including sending transactions, checking balances, and signing data. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect) - -
- -## Feature Overview - -This example demonstrates how to connect to the Immutable zkEVM network using the Passport SDK. The connection to zkEVM is a prerequisite for performing any other zkEVM operations like sending transactions or checking balances. - -## SDK Integration Details - -The ZkEvmConnect feature establishes a connection between your game and the Immutable zkEVM network through the user's Passport wallet. This connection enables subsequent blockchain operations like sending transactions, signing data, and checking balances. - -```csharp title="ZkEvmConnectScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/ZkEvmConnectScript.cs" -private async UniTaskVoid ConnectZkEvmAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport not initialized."); - return; - } - - ShowOutput("Connecting to zkEVM..."); - try - { - await Passport.Instance.ConnectEvm(); - - // Update connection state and refresh UI - SampleAppManager.IsConnectedToZkEvm = true; - var sceneManager = FindObjectOfType(); - if (sceneManager != null) - { - sceneManager.UpdateZkEvmButtonStates(); - } - - ShowOutput("Connected to EVM"); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to connect to zkEVM: {ex.Message}"); - } -} -``` - -The implementation works as follows: - -1. First, it checks if the Passport instance is initialized, which is a prerequisite for connecting to zkEVM. -2. Then it calls `Passport.Instance.ConnectEvm()`, which initiates the connection to the Immutable zkEVM network. -3. After successful connection, it updates the application state to reflect the connected status. -4. Finally, it updates the UI to enable buttons for other zkEVM operations that require an active connection. - -## Running the Feature Example - -### Prerequisites - -- Unity 2021.3 LTS or newer -- Immutable SDK package imported into your project -- Passport configured with appropriate credentials from [Immutable Hub](https://hub.immutable.com) -- User must be logged in to Passport before connecting to zkEVM - -### Steps to Run - -1. Open the sample scene in Unity Editor -2. Enter Play mode -3. Log in to Passport if not already logged in -4. Navigate to the zkEVM section in the sample app -5. Click the "Connect to zkEVM" button -6. If successful, you'll see "Connected to EVM" in the output text area -7. Other zkEVM-related buttons will become active, indicating you can now perform those operations - -## Summary - -The ZkEvmConnect feature provides a straightforward way to establish a connection to the Immutable zkEVM network, which is required for any blockchain interactions on this network. Once connected, your application can perform various blockchain operations such as sending transactions, checking balances, and signing data. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md.meta deleted file mode 100644 index 45cf93f7..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmConnect/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: fac0c831a9a9142dbae170b1b8205841 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json deleted file mode 100644 index eec2be11..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Get Account Balance from zkEVM", - "description": "Learn how to query Ethereum account balances on the Immutable zkEVM blockchain using the Passport SDK", - "keywords": ["Immutable", "SDK", "zkEVM", "Balance", "Ethereum", "Blockchain", "Web3"], - "tech_stack": ["Unity", "C#", "Immutable Passport SDK", "zkEVM"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json.meta deleted file mode 100644 index 03f31e06..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 72b2111e863a846de99a42fc6aafd4c0 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md deleted file mode 100644 index debcc2c3..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md +++ /dev/null @@ -1,85 +0,0 @@ - - -This feature demonstrates how to retrieve an account's balance from the Immutable zkEVM blockchain using the Passport SDK. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance) - -
- -## Feature Overview - -The ZkEvmGetBalance feature lets developers query the balance of any Ethereum address on the Immutable zkEVM blockchain. This is essential for games and applications that need to display user balances, check if users have sufficient funds for transactions, or monitor balance changes. - -## SDK Integration Details - -The feature utilizes the `ZkEvmGetBalance` method from the Passport SDK to retrieve the account balance in Wei (the smallest unit of Ether). - -```csharp title="ZkEvmGetBalanceScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/ZkEvmGetBalanceScript.cs" -public void GetBalance() -{ - GetBalanceAsync(); -} - -private async UniTaskVoid GetBalanceAsync() -{ - if (SampleAppManager.PassportInstance == null) - { - ShowOutput("Passport instance is null"); - return; - } - ShowOutput("Getting account balance..."); - try - { - string balanceHex = await SampleAppManager.PassportInstance.ZkEvmGetBalance(AddressInput.text); - var balanceDec = BigInteger.Parse(balanceHex.Replace("0x", ""), NumberStyles.HexNumber); - if (balanceDec < 0) - { - balanceDec = BigInteger.Parse("0" + balanceHex.Replace("0x", ""), NumberStyles.HexNumber); - } - ShowOutput($"Balance:\nHex: {balanceHex}\nDec: {balanceDec}"); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to get balance: {ex.Message}"); - } -} -``` - -The implementation works as follows: - -1. The `GetBalance` method is called when the user initiates a balance check. -2. Inside `GetBalanceAsync`, the code first verifies that the Passport instance is available. -3. It then calls `ZkEvmGetBalance` with the address input provided by the user (the account address to check). -4. The balance is returned in hexadecimal format (e.g., "0x1a2b3c4d"). -5. The code converts this hexadecimal value to a decimal representation using `BigInteger.Parse`. -6. If parsing results in a negative number (which can happen with very large hex values), the code prepends a "0" to ensure proper parsing. -7. Both the hexadecimal and decimal representations of the balance are displayed to the user. - -## Running the Feature Example - -### Prerequisites -- Unity Editor (2021.3 LTS or newer) -- An Immutable Passport account (create one at [Immutable Hub](https://hub.immutable.com)) -- The Immutable Unity SDK properly installed and configured - -### Steps to Run the Example - -1. Open the sample project in Unity Editor. -2. Make sure you have properly configured the Passport SDK with your credentials. -3. Build and run the sample app. -4. Log in to your Passport account when prompted. -5. Navigate to the authenticated screen. -6. Connect to zkEVM by clicking the "Connect zkEVM" button. -7. After connecting, click the "Get Balance" button. -8. Enter an Ethereum address in the input field. -9. Submit the request to view the account balance in both hexadecimal and decimal format. - -## Summary - -The ZkEvmGetBalance feature provides a straightforward way to query account balances on the Immutable zkEVM blockchain. By integrating this feature, developers can enable their games and applications to check user balances, which is essential for features like displaying wallet information, verifying sufficient funds before transactions, or implementing conditional logic based on user balances. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md.meta deleted file mode 100644 index 685704b9..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetBalance/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 175970d682bd74260b1767a76129a79c -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json deleted file mode 100644 index 54ec1dd2..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Retrieve zkEVM Transaction Receipt", - "description": "Learn how to retrieve and interpret transaction receipts from the Immutable zkEVM blockchain using the Passport SDK", - "keywords": ["Immutable", "SDK", "Passport", "zkEVM", "Transaction", "Receipt", "Blockchain"], - "tech_stack": ["Unity", "C#", "Immutable Passport"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json.meta deleted file mode 100644 index 80ef76b5..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a6afe94d9e17543ddbf5e3471ebcf0d7 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md deleted file mode 100644 index 40d3a449..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md +++ /dev/null @@ -1,100 +0,0 @@ - - -The Immutable Passport SDK provides functionality to retrieve transaction receipts from the Immutable zkEVM blockchain. This feature allows developers to check the status of a transaction to determine if it has been processed successfully, failed, or is still pending. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt) - -
- -## Feature Overview - -The ZkEvmGetTransactionReceipt feature demonstrates how to use the Immutable Passport SDK to retrieve the receipt of a transaction on the Immutable zkEVM blockchain using a transaction hash. - -## SDK Integration Details - -This feature demonstrates how to retrieve a transaction receipt from the Immutable zkEVM blockchain using the Passport SDK. To implement this functionality, you need to: - -1. Ensure that the user is connected to zkEVM -2. Call the ZkEvmGetTransactionReceipt method with the transaction hash -3. Process the transaction receipt response - -```csharp title="ZkEvmGetTransactionReceiptScript" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/ZkEvmGetTransactionReceiptScript.cs" -private async UniTaskVoid GetZkEvmTransactionReceiptAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - ShowOutput("Getting transaction receipt..."); - try - { - await Passport.Instance.ConnectEvm(); - TransactionReceiptResponse response = await Passport.Instance.ZkEvmGetTransactionReceipt(TransactionHash.text); - string status = $"Status: {GetTransactionStatusString(response.status)}"; - ShowOutput(status); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to retrieve transaction receipt: {ex.Message}"); - } -} - -private string GetTransactionStatusString(string status) -{ - switch (status) - { - case "1": - case "0x1": - return "Success"; - case "0": - case "0x0": - return "Failed"; - case null: - return "Still processing"; - default: - return "Unknown status"; - } -} -``` - -The example above demonstrates the following steps: - -1. First, we call `ConnectEvm()` to ensure the user is connected to the zkEVM network. -2. Then, we call `ZkEvmGetTransactionReceipt(txHash)` with the transaction hash to retrieve the transaction receipt. -3. The response contains a status field that indicates whether the transaction was successful, failed, or is still processing. -4. We interpret the status code using a helper method that converts the raw status code to a human-readable string. - -The `TransactionReceiptResponse` object provides comprehensive information about the transaction, including: -- Transaction status (success, failure, or processing) -- Block information (hash, number) -- Gas usage information -- Transaction details (hash, index, etc.) -- Logs generated by the transaction - -## Running the Feature Example - -### Prerequisites - -- A Unity project with Immutable Passport SDK installed -- An Immutable Hub account and configured environment. [Sign up here](https://hub.immutable.com/) if you don't have one. -- A valid transaction hash from a previously executed transaction on Immutable zkEVM - -### Step-by-step Instructions - -1. Open the Unity Editor with the Immutable SDK sample project -2. Ensure you're logged in to Passport through the sample app -3. Navigate to the ZkEvmGetTransactionReceipt scene -4. Enter a valid transaction hash in the input field -5. Click the "Get Transaction Receipt" button -6. The status of the transaction will be displayed in the output field - -## Summary - -The ZkEvmGetTransactionReceipt feature provides a simple way to check the status of a transaction on the Immutable zkEVM blockchain. It allows developers to determine if a transaction has been successfully processed, failed, or is still pending, which is essential for providing feedback to users in applications that involve blockchain transactions. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md.meta deleted file mode 100644 index df1bcaee..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmGetTransactionReceipt/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 5946e62ec65f44b48aa3f58908041026 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json deleted file mode 100644 index ea65a0c3..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "Request Wallet Accounts", - "description": "Retrieve Ethereum addresses associated with the user's Immutable Passport account", - "keywords": ["Immutable", "SDK", "Passport", "ZkEvm", "Accounts", "Wallet", "Ethereum", "Unity"], - "tech_stack": ["Unity", "C#", "Immutable SDK", "Passport"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json.meta deleted file mode 100644 index a48f9018..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a4a4f2fd3742c4a1d861bcf46930d688 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md deleted file mode 100644 index 8a6e9476..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md +++ /dev/null @@ -1,76 +0,0 @@ - - -Retrieve wallet addresses from the user's Immutable Passport account using the ZkEvmRequestAccounts feature. This feature allows your Unity application to access the Ethereum addresses associated with the logged-in user's Passport account. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts) - -
- -## Feature Overview - -The ZkEvmRequestAccounts feature provides a simple way to request the list of Ethereum addresses associated with the user's Immutable Passport account. This is a crucial step for any application that needs to interact with the user's blockchain wallet or perform blockchain operations on their behalf. - -## SDK Integration Details - -The ZkEvmRequestAccounts feature allows you to retrieve the Ethereum addresses from the user's Passport account using a simple asynchronous call. - -```csharp title="ZkEvmRequestAccountsScript" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/ZkEvmRequestAccountsScript.cs" -private async UniTaskVoid RequestAccountsAsync() -{ - if (SampleAppManager.PassportInstance == null) - { - ShowOutput("Passport not initialized."); - return; - } - - ShowOutput("Requesting wallet accounts..."); - try - { - List accounts = await SampleAppManager.PassportInstance.ZkEvmRequestAccounts(); - ShowOutput(accounts.Count > 0 ? string.Join(", ", accounts) : "No accounts found."); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to request wallet accounts: {ex.Message}"); - } -} -``` - -The code works by: - -1. Checking if the Passport instance is properly initialized -2. Making an asynchronous call to `ZkEvmRequestAccounts()` method from the Passport SDK -3. Receiving a list of Ethereum addresses associated with the user's account -4. Displaying the results or handling any errors that occur during the process - -This feature should be used after a user has successfully logged in to Passport and before performing any blockchain operations that require their wallet address. - -## Running the Feature Example - -### Prerequisites - -Before running the feature example, ensure you have: - -1. Set up your Immutable Passport application on [Immutable Hub](https://hub.immutable.com) -2. Configured your Unity project with the Immutable Passport SDK -3. Successfully initialized Passport in your application -4. User must be logged in to Passport - -### Steps to Run - -1. Open the sample Unity project in the Unity Editor -2. Navigate to the Scenes folder, open the "AuthenticatedScene" scene, and click on the "Connect to EVM" button. -3. Then, click on the "Request accounts" button containing the ZkEvmRequestAccounts example -4. Log in to your Passport account if not already logged in -5. Click the "Request Accounts" button in the UI -6. The addresses associated with the user's Passport account will be displayed in the output area - -## Summary - -The ZkEvmRequestAccounts feature provides a straightforward way to retrieve Ethereum addresses associated with the user's Passport account. This feature is essential for any dApp that needs to interact with the blockchain on behalf of the user, as it provides the necessary wallet addresses for transaction signing and other operations. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md.meta deleted file mode 100644 index ad84e3c9..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmRequestAccounts/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 2298e10deedec4487b116f4db8e05488 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json deleted file mode 100644 index 843625ba..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "ZkEvm Send Transaction", - "description": "Send transactions to the Immutable zkEVM network from your Unity game, allowing users to interact with smart contracts and transfer assets.", - "keywords": ["Immutable", "SDK", "Passport", "zkEVM", "Transaction", "Blockchain", "Smart Contract"], - "tech_stack": ["Unity", "C#", "Immutable Passport SDK", "zkEVM"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json.meta deleted file mode 100644 index d6fef291..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: abe05855192e041f69850866b26c3965 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md deleted file mode 100644 index 57eee612..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md +++ /dev/null @@ -1,79 +0,0 @@ - - -Send transactions to the Immutable zkEVM network from your Unity game using Passport SDK. This feature allows your users to sign and submit transactions to execute smart contract methods or transfer assets. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction) - -
- -## Feature Overview -This Passport feature demonstrates how to send transactions to the Immutable zkEVM network using the authenticated Passport user's account. It provides two transaction modes: -- Basic transaction submission (`ZkEvmSendTransaction`) -- Transaction with confirmation (`ZkEvmSendTransactionWithConfirmation`) - -## SDK Integration Details - -### Sending a Transaction - -The Passport SDK provides a simple way to send transactions to the zkEVM network: - -```csharp title="ZkEvmSendTransactionScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/ZkEvmSendTransactionScript.cs" -// Create transaction request -TransactionRequest request = new TransactionRequest -{ - to = ToInputField.text, // Destination address - value = ValueInputField.text, // Amount of IMX to send (in wei) - data = DataInputField.text // Transaction data (for contract interactions) -}; - -// Send transaction without confirmation -string transactionHash = await SampleAppManager.PassportInstance.ZkEvmSendTransaction(request); -``` - -This method returns a transaction hash immediately after submission, allowing your application to continue while the transaction is being processed by the network. - -### Sending a Transaction with Confirmation - -For use cases where you need to know the transaction result before proceeding: - -```csharp title="ZkEvmSendTransactionScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/ZkEvmSendTransactionScript.cs" -// Send transaction with confirmation and display transaction status upon completion -TransactionReceiptResponse response = await SampleAppManager.PassportInstance.ZkEvmSendTransactionWithConfirmation(request); -``` - -This method waits for the transaction to be included in a block and returns the transaction receipt, which includes the transaction status (success or failure). - -### Checking Transaction Status - -You can also manually poll for transaction status using the transaction hash: - -```csharp title="ZkEvmSendTransactionScript.cs" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/ZkEvmSendTransactionScript.cs" -// Poll for the receipt and display transaction status -TransactionReceiptResponse response = await SampleAppManager.PassportInstance.ZkEvmGetTransactionReceipt(transactionHash); -``` - -## Running the Feature Example - -### Prerequisites -- Set up your application with the Immutable SDK using [Immutable Hub](https://hub.immutable.com) -- Complete the Passport login process - -### Steps to Run in Unity Editor -1. Navigate to the ZkEvmSendTransaction scene in `sample/Assets/Scenes/Passport/ZkEvm/ZkEvmSendTransaction.unity` -2. Run the scene in the Unity Editor -3. Enter the following in the form: - - **To**: The destination address (e.g., another wallet address) - - **Value**: Amount to send in wei (e.g., "1000000000000000" for 0.001 IMX) - - **Data**: Optional data for contract interactions -4. Select whether to wait for confirmation using the checkbox -5. Click "Send Transaction" to execute the transaction -6. View the transaction result displayed in the UI - -## Summary -The ZkEvmSendTransaction feature enables your game to interact with the Immutable zkEVM blockchain by sending transactions from the user's Passport wallet. This allows for implementing various blockchain operations like token transfers, smart contract interactions, and more. The ability to either fire-and-forget transactions or wait for confirmations gives developers flexibility to implement different user experience flows based on their game's requirements. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md.meta deleted file mode 100644 index a14d39e9..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSendTransaction/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: db3db69c418874807afe5ccd8564d047 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json deleted file mode 100644 index 2cac72ef..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": "ZkEVM Sign Typed Data", - "description": "Sign EIP-712 structured data messages using Passport SDK to enable secure and user-friendly off-chain signing for on-chain use", - "keywords": ["Immutable", "SDK", "Passport", "ZkEVM", "EIP-712", "Sign Typed Data", "Web3"], - "tech_stack": ["Unity", "C#", "Passport SDK", "ZkEVM"], - "product": "Passport", - "programming_language": "C#" -} \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json.meta deleted file mode 100644 index c133d51e..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/metadata.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 64fd359c934504a848d8e9f56ea52f33 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md deleted file mode 100644 index aafb3829..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md +++ /dev/null @@ -1,80 +0,0 @@ - - -Sign EIP-712 structured data using the Passport SDK, enabling secure and user-friendly off-chain message signing for on-chain use. - -
- -[View feature on Github](https://github.com/immutable/unity-immutable-sdk/tree/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData) - -
- -## Feature Overview - -The ZkEVM Sign Typed Data feature demonstrates how to sign EIP-712 structured data messages using the Immutable Passport SDK. EIP-712 is a standard for hashing and signing of typed structured data as opposed to just byte strings, making off-chain message signing more secure and user-friendly. - -## SDK Integration Details - -The ZkEvmSignTypedDataV4 method in the Passport SDK allows developers to sign EIP-712 structured messages in JSON string format with the logged-in user's Passport account. - -```csharp title="ZkEvmSignTypedData" manualLink="https://github.com/immutable/unity-immutable-sdk/blob/main/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/ZkEvmSignTypedDataScript.cs" -private async UniTaskVoid SignTypedDataAsync() -{ - if (Passport.Instance == null) - { - ShowOutput("Passport instance is null"); - return; - } - ShowOutput("Signing payload..."); - try - { - await Passport.Instance.ConnectEvm(); - string signature = await Passport.Instance.ZkEvmSignTypedDataV4(Payload.text); - ShowOutput(signature); - } - catch (System.Exception ex) - { - ShowOutput($"Failed to sign typed data: {ex.Message}"); - } -} -``` - -The code above demonstrates the following process: -1. First, it ensures the Passport instance is initialized -2. It connects to the EVM network using `ConnectEvm()` -3. It calls the `ZkEvmSignTypedDataV4()` method, passing in the EIP-712 formatted payload as a JSON string -4. The method returns a signature string that can be used for verification purposes - -The payload follows the EIP-712 standard JSON format, which includes: -- A `types` object defining the structure of your data -- A `domain` object with chain-specific information to prevent cross-chain replay attacks -- A `primaryType` field indicating the main struct being signed -- A `message` object containing the actual data to sign - -## Running the Feature Example - -### Prerequisites -- Unity Editor (2022.3 LTS or newer) -- Immutable Passport SDK installed -- [Immutable Hub](https://hub.immutable.com/) account for environment setup - -### Steps to Run -1. Open the sample project in Unity Editor -2. Navigate to the `/Assets/Scenes/Passport/ZkEvm/ZkEvmSignTypedData.unity` scene -3. Enter your EIP-712 formatted payload in the text field - - Ensure it's in valid JSON format following the EIP-712 standard -4. Click the "Sign Typed Data" button -5. The signature will be displayed in the output field if successful - -## Summary - -The ZkEVM Sign Typed Data feature allows developers to implement secure message signing in their games using the standardized EIP-712 format. This enables various use cases like: -- User authentication -- Proving ownership of assets -- Creating off-chain orders for on-chain execution -- Implementing gasless transactions with meta-transactions - -By using structured, typed data instead of opaque hex strings, users get a clearer understanding of what they're signing, enhancing the security and usability of your blockchain integration. \ No newline at end of file diff --git a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md.meta b/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md.meta deleted file mode 100644 index d29d05cf..00000000 --- a/sample/Assets/Scripts/Passport/ZkEvm/ZkEvmSignTypedData/tutorial.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 0968d6fe5d1a24e39879224eb666978b -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/sample/Assets/Scripts/Passport/_prompts/tutorial-generation-prompt.txt b/sample/Assets/Scripts/Passport/_prompts/tutorial-generation-prompt.txt index bc900579..21a5d22c 100644 --- a/sample/Assets/Scripts/Passport/_prompts/tutorial-generation-prompt.txt +++ b/sample/Assets/Scripts/Passport/_prompts/tutorial-generation-prompt.txt @@ -1,99 +1,156 @@ -# Passport Feature Tutorial Generator +# Passport Feature Group Tutorial Generator ## Task Overview -Analyze the sample/Assets/Scripts/Passport/{FeatureName}/ directory and create documentation files for the atomic Passport feature example. For the specified feature, you will create: -1. A comprehensive tutorial.md file -2. A metadata.json file +Analyze the specified {FEATURE_GROUP} from sample/Assets/Scripts/Passport/features.json and create comprehensive documentation for it. You will create: +1. A comprehensive tutorial.md file covering all features in the specified group +2. A metadata.json file for the feature group + +## Input Required +- FEATURE_GROUP: The exact name of the specific feature group to document, as it appears in features.json + +## Structure of features.json +The features.json file has the following structure: +```json +{ + "features": { + "{FEATURE_GROUP}": { + "feature1": { ... }, + "feature2": { ... }, + ... + }, + "anotherFeatureGroup": { + ... + } + } +} +``` + +You will be analyzing one specific {FEATURE_GROUP} and all features contained within it. + +## Special Case: Single-Feature Groups +IMPORTANT: If the specified {FEATURE_GROUP} contains only one feature, treat it as a standalone feature rather than a feature group. This means: +- Do not refer to it as a "feature group" in the documentation +- Skip the "Feature Group Overview" section that discusses relationships between features +- Focus solely on documenting the single feature in depth +- Adjust headings and terminology accordingly to avoid references to a "group" +- For the "Running the Feature Example" section (note: not "Examples"), provide steps specific to this single feature ## Preparation Before starting: -- Read through all SDK documentation (in the /src/Packages and /src/Packages folders) +- Read through all SDK documentation (in the /src/Packages folders) - Understand the SDK's key features, functionality, and integration patterns - Focus on the Passport SDK the most. That's your area of specialty. +- Familiarize yourself with the specified feature group defined in features.json -## Process for Each Atomic Feature Example -For the specified atomic feature in sample/Assets/Scripts/Passport/{FeatureName}/ that doesn't already have both tutorial.md and metadata.json: +## Process for the Specified Feature Group ### 1. Analysis Phase -- Read all C# code files in the feature directory -- Identify the Passport feature being demonstrated. Reference features.json at the Passport root for the feature name and order. -- Understand the feature's architecture, components, and data flow +- Identify the specified {FEATURE_GROUP} and all member features from features.json +- For each feature in the group, read all C# code files in the feature's directory (sample/Assets/Scripts/Passport/{FeatureName}/) +- Understand how the features in the group relate to each other +- Identify the common patterns, architecture, components, and data flow across the feature group - Note all frameworks, libraries, and dependencies used -- IMPORTANT: Focus only on the logic for this atomic feature, not on unrelated features or SDK initialization. +- IMPORTANT: Focus on the logical connections between features in the group while maintaining focus on each feature's specific implementation details. + +### 2. Create tutorial.md in sample/Assets/Scripts/Passport/_tutorials/{FEATURE_GROUP}/ +Create a tutorial.md file for the feature group with the following structure: -### 2. Create tutorial.md -Create a tutorial.md file in the feature's root with the following structure: +#### Group Introduction +- Brief overview of the feature group's purpose and importance +- Which specific SDK capabilities the group demonstrates +- Link to the sample app GitHub repository. (The Github repository MUST BE linked with this message: "View feature group on Github") -#### Introduction -- Brief overview of the feature's purpose -- Which specific SDK capability it demonstrates -- Link to the feature's GitHub repository. (The Github repository MUST BE linked to this message: "View feature on Github") +Note: For single-feature cases, rename this section to "Feature Introduction" and adjust the link text to "View feature on Github" -IMPORTANT: The TITLE (the text that starts with #) of the feature that comes before the "View feature on Github" link must be wrapped in a