From bc8217894cf24ef85a6f3477dace711ac8b77ab9 Mon Sep 17 00:00:00 2001 From: Alec Ananian <1013230+alecananian@users.noreply.github.com> Date: Wed, 15 May 2024 07:27:17 -0700 Subject: [PATCH 1/2] add connect flag for silent login (#56) --- .../Runtime/Connect/UI/TDKConnectUIManager.cs | 17 ++++++++++++----- .../Runtime/Connect/UI/TDKEmbeddedWalletUI.cs | 8 ++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Assets/Treasure/TDK/Runtime/Connect/UI/TDKConnectUIManager.cs b/Assets/Treasure/TDK/Runtime/Connect/UI/TDKConnectUIManager.cs index 46e1570a..4de76381 100644 --- a/Assets/Treasure/TDK/Runtime/Connect/UI/TDKConnectUIManager.cs +++ b/Assets/Treasure/TDK/Runtime/Connect/UI/TDKConnectUIManager.cs @@ -23,7 +23,7 @@ public class TDKConnectUIManager : MonoBehaviour [Header("Test buttons")] [SerializeField] private Button switchThemeButton; [SerializeField] private Button switchSceneButton; - [SerializeField] private ScreenOrientation currentOriantation; + [SerializeField] private ScreenOrientation currentOriantation; private ModalBase currentModalOpended; @@ -31,13 +31,14 @@ public class TDKConnectUIManager : MonoBehaviour private string _address; private string _email; + private bool _isSilentLogin = false; private bool useSmartWallets = true; private ChainData _currentChainData; private void Awake() { if (Instance == null) - Instance = this; + Instance = this; } private void Start() @@ -63,6 +64,11 @@ private void Start() }); } + public bool IsSilentLogin + { + get { return _isSilentLogin; } + } + #region test code IEnumerator SwitchScene() { @@ -134,9 +140,9 @@ public void ShowAccountModal() currentModalOpended.Hide(); currentModalOpended = logedInHolder; - logedInHolder.Show(); + logedInHolder.Show(); - TDK.Analytics.TrackCustomEvent(AnalyticsConstants.EVT_TREASURECONNECT_UI_ACCOUNT); + TDK.Analytics.TrackCustomEvent(AnalyticsConstants.EVT_TREASURECONNECT_UI_ACCOUNT); } public void LogOut() @@ -157,9 +163,10 @@ private void Activate() #endregion #region Connecting - public async Task ConnectEmail(string email) + public async Task ConnectEmail(string email, bool isSilentLogin = false) { _email = email; + _isSilentLogin = isSilentLogin; var wc = useSmartWallets ? new WalletConnection( provider: WalletProvider.SmartWallet, diff --git a/Assets/Treasure/TDK/Runtime/Connect/UI/TDKEmbeddedWalletUI.cs b/Assets/Treasure/TDK/Runtime/Connect/UI/TDKEmbeddedWalletUI.cs index 79db33aa..2e9f043f 100644 --- a/Assets/Treasure/TDK/Runtime/Connect/UI/TDKEmbeddedWalletUI.cs +++ b/Assets/Treasure/TDK/Runtime/Connect/UI/TDKEmbeddedWalletUI.cs @@ -10,6 +10,8 @@ namespace Treasure { + public class TDKSilentLoginException : Exception { } + public class TDKEmbeddedWalletUI : InAppWalletUI { [Space] @@ -79,6 +81,12 @@ public override async Task LoginWithOTP() } catch (Exception e) { + if (TDKConnectUIManager.Instance.IsSilentLogin) + { + ThirdwebDebug.Log($"Could not recreate user automatically, skipping silent login"); + throw new TDKSilentLoginException(); + } + ThirdwebDebug.Log($"Could not recreate user automatically, proceeding with auth: {e.Message}"); } From ab78d229167a26429cdd5e5a227ae91e83c7d632 Mon Sep 17 00:00:00 2001 From: Alec Ananian <1013230+alecananian@users.noreply.github.com> Date: Wed, 15 May 2024 07:27:51 -0700 Subject: [PATCH 2/2] v0.3.2 --- Assets/Treasure/TDK/Runtime/TDKVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Treasure/TDK/Runtime/TDKVersion.cs b/Assets/Treasure/TDK/Runtime/TDKVersion.cs index 85b95d45..eb0f73c3 100644 --- a/Assets/Treasure/TDK/Runtime/TDKVersion.cs +++ b/Assets/Treasure/TDK/Runtime/TDKVersion.cs @@ -3,6 +3,6 @@ public static class TDKVersion { public static string name = "tdk-unity"; - public static string version = "0.3.1"; + public static string version = "0.3.2"; } }