Skip to content

Commit

Permalink
Remove deprecated REST API calls from client (#4190)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck authored Sep 28, 2022
1 parent 57d68d0 commit c11b30f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 95 deletions.
39 changes: 0 additions & 39 deletions beacon_chain/spec/eth2_apis/rest_beacon_calls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
49 changes: 0 additions & 49 deletions beacon_chain/spec/eth2_apis/rest_debug_calls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.}
Expand Down
7 changes: 0 additions & 7 deletions beacon_chain/spec/eth2_apis/rest_validator_calls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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] {.
Expand Down

0 comments on commit c11b30f

Please sign in to comment.