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[$value] = value
|
||||||
res
|
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)
|
n.kind.expect(JString, argName)
|
||||||
const enumStrings = static: getEnumStringTable(type(result))
|
const enumStrings = static: getEnumStringTable(type(result))
|
||||||
try:
|
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:
|
except KeyError:
|
||||||
raise newException(
|
raise newException(
|
||||||
ValueError, "Parameter \"" & argName & "\" value invalid: " & n.getStr)
|
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
|
import
|
||||||
std/options,
|
std/options,
|
||||||
ethtypes
|
ethtypes
|
||||||
|
@ -37,5 +35,5 @@ type
|
||||||
syncing = "SYNCING"
|
syncing = "SYNCING"
|
||||||
|
|
||||||
ForkchoiceUpdatedResponse* = object
|
ForkchoiceUpdatedResponse* = object
|
||||||
status*: string
|
status*: ForkchoiceUpdatedStatus
|
||||||
payloadId*: Option[PayloadID]
|
payloadId*: Option[PayloadID]
|
||||||
|
|
Loading…
Reference in New Issue