diff --git a/Tests/WalletConnectSharp.Sign.Test/SignTests.cs b/Tests/WalletConnectSharp.Sign.Test/SignTests.cs index d7d005b..55d136a 100644 --- a/Tests/WalletConnectSharp.Sign.Test/SignTests.cs +++ b/Tests/WalletConnectSharp.Sign.Test/SignTests.cs @@ -1,11 +1,9 @@ using WalletConnectSharp.Common.Model.Errors; using WalletConnectSharp.Common.Utils; -using WalletConnectSharp.Crypto; using WalletConnectSharp.Network.Models; using WalletConnectSharp.Sign.Interfaces; using WalletConnectSharp.Sign.Models; using WalletConnectSharp.Sign.Models.Engine; -using WalletConnectSharp.Storage; using WalletConnectSharp.Tests.Common; using Xunit; using Xunit.Abstractions; @@ -786,8 +784,8 @@ public async Task TestAddressProviderChainIdChange() _ = await TestConnectMethod(ClientA, ClientB); - const string badChainId = "invalid:invalid"; - await Assert.ThrowsAsync(() => ClientA.AddressProvider.SetDefaultChainIdAsync(badChainId)); + const string badChainId = "badChainId"; + await Assert.ThrowsAsync(() => ClientA.AddressProvider.SetDefaultChainIdAsync(badChainId)); // Change the default chain id const string newChainId = "eip155:10"; diff --git a/WalletConnectSharp.Sign/Controllers/AddressProvider.cs b/WalletConnectSharp.Sign/Controllers/AddressProvider.cs index 683ec76..8fa7e1a 100644 --- a/WalletConnectSharp.Sign/Controllers/AddressProvider.cs +++ b/WalletConnectSharp.Sign/Controllers/AddressProvider.cs @@ -1,4 +1,5 @@ using WalletConnectSharp.Common.Utils; +using WalletConnectSharp.Core; using WalletConnectSharp.Sign.Interfaces; using WalletConnectSharp.Sign.Models; using WalletConnectSharp.Sign.Models.Engine.Events; @@ -220,9 +221,9 @@ public async Task SetDefaultChainIdAsync(string chainId) throw new ArgumentNullException(nameof(chainId)); } - if (!DefaultSession.Namespaces[DefaultNamespace].Chains.Contains(chainId)) + if (!Utils.IsValidChainId(chainId)) { - throw new InvalidOperationException($"Chain {chainId} is not available in the current session"); + throw new ArgumentException("The format of 'chainId' is invalid. Must be in the format of 'namespace:chainId' (e.g. 'eip155:10'). See CAIP-2 for more information."); } DefaultChainId = chainId;