Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions eth_tester/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
from .main import (
EthereumTester,
)
from .rpc import (
run_server,
)

__version__ = __version("eth-tester")
58 changes: 58 additions & 0 deletions eth_tester/rpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from typing import (
List,
)

import click
from eth_typing import (
ChecksumAddress,
)
from jsonrpc import (
ASGIHandler,
)
import uvicorn

from eth_tester import (
EthereumTester,
)

app: ASGIHandler = ASGIHandler()

eth_tester = EthereumTester()


@app.dispatcher.register
async def get_accounts() -> List[ChecksumAddress]:
"""
Returns a list of accounts.
"""
return eth_tester.get_accounts()


@click.command()
@click.option(
"--host",
default="127.0.0.1",
show_default=True,
help="Host to run the server on.",
)
@click.option(
"--port",
default=5000,
show_default=True,
help="Port to run the server on.",
)
def run_server(host: str, port: int):
click.secho(f"Starting JSON-RPC server on {host}:{port}", fg="green", bold=True)

# List accounts
accounts_response = eth_tester.get_accounts()
click.secho("Accounts:", fg="yellow")
for account in accounts_response:
click.secho(account, fg="yellow")
click.secho("\n", fg="yellow")

uvicorn.run(app, host=host, port=port)


if __name__ == "__main__":
run_server()
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@
url="https://github.com/ethereum/eth-tester",
include_package_data=True,
install_requires=[
"click>=8.1.8",
"eth-abi>=3.0.1",
"eth-account>=0.12.3",
"eth-keys>=0.4.0",
"eth-utils>=2.0.0",
"jsonrpc-py>=5.6.0",
"rlp>=3.0.0",
"semantic_version>=2.6.0",
"uvicorn>=0.34.2",
],
extras_require=extras_require,
python_requires=">=3.8,<4",
Expand Down