Skip to content

Commit

Permalink
Merge branch 'main' into fix/gh-1681-uninstall_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
eshaan7 authored Nov 25, 2024
2 parents 9451e73 + da2e5d0 commit a7eff85
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/provider/src/provider/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ pub trait Provider<T: Transport + Clone = BoxTransport, N: Network = Ethereum>:
.map(|opt_count: Option<U64>| opt_count.map(|count| count.to::<u64>()))
}

/// Returns the number of transactions in a block matching the given block number.
async fn get_block_transaction_count_by_number(
&self,
block_number: BlockNumberOrTag,
) -> TransportResult<Option<u64>> {
self.client()
.request("eth_getBlockTransactionCountByNumber", (block_number,))
.await
.map(|opt_count: Option<U64>| opt_count.map(|count| count.to::<u64>()))
}

/// Gets the selected block [BlockId] receipts.
fn get_block_receipts(
&self,
Expand Down Expand Up @@ -1719,6 +1730,14 @@ mod tests {
assert!(tx_count.is_some());
}

#[tokio::test]
async fn gets_block_transaction_count_by_number() {
let provider = ProviderBuilder::new().on_anvil();
let tx_count =
provider.get_block_transaction_count_by_number(BlockNumberOrTag::Latest).await.unwrap();
assert!(tx_count.is_some());
}

#[tokio::test]
async fn gets_block_receipts() {
let provider = ProviderBuilder::new().on_anvil();
Expand Down

0 comments on commit a7eff85

Please sign in to comment.