diff --git a/hrotti/main.py b/hrotti/main.py index cad5cc2..de98288 100644 --- a/hrotti/main.py +++ b/hrotti/main.py @@ -1,22 +1,14 @@ import json from fastapi import FastAPI, WebSocket -from pydantic import BaseModel +from .methods import RPCRequest, handle_request app = FastAPI() -class RPCRequest(BaseModel): - jsonrpc: str - method: str - params: list - id: int - - -@app.post("/jsonrpc") +@app.post("/http") async def handle_json_rpc(request: RPCRequest): - if request.method == "eth_blockNumber": - return {"jsonrpc": "2.0", "id": request.id, "result": "0x5BAD55"} + return handle_request(request) @app.websocket("/ws") diff --git a/hrotti/methods.py b/hrotti/methods.py new file mode 100644 index 0000000..4911a6e --- /dev/null +++ b/hrotti/methods.py @@ -0,0 +1,12 @@ +from pydantic import BaseModel + + +class RPCRequest(BaseModel): + jsonrpc: str + method: str + params: list + id: int + + +def handle_request(request: RPCRequest): + pass