refactor forkchoiceUpdated response type

This commit is contained in:
Dustin Brody 2022-02-11 15:35:48 +00:00
parent 649b0bf42f
commit 0012deda79
No known key found for this signature in database
GPG Key ID: 3D7A11A0156519DC
2 changed files with 1 additions and 17 deletions

View File

@ -73,16 +73,6 @@ func getEnumStringTable(enumType: typedesc): Table[string, enumType] {.compileTi
res[$value] = value
res
proc fromJson*(
n: JsonNode, argName: string, result: var ForkchoiceUpdatedStatus) {.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)
proc fromJson*(
n: JsonNode, argName: string, result: var PayloadExecutionStatus) {.inline.} =
n.kind.expect(JString, argName)

View File

@ -33,16 +33,10 @@ type
finalizedBlockHash*: BlockHash
# https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.6/src/engine/specification.md#response-1
ForkchoiceUpdatedStatus* {.pure.} = enum
valid = "VALID"
invalid = "INVALID"
syncing = "SYNCING"
invalid_terminal_block = "INVALID_TERMINAL_BLOCK"
PayloadID* = FixedBytes[8]
ForkchoiceUpdatedResponse* = object
payloadStatus*: ForkchoiceUpdatedStatus
payloadStatus*: PayloadStatusV1
payloadId*: Option[PayloadID]
const