Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Tests/WalletConnectSharp.Sign.Test/SignTests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -786,8 +784,8 @@ public async Task TestAddressProviderChainIdChange()

_ = await TestConnectMethod(ClientA, ClientB);

const string badChainId = "invalid:invalid";
await Assert.ThrowsAsync<InvalidOperationException>(() => ClientA.AddressProvider.SetDefaultChainIdAsync(badChainId));
const string badChainId = "badChainId";
await Assert.ThrowsAsync<ArgumentException>(() => ClientA.AddressProvider.SetDefaultChainIdAsync(badChainId));

// Change the default chain id
const string newChainId = "eip155:10";
Expand Down
5 changes: 3 additions & 2 deletions WalletConnectSharp.Sign/Controllers/AddressProvider.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down