1
1
use alloy:: {
2
- primitives:: { address , Address } ,
2
+ primitives:: Address ,
3
3
providers:: { Provider , ProviderBuilder , WsConnect } ,
4
4
rpc:: types:: { BlockNumberOrTag , Filter , ValueOrArray , Log } ,
5
5
} ;
@@ -10,8 +10,8 @@ use hex_literal::hex;
10
10
11
11
#[ tokio:: main]
12
12
async fn main ( ) -> Result < ( ) > {
13
- let rpc_url_chain1 = "wss://sepolia.infura.io/ws/v3/8dd4a35393c04ed8a4c1c563c8ea099e" ; // Replace with your actual URL
14
- let rpc_url_chain2 = "wss://polygon-amoy.infura.io/ws/v3/8dd4a35393c04ed8a4c1c563c8ea099e" ; // Replace with your actual URL
13
+ let rpc_url_chain1 = "wss://sepolia.infura.io/ws/v3/8dd4a35393c04ed8a4c1c563c8ea099e" ;
14
+ let rpc_url_chain2 = "wss://polygon-amoy.infura.io/ws/v3/8dd4a35393c04ed8a4c1c563c8ea099e" ;
15
15
16
16
let ws_chain1 = WsConnect :: new ( rpc_url_chain1) ;
17
17
let ws_chain2 = WsConnect :: new ( rpc_url_chain2) ;
@@ -21,18 +21,13 @@ async fn main() -> Result<()> {
21
21
22
22
let contract_address: Address = Address :: from ( hex ! ( "8c6faf12a32462f5f2f5282821fe9e789e6d82e7" ) ) ;
23
23
24
- let filter_chain1 = Filter :: new ( )
24
+ let filter_chain = Filter :: new ( )
25
25
. address ( ValueOrArray :: Value ( contract_address) )
26
26
. event ( "Generate(uint256,uint256)" )
27
27
. from_block ( BlockNumberOrTag :: Latest ) ;
28
28
29
- let filter_chain2 = Filter :: new ( )
30
- . address ( ValueOrArray :: Value ( contract_address) )
31
- . event ( "Generate(uint256,uint256)" )
32
- . from_block ( BlockNumberOrTag :: Latest ) ;
33
-
34
- let sub_chain1 = provider_chain1. subscribe_logs ( & filter_chain1) . await ?;
35
- let sub_chain2 = provider_chain2. subscribe_logs ( & filter_chain2) . await ?;
29
+ let sub_chain1 = provider_chain1. subscribe_logs ( & filter_chain) . await ?;
30
+ let sub_chain2 = provider_chain2. subscribe_logs ( & filter_chain) . await ?;
36
31
37
32
let mut stream_chain1 = sub_chain1. into_stream ( ) ;
38
33
let mut stream_chain2 = sub_chain2. into_stream ( ) ;
0 commit comments