Skip to content

Commit bd42484

Browse files
committed
refactor(anvil): remove TypedTransaction::essentials() method
1 parent d9f47a7 commit bd42484

File tree

2 files changed

+3
-93
lines changed
  • crates/anvil

2 files changed

+3
-93
lines changed

crates/anvil/core/src/eth/transaction/mod.rs

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -492,96 +492,6 @@ impl TypedTransaction {
492492
}
493493
}
494494

495-
/// Returns a helper type that contains commonly used values as fields
496-
pub fn essentials(&self) -> TransactionEssentials {
497-
match self {
498-
Self::Legacy(t) => TransactionEssentials {
499-
kind: t.tx().to,
500-
input: t.tx().input.clone(),
501-
nonce: t.tx().nonce,
502-
gas_limit: t.tx().gas_limit,
503-
gas_price: Some(t.tx().gas_price),
504-
max_fee_per_gas: None,
505-
max_priority_fee_per_gas: None,
506-
max_fee_per_blob_gas: None,
507-
blob_versioned_hashes: None,
508-
value: t.tx().value,
509-
chain_id: t.tx().chain_id,
510-
access_list: Default::default(),
511-
},
512-
Self::EIP2930(t) => TransactionEssentials {
513-
kind: t.tx().to,
514-
input: t.tx().input.clone(),
515-
nonce: t.tx().nonce,
516-
gas_limit: t.tx().gas_limit,
517-
gas_price: Some(t.tx().gas_price),
518-
max_fee_per_gas: None,
519-
max_priority_fee_per_gas: None,
520-
max_fee_per_blob_gas: None,
521-
blob_versioned_hashes: None,
522-
value: t.tx().value,
523-
chain_id: Some(t.tx().chain_id),
524-
access_list: t.tx().access_list.clone(),
525-
},
526-
Self::EIP1559(t) => TransactionEssentials {
527-
kind: t.tx().to,
528-
input: t.tx().input.clone(),
529-
nonce: t.tx().nonce,
530-
gas_limit: t.tx().gas_limit,
531-
gas_price: None,
532-
max_fee_per_gas: Some(t.tx().max_fee_per_gas),
533-
max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas),
534-
max_fee_per_blob_gas: None,
535-
blob_versioned_hashes: None,
536-
value: t.tx().value,
537-
chain_id: Some(t.tx().chain_id),
538-
access_list: t.tx().access_list.clone(),
539-
},
540-
Self::EIP4844(t) => TransactionEssentials {
541-
kind: TxKind::Call(t.tx().tx().to),
542-
input: t.tx().tx().input.clone(),
543-
nonce: t.tx().tx().nonce,
544-
gas_limit: t.tx().tx().gas_limit,
545-
gas_price: None,
546-
max_fee_per_gas: Some(t.tx().tx().max_fee_per_gas),
547-
max_priority_fee_per_gas: Some(t.tx().tx().max_priority_fee_per_gas),
548-
max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas),
549-
blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()),
550-
value: t.tx().tx().value,
551-
chain_id: Some(t.tx().tx().chain_id),
552-
access_list: t.tx().tx().access_list.clone(),
553-
},
554-
Self::EIP7702(t) => TransactionEssentials {
555-
kind: TxKind::Call(t.tx().to),
556-
input: t.tx().input.clone(),
557-
nonce: t.tx().nonce,
558-
gas_limit: t.tx().gas_limit,
559-
gas_price: None,
560-
max_fee_per_gas: Some(t.tx().max_fee_per_gas),
561-
max_priority_fee_per_gas: Some(t.tx().max_priority_fee_per_gas),
562-
max_fee_per_blob_gas: None,
563-
blob_versioned_hashes: None,
564-
value: t.tx().value,
565-
chain_id: Some(t.tx().chain_id),
566-
access_list: t.tx().access_list.clone(),
567-
},
568-
Self::Deposit(t) => TransactionEssentials {
569-
kind: t.to,
570-
input: t.input.clone(),
571-
nonce: 0,
572-
gas_limit: t.gas_limit,
573-
gas_price: Some(0),
574-
max_fee_per_gas: None,
575-
max_priority_fee_per_gas: None,
576-
max_fee_per_blob_gas: None,
577-
blob_versioned_hashes: None,
578-
value: t.value,
579-
chain_id: t.chain_id(),
580-
access_list: Default::default(),
581-
},
582-
}
583-
}
584-
585495
pub fn as_legacy(&self) -> Option<&Signed<TxLegacy>> {
586496
match self {
587497
Self::Legacy(tx) => Some(tx),

crates/anvil/src/eth/backend/mem/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3752,8 +3752,8 @@ impl TransactionValidator for Backend {
37523752
return Err(InvalidTransactionError::FeeCapTooLow);
37533753
}
37543754

3755-
if let (Some(max_priority_fee_per_gas), Some(max_fee_per_gas)) =
3756-
(tx.essentials().max_priority_fee_per_gas, tx.essentials().max_fee_per_gas)
3755+
if let (Some(max_priority_fee_per_gas), max_fee_per_gas) =
3756+
(tx.as_ref().max_priority_fee_per_gas(), tx.as_ref().max_fee_per_gas())
37573757
&& max_priority_fee_per_gas > max_fee_per_gas
37583758
{
37593759
warn!(target: "backend", "max priority fee per gas={}, too high, max fee per gas={}", max_priority_fee_per_gas, max_fee_per_gas);
@@ -3764,7 +3764,7 @@ impl TransactionValidator for Backend {
37643764
// EIP-4844 blob fee validation
37653765
if env.evm_env.cfg_env.spec >= SpecId::CANCUN
37663766
&& tx.transaction.is_eip4844()
3767-
&& let Some(max_fee_per_blob_gas) = tx.essentials().max_fee_per_blob_gas
3767+
&& let Some(max_fee_per_blob_gas) = tx.as_ref().max_fee_per_blob_gas()
37683768
&& let Some(blob_gas_and_price) = &env.evm_env.block_env.blob_excess_gas_and_price
37693769
&& max_fee_per_blob_gas < blob_gas_and_price.blob_gasprice
37703770
{

0 commit comments

Comments
 (0)