This commit is contained in:
cheatfate 2021-04-12 19:05:13 +03:00 committed by zah
parent 477decbcf5
commit 3417871370
1 changed files with 13 additions and 0 deletions

View File

@ -339,3 +339,16 @@ proc decodeBody*[T](t: typedesc[T],
except CatchableError as exc: except CatchableError as exc:
return err("Unexpected deserialization error") return err("Unexpected deserialization error")
ok(data) 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])