Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(network): block context in ReceiptResponse #1003

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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