Sitelet https://github.com/SharkHand3/examples/commit/2f109ec5dd66da586e2006e74061d6e19f3ee9b2
Skip to content

Commit 2f109ec

Browse files
authored
[Debt] Improve alloy prelude crate exports and defaults (alloy-rs#39)
* only import what is necessary * repoint branch, still works after refactor * repoint crate * use modified core * fix upstream regression * remove patches * fix link, do not use fork
1 parent 49c40da commit 2f109ec

11 files changed

Lines changed: 50 additions & 99 deletions

File tree

‎.github/workflows/integration.yml‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,10 @@ jobs:
5454
| grep refs/heads/main \
5555
| cut -f 1)
5656
57-
# Fetch the latest commit hash of the `main` branch from the Alloy Core repository
58-
export latest_alloy_core_commit=$(git ls-remote https://github.com/alloy-rs/core.git \
59-
| grep refs/heads/main \
60-
| cut -f 1)
61-
6257
# Use the commit hash to update the rev in Cargo.toml
6358
sed -i 's/\(alloy = { git = "https:\/\/github.com\/alloy-rs\/alloy", rev = "\)[^"]*/\1'"$latest_alloy_commit"'/' \
6459
Cargo.toml
6560
66-
# Temporary patch until https://github.com/alloy-rs/alloy/pull/392 is resolved
67-
sed -i 's/\(alloy-rpc-client = { git = "https:\/\/github.com\/alloy-rs\/alloy", rev = "\)[^"]*/\1'"$latest_alloy_commit"'/' \
68-
examples/providers/Cargo.toml
69-
sed -i 's/\(alloy-provider = { git = "https:\/\/github.com\/alloy-rs\/alloy", rev = "\)[^"]*/\1'"$latest_alloy_commit"'/' \
70-
examples/providers/Cargo.toml
71-
sed -i 's/\(alloy-rpc-client = { git = "https:\/\/github.com\/alloy-rs\/alloy", rev = "\)[^"]*/\1'"$latest_alloy_commit"'/' \
72-
examples/subscriptions/Cargo.toml
73-
sed -i 's/\(alloy-provider = { git = "https:\/\/github.com\/alloy-rs\/alloy", rev = "\)[^"]*/\1'"$latest_alloy_commit"'/' \
74-
examples/subscriptions/Cargo.toml
75-
7661
# Update to the latest commit
7762
cargo update
7863

‎Cargo.toml‎

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,41 +81,26 @@ unnecessary_struct_initialization = "allow"
8181
use_self = "allow"
8282

8383
[workspace.dependencies]
84-
alloy = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
85-
# "dyn-abi",
86-
# "json-abi",
87-
# "json",
88-
"sol-types",
89-
# "rlp",
90-
# "serde",
84+
alloy = { git = "https://github.com/alloy-rs/alloy", rev = "27d5ba9", features = [
9185
"contract",
92-
# "consensus",
93-
# "eips",
9486
"network",
95-
# "genesis",
9687
"node-bindings",
9788
"providers",
98-
"rpc",
99-
# "json-rpc",
89+
"provider-http",
90+
"provider-ipc",
91+
"provider-ws",
10092
"rpc-client",
101-
# "rpc-types",
93+
"rpc-client-ipc",
94+
"rpc-client-ws",
10295
"rpc-types-eth",
103-
# "rpc-types-engine",
10496
"rpc-types-trace",
10597
"signers",
106-
# "signer-aws",
107-
# "signer-gcp",
10898
"signer-keystore",
10999
"signer-ledger",
110100
"signer-mnemonic",
111101
"signer-trezor",
112102
"signer-wallet",
113103
"signer-yubihsm",
114-
"transports",
115-
"transport-http",
116-
"transport-ipc",
117-
"transport-ws",
118-
"pubsub",
119104
] }
120105

121106
# async

‎examples/providers/Cargo.toml‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,7 @@ workspace = true
1414

1515
[dev-dependencies]
1616
alloy.workspace = true
17-
# Temp dependency fix to enable relevant features - Ref: https://github.com/alloy-rs/examples/pull/3#discussion_r1537842062
18-
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
19-
"pubsub",
20-
"ipc",
21-
"ws",
22-
] }
23-
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
24-
"pubsub",
25-
"ws",
26-
"ipc",
27-
] }
2817

29-
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af" }
30-
31-
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af" }
32-
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af" }
3318
eyre.workspace = true
3419
futures-util = "0.3"
3520
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

‎examples/providers/examples/connect_builtin.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
//! Example of using the `RootProvider<N, T: BoxTransport>::connect_builtin` to create a provider
22
//! from a connection string. The connection string can be a HTTP, WS or IPC endpoint.
33
4-
use alloy::node_bindings::Anvil;
5-
use alloy_network::Ethereum;
6-
use alloy_provider::{Provider, RootProvider};
7-
use alloy_transport::BoxTransport;
4+
use alloy::{
5+
network::Ethereum,
6+
node_bindings::Anvil,
7+
providers::{Provider, RootProvider},
8+
transports::BoxTransport,
9+
};
810
use eyre::Result;
911
use futures_util::StreamExt;
1012

