Skip to content

Commit

Permalink
feat: op-alloy meta crate (#210)
Browse files Browse the repository at this point in the history
### Description

Introduces a meta crate like `alloy` that re-exports all `op-alloy-*`
crates behind respective feature flags.
  • Loading branch information
refcell authored Nov 1, 2024
1 parent 5fb9293 commit 1f5686d
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ rustdoc-args = ["--cfg", "docsrs"]
op-alloy-genesis = { version = "0.5.2", path = "crates/genesis", default-features = false }
op-alloy-protocol = { version = "0.5.2", path = "crates/protocol", default-features = false }
op-alloy-consensus = { version = "0.5.2", path = "crates/consensus", default-features = false }
op-alloy-network = { version = "0.5.2", path = "crates/network", default-features = false }
op-alloy-provider = { version = "0.5.2", path = "crates/provider", default-features = false }
op-alloy-rpc-types = { version = "0.5.2", path = "crates/rpc-types", default-features = false }
op-alloy-rpc-jsonrpsee = { version = "0.5.2", path = "crates/rpc-jsonrpsee", default-features = false }
op-alloy-rpc-types-engine = { version = "0.5.2", path = "crates/rpc-types-engine", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fmt-native-check:

# Lint the Rust documentation
lint-docs:
RUSTDOCFLAGS="-D warnings" cargo doc --all --no-deps --document-private-items
RUSTDOCFLAGS="-D warnings" cargo doc --all --no-deps --document-private-items

# Fixes the formatting of the workspace
fmtf:
Expand All @@ -45,4 +45,4 @@ build *args='':

# Runs `cargo hack check` against the workspace
hack:
cargo hack check --feature-powerset --no-dev-deps
cargo hack check --feature-powerset --no-dev-deps --exclude op-alloy
83 changes: 83 additions & 0 deletions crates/op-alloy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[package]
name = "op-alloy"
description = "Connect applications to the OP Stack"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
exclude.workspace = true

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints]
workspace = true

[dependencies]
# Workspace
op-alloy-consensus = { workspace = true, optional = true }
op-alloy-genesis = { workspace = true, optional = true }
op-alloy-network = { workspace = true, optional = true }
op-alloy-protocol = { workspace = true, optional = true }
op-alloy-provider = { workspace = true, optional = true }
op-alloy-rpc-jsonrpsee = { workspace = true, optional = true }
op-alloy-rpc-types-engine = { workspace = true, optional = true }
op-alloy-rpc-types = { workspace = true, optional = true }

[features]
default = ["std", "k256", "serde"]

std = [
"op-alloy-consensus?/std",
"op-alloy-genesis?/std",
"op-alloy-protocol?/std",
"op-alloy-rpc-types?/std",
"op-alloy-rpc-types-engine?/std",
]

full = [
"consensus",
"genesis",
"provider",
"network",
"protocol",
"rpc-types",
"rpc-types-engine",
"rpc-jsonrpsee",
]

k256 = [
"op-alloy-consensus?/k256",
]

arbitrary = [
"op-alloy-consensus?/arbitrary",
"op-alloy-genesis?/arbitrary",
"op-alloy-protocol?/arbitrary",
"op-alloy-rpc-types?/arbitrary",
"op-alloy-rpc-types-engine?/arbitrary",
]

serde = [
"op-alloy-consensus?/serde",
"op-alloy-genesis?/serde",
"op-alloy-protocol?/serde",
"op-alloy-rpc-types-engine?/serde",
]

# `no_std` support
consensus = ["dep:op-alloy-consensus"]
genesis = ["dep:op-alloy-genesis"]
protocol = ["dep:op-alloy-protocol"]
rpc-types = ["dep:op-alloy-rpc-types"]
rpc-types-engine = ["dep:op-alloy-rpc-types-engine"]

# std features
provider = ["dep:op-alloy-provider"]
network = ["dep:op-alloy-network"]
rpc-jsonrpsee = ["dep:op-alloy-rpc-jsonrpsee"]

1 change: 1 addition & 0 deletions crates/op-alloy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../README.md
39 changes: 39 additions & 0 deletions crates/op-alloy/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#![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"
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

#[cfg(feature = "consensus")]
#[doc(inline)]
pub use op_alloy_consensus as consensus;

#[cfg(feature = "genesis")]
#[doc(inline)]
pub use op_alloy_genesis as genesis;

#[cfg(feature = "network")]
#[doc(inline)]
pub use op_alloy_network as network;

#[cfg(feature = "protocol")]
#[doc(inline)]
pub use op_alloy_protocol as protocol;

#[cfg(feature = "provider")]
#[doc(inline)]
pub use op_alloy_provider as provider;

#[cfg(feature = "rpc-types")]
#[doc(inline)]
pub use op_alloy_rpc_types as rpc_types;

#[cfg(feature = "rpc-types-engine")]
#[doc(inline)]
pub use op_alloy_rpc_types_engine as rpc_types_engine;

#[cfg(feature = "rpc-jsonrpsee")]
#[doc(inline)]
pub use op_alloy_rpc_jsonrpsee as rpc_jsonrpsee;

0 comments on commit 1f5686d

Please sign in to comment.