Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag subscribe_logs as non-runnable, follow up for #59 #60

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
-e 'ws' \
-e 'ws_auth' \
-e 'connect_builtin' \
-e 'subscribe_logs' \
| xargs -n1 echo
)"

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
-e 'ws' \
-e 'ws_auth' \
-e 'connect_builtin' \
-e 'subscribe_logs' \
| xargs -n1 echo
)"

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ cargo run --example 2>&1 \
-e 'ws' \
-e 'ws_auth' \
-e 'connect_builtin' \
-e 'subscribe_logs' \
| xargs -I {} sh -c 'if cargo run --example {} --quiet 1>/dev/null; then \
echo "Successfully ran: {}"; \
else \
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ This repository contains the following examples:
- [x] [Signer management filler](./examples/fillers/examples/signer_filler.rs)
- [x] Subscriptions
- [x] [Subscribe and watch blocks](./examples/subscriptions/examples/subscribe_blocks.rs)
- [x] [Subscribe to contract events and watch logs](./examples/subscriptions/examples/watch_contract_event.rs)
- [x] [Watch and poll for contract event logs](./examples/subscriptions/examples/poll_logs.rs)
- [x] [Subscribe and listen for contract event logs](./examples/subscriptions/examples/subscribe_logs.rs)
- [x] [Event multiplexer](./examples/subscriptions/examples/event_multiplexer.rs)
- [x] Providers
- [x] [Builder](./examples/providers/examples/builder.rs)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Example of subscribing to blocks and watching contract events by WebSocket subscription.
//! Example of watching and polling for contract events by WebSocket subscription.

use alloy::{node_bindings::Anvil, providers::ProviderBuilder, rpc::client::WsConnect, sol};
use eyre::Result;
Expand Down Expand Up @@ -58,7 +58,7 @@ async fn main() -> Result<()> {
let _ = decrement_call.send().await?;
}

// Listen for the events.
// Poll for logs.
increment_filter
.into_stream()
.take(2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Example of subscribing to logs from the Ethereum network using an external provider.
//! Example of subscribing and listening for contract events by WebSocket subscription.

use alloy::{
primitives::{address, b256},
Expand All @@ -13,6 +13,14 @@ use futures_util::stream::StreamExt;

#[tokio::main]
async fn main() -> Result<()> {
// Set up the WS transport which is consumed by the RPC client.
let rpc_url = "wss://eth-mainnet.g.alchemy.com/v2/your-api-key";

// Create the provider.
let ws = WsConnect::new(rpc_url);
let provider = ProviderBuilder::new().on_ws(ws).await?;

// Create a filter to watch for Uniswap token transfers.
let uniswap_token_address = address!("1f9840a85d5aF5bf1D1762F925BDADdC4201F984");
let tranfer_event_signature =
b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef");
Expand All @@ -21,13 +29,8 @@ async fn main() -> Result<()> {
.event_signature(tranfer_event_signature)
.from_block(BlockNumberOrTag::Latest);

let rpc_url = "wss://eth.merkle.io"; // DON'T use wss://eth.merkle.io _> this filters wrongly, tested alchemy.io's to be working fine

// Create the provider.
let ws = WsConnect::new(rpc_url);
let provider = ProviderBuilder::new().on_ws(ws).await.unwrap();

let sub = provider.subscribe_logs(&filter).await.expect("Failed to subscribe to logs");
// Subscribe to logs.
let sub = provider.subscribe_logs(&filter).await?;
let mut stream = sub.into_stream();

while let Some(log) = stream.next().await {
Expand Down
Loading