Switch UnblindedSignatureJsonConverter from 'JsonConverter' to 'JsonConverter<T>'
MODIFY
WalletWasabi/JsonConverters/UnblindedSignatureJsonConverter.cs
WalletWasabi/JsonConverters/UnblindedSignatureJsonConverter.cs
@@ -6,16 +6,10 @@ using WalletWasabi.Crypto;
namespace WalletWasabi.JsonConverters;
-public class UnblindedSignatureJsonConverter : JsonConverter
+public class UnblindedSignatureJsonConverter : JsonConverter<UnblindedSignature>
{
/// <inheritdoc />
- public override bool CanConvert(Type objectType)
- {
- return objectType == typeof(UnblindedSignature);
- }
-
- /// <inheritdoc />
- public override object ReadJson(JsonReader reader, Type? objectType, object? existingValue, JsonSerializer? serializer)
+ public override UnblindedSignature? ReadJson(JsonReader reader, Type objectType, UnblindedSignature? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
JArray arr = JArray.Load(reader);
@@ -44,9 +38,9 @@ public class UnblindedSignatureJsonConverter : JsonConverter
}
/// <inheritdoc />
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer? serializer)
+ public override void WriteJson(JsonWriter writer, UnblindedSignature? value, JsonSerializer serializer)
{
- var signature = (UnblindedSignature)value;
+ var signature = value ?? throw new ArgumentNullException(nameof(value));
var c = new BigInteger(signature.C.ToBytes(), isUnsigned: true, isBigEndian: true);
var s = new BigInteger(signature.S.ToBytes(), isUnsigned: true, isBigEndian: true);
writer.WriteStartArray();

Switch UnblindedSignatureJsonConverter from 'JsonConverter' to 'JsonConverter<T>'