From a2abd47947a78e67783669e03d87ca2b73469059 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Wed, 15 Jan 2025 16:03:02 +0200 Subject: [PATCH 01/21] Local web wallet redirects --- .../Assets/Scripts/AppInit.cs | 41 +++++++++++ .../Assets/Scripts/AppKitInit.cs | 2 +- .../Reown/AppKit/Views/WebWalletView.meta | 3 + .../Views/WebWalletView/WebWalletView.uss | 14 ++++ .../WebWalletView/WebWalletView.uss.meta | 3 + .../Views/WebWalletView/WebWalletView.uxml | 18 +++++ .../WebWalletView/WebWalletView.uxml.meta | 3 + .../ModalController/ModalController.cs | 3 +- .../Runtime/Controllers/RouterController.cs | 1 + .../Runtime/Presenters/ConnectPresenter.cs | 6 ++ .../Runtime/Presenters/WebAppPresenter.cs | 4 +- .../Runtime/Presenters/WebWalletPresenter.cs | 53 +++++++++++++++ .../Presenters/WebWalletPresenter.cs.meta | 3 + .../Runtime/Views/WebWalletView.meta | 3 + .../Views/WebWalletView/WebWalletView.cs | 68 +++++++++++++++++++ .../Views/WebWalletView/WebWalletView.cs.meta | 3 + .../Runtime/ReownSignUnityInterceptor.cs | 8 +-- src/Reown.Sign.Unity/Runtime/Linker.cs | 4 +- 18 files changed, 231 insertions(+), 9 deletions(-) create mode 100644 src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView.meta create mode 100644 src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uss create mode 100644 src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uss.meta create mode 100644 src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uxml create mode 100644 src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uxml.meta create mode 100644 src/Reown.AppKit.Unity/Runtime/Presenters/WebWalletPresenter.cs create mode 100644 src/Reown.AppKit.Unity/Runtime/Presenters/WebWalletPresenter.cs.meta create mode 100644 src/Reown.AppKit.Unity/Runtime/Views/WebWalletView.meta create mode 100644 src/Reown.AppKit.Unity/Runtime/Views/WebWalletView/WebWalletView.cs create mode 100644 src/Reown.AppKit.Unity/Runtime/Views/WebWalletView/WebWalletView.cs.meta diff --git a/sample/Reown.AppKit.Unity/Assets/Scripts/AppInit.cs b/sample/Reown.AppKit.Unity/Assets/Scripts/AppInit.cs index e549831..0feded0 100644 --- a/sample/Reown.AppKit.Unity/Assets/Scripts/AppInit.cs +++ b/sample/Reown.AppKit.Unity/Assets/Scripts/AppInit.cs @@ -1,4 +1,8 @@ +using System.Linq; +using IngameDebugConsole; using mixpanel; +using Newtonsoft.Json; +using Reown.AppKit.Unity; using Skibitsky.Unity; using UnityEngine; using UnityEngine.SceneManagement; @@ -39,5 +43,42 @@ private void ConfigureMixpanel() Mixpanel.Track(logString, props); }; } + + [ConsoleMethod("accounts", "Lists all connected accounts")] + public static async void Accounts() + { + var accounts = await AppKit.ConnectorController.GetAccountsAsync(); + + if (accounts == null || accounts.Length == 0) + { + Debug.Log("No accounts connected"); + return; + } + + foreach (var account in accounts) + { + Debug.Log(account.AccountId); + } + } + + [ConsoleMethod("sessionProps", "Prints session properties")] + public static void SessionProps() + { + var walletConnect = AppKit.ConnectorController.ActiveConnector as WalletConnectConnector; + var addressProvider = walletConnect.SignClient.AddressProvider; + var sessionProperties = addressProvider.DefaultSession.SessionProperties; + + if (sessionProperties == null) + { + Debug.Log("No session properties found"); + return; + } + + var json = JsonConvert.SerializeObject(sessionProperties, new JsonSerializerSettings + { + Formatting = Formatting.Indented + }); + Debug.Log(json); + } } } \ No newline at end of file diff --git a/sample/Reown.AppKit.Unity/Assets/Scripts/AppKitInit.cs b/sample/Reown.AppKit.Unity/Assets/Scripts/AppKitInit.cs index b1e3e24..d6c33d7 100644 --- a/sample/Reown.AppKit.Unity/Assets/Scripts/AppKitInit.cs +++ b/sample/Reown.AppKit.Unity/Assets/Scripts/AppKitInit.cs @@ -56,7 +56,7 @@ private async void Start() // On mobile show 5 wallets on the Connect view (the first AppKit modal screen) connectViewWalletsCountMobile = 5, // Assign the SIWE configuration created above. Can be null if SIWE is not used. - siweConfig = siweConfig + // siweConfig = siweConfig }; Debug.Log("[AppKit Init] Initializing AppKit..."); diff --git a/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView.meta b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView.meta new file mode 100644 index 0000000..8402f48 --- /dev/null +++ b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 42856f451b544e0eb64c15dcf60730b7 +timeCreated: 1736947636 \ No newline at end of file diff --git a/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uss b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uss new file mode 100644 index 0000000..7ee72d6 --- /dev/null +++ b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uss @@ -0,0 +1,14 @@ +#web-wallet-view__loading-label { + margin-top: 10; + margin-bottom: 10; + -unity-text-align: middle-center; + color: var(--ro-color-fg-100); +} + +#web-wallet-view__buttons { + margin-top: 10; +} + +#web-wallet-view__buttons > Link { + margin-bottom: 20; +} \ No newline at end of file diff --git a/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uss.meta b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uss.meta new file mode 100644 index 0000000..5b1c0f7 --- /dev/null +++ b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uss.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d8a6b9c0bb0437ab6a802d2b175ad7f +timeCreated: 1736947648 \ No newline at end of file diff --git a/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uxml b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uxml new file mode 100644 index 0000000..3f808df --- /dev/null +++ b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Views/WebWalletView/WebWalletView.uxml @@ -0,0 +1,18 @@ + +