Skip to content

Commit

Permalink
feature(rpc): add remaining anvil rpc methods to provider (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks authored Jun 6, 2024
1 parent 0b0bcf3 commit ebd72f1
Show file tree
Hide file tree
Showing 13 changed files with 983 additions and 33 deletions.
4 changes: 3 additions & 1 deletion crates/alloy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ alloy-pubsub = { workspace = true, default-features = false, optional = true }
# rpc
alloy-json-rpc = { workspace = true, default-features = false, optional = true }
alloy-rpc-client = { workspace = true, default-features = false, optional = true }
alloy-rpc-types-anvil = { workspace = true, default-features = false, optional = true }
alloy-rpc-types-beacon = { workspace = true, default-features = false, optional = true }
alloy-rpc-types-engine = { workspace = true, default-features = false, optional = true }
alloy-rpc-types-trace = { workspace = true, default-features = false, optional = true }
Expand Down Expand Up @@ -98,7 +99,7 @@ contract = ["dep:alloy-contract", "dyn-abi", "json-abi", "json", "sol-types"]
eips = ["dep:alloy-eips"]
genesis = ["dep:alloy-genesis"]
network = ["dep:alloy-network"]
node-bindings = ["dep:alloy-node-bindings", "alloy-provider?/anvil"]
node-bindings = ["dep:alloy-node-bindings", "alloy-provider?/anvil-node"]

# providers
providers = ["dep:alloy-provider"]
Expand All @@ -121,6 +122,7 @@ rpc-client = ["rpc", "dep:alloy-rpc-client"]
rpc-client-ws = ["rpc", "alloy-rpc-client?/ws"]
rpc-client-ipc = ["rpc", "alloy-rpc-client?/ipc"]
rpc-types = ["rpc"]
rpc-types-anvil = ["rpc-types", "dep:alloy-rpc-types-anvil"]
rpc-types-eth = ["rpc-types", "dep:alloy-rpc-types"]
rpc-types-beacon = ["rpc-types", "dep:alloy-rpc-types-beacon"]
rpc-types-engine = ["rpc-types", "dep:alloy-rpc-types-engine"]
Expand Down
8 changes: 6 additions & 2 deletions crates/alloy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ pub mod rpc {
/// Ethereum JSON-RPC type definitions.
#[cfg(feature = "rpc-types")]
pub mod types {
#[cfg(feature = "rpc-types-eth")]
#[cfg(feature = "rpc-types-anvil")]
#[doc(inline)]
pub use alloy_rpc_types as eth;
pub use alloy_rpc_types_anvil as anvil;

#[cfg(feature = "rpc-types-beacon")]
#[doc(inline)]
Expand All @@ -139,6 +139,10 @@ pub mod rpc {
#[doc(inline)]
pub use alloy_rpc_types_engine as engine;

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

#[cfg(feature = "rpc-types-trace")]
#[doc(inline)]
pub use alloy_rpc_types_trace as trace;
Expand Down
2 changes: 1 addition & 1 deletion crates/contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ alloy-pubsub = { workspace = true, optional = true }
alloy-rpc-client = { workspace = true, features = ["pubsub", "ws"] }
alloy-transport-http.workspace = true
alloy-node-bindings.workspace = true
alloy-provider = { workspace = true, features = ["anvil"] }
alloy-provider = { workspace = true, features = ["anvil-node"] }

reqwest.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
Expand Down
9 changes: 8 additions & 1 deletion crates/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ alloy-network.workspace = true
alloy-node-bindings = { workspace = true, optional = true }
alloy-signer-wallet = { workspace = true, optional = true }
alloy-rpc-client.workspace = true
alloy-rpc-types-anvil = { workspace = true, optional = true }
alloy-rpc-types-trace.workspace = true
alloy-rpc-types.workspace = true
alloy-rpc-types-engine = { workspace = true, optional = true }
Expand Down Expand Up @@ -77,5 +78,11 @@ ipc = ["pubsub", "alloy-rpc-client/ipc", "alloy-transport-ipc"]
reqwest-default-tls = ["alloy-transport-http?/reqwest-default-tls"]
reqwest-rustls-tls = ["alloy-transport-http?/reqwest-rustls-tls"]
reqwest-native-tls = ["alloy-transport-http?/reqwest-native-tls"]
anvil = ["reqwest", "dep:alloy-node-bindings", "dep:alloy-signer-wallet"]
anvil-api = ["dep:alloy-rpc-types-anvil"]
anvil-node = [
"anvil-api",
"reqwest",
"dep:alloy-node-bindings",
"dep:alloy-signer-wallet",
]
engine-api = ["dep:alloy-rpc-types-engine"]
2 changes: 1 addition & 1 deletion crates/provider/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl<L, F, N> ProviderBuilder<L, F, N> {

// Enabled when the `anvil` feature is enabled, or when both in test and the
// `reqwest` feature is enabled.
#[cfg(any(test, feature = "anvil"))]
#[cfg(any(test, feature = "anvil-node"))]
impl<L, F> ProviderBuilder<L, F, Ethereum> {
/// Build this provider with anvil, using an Reqwest HTTP transport.
pub fn on_anvil(self) -> F::Provider
Expand Down
Loading

0 comments on commit ebd72f1

Please sign in to comment.