Remove deprecated REST API calls from client (#4190)

* https://github.com/ethereum/beacon-APIs/pull/220
* https://github.com/ethereum/beacon-APIs/pull/218
This commit is contained in:
Jacek Sieka 2022-09-28 12:37:54 +02:00 committed by GitHub
parent 57d68d0f72
commit c11b30f8e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 95 deletions

View File

@ -116,45 +116,6 @@ proc publishBlock*(body: bellatrix.SignedBeaconBlock): RestPlainResponse {.
meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/publishBlock
proc getBlockPlain*(block_id: BlockIdent): RestPlainResponse {.
rest, endpoint: "/eth/v1/beacon/blocks/{block_id}",
accept: preferSSZ,
meth: MethodGet.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/getBlock
proc getBlock*(client: RestClientRef, block_id: BlockIdent,
restAccept = ""): Future[ForkedSignedBeaconBlock] {.async.} =
let resp =
if len(restAccept) > 0:
await client.getBlockPlain(block_id, restAcceptType = restAccept)
else:
await client.getBlockPlain(block_id)
let data =
case resp.status
of 200:
if resp.contentType.isNone() or
isWildCard(resp.contentType.get().mediaType):
raise newException(RestError, "Missing or incorrect Content-Type")
else:
let mediaType = resp.contentType.get().mediaType
if mediaType == ApplicationJsonMediaType:
let blck = decodeBytes(GetBlockResponse, resp.data,
resp.contentType).valueOr:
raise newException(RestError, $error)
ForkedSignedBeaconBlock.init(blck.data)
elif mediaType == OctetStreamMediaType:
let blck = decodeBytes(GetPhase0BlockSszResponse, resp.data,
resp.contentType).valueOr:
raise newException(RestError, $error)
ForkedSignedBeaconBlock.init(blck)
else:
raise newException(RestError, "Unsupported Content-Type")
of 400, 404, 500:
raiseGenericError(resp)
else:
raiseUnknownStatusError(resp)
return data
proc getBlockV2Plain*(block_id: BlockIdent): RestPlainResponse {.
rest, endpoint: "/eth/v2/beacon/blocks/{block_id}",
accept: preferSSZ,

View File

@ -16,55 +16,6 @@ import
export chronos, client, rest_types, eth2_rest_serialization
proc getStatePlain*(state_id: StateIdent): RestPlainResponse {.
rest, endpoint: "/eth/v1/debug/beacon/states/{state_id}",
accept: preferSSZ,
meth: MethodGet.}
## https://ethereum.github.io/beacon-APIs/#/Beacon/getState
proc getState*(client: RestClientRef, state_id: StateIdent,
restAccept = ""): Future[phase0.BeaconState] {.async.} =
let resp =
if len(restAccept) > 0:
await client.getStatePlain(state_id, restAcceptType = restAccept)
else:
await client.getStatePlain(state_id)
let data =
case resp.status
of 200:
if resp.contentType.isNone() or
isWildCard(resp.contentType.get().mediaType):
raise newException(RestError, "Missing or incorrect Content-Type")
else:
let mediaType = resp.contentType.get().mediaType
if mediaType == ApplicationJsonMediaType:
let state = decodeBytes(GetStateResponse, resp.data,
resp.contentType).valueOr:
raise newException(RestError, $error)
state.data
elif mediaType == OctetStreamMediaType:
let state = decodeBytes(GetPhase0StateSszResponse, resp.data,
resp.contentType).valueOr:
raise newException(RestError, $error)
state
else:
raise newException(RestError, "Unsupported content-type")
of 400, 404, 500:
let error =
block:
let res = decodeBytes(RestGenericError, resp.data, resp.contentType)
if res.isErr():
let msg = "Incorrect response error format (" & $resp.status &
") [" & $res.error() & "]"
raise newException(RestError, msg)
res.get()
let msg = "Error response (" & $resp.status & ") [" & error.message & "]"
raise newException(RestError, msg)
else:
let msg = "Unknown response status error (" & $resp.status & ")"
raise newException(RestError, msg)
return data
proc getDebugChainHeads*(): RestResponse[GetDebugChainHeadsResponse] {.
rest, endpoint: "/eth/v1/debug/beacon/heads",
meth: MethodGet.}

View File

@ -34,13 +34,6 @@ proc getSyncCommitteeDuties*(epoch: Epoch,
meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Validator/getSyncCommitteeDuties
proc produceBlock*(slot: Slot, randao_reveal: ValidatorSig,
graffiti: GraffitiBytes
): RestResponse[ProduceBlockResponse] {.
rest, endpoint: "/eth/v1/validator/blocks/{slot}",
meth: MethodGet.}
## https://ethereum.github.io/beacon-APIs/#/Validator/produceBlock
proc produceBlockV2*(slot: Slot, randao_reveal: ValidatorSig,
graffiti: GraffitiBytes
): RestResponse[ProduceBlockResponseV2] {.