mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-02 01:36:06 +00:00
Address #2489.
This commit is contained in:
parent
477decbcf5
commit
3417871370
@ -339,3 +339,16 @@ proc decodeBody*[T](t: typedesc[T],
|
||||
except CatchableError as exc:
|
||||
return err("Unexpected deserialization error")
|
||||
ok(data)
|
||||
|
||||
RestJson.useCustomSerialization(BeaconState.justification_bits):
|
||||
read:
|
||||
let s = reader.readValue(string)
|
||||
if s.len != 4:
|
||||
raiseUnexpectedValue(reader, "A string with 4 characters expected")
|
||||
try:
|
||||
hexToByteArray(s, 1)[0]
|
||||
except ValueError:
|
||||
raiseUnexpectedValue(reader,
|
||||
"The `justification_bits` value must be a hex string")
|
||||
write:
|
||||
writer.writeValue "0x" & toHex([value])
|
||||
|
Loading…
x
Reference in New Issue
Block a user