@@ -209,42 +209,36 @@ impl<N: Network> TxFiller<N> for UrgentQueue {
209
209
Ok (tx )
210
210
}
211
211
212
- async fn prepare <P , T >(
212
+ async fn prepare <P >(
213
213
& self ,
214
214
_provider : & P ,
215
215
_tx : & <N as Network >:: TransactionRequest ,
216
216
) -> TransportResult <Self :: Fillable >
217
217
where
218
- P : Provider <T , N >,
219
- T : Transport + Clone ,
218
+ P : Provider <N >,
220
219
{
221
- let data = match self
222
- . client
223
- . get (" https://api.blocknative.com/gasprices/blockprices" )
224
- . send ()
225
- . await
226
- {
227
- Ok (res ) => res ,
228
- Err (e ) => {
229
- return Err (RpcError :: Transport (TransportErrorKind :: Custom (Box :: new (
230
- std :: io :: Error :: new (
231
- std :: io :: ErrorKind :: Other ,
232
- format! (" Failed to fetch gas price, {}" , e ),
233
- ),
234
- ))));
235
- }
236
- };
220
+ println! (" Fetching gas prices from Blocknative" );
221
+ let data =
222
+ match self . client. get (" https://api.blocknative.com/gasprices/blockprices" ). send (). await
223
+ {
224
+ Ok (res ) => res ,
225
+ Err (e ) => {
226
+ return Err (RpcError :: Transport (TransportErrorKind :: Custom (Box :: new (
227
+ std :: io :: Error :: new (
228
+ std :: io :: ErrorKind :: Other ,
229
+ format! (" Failed to fetch gas price, {}" , e ),
230
+ ),
231
+ ))));
232
+ }
233
+ };
237
234
let body = data . text (). await . unwrap ();
238
235
let json = serde_json :: from_str :: <serde_json :: Value >(& body ). unwrap ();
239
236
let prices = & json [" blockPrices" ][0 ][" estimatedPrices" ][0 ];
240
237
let max_fee_per_gas = (prices [" maxFeePerGas" ]. as_f64 (). unwrap () * 1e 9 ) as u128 ;
241
238
let max_priority_fee_per_gas =
242
239
(prices [" maxPriorityFeePerGas" ]. as_f64 (). unwrap () * 1e 9 ) as u128 ;
243
-
244
- let fillable = GasPriceFillable {
245
- max_fee_per_gas ,
246
- max_priority_fee_per_gas ,
247
- };
240
+
241
+ let fillable = GasPriceFillable { max_fee_per_gas , max_priority_fee_per_gas };
248
242
Ok (fillable )
249
243
}
250
244
}
0 commit comments