add section headers for REST serialization (#4210)

Adds missing REST serialization sections and makes them consistent.
This commit is contained in:
Etan Kissling 2022-10-04 00:29:07 +02:00 committed by GitHub
parent 231eb8a590
commit 83cd104d07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -464,6 +464,7 @@ proc readValue*(reader: var JsonReader[RestJson], value: var uint64) {.
else:
reader.raiseUnexpectedValue($res.error() & ": " & svalue)
## uint8
proc writeValue*(w: var JsonWriter[RestJson], value: uint8) {.
raises: [IOError, Defect].} =
writeValue(w, Base10.toString(value))
@ -477,6 +478,7 @@ proc readValue*(reader: var JsonReader[RestJson], value: var uint8) {.
else:
reader.raiseUnexpectedValue($res.error() & ": " & svalue)
## JustificationBits
proc writeValue*(w: var JsonWriter[RestJson], value: JustificationBits) {.
raises: [IOError, Defect].} =
w.writeValue hexOriginal([uint8(value)])
@ -579,6 +581,7 @@ proc readValue*(reader: var JsonReader[RestJson], value: var ValidatorIndex)
else:
reader.raiseUnexpectedValue($res.error())
## IndexInSyncCommittee
proc writeValue*(writer: var JsonWriter[RestJson], value: IndexInSyncCommittee)
{.raises: [IOError, Defect].} =
writeValue(writer, Base10.toString(distinctBase(value)))
@ -778,6 +781,7 @@ proc writeValue*(writer: var JsonWriter[RestJson], value: Eth1Address) {.
raises: [IOError, Defect].} =
writeValue(writer, hexOriginal(distinctBase(value)))
## GraffitiBytes
proc writeValue*(writer: var JsonWriter[RestJson], value: GraffitiBytes)
{.raises: [IOError, Defect].} =
writeValue(writer, hexOriginal(distinctBase(value)))
@ -789,7 +793,7 @@ proc readValue*(reader: var JsonReader[RestJson], T: type GraffitiBytes): T
except ValueError as err:
reader.raiseUnexpectedValue err.msg
## Version
## Version | ForkDigest | DomainType | GraffitiBytes
proc readValue*(
reader: var JsonReader[RestJson],
value: var (Version | ForkDigest | DomainType | GraffitiBytes)) {.
@ -1442,7 +1446,7 @@ proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconStat
writer.writeField("data", value.bellatrixData.data)
writer.endRecord()
# Web3SignerRequest
## Web3SignerRequest
proc writeValue*(writer: var JsonWriter[RestJson],
value: Web3SignerRequest) {.
raises: [IOError, Defect].} =
@ -2103,6 +2107,7 @@ proc readValue*(reader: var JsonReader[RestJson],
keystores: keystores, passwords: passwords, slashing_protection: slashing
)
## RestActivityItem
proc writeValue*(writer: var JsonWriter[RestJson],
value: RestActivityItem) {.
raises: [IOError, Defect].} =
@ -2149,6 +2154,7 @@ proc readValue*(reader: var JsonReader[RestJson],
value = RestActivityItem(index: index.get(), epoch: epoch.get(),
active: active.get())
## HeadChangeInfoObject
proc writeValue*(writer: var JsonWriter[RestJson],
value: HeadChangeInfoObject) {.
raises: [IOError, Defect].} =
@ -2165,6 +2171,7 @@ proc writeValue*(writer: var JsonWriter[RestJson],
writer.writeField("execution_optimistic", value.optimistic.get())
writer.endRecord()
## ReorgInfoObject
proc writeValue*(writer: var JsonWriter[RestJson],
value: ReorgInfoObject) {.
raises: [IOError, Defect].} =
@ -2179,6 +2186,7 @@ proc writeValue*(writer: var JsonWriter[RestJson],
writer.writeField("execution_optimistic", value.optimistic.get())
writer.endRecord()
## FinalizationInfoObject
proc writeValue*(writer: var JsonWriter[RestJson],
value: FinalizationInfoObject) {.
raises: [IOError, Defect].} =
@ -2190,6 +2198,7 @@ proc writeValue*(writer: var JsonWriter[RestJson],
writer.writeField("execution_optimistic", value.optimistic.get())
writer.endRecord()
## EventBeaconBlockObject
proc writeValue*(writer: var JsonWriter[RestJson],
value: EventBeaconBlockObject) {.
raises: [IOError, Defect].} =
@ -2200,6 +2209,7 @@ proc writeValue*(writer: var JsonWriter[RestJson],
writer.writeField("execution_optimistic", value.optimistic.get())
writer.endRecord()
## RestSyncInfo
proc writeValue*(writer: var JsonWriter[RestJson],
value: RestSyncInfo) {.
raises: [IOError, Defect].} =