eigen_testing_utils/
transaction.rs

1use alloy::primitives::FixedBytes;
2use alloy::providers::{PendingTransactionBuilder, PendingTransactionError, ProviderBuilder};
3use alloy::rpc::types::eth::TransactionReceipt;
4use alloy::transports::TransportErrorKind;
5use url::Url;
6
7/// Wait for a transaction to finish and return its receipt.
8///
9/// # Arguments
10///
11/// `rpc_url` - The RPC URL.
12/// `tx_hash` - The hash of the transaction.
13///
14/// # Returns
15///
16/// A [`TransactionReceipt`] containing the transaction receipt.
17pub async fn wait_transaction(
18    rpc_url: &str,
19    tx_hash: FixedBytes<32>,
20) -> Result<TransactionReceipt, PendingTransactionError> {
21    let url = Url::parse(rpc_url).map_err(|_| TransportErrorKind::custom_str("Invalid RPC URL"))?;
22    let root_provider = ProviderBuilder::new()
23        .disable_recommended_fillers()
24        .connect_http(url);
25    let pending_tx = PendingTransactionBuilder::new(root_provider, tx_hash);
26    pending_tx.get_receipt().await
27}