0xSpaceShard / starknet-devnet-rs

A local testnet for Starknet... in Rust
https://0xspaceshard.github.io/starknet-devnet-rs/
MIT License
104 stars 60 forks source link

API unification - more widespread JSON-RPC API #463

Closed FabijanC closed 2 months ago

FabijanC commented 4 months ago

Currently Devnet has endpoints such as /mint, /dump, /load, etc. which aren't JSON-RPC based. Similar to how Devnet supports starknet_<METHOD_NAME> JSON-RPC methods, there could be devnet_<METHOD_NAME> methods such as devnet_mint> which would follow JSON-RPC semantics.

For the transition phase, let's keep both REST and JSON-RPC API. E.g. minting should, for now, be possible via both

POST /mint
{ "amount": ..., "address": ... }

and

POST /rpc
{ "method": "devnet_mint", "amount": ..., "address": ... }

And in the future we can just keep the RPC support.

Reference

Here's what Tenderly does: https://docs.tenderly.co/virtual-testnets/admin-rpc

mubarak23 commented 4 months ago

@FabijanC kindly assign this issue to me, i will like to work on it.

FabijanC commented 4 months ago

@mubarak23 Thanks for commenting, please wait until it is decided whose responsibility this should be.

FabijanC commented 4 months ago

@mubarak23 You've been assigned. Please note that the issue description has been updated.

MubarakCinderbuild commented 4 months ago

@FabijanC thank you.

i will take a bit of time to study the code and start working on the issue.

don't mind if you can point me to where is the best to start.

FabijanC commented 4 months ago

You can run Devnet in debug mode, send it a simple RPC request, and see which parts of the code it goes through. You could then see how to expand JsonRpcHandler to support all the Devnet-specific requests. Ideally, you would not use the StarknetRequest enumeration for these requests. Ideally, the RPC and REST endpoints would point to the same internal logic (e.g. only one minting logic implementation, but different endpoints using it).