diff --git a/Packages/.gitignore b/Packages/.gitignore index d51905818..4a12d5262 100644 --- a/Packages/.gitignore +++ b/Packages/.gitignore @@ -79,10 +79,15 @@ crashlytics-build.properties !*.meta # Ignore the build artifacts from our libraries -# /io.chainsafe.web3-unity/Runtime/Libraries/*.dll -# /io.chainsafe.web3-unity/Runtime/Libraries/*.dll.meta +/io.chainsafe.web3-unity/Runtime/Libraries/*.dll +/io.chainsafe.web3-unity/Runtime/Libraries/*.dll.meta /io.chainsafe.web3-unity/Runtime/Libraries/*.pdb /io.chainsafe.web3-unity/Runtime/Libraries/*.pdb.meta +/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/*.dll +/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/*.dll.meta +/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/*.pdb +/io.chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/*.pdb.meta + # Since the folder is called 'Debug', it's being ignored, so negate that !/io.chainsafe.web3-unity.web3auth/Runtime/Plugins/Web3AuthSDK/Debug \ No newline at end of file diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll index b04f089a5..d7b5efef3 100644 Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll differ diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll index e6d1bea4f..31c267fb8 100644 Binary files a/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll and b/Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll differ diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs index ec1fe181c..0c9ed5b43 100644 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs +++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Scenes/ExistingWalletLogin.cs @@ -185,7 +185,8 @@ private void BuildWalletConnectConfig() // try and get saved value SavedSessionTopic = walletConnectConfig?.SavedSessionTopic, SupportedWallets = supportedWallets, - StoragePath = Application.persistentDataPath, + // save file closer to assets when in editor, more accessible + StoragePath = Application.isEditor ? Application.dataPath : Application.persistentDataPath, RedirectToWallet = redirectToWallet, KeepSessionAlive = autoLogin || rememberMeToggle.isOn, DefaultWallet = defaultWallet, diff --git a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/PlayerData.cs b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/PlayerData.cs index c9abc92ab..1bd28bc1e 100644 --- a/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/PlayerData.cs +++ b/Packages/io.chainsafe.web3-unity/Samples~/Web3.Unity/Scripts/Utilities/PlayerData.cs @@ -14,14 +14,24 @@ public class PlayerData { #region Save & Load - private static string _path = $"{Path.Combine(Application.persistentDataPath, nameof(PlayerData))}.json"; + private string Path + { + get + { + // save closer to assets when in editor + // more accessible + string directory = Application.isEditor ? Application.dataPath : Application.persistentDataPath; + + return $"{System.IO.Path.Combine(directory, nameof(PlayerData))}.json"; + } + } /// /// Singleton instance. /// public static PlayerData Instance { get; private set; } = new PlayerData(); - private bool FileExists => File.Exists(_path); + private bool FileExists => File.Exists(Path); /// /// Loads Data when runtime starts. @@ -41,26 +51,26 @@ private void LoadData() return; } - using (FileStream fs = new FileStream(_path, FileMode.Open, FileAccess.Read)) + using (FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read)) using (StreamReader sr = new StreamReader(fs)) { string rawJson = sr.ReadToEnd(); Instance = JsonConvert.DeserializeObject(rawJson); - Debug.Log($"{nameof(PlayerData)} loaded from path {_path}."); + Debug.Log($"{nameof(PlayerData)} loaded from path {Path}."); } } private void SaveData() { // create file - using (FileStream fs = new FileStream(_path, FileMode.OpenOrCreate, FileAccess.Write)) + using (FileStream fs = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Write)) using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(JsonConvert.SerializeObject(Instance)); - Debug.Log($"{nameof(PlayerData)} saved at path {_path}."); + Debug.Log($"{nameof(PlayerData)} saved at path {Path}."); } } diff --git a/src/ChainSafe.Gaming.WalletConnect/WalletConnectCustomProvider.cs b/src/ChainSafe.Gaming.WalletConnect/WalletConnectCustomProvider.cs index 2a13cffa7..3a3b2646d 100644 --- a/src/ChainSafe.Gaming.WalletConnect/WalletConnectCustomProvider.cs +++ b/src/ChainSafe.Gaming.WalletConnect/WalletConnectCustomProvider.cs @@ -379,6 +379,13 @@ private FileSystemStorage BuildStorage() { var path = Path.Combine(config.StoragePath, "walletconnect.json"); + // If we're not restoring a session and save WC file exists remove it. + // This is done to mitigate for a WC error that happens intermittently where generated Uri doesn't connect wallet. + if (string.IsNullOrEmpty(config.SavedSessionTopic) && File.Exists(path)) + { + File.Delete(path); + } + WCLogger.Log($"Wallet Connect Storage set to {path}"); return new FileSystemStorage(path); diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs index ec1fe181c..0c9ed5b43 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Scenes/ExistingWalletLogin.cs @@ -185,7 +185,8 @@ private void BuildWalletConnectConfig() // try and get saved value SavedSessionTopic = walletConnectConfig?.SavedSessionTopic, SupportedWallets = supportedWallets, - StoragePath = Application.persistentDataPath, + // save file closer to assets when in editor, more accessible + StoragePath = Application.isEditor ? Application.dataPath : Application.persistentDataPath, RedirectToWallet = redirectToWallet, KeepSessionAlive = autoLogin || rememberMeToggle.isOn, DefaultWallet = defaultWallet, diff --git a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/PlayerData.cs b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/PlayerData.cs index c9abc92ab..1bd28bc1e 100644 --- a/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/PlayerData.cs +++ b/src/UnitySampleProject/Assets/Samples/web3.unity SDK/2.5.0/Web3.Unity Samples/Scripts/Utilities/PlayerData.cs @@ -14,14 +14,24 @@ public class PlayerData { #region Save & Load - private static string _path = $"{Path.Combine(Application.persistentDataPath, nameof(PlayerData))}.json"; + private string Path + { + get + { + // save closer to assets when in editor + // more accessible + string directory = Application.isEditor ? Application.dataPath : Application.persistentDataPath; + + return $"{System.IO.Path.Combine(directory, nameof(PlayerData))}.json"; + } + } /// /// Singleton instance. /// public static PlayerData Instance { get; private set; } = new PlayerData(); - private bool FileExists => File.Exists(_path); + private bool FileExists => File.Exists(Path); /// /// Loads Data when runtime starts. @@ -41,26 +51,26 @@ private void LoadData() return; } - using (FileStream fs = new FileStream(_path, FileMode.Open, FileAccess.Read)) + using (FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read)) using (StreamReader sr = new StreamReader(fs)) { string rawJson = sr.ReadToEnd(); Instance = JsonConvert.DeserializeObject(rawJson); - Debug.Log($"{nameof(PlayerData)} loaded from path {_path}."); + Debug.Log($"{nameof(PlayerData)} loaded from path {Path}."); } } private void SaveData() { // create file - using (FileStream fs = new FileStream(_path, FileMode.OpenOrCreate, FileAccess.Write)) + using (FileStream fs = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Write)) using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(JsonConvert.SerializeObject(Instance)); - Debug.Log($"{nameof(PlayerData)} saved at path {_path}."); + Debug.Log($"{nameof(PlayerData)} saved at path {Path}."); } }