Skip to content

Commit

Permalink
feat(rpc/v06): re-enable v06 routes
Browse files Browse the repository at this point in the history
  • Loading branch information
t00ts committed Jan 31, 2025
1 parent 462ef70 commit 7572d70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 35 deletions.
7 changes: 7 additions & 0 deletions crates/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod pending;
#[cfg(test)]
mod test_setup;
pub mod types;
pub mod v06;
pub mod v07;
pub mod v08;

Expand Down Expand Up @@ -43,6 +44,7 @@ const DEFAULT_MAX_CONNECTIONS: usize = 1024;

#[derive(Copy, Clone, Debug, Default, PartialEq, PartialOrd)]
pub enum RpcVersion {
V06,
#[default]
V07,
V08,
Expand All @@ -52,6 +54,7 @@ pub enum RpcVersion {
impl RpcVersion {
fn to_str(self) -> &'static str {
match self {
RpcVersion::V06 => "v0.6",
RpcVersion::V07 => "v0.7",
RpcVersion::V08 => "v0.8",
RpcVersion::PathfinderV01 => "v0.1",
Expand Down Expand Up @@ -161,11 +164,13 @@ impl RpcServer {
}
}

let v06_routes = v06::register_routes().build(self.context.clone());
let v07_routes = v07::register_routes().build(self.context.clone());
let v08_routes = v08::register_routes().build(self.context.clone());
let pathfinder_routes = pathfinder::register_routes().build(self.context.clone());

let default_router = match self.default_version {
RpcVersion::V06 => v06_routes.clone(),
RpcVersion::V07 => v07_routes.clone(),
RpcVersion::V08 => v08_routes.clone(),
RpcVersion::PathfinderV01 => {
Expand All @@ -178,6 +183,8 @@ impl RpcServer {
// used by monitoring bots to check service health.
.route("/", get(empty_body).post(rpc_handler))
.with_state(default_router.clone())
.route("/rpc/v0_6", post(rpc_handler))
.with_state(v06_routes.clone())
.route("/rpc/v0_7", post(rpc_handler))
.with_state(v07_routes.clone())
// TODO Uncomment once RPC 0.8 is ready.
Expand Down
40 changes: 5 additions & 35 deletions crates/rpc/src/v06.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
use crate::jsonrpc::{RpcRouter, RpcRouterBuilder};

pub(crate) mod method;
pub(crate) mod types;

#[rustfmt::skip]
pub fn register_routes() -> RpcRouterBuilder {
RpcRouter::builder(crate::RpcVersion::V06)
.register("starknet_blockHashAndNumber" , crate::method::block_hash_and_number)
.register("starknet_blockNumber" , crate::method::block_number)
.register("starknet_chainId" , crate::method::chain_id)
.register("starknet_getBlockTransactionCount" , crate::method::get_block_transaction_count)
.register("starknet_getClass" , crate::method::get_class)
.register("starknet_getClassAt" , crate::method::get_class_at)
.register("starknet_getClassHashAt" , crate::method::get_class_hash_at)
.register("starknet_getNonce" , crate::method::get_nonce)
.register("starknet_getStorageAt" , crate::method::get_storage_at)

.register("starknet_getEvents" , crate::method::get_events)
.register("starknet_getStateUpdate" , crate::method::get_state_update)

.register("starknet_syncing" , method::syncing)
.register("starknet_getTransactionStatus" , method::get_transaction_status)
.register("starknet_call" , method::call)
.register("starknet_addDeclareTransaction" , method::add_declare_transaction)
.register("starknet_addDeployAccountTransaction" , method::add_deploy_account_transaction)
.register("starknet_addInvokeTransaction" , method::add_invoke_transaction)
.register("starknet_estimateFee" , method::estimate_fee)
.register("starknet_estimateMessageFee" , method::estimate_message_fee)
.register("starknet_getBlockWithTxHashes" , method::get_block_with_tx_hashes)
.register("starknet_getBlockWithTxs" , method::get_block_with_txs)
.register("starknet_getTransactionByBlockIdAndIndex" , method::get_transaction_by_block_id_and_index)
.register("starknet_getTransactionByHash" , crate::method::get_transaction_by_hash)
.register("starknet_getTransactionReceipt" , method::get_transaction_receipt)
.register("starknet_simulateTransactions" , method::simulate_transactions)
.register("starknet_specVersion" , || "0.6.0")
.register("starknet_traceBlockTransactions" , method::trace_block_transactions)
.register("starknet_traceTransaction" , method::trace_transaction)

.register("pathfinder_getProof" , crate::pathfinder::methods::get_proof)
.register("starknet_blockNumber", crate::method::block_number)
.register("starknet_chainId", crate::method::chain_id)
.register("starknet_getBlockTransactionCount", crate::method::get_block_transaction_count)
.register("starknet_getNonce", crate::method::get_nonce)
.register("starknet_getStorageAt", crate::method::get_storage_at)
}

0 comments on commit 7572d70

Please sign in to comment.