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

network: Add status method to ReceiptResponse trait #846

Merged
merged 5 commits into from
Jun 12, 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
4 changes: 4 additions & 0 deletions crates/network/src/any/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ impl ReceiptResponse for AnyTransactionReceipt {
fn contract_address(&self) -> Option<alloy_primitives::Address> {
self.contract_address
}

fn status(&self) -> bool {
self.inner.inner.status()
}
}

impl TransactionResponse for WithOtherFields<Transaction> {
Expand Down
4 changes: 4 additions & 0 deletions crates/network/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ impl ReceiptResponse for alloy_rpc_types_eth::TransactionReceipt {
fn contract_address(&self) -> Option<alloy_primitives::Address> {
self.contract_address
}

fn status(&self) -> bool {
self.inner.status()
}
}

impl TransactionResponse for alloy_rpc_types_eth::Transaction {
Expand Down
15 changes: 15 additions & 0 deletions crates/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ pub use alloy_eips::eip2718;
pub trait ReceiptResponse {
/// Address of the created contract, or `None` if the transaction was not a deployment.
fn contract_address(&self) -> Option<Address>;

/// Status of the transaction.
///
/// ## Note
///
/// Caution must be taken when using this method for deep-historical
/// receipts, as it may not accurately reflect the status of the
/// transaction. The transaction status is not knowable from the receipt
/// for transactions before [EIP-658].
///
/// This can be handled using [`TxReceipt::status_or_post_state`].
///
/// [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;
}

/// Transaction Response
Expand Down