Skip to content
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
5 changes: 5 additions & 0 deletions anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,11 @@ pub enum TypedTransaction {
// == impl TypedTransaction ==

impl TypedTransaction {
/// Returns true if the transaction uses dynamic fees: EIP1559
pub fn is_dynamic_fee(&self) -> bool {
matches!(self, TypedTransaction::EIP1559(_))
}

pub fn gas_price(&self) -> U256 {
match self {
TypedTransaction::Legacy(tx) => tx.gas_price,
Expand Down
3 changes: 1 addition & 2 deletions anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ pub fn transaction_build(
) -> Transaction {
let mut transaction: Transaction = eth_transaction.clone().into();

if let TypedTransaction::EIP1559(_) = eth_transaction.as_ref() {
if eth_transaction.is_dynamic_fee() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, this properly "inverts" the check that used to happen below with !is_eip1559

if block.is_none() && info.is_none() {
// transaction is not mined yet, gas price is considered just `max_fee_per_gas`
transaction.gas_price = transaction.max_fee_per_gas;
Expand All @@ -2264,7 +2264,6 @@ pub fn transaction_build(
} else {
transaction.max_fee_per_gas = None;
transaction.max_priority_fee_per_gas = None;
transaction.transaction_type = None;
}

transaction.block_hash =
Expand Down