WalletConnect / Web3ModalUnity

WalletConnect AppKit: a single Web3 provider solution for all Wallets
Apache License 2.0
14 stars 2 forks source link

Web3Modal Working In Editor But Not In Build #24

Closed brian-kryptomon closed 2 months ago

brian-kryptomon commented 2 months ago

Describe the bug After getting everything working in the Unity editor - I went to create a Windows build and the web3modal doesn't work and throws a null reference exception.

To Reproduce Perform a build on 2022.3.x Unity and I get this error stack:

NullReferenceException: Object reference not set to an instance of an object WalletConnect.Web3Modal.ModalControllerUtk.InitializeAsyncCore () (at <2eda3a9d91a94a968db7379d9b1fa616>:0) WalletConnect.Web3Modal.ModalController.InitializeAsync () (at <2eda3a9d91a94a968db7379d9b1fa616>:0) WalletConnect.Web3Modal.Web3ModalCore.InitializeAsyncCore () (at <2eda3a9d91a94a968db7379d9b1fa616>:0) WalletConnect.Web3Modal.Web3Modal.InitializeAsync (WalletConnect.Web3Modal.Web3ModalConfig config) (at <2eda3a9d91a94a968db7379d9b1fa616>:0) PinkMoon.World.Blockchain.WalletConnectWalletProviderService.Setup () (at <84ec0767e2d34d7ab1a98a64d6f811f4>:0) System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) (at :0) UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at :0) UnityEngine.UnitySynchronizationContext.Exec () (at :0) UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at :0)

Expected behavior The wallet connect modal should show up.

Screenshots N/A

Environment

Is this happening in Unity Editor or on a player like Android, iOS, Windows? This only seems to happen on the builds not on the editor.

Wallets used for testing N/A can't even get modal to show up

Additional context N/A

brian-kryptomon commented 2 months ago

I did some more debugging its happening here:

ModalControllerUtk.cs (Line 34) Web3Modal = UIDocument.rootVisualElement.Children().First();

And I think this might be related since its showing up in the logs earlier:

ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown. Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') Could not resolve type with token 0100002f from typeref (expected class 'System.Security.Policy.EvidenceBase' in assembly 'System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') System.Reflection.Assembly.GetTypes () (at :0) UnityEngine.UIElements.VisualElementFactoryRegistry.RegisterUserFactories () (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UXML/VisualElementFactoryRegistry.cs:180) UnityEngine.UIElements.VisualElementFactoryRegistry.get_factories () (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UXML/VisualElementFactoryRegistry.cs:34) UnityEngine.UIElements.VisualElementFactoryRegistry.TryGetValue (System.String fullTypeName, System.Collections.Generic.List1[UnityEngine.UIElements.IUxmlFactory]& factoryList) (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UXML/VisualElementFactoryRegistry.cs:72) UnityEngine.UIElements.VisualTreeAsset.Create (UnityEngine.UIElements.VisualElementAsset asset, UnityEngine.UIElements.CreationContext ctx) (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UXML/VisualTreeAsset.cs:777) UnityEngine.UIElements.VisualTreeAsset.CloneSetupRecursively (UnityEngine.UIElements.VisualElementAsset root, System.Collections.Generic.Dictionary2[TKey,TValue] idToChildren, UnityEngine.UIElements.CreationContext context) (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UXML/VisualTreeAsset.cs:566) UnityEngine.UIElements.VisualTreeAsset.CloneTree (UnityEngine.UIElements.VisualElement target, System.Collections.Generic.Dictionary2[TKey,TValue] slotInsertionPoints, System.Collections.Generic.List1[T] attributeOverrides) (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UXML/VisualTreeAsset.cs:538) UnityEngine.UIElements.VisualTreeAsset.Instantiate () (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UXML/VisualTreeAsset.cs:399) UnityEngine.UIElements.UIDocument.RecreateUI () (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/GameObjects/UIDocument.cs:423) UnityEngine.UIElements.UIDocument.OnEnable () (at C:/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/GameObjects/UIDocument.cs:319)

brian-kryptomon commented 2 months ago

Turns out it was just a bad dependencies that one of my devs imported to the project 2 years ago but we never used any of the UI stuff so it never became visible.