1//! Support for validating transactions at certain stages
23use crate::eth::error::{BlockchainError, InvalidTransactionError};
4use anvil_core::eth::transaction::PendingTransaction;
5use foundry_evm::revm::primitives::{AccountInfo, EnvWithHandlerCfg};
67/// A trait for validating transactions
8#[async_trait::async_trait]
9pub trait TransactionValidator {
10/// Validates the transaction's validity when it comes to nonce, payment
11 ///
12 /// This is intended to be checked before the transaction makes it into the pool and whether it
13 /// should rather be outright rejected if the sender has insufficient funds.
14async fn validate_pool_transaction(
15&self,
16 tx: &PendingTransaction,
17 ) -> Result<(), BlockchainError>;
1819/// Validates the transaction against a specific account before entering the pool
20fn validate_pool_transaction_for(
21&self,
22 tx: &PendingTransaction,
23 account: &AccountInfo,
24 env: &EnvWithHandlerCfg,
25 ) -> Result<(), InvalidTransactionError>;
2627/// Validates the transaction against a specific account
28 ///
29 /// This should succeed if the transaction is ready to be executed
30fn validate_for(
31&self,
32 tx: &PendingTransaction,
33 account: &AccountInfo,
34 env: &EnvWithHandlerCfg,
35 ) -> Result<(), InvalidTransactionError>;
36}