fix REST encoding

This commit is contained in:
Etan Kissling 2024-06-25 13:08:41 +02:00
parent 885000f02b
commit 0ef4742fd5
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D

View File

@ -1027,6 +1027,20 @@ proc readValue*(reader: var JsonReader[RestJson], value: var JustificationBits)
raiseUnexpectedValue(reader,
"The `justification_bits` value must be a hex string")
## openArray[byte]
proc writeValue*(
w: var JsonWriter[RestJson], value: openArray[byte]
) {.raises: [IOError].} =
w.writeValue hexOriginal(value)
proc readValue*(reader: var JsonReader[RestJson], value: var openArray[byte]) {.
raises: [IOError, SerializationError].} =
let hex = reader.readValue(string)
try:
hexToByteArrayStrict(hex, value)
except ValueError:
raiseUnexpectedValue(reader, "Byte array value must be a hex string")
## UInt256
proc writeValue*(
w: var JsonWriter[RestJson], value: UInt256) {.raises: [IOError].} =