@@ -2,11 +2,11 @@ use futures03::{future::BoxFuture, stream::FuturesUnordered};
22use graph:: abi;
33use graph:: abi:: DynSolValueExt ;
44use graph:: abi:: FunctionExt ;
5- use graph:: alloy_todo;
65use graph:: blockchain:: client:: ChainClient ;
76use graph:: blockchain:: BlockHash ;
87use graph:: blockchain:: ChainIdentifier ;
98use graph:: blockchain:: ExtendedBlockPtr ;
9+ use graph:: components:: ethereum:: * ;
1010use graph:: components:: transaction_receipt:: LightTransactionReceipt ;
1111use graph:: data:: store:: ethereum:: call;
1212use graph:: data:: store:: scalar;
@@ -52,7 +52,6 @@ use graph::{
5252 ChainStore , CheapClone , DynTryFuture , Error , EthereumCallCache , Logger , TimeoutError ,
5353 } ,
5454} ;
55- use graph:: { components:: ethereum:: * , prelude:: web3:: api:: Web3 } ;
5655use itertools:: Itertools ;
5756use std:: collections:: { BTreeMap , BTreeSet , HashMap , HashSet } ;
5857use std:: convert:: TryFrom ;
@@ -92,7 +91,6 @@ type AlloyProvider = FillProvider<
9291pub struct EthereumAdapter {
9392 logger : Logger ,
9493 provider : String ,
95- web3 : Arc < Web3 < Transport > > ,
9694 alloy : Arc < AlloyProvider > ,
9795 metrics : Arc < ProviderEthRpcMetrics > ,
9896 supports_eip_1898 : bool ,
@@ -105,7 +103,6 @@ impl std::fmt::Debug for EthereumAdapter {
105103 f. debug_struct ( "EthereumAdapter" )
106104 . field ( "logger" , & self . logger )
107105 . field ( "provider" , & self . provider )
108- . field ( "web3" , & self . web3 )
109106 . field ( "alloy" , & "<Provider>" )
110107 . field ( "metrics" , & self . metrics )
111108 . field ( "supports_eip_1898" , & self . supports_eip_1898 )
@@ -120,7 +117,6 @@ impl CheapClone for EthereumAdapter {
120117 Self {
121118 logger : self . logger . clone ( ) ,
122119 provider : self . provider . clone ( ) ,
123- web3 : self . web3 . cheap_clone ( ) ,
124120 alloy : self . alloy . clone ( ) ,
125121 metrics : self . metrics . cheap_clone ( ) ,
126122 supports_eip_1898 : self . supports_eip_1898 ,
@@ -143,28 +139,28 @@ impl EthereumAdapter {
143139 supports_eip_1898 : bool ,
144140 call_only : bool ,
145141 ) -> Self {
146- let rpc_url = match & transport {
147- Transport :: RPC {
148- client : _,
149- metrics : _,
150- provider : _,
151- url : rpc_url,
152- } => rpc_url. clone ( ) ,
153- Transport :: IPC ( _ipc) => alloy_todo ! ( ) ,
154- Transport :: WS ( _web_socket) => alloy_todo ! ( ) ,
142+ let alloy = match & transport {
143+ Transport :: RPC { client, .. } => Arc :: new (
144+ alloy:: providers:: ProviderBuilder :: new ( )
145+ . connect_client ( alloy:: rpc:: client:: RpcClient :: new ( client. clone ( ) , false ) ) ,
146+ ) ,
147+ Transport :: IPC ( ipc_connect) => Arc :: new (
148+ alloy:: providers:: ProviderBuilder :: new ( )
149+ . connect_ipc ( ipc_connect. clone ( ) )
150+ . await
151+ . unwrap ( ) ,
152+ ) ,
153+ Transport :: WS ( ws_connect) => Arc :: new (
154+ alloy:: providers:: ProviderBuilder :: new ( )
155+ . connect_ws ( ws_connect. clone ( ) )
156+ . await
157+ . unwrap ( ) ,
158+ ) ,
155159 } ;
156- let web3 = Arc :: new ( Web3 :: new ( transport) ) ;
157- let alloy = Arc :: new (
158- alloy:: providers:: ProviderBuilder :: new ( )
159- . connect ( & rpc_url)
160- . await
161- . unwrap ( ) ,
162- ) ;
163160
164161 EthereumAdapter {
165162 logger,
166163 provider,
167- web3,
168164 alloy,
169165 metrics : provider_metrics,
170166 supports_eip_1898,
@@ -305,7 +301,7 @@ impl EthereumAdapter {
305301 // cached. The result is not used for anything critical, so it is fine to be lazy.
306302 async fn check_block_receipt_support_and_update_cache (
307303 & self ,
308- alloy : Arc < dyn alloy :: providers :: Provider > ,
304+ alloy : Arc < dyn Provider > ,
309305 block_hash : B256 ,
310306 supports_eip_1898 : bool ,
311307 call_only : bool ,
@@ -2156,7 +2152,7 @@ async fn filter_call_triggers_from_unsuccessful_transactions(
21562152
21572153/// Deprecated. Wraps the [`fetch_transaction_receipts_in_batch`] in a retry loop.
21582154async fn fetch_transaction_receipts_in_batch_with_retry (
2159- alloy : Arc < dyn alloy :: providers :: Provider > ,
2155+ alloy : Arc < dyn Provider > ,
21602156 hashes : Vec < B256 > ,
21612157 block_hash : B256 ,
21622158 logger : Logger ,
@@ -2182,7 +2178,7 @@ async fn fetch_transaction_receipts_in_batch_with_retry(
21822178
21832179/// Deprecated. Attempts to fetch multiple transaction receipts in a batching context.
21842180async fn fetch_transaction_receipts_in_batch (
2185- alloy : Arc < dyn alloy :: providers :: Provider > ,
2181+ alloy : Arc < dyn Provider > ,
21862182 hashes : Vec < B256 > ,
21872183 block_hash : B256 ,
21882184 logger : Logger ,
@@ -2212,7 +2208,7 @@ async fn fetch_transaction_receipts_in_batch(
22122208}
22132209
22142210async fn batch_get_transaction_receipts (
2215- provider : Arc < dyn alloy :: providers :: Provider > ,
2211+ provider : Arc < dyn Provider > ,
22162212 tx_hashes : Vec < B256 > ,
22172213) -> Result < Vec < Option < alloy:: rpc:: types:: TransactionReceipt > > , Box < dyn std:: error:: Error > > {
22182214 let mut batch = alloy:: rpc:: client:: BatchRequest :: new ( provider. client ( ) ) ;
@@ -2242,7 +2238,7 @@ async fn batch_get_transaction_receipts(
22422238}
22432239
22442240pub ( crate ) async fn check_block_receipt_support (
2245- alloy : Arc < dyn alloy :: providers :: Provider > ,
2241+ alloy : Arc < dyn Provider > ,
22462242 block_hash : B256 ,
22472243 supports_eip_1898 : bool ,
22482244 call_only : bool ,
@@ -2271,7 +2267,7 @@ pub(crate) async fn check_block_receipt_support(
22712267// based on whether block receipts are supported or individual transaction receipts
22722268// need to be fetched.
22732269async fn fetch_receipts_with_retry (
2274- alloy : Arc < dyn alloy :: providers :: Provider > ,
2270+ alloy : Arc < dyn Provider > ,
22752271 hashes : Vec < B256 > ,
22762272 block_hash : B256 ,
22772273 logger : Logger ,
@@ -2285,7 +2281,7 @@ async fn fetch_receipts_with_retry(
22852281
22862282// Fetches receipts for each transaction in the block individually.
22872283async fn fetch_individual_receipts_with_retry (
2288- alloy : Arc < dyn alloy :: providers :: Provider > ,
2284+ alloy : Arc < dyn Provider > ,
22892285 hashes : Vec < B256 > ,
22902286 block_hash : B256 ,
22912287 logger : Logger ,
@@ -2316,7 +2312,7 @@ async fn fetch_individual_receipts_with_retry(
23162312
23172313/// Fetches transaction receipts of all transactions in a block with `eth_getBlockReceipts` call.
23182314async fn fetch_block_receipts_with_retry (
2319- alloy : Arc < dyn alloy :: providers :: Provider > ,
2315+ alloy : Arc < dyn Provider > ,
23202316 hashes : Vec < B256 > ,
23212317 block_hash : B256 ,
23222318 logger : Logger ,
@@ -2361,7 +2357,7 @@ async fn fetch_block_receipts_with_retry(
23612357
23622358/// Retries fetching a single transaction receipt using alloy, then converts to web3 format.
23632359async fn fetch_transaction_receipt_with_retry (
2364- alloy : Arc < dyn alloy :: providers :: Provider > ,
2360+ alloy : Arc < dyn Provider > ,
23652361 transaction_hash : B256 ,
23662362 block_hash : B256 ,
23672363 logger : Logger ,
0 commit comments