Switch OutPointAsTxoRefJsonConverter from 'JsonConverter' to 'JsonConverter<T>'
MODIFY
WalletWasabi/JsonConverters/OutPointAsTxoRefJsonConverter.cs
WalletWasabi/JsonConverters/OutPointAsTxoRefJsonConverter.cs
@@ -4,16 +4,10 @@ using Newtonsoft.Json.Linq;
namespace WalletWasabi.JsonConverters;
-public class OutPointAsTxoRefJsonConverter : JsonConverter
+public class OutPointAsTxoRefJsonConverter : JsonConverter<OutPoint>
{
/// <inheritdoc />
- public override bool CanConvert(Type objectType)
- {
- return objectType == typeof(OutPoint);
- }
-
- /// <inheritdoc />
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ public override OutPoint? ReadJson(JsonReader reader, Type objectType, OutPoint? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
JObject item = JObject.Load(reader);
@@ -23,9 +17,14 @@ public class OutPointAsTxoRefJsonConverter : JsonConverter
}
/// <inheritdoc />
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, OutPoint? value, JsonSerializer serializer)
{
- var outpoint = value as OutPoint;
+ if (value is null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ var outpoint = value;
writer.WriteStartObject();
writer.WritePropertyName("TransactionId");
writer.WriteValue(outpoint.Hash.ToString());

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