fix vc api

This commit is contained in:
Agnish Ghosh 2024-10-31 11:53:29 +05:30
parent 51780ab5b0
commit be592e02fe
2 changed files with 50 additions and 1 deletions

View File

@ -26,7 +26,8 @@ type
bellatrix.SignedBeaconBlock | bellatrix.SignedBeaconBlock |
capella.SignedBeaconBlock | capella.SignedBeaconBlock |
DenebSignedBlockContents | DenebSignedBlockContents |
ElectraSignedBlockContents ElectraSignedBlockContents |
FuluSignedBlockContents
proc getGenesis*(): RestResponse[GetGenesisResponse] {. proc getGenesis*(): RestResponse[GetGenesisResponse] {.
rest, endpoint: "/eth/v1/beacon/genesis", rest, endpoint: "/eth/v1/beacon/genesis",
@ -163,6 +164,11 @@ proc publishBlock*(body: ElectraSignedBlockContents): RestPlainResponse {.
meth: MethodPost.} meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock
proc publishBlock*(body: FuluSignedBlockContents): RestPlainResponse {.
rest, endpoint: "/eth/v1/beacon/blocks",
meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock
proc publishSszBlock*( proc publishSszBlock*(
client: RestClientRef, client: RestClientRef,
blck: ForkySignedBeaconBlock blck: ForkySignedBeaconBlock
@ -217,6 +223,14 @@ proc publishBlockV2(
meth: MethodPost.} meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlockV2 ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlockV2
proc publishBlockV2(
broadcast_validation: Option[BroadcastValidationType],
body: FuluSignedBlockContents
): RestPlainResponse {.rest, endpoint: "/eth/v2/beacon/blocks",
meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlockV2
proc publishBlockV2*( proc publishBlockV2*(
client: RestClientRef, client: RestClientRef,
broadcast_validation: Option[BroadcastValidationType], broadcast_validation: Option[BroadcastValidationType],
@ -229,6 +243,8 @@ proc publishBlockV2*(
ConsensusFork.Deneb.toString() ConsensusFork.Deneb.toString()
elif blck is ElectraSignedBlockContents: elif blck is ElectraSignedBlockContents:
ConsensusFork.Electra.toString() ConsensusFork.Electra.toString()
elif blck is FuluSignedBlockContents:
ConsensusFork.Fulu.toString()
else: else:
typeof(blck).kind.toString() typeof(blck).kind.toString()
client.publishBlockV2( client.publishBlockV2(
@ -248,6 +264,8 @@ proc publishSszBlockV2*(
ConsensusFork.Deneb.toString() ConsensusFork.Deneb.toString()
elif blck is ElectraSignedBlockContents: elif blck is ElectraSignedBlockContents:
ConsensusFork.Electra.toString() ConsensusFork.Electra.toString()
elif blck is FuluSignedBlockContents:
ConsensusFork.Fulu.toString()
else: else:
typeof(blck).kind.toString() typeof(blck).kind.toString()
client.publishBlockV2( client.publishBlockV2(
@ -290,6 +308,12 @@ proc publishBlindedBlock*(body: electra_mev.SignedBlindedBeaconBlock):
meth: MethodPost.} meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock
proc publishBlindedBlock*(body: fulu_mev.SignedBlindedBeaconBlock):
RestPlainResponse {.
rest, endpoint: "/eth/v1/beacon/blinded_blocks",
meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock
proc publishSszBlindedBlock*( proc publishSszBlindedBlock*(
client: RestClientRef, client: RestClientRef,
blck: ForkySignedBeaconBlock blck: ForkySignedBeaconBlock
@ -344,6 +368,13 @@ proc publishBlindedBlockV2*(
meth: MethodPost.} meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock ## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock
proc publishBlindedBlockV2*(
broadcast_validation: Option[BroadcastValidationType],
body: fulu_mev.SignedBlindedBeaconBlock
): RestPlainResponse {.rest, endpoint: "/eth/v2/beacon/blinded_blocks",
meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlindedBlock
proc publishBlindedBlockV2*( proc publishBlindedBlockV2*(
client: RestClientRef, client: RestClientRef,
broadcast_validation: Option[BroadcastValidationType], broadcast_validation: Option[BroadcastValidationType],

View File

@ -2511,6 +2511,8 @@ proc publishBlockV2*(
publishBlockV2(it, some(broadcast_validation), data.denebData) publishBlockV2(it, some(broadcast_validation), data.denebData)
of ConsensusFork.Electra: of ConsensusFork.Electra:
publishBlockV2(it, some(broadcast_validation), data.electraData) publishBlockV2(it, some(broadcast_validation), data.electraData)
of ConsensusFork.Fulu:
publishBlockV2(it, some(broadcast_validation), data.fuluData)
do: do:
if apiResponse.isErr(): if apiResponse.isErr():
handleCommunicationError() handleCommunicationError()
@ -2562,6 +2564,8 @@ proc publishBlockV2*(
publishBlockV2(it, some(broadcast_validation), data.denebData) publishBlockV2(it, some(broadcast_validation), data.denebData)
of ConsensusFork.Electra: of ConsensusFork.Electra:
publishBlockV2(it, some(broadcast_validation), data.electraData) publishBlockV2(it, some(broadcast_validation), data.electraData)
of ConsensusFork.Fulu:
publishBlockV2(it, some(broadcast_validation), data.fuluData)
do: do:
if apiResponse.isErr(): if apiResponse.isErr():
@ -2627,6 +2631,8 @@ proc publishBlock*(
publishBlock(it, data.denebData) publishBlock(it, data.denebData)
of ConsensusFork.Electra: of ConsensusFork.Electra:
publishBlock(it, data.electraData) publishBlock(it, data.electraData)
of ConsensusFork.Fulu:
publishBlock(it, data.fuluData)
do: do:
if apiResponse.isErr(): if apiResponse.isErr():
handleCommunicationError() handleCommunicationError()
@ -2675,6 +2681,8 @@ proc publishBlock*(
publishBlock(it, data.denebData) publishBlock(it, data.denebData)
of ConsensusFork.Electra: of ConsensusFork.Electra:
publishBlock(it, data.electraData) publishBlock(it, data.electraData)
of ConsensusFork.Fulu:
publishBlock(it, data.fuluData)
do: do:
if apiResponse.isErr(): if apiResponse.isErr():
@ -2841,6 +2849,9 @@ proc publishBlindedBlockV2*(
of ConsensusFork.Electra: of ConsensusFork.Electra:
publishBlindedBlockV2(it, some(broadcast_validation), publishBlindedBlockV2(it, some(broadcast_validation),
data.electraData) data.electraData)
of ConsensusFork.Fulu:
publishBlindedBlockV2(it, some(broadcast_validation),
data.fuluData)
do: do:
if apiResponse.isErr(): if apiResponse.isErr():
handleCommunicationError() handleCommunicationError()
@ -2897,6 +2908,9 @@ proc publishBlindedBlockV2*(
of ConsensusFork.Electra: of ConsensusFork.Electra:
publishBlindedBlockV2(it, some(broadcast_validation), publishBlindedBlockV2(it, some(broadcast_validation),
data.electraData) data.electraData)
of ConsensusFork.Fulu:
publishBlindedBlockV2(it, some(broadcast_validation),
data.fuluData)
do: do:
if apiResponse.isErr(): if apiResponse.isErr():
handleCommunicationError() handleCommunicationError()
@ -2960,6 +2974,8 @@ proc publishBlindedBlock*(
publishBlindedBlock(it, data.denebData) publishBlindedBlock(it, data.denebData)
of ConsensusFork.Electra: of ConsensusFork.Electra:
publishBlindedBlock(it, data.electraData) publishBlindedBlock(it, data.electraData)
of ConsensusFork.Fulu:
publishBlindedBlock(it, data.fuluData)
do: do:
if apiResponse.isErr(): if apiResponse.isErr():
handleCommunicationError() handleCommunicationError()
@ -3007,6 +3023,8 @@ proc publishBlindedBlock*(
publishBlindedBlock(it, data.denebData) publishBlindedBlock(it, data.denebData)
of ConsensusFork.Electra: of ConsensusFork.Electra:
publishBlindedBlock(it, data.electraData) publishBlindedBlock(it, data.electraData)
of ConsensusFork.Fulu:
publishBlindedBlock(it, data.fuluData)
do: do:
if apiResponse.isErr(): if apiResponse.isErr():
handleCommunicationError() handleCommunicationError()