From 322884bed7f700f479c547464d4937cf0edb647a Mon Sep 17 00:00:00 2001 From: Yash Atreya <44857776+yash-atreya@users.noreply.github.com> Date: Tue, 2 Jul 2024 20:00:34 +0530 Subject: [PATCH] feat(network): block context in ReceiptResponse --- crates/network/src/any/mod.rs | 8 ++++++++ crates/network/src/ethereum/mod.rs | 8 ++++++++ crates/network/src/lib.rs | 8 +++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/network/src/any/mod.rs b/crates/network/src/any/mod.rs index 1885e5835a9..8cc7bf2bbe1 100644 --- a/crates/network/src/any/mod.rs +++ b/crates/network/src/any/mod.rs @@ -84,6 +84,14 @@ impl ReceiptResponse for AnyTransactionReceipt { fn status(&self) -> bool { self.inner.inner.status() } + + fn block_hash(&self) -> Option { + self.inner.block_hash + } + + fn block_number(&self) -> Option { + self.inner.block_number + } } impl TransactionResponse for WithOtherFields { diff --git a/crates/network/src/ethereum/mod.rs b/crates/network/src/ethereum/mod.rs index 9bfe362c578..68729e3f0f9 100644 --- a/crates/network/src/ethereum/mod.rs +++ b/crates/network/src/ethereum/mod.rs @@ -40,6 +40,14 @@ impl ReceiptResponse for alloy_rpc_types_eth::TransactionReceipt { fn status(&self) -> bool { self.inner.status() } + + fn block_hash(&self) -> Option { + self.block_hash + } + + fn block_number(&self) -> Option { + self.block_number + } } impl TransactionResponse for alloy_rpc_types_eth::Transaction { diff --git a/crates/network/src/lib.rs b/crates/network/src/lib.rs index 0afa1f7f093..e0a63d2a233 100644 --- a/crates/network/src/lib.rs +++ b/crates/network/src/lib.rs @@ -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; @@ -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; + + /// Number of the block this transaction was included within. + fn block_number(&self) -> Option; } /// Transaction Response