WalletConnect / WalletConnectSharp

A C# implementation of the WalletConnect client
Apache License 2.0
139 stars 60 forks source link

TypedEventHandler does not forward Error in RequestCallback method #158

Closed bugbytesinc closed 7 months ago

bugbytesinc commented 7 months ago

In the TypedEventHandler within the Core project, there is a missing edge case where an Error attached to the result is not forwarded for further processing. At this line:

https://github.com/WalletConnect/WalletConnectSharp/blob/60de2c867f67a68feb44bf04fbf456a8d8378f1b/WalletConnectSharp.Core/Models/MessageHandler/TypedEventHandler.cs#L230

we have:

if (rea.Response != null || rea.Error != null)
{
    await _ref.MessageHandler.SendResult<T, TR>(arg2.Id, arg1, rea.Response);
}

If the Response is null because the Error is not, the error is not propagated to the, would suggest something like the following instead:

            if (rea.Error != null)
            {
                await _ref.MessageHandler.SendError<T, TR>(arg2.Id, arg1, rea.Error);
            }
            else if (rea.Response != null)
            {
                await _ref.MessageHandler.SendResult<T, TR>(arg2.Id, arg1, rea.Response);
            }

This follows the patterns seen elsewhere in the code.