diff --git a/research/fakeee.nim b/research/fakeee.nim index 57339c99d..41c0eab95 100644 --- a/research/fakeee.nim +++ b/research/fakeee.nim @@ -11,6 +11,7 @@ import std/typetraits, + stew/byteutils, json_rpc/[rpcserver, errors], web3/[conversions, engine_api_types], chronicles @@ -26,6 +27,14 @@ proc setupEngineAPI*(server: RpcServer) = status: PayloadExecutionStatus.syncing, ) + # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/shanghai.md#engine_newpayloadv2 + server.rpc("engine_newPayloadV2") do(payload: ExecutionPayloadV2) -> PayloadStatusV1: + info "engine_newPayloadV2", payload + + return PayloadStatusV1( + status: PayloadExecutionStatus.syncing, + ) + # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/paris.md#engine_getpayloadv1 server.rpc("engine_getPayloadV1") do(payloadId: PayloadID) -> ExecutionPayloadV1: info "engine_getPayloadV1", @@ -57,6 +66,36 @@ proc setupEngineAPI*(server: RpcServer) = payloadStatus: PayloadStatusV1( status: PayloadExecutionStatus.syncing)) + # https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/shanghai.md#engine_forkchoiceupdatedv2 + server.rpc("engine_forkchoiceUpdatedV2") do( + forkchoiceState: ForkchoiceStateV1, payloadAttributes: Option[PayloadAttributesV2]) -> ForkchoiceUpdatedResponse: + info "engine_forkchoiceUpdatedV2", + forkchoiceState, payloadAttributes + + return ForkchoiceUpdatedResponse( + payloadStatus: PayloadStatusV1( + status: PayloadExecutionStatus.syncing)) + + server.rpc("eth_getBlockByNumber") do( + quantityTag: string, fullTransactions: bool) -> JsonNode: + info "eth_getBlockByNumber", quantityTag, fullTransactions + + return if quantityTag == "latest": + %BlockObject(number: 1000.Quantity) + else: + newJObject() + + server.rpc("eth_getBlockByHash") do( + data: string, fullTransactions: bool) -> BlockObject: + info "eth_getBlockByHash", data = toHex(data), fullTransactions + + return BlockObject(number: 1000.Quantity) + + server.rpc("eth_chainId") do() -> Quantity: + info "eth_chainId" + + return 1.Quantity + when isMainModule: let server = newRpcHttpServer( # authHooks = @[httpJwtAuthHook, httpCorsHook], diff --git a/vendor/nim-web3 b/vendor/nim-web3 index c4fefea38..fcc7d7e8b 160000 --- a/vendor/nim-web3 +++ b/vendor/nim-web3 @@ -1 +1 @@ -Subproject commit c4fefea387303e88449339a3051a6779c7b4d226 +Subproject commit fcc7d7e8b18827e5ed0f89f55bbd0bb1081b85ae