Skip to content

Commit

Permalink
feat(network): block context in ReceiptResponse (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-atreya authored Jul 2, 2024
1 parent 735c73a commit 3cbefdd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions crates/network/src/any/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ impl ReceiptResponse for AnyTransactionReceipt {
fn status(&self) -> bool {
self.inner.inner.status()
}

fn block_hash(&self) -> Option<alloy_primitives::BlockHash> {
self.inner.block_hash
}

fn block_number(&self) -> Option<u64> {
self.inner.block_number
}
}

impl TransactionResponse for WithOtherFields<Transaction> {
Expand Down
8 changes: 8 additions & 0 deletions crates/network/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ impl ReceiptResponse for alloy_rpc_types_eth::TransactionReceipt {
fn status(&self) -> bool {
self.inner.status()
}

fn block_hash(&self) -> Option<alloy_primitives::BlockHash> {
self.block_hash
}

fn block_number(&self) -> Option<u64> {
self.block_number
}
}

impl TransactionResponse for alloy_rpc_types_eth::Transaction {
Expand Down
8 changes: 7 additions & 1 deletion crates/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use alloy_consensus::TxReceipt;
use alloy_eips::eip2718::{Eip2718Envelope, Eip2718Error};
use alloy_json_rpc::RpcObject;
use alloy_primitives::{Address, Bytes, TxHash, U256};
use alloy_primitives::{Address, BlockHash, Bytes, TxHash, U256};
use core::fmt::{Debug, Display};

mod transaction;
Expand Down Expand Up @@ -49,6 +49,12 @@ pub trait ReceiptResponse {
/// [EIP-658]: https://eips.ethereum.org/EIPS/eip-658
/// [`TxReceipt::status_or_post_state`]: alloy_consensus::TxReceipt::status_or_post_state
fn status(&self) -> bool;

/// Hash of the block this transaction was included within.
fn block_hash(&self) -> Option<BlockHash>;

/// Number of the block this transaction was included within.
fn block_number(&self) -> Option<u64>;
}

/// Transaction Response
Expand Down

0 comments on commit 3cbefdd

Please sign in to comment.