mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-12 23:34:44 +00:00
fix REST encoding
This commit is contained in:
parent
885000f02b
commit
0ef4742fd5
@ -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].} =
|
||||
|
Loading…
x
Reference in New Issue
Block a user