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

chore: move tx errors #13288

Merged
merged 2 commits into from
Dec 11, 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
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Various error variants that can happen when working with transactions.

use crate::GotExpectedBoxed;
use alloy_primitives::U256;

/// Represents error variants that can happen when trying to validate a
/// [Transaction](crate::Transaction)
/// Represents error variants that can happen when trying to validate a transaction.
#[derive(Debug, Clone, Eq, PartialEq, derive_more::Display)]
pub enum InvalidTransactionError {
/// The sender does not have enough funds to cover the transaction fees
Expand Down Expand Up @@ -64,19 +65,17 @@ pub enum InvalidTransactionError {

impl core::error::Error for InvalidTransactionError {}

/// Represents error variants that can happen when trying to convert a transaction to
/// [`PooledTransactionsElement`](crate::PooledTransactionsElement)
/// Represents error variants that can happen when trying to convert a transaction to pooled
/// transaction.
#[derive(Debug, Clone, Eq, PartialEq, derive_more::Display, derive_more::Error)]
pub enum TransactionConversionError {
/// This error variant is used when a transaction cannot be converted into a
/// [`PooledTransactionsElement`](crate::PooledTransactionsElement) because it is not supported
/// for P2P network.
/// This error variant is used when a transaction cannot be converted into a pooled transaction
/// because it is not supported for P2P network.
#[display("Transaction is not supported for p2p")]
UnsupportedForP2P,
}

/// Represents error variants than can happen when trying to convert a
/// [`RecoveredTx`](crate::RecoveredTx) transaction.
/// Represents error variants than can happen when trying to convert a recovered transaction.
#[derive(Debug, Clone, Eq, PartialEq, derive_more::Display)]
pub enum TryFromRecoveredTransactionError {
/// Thrown if the transaction type is unsupported.
Expand Down
2 changes: 2 additions & 0 deletions crates/primitives-traits/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pub mod execute;
pub mod signed;
pub mod tx_type;

pub mod error;

use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
use core::{fmt, hash::Hash};

Expand Down
11 changes: 6 additions & 5 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ use signature::decode_with_eip155_chain_id;
use std::sync::{LazyLock, OnceLock};

pub use compat::FillTxEnv;
pub use error::{
InvalidTransactionError, TransactionConversionError, TryFromRecoveredTransactionError,
};
pub use meta::TransactionMeta;
pub use pooled::{PooledTransactionsElement, PooledTransactionsElementEcRecovered};
pub use reth_primitives_traits::WithEncoded;
pub use reth_primitives_traits::{
transaction::error::{
InvalidTransactionError, TransactionConversionError, TryFromRecoveredTransactionError,
},
WithEncoded,
};
pub use sidecar::BlobTransaction;
pub use signature::{recover_signer, recover_signer_unchecked};
pub use tx_type::TxType;
Expand All @@ -49,7 +51,6 @@ pub mod util;

pub(crate) mod access_list;
mod compat;
mod error;
mod meta;
mod pooled;
mod sidecar;
Expand Down
3 changes: 1 addition & 2 deletions crates/primitives/src/transaction/pooled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
//! response to `GetPooledTransactions`.

use super::{
error::TransactionConversionError, recover_signer_unchecked, signature::recover_signer,
TxEip7702,
recover_signer_unchecked, signature::recover_signer, TransactionConversionError, TxEip7702,
};
use crate::{BlobTransaction, RecoveredTx, Transaction, TransactionSigned, TxType};
use alloc::vec::Vec;
Expand Down
Loading