From bc8c1f1521bee255917dfacd92d43eaf4d84950e Mon Sep 17 00:00:00 2001 From: Julia Seward Date: Wed, 4 Oct 2023 17:02:11 -0400 Subject: [PATCH 1/6] fix: no longer hide exceptions when loading session file --- .../FileSystemStorage.cs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs b/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs index 2376614..60dbe45 100644 --- a/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs +++ b/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs @@ -110,23 +110,8 @@ private async Task Load() await _semaphoreSlim.WaitAsync(); var json = await File.ReadAllTextAsync(FilePath, Encoding.UTF8); _semaphoreSlim.Release(); - - try - { - Entries = JsonConvert.DeserializeObject>(json, - new JsonSerializerSettings() {TypeNameHandling = TypeNameHandling.Auto}); - } - catch (JsonSerializationException e) - { - // Move the file to a .unsupported file - // and start fresh - WCLogger.LogError(e); - WCLogger.LogError("Cannot load JSON file, moving data to .unsupported file to force continue"); - if (File.Exists(FilePath + ".unsupported")) - File.Move(FilePath + ".unsupported", FilePath + "." + Guid.NewGuid() + ".unsupported"); - File.Move(FilePath, FilePath + ".unsupported"); - Entries = new Dictionary(); - } + Entries = JsonConvert.DeserializeObject>(json, + new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); } } } From 82a77ca5a6f9b4f83ad2e266c3368e8739c0c8ac Mon Sep 17 00:00:00 2001 From: Julia Seward Date: Wed, 4 Oct 2023 19:44:29 -0400 Subject: [PATCH 2/6] chore: bump version --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 642210f..770278e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 2.1.0 + 2.1.1 net6.0;netcoreapp3.1;netstandard2.1; From f2db3e554e64904e047c0cb0643541913dc2d368 Mon Sep 17 00:00:00 2001 From: Julia Seward Date: Mon, 9 Oct 2023 15:22:09 -0400 Subject: [PATCH 3/6] fix: do not disconnect relayer after 10 seconds --- WalletConnectSharp.Core/Controllers/Relayer.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/WalletConnectSharp.Core/Controllers/Relayer.cs b/WalletConnectSharp.Core/Controllers/Relayer.cs index 9b9d65b..9a94db8 100644 --- a/WalletConnectSharp.Core/Controllers/Relayer.cs +++ b/WalletConnectSharp.Core/Controllers/Relayer.cs @@ -156,20 +156,6 @@ await Task.WhenAll( RegisterEventListeners(); initialized = true; - -#pragma warning disable CS4014 - Task.Run(async () => -#pragma warning restore CS4014 - { - await Task.Delay(TimeSpan.FromSeconds(10)); - - if (this.Subscriber.Topics.Length == 0) - { - // No topics subscribed to after init, closing transport - await this.TransportClose(); - this.transportExplicityClosed = false; - } - }); } protected virtual async Task CreateProvider() From 5474053b40b194000fff27da8fc7107368d16295 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Thu, 12 Oct 2023 17:52:59 +0900 Subject: [PATCH 4/6] fix: SessionStruct is missing pairing topic --- WalletConnectSharp.Sign/Internals/EngineHandler.cs | 2 ++ .../Models/Engine/Methods/SessionSettle.cs | 6 ++++++ WalletConnectSharp.Sign/Models/SessionStruct.cs | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/WalletConnectSharp.Sign/Internals/EngineHandler.cs b/WalletConnectSharp.Sign/Internals/EngineHandler.cs index 6e3569a..710b94c 100644 --- a/WalletConnectSharp.Sign/Internals/EngineHandler.cs +++ b/WalletConnectSharp.Sign/Internals/EngineHandler.cs @@ -132,6 +132,7 @@ async Task IEnginePrivate.OnSessionSettleRequest(string topic, JsonRpcRequest + /// Pairing topic for this session + /// + [JsonProperty("pairingTopic")] + public string PairingTopic; + /// /// The protocol options that should be used in this session /// diff --git a/WalletConnectSharp.Sign/Models/SessionStruct.cs b/WalletConnectSharp.Sign/Models/SessionStruct.cs index 98165b0..f34872b 100644 --- a/WalletConnectSharp.Sign/Models/SessionStruct.cs +++ b/WalletConnectSharp.Sign/Models/SessionStruct.cs @@ -16,6 +16,12 @@ public struct SessionStruct : IKeyHolder [JsonProperty("topic")] public string Topic; + /// + /// The pairing topic of this session + /// + [JsonProperty("pairingTopic")] + public string PairingTopic; + /// /// The relay protocol options this session is using /// From ae1c2a0061c8892c8185f1cd0aed5be508fc0be4 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Mon, 16 Oct 2023 14:56:04 +0900 Subject: [PATCH 5/6] Decrease pause check interval from 2ms to 1s --- WalletConnectSharp.Core/Controllers/Relayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WalletConnectSharp.Core/Controllers/Relayer.cs b/WalletConnectSharp.Core/Controllers/Relayer.cs index 9a94db8..12324da 100644 --- a/WalletConnectSharp.Core/Controllers/Relayer.cs +++ b/WalletConnectSharp.Core/Controllers/Relayer.cs @@ -451,7 +451,7 @@ private async Task ToEstablishConnection() while (Provider.Connection.IsPaused) { WCLogger.Log("[Relayer] Waiting for connection to unpause"); - await Task.Delay(2); + await Task.Delay(TimeSpan.FromSeconds(1)); } return; } From 25aa38afd3be3a5a210ddc380fe29b006433bd42 Mon Sep 17 00:00:00 2001 From: skibitsky Date: Mon, 16 Oct 2023 17:38:02 +0900 Subject: [PATCH 6/6] Revert "Merge branch 'fix/filesystem-hides-error' into release/2.1.1" This reverts commit a60ee6505f7c48dd339f867afe97ad3894124dcf, reversing changes made to d26757f437f4b17b1b8baa2da0867eb7977ffd1f. --- .../FileSystemStorage.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs b/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs index 60dbe45..2376614 100644 --- a/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs +++ b/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs @@ -110,8 +110,23 @@ private async Task Load() await _semaphoreSlim.WaitAsync(); var json = await File.ReadAllTextAsync(FilePath, Encoding.UTF8); _semaphoreSlim.Release(); - Entries = JsonConvert.DeserializeObject>(json, - new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); + + try + { + Entries = JsonConvert.DeserializeObject>(json, + new JsonSerializerSettings() {TypeNameHandling = TypeNameHandling.Auto}); + } + catch (JsonSerializationException e) + { + // Move the file to a .unsupported file + // and start fresh + WCLogger.LogError(e); + WCLogger.LogError("Cannot load JSON file, moving data to .unsupported file to force continue"); + if (File.Exists(FilePath + ".unsupported")) + File.Move(FilePath + ".unsupported", FilePath + "." + Guid.NewGuid() + ".unsupported"); + File.Move(FilePath, FilePath + ".unsupported"); + Entries = new Dictionary(); + } } } }