use enum for ForkchoiceUpdatedStatus.status
This commit is contained in:
parent
980461c982
commit
0b5466f56e
|
@ -73,11 +73,22 @@ func getEnumStringTable(enumType: typedesc): Table[string, enumType] {.compileTi
|
|||
res[$value] = value
|
||||
res
|
||||
|
||||
proc fromJson*(n: JsonNode, argName: string, result: var PayloadExecutionStatus) {.inline.} =
|
||||
proc fromJson*(
|
||||
n: JsonNode, argName: string, result: var ForkchoiceUpdatedStatus) {.inline.} =
|
||||
n.kind.expect(JString, argName)
|
||||
const enumStrings = static: getEnumStringTable(type(result))
|
||||
try:
|
||||
enumStrings[n.getStr]
|
||||
result = enumStrings[n.getStr]
|
||||
except KeyError:
|
||||
raise newException(
|
||||
ValueError, "Parameter \"" & argName & "\" value invalid: " & n.getStr)
|
||||
|
||||
proc fromJson*(
|
||||
n: JsonNode, argName: string, result: var PayloadExecutionStatus) {.inline.} =
|
||||
n.kind.expect(JString, argName)
|
||||
const enumStrings = static: getEnumStringTable(type(result))
|
||||
try:
|
||||
result = enumStrings[n.getStr]
|
||||
except KeyError:
|
||||
raise newException(
|
||||
ValueError, "Parameter \"" & argName & "\" value invalid: " & n.getStr)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.5/src/engine/specification.md
|
||||
|
||||
import
|
||||
std/options,
|
||||
ethtypes
|
||||
|
@ -37,5 +35,5 @@ type
|
|||
syncing = "SYNCING"
|
||||
|
||||
ForkchoiceUpdatedResponse* = object
|
||||
status*: string
|
||||
status*: ForkchoiceUpdatedStatus
|
||||
payloadId*: Option[PayloadID]
|
||||
|
|
Loading…
Reference in New Issue