-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rpc-client): Introduce rpc-jsonrpsee Crate (#37)
* feat(rpc-client): Introduce rpc-client crate * fix(rpc-client): jsonrpsee dep * fix(rpc-jsonrpsee): crate rename * fix(rpc-jsonrpsee): crate rename * fix(rpc-jsonrpsee): crate rename * fix(rpc-types): lints * fix(rpc-types): jsonrpsee dep * fix(rpc-jsonrpsee): exclude in github actions
- Loading branch information
Showing
8 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "op-alloy-rpc-jsonrpsee" | ||
description = "Optimism RPC Client" | ||
|
||
version.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
authors.workspace = true | ||
repository.workspace = true | ||
exclude.workspace = true | ||
|
||
[dependencies] | ||
# Alloy | ||
op-alloy-rpc-types.workspace = true | ||
alloy-eips.workspace = true | ||
|
||
# rpc | ||
jsonrpsee.workspace = true | ||
|
||
[features] | ||
client = [ | ||
"jsonrpsee/client", | ||
"jsonrpsee/async-client", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# op-alloy-rpc-jsonrpsee | ||
|
||
Low-level Optimism JSON-RPC server and client implementations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![doc = include_str!("../README.md")] | ||
#![doc( | ||
html_logo_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/alloy.jpg", | ||
html_favicon_url = "https://raw.githubusercontent.com/alloy-rs/core/main/assets/favicon.ico" | ||
)] | ||
#![warn( | ||
missing_copy_implementations, | ||
missing_debug_implementations, | ||
missing_docs, | ||
unreachable_pub, | ||
clippy::missing_const_for_fn, | ||
rustdoc::all | ||
)] | ||
#![deny(unused_must_use, rust_2018_idioms)] | ||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] | ||
#![cfg_attr(not(test), warn(unused_crate_dependencies))] | ||
|
||
pub mod traits; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//! Rollup Node | ||
use alloy_eips::BlockNumberOrTag; | ||
use jsonrpsee::{core::RpcResult, proc_macros::rpc}; | ||
use op_alloy_rpc_types::{config::RollupConfig, output::OutputResponse, sync::SyncStatus}; | ||
|
||
/// Optimism specified rpc interface. | ||
/// | ||
/// https://docs.optimism.io/builders/node-operators/json-rpc | ||
/// https://github.com/ethereum-optimism/optimism/blob/8dd17a7b114a7c25505cd2e15ce4e3d0f7e3f7c1/op-node/node/api.go#L114 | ||
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "optimism"))] | ||
#[cfg_attr(feature = "client", rpc(server, client, namespace = "optimism"))] | ||
pub trait RollupNode { | ||
/// Get the output root at a specific block. | ||
#[method(name = "outputAtBlock")] | ||
async fn op_output_at_block(&self, block_number: BlockNumberOrTag) | ||
-> RpcResult<OutputResponse>; | ||
|
||
/// Get the synchronization status. | ||
#[method(name = "syncStatus")] | ||
async fn op_sync_status(&self) -> RpcResult<SyncStatus>; | ||
|
||
/// Get the rollup configuration parameters. | ||
#[method(name = "rollupConfig")] | ||
async fn op_rollup_config(&self) -> RpcResult<RollupConfig>; | ||
|
||
/// Get the software version. | ||
#[method(name = "version")] | ||
async fn op_version(&self) -> RpcResult<String>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//! Output Types | ||
use crate::sync::{L2BlockRef, SyncStatus}; | ||
use alloy_primitives::B256; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// An [output response][or] for Optimism Rollup. | ||
/// | ||
/// [or]: https://github.com/ethereum-optimism/optimism/blob/f20b92d3eb379355c876502c4f28e72a91ab902f/op-service/eth/output.go#L10-L17 | ||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct OutputResponse { | ||
/// The output version. | ||
pub version: B256, | ||
/// The output root hash. | ||
pub output_root: B256, | ||
/// A reference to the L2 block. | ||
pub block_ref: L2BlockRef, | ||
/// The withdrawal storage root. | ||
pub withdrawal_storage_root: B256, | ||
/// The state root. | ||
pub state_root: B256, | ||
/// The status of the node sync. | ||
pub sync_status: SyncStatus, | ||
} |