‎examples/providers/examples/ipc.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
//! Example of using the IPC provider to get the latest block number.
22
3-
use alloy_network::Ethereum;
4-
use alloy_provider::{Provider, RootProvider};
5-
use alloy_rpc_client::RpcClient;
6-
use alloy_transport_ipc::IpcConnect;
3+
use alloy::{
4+
network::Ethereum,
5+
providers::{Provider, RootProvider},
6+
rpc::client::RpcClient,
7+
transports::ipc::IpcConnect,
8+
};
79
use eyre::Result;
810

911
#[tokio::main]

‎examples/providers/examples/ws.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Example of using the WS provider to subscribe to new blocks.
22
3-
// Temp Fix
4-
use alloy_network::Ethereum;
5-
use alloy_provider::{Provider, RootProvider};
6-
use alloy_rpc_client::{RpcClient, WsConnect};
7-
//
3+
use alloy::{
4+
network::Ethereum,
5+
providers::{Provider, RootProvider},
6+
rpc::client::{RpcClient, WsConnect},
7+
};
88
use eyre::Result;
99
use futures_util::StreamExt;
1010

‎examples/providers/examples/ws_with_auth.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Example of using the WS provider with auth to subscribe to new blocks.
22
3-
// Temp Fix
4-
use alloy_network::Ethereum;
5-
use alloy_provider::{Provider, RootProvider};
6-
use alloy_rpc_client::{RpcClient, WsConnect};
7-
use alloy_transport::Authorization;
8-
//
3+
use alloy::{
4+
network::Ethereum,
5+
providers::{Provider, RootProvider},
6+
rpc::client::{RpcClient, WsConnect},
7+
transports::Authorization,
8+
};
99
use eyre::Result;
1010
use futures_util::StreamExt;
1111

‎examples/subscriptions/Cargo.toml‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,6 @@ workspace = true
1414

1515
[dev-dependencies]
1616
alloy.workspace = true
17-
# Temp fix for enabling features. Ref: https://github.com/alloy-rs/examples/pull/3/#discussion_r1537842062
18-
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
19-
"pubsub",
20-
"ws",
21-
] }
22-
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
23-
"pubsub",
24-
] }
25-
# alloy-contract.workspace = true
26-
# alloy-network.workspace = true
27-
# alloy-node-bindings.workspace = true
28-
# alloy-provider = { workspace = true, features = ["pubsub", "ws"] }
29-
# alloy-pubsub.workspace = true
30-
# alloy-primitives.workspace = true
31-
# alloy-rpc-client.workspace = true
32-
# alloy-rpc-types.workspace = true
33-
# alloy-sol-types = { workspace = true }
3417

3518
eyre.workspace = true
3619
futures-util = "0.3"

‎examples/subscriptions/examples/event_multiplexer.rs‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
//! Example of multiplexing the watching of event logs.
22
3-
use alloy::{node_bindings::Anvil, primitives::I256, sol, sol_types::SolEvent};
4-
use alloy_provider::ProviderBuilder;
5-
use alloy_rpc_client::{RpcClient, WsConnect};
3+
use alloy::{
4+
node_bindings::Anvil,
5+
primitives::I256,
6+
providers::ProviderBuilder,
7+
rpc::client::{RpcClient, WsConnect},
8+
sol,
9+
sol_types::SolEvent,
10+
};
611
use eyre::Result;
712
use futures_util::StreamExt;
813
use std::str::FromStr;

‎examples/subscriptions/examples/subscribe_blocks.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
//! Example of subscribing to blocks and watching block headers by polling.
22
3-
use alloy::node_bindings::Anvil;
4-
use alloy_provider::{Provider, ProviderBuilder};
5-
use alloy_rpc_client::RpcClient;
3+
use alloy::{
4+
node_bindings::Anvil,
5+
providers::{Provider, ProviderBuilder},
6+
rpc::client::{RpcClient, WsConnect},
7+
};
68
use eyre::Result;
79
use futures_util::{stream, StreamExt};
810

@@ -13,7 +15,7 @@ async fn main() -> Result<()> {
1315
let anvil = Anvil::new().block_time(1).try_spawn()?;
1416

1517
// Create a provider.
16-
let ws = alloy_rpc_client::WsConnect::new(anvil.ws_endpoint());
18+
let ws = WsConnect::new(anvil.ws_endpoint());
1719
let provider = ProviderBuilder::new().on_client(RpcClient::connect_pubsub(ws).await?);
1820

1921
// Subscribe to blocks.

0 commit comments

Comments
 (0)