Switch Uint256JsonConverter from 'JsonConverter' to 'JsonConverter<T>'
MODIFY
WalletWasabi/JsonConverters/Uint256JsonConverter.cs
WalletWasabi/JsonConverters/Uint256JsonConverter.cs
@@ -4,25 +4,19 @@ using WalletWasabi.Helpers;
namespace WalletWasabi.JsonConverters;
-public class Uint256JsonConverter : JsonConverter
+public class Uint256JsonConverter : JsonConverter<uint256>
{
/// <inheritdoc />
- public override bool CanConvert(Type objectType)
+ public override uint256? ReadJson(JsonReader reader, Type objectType, uint256? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
- return objectType == typeof(uint256);
- }
-
- /// <inheritdoc />
- public override object? ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
- {
- var value = Guard.Correct((string)reader.Value);
+ var value = Guard.Correct((string?)reader.Value);
return string.IsNullOrWhiteSpace(value) ? default : new uint256(value);
}
/// <inheritdoc />
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, uint256? value, JsonSerializer serializer)
{
- writer.WriteValue(((uint256)value)?.ToString());
+ writer.WriteValue(value?.ToString());
}
}

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