Skip to content

Commit

Permalink
modules
Browse files Browse the repository at this point in the history
  • Loading branch information
makemake-kbo committed Jan 1, 2024
1 parent 1930d60 commit 67c85b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
14 changes: 3 additions & 11 deletions hrotti/main.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
12 changes: 12 additions & 0 deletions hrotti/methods.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 67c85b2

Please sign in to comment.