Skip to content

Commit 5ba3cdd

Browse files
authored
Update receipts.rs
1 parent 9232f69 commit 5ba3cdd

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

crates/script/src/receipts.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,27 @@ pub async fn check_tx_status(
3737
.get_receipt()
3838
.await
3939
{
40-
Ok(receipt) => Ok(receipt.into()),
40+
Ok(receipt) => {
41+
// Check if the receipt has valid block information
42+
if receipt.block_number.is_none() || receipt.block_hash.is_none() || receipt.transaction_index.is_none() {
43+
// Receipt is empty, possibly due to RPC discarding the transaction
44+
match provider.get_transaction_by_hash(hash).await {
45+
Ok(_) => {
46+
// Transaction is still known to the node, so we should wait
47+
Err(RetryError::Continue(eyre!(
48+
"Received an empty receipt for {hash}, but transaction is still known to the node, waiting for full receipt"
49+
)))
50+
}
51+
Err(_) => {
52+
// Transaction is not known to the node, mark it as dropped
53+
Ok(TxStatus::Dropped)
54+
}
55+
}
56+
} else {
57+
// Receipt has valid block information, proceed normally
58+
Ok(receipt.into())
59+
}
60+
}
4161
Err(e) => match provider.get_transaction_by_hash(hash).await {
4262
Ok(_) => match e {
4363
PendingTransactionError::TxWatcher(WatchTxError::Timeout) => {

0 commit comments

Comments
 (0)