Skip to content

Commit e57acef

Browse files
authored
Update fillers.mdx (#150)
Updated `prepare` function call to match the function signature from the UrgentFiller.rs in examples repository.
1 parent 59a07db commit e57acef

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

vocs/docs/pages/guides/fillers.mdx

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -209,42 +209,36 @@ impl<N: Network> TxFiller<N> for UrgentQueue {
209209
Ok(tx)
210210
}
211211

212-
async fn prepare<P, T>(
212+
async fn prepare<P>(
213213
&self,
214214
_provider: &P,
215215
_tx: &<N as Network>::TransactionRequest,
216216
) -> TransportResult<Self::Fillable>
217217
where
218-
P: Provider<T, N>,
219-
T: Transport + Clone,
218+
P: Provider<N>,
220219
{
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+
};
237234
let body = data.text().await.unwrap();
238235
let json = serde_json::from_str::<serde_json::Value>(&body).unwrap();
239236
let prices = &json["blockPrices"][0]["estimatedPrices"][0];
240237
let max_fee_per_gas = (prices["maxFeePerGas"].as_f64().unwrap() * 1e9) as u128;
241238
let max_priority_fee_per_gas =
242239
(prices["maxPriorityFeePerGas"].as_f64().unwrap() * 1e9) 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 };
248242
Ok(fillable)
249243
}
250244
}

0 commit comments

Comments
 (0)