diff --git a/sample/Reown.AppKit.Unity/Assets/Scenes/AppKit Init.unity b/sample/Reown.AppKit.Unity/Assets/Scenes/AppKit Init.unity index 8fe8fa7..85d8940 100644 --- a/sample/Reown.AppKit.Unity/Assets/Scenes/AppKit Init.unity +++ b/sample/Reown.AppKit.Unity/Assets/Scenes/AppKit Init.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 9 + serializedVersion: 10 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -42,8 +42,8 @@ RenderSettings: --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GIWorkflowMode: 1 + serializedVersion: 13 + m_BakeOnSceneLoad: 0 m_GISettings: serializedVersion: 2 m_BounceScale: 1 @@ -66,9 +66,6 @@ LightmapSettings: m_LightmapParameters: {fileID: 0} m_LightmapsBakeMode: 1 m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 m_ReflectionCompression: 2 m_MixedBakeMode: 2 m_BakeBackend: 1 @@ -327,7 +324,7 @@ GameObject: m_Component: - component: {fileID: 1245457781} m_Layer: 0 - m_Name: ----- Web3Modal + m_Name: ----- AppKit m_TagString: EditorOnly m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/sample/Reown.AppKit.Unity/Assets/Scenes/Init Scene.unity b/sample/Reown.AppKit.Unity/Assets/Scenes/Init Scene.unity index 9a09a87..02d5601 100644 --- a/sample/Reown.AppKit.Unity/Assets/Scenes/Init Scene.unity +++ b/sample/Reown.AppKit.Unity/Assets/Scenes/Init Scene.unity @@ -189,11 +189,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchorMax.x - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchorMax.y - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchorMin.y @@ -215,6 +215,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchoredPosition.x value: 0 @@ -239,6 +247,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchoredPosition.x value: 0 @@ -343,6 +359,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchoredPosition.x value: 0 @@ -367,6 +391,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchoredPosition.x value: 0 @@ -391,6 +423,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchoredPosition.x value: 0 @@ -415,6 +455,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchoredPosition.x value: 0 @@ -439,6 +487,14 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} propertyPath: m_AnchoredPosition.x value: 0 diff --git a/sample/Reown.AppKit.Unity/Assets/Scripts/AppInit.cs b/sample/Reown.AppKit.Unity/Assets/Scripts/AppInit.cs index e549831..ab4e324 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; @@ -22,6 +26,7 @@ private void Start() private void InitDebugConsole() { #if UNITY_STANDALONE || UNITY_ANDROID || UNITY_IOS + Debug.developerConsoleVisible = false; // disable Unity console DontDestroyOnLoad(gameObject); _debugConsole.SetActive(true); #endif @@ -39,5 +44,61 @@ 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); + } + + [ConsoleMethod("session", "Prints active session")] + public static void Session() + { + var walletConnect = AppKit.ConnectorController.ActiveConnector as WalletConnectConnector; + var session = walletConnect.SignClient.AddressProvider.DefaultSession; + + if (session == null) + { + Debug.Log("No active session found"); + return; + } + + var json = JsonConvert.SerializeObject(session, 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..ab5e363 100644 --- a/sample/Reown.AppKit.Unity/Assets/Scripts/AppKitInit.cs +++ b/sample/Reown.AppKit.Unity/Assets/Scripts/AppKitInit.cs @@ -8,6 +8,7 @@ #if !UNITY_WEBGL using mixpanel; +using Sentry; #endif namespace Sample @@ -21,20 +22,20 @@ private async void Start() // Set up Reown logger to collect logs from AppKit ReownLogger.Instance = new UnityLogger(); - // The very basic configuration of SIWE - var siweConfig = new SiweConfig - { - GetMessageParams = () => new SiweMessageParams - { - Domain = "example.com", - Uri = "https://example.com/login" - }, - SignOutOnChainChange = false - }; - - // Subscribe to SIWE events - siweConfig.SignInSuccess += _ => Debug.Log("[Dapp] SIWE Sign In Success!"); - siweConfig.SignOutSuccess += () => Debug.Log("[Dapp] SIWE Sign Out Success!"); + // // The very basic configuration of SIWE + // var siweConfig = new SiweConfig + // { + // GetMessageParams = () => new SiweMessageParams + // { + // Domain = "example.com", + // Uri = "https://example.com/login" + // }, + // SignOutOnChainChange = false + // }; + // + // // Subscribe to SIWE events + // siweConfig.SignInSuccess += _ => Debug.Log("[Dapp] SIWE Sign In Success!"); + // siweConfig.SignOutSuccess += () => Debug.Log("[Dapp] SIWE Sign Out Success!"); // AppKit configuration var appKitConfig = new AppKitConfig @@ -52,11 +53,18 @@ private async void Start() Native = "appkit-sample-unity://" } ), - customWallets = GetCustomWallets(), + // customWallets = GetCustomWallets(), // On mobile show 5 wallets on the Connect view (the first AppKit modal screen) - connectViewWalletsCountMobile = 5, + // connectViewWalletsCountMobile = 5, + supportedChains = new[] + { + ChainConstants.Chains.Optimism, + ChainConstants.Chains.Ethereum, + ChainConstants.Chains.Arbitrum, + ChainConstants.Chains.Base + } // Assign the SIWE configuration created above. Can be null if SIWE is not used. - siweConfig = siweConfig + // siweConfig = siweConfig }; Debug.Log("[AppKit Init] Initializing AppKit..."); @@ -66,9 +74,17 @@ await AppKit.InitializeAsync( ); #if !UNITY_WEBGL - // The Mixpanel is used by the sample project to collect telemetry + // The Mixpanel are Sentry are used by the sample project to collect telemetry var clientId = await AppKit.Instance.SignClient.CoreClient.Crypto.GetClientId(); Mixpanel.Identify(clientId); + + SentrySdk.ConfigureScope(scope => + { + scope.User = new SentryUser + { + Id = clientId + }; + }); #endif Debug.Log($"[AppKit Init] AppKit initialized. Loading menu scene..."); diff --git a/sample/Reown.AppKit.Unity/Assets/Scripts/Dapp.cs b/sample/Reown.AppKit.Unity/Assets/Scripts/Dapp.cs index 0aa9e51..e3b5c1e 100644 --- a/sample/Reown.AppKit.Unity/Assets/Scripts/Dapp.cs +++ b/sample/Reown.AppKit.Unity/Assets/Scripts/Dapp.cs @@ -5,7 +5,9 @@ using Nethereum.JsonRpc.Client; using Nethereum.Web3; using Reown.AppKit.Unity; +using Reown.AppKit.Unity.Profile; using Reown.Core; +using Reown.Core.Common.Model.Errors; using UnityEngine; using UnityEngine.UIElements; using ButtonUtk = UnityEngine.UIElements.Button; @@ -15,6 +17,7 @@ namespace Sample public class Dapp : MonoBehaviour { [SerializeField] private UIDocument _uiDocument; + private int _messageCounter = 0; private ButtonStruct[] _buttons; private VisualElement _buttonsContainer; @@ -55,12 +58,12 @@ private void BuildButtons() OnClick = OnPersonalSignButton, AccountRequired = true }, - new ButtonStruct - { - Text = "Sign Typed Data", - OnClick = OnSignTypedDataV4Button, - AccountRequired = true - }, + // new ButtonStruct + // { + // Text = "Sign Typed Data", + // OnClick = OnSignTypedDataV4Button, + // AccountRequired = true + // }, new ButtonStruct { Text = "Send Transaction", @@ -77,7 +80,7 @@ private void BuildButtons() { Text = "Read Contract", OnClick = OnReadContractClicked, - AccountRequired = true, + // AccountRequired = true, ChainIds = new HashSet { "eip155:1" @@ -210,24 +213,30 @@ public async void OnPersonalSignButton() { Debug.Log("[AppKit Sample] OnPersonalSignButton"); + var messageCounter = ++_messageCounter; try { var account = await AppKit.GetAccountAsync(); - const string message = "Hello from Unity!"; + var message = $"Hello from Unity! (Request #{messageCounter})"; + + Notification.ShowMessage($"Signing message:\n\n{message}"); + + await System.Threading.Tasks.Task.Delay(1_000); // It's also possible to sign a message as a byte array // var messageBytes = System.Text.Encoding.UTF8.GetBytes(message); // var signature = await AppKit.Evm.SignMessageAsync(messageBytes); var signature = await AppKit.Evm.SignMessageAsync(message); + Debug.Log($"Recieved signature: {signature}"); var isValid = await AppKit.Evm.VerifyMessageSignatureAsync(account.Address, message, signature); - Notification.ShowMessage($"Signature valid: {isValid}"); + Notification.ShowMessage($"Signature valid: {isValid} (Request #{messageCounter})"); } - catch (RpcResponseException e) + catch (ReownNetworkException e) { - Notification.ShowMessage($"{nameof(RpcResponseException)}:\n{e.Message}"); + Notification.ShowMessage($"Error processing personal_sign request #{messageCounter}\n\n{nameof(RpcResponseException)}:\n{e.Message}"); Debug.LogException(e, this); } } @@ -335,13 +344,13 @@ public async void OnSignTypedDataV4Button() public async void OnReadContractClicked() { - if (AppKit.NetworkController.ActiveChain.ChainId != "eip155:1") - { - Notification.ShowMessage("Please switch to Ethereum mainnet."); - return; - } + // if (AppKit.NetworkController.ActiveChain.ChainId != "eip155:1") + // { + // Notification.ShowMessage("Please switch to Ethereum mainnet."); + // return; + // } - const string contractAddress = "0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb"; // on Ethereum mainnet + const string contractAddress = "0x64b88c73A5DfA78D1713fE1b4c69a22d7E0faAa7"; const string yugaLabsAddress = "0xA858DDc0445d8131daC4d1DE01f834ffcbA52Ef1"; const string abi = CryptoPunksAbi; @@ -356,7 +365,7 @@ public async void OnReadContractClicked() { yugaLabsAddress }); - var result = $"Yuga Labs owns: {balance} {tokenName} tokens active chain."; + var result = $"Yuga Labs owns: {balance} {tokenName} tokens at active chain."; Notification.ShowMessage(result); } diff --git a/sample/Reown.AppKit.Unity/Packages/manifest.json b/sample/Reown.AppKit.Unity/Packages/manifest.json index 9eb200f..a2437fa 100644 --- a/sample/Reown.AppKit.Unity/Packages/manifest.json +++ b/sample/Reown.AppKit.Unity/Packages/manifest.json @@ -20,7 +20,7 @@ "com.unity.test-framework": "1.4.5", "com.unity.ugui": "2.0.0", "com.yasirkula.ingamedebugconsole": "1.6.8", - "io.sentry.unity": "2.3.0", + "io.sentry.unity": "2.4.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", diff --git a/sample/Reown.AppKit.Unity/Packages/packages-lock.json b/sample/Reown.AppKit.Unity/Packages/packages-lock.json index c8666d0..9b83c80 100644 --- a/sample/Reown.AppKit.Unity/Packages/packages-lock.json +++ b/sample/Reown.AppKit.Unity/Packages/packages-lock.json @@ -214,7 +214,7 @@ "url": "https://package.openupm.com" }, "io.sentry.unity": { - "version": "2.3.0", + "version": "2.4.0", "depth": 0, "source": "registry", "dependencies": {}, @@ -367,4 +367,4 @@ } } } -} \ No newline at end of file +} diff --git a/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset b/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset index 2fe0d27..282659f 100644 --- a/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset +++ b/sample/Reown.AppKit.Unity/ProjectSettings/ProjectSettings.asset @@ -140,7 +140,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 1.2.0 + bundleVersion: 1.3.0 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 @@ -169,10 +169,10 @@ PlayerSettings: buildNumber: Standalone: 0 VisionOS: 0 - iPhone: 2 + iPhone: 3 tvOS: 0 overrideDefaultApplicationIdentifier: 1 - AndroidBundleVersionCode: 2 + AndroidBundleVersionCode: 3 AndroidMinSdkVersion: 23 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 diff --git a/src/Reown.AppKit.Unity/Resources/Fonts & Materials/Inter/Inter-Regular SDF.asset b/src/Reown.AppKit.Unity/Resources/Fonts & Materials/Inter/Inter-Regular SDF.asset index 7b2096f..61d6b21 100644 --- a/src/Reown.AppKit.Unity/Resources/Fonts & Materials/Inter/Inter-Regular SDF.asset +++ b/src/Reown.AppKit.Unity/Resources/Fonts & Materials/Inter/Inter-Regular SDF.asset @@ -2696,11 +2696,11 @@ MonoBehaviour: italicTypeface: {fileID: 0} - regularTypeface: {fileID: 0} italicTypeface: {fileID: 0} - - regularTypeface: {fileID: 0} + - regularTypeface: {fileID: 11400000, guid: 2874db8c458054fa9a7c0a459981b379, type: 2} italicTypeface: {fileID: 0} - - regularTypeface: {fileID: 0} + - regularTypeface: {fileID: 11400000, guid: 13ca5dd63df1340ddbe089ae80e658ab, type: 2} italicTypeface: {fileID: 0} - - regularTypeface: {fileID: 0} + - regularTypeface: {fileID: 11400000, guid: 9ba5c39bac3324e6f83d07c1157e1476, type: 2} italicTypeface: {fileID: 0} - regularTypeface: {fileID: 0} italicTypeface: {fileID: 0} diff --git a/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance.meta b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance.meta new file mode 100644 index 0000000..7b246de --- /dev/null +++ b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 42c084f93f074b7185c15273c2f4a68f +timeCreated: 1738160693 \ No newline at end of file diff --git a/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uss b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uss new file mode 100644 index 0000000..5afed25 --- /dev/null +++ b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uss @@ -0,0 +1,17 @@ +:root { + flex-direction: row; + color: var(--ro-color-fg-100) +} + +Label { + padding: 0; + margin: 0; +} + +#balance__symbol { + padding-right: 2px; +} + +#balance__decimal { + color: var(--ro-color-fg-200) +} \ No newline at end of file diff --git a/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uss.meta b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uss.meta new file mode 100644 index 0000000..369c3da --- /dev/null +++ b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uss.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 80b4de2ee9594cefad4d38684df5f692 +timeCreated: 1738160902 \ No newline at end of file diff --git a/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uxml b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uxml new file mode 100644 index 0000000..4d34530 --- /dev/null +++ b/src/Reown.AppKit.Unity/Resources/Reown/AppKit/Components/Balance/Balance.uxml @@ -0,0 +1,6 @@ + +